Search in sources :

Example 1 with IntReferenceHolder

use of net.minecraft.util.IntReferenceHolder in project Overloaded by CJ-MC-Mods.

the class InstantFurnaceContainer method broadcastChanges.

@Override
public void broadcastChanges() {
    int j;
    for (j = 0; j < this.slots.size(); ++j) {
        ItemStack itemstack = this.slots.get(j).getItem();
        itemstack = itemstack.isEmpty() ? ItemStack.EMPTY : itemstack.copy();
        this.lastSlots.set(j, itemstack);
        for (IContainerListener icontainerlistener : this.containerListeners) {
            icontainerlistener.slotChanged(this, j, itemstack);
        }
    }
    ContainerDataMessage message = new ContainerDataMessage(this.containerId);
    for (j = 0; j < this.dataSlots.size(); ++j) {
        IntReferenceHolder intreferenceholder = this.dataSlots.get(j);
        if (intreferenceholder.checkAndClearUpdateFlag()) {
            message.addData(j, intreferenceholder.get());
        }
    }
    if (!message.getData().isEmpty()) {
        for (IContainerListener listener : this.containerListeners) {
            if (listener instanceof ServerPlayerEntity) {
                Overloaded.proxy.networkWrapper.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) listener), message);
            }
        }
    }
}
Also used : ContainerDataMessage(com.cjm721.overloaded.network.packets.ContainerDataMessage) IntReferenceHolder(net.minecraft.util.IntReferenceHolder) IContainerListener(net.minecraft.inventory.container.IContainerListener) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ContainerDataMessage (com.cjm721.overloaded.network.packets.ContainerDataMessage)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 IContainerListener (net.minecraft.inventory.container.IContainerListener)1 ItemStack (net.minecraft.item.ItemStack)1 IntReferenceHolder (net.minecraft.util.IntReferenceHolder)1