-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #422 from WaitingIdly/actually-additions-laser-upg…
…rade Fix Laser Upgrade Voiding with size == 1
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ava/mod/acgaming/universaltweaks/mods/actuallyadditions/mixin/UTBlockLaserRelayMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |