Skip to content

Commit

Permalink
Merge pull request #422 from WaitingIdly/actually-additions-laser-upg…
Browse files Browse the repository at this point in the history
…rade

Fix Laser Upgrade Voiding with size == 1
  • Loading branch information
ACGaming authored Apr 5, 2024
2 parents 9c8de14 + 7b99e61 commit 9958925
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ All changes are toggleable via config files.
* **Disable Plague Potion Clouds:** Disables AbyssalCraft's Plague-type mobs spawning lingering potion effects on death
* **Actually Additions**
* **Duplication Fixes:** Fixes various duplication exploits
* **Laser Upgrade Voiding:** Fixes Laser Upgrades voiding instead of applying if there is only one item in the stack
* **Advent of Ascension**
* **Improved Player Tick:** Improves AoA player ticking by only sending inventory changes when necessary
* **Arcane Archives**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ public static class ActuallyAdditionsCategory
@Config.Name("Duplication Fixes")
@Config.Comment("Fixes various duplication exploits")
public boolean utDuplicationFixesToggle = true;

@Config.Name("Laser Upgrade Voiding")
@Config.Comment("Fixes Laser Upgrades voiding instead of applying if there is only one item in the stack")
public boolean utLaserUpgradeVoid = true;
}

public static class ArcaneArchivesCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public List<String> getMixinConfigs()
configs.add("mixins.mods.aoa3.json");
configs.add("mixins.mods.abyssalcraft.json");
configs.add("mixins.mods.actuallyadditions.dupes.json");
configs.add("mixins.mods.actuallyadditions.json");
configs.add("mixins.mods.arcanearchives.dupes.json");
configs.add("mixins.mods.biomesoplenty.json");
configs.add("mixins.mods.bloodmagic.dupes.json");
Expand Down Expand Up @@ -117,6 +118,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return Loader.isModLoaded("abyssalcraft");
case "mixins.mods.actuallyadditions.dupes.json":
return Loader.isModLoaded("actuallyadditions") && UTConfigMods.ACTUALLY_ADDITIONS.utDuplicationFixesToggle;
case "mixins.mods.actuallyadditions.json":
return Loader.isModLoaded("actuallyadditions");
case "mixins.mods.arcanearchives.dupes.json":
return Loader.isModLoaded("arcanearchives") && UTConfigMods.ARCANE_ARCHIVES.utDuplicationFixesToggle;
case "mixins.mods.biomesoplenty.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package mod.acgaming.universaltweaks.mods.actuallyadditions.mixin;

import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import mod.acgaming.universaltweaks.config.UTConfigMods;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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;

// Courtesy of WaitingIdly
@Mixin(value = BlockLaserRelay.class, remap = false)
public abstract class UTBlockLaserRelayMixin
{
@Inject(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;isCreative()Z"))
public void utOnBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9, CallbackInfoReturnable<Boolean> cir)
{
if (!UTConfigMods.ACTUALLY_ADDITIONS.utLaserUpgradeVoid) return;
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityLaserRelay) {
ItemStack stack = player.getHeldItem(hand);
ItemStack set = stack.copy();
set.setCount(1);
((TileEntityLaserRelay) tile).inv.setStackInSlot(0, set);
if (!player.isCreative()) {
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
}
cir.setReturnValue(true);
}
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.actuallyadditions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.actuallyadditions.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTBlockLaserRelayMixin"]
}

0 comments on commit 9958925

Please sign in to comment.