make guis more generic

This commit is contained in:
Sen 2025-05-31 18:38:53 +02:00
parent 374e0c4617
commit 5534531416
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
22 changed files with 334 additions and 504 deletions

View file

@ -34,7 +34,7 @@ import common.init.SoundEvent;
import common.init.UniverseRegistry;
import common.inventory.Container;
import common.inventory.ContainerChest;
import common.inventory.ContainerHorseInventory;
import common.inventory.ContainerEntityInventory;
import common.inventory.ContainerMerchant;
import common.inventory.ICrafting;
import common.inventory.IInventory;
@ -104,7 +104,7 @@ import common.tags.TagObject;
import common.tileentity.IInteractionObject;
import common.tileentity.ILockableContainer;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityMachine;
import common.tileentity.TileEntityDevice;
import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.util.BoundingBox;
@ -699,10 +699,10 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.getNextWindowId();
if (chestInventory instanceof TileEntityMachine)
if (chestInventory instanceof TileEntityDevice)
{
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "machine_" + ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getCommandName(), chestInventory.getSizeInventory(),
((TileEntityMachine)chestInventory).getPos()));
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "tile", chestInventory.getCommandName(), chestInventory.getSizeInventory(),
((TileEntityDevice)chestInventory).getPos()));
this.entity.openContainer = ((IInteractionObject)chestInventory).createContainer(this.entity.inventory, this.entity);
}
else if (chestInventory instanceof IInteractionObject)
@ -720,7 +720,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.entity.openContainer.onCraftGuiOpened(this);
}
public void displayGUIHorse(EntityHorse horse, IInventory horseInventory)
public void displayEntityGui(Entity entity, IInventory inventory)
{
if (this.entity.openContainer != this.entity.inventoryContainer)
{
@ -728,8 +728,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer
}
this.getNextWindowId();
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", horseInventory.getCommandName(), horseInventory.getSizeInventory(), horse.getId()));
this.entity.openContainer = new ContainerHorseInventory(this.entity.inventory, horseInventory, horse, this.entity);
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "entity", inventory.getCommandName(), inventory.getSizeInventory(), entity.getId()));
this.entity.openContainer = new ContainerEntityInventory(this.entity.inventory, inventory, entity, this.entity);
this.entity.openContainer.windowId = this.currentWindowId;
this.entity.openContainer.onCraftGuiOpened(this);
}