Skip to content

Commit

Permalink
Betterer P2P Integration
Browse files Browse the repository at this point in the history
Advanced Memory Card:
- Interface P2P Support
- Allow changing Input/Output via right click menu
- Two New Modes
- New Colors, separating input(s) and output(s)
- Bug Fixes, especially relating to renaming and multiple inputs
  • Loading branch information
IntegerLimit committed Aug 24, 2024
1 parent 501c910 commit 31ba721
Show file tree
Hide file tree
Showing 41 changed files with 1,317 additions and 84 deletions.
11 changes: 11 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ dependencies {
// CoFH Core (compile time dep of Thermal Foundation) (from CurseForge)
compileOnly "curse.maven:cofh-core-69162:2920433" // Version 4.6.6.1

// Betterer P2P (from CurseForge)
compileOnly rfg.deobf("curse.maven:betterer-p2p-943734:4928154") // Version 1.3.2

// Forgelin (dep of Betterer P2P) (from CurseForge)
compileOnly "curse.maven:shadowfacts-forgelin-248453:2785465" // Version 1.8.4

/* -------------------------------- Soft Deps, Multiple Runtime Declaration -------------------------------- */
if (project.enable_draconic.toBoolean() || project.enable_thermal.toBoolean()) {
runtimeOnly "curse.maven:redstone-flux-270789:2920436" // Version 2.1.1.1
Expand Down Expand Up @@ -209,6 +215,11 @@ dependencies {
runtimeOnly "curse.maven:nae2-884359:5380800" // Version 1.6.4
}

if (project.enable_better_p2p.toBoolean()) {
runtimeOnly "curse.maven:shadowfacts-forgelin-248453:2785465" // Version 1.8.4
runtimeOnly "curse.maven:betterer-p2p-943734:4928154" // Version 1.3.2
}

if (project.enable_dme.toBoolean()) {
// Dep: Patchouli
runtimeOnly "curse.maven:patchouli-306770:3162874" // Version 1.0-23.6
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ enable_ae2 = false
# Whether to enable NAE2 in runtime. Requires enable_ae2 to be true.
enable_nae2 = false

# Whether to enable Betterer P2P in runtime. Requires enable_ae2 to be true.
enable_better_p2p = false

# Whether to enable DME in runtime. Enables the DME Sim Chamber.
enable_dme = false

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.nomiceu.nomilabs.gregtech;
package com.nomiceu.nomilabs;

import static gregtech.api.GregTechAPI.soundManager;

import net.minecraft.util.SoundEvent;

import com.nomiceu.nomilabs.LabsValues;

public class LabsSounds {

public static SoundEvent MICROVERSE;
Expand Down
61 changes: 61 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/LabsTextures.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.nomiceu.nomilabs;

import com.nomiceu.nomilabs.util.LabsNames;

import gregtech.api.gui.resources.TextureArea;
import gregtech.client.renderer.texture.cube.OrientedOverlayRenderer;
import gregtech.client.renderer.texture.cube.SimpleOverlayRenderer;

public class LabsTextures {

/* Overlays (Machine) */
public static OrientedOverlayRenderer GROWTH_CHAMBER_OVERLAY;

/* Overlays (Casings) */
public static SimpleOverlayRenderer MICROVERSE_CASING;

/* Recipe Map Textures */
public static TextureArea PROGRESS_BAR_ROCKET;

/* Gui Textures */
public static TextureArea[] P2P_CUSTOM_MODES;
public static TextureArea P2P_INPUT_ICON;
public static TextureArea P2P_OUTPUT_ICON;

public static void preInit() {
GROWTH_CHAMBER_OVERLAY = new OrientedOverlayRenderer("nomilabs:multiblock/growth_chamber");
MICROVERSE_CASING = new SimpleOverlayRenderer("nomilabs:microverse_casing");
PROGRESS_BAR_ROCKET = labsFullImage("textures/gui/progress_bar/progress_bar_rocket.png");

var imageSizeX = 64;
var imageSizeY = 32;
var imageLoc = "textures/gui/advanced_memory_card/custom_modes.png";
var spriteSize = 32;
P2P_CUSTOM_MODES = new TextureArea[] {
labsAreaImage(imageLoc, imageSizeX, imageSizeY, 0, 0, spriteSize, spriteSize),
labsAreaImage(imageLoc, imageSizeX, imageSizeY, spriteSize, 0, spriteSize, spriteSize),
};

P2P_INPUT_ICON = labsFullImage("textures/gui/advanced_memory_card/input.png");
P2P_OUTPUT_ICON = labsFullImage("textures/gui/advanced_memory_card/output.png");
}

/**
* Like the one in TextureArea, but with Labs Registry.
*/
public static TextureArea labsFullImage(String imageLocation) {
return new TextureArea(LabsNames.makeLabsName(imageLocation), 0.0, 0.0, 1.0, 1.0);
}

/**
* Almost like the one in TextureArea, but with Labs Registry.
*/
public static TextureArea labsAreaImage(String imageLocation, int imageSizeX, int imageSizeY, int u, int v,
int width, int height) {
return new TextureArea(LabsNames.makeLabsName(imageLocation),
u / (imageSizeX * 1.0),
v / (imageSizeY * 1.0),
width / (imageSizeX * 1.0),
height / (imageSizeY * 1.0));
}
}
1 change: 1 addition & 0 deletions src/main/java/com/nomiceu/nomilabs/LabsValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ public class LabsValues {
public static final String AE2_STUFF_MODID = "ae2stuff";
public static final String BOGOSORT_MODID = "bogosorter";
public static final String THERMAL_FOUNDATION_MODID = "thermalfoundation";
public static final String BETTER_P2P_MODID = "betterp2p";
}
3 changes: 2 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public class LabsLateMixin implements ILateMixinLoader {
new AbstractMap.SimpleImmutableEntry<>(LabsValues.AA_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.BOGOSORT_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.THERMAL_FOUNDATION_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.BQU_MODID, true))
new AbstractMap.SimpleImmutableEntry<>(LabsValues.BQU_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.BETTER_P2P_MODID, true))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

@Override
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/event/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
import net.minecraftforge.fml.relauncher.SideOnly;

import com.cleanroommc.groovyscript.event.ScriptRunEvent;
import com.nomiceu.nomilabs.LabsTextures;
import com.nomiceu.nomilabs.LabsValues;
import com.nomiceu.nomilabs.NomiLabs;
import com.nomiceu.nomilabs.fluid.registry.LabsFluids;
import com.nomiceu.nomilabs.gregtech.LabsTextures;
import com.nomiceu.nomilabs.gregtech.block.registry.LabsMetaBlocks;
import com.nomiceu.nomilabs.integration.betterp2p.LabsBetterMemoryCardModes;
import com.nomiceu.nomilabs.integration.betterp2p.ModeDescriptionsHandler;
import com.nomiceu.nomilabs.integration.betterquesting.LabsTierHelper;
import com.nomiceu.nomilabs.item.registry.LabsItems;
import com.nomiceu.nomilabs.network.LabsNetworkHandler;
Expand Down Expand Up @@ -78,6 +80,13 @@ public static void addTooltipNormal(ItemTooltipEvent event) {
@SubscribeEvent
public static void languageChanged(LabsResourcesRefreshedEvent event) {
LabsTooltipHelper.onLanguageChange();

if (Loader.isModLoaded(LabsValues.BETTER_P2P_MODID)) {
// Make sure Modes is Loaded before Description Refresh
// Doesn't consume any resources or time if class already loaded
LabsBetterMemoryCardModes.preInit();
ModeDescriptionsHandler.refreshDescriptions();
}
}

@SubscribeEvent
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import com.cleanroommc.groovyscript.event.GsHandEvent;
import com.cleanroommc.groovyscript.event.ScriptRunEvent;
import com.nomiceu.nomilabs.LabsSounds;
import com.nomiceu.nomilabs.LabsValues;
import com.nomiceu.nomilabs.block.registry.LabsBlocks;
import com.nomiceu.nomilabs.config.LabsConfig;
import com.nomiceu.nomilabs.creativetab.registry.LabsCreativeTabs;
import com.nomiceu.nomilabs.dimension.LabsDimensions;
import com.nomiceu.nomilabs.fluid.FluidRegistryMixinHelper;
import com.nomiceu.nomilabs.fluid.registry.LabsFluids;
import com.nomiceu.nomilabs.gregtech.LabsSounds;
import com.nomiceu.nomilabs.gregtech.block.registry.LabsMetaBlocks;
import com.nomiceu.nomilabs.gregtech.material.registry.LabsMaterials;
import com.nomiceu.nomilabs.gregtech.metatileentity.registry.LabsMetaTileEntities;
Expand All @@ -39,6 +39,7 @@
import com.nomiceu.nomilabs.groovy.GroovyScriptHandManager;
import com.nomiceu.nomilabs.groovy.NCActiveCoolerHelper;
import com.nomiceu.nomilabs.integration.architecturecraft.LabsShapes;
import com.nomiceu.nomilabs.integration.betterp2p.LabsBetterMemoryCardModes;
import com.nomiceu.nomilabs.integration.jei.JEIPlugin;
import com.nomiceu.nomilabs.integration.top.LabsTOPManager;
import com.nomiceu.nomilabs.item.ItemExcitationCoil;
Expand Down Expand Up @@ -73,6 +74,9 @@ public static void preInit() {
LabsConfig.modIntegration.enableArchitectureCraftIntegration)
LabsShapes.preInit();

if (Loader.isModLoaded(LabsValues.BETTER_P2P_MODID))
LabsBetterMemoryCardModes.preInit();

LabsCreativeTabs.preInit();

if (LabsConfig.content.customContent.enableItems)
Expand Down
32 changes: 0 additions & 32 deletions src/main/java/com/nomiceu/nomilabs/gregtech/LabsTextures.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.nomiceu.nomilabs.gregtech.LabsTextures;
import com.nomiceu.nomilabs.LabsTextures;
import com.nomiceu.nomilabs.gregtech.block.BlockUniqueCasing;
import com.nomiceu.nomilabs.gregtech.block.registry.LabsMetaBlocks;
import com.nomiceu.nomilabs.gregtech.recipe.LabsRecipeMaps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.nomiceu.nomilabs.LabsTextures;
import com.nomiceu.nomilabs.LabsValues;
import com.nomiceu.nomilabs.block.registry.LabsBlocks;
import com.nomiceu.nomilabs.gregtech.LabsTextures;
import com.nomiceu.nomilabs.gregtech.metatileentity.registry.LabsMetaTileEntities;
import com.nomiceu.nomilabs.gregtech.recipe.LabsRecipeMaps;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import net.minecraftforge.fml.common.Loader;

import com.nomiceu.nomilabs.LabsSounds;
import com.nomiceu.nomilabs.LabsTextures;
import com.nomiceu.nomilabs.LabsValues;
import com.nomiceu.nomilabs.config.LabsConfig;
import com.nomiceu.nomilabs.gregtech.LabsSounds;
import com.nomiceu.nomilabs.gregtech.LabsTextures;
import com.nomiceu.nomilabs.util.LabsModeHelper;

import gregtech.api.gui.GuiTextures;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nomiceu.nomilabs.integration.betterp2p;

import com.projecturanus.betterp2p.network.data.P2PLocation;

import appeng.parts.p2p.PartP2PTunnel;

public interface AccessibleGridServerCache {

PartP2PTunnel<?> labs$changeIsInput(P2PLocation key, boolean isInput);

boolean labs$addInput(P2PLocation key, short sourceFrequency);

boolean labs$addOutput(P2PLocation key, short sourceFrequency);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nomiceu.nomilabs.integration.betterp2p;

import com.projecturanus.betterp2p.item.BetterMemoryCardModes;

public interface AccessibleGuiAdvancedMemoryCard {

BetterMemoryCardModes labs$getMode();

void labs$setMode(BetterMemoryCardModes mode);

void labs$syncMemoryInfo();

void labs$closeTypeSelector();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.nomiceu.nomilabs.integration.betterp2p;

public interface ExtendedITypeReceiver {

void acceptIsInput(boolean isInput);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.nomiceu.nomilabs.integration.betterp2p;

import java.util.Map;

import net.minecraftforge.common.util.EnumHelper;

import com.projecturanus.betterp2p.item.BetterMemoryCardModes;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;

public class LabsBetterMemoryCardModes {

/**
* Map of Mode to Labs ID.
*/
public static final Map<BetterMemoryCardModes, Integer> LABS_ADDED_MODES = new Object2ObjectOpenHashMap<>();

public static final BetterMemoryCardModes ADD_AS_INPUT = addMode(0, "ADD_AS_INPUT",
"nomilabs.gui.advanced_memory_card.mode.add_input",
"nomilabs.gui.advanced_memory_card.mode.add_input.desc.1",
"nomilabs.gui.advanced_memory_card.mode.add_input.desc.2");

public static final BetterMemoryCardModes ADD_AS_OUTPUT = addMode(1, "ADD_AS_OUTPUT",
"nomilabs.gui.advanced_memory_card.mode.add_output",
"nomilabs.gui.advanced_memory_card.mode.add_output.desc.1",
"nomilabs.gui.advanced_memory_card.mode.add_output.desc.2");

/**
* Essentially, this loads the class, allowing the above values to be added.
* <p>
* If for some reason, the values are needed before this, they will still be loaded, and calling init will have no
* affect on that.
*/
public static void preInit() {}

private static BetterMemoryCardModes addMode(int labsId, String name, String unlocalizedName,
String... unlocalizedDesc) {
BetterMemoryCardModes result = EnumHelper.addEnum(BetterMemoryCardModes.class, name,
new Class<?>[] { String.class, String[].class },
unlocalizedName, unlocalizedDesc);
LABS_ADDED_MODES.put(result, labsId);
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.nomiceu.nomilabs.integration.betterp2p;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.nomiceu.nomilabs.mixin.betterp2p.GuiAdvancedMemoryCardKtAccessor;
import com.projecturanus.betterp2p.item.BetterMemoryCardModes;
import com.projecturanus.betterp2p.item.BetterMemoryCardModesKt;

public class ModeDescriptionsHandler {

public static final Map<BetterMemoryCardModes, List<String>> labsModeDescriptions;

public static void refreshDescriptions() {
labsModeDescriptions.clear();
for (var mode : BetterMemoryCardModes.values()) {
labsModeDescriptions.put(mode,
GuiAdvancedMemoryCardKtAccessor.fmtTooltips(mode.getUnlocalizedName(), mode.getUnlocalizedDesc(),
BetterMemoryCardModesKt.MAX_TOOLTIP_LENGTH));
}
}

static {
labsModeDescriptions = new HashMap<>();
refreshDescriptions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ else if (flag == FLAG_FORME) {
invis.blockName = Objects.requireNonNull(states.getDefault().getBlock().getRegistryName()).toString();
TileInvisECoreBlockState invisState = (TileInvisECoreBlockState) invis;
if (BlockStates.statesEqual(states.getDefault(), states.getDefault().getBlock().getDefaultState())) {
invisState.setIsDefault();
invisState.labs$setIsDefault();
} else {
invisState.setMetadata(states.getDefault().getBlock().getMetaFromState(states.getDefault()));
invisState.labs$setMetadata(states.getDefault().getBlock().getMetaFromState(states.getDefault()));
}
invis.setController(core);
}
Expand Down Expand Up @@ -280,11 +280,11 @@ public boolean checkBlock(BlockStates states, World world, BlockPos pos) {
if (invis.blockName
.equals(Objects.requireNonNull(states.getDefault().getBlock().getRegistryName()).toString())) {
TileInvisECoreBlockState invisState = (TileInvisECoreBlockState) invis;
if (invisState.getDefault()) {
if (invisState.labs$getDefault()) {
if (BlockStates.statesEqual(states.getDefault(), states.getDefault().getBlock().getDefaultState()))
return true;
} else if (states.getDefault().getBlock().getMetaFromState(states.getDefault()) ==
invisState.getMetadata())
invisState.labs$getMetadata())
return true;
}
}
Expand Down
Loading

0 comments on commit 31ba721

Please sign in to comment.