Posted September 4, 20178 yr 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, 20178 yr by fcelon Solved
September 4, 20178 yr Without the readEntityFromNBT and writeEntityToNBT methods calling super, your entity on the client can't be synchronized with the copy on the server. 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.
September 4, 20178 yr Author 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.
September 4, 20178 yr 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, 20178 yr 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.
September 4, 20178 yr Author Even without the @Override annotation calling the super.readFromNBT still causes the infinite loop.
September 4, 20178 yr 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, 20178 yr 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.
September 4, 20178 yr Author super.readEntityFromNBT doesn't work. Cannot directly invoke the abstract method readEntityFromNBT(NBTTagCompound) for the type Entity
September 4, 20178 yr Oh, you're extending Entity directly. I missed that. Not sure what's preventing you from interacting with it then. 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.
September 5, 20178 yr Author I just found it. @Override public boolean canBeCollidedWith() { return true; } After adding this to the code the entity works fine.
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.