diff --git a/src/main/java/com/teammoeg/chorda/block/CBlockInterfaces.java b/src/main/java/com/teammoeg/chorda/block/CBlockInterfaces.java index 81174abe0..5a1b4623c 100644 --- a/src/main/java/com/teammoeg/chorda/block/CBlockInterfaces.java +++ b/src/main/java/com/teammoeg/chorda/block/CBlockInterfaces.java @@ -19,14 +19,16 @@ package com.teammoeg.chorda.block; +import com.teammoeg.chorda.block.entity.BlockStateAccess; + import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; public class CBlockInterfaces { - public interface IActiveState extends IEBlockInterfaces.BlockstateProvider { + public interface IActiveState extends BlockStateAccess { default boolean getIsActive() { - BlockState state = this.getState(); + BlockState state = this.getBlock(); return state.hasProperty(BlockStateProperties.LIT) ? state.getValue(BlockStateProperties.LIT) : false; } @@ -36,10 +38,10 @@ default boolean getIsActive() { * @return true if the state was changed, false otherwise */ default boolean setActive(boolean active) { - BlockState state = this.getState(); + BlockState state = this.getBlock(); if (state.getValue(BlockStateProperties.LIT) != active) { BlockState newState = state.setValue(BlockStateProperties.LIT, active); - this.setState(newState); + this.setBlock(newState); return true; } return false; diff --git a/src/main/java/com/teammoeg/chorda/block/CGuiBlock.java b/src/main/java/com/teammoeg/chorda/block/CGuiBlock.java index dfd444494..44bd681a7 100644 --- a/src/main/java/com/teammoeg/chorda/block/CGuiBlock.java +++ b/src/main/java/com/teammoeg/chorda/block/CGuiBlock.java @@ -92,11 +92,17 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player if (b) return InteractionResult.SUCCESS; } - if (tile instanceof IInteractionObjectIE interaction && hand == InteractionHand.MAIN_HAND && !player.isShiftKeyDown()) { - BlockEntity master = interaction.getGuiMaster(); - if (master instanceof MenuProvider menu) - NetworkHooks.openScreen((ServerPlayer)player, menu,master.getBlockPos()); - return InteractionResult.SUCCESS; + if(hand == InteractionHand.MAIN_HAND && !player.isShiftKeyDown()) { + if (tile instanceof IInteractionObjectIE interaction) { + BlockEntity master = interaction.getGuiMaster(); + if (master instanceof MenuProvider menu) + NetworkHooks.openScreen((ServerPlayer)player, menu,master.getBlockPos()); + return InteractionResult.SUCCESS; + } + if (tile instanceof MenuProvider menu) { + NetworkHooks.openScreen((ServerPlayer)player, menu,tile.getBlockPos()); + return InteractionResult.SUCCESS; + } } return superResult; } diff --git a/src/main/java/com/teammoeg/chorda/block/entity/BlockStateAccess.java b/src/main/java/com/teammoeg/chorda/block/entity/BlockStateAccess.java new file mode 100644 index 000000000..42e49bc6c --- /dev/null +++ b/src/main/java/com/teammoeg/chorda/block/entity/BlockStateAccess.java @@ -0,0 +1,8 @@ +package com.teammoeg.chorda.block.entity; + +import net.minecraft.world.level.block.state.BlockState; + +public interface BlockStateAccess { + public BlockState getBlock(); + public void setBlock(BlockState state); +} diff --git a/src/main/java/com/teammoeg/chorda/block/entity/CBlockEntity.java b/src/main/java/com/teammoeg/chorda/block/entity/CBlockEntity.java index b7e45e56f..8ecd403bb 100644 --- a/src/main/java/com/teammoeg/chorda/block/entity/CBlockEntity.java +++ b/src/main/java/com/teammoeg/chorda/block/entity/CBlockEntity.java @@ -19,23 +19,139 @@ package com.teammoeg.chorda.block.entity; -import blusunrize.immersiveengineering.common.blocks.IEBaseBlockEntity; -import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.core.BlockPos; - -public abstract class CBlockEntity extends IEBaseBlockEntity implements SyncableBlockEntity { - +import net.minecraft.world.level.block.state.BlockState; +/** + * CBlockEntity + * blockentity with our basic code, for convenience, some code are inspired by Immersive Engineering + * */ +public abstract class CBlockEntity extends BlockEntity implements SyncableBlockEntity,BlockStateAccess { + protected boolean isUnloaded; public CBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); } + @Override + public void load(CompoundTag nbtIn) + { + super.load(nbtIn); + this.readCustomNBT(nbtIn, false); + } + + public abstract void readCustomNBT(CompoundTag nbt, boolean descPacket); + + @Override + protected void saveAdditional(CompoundTag nbt) + { + super.saveAdditional(nbt); + this.writeCustomNBT(nbt, false); + } + + public abstract void writeCustomNBT(CompoundTag nbt, boolean descPacket); + + @Override + public ClientboundBlockEntityDataPacket getUpdatePacket() + { + return ClientboundBlockEntityDataPacket.create(this, be -> { + CompoundTag nbttagcompound = new CompoundTag(); + this.writeCustomNBT(nbttagcompound, true); + return nbttagcompound; + }); + } + + @Override + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) + { + CompoundTag nonNullTag = pkt.getTag()!=null?pkt.getTag(): new CompoundTag(); + this.readCustomNBT(nonNullTag, true); + } + + @Override + public void handleUpdateTag(CompoundTag tag) + { + this.readCustomNBT(tag, true); + } + @Override + public CompoundTag getUpdateTag() + { + CompoundTag nbt = super.getUpdateTag(); + writeCustomNBT(nbt, true); + return nbt; + } + @Override + public boolean triggerEvent(int id, int type) + { + if(id==0||id==255) + { + syncData(); + return true; + } + else if(id==254) + { + BlockState state = level.getBlockState(worldPosition); + level.sendBlockUpdated(worldPosition, state, state, 3); + return true; + } + return super.triggerEvent(id, type); + } public void syncData() { this.setChanged(); - // level.markAndNotifyBlock(worldPosition, level.getChunkAt(pos), getBlockState(), getBlockState(), 4, 128); level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); + level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); } + @Override + public final void setRemoved() + { + if(!isUnloaded) + onRemoved(); + super.setRemoved(); + } + public void onRemoved(){ + + } + @Override + public void onLoad() + { + super.onLoad(); + isUnloaded = false; + } + @Override + public void onChunkUnloaded() + { + super.onChunkUnloaded(); + isUnloaded = true; + onUnloaded(); + } + public void onUnloaded(){ + } + protected void setChunkUnsaved() + { + if(this.level.hasChunkAt(this.worldPosition)) + this.level.getChunkAt(this.worldPosition).setUnsaved(true); + } + @Override + public void setChanged() + { + setChunkUnsaved(); + BlockState state = getBlockState(); + if(state.hasAnalogOutputSignal()) + this.level.updateNeighbourForOutputSignal(this.worldPosition, state.getBlock()); + } + @Override + public BlockState getBlock() { + return this.getBlockState(); + } + @Override + public void setBlock(BlockState state) { + this.level.setBlock(this.worldPosition, state, 4); + this.setBlockState(state); + + } } diff --git a/src/main/java/com/teammoeg/chorda/capability/ChangeDetectedFluidHandler.java b/src/main/java/com/teammoeg/chorda/capability/capabilities/ChangeDetectedFluidHandler.java similarity index 98% rename from src/main/java/com/teammoeg/chorda/capability/ChangeDetectedFluidHandler.java rename to src/main/java/com/teammoeg/chorda/capability/capabilities/ChangeDetectedFluidHandler.java index dec96d26f..eefdae317 100644 --- a/src/main/java/com/teammoeg/chorda/capability/ChangeDetectedFluidHandler.java +++ b/src/main/java/com/teammoeg/chorda/capability/capabilities/ChangeDetectedFluidHandler.java @@ -17,7 +17,7 @@ * */ -package com.teammoeg.chorda.capability; +package com.teammoeg.chorda.capability.capabilities; import com.teammoeg.chorda.block.entity.SyncableBlockEntity; diff --git a/src/main/java/com/teammoeg/chorda/capability/ChangeDetectedItemHandler.java b/src/main/java/com/teammoeg/chorda/capability/capabilities/ChangeDetectedItemHandler.java similarity index 97% rename from src/main/java/com/teammoeg/chorda/capability/ChangeDetectedItemHandler.java rename to src/main/java/com/teammoeg/chorda/capability/capabilities/ChangeDetectedItemHandler.java index bad5892d4..af5945550 100644 --- a/src/main/java/com/teammoeg/chorda/capability/ChangeDetectedItemHandler.java +++ b/src/main/java/com/teammoeg/chorda/capability/capabilities/ChangeDetectedItemHandler.java @@ -17,7 +17,7 @@ * */ -package com.teammoeg.chorda.capability; +package com.teammoeg.chorda.capability.capabilities; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/teammoeg/chorda/capability/CurioCapabilityProvider.java b/src/main/java/com/teammoeg/chorda/capability/capabilities/CurioCapabilityProvider.java similarity index 96% rename from src/main/java/com/teammoeg/chorda/capability/CurioCapabilityProvider.java rename to src/main/java/com/teammoeg/chorda/capability/capabilities/CurioCapabilityProvider.java index fd6b65cc1..04a66affb 100644 --- a/src/main/java/com/teammoeg/chorda/capability/CurioCapabilityProvider.java +++ b/src/main/java/com/teammoeg/chorda/capability/capabilities/CurioCapabilityProvider.java @@ -17,7 +17,7 @@ * */ -package com.teammoeg.chorda.capability; +package com.teammoeg.chorda.capability.capabilities; import net.minecraft.core.Direction; import net.minecraftforge.common.capabilities.Capability; diff --git a/src/main/java/com/teammoeg/chorda/capability/capabilities/ItemHandlerWrapper.java b/src/main/java/com/teammoeg/chorda/capability/capabilities/ItemHandlerWrapper.java new file mode 100644 index 000000000..e4cb07c78 --- /dev/null +++ b/src/main/java/com/teammoeg/chorda/capability/capabilities/ItemHandlerWrapper.java @@ -0,0 +1,41 @@ +package com.teammoeg.chorda.capability.capabilities; + +import java.util.function.Supplier; + +import org.jetbrains.annotations.NotNull; + +import lombok.Getter; +import lombok.Setter; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.IItemHandlerModifiable; + +public class ItemHandlerWrapper implements IItemHandlerModifiable { + private final Supplier intern; + public void setStackInSlot(int slot, @NotNull ItemStack stack) { + intern.get().setStackInSlot(slot, stack); + } + public int getSlots() { + return intern.get().getSlots(); + } + public @NotNull ItemStack getStackInSlot(int slot) { + return intern.get().getStackInSlot(slot); + } + public @NotNull ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { + return intern.get().insertItem(slot, stack, simulate); + } + public @NotNull ItemStack extractItem(int slot, int amount, boolean simulate) { + return intern.get().extractItem(slot, amount, simulate); + } + public int getSlotLimit(int slot) { + return intern.get().getSlotLimit(slot); + } + public boolean isItemValid(int slot, @NotNull ItemStack stack) { + return intern.get().isItemValid(slot, stack); + } + public ItemHandlerWrapper(Supplier intern) { + super(); + this.intern = intern; + } + + +} diff --git a/src/main/java/com/teammoeg/chorda/client/widget/ImageButton.java b/src/main/java/com/teammoeg/chorda/client/widget/HoverableImageButton.java similarity index 78% rename from src/main/java/com/teammoeg/chorda/client/widget/ImageButton.java rename to src/main/java/com/teammoeg/chorda/client/widget/HoverableImageButton.java index 5a4ed669c..6a38044fe 100644 --- a/src/main/java/com/teammoeg/chorda/client/widget/ImageButton.java +++ b/src/main/java/com/teammoeg/chorda/client/widget/HoverableImageButton.java @@ -28,31 +28,31 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.Component; -public class ImageButton extends Button { +public class HoverableImageButton extends Button { int xTexStart; int yTexStart; private final int textureWidth; private final int textureHeight; int state; ResourceLocation TEXTURE; - public ImageButton(ResourceLocation texture,int xIn, int yIn, int widthIn, int heightIn, int xTexStartIn, int yTexStartIn, + public HoverableImageButton(ResourceLocation texture,int xIn, int yIn, int widthIn, int heightIn, int xTexStartIn, int yTexStartIn, Button.OnPress onPressIn) { this(texture,xIn, yIn, widthIn, heightIn, xTexStartIn, yTexStartIn, null, onPressIn); } - public ImageButton(ResourceLocation texture,int xIn, int yIn, int widthIn, int heightIn, int xTexStartIn, int yTexStartIn, + public HoverableImageButton(ResourceLocation texture,int xIn, int yIn, int widthIn, int heightIn, int xTexStartIn, int yTexStartIn, Tooltip tt, Button.OnPress onPressIn) { this(texture,xIn, yIn, widthIn, heightIn, xTexStartIn, yTexStartIn, 256, 256, onPressIn, tt, Components.empty()); } - public ImageButton(ResourceLocation texture,int x, int y, int width, int height, int xTexStart, int yTexStart, int textureWidth, + public HoverableImageButton(ResourceLocation texture,int x, int y, int width, int height, int xTexStart, int yTexStart, int textureWidth, int textureHeight, Button.OnPress onPress, Component title) { this(texture,x, y, width, height, xTexStart, yTexStart, textureWidth, textureHeight, onPress, null, title); } - public ImageButton(ResourceLocation texture,int p_i244513_1_, int p_i244513_2_, int p_i244513_3_, int p_i244513_4_, int p_i244513_5_, + public HoverableImageButton(ResourceLocation texture,int p_i244513_1_, int p_i244513_2_, int p_i244513_3_, int p_i244513_4_, int p_i244513_5_, int p_i244513_6_, int p_i244513_9_, int p_i244513_10_, Button.OnPress p_i244513_11_, Tooltip p_i244513_12_, Component p_i244513_13_) { super(Button.builder(p_i244513_13_, p_i244513_11_).bounds(p_i244513_2_, p_i244513_3_, p_i244513_4_, p_i244513_5_).tooltip(p_i244513_12_)); @@ -67,8 +67,8 @@ public void setPosition(int xIn, int yIn) { this.setX(xIn); this.setY(yIn); } - - public void renderButton(GuiGraphics matrixStack, int mouseX, int mouseY, float partialTicks) { + @Override + public void renderWidget(GuiGraphics matrixStack, int mouseX, int mouseY, float partialTicks) { int i = 0, j = state * this.height; if (this.isHovered()) { diff --git a/src/main/java/com/teammoeg/chorda/client/widget/TabImageButton.java b/src/main/java/com/teammoeg/chorda/client/widget/TabImageButton.java new file mode 100644 index 000000000..770cdb44d --- /dev/null +++ b/src/main/java/com/teammoeg/chorda/client/widget/TabImageButton.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2024 TeamMoeg + * + * This file is part of Frosted Heart. + * + * Frosted Heart is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * Frosted Heart is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Frosted Heart. If not, see . + * + */ + +package com.teammoeg.chorda.client.widget; + +import java.util.function.Supplier; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.teammoeg.chorda.lang.Components; + +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.Button; +import net.minecraft.client.gui.components.Tooltip; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.network.chat.Component; + +public class TabImageButton extends Button { + int xTexStart; + int yTexStart; + private final int textureWidth; + private final int textureHeight; + final int tab; + Supplier currentTab; + ResourceLocation TEXTURE; + public TabImageButton(ResourceLocation texture,int xIn, int yIn, int widthIn, int heightIn, int xTexStartIn, int yTexStartIn,int tab, + Button.OnPress onPressIn) { + this(texture,xIn, yIn, widthIn, heightIn, xTexStartIn, yTexStartIn, tab, null, onPressIn); + } + + public TabImageButton(ResourceLocation texture,int xIn, int yIn, int widthIn, int heightIn, int xTexStartIn, int yTexStartIn,int tab, + Tooltip tt, Button.OnPress onPressIn) { + + this(texture,xIn, yIn, widthIn, heightIn, xTexStartIn, yTexStartIn, 256, 256, tab, onPressIn, tt, + Components.empty()); + } + + public TabImageButton(ResourceLocation texture,int x, int y, int width, int height, int xTexStart, int yTexStart, int textureWidth, + int textureHeight,int tab, Button.OnPress onPress, Component title) { + this(texture,x, y, width, height, xTexStart, yTexStart, textureWidth, textureHeight, tab, onPress, null, title); + } + + public TabImageButton(ResourceLocation texture,int p_i244513_1_, int p_i244513_2_, int p_i244513_3_, int p_i244513_4_, int p_i244513_5_, + int p_i244513_6_, int p_i244513_9_, int p_i244513_10_,int tab, Button.OnPress p_i244513_11_, + Tooltip p_i244513_12_, Component p_i244513_13_) { + super(Button.builder(p_i244513_13_, p_i244513_11_).bounds(p_i244513_2_, p_i244513_3_, p_i244513_4_, p_i244513_5_).tooltip(p_i244513_12_)); + this.TEXTURE=texture; + this.textureWidth = p_i244513_9_; + this.textureHeight = p_i244513_10_; + this.xTexStart = p_i244513_5_; + this.yTexStart = p_i244513_6_; + this.tab=tab; + } + public TabImageButton bind(Supplier supp) { + this.currentTab=supp; + return this; + } + public void setPosition(int xIn, int yIn) { + this.setX(xIn); + this.setY(yIn); + } + @Override + public void renderWidget(GuiGraphics matrixStack, int mouseX, int mouseY, float partialTicks) { + int current=0; + if(currentTab!=null) + current=currentTab.get(); + int i = (tab==current)?0: this.width; + + + RenderSystem.enableDepthTest(); + matrixStack.blit(TEXTURE, this.getX(), this.getY(), this.xTexStart + i, this.yTexStart, this.width, this.height, + this.textureWidth, this.textureHeight); + + } +} \ No newline at end of file diff --git a/src/main/java/com/teammoeg/chorda/io/SerializeUtil.java b/src/main/java/com/teammoeg/chorda/io/SerializeUtil.java index 540991e7d..62974b809 100644 --- a/src/main/java/com/teammoeg/chorda/io/SerializeUtil.java +++ b/src/main/java/com/teammoeg/chorda/io/SerializeUtil.java @@ -34,8 +34,6 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import org.jetbrains.annotations.NotNull; - import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -48,13 +46,11 @@ import com.teammoeg.chorda.util.CRegistryHelper; import net.minecraft.world.item.ItemStack; -import net.minecraft.Util; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.TagParser; import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; -// TODO: Auto-generated Javadoc /** * utils wrapped function for serialization and networking. diff --git a/src/main/java/com/teammoeg/chorda/menu/CBaseMenu.java b/src/main/java/com/teammoeg/chorda/menu/CBaseMenu.java index 27a28d2d7..600bba483 100644 --- a/src/main/java/com/teammoeg/chorda/menu/CBaseMenu.java +++ b/src/main/java/com/teammoeg/chorda/menu/CBaseMenu.java @@ -33,7 +33,7 @@ import com.teammoeg.chorda.network.ContainerDataSyncMessageS2C; import com.teammoeg.chorda.network.ContainerOperationMessageC2S; -import blusunrize.immersiveengineering.common.gui.IEContainerMenu.MoveItemsFunc; +import lombok.Getter; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; @@ -222,6 +222,7 @@ public Function build(CBaseMenu t) { private final Lazy validator=Lazy.of(()->buildValidator(new Validator())); protected Lazy> moveFunction = Lazy.of(() -> defineQuickMoveStack().build(this)); protected List> specialDataSlots = new ArrayList<>(); + @Getter private Player player; /** * Constructor of c base menu diff --git a/src/main/java/com/teammoeg/chorda/menu/CBlockEntityMenu.java b/src/main/java/com/teammoeg/chorda/menu/CBlockEntityMenu.java index 6c5a86359..f27ec061a 100644 --- a/src/main/java/com/teammoeg/chorda/menu/CBlockEntityMenu.java +++ b/src/main/java/com/teammoeg/chorda/menu/CBlockEntityMenu.java @@ -19,8 +19,6 @@ package com.teammoeg.chorda.menu; -import com.teammoeg.chorda.menu.CBaseMenu.Validator; - import blusunrize.immersiveengineering.common.gui.BlockEntityInventory; import blusunrize.immersiveengineering.common.util.inventory.IIEInventory; import net.minecraft.world.Container; @@ -31,6 +29,7 @@ public abstract class CBlockEntityMenu extends CBaseMenu { protected T blockEntity; public Container inv; + public T getBlock() { return blockEntity; diff --git a/src/main/java/com/teammoeg/chorda/menu/CCustomMenuSlot.java b/src/main/java/com/teammoeg/chorda/menu/CCustomMenuSlot.java index 32d4367a6..fddd9a488 100644 --- a/src/main/java/com/teammoeg/chorda/menu/CCustomMenuSlot.java +++ b/src/main/java/com/teammoeg/chorda/menu/CCustomMenuSlot.java @@ -26,8 +26,8 @@ import java.util.function.Function; import java.util.function.IntFunction; import java.util.function.Supplier; + import com.mojang.serialization.Codec; -import com.mojang.serialization.JsonOps; import com.teammoeg.chorda.io.CodecUtil; import com.teammoeg.chorda.io.registry.IdRegistry; diff --git a/src/main/java/com/teammoeg/chorda/menu/DummyMenuProvider.java b/src/main/java/com/teammoeg/chorda/menu/DummyMenuProvider.java index d4b6cd61d..580119e65 100644 --- a/src/main/java/com/teammoeg/chorda/menu/DummyMenuProvider.java +++ b/src/main/java/com/teammoeg/chorda/menu/DummyMenuProvider.java @@ -8,7 +8,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuConstructor; -import net.minecraft.world.inventory.MenuType; public class DummyMenuProvider implements MenuProvider { MenuConstructor type; diff --git a/src/main/java/com/teammoeg/chorda/menu/slots/ArmorSlotItemHandler.java b/src/main/java/com/teammoeg/chorda/menu/slots/ArmorSlotItemHandler.java new file mode 100644 index 000000000..d3853c1cd --- /dev/null +++ b/src/main/java/com/teammoeg/chorda/menu/slots/ArmorSlotItemHandler.java @@ -0,0 +1,70 @@ +package com.teammoeg.chorda.menu.slots; + +import com.mojang.datafixers.util.Pair; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.world.item.Equipable; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.SlotItemHandler; + +public class ArmorSlotItemHandler extends SlotItemHandler { + public static final ResourceLocation[] TEXTURE_EMPTY_SLOTS = new ResourceLocation[]{InventoryMenu.EMPTY_ARMOR_SLOT_BOOTS, InventoryMenu.EMPTY_ARMOR_SLOT_LEGGINGS, InventoryMenu.EMPTY_ARMOR_SLOT_CHESTPLATE, InventoryMenu.EMPTY_ARMOR_SLOT_HELMET}; + protected Player owner; + protected EquipmentSlot equipmentslot; + + + public ArmorSlotItemHandler(Player owner, EquipmentSlot equipmentslot,IItemHandler pContainer, int pSlot, int pX, int pY) { + super(pContainer, pSlot, pX, pY); + this.owner = owner; + this.equipmentslot = equipmentslot; + } + + public void setByPlayer(ItemStack p_270969_) { + onEquipItem(owner, equipmentslot, p_270969_, this.getItem()); + super.setByPlayer(p_270969_); + } + + void onEquipItem(Player pPlayer, EquipmentSlot pSlot, ItemStack pNewItem, ItemStack pOldItem) { + Equipable equipable = Equipable.get(pNewItem); + if (equipable != null) { + pPlayer.onEquipItem(pSlot, pOldItem, pNewItem); + } + + } + + /** + * Returns the maximum stack size for a given slot (usually the same as + * getInventoryStackLimit(), but 1 in + * the case of armor slots) + */ + public int getMaxStackSize() { + return 1; + } + + /** + * Check if the stack is allowed to be placed in this slot, used for armor slots + * as well as furnace fuel. + */ + public boolean mayPlace(ItemStack p_39746_) { + return p_39746_.canEquip(equipmentslot, owner); + } + + /** + * Return whether this slot's stack can be taken from this slot. + */ + public boolean mayPickup(Player p_39744_) { + ItemStack itemstack = this.getItem(); + return !itemstack.isEmpty() && !p_39744_.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? false + : super.mayPickup(p_39744_); + } + + public Pair getNoItemIcon() { + return Pair.of(InventoryMenu.BLOCK_ATLAS, TEXTURE_EMPTY_SLOTS[equipmentslot.getIndex()]); + } + +} diff --git a/src/main/java/com/teammoeg/chorda/menu/slots/OffHandSlotItemHandler.java b/src/main/java/com/teammoeg/chorda/menu/slots/OffHandSlotItemHandler.java new file mode 100644 index 000000000..3a4592f6d --- /dev/null +++ b/src/main/java/com/teammoeg/chorda/menu/slots/OffHandSlotItemHandler.java @@ -0,0 +1,40 @@ +package com.teammoeg.chorda.menu.slots; + +import com.mojang.datafixers.util.Pair; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.IItemHandler; + +public class OffHandSlotItemHandler extends ArmorSlotItemHandler { + + + + public OffHandSlotItemHandler(Player owner, IItemHandler pContainer, int pSlot, int pX, int pY) { + super(owner, EquipmentSlot.OFFHAND, pContainer, pSlot, pX, pY); + } + + @Override + public int getMaxStackSize() { + return container.getMaxStackSize(); + } + + @Override + public boolean mayPlace(ItemStack p_39746_) { + return true; + } + + @Override + public boolean mayPickup(Player p_39744_) { + return true; + } + + @Override + public Pair getNoItemIcon() { + return Pair.of(InventoryMenu.BLOCK_ATLAS, InventoryMenu.EMPTY_ARMOR_SLOT_SHIELD); + } + +} diff --git a/src/main/java/com/teammoeg/frostedheart/content/climate/block/wardrobe/WardrobeBlockEntity.java b/src/main/java/com/teammoeg/frostedheart/content/climate/block/wardrobe/WardrobeBlockEntity.java index 1deb09665..a45ebcc02 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/climate/block/wardrobe/WardrobeBlockEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/climate/block/wardrobe/WardrobeBlockEntity.java @@ -19,47 +19,45 @@ package com.teammoeg.frostedheart.content.climate.block.wardrobe; +import com.teammoeg.chorda.block.entity.CBlockEntity; import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; +import com.teammoeg.frostedheart.content.climate.player.PlayerTemperatureData.BodyPart; + import net.minecraft.core.BlockPos; -import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.world.ContainerHelper; +import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.items.ItemStackHandler; -public class WardrobeBlockEntity extends RandomizableContainerBlockEntity { - private NonNullList wardrobeInventory = NonNullList.withSize(24, ItemStack.EMPTY); +public class WardrobeBlockEntity extends CBlockEntity implements MenuProvider { + public static final int NUM_INVENTORY=3; + ItemStackHandler[] invs=new ItemStackHandler[NUM_INVENTORY]; public WardrobeBlockEntity(BlockPos pos, BlockState state) { super(FHBlockEntityTypes.WARDROBE.get(), pos, state); - } - - - - @Override - public NonNullList getItems() { - return wardrobeInventory; - } + int countSlot=5; + for(BodyPart bp:BodyPart.values()) { + countSlot+=bp.slotNum; + } + for(int i=0;i itemsIn) { - this.wardrobeInventory = itemsIn; + @Override + public int getSlotLimit(int slot) { + return 1; + } + + }; + } } - public Component getDisplayName() { return Component.translatable("container.wardrobe"); } - @Override - protected Component getDefaultName() { - return null; - } - public AbstractContainerMenu createMenu(int id, Inventory playerInventory, Player player) { return new WardrobeMenu( id, @@ -67,24 +65,24 @@ public AbstractContainerMenu createMenu(int id, Inventory playerInventory, Playe this ); } + @Override + public void readCustomNBT(CompoundTag nbt, boolean descPacket) { + if(!descPacket) + for(int i=0;i { - int page; - protected class PagedLiningSlot extends LiningSlot{ - final int slotPage; - - public PagedLiningSlot(Player owner, BodyPart part, IItemHandler pContainer, int pSlot, int pX, int pY, - int slotPage) { - super(owner, part, pContainer, pSlot, pX, pY); - this.slotPage = slotPage; - } - - @Override - public boolean isActive() { - return slotPage==page; - } - - } + CDataSlot page=CCustomMenuSlot.SLOT_INT.create(this); + ItemHandlerWrapper wrap; public WardrobeMenu(int id, Inventory inventoryPlayer, WardrobeBlockEntity tile) { super(FHMenuTypes.WARDROBE.get(),tile,id, inventoryPlayer.player,37); - blockEntity=tile; + wrap=new ItemHandlerWrapper(()->tile.invs[page.getValue()]); + PlayerTemperatureData ptd = PlayerTemperatureData.getCapability(inventoryPlayer.player).resolve().get(); + int y0=6; + this.addSlot(new ArmorSlot(inventoryPlayer.player, EquipmentSlot.HEAD, inventoryPlayer, 39, 6, y0)); + this.addSlot(new ArmorSlot(inventoryPlayer.player, EquipmentSlot.CHEST, inventoryPlayer, 38, 6, y0 + 18)); + this.addSlot(new OffHandSlot(inventoryPlayer.player, inventoryPlayer, 40, 6, y0 + 18 * 2)); + this.addSlot(new ArmorSlot(inventoryPlayer.player, EquipmentSlot.LEGS, inventoryPlayer, 37, 6, y0 + 18 * 3)); + this.addSlot(new ArmorSlot(inventoryPlayer.player, EquipmentSlot.FEET, inventoryPlayer, 36, 6, y0 + 18 * 4)); + for (int j = 0; j < 5; j++) { + BodyPart bp=BodyPart.values()[j]; + BodyPartData clothes=ptd.clothesOfParts.get(bp); + for (int k = 0; k < clothes.getSize(); ++k) { + this.addSlot(new LiningSlot(inventoryPlayer.player,bp, + clothes.clothes, k, 6+18 + k * 18, 6+18*j)); + } + } + y0=6; + this.addSlot(new ArmorSlotItemHandler(inventoryPlayer.player, EquipmentSlot.HEAD, wrap, 3, 121, y0)); + this.addSlot(new ArmorSlotItemHandler(inventoryPlayer.player, EquipmentSlot.CHEST, wrap, 2, 121, y0 + 18)); + this.addSlot(new OffHandSlotItemHandler(inventoryPlayer.player, wrap, 4, 6, y0 + 18 * 2)); + this.addSlot(new ArmorSlotItemHandler(inventoryPlayer.player, EquipmentSlot.LEGS, wrap, 1, 121, y0 + 18 * 3)); + this.addSlot(new ArmorSlotItemHandler(inventoryPlayer.player, EquipmentSlot.FEET, wrap, 0, 121, y0 + 18 * 4)); + int slotOrder=4; + for (int j = 0; j < 5; j++) { + BodyPart bp=BodyPart.values()[j]; + + for (int k = 0; k < bp.slotNum; ++k) { + this.addSlot(new LiningSlot(inventoryPlayer.player,bp,wrap, ++slotOrder, 121+18 + k * 18, 6+18*j)); + } + } /*for(int p=0;p<3;p++) { for(int k=0;k<1;++k) { this.addSlot(new PagedLiningSlot(inventoryPlayer.player,PlayerTemperatureData.BodyPart.HEAD,blockEntity, 8*p+0+k, 100+k*18, 7,p)); @@ -44,7 +71,29 @@ public WardrobeMenu(int id, Inventory inventoryPlayer, WardrobeBlockEntity tile) this.addSlot(new PagedLiningSlot(inventoryPlayer.player,PlayerTemperatureData.BodyPart.FEET,blockEntity, 8*p+7+k, 100+k*18, 76,p)); } }*/ - super.addPlayerInventory(inventoryPlayer, 8, 120, 178); + super.addPlayerInventory(inventoryPlayer, 18, 120, 178); + } + public void swapSlots() { + int tslots=wrap.getSlots(); + for(int i=0;i { - private static final ResourceLocation TEXTURE = FHClientUtils.makeGuiTextureLocation("changing"); - private static final ResourceLocation TEXTURE_CLOSET = FHClientUtils.makeGuiTextureLocation("closet"); + private static final ResourceLocation TEXTURE = FHClientUtils.makeGuiTextureLocation("closet"); public WardrobeScreen(WardrobeMenu inventorySlotsIn, Inventory inv, Component title) { super(inventorySlotsIn, inv, title, TEXTURE); super.imageHeight = 202; super.imageWidth = 261; } + + @Override + protected void init() { + this.addRenderableWidget(new HoverableImageButton(TEXTURE,leftPos + 88, topPos + 40, 21, 21, 197, 63,btn -> { menu.sendMessage(1, 0);})); + for(int i=0;i{ menu.sendMessage(2, ctab);}).bind(menu.page.asSupplier())); + } + super.init(); + } + protected void drawBackgroundTexture(GuiGraphics graphics) { - graphics.blit(background, leftPos, topPos, 0, 0, 176, 202); - graphics.blit(TEXTURE_CLOSET, leftPos+176, topPos, 0, 0, 85, 114); + graphics.blit(background, leftPos, topPos, 0, 0, 197, 202); } protected void drawContainerBackgroundPre(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) { int i = this.leftPos; int j = this.topPos; - InventoryScreen.renderEntityInInventoryFollowsMouse(pGuiGraphics, i + 60, j + 97, 45, (float) (i + 40) - pMouseX, - (float) (j + 75 - 50) - pMouseY, ClientUtils.getPlayer()); + InventoryScreen.renderEntityInInventoryFollowsMouse(pGuiGraphics, i - 60, j + 99, 45, (float) (i -80) - pMouseX, + (float) (j + 77 - 50) - pMouseY, ClientUtils.getPlayer()); } @Override diff --git a/src/main/java/com/teammoeg/frostedheart/content/climate/player/PlayerTemperatureData.java b/src/main/java/com/teammoeg/frostedheart/content/climate/player/PlayerTemperatureData.java index 56f3a0e3e..68bffe65b 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/climate/player/PlayerTemperatureData.java +++ b/src/main/java/com/teammoeg/frostedheart/content/climate/player/PlayerTemperatureData.java @@ -46,24 +46,26 @@ public class PlayerTemperatureData implements NBTSerializable { public enum BodyPart implements StringRepresentable{ - HEAD(EquipmentSlot.HEAD, 0.1f, 0.1f), // 10% area - TORSO(EquipmentSlot.CHEST, 0.4f, 0.4f), // 40% area + HEAD(EquipmentSlot.HEAD, 0.1f, 0.1f,1), // 10% area + TORSO(EquipmentSlot.CHEST, 0.4f, 0.4f,3), // 40% area - HANDS(EquipmentSlot.MAINHAND, 0.05f, 0.05f), // 5% area - LEGS(EquipmentSlot.LEGS, 0.4f, 0.4f), // 40% area - FEET(EquipmentSlot.FEET, 0.05f, 0.05f); // 5% area + HANDS(EquipmentSlot.MAINHAND, 0.05f, 0.05f,1), // 5% area + LEGS(EquipmentSlot.LEGS, 0.4f, 0.4f,3), // 40% area + FEET(EquipmentSlot.FEET, 0.05f, 0.05f,1); // 5% area public final EquipmentSlot slot; public final float area; public final float affectsCore; + public final int slotNum; private final static Map VANILLA_MAP=Util.make(new EnumMap<>(EquipmentSlot.class),t->{ for(BodyPart part:BodyPart.values()) if(part.slot!=null) t.put(part.slot, part); }); - private BodyPart(EquipmentSlot slot,float area,float affectsCore) { + private BodyPart(EquipmentSlot slot,float area,float affectsCore,int slotNum) { this.slot = slot; this.area=area; this.affectsCore=affectsCore; + this.slotNum=slotNum; } @Override @@ -100,11 +102,8 @@ public void deathResetTemperature() { } } public PlayerTemperatureData() { - clothesOfParts.put(BodyPart.HEAD, new BodyPartData(1)); - clothesOfParts.put(BodyPart.HANDS, new BodyPartData(1)); - clothesOfParts.put(BodyPart.FEET, new BodyPartData(1)); - clothesOfParts.put(BodyPart.TORSO, new BodyPartData(3)); - clothesOfParts.put(BodyPart.LEGS, new BodyPartData(3)); + for(BodyPart bp:BodyPart.values()) + clothesOfParts.put(bp, new BodyPartData(bp.slotNum)); } public FHTemperatureDifficulty getDifficulty() { if(difficulty==null) diff --git a/src/main/java/com/teammoeg/frostedheart/content/incubator/IncubatorTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/incubator/IncubatorTileEntity.java index 60a94e214..a0ef139d6 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/incubator/IncubatorTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/incubator/IncubatorTileEntity.java @@ -86,7 +86,7 @@ public class IncubatorTileEntity extends CBlockEntity implements CTickableBlockE public FluidStack drain(FluidStack resource, FluidAction action) { FluidStack fs = fluid[1].drain(resource, action); if (!fs.isEmpty() && action == FluidAction.EXECUTE) { - markContainingBlockForUpdate(null); + syncData(); } return fs; } @@ -95,7 +95,7 @@ public FluidStack drain(FluidStack resource, FluidAction action) { public FluidStack drain(int maxDrain, FluidAction action) { FluidStack fs = fluid[1].drain(maxDrain, action); if (!fs.isEmpty() && action == FluidAction.EXECUTE) { - markContainingBlockForUpdate(null); + syncData(); } return fs; } @@ -104,7 +104,7 @@ public FluidStack drain(int maxDrain, FluidAction action) { public int fill(FluidStack resource, FluidAction action) { int f = fluid[0].fill(resource, action); if (f > 0 && action == FluidAction.EXECUTE) { - markContainingBlockForUpdate(null); + syncData(); } return f; @@ -276,7 +276,7 @@ public void tick() { lprocess = 0; this.setActive(false); this.setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); return; } if (fuel <= 0) { @@ -305,7 +305,7 @@ public void tick() { efficiency -= 0.005F; this.setActive(false); this.setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); return; } } @@ -324,7 +324,7 @@ public void tick() { } this.setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); } else if (!out.isEmpty() || !outfluid.isEmpty()) { if (ItemHandlerHelper.canItemStacksStack(out, inventory.get(3))) { ItemStack is = inventory.get(3); @@ -362,7 +362,7 @@ public void tick() { isFoodRecipe = false; lprocess = 0; this.setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); return; } } @@ -377,7 +377,7 @@ public void tick() { catalyst.shrink(1); efficiency = 0.2f; this.setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); return; } if (efficiency > 0.01) { @@ -397,7 +397,7 @@ public void tick() { water = 1; this.setActive(true); this.setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); return; } } @@ -415,7 +415,7 @@ public void tick() { this.setActive(false); if (changed) { this.setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); } } diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/charger/ChargerTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/charger/ChargerTileEntity.java index 07e8f0dfc..9fe174fc7 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/charger/ChargerTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/charger/ChargerTileEntity.java @@ -28,6 +28,7 @@ import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation; import com.teammoeg.chorda.block.CBlockInterfaces; +import com.teammoeg.chorda.block.entity.CBlockEntity; import com.teammoeg.chorda.block.entity.CTickableBlockEntity; import com.teammoeg.chorda.util.CUtils; import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; @@ -59,7 +60,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; -public class ChargerTileEntity extends IEBaseBlockEntity implements CTickableBlockEntity, CBlockInterfaces.IActiveState, IHaveGoggleInformation, HeatNetworkProvider { +public class ChargerTileEntity extends CBlockEntity implements CTickableBlockEntity, CBlockInterfaces.IActiveState, IHaveGoggleInformation, HeatNetworkProvider { public static final int INPUT_SLOT = 0; public static final int OUTPUT_SLOT = 1; @@ -136,7 +137,7 @@ public InteractionResult onClick(Player pe, ItemStack is) { ItemStack gain = cr.output.copy(); CUtils.giveItem(pe, gain); setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); } drawEffect(); return InteractionResult.SUCCESS; @@ -154,7 +155,7 @@ public InteractionResult onClick(Player pe, ItemStack is) { ItemStack gain = sr.assemble(null, this.level.registryAccess()).copy(); CUtils.giveItem(pe, gain); setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); } drawEffect(); return InteractionResult.SUCCESS; @@ -172,7 +173,7 @@ public InteractionResult onClick(Player pe, ItemStack is) { ItemStack gain = sr.assemble(null, this.level.registryAccess()).copy(); CUtils.giveItem(pe, gain); setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); } drawEffect(); return InteractionResult.SUCCESS; @@ -197,7 +198,7 @@ public void tick() { power += (float) (actual * 10); this.setActive(true); setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); } else this.setActive(false); } else if (getIsActive()) { diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/fountain/FountainTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/fountain/FountainTileEntity.java index bfb579e0c..4ad654e64 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/fountain/FountainTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/fountain/FountainTileEntity.java @@ -21,6 +21,7 @@ import blusunrize.immersiveengineering.common.blocks.IEBaseBlockEntity; import com.teammoeg.chorda.block.CBlockInterfaces; +import com.teammoeg.chorda.block.entity.CBlockEntity; import com.teammoeg.chorda.block.entity.CTickableBlockEntity; import com.teammoeg.frostedheart.bootstrap.common.FHAttributes; import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes; @@ -44,7 +45,7 @@ import javax.annotation.Nonnull; import java.util.UUID; -public class FountainTileEntity extends IEBaseBlockEntity implements CTickableBlockEntity, CBlockInterfaces.IActiveState { +public class FountainTileEntity extends CBlockEntity implements CTickableBlockEntity, CBlockInterfaces.IActiveState { public static final int RANGE_PER_NOZZLE = 1; public static final int MAX_HEIGHT = 5; @@ -85,10 +86,6 @@ public void readCustomNBT(CompoundTag nbt, boolean descPacket) { lastTemp = nbt.getFloat("lastTemp"); } - @Override - public void receiveMessageFromServer(CompoundTag message) { - super.receiveMessageFromServer(message); - } @Override public void tick() { @@ -132,13 +129,13 @@ public void tick() { power--; } setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); } else this.setActive(false); // grant player effect if structure is valid if (height > 0 && power > 0) { setChanged(); - this.markContainingBlockForUpdate(null); + this.syncData(); adjustHeat(getRange()); for (Player p : this.getLevel().players()) { @@ -172,7 +169,7 @@ public void tick() { private BlockPos findWater() { if (getRange() == 0) return null; - BlockState state = getState(); + BlockState state = getBlock(); BlockPos pos = null; int tries = 0; @@ -242,8 +239,8 @@ public void refill() { @Override - public void setRemovedIE() { - super.setRemovedIE(); + public void onRemoved() { + super.onRemoved(); removeHeat(); for (int i = 0; i < MAX_HEIGHT; i++) { diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/sauna/SaunaTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/sauna/SaunaTileEntity.java index 6ffb4e16a..4d55392eb 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/sauna/SaunaTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/sauna/SaunaTileEntity.java @@ -24,6 +24,7 @@ import blusunrize.immersiveengineering.common.util.inventory.IIEInventory; import com.teammoeg.chorda.block.CBlockInterfaces; +import com.teammoeg.chorda.block.entity.CBlockEntity; import com.teammoeg.chorda.block.entity.CTickableBlockEntity; import com.teammoeg.chorda.dataholders.team.CTeamDataManager; import com.teammoeg.chorda.util.CUtils; @@ -71,7 +72,7 @@ import java.util.Set; import java.util.UUID; -public class SaunaTileEntity extends IEBaseBlockEntity implements CTickableBlockEntity, CBlockInterfaces.IActiveState, IIEInventory, MenuProvider { +public class SaunaTileEntity extends CBlockEntity implements CTickableBlockEntity, CBlockInterfaces.IActiveState, IIEInventory, MenuProvider { private static final int RANGE = 5; private static final int WALL_HEIGHT = 3; @@ -240,10 +241,6 @@ public void readCustomNBT(CompoundTag nbt, boolean descPacket) { network.load(nbt, descPacket); } - @Override - public void receiveMessageFromServer(CompoundTag message) { - super.receiveMessageFromServer(message); - } private boolean structureIsValid() { floor.clear(); diff --git a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/steamcore/SteamCoreTileEntity.java b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/steamcore/SteamCoreTileEntity.java index 08ca29c42..7e13ddc9f 100644 --- a/src/main/java/com/teammoeg/frostedheart/content/steamenergy/steamcore/SteamCoreTileEntity.java +++ b/src/main/java/com/teammoeg/frostedheart/content/steamenergy/steamcore/SteamCoreTileEntity.java @@ -102,14 +102,15 @@ protected void write(CompoundTag tag, boolean client) { } @Override - public BlockState getState() { + public BlockState getBlock() { return this.getBlockState(); } @Override - public void setState(BlockState blockState) { - if (this.getWorldNonnull().getBlockState(this.worldPosition) == this.getState()) { + public void setBlock(BlockState blockState) { + if (this.getWorldNonnull().getBlockState(this.worldPosition) == this.getBlock()) { this.getWorldNonnull().setBlockAndUpdate(this.worldPosition, blockState); + super.setBlockState(blockState); } }