mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-23 09:37:35 +01:00
Fix updateInventoryTitle on containers
This commit is contained in:
parent
b89073d4c1
commit
b6eb42e07f
@ -218,6 +218,7 @@ import net.minecraft.server.v1_14_R1.ChunkProviderServer;
|
||||
import net.minecraft.server.v1_14_R1.Container;
|
||||
import net.minecraft.server.v1_14_R1.ContainerAccess;
|
||||
import net.minecraft.server.v1_14_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_14_R1.Containers;
|
||||
import net.minecraft.server.v1_14_R1.ControllerJump;
|
||||
import net.minecraft.server.v1_14_R1.ControllerMove;
|
||||
import net.minecraft.server.v1_14_R1.CrashReport;
|
||||
@ -1390,9 +1391,90 @@ public class NMSImpl implements NMSBridge {
|
||||
@Override
|
||||
public void updateInventoryTitle(Player player, InventoryView view, String newTitle) {
|
||||
EntityPlayer handle = (EntityPlayer) getHandle(player);
|
||||
Containers<?> menuType = null;
|
||||
switch (view.getTopInventory().getType()) {
|
||||
case ANVIL:
|
||||
menuType = Containers.ANVIL;
|
||||
break;
|
||||
case BARREL:
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
break;
|
||||
case BEACON:
|
||||
menuType = Containers.BEACON;
|
||||
break;
|
||||
case BLAST_FURNACE:
|
||||
menuType = Containers.BLAST_FURNACE;
|
||||
break;
|
||||
case BREWING:
|
||||
menuType = Containers.BREWING_STAND;
|
||||
break;
|
||||
case CARTOGRAPHY:
|
||||
menuType = Containers.CARTOGRAPHY;
|
||||
break;
|
||||
case CHEST:
|
||||
int sz = view.getTopInventory().getSize();
|
||||
if (sz > 45) {
|
||||
menuType = Containers.GENERIC_9X6;
|
||||
} else if (sz > 36) {
|
||||
menuType = Containers.GENERIC_9X5;
|
||||
} else if (sz > 27) {
|
||||
menuType = Containers.GENERIC_9X4;
|
||||
} else if (sz > 18) {
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
} else if (sz > 9) {
|
||||
menuType = Containers.GENERIC_9X2;
|
||||
} else {
|
||||
menuType = Containers.GENERIC_9X1;
|
||||
}
|
||||
break;
|
||||
case PLAYER:
|
||||
case CRAFTING:
|
||||
case CREATIVE:
|
||||
return;
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
menuType = Containers.GENERIC_3X3;
|
||||
break;
|
||||
case ENCHANTING:
|
||||
menuType = Containers.ENCHANTMENT;
|
||||
break;
|
||||
case ENDER_CHEST:
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
break;
|
||||
case FURNACE:
|
||||
menuType = Containers.FURNACE;
|
||||
break;
|
||||
case GRINDSTONE:
|
||||
menuType = Containers.GRINDSTONE;
|
||||
break;
|
||||
case HOPPER:
|
||||
menuType = Containers.HOPPER;
|
||||
break;
|
||||
case LECTERN:
|
||||
menuType = Containers.LECTERN;
|
||||
break;
|
||||
case LOOM:
|
||||
menuType = Containers.LOOM;
|
||||
break;
|
||||
case MERCHANT:
|
||||
menuType = Containers.MERCHANT;
|
||||
break;
|
||||
case SHULKER_BOX:
|
||||
menuType = Containers.SHULKER_BOX;
|
||||
break;
|
||||
case SMOKER:
|
||||
menuType = Containers.SMOKER;
|
||||
break;
|
||||
case STONECUTTER:
|
||||
menuType = Containers.STONECUTTER;
|
||||
break;
|
||||
case WORKBENCH:
|
||||
menuType = Containers.CRAFTING;
|
||||
break;
|
||||
}
|
||||
Container active = handle.activeContainer;
|
||||
handle.playerConnection.sendPacket(
|
||||
new PacketPlayOutOpenWindow(active.windowId, active.getType(), new ChatComponentText(newTitle)));
|
||||
handle.playerConnection
|
||||
.sendPacket(new PacketPlayOutOpenWindow(active.windowId, menuType, new ChatComponentText(newTitle)));
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
|
@ -220,6 +220,7 @@ import net.minecraft.server.v1_15_R1.ChunkProviderServer;
|
||||
import net.minecraft.server.v1_15_R1.Container;
|
||||
import net.minecraft.server.v1_15_R1.ContainerAccess;
|
||||
import net.minecraft.server.v1_15_R1.ContainerAnvil;
|
||||
import net.minecraft.server.v1_15_R1.Containers;
|
||||
import net.minecraft.server.v1_15_R1.ControllerJump;
|
||||
import net.minecraft.server.v1_15_R1.ControllerMove;
|
||||
import net.minecraft.server.v1_15_R1.ControllerMoveFlying;
|
||||
@ -1429,9 +1430,90 @@ public class NMSImpl implements NMSBridge {
|
||||
@Override
|
||||
public void updateInventoryTitle(Player player, InventoryView view, String newTitle) {
|
||||
EntityPlayer handle = (EntityPlayer) getHandle(player);
|
||||
Containers<?> menuType = null;
|
||||
switch (view.getTopInventory().getType()) {
|
||||
case ANVIL:
|
||||
menuType = Containers.ANVIL;
|
||||
break;
|
||||
case BARREL:
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
break;
|
||||
case BEACON:
|
||||
menuType = Containers.BEACON;
|
||||
break;
|
||||
case BLAST_FURNACE:
|
||||
menuType = Containers.BLAST_FURNACE;
|
||||
break;
|
||||
case BREWING:
|
||||
menuType = Containers.BREWING_STAND;
|
||||
break;
|
||||
case CARTOGRAPHY:
|
||||
menuType = Containers.CARTOGRAPHY_TABLE;
|
||||
break;
|
||||
case CHEST:
|
||||
int sz = view.getTopInventory().getSize();
|
||||
if (sz > 45) {
|
||||
menuType = Containers.GENERIC_9X6;
|
||||
} else if (sz > 36) {
|
||||
menuType = Containers.GENERIC_9X5;
|
||||
} else if (sz > 27) {
|
||||
menuType = Containers.GENERIC_9X4;
|
||||
} else if (sz > 18) {
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
} else if (sz > 9) {
|
||||
menuType = Containers.GENERIC_9X2;
|
||||
} else {
|
||||
menuType = Containers.GENERIC_9X1;
|
||||
}
|
||||
break;
|
||||
case PLAYER:
|
||||
case CRAFTING:
|
||||
case CREATIVE:
|
||||
return;
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
menuType = Containers.GENERIC_3X3;
|
||||
break;
|
||||
case ENCHANTING:
|
||||
menuType = Containers.ENCHANTMENT;
|
||||
break;
|
||||
case ENDER_CHEST:
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
break;
|
||||
case FURNACE:
|
||||
menuType = Containers.FURNACE;
|
||||
break;
|
||||
case GRINDSTONE:
|
||||
menuType = Containers.GRINDSTONE;
|
||||
break;
|
||||
case HOPPER:
|
||||
menuType = Containers.HOPPER;
|
||||
break;
|
||||
case LECTERN:
|
||||
menuType = Containers.LECTERN;
|
||||
break;
|
||||
case LOOM:
|
||||
menuType = Containers.LOOM;
|
||||
break;
|
||||
case MERCHANT:
|
||||
menuType = Containers.MERCHANT;
|
||||
break;
|
||||
case SHULKER_BOX:
|
||||
menuType = Containers.SHULKER_BOX;
|
||||
break;
|
||||
case SMOKER:
|
||||
menuType = Containers.SMOKER;
|
||||
break;
|
||||
case STONECUTTER:
|
||||
menuType = Containers.STONECUTTER;
|
||||
break;
|
||||
case WORKBENCH:
|
||||
menuType = Containers.CRAFTING;
|
||||
break;
|
||||
}
|
||||
Container active = handle.activeContainer;
|
||||
handle.playerConnection.sendPacket(
|
||||
new PacketPlayOutOpenWindow(active.windowId, active.getType(), new ChatComponentText(newTitle)));
|
||||
handle.playerConnection
|
||||
.sendPacket(new PacketPlayOutOpenWindow(active.windowId, menuType, new ChatComponentText(newTitle)));
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
|
@ -227,6 +227,7 @@ import net.minecraft.server.v1_16_R3.ChunkProviderServer;
|
||||
import net.minecraft.server.v1_16_R3.Container;
|
||||
import net.minecraft.server.v1_16_R3.ContainerAccess;
|
||||
import net.minecraft.server.v1_16_R3.ContainerAnvil;
|
||||
import net.minecraft.server.v1_16_R3.Containers;
|
||||
import net.minecraft.server.v1_16_R3.ControllerJump;
|
||||
import net.minecraft.server.v1_16_R3.ControllerMove;
|
||||
import net.minecraft.server.v1_16_R3.ControllerMoveFlying;
|
||||
@ -1452,9 +1453,93 @@ public class NMSImpl implements NMSBridge {
|
||||
@Override
|
||||
public void updateInventoryTitle(Player player, InventoryView view, String newTitle) {
|
||||
EntityPlayer handle = (EntityPlayer) getHandle(player);
|
||||
Containers<?> menuType = null;
|
||||
switch (view.getTopInventory().getType()) {
|
||||
case ANVIL:
|
||||
menuType = Containers.ANVIL;
|
||||
break;
|
||||
case BARREL:
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
break;
|
||||
case BEACON:
|
||||
menuType = Containers.BEACON;
|
||||
break;
|
||||
case BLAST_FURNACE:
|
||||
menuType = Containers.BLAST_FURNACE;
|
||||
break;
|
||||
case BREWING:
|
||||
menuType = Containers.BREWING_STAND;
|
||||
break;
|
||||
case CARTOGRAPHY:
|
||||
menuType = Containers.CARTOGRAPHY_TABLE;
|
||||
break;
|
||||
case CHEST:
|
||||
int sz = view.getTopInventory().getSize();
|
||||
if (sz > 45) {
|
||||
menuType = Containers.GENERIC_9X6;
|
||||
} else if (sz > 36) {
|
||||
menuType = Containers.GENERIC_9X5;
|
||||
} else if (sz > 27) {
|
||||
menuType = Containers.GENERIC_9X4;
|
||||
} else if (sz > 18) {
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
} else if (sz > 9) {
|
||||
menuType = Containers.GENERIC_9X2;
|
||||
} else {
|
||||
menuType = Containers.GENERIC_9X1;
|
||||
}
|
||||
break;
|
||||
case PLAYER:
|
||||
case CRAFTING:
|
||||
case CREATIVE:
|
||||
return;
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
menuType = Containers.GENERIC_3X3;
|
||||
break;
|
||||
case ENCHANTING:
|
||||
menuType = Containers.ENCHANTMENT;
|
||||
break;
|
||||
case ENDER_CHEST:
|
||||
menuType = Containers.GENERIC_9X3;
|
||||
break;
|
||||
case FURNACE:
|
||||
menuType = Containers.FURNACE;
|
||||
break;
|
||||
case GRINDSTONE:
|
||||
menuType = Containers.GRINDSTONE;
|
||||
break;
|
||||
case HOPPER:
|
||||
menuType = Containers.HOPPER;
|
||||
break;
|
||||
case LECTERN:
|
||||
menuType = Containers.LECTERN;
|
||||
break;
|
||||
case LOOM:
|
||||
menuType = Containers.LOOM;
|
||||
break;
|
||||
case MERCHANT:
|
||||
menuType = Containers.MERCHANT;
|
||||
break;
|
||||
case SHULKER_BOX:
|
||||
menuType = Containers.SHULKER_BOX;
|
||||
break;
|
||||
case SMITHING:
|
||||
menuType = Containers.SMITHING;
|
||||
break;
|
||||
case SMOKER:
|
||||
menuType = Containers.SMOKER;
|
||||
break;
|
||||
case STONECUTTER:
|
||||
menuType = Containers.STONECUTTER;
|
||||
break;
|
||||
case WORKBENCH:
|
||||
menuType = Containers.CRAFTING;
|
||||
break;
|
||||
}
|
||||
Container active = handle.activeContainer;
|
||||
handle.playerConnection.sendPacket(
|
||||
new PacketPlayOutOpenWindow(active.windowId, active.getType(), new ChatComponentText(newTitle)));
|
||||
handle.playerConnection
|
||||
.sendPacket(new PacketPlayOutOpenWindow(active.windowId, menuType, new ChatComponentText(newTitle)));
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ import net.minecraft.world.entity.projectile.FishingHook;
|
||||
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
||||
import net.minecraft.world.inventory.AnvilMenu;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
@ -1448,9 +1448,94 @@ public class NMSImpl implements NMSBridge {
|
||||
@Override
|
||||
public void updateInventoryTitle(Player player, InventoryView view, String newTitle) {
|
||||
ServerPlayer handle = (ServerPlayer) getHandle(player);
|
||||
InventoryMenu active = handle.inventoryMenu;
|
||||
handle.connection.send(
|
||||
new ClientboundOpenScreenPacket(active.containerId, active.getType(), new TextComponent(newTitle)));
|
||||
MenuType<?> menuType = null;
|
||||
switch (view.getTopInventory().getType()) {
|
||||
case ANVIL:
|
||||
menuType = MenuType.ANVIL;
|
||||
break;
|
||||
case BARREL:
|
||||
menuType = MenuType.GENERIC_9x3;
|
||||
break;
|
||||
case BEACON:
|
||||
menuType = MenuType.BEACON;
|
||||
break;
|
||||
case BLAST_FURNACE:
|
||||
menuType = MenuType.BLAST_FURNACE;
|
||||
break;
|
||||
case BREWING:
|
||||
menuType = MenuType.BREWING_STAND;
|
||||
break;
|
||||
case CARTOGRAPHY:
|
||||
menuType = MenuType.CARTOGRAPHY_TABLE;
|
||||
break;
|
||||
case CHEST:
|
||||
int sz = view.getTopInventory().getSize();
|
||||
if (sz > 45) {
|
||||
menuType = MenuType.GENERIC_9x6;
|
||||
} else if (sz > 36) {
|
||||
menuType = MenuType.GENERIC_9x5;
|
||||
} else if (sz > 27) {
|
||||
menuType = MenuType.GENERIC_9x4;
|
||||
} else if (sz > 18) {
|
||||
menuType = MenuType.GENERIC_9x3;
|
||||
} else if (sz > 9) {
|
||||
menuType = MenuType.GENERIC_9x2;
|
||||
} else {
|
||||
menuType = MenuType.GENERIC_9x1;
|
||||
}
|
||||
break;
|
||||
case COMPOSTER:
|
||||
break;
|
||||
case PLAYER:
|
||||
case CRAFTING:
|
||||
case CREATIVE:
|
||||
return;
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
menuType = MenuType.GENERIC_3x3;
|
||||
break;
|
||||
case ENCHANTING:
|
||||
menuType = MenuType.ENCHANTMENT;
|
||||
break;
|
||||
case ENDER_CHEST:
|
||||
menuType = MenuType.GENERIC_9x3;
|
||||
break;
|
||||
case FURNACE:
|
||||
menuType = MenuType.FURNACE;
|
||||
break;
|
||||
case GRINDSTONE:
|
||||
menuType = MenuType.GRINDSTONE;
|
||||
break;
|
||||
case HOPPER:
|
||||
menuType = MenuType.HOPPER;
|
||||
break;
|
||||
case LECTERN:
|
||||
menuType = MenuType.LECTERN;
|
||||
break;
|
||||
case LOOM:
|
||||
menuType = MenuType.LOOM;
|
||||
break;
|
||||
case MERCHANT:
|
||||
menuType = MenuType.MERCHANT;
|
||||
break;
|
||||
case SHULKER_BOX:
|
||||
menuType = MenuType.SHULKER_BOX;
|
||||
break;
|
||||
case SMITHING:
|
||||
menuType = MenuType.SMITHING;
|
||||
break;
|
||||
case SMOKER:
|
||||
menuType = MenuType.SMOKER;
|
||||
break;
|
||||
case STONECUTTER:
|
||||
menuType = MenuType.STONECUTTER;
|
||||
break;
|
||||
case WORKBENCH:
|
||||
menuType = MenuType.CRAFTING;
|
||||
break;
|
||||
}
|
||||
handle.connection.send(new ClientboundOpenScreenPacket(handle.containerMenu.containerId, menuType,
|
||||
new TextComponent(newTitle)));
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,6 @@ import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
import net.minecraft.ReportedException;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.Connection;
|
||||
@ -284,7 +283,7 @@ import net.minecraft.world.entity.projectile.FishingHook;
|
||||
import net.minecraft.world.entity.vehicle.AbstractMinecart;
|
||||
import net.minecraft.world.inventory.AnvilMenu;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
@ -1456,9 +1455,94 @@ public class NMSImpl implements NMSBridge {
|
||||
@Override
|
||||
public void updateInventoryTitle(Player player, InventoryView view, String newTitle) {
|
||||
ServerPlayer handle = (ServerPlayer) getHandle(player);
|
||||
InventoryMenu active = handle.inventoryMenu;
|
||||
handle.connection.send(
|
||||
new ClientboundOpenScreenPacket(active.containerId, active.getType(), new TextComponent(newTitle)));
|
||||
MenuType<?> menuType = null;
|
||||
switch (view.getTopInventory().getType()) {
|
||||
case ANVIL:
|
||||
menuType = MenuType.ANVIL;
|
||||
break;
|
||||
case BARREL:
|
||||
menuType = MenuType.GENERIC_9x3;
|
||||
break;
|
||||
case BEACON:
|
||||
menuType = MenuType.BEACON;
|
||||
break;
|
||||
case BLAST_FURNACE:
|
||||
menuType = MenuType.BLAST_FURNACE;
|
||||
break;
|
||||
case BREWING:
|
||||
menuType = MenuType.BREWING_STAND;
|
||||
break;
|
||||
case CARTOGRAPHY:
|
||||
menuType = MenuType.CARTOGRAPHY_TABLE;
|
||||
break;
|
||||
case CHEST:
|
||||
int sz = view.getTopInventory().getSize();
|
||||
if (sz > 45) {
|
||||
menuType = MenuType.GENERIC_9x6;
|
||||
} else if (sz > 36) {
|
||||
menuType = MenuType.GENERIC_9x5;
|
||||
} else if (sz > 27) {
|
||||
menuType = MenuType.GENERIC_9x4;
|
||||
} else if (sz > 18) {
|
||||
menuType = MenuType.GENERIC_9x3;
|
||||
} else if (sz > 9) {
|
||||
menuType = MenuType.GENERIC_9x2;
|
||||
} else {
|
||||
menuType = MenuType.GENERIC_9x1;
|
||||
}
|
||||
break;
|
||||
case COMPOSTER:
|
||||
break;
|
||||
case PLAYER:
|
||||
case CRAFTING:
|
||||
case CREATIVE:
|
||||
return;
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
menuType = MenuType.GENERIC_3x3;
|
||||
break;
|
||||
case ENCHANTING:
|
||||
menuType = MenuType.ENCHANTMENT;
|
||||
break;
|
||||
case ENDER_CHEST:
|
||||
menuType = MenuType.GENERIC_9x3;
|
||||
break;
|
||||
case FURNACE:
|
||||
menuType = MenuType.FURNACE;
|
||||
break;
|
||||
case GRINDSTONE:
|
||||
menuType = MenuType.GRINDSTONE;
|
||||
break;
|
||||
case HOPPER:
|
||||
menuType = MenuType.HOPPER;
|
||||
break;
|
||||
case LECTERN:
|
||||
menuType = MenuType.LECTERN;
|
||||
break;
|
||||
case LOOM:
|
||||
menuType = MenuType.LOOM;
|
||||
break;
|
||||
case MERCHANT:
|
||||
menuType = MenuType.MERCHANT;
|
||||
break;
|
||||
case SHULKER_BOX:
|
||||
menuType = MenuType.SHULKER_BOX;
|
||||
break;
|
||||
case SMITHING:
|
||||
menuType = MenuType.SMITHING;
|
||||
break;
|
||||
case SMOKER:
|
||||
menuType = MenuType.SMOKER;
|
||||
break;
|
||||
case STONECUTTER:
|
||||
menuType = MenuType.STONECUTTER;
|
||||
break;
|
||||
case WORKBENCH:
|
||||
menuType = MenuType.CRAFTING;
|
||||
break;
|
||||
}
|
||||
handle.connection.send(new ClientboundOpenScreenPacket(handle.containerMenu.containerId, menuType,
|
||||
new TextComponent(newTitle)));
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
|
@ -1557,7 +1557,7 @@ public class NMSImpl implements NMSBridge {
|
||||
menuType = MenuType.CRAFTING;
|
||||
break;
|
||||
}
|
||||
handle.connection.send(new ClientboundOpenScreenPacket(handle.inventoryMenu.containerId, menuType,
|
||||
handle.connection.send(new ClientboundOpenScreenPacket(handle.containerMenu.containerId, menuType,
|
||||
MutableComponent.create(new LiteralContents(newTitle))));
|
||||
player.updateInventory();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user