December 20, 20186 yr Author Its an index right? for the position of which dragon UUID should I be selecting to input commands with?
December 20, 20186 yr Author SO I have this in the guiDragonWhistle @Override protected void actionPerformed(GuiButton button) { if(dragon != null) { byte previousState = dragon.getWhistleState(); dragon.come(button == come); dragon.circle(button == circle); dragon.follow(button == followFlying); dragon.nothing(button == nothing); byte controlState = dragon.getWhistleState(); if (controlState != previousState) { DragonMounts.NETWORK_WRAPPER .sendToServer(new MessageDragonWhistle(dragon.getEntityId(), controlState)); } } } How do I replace the nothing value, basicaaly the default one, the one with no commands. Can I just easily insert something like a null or false value?
December 20, 20186 yr Author package com.TheRPGAdventurer.ROTD.client.items; import java.util.List; import java.util.UUID; import javax.annotation.Nullable; import com.TheRPGAdventurer.ROTD.DragonMounts; import com.TheRPGAdventurer.ROTD.server.entity.EntityTameableDragon; import com.TheRPGAdventurer.ROTD.util.DMUtils; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTUtil; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.WorldWorkerManager; import net.minecraftforge.common.util.Constants; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ItemDragonWhistle extends Item { // private final MessageDragonWhistle dcw = new MessageDragonWhistle(); // private List<EntityTameableDragon> dragons = new ArrayList(); // EntityTameableDragon dragon; private byte oldIndex; public ItemDragonWhistle() { this.setUnlocalizedName("dragon_whistle"); this.setRegistryName(new ResourceLocation(DragonMounts.MODID, "dragon_whistle")); this.setMaxStackSize(1); this.setCreativeTab(DragonMounts.TAB); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { // tooltip.add(StatCollector.translateToLocal(dragon.toString())); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); int i = player.dimension; if(worldIn instanceof WorldServer) { WorldServer worldServer = (WorldServer) worldIn; EntityTameableDragon dragon = (EntityTameableDragon) worldServer.getEntityFromUuid(stack.getTagCompound().getUniqueId("dragons")); if (player.isSneaking() && stack.hasTagCompound()) { byte oldIndex = stack.getTagCompound().getByte("dragons"); byte newIndex = (byte) ((oldIndex + 1) % Math.min(3, stack.getTagCompound().getSize())); stack.getTagCompound().setByte("dragons", newIndex); DMUtils.getLogger().info("Dragon is" + dragon.getDisplayName().toString()); player.sendStatusMessage(new TextComponentString("whistle.controlling:" + dragon.getDisplayName().toString() + "" +dragon.getUniqueID().toString()), true); } } if (!player.isSneaking() && stack.hasTagCompound()) { if (worldIn.isRemote) { DragonMounts.proxy.openDragonWhistleGui(stack.getTagCompound().getUniqueId("dragons"), new ItemStack(this), worldIn); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); } } else if(!stack.hasTagCompound()) { player.sendStatusMessage(new TextComponentString("whistle.empty"), true); return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack); } return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack); } @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity target) { if (target instanceof EntityTameableDragon) { EntityTameableDragon dragon = (EntityTameableDragon) target; if (dragon.isTamedFor(player)) { NBTTagCompound nbt = new NBTTagCompound(); // NBTTagList nbtList; if (stack.hasTagCompound()) { nbt = stack.getTagCompound(); } else { stack.setTagCompound(nbt); } if (nbt.hasKey("dragons") && stack.getTagCompound().getSize() <= 3) { // I got confused because VoidWalker is mentioning NBTTagList and Im tempted use it UUID uuid = dragon.getUniqueID(); nbt.setTag("dragons", NBTUtil.createUUIDTag(uuid)); // is storing for the dragon in here enough? } else { player.sendStatusMessage(new TextComponentString("whistle.limit"), true); } } else { player.sendStatusMessage(new TextComponentString("dragon.notOwned"), true); } return true; } else { return false; } } } 1. is stack.gettagcompound.setByte("dragons", newIndex) should I use to get the index of collected dragons? I get an error called: Caused by: java.lang.ArithmeticException: / by zero 2. I thinks something is missing I ge Edited December 20, 20186 yr by diesieben07 syntax highlighting
December 21, 20186 yr Author 13 hours ago, diesieben07 said: Ahem: Your code does not make much sense. You are treating the dragons NBT key both as a byte and also as a single UUID. You need a separate key for the index and the list of UUIDs. If the oneo f the dragon is dead, how do I remove its index?
December 21, 20186 yr Author On 12/18/2018 at 6:59 PM, V0idWa1k3r said: Eiher name your tags dragon_0, dragon_1, etc. or store them in an NBTTagList. This is the only one that I do not understand. Dont kno how to use NBTTagList, What tag dragn_0, I though there was only 2 NBT's. the "dragon" for the dragon and "byte" for the selection
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.