Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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;
   }

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

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/

  • Author

Tried killing server-side, didn't work. I've been trying to figure out NBT Tags, and have gotten nowhere. Can they even be used to store a List and add to it like that?

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.

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.