Jump to content

Recommended Posts

Posted

I've been working on a clone of the x-gun from the manga "Gantz", but I can't seem to get it working. For those who haven't read Gantz, the item I'm making (MC Version) should lock on to entities with a right click, and when the player right clicks while sneaking, kills everything it's locked onto, or deals huge damage. (In the manga, it blows their heads up) I've gotten the lock-on list to work, but when I shift+right click, nothing happens. I've replaced the attackEntityFrom() line with addVelocity(0, 10, 0), and that works fine (Still have a few pigs somewhere in the sky), but I can't damage them or add potion effects. Any help?

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
   {
         Minecraft mc = Minecraft.getMinecraft();
         MovingObjectPosition objectMouseOver = mc.objectMouseOver;
         if(mc.objectMouseOver != null && mc.objectMouseOver.entityHit != null)
         {
            Entity target = objectMouseOver.entityHit;
            if(target instanceof EntityLivingBase)
            {
               EntityLivingBase living = (EntityLivingBase)target;
               if(!entList.contains(living))
               {
                  entList.add(living);
               }
            }
         }
         if(par3EntityPlayer.isSneaking())
         {
            if (entList != null && !entList.isEmpty())
            {
               Iterator iterator = entList.iterator();
               while (iterator.hasNext())
               {
                  EntityLivingBase livingBase = (EntityLivingBase)iterator.next();
                  livingBase.attackEntityFrom(DamageSource.generic, 30.0F);
               }
            }
            entList.clear();
         }
      return par1ItemStack;
   }

Posted

Your enList is in the item? 

 

How is that going to work.  You need to store the list in the itemstack.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

1) You should add the entList into the method because if it is in the Item, all the Items of the same type have the same locked-on entities, and you probably don't want that.

2) You might want to do the killing server-side:

if(!world.isRemote){DO THINGS}

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

NBT can be used to store an entire class worth of information. I can say that because in a mod I am working on some of my Entities are pretty much pure NBT tags... :P

 

Its all about how you are trying to store the information. NBT supports all the primitive type data (at least, it should) so you can save everything you need.

 

What you will want to do, is create a NBTTagList that is filled with NBTTagCompounds. Each NBTTagCompound will represent whatever you want. Then, you just attach all the variables of the class you need saved. So for example, my entities need their health, owner, maxHealth, position, and more. These are just stored using nbtTagCompoundInstance.set***("identifier", variable); Where *** is the variable type you want to save, identifier is the string you use to identify that saved variable, and variable is the variable you want to save.

 

 

 

Did that make sense at all?

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

NBT can be used to store an entire class worth of information. I can say that because in a mod I am working on some of my Entities are pretty much pure NBT tags... :P

 

Its all about how you are trying to store the information. NBT supports all the primitive type data (at least, it should) so you can save everything you need.

 

What you will want to do, is create a NBTTagList that is filled with NBTTagCompounds. Each NBTTagCompound will represent whatever you want. Then, you just attach all the variables of the class you need saved. So for example, my entities need their health, owner, maxHealth, position, and more. These are just stored using nbtTagCompoundInstance.set***("identifier", variable); Where *** is the variable type you want to save, identifier is the string you use to identify that saved variable, and variable is the variable you want to save.

 

 

 

Did that make sense at all?

 

Yeah, made lots of sense. Been looking around. Still have no clue whatsoever how to store+edit Lists (of EntityLivingBase). Ints, floats, Strings are easy, as there's methods for them. But how do I use NBTTagList? From what I read, it stores only lists of Tags... There's always the possibility I'm kinda stupid/inexperienced/whatever.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.