• Posts

    • It doesn't exist anymore, you have to make the methods manually, it looks a bit like this: public class MyMessage { int value; public MyMessage(int value) { this.value = value; } public static void encode(MyMessage msg, PacketBuffer buffer) { buffer.writeInt(msg.value); } public static MyMessage decode(PacketBuffer buffer) { return new MyMessage(buffer.readInt()); //Remember to read in the same oreder you wrote! } public static void handle(MyMessage msg, Supplier<NetworkEvent.Context> ctx) { if (ctx.get().getDirection() == NetworkDirection.PLAY_TO_SERVER) { //Checks if the packet's direction is to the server ctx.get().enqueueWork(() -> { //Your code goes here }); } ctx.get().setPacketHandled(true); } } I'm 99% sure that's correct, kinda freestyled it though. To send it use SimpleChannel#sendToServer, don't forget to register it with SimpleChannel#registerMessage, and don't worry if you don't understand it right away, it took me a while to fully understand packets in 1.15.
    • https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/
    • In your container you create a new ItemStackHandler, which is completely separate from your TE and thus will lose all it's data after closing the container.
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • I changed TileEntity and Container class  but It still does nothing TE: package com.budrunbun.lavalamp.tileEntities; import com.budrunbun.lavalamp.containers.CheeseGeneratorContainer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.items.ItemStackHandler; import javax.annotation.Nullable; public class CheeseGeneratorTE extends TileEntity implements INamedContainerProvider { private final ItemStackHandler handler = new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { super.onContentsChanged(slot); markDirty(); } }; public CheeseGeneratorTE() { super(ModTileEntities.CHEESE_GENERATOR_TE); } @Override public void read(CompoundNBT compound) { handler.deserializeNBT(compound.getCompound("inv")); super.read(compound); } @Override public CompoundNBT write(CompoundNBT compound) { compound.put("inv",handler.serializeNBT()); return super.write(compound); } @Override public ITextComponent getDisplayName() { return new TranslationTextComponent("cheese_generator"); } @Nullable @Override public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new CheeseGeneratorContainer(windowId, playerInventory); } } Container: package com.budrunbun.lavalamp.containers; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.SlotItemHandler; import javax.annotation.Nonnull; public class CheeseGeneratorContainer extends Container { private final ItemStackHandler handler = new ItemStackHandler(1); public CheeseGeneratorContainer(int windowId, PlayerInventory playerInventory) { super(ModContainers.CHEESE_GENERATOR_CONTAINER, windowId); this.addSlot(new SlotItemHandler(handler, 0, 12 + 4 * 18, 8 + 2 * 18)); int leftCol = (184 - 162) / 2 + 1; for (int playerInvRow = 0; playerInvRow < 3; playerInvRow++) { for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++) { this.addSlot(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, 184 - (4 - playerInvRow) * 18 - 10)); } } for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++) { this.addSlot(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, 184 - 24)); } } @Override public boolean canInteractWith(PlayerEntity playerIn) { return true; } }  
  • Topics

  • Who's Online (See full list)