use of net.minecraft.server.v1_16_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);
for (Container container : containers) {
container.a(this);
}
// Update the armorstand grid
display.update();
}
use of net.minecraft.server.v1_16_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_16_R1.DataWatcher.Item in project SilkSpawners by timbru31.
the class NMSHandler method getVanillaNBTEntityID.
@Override
@Nullable
public String getVanillaNBTEntityID(final ItemStack item) {
net.minecraft.server.v1_16_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).getCompound(0).getCompound("Entity").getString("id");
} else {
return null;
}
}
use of net.minecraft.server.v1_16_R1.DataWatcher.Item in project SilkSpawners by timbru31.
the class NMSHandler method newEggItem.
@SuppressWarnings("deprecation")
@Override
public ItemStack newEggItem(final String entityID, final int amount, final String displayName) {
Material spawnEgg = Material.matchMaterial(entityID.toUpperCase() + "_SPAWN_EGG");
if (spawnEgg == null) {
spawnEgg = Material.LEGACY_MONSTER_EGG;
}
final ItemStack item = new ItemStack(spawnEgg, amount);
if (displayName != null) {
final ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(displayName);
item.setItemMeta(itemMeta);
}
net.minecraft.server.v1_16_R1.ItemStack itemStack = null;
final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
itemStack = CraftItemStack.asNMSCopy(craftStack);
final NBTTagCompound tag = itemStack.getOrCreateTag();
if (!tag.hasKey("SilkSpawners")) {
tag.set("SilkSpawners", new NBTTagCompound());
}
tag.getCompound("SilkSpawners").setString("entity", entityID);
if (!tag.hasKey("EntityTag")) {
tag.set("EntityTag", new NBTTagCompound());
}
String prefixedEntity;
if (!entityID.startsWith("minecraft:")) {
prefixedEntity = "minecraft:" + entityID;
} else {
prefixedEntity = entityID;
}
tag.getCompound("EntityTag").setString("id", prefixedEntity);
return CraftItemStack.asCraftMirror(itemStack);
}
Aggregations