diff --git a/src/main/java/com/atsuishio/superbwarfare/block/SuperbItemInterfaceBlock.java b/src/main/java/com/atsuishio/superbwarfare/block/SuperbItemInterfaceBlock.java index 5764a6b38..8c30a1e5a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/SuperbItemInterfaceBlock.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/SuperbItemInterfaceBlock.java @@ -35,18 +35,11 @@ import javax.annotation.ParametersAreNonnullByDefault; public class SuperbItemInterfaceBlock extends BaseEntityBlock { public static final BooleanProperty ENABLED = BlockStateProperties.ENABLED; - public static final DirectionProperty FACING = DirectionProperty.create("facing"); public SuperbItemInterfaceBlock() { - this(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).requiresCorrectToolForDrops().strength(3.0F, 4.8F).sound(SoundType.METAL)); - } - - public SuperbItemInterfaceBlock(BlockBehaviour.Properties properties) { - super(properties); - - this.registerDefaultState(this.stateDefinition.any().setValue(ENABLED, true)); - this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.DOWN)); + super(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).requiresCorrectToolForDrops().strength(3.0F, 4.8F).sound(SoundType.METAL)); + this.registerDefaultState(this.stateDefinition.any().setValue(ENABLED, true).setValue(FACING, Direction.DOWN)); } @Nullable @@ -66,9 +59,7 @@ public class SuperbItemInterfaceBlock extends BaseEntityBlock { @Override public BlockState getStateForPlacement(@NotNull BlockPlaceContext context) { Direction direction = context.getClickedFace().getOpposite(); - return this.defaultBlockState() - .setValue(FACING, direction) - .setValue(ENABLED, true); + return this.defaultBlockState().setValue(FACING, direction).setValue(ENABLED, true); } @Override @@ -119,7 +110,7 @@ public class SuperbItemInterfaceBlock extends BaseEntityBlock { } } - private static final MapCodec CODEC = BlockBehaviour.simpleCodec(SuperbItemInterfaceBlock::new); + private static final MapCodec CODEC = BlockBehaviour.simpleCodec(prop -> new SuperbItemInterfaceBlock()); @Override protected @NotNull MapCodec codec() { diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/SuperbItemInterfaceBlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/SuperbItemInterfaceBlockEntity.java index b7ea7f968..821032977 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/SuperbItemInterfaceBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/SuperbItemInterfaceBlockEntity.java @@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.block.SuperbItemInterfaceBlock; import com.atsuishio.superbwarfare.init.ModBlockEntities; import com.atsuishio.superbwarfare.menu.SuperbItemInterfaceMenu; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; @@ -32,13 +31,8 @@ public class SuperbItemInterfaceBlockEntity extends BaseContainerBlockEntity { private NonNullList items = NonNullList.withSize(CONTAINER_SIZE, ItemStack.EMPTY); private int cooldownTime = -1; - private final Direction facing; - - public SuperbItemInterfaceBlockEntity(BlockPos pPos, BlockState pBlockState) { super(ModBlockEntities.SUPERB_ITEM_INTERFACE.get(), pPos, pBlockState); - - this.facing = pBlockState.getValue(SuperbItemInterfaceBlock.FACING); } public static void serverTick(Level level, BlockPos pos, BlockState state, SuperbItemInterfaceBlockEntity blockEntity) { @@ -48,10 +42,12 @@ public class SuperbItemInterfaceBlockEntity extends BaseContainerBlockEntity { if (blockEntity.isEmpty()) return; + var facing = state.getValue(SuperbItemInterfaceBlock.FACING); + // find entities - var x = pos.getX() + blockEntity.facing.getStepX(); - var y = pos.getY() + blockEntity.facing.getStepY(); - var z = pos.getZ() + blockEntity.facing.getStepZ(); + var x = pos.getX() + facing.getStepX(); + var y = pos.getY() + facing.getStepY(); + var z = pos.getZ() + facing.getStepZ(); var list = level.getEntities( (Entity) null, @@ -113,7 +109,7 @@ public class SuperbItemInterfaceBlockEntity extends BaseContainerBlockEntity { @Override protected @NotNull AbstractContainerMenu createMenu(int pContainerId, @NotNull Inventory pInventory) { - return new SuperbItemInterfaceMenu(pContainerId, pInventory); + return new SuperbItemInterfaceMenu(pContainerId, pInventory, this); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/SuperbItemInterfaceScreen.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/SuperbItemInterfaceScreen.java index d14aa48f7..e46918dee 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/SuperbItemInterfaceScreen.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/SuperbItemInterfaceScreen.java @@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull; @OnlyIn(Dist.CLIENT) public class SuperbItemInterfaceScreen extends AbstractContainerScreen { + private static final ResourceLocation HOPPER_LOCATION = ResourceLocation.withDefaultNamespace("textures/gui/container/hopper.png"); public SuperbItemInterfaceScreen(SuperbItemInterfaceMenu menu, Inventory playerInventory, Component title) { @@ -22,6 +23,7 @@ public class SuperbItemInterfaceScreen extends AbstractContainerScreen