Jump to content

Recommended Posts

Posted

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?

Posted

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

Posted

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/

Posted

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

Posted

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?

Posted

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

Posted

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/

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been using this modpack for a few days now with no issues, it was working properly just an hour or two ago and now all of a sudden when I try to load it I get this error: 'The game crashed: exception in server tick loop Error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $' debug log: https://pastebin.com/1htBuhsP crash report: https://pastebin.com/QggHKYDg
    • Everything worked fine until I decided to install supplementaries squared, amendments and a couple other mods like artifacts, and compats for it. I'm having a hard time fixing this, and I get this crash whenever I try to enter a world. Not even a new world is feasible. Any help would be highly appreciated!! https://pastebin.com/7KXYZ6fM
    • Internal Exception: com.google.gson.JsonParseException: Error loading registry data: Unknown element: ResourceKey[minecraft:worldgen/configured_feature / minecraft:crimson_forest_vegetation]   This error is there when i try to join my friends server. We had some mods and it was okay but after 3 days i cant join.
    • It just says the mod i had but i dont have now.. and i didnt even use these mods and it still was crashing with the mods  
    • Hello,   I've been back and forth in emails with some CurseForge support staff on the issue but there's been no progress. In the CurseForge app, I have custom profiles and some public modpacks that will not load no matter what. I've goen through every link sent to me, I've reinstalled Minecraft, reinstalled the launcher, repaired the installations individually, uninstalled and reinstalled the public modpacks, downloaded the latest Java--all of it. But each time, I'm always met with either "java runtime exception", "exit code 1" on the rare occasions Minecraft does launch, or "java is out of date" (which literally cannot be possible since I reinstalled the latest version a few different times.) Making a new profile works, but I want to be able to play the ones I had before.  I had gotten one of the old public Minecraft modpacks to work, the prehistoric one about dinosaurs being featured right now, but then it only worked once. I've tried to retrace my steps and it just would not work. I have genuinely no clue what's going on.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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