use of net.minecraft.server.v1_14_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_14_R1.DataWatcher.Item in project Citizens2 by CitizensDev.
the class ItemFrameController method createEntity.
@Override
protected Entity createEntity(Location at, NPC npc) {
Entity e = super.createEntity(at, npc);
EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
item.setDirection(EnumDirection.EAST);
item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
return e;
}
use of net.minecraft.server.v1_14_R1.DataWatcher.Item in project RoseStacker by Rosewood-Development.
the class NMSHandlerImpl method updateEntityNameTagForPlayer.
@Override
public void updateEntityNameTagForPlayer(Player player, org.bukkit.entity.Entity entity, String customName, boolean customNameVisible) {
try {
List<Item<?>> dataWatchers = new ArrayList<>();
Optional<IChatBaseComponent> nameComponent = Optional.ofNullable(CraftChatMessage.fromStringOrNull(customName));
dataWatchers.add(new DataWatcher.Item<>(DataWatcherRegistry.f.a(2), nameComponent));
dataWatchers.add(new DataWatcher.Item<>(DataWatcherRegistry.i.a(3), customNameVisible));
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata();
field_PacketPlayOutEntityMetadata_a.set(packetPlayOutEntityMetadata, entity.getEntityId());
field_PacketPlayOutEntityMetadata_b.set(packetPlayOutEntityMetadata, dataWatchers);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_14_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_14_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);
}
use of net.minecraft.server.v1_14_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_14_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;
}
return tag.getCompound("SilkSpawners").getString("entity");
}
Aggregations