Jump to content

Recommended Posts

Posted

Hi i am helping to port a mod from 1.7.10 to 1.10.2 , the mod has an UraniumOre wich behaves just like a cactus block when the player collides with it, here is my code 

 

1486788790-z5a234fb3.png

 

i also tried to use DamageSoruce.cactus but it doesn't work either

Thanks for any help

Posted

The block needs to have a boundary smaller than a full 1x1x1 cube, otherwise the player can't collide with it.  I believe the minimum offset is 0.005. Something in around that neighborhood (might be 0.01).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

Thanks for the answer, i had this but it didnt work either:

 

public AxisAlignedBB getSelectedBoundingBox(World world, int i, int j, int k) {
        float var5 = 0.0625F;
        return new AxisAlignedBB((float) i + var5, j, (float) k + var5, (float) (i + 1) - var5,
                (float) (j + 1) - var5, (float) (k + 1) - var5);
    }

 

maybe here is the problem, but this is a copy of the 1.7.10 code in which works fine

Edited by Daniat
Posted

Your method doesn't override any method from a parent class (it has the wrong argument types to override Block#onEntityCollidedWithBlock), so it's never called. If you'd annotated it with @Override, your IDE or the compiler would have told you this.

 

I recommend using your IDE to auto-generate override methods with the correct signature and annotations.

 

When updating a new version of Minecraft, I auto-generate override methods for any methods I was previously overriding that have changed signature and then move the body of the previous method into the new one.

 

Side note: DamageSource instances should be treated as singletons (i.e. created once and then stored somewhere) unless there's additional data that changes each time the damage is done (e.g. the entities of EntityDamageSource/EntityDamageSourceIndirect).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

I believe you want to override getCollisionBoundingBox.

Ninja'd by Choonster

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 minute ago, Daniat said:

Yes i try to call @Override but i get this

 

4 minutes ago, Choonster said:

Your method doesn't override any method from a parent class (it has the wrong argument types to override Block#onEntityCollidedWithBlock), so it's never called. If you'd annotated it with @Override, your IDE or the compiler would have told you this.

 

I recommend using your IDE to auto-generate override methods with the correct signature and annotations.

 

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Removing @Override is never the correct answer.

It's ignoring the problem.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
7 minutes ago, Daniat said:

P.d. im sorry i am still a newbie in modding

 

This isn't specific to Minecraft or Forge, this is basic Java knowledge which you should already have before starting to make a mod.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
5 minutes ago, Choonster said:

(it has the wrong argument types to override Block#onEntityCollidedWithBlock)

 

the only difference i see in argument types is EntityLivingBase, here is the overload  onEntityCollidedWithBlock(World, BlockPos, IBlockState, Entity)

 

Posted
1 minute ago, Choonster said:

 

This isn't specific to Minecraft or Forge, this is basic Java knowledge which you should already have before starting to make a mod.

well actually i am not making the mod, its just a mod i ve used and i want to port it to 1.10.2, but thanks for your help, now i know the problem is that i dont override these methods

Posted
4 minutes ago, Daniat said:

the only difference i see in argument types is EntityLivingBase, here is the overload  onEntityCollidedWithBlock(World, BlockPos, IBlockState, Entity)

 

That difference is what prevents it from being an override method.

 

As this tutorial explains, override methods must have the same return type, number and type of parameters as the super method. You can return a subtype of the super method's return type, but the parameter types must be exactly the same. 

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
Just now, Choonster said:

 

That difference is what prevents it from being an override method.

 

As this tutorial explains, override methods must have the same return type, number and type of parameters as the super method. You can return a subtype of the super method's return type, but the parameter types must be exactly the same. 

yes i remember, i didnt use Entity cause the player is the only one who takes damage, i mean its not like a cactus which damages all mobs

Posted

The method still takes in an Entity, you have to filter out the other types yourself in the method.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
29 minutes ago, Draco18s said:

I believe you want to override getCollisionBoundingBox.

Ninja'd by Choonster

yes, true, dumb of me, but this was my decompiled source code to start with

public AxisAlignedBB func_149668_a(World world, int i, int j, int k)

Posted (edited)

Now it works pretty much like it does in 1.7.10 just that now damages every living thing that touches it, maybe this way is more realistic xD

Here is the code if anyone is interested, thanks Draco18s and Choonster for the help

z5a234fb5.png

 

Edit: SOLVED

Edited by Daniat

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.