package info.u_team.u_team_test.container;

import info.u_team.u_team_core.api.sync.*;
import info.u_team.u_team_core.api.sync.MessageHolder.EmptyMessageHolder;
import info.u_team.u_team_core.container.UTileEntityContainer;
import info.u_team.u_team_test.init.TestContainers;
import info.u_team.u_team_test.tileentity.BasicTileEntityTileEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.network.PacketBuffer;

public class BasicTileEntityContainer extends UTileEntityContainer<BasicTileEntityTileEntity> {
	
	private EmptyMessageHolder valueMessage;
	private MessageHolder cooldownMessage;
	
	// Client
	public BasicTileEntityContainer(int id, PlayerInventory playerInventory, PacketBuffer buffer) {
		super(TestContainers.BASIC.get(), id, playerInventory, buffer);
	}
	
	// Server
	public BasicTileEntityContainer(int id, PlayerInventory playerInventory, BasicTileEntityTileEntity tileEntity) {
		super(TestContainers.BASIC.get(), id, playerInventory, tileEntity);
	}
	
	@Override
	protected void init(boolean server) {
		tileEntity.getSlots().ifPresent(handler -> appendInventory(handler, 2, 9, 8, 41));
		appendPlayerInventory(playerInventory, 8, 91);
		
		addServerToClientTracker(BufferReferenceHolder.createIntHolder(() -> tileEntity.value, value -> tileEntity.value = value));
		addServerToClientTracker(BufferReferenceHolder.createIntHolder(() -> tileEntity.cooldown, value -> tileEntity.cooldown = value));
		
		valueMessage = addClientToServerTracker(new EmptyMessageHolder(() -> {
			tileEntity.value += 100;
			tileEntity.markDirty();
		}));
		
		cooldownMessage = addClientToServerTracker(new MessageHolder(packet -> {
			tileEntity.cooldown = Math.min(packet.readShort(), 100);
			tileEntity.markDirty();
		}));
	}
	
	public EmptyMessageHolder getValueMessage() {
		return valueMessage;
	}
	
	public MessageHolder getCooldownMessage() {
		return cooldownMessage;
	}
}

@@ -1047,16 +1047,32 @@
 er) %7B%0A%09%09
+appendInventory(
 tileEnti
@@ -1088,53 +1088,8 @@
 ts()
-.ifPresent(handler -%3E appendInventory(handler
 , 2,
@@ -1098,17 +1098,16 @@
 , 8, 41)
-)
 ;%0A%09%09appe

Fix the basic tile entity container