use of net.minecraft.server.v1_12_R1.DataWatcher.Item in project TheAPI by TheDevTec.
the class v1_12_R1 method openAnvilGUI.
@Override
public void openAnvilGUI(Player player, Object con, String title, ItemStack[] items) {
ContainerAnvil container = (ContainerAnvil) con;
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
int id = container.windowId;
net.minecraft.server.v1_12_R1.ItemStack[] nmsItems = new net.minecraft.server.v1_12_R1.ItemStack[items.length];
for (int i = 0; i < items.length; ++i) {
ItemStack is = items[i];
if (is == null || is.getType() == Material.AIR)
continue;
net.minecraft.server.v1_12_R1.ItemStack item = null;
container.setItem(i, item = (net.minecraft.server.v1_12_R1.ItemStack) asNMSItem(is));
nmsItems[i] = item;
}
BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, "minecraft:anvil", 0, title));
int i = 0;
for (net.minecraft.server.v1_12_R1.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
nmsPlayer.activeContainer.transferTo((Container) container, (CraftPlayer) player);
nmsPlayer.activeContainer = (Container) container;
((Container) container).addSlotListener(nmsPlayer);
container.checkReachable = false;
}
use of net.minecraft.server.v1_12_R1.DataWatcher.Item in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method setItem.
@Override
public void setItem(int index, ItemStack item) {
// Instead of updating one container, update all the containers
// That are looking at the table, basically the viewers
items.set(index, item == null ? ItemStack.a : item);
for (Container container : containers) {
container.a(this);
}
// Update the armorstand grid
display.update();
}
use of net.minecraft.server.v1_12_R1.DataWatcher.Item in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method remove.
@Override
public void remove() {
display.stop();
for (ItemStack item : items) {
org.bukkit.inventory.ItemStack is = CraftItemStack.asBukkitCopy(item);
if (is.getType() != Material.AIR) {
bloc.getWorld().dropItem(bloc.clone().add(.5, .9, .5), is);
}
}
items.clear();
}
use of net.minecraft.server.v1_12_R1.DataWatcher.Item in project SilkSpawners by timbru31.
the class NMSHandler method getSilkSpawnersNBTEntityID.
@Override
@Nullable
public String getSilkSpawnersNBTEntityID(final ItemStack item) {
net.minecraft.server.v1_12_R1.ItemStack itemStack = null;
final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
itemStack = CraftItemStack.asNMSCopy(craftStack);
final NBTTagCompound tag = itemStack.getTag();
if (tag == null || !tag.hasKey("SilkSpawners")) {
return null;
}
final NBTTagCompound silkSpawnersTag = tag.getCompound("SilkSpawners");
if (silkSpawnersTag.hasKey("entity")) {
return silkSpawnersTag.getString("entity");
}
if (silkSpawnersTag.hasKey("entityID")) {
return getEntityFromNumericalID(silkSpawnersTag.getShort("entityID"));
}
return null;
}
use of net.minecraft.server.v1_12_R1.DataWatcher.Item in project SilkSpawners by timbru31.
the class NMSHandler method getVanillaNBTEntityID.
@Override
public String getVanillaNBTEntityID(final ItemStack item) {
net.minecraft.server.v1_12_R1.ItemStack itemStack = null;
final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getTag();
if (tag == null || !tag.hasKey("BlockEntityTag")) {
return null;
}
tag = tag.getCompound("BlockEntityTag");
if (tag.hasKey("EntityId")) {
return tag.getString("EntityId");
} else if (tag.hasKey("SpawnData") && tag.getCompound("SpawnData").hasKey("id")) {
return tag.getCompound("SpawnData").getString("id");
} else if (tag.hasKey("SpawnPotentials") && !tag.getList("SpawnPotentials", 8).isEmpty()) {
return tag.getList("SpawnPotentials", 8).get(0).getCompound("Entity").getString("id");
} else {
return null;
}
}
Aggregations