Electric Posted August 6, 2018 Share Posted August 6, 2018 By following the EnderDragon's format, I have successfully created a multipart entity, complete with several different bounding boxes. After a player right clicks the entity, I would like to be able to detect which bounding box is being interacted with, but I am not sure if this is possible. IEntityMultiPart does supply the following method, which detects the bounding box, but it is only triggered with a left click. Any ideas? public boolean attackEntityFromPart(MultiPartEntityPart consolePart, DamageSource source, float damage) Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 6, 2018 Share Posted August 6, 2018 2 minutes ago, Electric said: By following the EnderDragon's format, I have successfully created a multipart entity, complete with several different bounding boxes. After a player right clicks the entity, I would like to be able to detect which bounding box is being interacted with, but I am not sure if this is possible. IEntityMultiPart does supply the following method, which detects the bounding box, but it is only triggered with a left click. Any ideas? Make your own class that extends MultiPartEntity part and override the interact method(processInitialInteract). And use that as the instance for your parts. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Electric Posted August 6, 2018 Author Share Posted August 6, 2018 I have tried the interact method, but I'm still not sure how to detect which part is being right clicked. Printing out items such as getCollisionBoundingBox and getEntityBoundingBox always return the same thing, regardless of which part on the entity is being clicked. I'm not sure how to differentiate between the boxes within the processInteract method. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 6, 2018 Share Posted August 6, 2018 2 hours ago, Electric said: I have tried the interact method, but I'm still not sure how to detect which part is being right clicked. Printing out items such as getCollisionBoundingBox and getEntityBoundingBox always return the same thing, regardless of which part on the entity is being clicked. I'm not sure how to differentiate between the boxes within the processInteract method. Post your code Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Electric Posted August 6, 2018 Author Share Posted August 6, 2018 Here is my Entity class: Spoiler public class EntityConsoleBrachacki extends EntityLiving implements IEntityMultiPart { protected final EntityAILookIdle aiLookIdle = new EntityAILookIdle(this); /** An array containing all body parts of this dragon */ public MultiPartEntityPart[] consolePartArray; /** The head bounding box of a dragon */ public MultiPartEntityPart consolePartRotor = new MultiPartEntityPart(this, "rotor", 1.0F, 3.0F); public MultiPartEntityPart consolePartFront = new MultiPartEntityPart(this, "front", 1.0F, 1.0F); public MultiPartEntityPart consolePartBack = new MultiPartEntityPart(this, "back", 1.0F, 1.0F); public static ITardisConsole getHandler(Entity entity) { if (entity.hasCapability(TARDIS_CONSOLE, EnumFacing.DOWN)) return entity.getCapability(TARDIS_CONSOLE, EnumFacing.DOWN); return null; } public EntityConsoleBrachacki(World worldIn) { super(worldIn); this.consolePartArray = new MultiPartEntityPart[] {this.consolePartRotor, this.consolePartFront, this.consolePartBack}; this.isImmuneToFire = true; setSize(4.0F, 1.5F); tasks.removeTask(aiLookIdle); } // @Override // public boolean shouldRenderInPass(int pass) // { // return pass == 0; // } @Override protected boolean canDespawn() { return false; } public void onLivingUpdate() { super.onLivingUpdate(); this.consolePartRotor.onUpdate(); this.consolePartRotor.setLocationAndAngles(this.posX + 1.5, this.posY, this.posZ, 0, 0); } public void onEntityUpdate() { super.onEntityUpdate(); } /** * Returns the <b>solid</b> collision bounding box for this entity. Used to make (e.g.) boats solid. Return null if * this entity is not solid. * * For general purposes, use {@link #width} and {@link #height}. * * see getEntityBoundingBox * omg this updates in real time */ @Nullable public AxisAlignedBB getCollisionBoundingBox() { return this.getEntityBoundingBox(); } @Override public void onCollideWithPlayer(EntityPlayer entityIn) {} @Override public boolean hitByEntity(Entity entityIn) { return true; } @Override public boolean canBePushed() { return false; } @Override protected void collideWithEntity(Entity p_82167_1_) {} @Override protected void collideWithNearbyEntities() { } @Override public boolean processInteract(EntityPlayer player, EnumHand hand) { System.out.println(this.getCollisionBoundingBox()); System.out.println(this.getEntityBoundingBox()); System.out.println(this.getParts()); return true; } /** * Makes the entity despawn if requirements are reached * I don't know if this is needed */ @Override protected void despawnEntity() { } /** * Return the Entity parts making up this Entity (currently only for dragons) */ @Override public Entity[] getParts() { return this.consolePartArray; } @Override public World getWorld() { return this.world; } /** * Run when one of the parts is hit by a player :D */ @Override public boolean attackEntityFromPart(MultiPartEntityPart consolePart, DamageSource source, float damage) { System.out.println(consolePart.partName); return false; } } Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 6, 2018 Share Posted August 6, 2018 15 minutes ago, Electric said: Here is my Entity class: Well you didn't do what I said. 12 hours ago, Animefan8888 said: Make your own class that extends MultiPartEntity part and override the interact method(processInitialInteract). And use that as the instance for your parts. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Electric Posted August 6, 2018 Author Share Posted August 6, 2018 I'm slightly confused on what you mean by that. Do I need to have my entity extend MultiPartEntityPart or make a whole new class that extends it? And if its the latter, how am I supposed to reference it for my own entity's parts? I tried this but I am lost: Spoiler public class EntityTest extends MultiPartEntityPart { public EntityTest(IEntityMultiPart parent, String partName, float width, float height) { super(parent, partName, width, height); } @Override public boolean processInitialInteract(EntityPlayer player, EnumHand hand) { System.out.println(partName); return false; } Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 6, 2018 Share Posted August 6, 2018 11 minutes ago, Electric said: And if its the latter, how am I supposed to reference it for my own entity's parts? I tried this but I am lost: Yes I meant the latter. Instead of doing new MultiPartEntity do new EntityTest. 1 Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Electric Posted August 6, 2018 Author Share Posted August 6, 2018 Oh wow, it works perfectly. Thank you for the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.