use of net.silentchaos512.gems.network.Message in project SilentGems by SilentChaos512.
the class ToolHelper method onUpdate.
public static void onUpdate(ItemStack toolOrArmor, World world, Entity entity, int itemSlot, boolean isSelected) {
// Tick tool souls
if (entity instanceof EntityPlayer) {
ToolSoul soul = SoulManager.getSoul(toolOrArmor);
if (soul != null) {
soul.updateTick(toolOrArmor, (EntityPlayer) entity);
}
}
if (!world.isRemote) {
// Randomize tools with no data.
if (hasNoConstruction(toolOrArmor)) {
ItemStack newTool = ToolRandomizer.INSTANCE.randomize(toolOrArmor);
}
// If the player gave him/herself a tool via JEI or creative, remove the example tag.
if (isExampleItem(toolOrArmor)) {
// tool.getTagCompound().setBoolean(NBT_EXAMPLE_TOOL, false);
toolOrArmor.getTagCompound().removeTag(NBT_EXAMPLE_TOOL);
}
initRootTag(toolOrArmor);
// Generate UUID if tool does not have one.
if (!hasUUID(toolOrArmor)) {
toolOrArmor.getTagCompound().setUniqueId(NBT_UUID, UUID.randomUUID());
}
return;
}
// Client-side name generation
if (world.getTotalWorldTime() % CHECK_NAME_FREQUENCY == 0 && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (toolOrArmor.hasTagCompound() && toolOrArmor.getTagCompound().hasKey(NBT_TEMP_PARTLIST)) {
NBTTagCompound compound = toolOrArmor.getTagCompound().getCompoundTag(NBT_TEMP_PARTLIST);
int i = 0;
String key = "part" + i;
List<ItemStack> parts = Lists.newArrayList();
// Load part stacks.
do {
NBTTagCompound tag = compound.getCompoundTag(key);
parts.add(StackHelper.loadFromNBT(tag));
key = "part" + ++i;
} while (compound.hasKey(key));
// Create name on the client.
String displayName = createToolName(toolOrArmor.getItem(), parts);
// tool.setStackDisplayName(displayName);
// Send to the server.
MessageItemRename message = new MessageItemRename(player.getName(), itemSlot, displayName, toolOrArmor);
String line = String.format("%s crafted \"%s\"", player.getName(), displayName);
SilentGems.logHelper.info(line);
NetworkHandler.INSTANCE.sendToServer(message);
}
}
}
use of net.silentchaos512.gems.network.Message in project SilentGems by SilentChaos512.
the class ToolSoul method sendUpdatePacket.
protected void sendUpdatePacket(ItemStack tool, EntityPlayer player, SoulSkill skillLearned, int skillLevel) {
// Server side: send update packet to player.
if (!player.world.isRemote) {
UUID uuid = ToolHelper.getSoulUUID(tool);
MessageSoulSync message = new MessageSoulSync(uuid, xp, level, actionPoints, skillLearned, skillLevel);
NetworkHandler.INSTANCE.sendTo(message, (EntityPlayerMP) player);
}
}
Aggregations