fcelon Posted September 4, 2017 Share Posted September 4, 2017 (edited) Hello, I have created my own entity, but I can't interact with it. When I spawn it into the world, I can see it's hitbox, but clicking on it does nothing and I can even place blocks right into it. This is my entity code. What should I do to make the hitbox work? import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; public class EntityBallista extends Entity { public EntityBallista(World worldIn) { super(worldIn); this.setSize(3, 2); this.entityCollisionReduction = 1; System.out.println(this.getEntityBoundingBox()); System.out.println(this.getCollisionBox(this)); } @Override public AxisAlignedBB getCollisionBox(Entity entityIn) { return entityIn.getEntityBoundingBox(); } public boolean processInitialInteract(EntityPlayer player, EnumHand hand) { System.out.println("Interacting"); if (player.isSneaking()) { return false; } else if (this.isBeingRidden()) { return true; } else { if (!this.world.isRemote) { player.startRiding(this); } return true; } } @Override protected void entityInit() { } @Override protected void readEntityFromNBT(NBTTagCompound compound) { //super.readFromNBT(compound); } @Override protected void writeEntityToNBT(NBTTagCompound compound) { //super.writeToNBT(compound); } } Thanks for any help. Edited September 5, 2017 by fcelon Solved Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 4, 2017 Share Posted September 4, 2017 Without the readEntityFromNBT and writeEntityToNBT methods calling super, your entity on the client can't be synchronized with the copy on the server. Quote 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. Link to comment Share on other sites More sharing options...
fcelon Posted September 4, 2017 Author Share Posted September 4, 2017 With the readEntityFromNBT and writeEntityToNBT methods calling super, an infinite loop will be created (readFromNBT calls readEntityFromNBT). I have already tried this and the entity could not be summoned. Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 4, 2017 Share Posted September 4, 2017 (edited) Then you need to not override the method. Overriding a method to do nothing is almost never the correct thing to do. That or call the correct super method...super.readEntityFromNBT Edited September 4, 2017 by Draco18s Quote 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. Link to comment Share on other sites More sharing options...
fcelon Posted September 4, 2017 Author Share Posted September 4, 2017 Even without the @Override annotation calling the super.readFromNBT still causes the infinite loop. Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 4, 2017 Share Posted September 4, 2017 (edited) Jesus christ on a crutch 24 minutes ago, Draco18s said: That or call the correct super method...super.readEntityFromNBT 18 minutes ago, fcelon said: Even without the @Override annotation calling the super.readFromNBT still causes the infinite loop. @Override is just an IDE directive, it isn't actually compiled to bytecode Edited September 4, 2017 by Draco18s Quote 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. Link to comment Share on other sites More sharing options...
fcelon Posted September 4, 2017 Author Share Posted September 4, 2017 super.readEntityFromNBT doesn't work. Cannot directly invoke the abstract method readEntityFromNBT(NBTTagCompound) for the type Entity Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 4, 2017 Share Posted September 4, 2017 Oh, you're extending Entity directly. I missed that. Not sure what's preventing you from interacting with it then. Quote 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. Link to comment Share on other sites More sharing options...
fcelon Posted September 5, 2017 Author Share Posted September 5, 2017 I just found it. @Override public boolean canBeCollidedWith() { return true; } After adding this to the code the entity works fine. 1 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.