修复卓越接口GUI问题
This commit is contained in:
parent
c7b8a07eff
commit
35d3679203
3 changed files with 12 additions and 23 deletions
|
@ -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<SuperbItemInterfaceBlock> CODEC = BlockBehaviour.simpleCodec(SuperbItemInterfaceBlock::new);
|
||||
private static final MapCodec<SuperbItemInterfaceBlock> CODEC = BlockBehaviour.simpleCodec(prop -> new SuperbItemInterfaceBlock());
|
||||
|
||||
@Override
|
||||
protected @NotNull MapCodec<? extends BaseEntityBlock> codec() {
|
||||
|
|
|
@ -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<ItemStack> 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
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class SuperbItemInterfaceScreen extends AbstractContainerScreen<SuperbItemInterfaceMenu> {
|
||||
|
||||
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<SuperbIte
|
|||
|
||||
@Override
|
||||
public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
this.renderBackground(guiGraphics, mouseX, mouseY, partialTick);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTick);
|
||||
this.renderTooltip(guiGraphics, mouseX, mouseY);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue