Skip to content

Commit

Permalink
Effortless Building Integration + JEI Recipe Category ID
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Mar 26, 2024
1 parent 7105eba commit a1e1f14
Show file tree
Hide file tree
Showing 16 changed files with 407 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ dependencies {
// Architecture Craft (from CurseForge)
compileOnly rfg.deobf("curse.maven:architecture-craft-277631:2750633") // Version 3.98

// Effortless Building (from CurseForge)
compileOnly rfg.deobf("curse.maven:effortless-building-302113:2847346") // Version 2.16

/* -------------------------------- 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 @@ -181,6 +184,10 @@ dependencies {
runtimeOnly "curse.maven:architecture-craft-277631:2750633" // Version 3.98
}

if (project.enable_effortless_building.toBoolean()) {
runtimeOnly "curse.maven:effortless-building-302113:2847346" // Version 2.16
}

if (project.enable_ender_storage.toBoolean()) {
// Ender Storage, runtime only, integrated in remappers (from CurseForge)
runtimeOnly "curse.maven:ender-storage-245174:2755787" // Version 2.4.6.137
Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,13 @@ enable_rocketry = false
# If this is set to false, the mixin will not apply.
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 = true

# Whether to enable Ender Storage in runtime. Enables remappers to remap items in ender storage.
# If this is set to false, the remappers will not apply there.
enable_ender_storage = true
enable_ender_storage = false

# Whether to enable Thermal Expansion and its deps in runtime. These are used for the excitation coil textures.
# If this is set to false, the top of the excitation coil will have a null texture.
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 @@ -31,4 +31,5 @@ public class LabsValues {
public static final String JEI_MODID = "jei";
public static final String ROCKETRY_MODID = "advancedrocketry";
public static final String ARCHITECTURE_MODID = "architecturecraft";
public static final String EFFORTLESS_MODID = "effortlessbuilding";
}
74 changes: 74 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,80 @@ public static class ModIntegration {
@Config.RequiresMcRestart
public boolean enableArchitectureCraftIntegration = true;

@Config.Comment("Effortless Building Integration Settings")
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding")
@Config.Name("effortless building integration")
public final EffortlessBuildingIntegration effortlessBuildingIntegration = new EffortlessBuildingIntegration();

public static class EffortlessBuildingIntegration {
@Config.Comment({"Whether to enable Effortless Building Integration, which splits the parts of reach.",
"None of the below options work if this config is set to false.",
"[default: true]"})
@Config.LangKey("config.nomilabs.mod_integration.effortlessbuilding.enable")
@Config.RequiresMcRestart
public boolean enableEffortlessBuildingIntegration = true;

@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;
}

public static class DraconicEvolutionIntegration {
@Config.Comment({"Whether to enable Draconic Evolution Integration, which adds many features, such as:",
"Allowing GregTech Draconium and Awakened Draconium in the reactor and energy core.",
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 @@ -28,7 +28,9 @@ public class LabsLateMixin implements ILateMixinLoader {
new AbstractMap.SimpleImmutableEntry<>(LabsValues.ROCKETRY_MODID,
LabsConfig.modIntegration.enableAdvancedRocketryIntegration),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.ARCHITECTURE_MODID,
LabsConfig.modIntegration.enableArchitectureCraftIntegration)
LabsConfig.modIntegration.enableArchitectureCraftIntegration),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.EFFORTLESS_MODID,
LabsConfig.modIntegration.effortlessBuildingIntegration.enableEffortlessBuildingIntegration)
)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.nomiceu.nomilabs.integration.effortlessbuilding;

import com.google.common.collect.ImmutableMap;
import com.nomiceu.nomilabs.config.LabsConfig;
import com.nomiceu.nomilabs.util.LabsTranslate;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.world.World;
import nl.requios.effortlessbuilding.BuildConfig;
import nl.requios.effortlessbuilding.EffortlessBuilding;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;

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

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)
);

// A complete overwrite so everything can be localized!
public static ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand, int upgradeLevel) {
if (player.isCreative()) {
if (world.isRemote) {
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.creative.1"));
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.creative.2"));
}
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}

ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
int currentLevel = modifierSettings.getReachUpgrade();
if (currentLevel < upgradeLevel - 1 && currentLevel >= 0) {
if (world.isRemote) EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.previous", upgradeLevel - 1));
}
if (currentLevel == upgradeLevel - 1) {
ReachInfo currentReach = REACH_MAP.get(upgradeLevel - 1);
ReachInfo newReach = REACH_MAP.get(upgradeLevel);
modifierSettings.setReachUpgrade(upgradeLevel);

if (world.isRemote) {
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));
EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.success.3",
currentReach.distance, newReach.distance));
}
player.setHeldItem(hand, ItemStack.EMPTY);

SoundEvent soundEvent = new SoundEvent(new ResourceLocation("entity.player.levelup"));
player.playSound(soundEvent, 1f, 1f);

return new ActionResult<>(EnumActionResult.PASS, ItemStack.EMPTY);
} else if (currentLevel > upgradeLevel - 1) {
if (world.isRemote) EffortlessBuilding.log(player, LabsTranslate.translate("effortlessbuilding.use.reach_upgrade.already_used"));
}
return new ActionResult<>(EnumActionResult.FAIL, player.getHeldItem(hand));
}
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));
}

public static class ReachInfo {
public final int distance;
public final int axis;
public final int maxBlocks;

public ReachInfo(int distance, int axis, int maxBlocks) {
this.distance = distance;
this.axis = axis;
this.maxBlocks = maxBlocks;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.nomiceu.nomilabs.mixin.effortlessbuilding;

import com.nomiceu.nomilabs.integration.effortlessbuilding.GenericReachUpgrade;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nl.requios.effortlessbuilding.item.ItemReachUpgrade1;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.List;

/**
* Adds Proper Information and Improves Clarity of Messages of Reach Upgrade 1.
*/
@Mixin(value = ItemReachUpgrade1.class, remap = false)
public class ItemReachUpgrade1Mixin {
@Inject(method = "onItemRightClick", at = @At("HEAD"), cancellable = true, remap = true)
public void onNewItemRightClick(World world, EntityPlayer player, EnumHand hand, CallbackInfoReturnable<ActionResult<ItemStack>> cir) {
cir.setReturnValue(GenericReachUpgrade.onItemRightClick(world, player, hand, 1));
}

@Inject(method = "addInformation", at = @At("HEAD"), cancellable = true, remap = true)
@SideOnly(Side.CLIENT)
public void addNewInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag, CallbackInfo ci) {
GenericReachUpgrade.addInformation(tooltip, 1);
ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.nomiceu.nomilabs.mixin.effortlessbuilding;

import com.nomiceu.nomilabs.integration.effortlessbuilding.GenericReachUpgrade;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nl.requios.effortlessbuilding.item.ItemReachUpgrade2;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.List;

/**
* Adds Proper Information and Improves Clarity of Messages of Reach Upgrade 2.
*/
@Mixin(value = ItemReachUpgrade2.class, remap = false)
public class ItemReachUpgrade2Mixin {
@Inject(method = "onItemRightClick", at = @At("HEAD"), cancellable = true, remap = true)
public void onNewItemRightClick(World world, EntityPlayer player, EnumHand hand, CallbackInfoReturnable<ActionResult<ItemStack>> cir) {
cir.setReturnValue(GenericReachUpgrade.onItemRightClick(world, player, hand, 2));
}

@Inject(method = "addInformation", at = @At("HEAD"), cancellable = true, remap = true)
@SideOnly(Side.CLIENT)
public void addNewInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag, CallbackInfo ci) {
GenericReachUpgrade.addInformation(tooltip, 2);
ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.nomiceu.nomilabs.mixin.effortlessbuilding;

import com.nomiceu.nomilabs.integration.effortlessbuilding.GenericReachUpgrade;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nl.requios.effortlessbuilding.item.ItemReachUpgrade3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.List;

/**
* Adds Proper Information and Improves Clarity of Messages of Reach Upgrade 3.
*/
@Mixin(value = ItemReachUpgrade3.class, remap = false)
public class ItemReachUpgrade3Mixin {
@Inject(method = "onItemRightClick", at = @At("HEAD"), cancellable = true, remap = true)
public void onNewItemRightClick(World world, EntityPlayer player, EnumHand hand, CallbackInfoReturnable<ActionResult<ItemStack>> cir) {
cir.setReturnValue(GenericReachUpgrade.onItemRightClick(world, player, hand, 3));
}

@Inject(method = "addInformation", at = @At("HEAD"), cancellable = true, remap = true)
@SideOnly(Side.CLIENT)
public void addNewInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag, CallbackInfo ci) {
GenericReachUpgrade.addInformation(tooltip, 3);
ci.cancel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.nomiceu.nomilabs.mixin.effortlessbuilding;

import com.nomiceu.nomilabs.integration.effortlessbuilding.GenericReachUpgrade;
import net.minecraft.entity.player.EntityPlayer;
import nl.requios.effortlessbuilding.buildmodifier.ModifierSettingsManager;
import nl.requios.effortlessbuilding.helper.ReachHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
* Changes the actual max axis distance and max blocks.
*/
@Mixin(value = ReachHelper.class, remap = false)
public class ReachHelperMixin {
@Inject(method = "getMaxBlocksPerAxis", at = @At("HEAD"), cancellable = true)
private static void getNewMaxBlocksPerAxis(EntityPlayer player, CallbackInfoReturnable<Integer> cir) {
if (player.isCreative()) {
cir.setReturnValue(GenericReachUpgrade.REACH_MAP.get(GenericReachUpgrade.CREATIVE_LEVEL).axis);
return;
}
int level = ModifierSettingsManager.getModifierSettings(player).getReachUpgrade();
cir.setReturnValue(GenericReachUpgrade.REACH_MAP.get(level).axis);
}

@Inject(method = "getMaxBlocksPlacedAtOnce", at = @At("HEAD"), cancellable = true)
private static void getNewMaxBlocksPlacedAtOnce(EntityPlayer player, CallbackInfoReturnable<Integer> cir) {
if (player.isCreative()) {
cir.setReturnValue(GenericReachUpgrade.REACH_MAP.get(GenericReachUpgrade.CREATIVE_LEVEL).maxBlocks);
return;
}
int level = ModifierSettingsManager.getModifierSettings(player).getReachUpgrade();
cir.setReturnValue(GenericReachUpgrade.REACH_MAP.get(level).maxBlocks);
}
}
Loading

0 comments on commit a1e1f14

Please sign in to comment.