Jump to content

Entities with collision box and/or light effect


Bedrock_Miner

Recommended Posts

Heyho Guys!

 

I planned to create a barrier which is basically an entity, thus it can be damaged. But this barrier should prevent players (or other entities) from walking through it. I thought about adding transparent blocks at the place the entity is but this shows two problems:

1st: The Blocks prevent the entity from being damaged because of their bounding box.

2nd: The entity sometimes moves a few blocks upwards (I think because of the block at its position, just like Items do)

 

I also tought about a kind of selfmade collision. I checked for colliding Entities and assigned 0 to their motion variables. The problem was, that this had no effect. Some experiments showed, that I can't set the motion of a creative-mode-player. The player doesn't move at all.

 

How can I create the barrier with one of those methods and how can I fix the corresponding errors?

Link to comment
Share on other sites

Change the model of the entity to look like a 2 block high area with transparency, would be a cool effect.

 

Change the entities' bounding box to fit that of a 2 block high area.

 

Set the entity to aggressively try to stay in teh center of the block you placed it in. 

 

That should create a cool effect.  If not, you might have to cause the entity to attack anything too close with a little knockback but no damage.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Is this entity supposed to move positions at all?  If not, then I think what you want is an actual block with a TileEntity attached.  You can use the TileEntity to handle any cool stuff like animation, damage and even counter attacks,  I guess the question is whether you're creating something more block-like (i.e. pathfinding considers it an obstacle and it can emit light) or more entity like (it moves around).

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

That is another way to do it.  From what I have seen with people having issues with entities avoiding pathing through it, the block has some downsides.  He also wanted the 'shield' area to be damagable.  That would probably work easier from an entity, but could be done with a tileetity as you suggested.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

For this project I have done it with a TileEntity, because this seemed to be easier for this purpose. One question about this: Which method do I have to override to make the block "hitable" and thus damageable with swords?

 

Well, I started another project which needs the same feature but a bit more difficult: Some people should be able to pass the barrier, namely the Owner and people in his team. How could this feature be achieved?

Link to comment
Share on other sites

Not srue on the hitable, you will have to look it up.

 

I think it has to do with where you put the bounding box and how you set the blocks proeperites.  Look at bedrock for its hardness and such compared to wood.  Might also compare to water that you can't really damage.

 

It depends on how you setup your 'repulsion' method.  Not sure what you finally decided on that.  You just look in your method for which entity activated it and if it is in your good list, don't finish the method.

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Well, your TileEntity should have a custom block associated with it and blocks are already break-able with a sword depending on hardness .  I think in your custom block class you can override the getPlayerRelativeBlockHardness() to check if sword is being held and if it call the super function and if not return 0.0F (i.e. doesn't damage block -- the name of the method is a bit misleading as it returns the damage not the hardness).

 

Something like this I think (I haven't tried this, but just based on what I think should work):

	@Override
public float getPlayerRelativeBlockHardness(EntityPlayer entityPlayer, World world, int x, int y, int z ){
	ItemStack heldStack = entityPlayer.getHeldItem();
	if( heldStack != null && heldStack.getItem() instanceof ItemSword ){
		return super.getPlayerRelativeBlockHardness( entityPlayer, world, x, y, z );
	}
	return 0.0F;
}

 

For controlling which entities can walk through it, you can dynamically change the collision box.  I explain how to do this in my tutorial (see the bounding box section) at http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-modding-quick-tips.html.  Basically you return different collision box depending on the entity checking the collision box.  The good thing about this is that entity pathfinding is also affected so entities will know they can move through.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

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.