Jump to content

Recommended Posts

Posted

Hey,  I was looking to make a block that gives players around it (in a given radius) and gives them a potion effect, I have everything already done, I just cant figure out how to search around a block for entitys.

 

~Any help would be appreciated, Shaun O'Neill.

View my website at -> http://www.xelitexirish.com/

You can nearly always contact me on my twitter (XeliteXirish)

Posted

You can use World#getEntitiesWithinAABB(ENTITY_CLASS,BOUNDING_BOX). You can replace the ENTITY_CLASS with EntityPlayer.class for a player. For the BOUNDING_BOX, you can use TileEntity#getRenderBoundingBox().expand(RADIUS,RADIUS,RADIUS).

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

Hey, I've looked at what you both said, but I keep getting an error.  The GitHub page for the block is https://github.com/XeliteXirish/Quantum-Energistics-2/blob/master/src/main/Common/com/XeliteXirish/QuantumEnergistics2/tileEntity/TileEntityPotionDispencer.java

 

The error I get is-

-- Head --
Stacktrace:
at com.XeliteXirish.QuantumEnergistics2.tileEntity.TileEntityPotionDispencer.<init>(TileEntityPotionDispencer.java:21)
at com.XeliteXirish.QuantumEnergistics2.block.blockPotionDispencer.createNewTileEntity(blockPotionDispencer.java:17)
at net.minecraft.block.Block.createTileEntity(Block.java:1778)
at net.minecraft.world.chunk.Chunk.func_150806_e(Chunk.java:947)
at net.minecraft.world.ChunkCache.getTileEntity(ChunkCache.java:102)
at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:189)
at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1624)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1271)

 

The error is on line: List players = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);

Any help would be nice :)

View my website at -> http://www.xelitexirish.com/

You can nearly always contact me on my twitter (XeliteXirish)

Posted

try moving that code into your update method like:

 

@Override
public void updateEntity() 
{
	if (!getWorldObj().isRemote)
	{
		List players = getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, this.getRenderBoundingBox().expand(range, range, range));
	        Iterator iterator = players.iterator();
                        EntityPlayer entityplayer;
                        while (iterator.hasNext())
                        {
                              entityplayer = (EntityPlayer)iterator.next();
                              ExtendPlayerRotManaStam props = ExtendPlayerRotManaStam.get(entityplayer);
                              if (props.needsMana())
                              {
             	                 if (mana > 1)
            	                 {
            		             props.regenMana(1f);
            		             mana -= 1;            		
            	                 }
                               }
                           }
                        repairItemsOnPlayers(players);
	}
}

 

remember you want to check whenever there is a nearby player.

Posted

Sorry I don't have any clue how I forgot that haha, anyways I have it working perfectly now :) For anyone interested in seeing it:https://github.com/XeliteXirish/Quantum-Energistics-2/blob/master/src/main/Common/com/XeliteXirish/QuantumEnergistics2/tileEntity/TileEntityPotionDispencer.java (Il commit in in a minute)

View my website at -> http://www.xelitexirish.com/

You can nearly always contact me on my twitter (XeliteXirish)

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.