Skip to content

Commit

Permalink
FTB Utils Integration + Effortless Building Improvements
Browse files Browse the repository at this point in the history
FTB:
- Fixes Ghost Items
- Sends a nice status message on cancel

Effortless:
- Fixes Dupe Bugs
- Fixes Able to Place in FTB Claimed Chunks
- Make Configs Editable on the Fly
  • Loading branch information
IntegerLimit committed Apr 25, 2024
1 parent 47c24ed commit 57e1b08
Show file tree
Hide file tree
Showing 31 changed files with 1,001 additions and 50 deletions.
8 changes: 8 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ dependencies {
// Effortless Building (from CurseForge)
compileOnly rfg.deobf("curse.maven:effortless-building-302113:2847346") // Version 2.16

// FTB Utilities (from CurseForge)
compileOnly rfg.deobf("curse.maven:ftb-utilities-forge-237102:3157548") // Version 5.4.1.131

// Better Questing Unofficial (from CurseForge)
compileOnly rfg.deobf("curse.maven:better-questing-unofficial-629629:5183601") // Version 4.2.2

Expand Down Expand Up @@ -206,6 +209,11 @@ dependencies {
runtimeOnly "curse.maven:effortless-building-302113:2847346" // Version 2.16
}

if (project.enable_ftb_utils.toBoolean()) {
runtimeOnly "curse.maven:ftb-library-legacy-forge-237167:2985811" // Version 5.4.7.2
runtimeOnly "curse.maven:ftb-utilities-forge-237102:3157548" // Version 5.4.1.131
}

if (project.enable_bqu.toBoolean()) {
runtimeOnly "curse.maven:better-questing-unofficial-629629:5183601" // Version 4.2.2
}
Expand Down
12 changes: 9 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ curseForgeRelations = requiredDependency:codechicken-lib-1-8;\
optionalDependency:better-questing-unofficial;\
optionalDependency:controlling;\
optionalDependency:default-world-generator-port;\
optionalDependency:dme;
optionalDependency:dme;\
optionalDependency:ftb-library-legacy-forge;\
optionalDependency:ftb-utilities-forge;

# This project's release type on CurseForge and/or Modrinth
# Alternatively this can be set with the 'RELEASE_TYPE' environment variable.
Expand Down Expand Up @@ -226,7 +228,7 @@ enable_chisel = false
enable_ae2 = false

# Whether to enable DME in runtime. Enables the DME Dat Hatch.
enable_dme = true
enable_dme = false

# Whether to enable Extended Crafting in runtime. Enables Extended Crafting Blocks in DME Sim Chamber and Naq Reactors.
# If this is set to false, those blocks will be set to air.
Expand Down Expand Up @@ -257,7 +259,11 @@ enable_architecture_craft = false

# Whether to enable Effortless Building in runtime. Enables the mixin which improves clarity of Reach Upgrades.
# If this is set to false, the mixin will not apply.
enable_effortless_building = false
enable_effortless_building = true

# Whether to enable FTB Utilities in runtime. Enables mixins which provide fixes relating to Ghost Items, and Effortless + FTB Utils Compat.
# If this is set to false, Effortless + FTB Utils Compat will not be applied, and the mixin will not apply.
enable_ftb_utils = true

# Whether to enable BQu in runtime. Enables Labs Tier Helper.
enable_bqu = false
Expand Down
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 @@ -37,4 +37,5 @@ public class LabsValues {
public static final String CONTROLLING_MODID = "controlling";
public static final String DEFAULT_WORLD_GEN_MODID = "defaultworldgenerator-port";
public static final String DME_MODID = "deepmoblearning";
public static final String FTB_UTILS_MODID = "ftbutilities";
}
19 changes: 18 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/NomiLabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.*;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.nomiceu.nomilabs.config.LabsConfig;
import com.nomiceu.nomilabs.event.ClientProxy;
import com.nomiceu.nomilabs.event.CommonProxy;
import com.nomiceu.nomilabs.integration.effortlessbuilding.EffortlessEventHandler;
import com.nomiceu.nomilabs.integration.ftbutilities.event.FTBUtilsEventHandler;
import com.nomiceu.nomilabs.remap.datafixer.DataFixerHandler;
import com.nomiceu.nomilabs.util.LabsSide;

Expand All @@ -23,12 +27,17 @@
"required-after:jei@[4.15.0,);" + "required-after:theoneprobe;" + "after:advancedrocketry;" +
"after:libvulpes;" + "after:crafttweaker@[4.1.20,);" + "after:appliedenergistics2;" +
"after:architecturecraft;" + "after:effortlessbuilding;" + "after:betterquesting;" +
"after:defaultworldgenerator-port;" + "after:deepmoblearning;")
"after:defaultworldgenerator-port;" + "after:deepmoblearning;" + "after:ftbutilities;")
@SuppressWarnings("unused")
public class NomiLabs {

public static final Logger LOGGER = LogManager.getLogger(LabsValues.LABS_MODID);

@EventHandler
public void onConstruction(FMLConstructionEvent event) {
CommonProxy.onConstruction();
}

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(this);
Expand All @@ -37,6 +46,14 @@ public void preInit(FMLPreInitializationEvent event) {
CommonProxy.preInit();
if (LabsSide.isClient())
ClientProxy.latePreInit();

if (Loader.isModLoaded(LabsValues.EFFORTLESS_MODID) &&
LabsConfig.modIntegration.effortlessBuildingIntegration.enableEffortlessBuildingIntegration)
MinecraftForge.EVENT_BUS.register(EffortlessEventHandler.class);

if (Loader.isModLoaded(LabsValues.FTB_UTILS_MODID) &&
LabsConfig.modIntegration.enableFTBUtilsIntegration)
MinecraftForge.EVENT_BUS.register(FTBUtilsEventHandler.class);
}

@EventHandler
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,17 @@ public static class ModIntegration {
@Config.Name("effortless building integration")
public final EffortlessBuildingIntegration effortlessBuildingIntegration = new EffortlessBuildingIntegration();

@Config.Comment({
"Whether to enable FTB Utilities Integration. Makes Status Messages more consistent, translatable, and fixes issues relating to Ghost Items.",
"[default: true]" })
@Config.LangKey("config.nomilabs.mod_integration.ftb_utils")
@Config.RequiresMcRestart
public boolean enableFTBUtilsIntegration = true;

public static class EffortlessBuildingIntegration {

@Config.Comment({ "Whether to enable Effortless Building Integration, which splits the parts of reach.",
"Also fixes various Dupe and Transmutation Bugs, and fixes allowing Placing Blocks in FTB Utils Claimed Chunks.",
"None of the below options work if this config is set to false.",
"[default: true]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.enable")
Expand All @@ -236,61 +244,51 @@ public static class EffortlessBuildingIntegration {
@Config.Comment({ "Max Reach Per Axis Without Upgrades.",
"[default: 8]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.axis.0")
@Config.RequiresMcRestart
public int axisReach0 = 8;

@Config.Comment({ "Max Reach Per Axis With 1 Upgrade.",
"[default: 16]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.axis.1")
@Config.RequiresMcRestart
public int axisReach1 = 16;

@Config.Comment({ "Max Reach Per Axis With 2 Upgrades.",
"[default: 32]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.axis.2")
@Config.RequiresMcRestart
public int axisReach2 = 32;

@Config.Comment({ "Max Reach Per Axis With 3 Upgrades.",
"[default: 64]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.axis.3")
@Config.RequiresMcRestart
public int axisReach3 = 64;

@Config.Comment({ "Max Reach Per Axis In Creative.",
"[default: 2048]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.axis.creative")
@Config.RequiresMcRestart
public int axisReachCreative = 2048;

@Config.Comment({ "Max Blocks Placed at Once Without Upgrades.",
"[default: 256]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.blocks.0")
@Config.RequiresMcRestart
public int blocksPlaced0 = 256;

@Config.Comment({ "Max Blocks Placed at Once With 1 Upgrade.",
"[default: 2048]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.blocks.1")
@Config.RequiresMcRestart
public int blocksPlaced1 = 2048;

@Config.Comment({ "Max Blocks Placed at Once With 2 Upgrades.",
"[default: 16384]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.blocks.2")
@Config.RequiresMcRestart
public int blocksPlaced2 = 16384;

@Config.Comment({ "Max Blocks Placed at Once With 3 Upgrades.",
"[default: 131072]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.blocks.3")
@Config.RequiresMcRestart
public int blocksPlaced3 = 131072;

@Config.Comment({ "Max Blocks Placed at Once In Creative.",
"[default: 1048576]" })
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.blocks.creative")
@Config.RequiresMcRestart
public int blocksPlacedCreative = 1048576;
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class LabsLateMixin implements ILateMixinLoader {
new AbstractMap.SimpleImmutableEntry<>(LabsValues.CONTROLLING_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.DEFAULT_WORLD_GEN_MODID,
LabsConfig.modIntegration.enableDefaultWorldGenIntegration),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.DME_MODID, true))
new AbstractMap.SimpleImmutableEntry<>(LabsValues.DME_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.FTB_UTILS_MODID,
LabsConfig.modIntegration.enableFTBUtilsIntegration))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

@Override
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.nomiceu.nomilabs.integration.top.TOPTooltipManager;
import com.nomiceu.nomilabs.item.ItemExcitationCoil;
import com.nomiceu.nomilabs.item.registry.LabsItems;
import com.nomiceu.nomilabs.network.LabsNetworkHandler;
import com.nomiceu.nomilabs.recipe.HandFramingRecipe;
import com.nomiceu.nomilabs.remap.LabsRemappers;
import com.nomiceu.nomilabs.remap.Remapper;
Expand All @@ -53,6 +54,10 @@
@SuppressWarnings("unused")
public class CommonProxy {

public static void onConstruction() {
LabsNetworkHandler.onConstruction();
}

public static void preInit() {
LabsModeHelper.check();

Expand Down Expand Up @@ -82,6 +87,8 @@ public static void preInit() {

DataFixerHandler.preInit();
FluidRegistryMixinHelper.preInit();

LabsNetworkHandler.preInit();
}

public static void loadComplete() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ protected boolean setupAndConsumeRecipeInputs(@NotNull Recipe recipe,
for (var stack : list) {
if (stack.getItem() == searchItem && DataModelHelper.getTier(stack) == searchTier) {
DataModelHelper.setCurrentTierDataCount(stack,
Math.min(Integer.MAX_VALUE, DataModelHelper.getCurrentTierDataCount(stack) + property.getAddition()));
Math.min(Integer.MAX_VALUE,
DataModelHelper.getCurrentTierDataCount(stack) + property.getAddition()));
DataModelHelper.setTotalSimulationCount(stack,
Math.min(Integer.MAX_VALUE, DataModelHelper.getTotalSimulationCount(stack) + property.getAddition()));
Math.min(Integer.MAX_VALUE,
DataModelHelper.getTotalSimulationCount(stack) + property.getAddition()));
var increase = true;
while (increase) {
increase = DataModelHelperAccessor.tryIncreaseTier(stack);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.nomiceu.nomilabs.integration.effortlessbuilding;

import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmode.BuildModes;
import nl.requios.effortlessbuilding.buildmode.ModeSettingsManager;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.network.RequestLookAtMessage;

@SuppressWarnings("unused")
public class EffortlessEventHandler {

@SubscribeEvent
public static void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) {
var player = event.getEntityPlayer();
var stack = player.getHeldItem(event.getHand());
if (!(stack.getItem() instanceof ItemBlock itemBlock)) return;

BuildModes.BuildModeEnum buildMode = ModeSettingsManager.getModeSettings(player).getBuildMode();
ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);

if (buildMode != BuildModes.BuildModeEnum.NORMAL) {
event.setCanceled(true);
} else if (modifierSettings.doQuickReplace()) {
event.setCanceled(true);
if (!event.getWorld().isRemote && player instanceof EntityPlayerMP playerMP) {
EffortlessBuilding.packetHandler.sendTo(new RequestLookAtMessage(true), playerMP);
}
} else if (!event.getWorld().isRemote && player instanceof EntityPlayerMP playerMP) {
EffortlessBuilding.packetHandler.sendTo(new RequestLookAtMessage(false), playerMP);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand All @@ -15,26 +16,27 @@
import nl.requios.effortlessbuilding.BuildConfig;
import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import scala.Int;

public class GenericReachUpgrade {

public static final int CREATIVE_LEVEL = -1;
public static Map<Integer, ReachInfo> REACH_MAP = ImmutableMap.of(
-1, new ReachInfo(BuildConfig.reach.maxReachCreative,
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReachCreative,
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlacedCreative),
0, new ReachInfo(BuildConfig.reach.maxReachLevel0,
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach0,
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced0),
1, new ReachInfo(BuildConfig.reach.maxReachLevel1,
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach1,
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced1),
2, new ReachInfo(BuildConfig.reach.maxReachLevel2,
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach2,
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced2),
3, new ReachInfo(BuildConfig.reach.maxReachLevel3,
LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach3,
LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced3));
-1, new ReachInfo(() -> BuildConfig.reach.maxReachCreative,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.axisReachCreative,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlacedCreative),
0, new ReachInfo(() -> BuildConfig.reach.maxReachLevel0,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach0,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced0),
1, new ReachInfo(() -> BuildConfig.reach.maxReachLevel1,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach1,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced1),
2, new ReachInfo(() -> BuildConfig.reach.maxReachLevel2,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach2,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced2),
3, new ReachInfo(() -> BuildConfig.reach.maxReachLevel3,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.axisReach3,
() -> LabsConfig.modIntegration.effortlessBuildingIntegration.blocksPlaced3));

// A complete overwrite so everything can be localized!
public static ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand,
Expand Down Expand Up @@ -64,9 +66,9 @@ public static ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer
EffortlessBuilding.log(player,
LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.success.1"));
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.success.2",
currentReach.axis, newReach.axis));
currentReach.getAxis(), newReach.getAxis()));
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.success.3",
currentReach.distance, newReach.distance));
currentReach.getDistance(), newReach.getDistance()));
}
player.setHeldItem(hand, ItemStack.EMPTY);

Expand All @@ -84,20 +86,32 @@ public static ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer
public static void addInformation(List<String> tooltip, int level) {
ReachInfo reach = REACH_MAP.get(level);
tooltip.add(LabsTranslate.translate("effortlessbuilding.item.reach_upgrade.tooltip.1"));
tooltip.add(LabsTranslate.translate("effortlessbuilding.item.reach_upgrade.tooltip.2", reach.axis));
tooltip.add(LabsTranslate.translate("effortlessbuilding.item.reach_upgrade.tooltip.3", reach.distance));
tooltip.add(LabsTranslate.translate("effortlessbuilding.item.reach_upgrade.tooltip.2", reach.getAxis()));
tooltip.add(LabsTranslate.translate("effortlessbuilding.item.reach_upgrade.tooltip.3", reach.getDistance()));
}

public static class ReachInfo {
// Uses Suppliers so that we can change configs on the fly
private final Supplier<Integer> distance;
private final Supplier<Integer> axis;
private final Supplier<Integer> maxBlocks;

public final int distance;
public final int axis;
public final int maxBlocks;

public ReachInfo(int distance, int axis, int maxBlocks) {
public ReachInfo(Supplier<Integer> distance, Supplier<Integer> axis, Supplier<Integer> maxBlocks) {
this.distance = distance;
this.axis = axis;
this.maxBlocks = maxBlocks;
}

public int getDistance() {
return distance.get();
}

public int getAxis() {
return axis.get();
}

public int getMaxBlocks() {
return maxBlocks.get();
}
}
}
Loading

0 comments on commit 57e1b08

Please sign in to comment.