mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-10-30 06:10:51 +01:00
Fixed relay things.
Fixed compass clicking.
This commit is contained in:
parent
cf0349b102
commit
99e166337b
4 changed files with 17 additions and 14 deletions
|
@ -104,7 +104,7 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements
|
||||||
BlockEntity tile = world.getBlockEntity(pos);
|
BlockEntity tile = world.getBlockEntity(pos);
|
||||||
if (tile instanceof TileEntityLaserRelay relay) {
|
if (tile instanceof TileEntityLaserRelay relay) {
|
||||||
|
|
||||||
if (StackUtil.isValid(stack)) {
|
if (!stack.isEmpty()) {
|
||||||
if (stack.getItem() instanceof ItemLaserWrench) {
|
if (stack.getItem() instanceof ItemLaserWrench) {
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
} else if (stack.getItem() == CommonConfig.Other.relayConfigureItem) {
|
} else if (stack.getItem() == CommonConfig.Other.relayConfigureItem) {
|
||||||
|
@ -120,10 +120,10 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements
|
||||||
relay.sendUpdate();
|
relay.sendUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.SUCCESS;
|
||||||
} else if (stack.getItem() instanceof ItemLaserRelayUpgrade) {
|
} else if (stack.getItem() instanceof ItemLaserRelayUpgrade) {
|
||||||
ItemStack inRelay = relay.inv.getStackInSlot(0);
|
ItemStack inRelay = relay.inv.getStackInSlot(0);
|
||||||
if (!StackUtil.isValid(inRelay)) {
|
if (inRelay.isEmpty()) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
if (!player.isCreative()) {
|
if (!player.isCreative()) {
|
||||||
player.setItemInHand(hand, StackUtil.shrink(stack, 1));
|
player.setItemInHand(hand, StackUtil.shrink(stack, 1));
|
||||||
|
@ -141,7 +141,7 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements
|
||||||
|
|
||||||
if (player.isShiftKeyDown()) {
|
if (player.isShiftKeyDown()) {
|
||||||
ItemStack inRelay = relay.inv.getStackInSlot(0).copy();
|
ItemStack inRelay = relay.inv.getStackInSlot(0).copy();
|
||||||
if (StackUtil.isValid(inRelay)) {
|
if (!inRelay.isEmpty()) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
relay.inv.setStackInSlot(0, ItemStack.EMPTY);
|
relay.inv.setStackInSlot(0, ItemStack.EMPTY);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.event;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.attachments.ActuallyAttachments;
|
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.CommonConfig;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
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.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
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.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.bus.api.Event;
|
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.living.LivingDropsEvent;
|
||||||
import net.neoforged.neoforge.event.entity.player.EntityItemPickupEvent;
|
import net.neoforged.neoforge.event.entity.player.EntityItemPickupEvent;
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
||||||
|
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.neoforged.neoforge.event.level.BlockEvent;
|
import net.neoforged.neoforge.event.level.BlockEvent;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class CommonEvents {
|
public class CommonEvents {
|
||||||
|
|
||||||
//TODO spawner shards are yeeted right?
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onBlockBreakEvent(BlockEvent.BreakEvent event) {
|
public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) { //Workaround, cant sneak right click a block with an item normally.
|
||||||
BlockState state = event.getState();
|
if (event.getLevel().isClientSide)
|
||||||
if (state != null && state.getBlock() == Blocks.SPAWNER) {
|
return;
|
||||||
// TODO: [port] add back once we've unflattened
|
if( (event.getLevel().getBlockState(event.getHitVec().getBlockPos()).getBlock() instanceof BlockLaserRelay) && (event.getItemStack().is(CommonConfig.Other.relayConfigureItem))) {
|
||||||
// event.getDrops().add(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.SPAWNER_SHARD.ordinal()));
|
event.setUseItem(Event.Result.DENY);
|
||||||
|
event.setUseBlock(Event.Result.ALLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -83,8 +83,8 @@ public final class PacketHandler {
|
||||||
// Particle fx = new ParticleLaserItem(mc.level, outX, outY, outZ, stack, 0.025, inX, inY, inZ);
|
// Particle fx = new ParticleLaserItem(mc.level, outX, outY, outZ, stack, 0.025, inX, inY, inZ);
|
||||||
//mc.effectRenderer.addEffect(fx); //TODO
|
//mc.effectRenderer.addEffect(fx); //TODO
|
||||||
|
|
||||||
mc.level.addParticle(ParticleLaserItem.Factory.createData(stack, outX, outY, outZ),
|
mc.level.addParticle(ParticleLaserItem.Factory.createData(stack, inX, inY, inZ),
|
||||||
inX, inY, inZ, 0, 0.025, 0);
|
outX, outY, outZ, 0, 0.025, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = (compound, context) -> {
|
public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = (compound, context) -> {
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCompassAction(Player player) {
|
public void onCompassAction(Player player) {
|
||||||
if (player.isShiftKeyDown()) {
|
if (player.isCrouching()) {
|
||||||
this.priority--;
|
this.priority--;
|
||||||
} else {
|
} else {
|
||||||
this.priority++;
|
this.priority++;
|
||||||
|
|
Loading…
Reference in a new issue