use of net.minecraft.inventory.container.ChestContainer in project Enigmatic-Legacy by Aizistral-Studios.
the class PacketEnderRingKey method handle.
public static void handle(PacketEnderRingKey msg, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> {
ServerPlayerEntity playerServ = ctx.get().getSender();
if (playerServ.openContainer.windowId == 0)
if (SuperpositionHandler.hasCurio(playerServ, EnigmaticLegacy.enderRing)) {
ChestContainer container = ChestContainer.createGeneric9X3(playerServ.currentWindowId + 1, playerServ.inventory, playerServ.getInventoryEnderChest());
playerServ.currentWindowId = container.windowId;
playerServ.connection.sendPacket(new SOpenWindowPacket(container.windowId, container.getType(), new TranslationTextComponent("container.enderchest")));
container.addListener(playerServ);
playerServ.openContainer = container;
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(playerServ, playerServ.openContainer));
playerServ.world.playSound(null, playerServ.getPosition(), SoundEvents.BLOCK_ENDER_CHEST_OPEN, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2)));
}
});
ctx.get().setPacketHandled(true);
}
use of net.minecraft.inventory.container.ChestContainer in project Magma-1.16.x by magmafoundation.
the class CraftContainer method setupSlots.
private void setupSlots(IInventory top, PlayerInventory bottom, PlayerEntity entityhuman) {
int windowId = -1;
switch(cachedType) {
case CREATIVE:
// TODO: This should be an error?
break;
case PLAYER:
case CHEST:
case ENDER_CHEST:
case BARREL:
delegate = new ChestContainer(ContainerType.GENERIC_9x3, windowId, bottom, top, top.getContainerSize() / 9);
break;
case DISPENSER:
case DROPPER:
delegate = new DispenserContainer(windowId, bottom, top);
break;
case FURNACE:
delegate = new FurnaceContainer(windowId, bottom, top, new IntArray(4));
break;
// TODO: This should be an error?
case CRAFTING:
case WORKBENCH:
// SPIGOT-3812 - manually set up slots so we can use the delegated inventory and not the automatically created one
setupWorkbench(top, bottom);
break;
case ENCHANTING:
delegate = new EnchantmentContainer(windowId, bottom);
break;
case BREWING:
delegate = new BrewingStandContainer(windowId, bottom, top, new IntArray(2));
break;
case HOPPER:
delegate = new HopperContainer(windowId, bottom, top);
break;
case ANVIL:
delegate = new RepairContainer(windowId, bottom);
break;
case SMITHING:
delegate = new SmokerContainer(windowId, bottom);
break;
case BEACON:
delegate = new BeaconContainer(windowId, bottom);
break;
case SHULKER_BOX:
delegate = new ShulkerBoxContainer(windowId, bottom, top);
break;
case BLAST_FURNACE:
delegate = new BlastFurnaceContainer(windowId, bottom, top, new IntArray(4));
break;
case LECTERN:
delegate = new LecternContainer(windowId, top, new IntArray(1), bottom);
break;
case SMOKER:
delegate = new SmokerContainer(windowId, bottom, top, new IntArray(4));
break;
case LOOM:
delegate = new LoomContainer(windowId, bottom);
break;
case CARTOGRAPHY:
delegate = new CartographyContainer(windowId, bottom);
break;
case GRINDSTONE:
delegate = new GrindstoneContainer(windowId, bottom);
break;
case STONECUTTER:
delegate = new StonecutterContainer(windowId, bottom);
break;
case MERCHANT:
delegate = new MerchantContainer(windowId, bottom);
break;
}
if (delegate != null) {
this.lastSlots = delegate.lastSlots;
this.slots = delegate.slots;
}
// SPIGOT-4598 - we should still delegate the shift click handler
if (cachedType == InventoryType.WORKBENCH) {
delegate = new WorkbenchContainer(windowId, bottom);
}
}
use of net.minecraft.inventory.container.ChestContainer in project LoliServer by Loli-Server.
the class CraftContainer method setupSlots.
private void setupSlots(IInventory top, PlayerInventory bottom, PlayerEntity entityhuman) {
int windowId = -1;
switch(cachedType) {
case CREATIVE:
// TODO: This should be an error?
break;
case PLAYER:
case CHEST:
case ENDER_CHEST:
case BARREL:
delegate = new ChestContainer(ContainerType.GENERIC_9x3, windowId, bottom, top, top.getContainerSize() / 9);
break;
case DISPENSER:
case DROPPER:
delegate = new DispenserContainer(windowId, bottom, top);
break;
case FURNACE:
delegate = new FurnaceContainer(windowId, bottom, top, new IntArray(4));
break;
// TODO: This should be an error?
case CRAFTING:
case WORKBENCH:
// SPIGOT-3812 - manually set up slots so we can use the delegated inventory and not the automatically created one
setupWorkbench(top, bottom);
break;
case ENCHANTING:
delegate = new EnchantmentContainer(windowId, bottom);
break;
case BREWING:
delegate = new BrewingStandContainer(windowId, bottom, top, new IntArray(2));
break;
case HOPPER:
delegate = new HopperContainer(windowId, bottom, top);
break;
case ANVIL:
delegate = new RepairContainer(windowId, bottom);
break;
case SMITHING:
delegate = new SmokerContainer(windowId, bottom);
break;
case BEACON:
delegate = new BeaconContainer(windowId, bottom);
break;
case SHULKER_BOX:
delegate = new ShulkerBoxContainer(windowId, bottom, top);
break;
case BLAST_FURNACE:
delegate = new BlastFurnaceContainer(windowId, bottom, top, new IntArray(4));
break;
case LECTERN:
delegate = new LecternContainer(windowId, top, new IntArray(1), bottom);
break;
case SMOKER:
delegate = new SmokerContainer(windowId, bottom, top, new IntArray(4));
break;
case LOOM:
delegate = new LoomContainer(windowId, bottom);
break;
case CARTOGRAPHY:
delegate = new CartographyContainer(windowId, bottom);
break;
case GRINDSTONE:
delegate = new GrindstoneContainer(windowId, bottom);
break;
case STONECUTTER:
delegate = new StonecutterContainer(windowId, bottom);
break;
case MERCHANT:
delegate = new MerchantContainer(windowId, bottom);
break;
}
if (delegate != null) {
this.lastSlots = delegate.lastSlots;
this.slots = delegate.slots;
}
// SPIGOT-4598 - we should still delegate the shift click handler
if (cachedType == InventoryType.WORKBENCH) {
delegate = new WorkbenchContainer(windowId, bottom);
}
}
Aggregations