use of net.minecraft.server.v1_9_R2.MinecraftKey in project MyPet by xXKeyleXx.
the class ConfigItem method load.
public void load(MaterialHolder material, String data) {
MinecraftKey key = new MinecraftKey(material.getLegacyName().getName());
Item item = Item.REGISTRY.get(key);
if (item == null) {
return;
}
net.minecraft.server.v1_8_R3.ItemStack is = new net.minecraft.server.v1_8_R3.ItemStack(item, 1, material.getLegacyName().getData());
if (data != null) {
NBTTagCompound tag = null;
String nbtString = data.trim();
if (nbtString.startsWith("{") && nbtString.endsWith("}")) {
try {
tag = MojangsonParser.parse(nbtString);
} catch (Exception e) {
MyPetApi.getLogger().warning("Error" + ChatColor.RESET + " in config: " + ChatColor.UNDERLINE + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
MyPetApi.getLogger().warning(item.getName() + " " + nbtString);
}
if (tag != null) {
is.setTag(tag);
}
}
}
this.item = CraftItemStack.asCraftMirror(is);
}
use of net.minecraft.server.v1_9_R2.MinecraftKey in project solinia3-core by mixxit.
the class ForgeUtils method sendForgeMessage.
public static void sendForgeMessage(Player player, String channelName, byte discriminator, String message) throws Exception {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(stream);
try {
// diesieben07 - Forge uses an unsigned byte for the discriminator, for a start
// dataOut.writeInt(discriminator);
dataOut.writeByte(discriminator);
// diesieben07 - But you should really send some kind of length prefix
// and then only read that much of the string
// You're already using DataOuput, it has writeUTFString
// dataOut.write(message.getBytes(StandardCharsets.UTF_8));
dataOut.writeUTF(message);
PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(new MinecraftKey(channelName), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray())));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
} finally {
dataOut.close();
stream.close();
}
}
use of net.minecraft.server.v1_9_R2.MinecraftKey in project Citizens2 by CitizensDev.
the class NMSImpl method registerEntityClass.
@Override
public void registerEntityClass(Class<?> clazz) {
if (ENTITY_REGISTRY == null)
return;
Class<?> search = clazz;
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
MinecraftKey key = ENTITY_REGISTRY.getKey(type);
if (key == null)
continue;
int code = ENTITY_REGISTRY.a(type);
ENTITY_REGISTRY.put(code, key, type);
return;
}
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
use of net.minecraft.server.v1_9_R2.MinecraftKey in project Citizens2 by CitizensDev.
the class NMSImpl method registerEntityClass.
@Override
public void registerEntityClass(Class<?> clazz) {
if (ENTITY_REGISTRY == null)
return;
Class<?> search = clazz;
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
MinecraftKey key = ENTITY_REGISTRY.getKey(type);
if (key == null || type == null)
continue;
CITIZENS_ENTITY_TYPES.put(clazz, type);
int code = ENTITY_REGISTRY.a(type);
ENTITY_REGISTRY.put(code, key, type);
return;
}
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
use of net.minecraft.server.v1_9_R2.MinecraftKey in project Citizens2 by CitizensDev.
the class NMSImpl method getSound.
@Override
public String getSound(String flag) throws CommandException {
try {
Sound sound = Sound.valueOf(flag.toUpperCase());
if (CRAFTSOUND_GETSOUND != null) {
String ret = (String) CRAFTSOUND_GETSOUND.invoke(sound);
if (ret == null)
throw new CommandException(Messages.INVALID_SOUND);
return ret;
} else {
SoundEffect effect = CraftSound.getSoundEffect(sound);
if (effect == null)
throw new CommandException(Messages.INVALID_SOUND);
MinecraftKey key = (MinecraftKey) SOUNDEFFECT_KEY.invoke(effect);
return key.getKey();
}
} catch (Throwable e) {
throw new CommandException(Messages.INVALID_SOUND);
}
}
Aggregations