diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java index e55b291e9..064ab534c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java @@ -104,7 +104,7 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements BlockEntity tile = world.getBlockEntity(pos); if (tile instanceof TileEntityLaserRelay relay) { - if (StackUtil.isValid(stack)) { + if (!stack.isEmpty()) { if (stack.getItem() instanceof ItemLaserWrench) { return InteractionResult.FAIL; } else if (stack.getItem() == CommonConfig.Other.relayConfigureItem) { @@ -120,10 +120,10 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements relay.sendUpdate(); } - return InteractionResult.PASS; + return InteractionResult.SUCCESS; } else if (stack.getItem() instanceof ItemLaserRelayUpgrade) { ItemStack inRelay = relay.inv.getStackInSlot(0); - if (!StackUtil.isValid(inRelay)) { + if (inRelay.isEmpty()) { if (!world.isClientSide) { if (!player.isCreative()) { player.setItemInHand(hand, StackUtil.shrink(stack, 1)); @@ -141,7 +141,7 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements if (player.isShiftKeyDown()) { ItemStack inRelay = relay.inv.getStackInSlot(0).copy(); - if (StackUtil.isValid(inRelay)) { + if (!inRelay.isEmpty()) { if (!world.isClientSide) { relay.inv.setStackInSlot(0, ItemStack.EMPTY); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java index 83cbf4762..466963403 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java @@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.event; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments; +import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.data.PlayerData; @@ -35,6 +36,7 @@ import net.minecraft.world.entity.monster.Spider; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.neoforged.bus.api.Event; @@ -43,20 +45,21 @@ import net.neoforged.neoforge.event.AnvilUpdateEvent; import net.neoforged.neoforge.event.entity.living.LivingDropsEvent; import net.neoforged.neoforge.event.entity.player.EntityItemPickupEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; import net.neoforged.neoforge.event.level.BlockEvent; import java.util.Locale; public class CommonEvents { - - //TODO spawner shards are yeeted right? @SubscribeEvent - public void onBlockBreakEvent(BlockEvent.BreakEvent event) { - BlockState state = event.getState(); - if (state != null && state.getBlock() == Blocks.SPAWNER) { - // TODO: [port] add back once we've unflattened - // event.getDrops().add(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.SPAWNER_SHARD.ordinal())); + public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) { //Workaround, cant sneak right click a block with an item normally. + if (event.getLevel().isClientSide) + return; + if( (event.getLevel().getBlockState(event.getHitVec().getBlockPos()).getBlock() instanceof BlockLaserRelay) && (event.getItemStack().is(CommonConfig.Other.relayConfigureItem))) { + event.setUseItem(Event.Result.DENY); + event.setUseBlock(Event.Result.ALLOW); } + } @SubscribeEvent diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java index dc1b7ec7a..db4405301 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java @@ -83,8 +83,8 @@ public final class PacketHandler { // Particle fx = new ParticleLaserItem(mc.level, outX, outY, outZ, stack, 0.025, inX, inY, inZ); //mc.effectRenderer.addEffect(fx); //TODO - mc.level.addParticle(ParticleLaserItem.Factory.createData(stack, outX, outY, outZ), - inX, inY, inZ, 0, 0.025, 0); + mc.level.addParticle(ParticleLaserItem.Factory.createData(stack, inX, inY, inZ), + outX, outY, outZ, 0, 0.025, 0); } }; public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = (compound, context) -> { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java index 6c97f8b22..b7e459c38 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java @@ -170,7 +170,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay { @Override public void onCompassAction(Player player) { - if (player.isShiftKeyDown()) { + if (player.isCrouching()) { this.priority--; } else { this.priority++;