use of net.minecraft.server.v1_15_R1 in project BedWars1058 by andrei1058.
the class v1_15_R1 method registerTntWhitelist.
@Override
public void registerTntWhitelist() {
try {
Field field = net.minecraft.server.v1_15_R1.Block.class.getDeclaredField("durability");
field.setAccessible(true);
field.set(Blocks.END_STONE, 12f);
field.set(Blocks.GLASS, 300f);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_15_R1 in project SimplePets by brainsynder-Dev.
the class EntityControllerPet method reloadLocation.
@Override
public void reloadLocation() {
if (displayEntity.getPassenger() != null) {
net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
Location loc;
if (this.displayRider != null) {
if (this.displayRider.getType().equals(EntityType.SHULKER)) {
loc = getBukkitEntity().getLocation().clone().subtract(0, 0.735, 0);
} else {
loc = getBukkitEntity().getLocation().clone();
}
} else {
loc = getBukkitEntity().getLocation().clone();
}
displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
if (entity instanceof Player) {
Player player = (Player) entity;
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
});
return;
}
net.minecraft.server.v1_15_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
Location loc;
if (this.displayRider != null) {
if (this.displayRider.getType().equals(EntityType.SHULKER)) {
loc = getBukkitEntity().getLocation().clone().add(0, 0.75, 0);
} else {
loc = getBukkitEntity().getLocation().clone();
}
} else {
loc = getBukkitEntity().getLocation().clone();
}
displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
if (entity instanceof Player) {
Player player = (Player) entity;
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
});
}
use of net.minecraft.server.v1_15_R1 in project SilkSpawners by timbru31.
the class NMSHandler method setNBTEntityID.
@Override
public ItemStack setNBTEntityID(final ItemStack item, final String entity) {
if (item == null || StringUtils.isBlank(entity)) {
Bukkit.getLogger().warning("[SilkSpawners] Skipping invalid spawner to set NBT data on.");
return null;
}
String prefixedEntity;
if (!entity.startsWith("minecraft:")) {
prefixedEntity = "minecraft:" + entity;
} else {
prefixedEntity = entity;
}
net.minecraft.server.v1_15_R1.ItemStack itemStack = null;
final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getOrCreateTag();
// Check for SilkSpawners key
if (!tag.hasKey("SilkSpawners")) {
tag.set("SilkSpawners", new NBTTagCompound());
}
tag.getCompound("SilkSpawners").setString("entity", entity);
// Check for Vanilla keys
if (!tag.hasKey("BlockEntityTag")) {
tag.set("BlockEntityTag", new NBTTagCompound());
}
tag = tag.getCompound("BlockEntityTag");
// EntityId - Deprecated in 1.9
tag.setString("EntityId", entity);
tag.setString("id", TileEntityTypes.a(TileEntityTypes.MOB_SPAWNER).getKey());
// SpawnData
if (!tag.hasKey("SpawnData")) {
tag.set("SpawnData", new NBTTagCompound());
}
tag.getCompound("SpawnData").setString("id", prefixedEntity);
if (!tag.hasKey("SpawnPotentials")) {
tag.set("SpawnPotentials", new NBTTagCompound());
}
// SpawnEgg data
if (!tag.hasKey("EntityTag")) {
tag.set("EntityTag", new NBTTagCompound());
}
tag.getCompound("EntityTag").setString("id", prefixedEntity);
return CraftItemStack.asCraftMirror(itemStack);
}
use of net.minecraft.server.v1_15_R1 in project SilkSpawners by timbru31.
the class NMSHandler method getVanillaNBTEntityID.
@Override
@Nullable
public String getVanillaNBTEntityID(final ItemStack item) {
net.minecraft.server.v1_15_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_15_R1 in project SilkSpawners by timbru31.
the class NMSHandler method getSilkSpawnersNBTEntityID.
@Override
@Nullable
public String getSilkSpawnersNBTEntityID(final ItemStack item) {
net.minecraft.server.v1_15_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