Posted December 28, 20159 yr My entity (not entity living ) keeps teleporting when anything touches it. It teleports up about 10 blocks (the actual entity does, not just the model). When I try to go under it, I can't. I seems to have an invisible barrier beneath it, and whenever I touch that barrier, the screen shakes and I get stuck in the barrier. This is not the bounding box, because the bounding box is where the entity is (using F3+B). After a little while, the entity will come back down. Then it starts all over again. code: package com.apmods.creeps.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; public class EntitySlotMachine extends Entity{ public EntitySlotMachine(World worldIn) { super(worldIn); this.setSize(2, 3); } @Override protected void entityInit() { this.dataWatcher.addObject(14, new Integer(0)); this.dataWatcher.addObject(15, new Integer(0)); this.dataWatcher.addObject(16, new Integer(0)); } @Override protected void readEntityFromNBT(NBTTagCompound tagCompund) { this.setSlot(0, tagCompund.getInteger("slot1")); this.setSlot(1, tagCompund.getInteger("slot2")); this.setSlot(2, tagCompund.getInteger("slot3")); } @Override protected void writeEntityToNBT(NBTTagCompound tagCompound) { tagCompound.setInteger("slot1", this.getSlot(0)); tagCompound.setInteger("slot2", this.getSlot(1)); tagCompound.setInteger("slot3", this.getSlot(2)); } public void setSlot(int slot, int state){ this.dataWatcher.updateObject(14 + slot, state); } public int getSlot(int slot){ return this.dataWatcher.getWatchableObjectInt(14 + slot); } @Override public void onUpdate() { // TODO Auto-generated method stub super.onUpdate(); this.prevPosX = posX; this.prevPosY = posY; this.prevPosZ = posZ; if(!this.onGround){ this.moveEntity(0, -0.5, 0); } } @Override public boolean interactFirst(EntityPlayer playerIn) { if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != playerIn) { return true; } else { if (!this.worldObj.isRemote) { playerIn.mountEntity(this); } return true; } } @Override public AxisAlignedBB getBoundingBox() { // TODO Auto-generated method stub return this.getEntityBoundingBox(); } @Override public AxisAlignedBB getCollisionBox(Entity entityIn) { // TODO Auto-generated method stub return this.getEntityBoundingBox(); } @Override public boolean canBeCollidedWith() { // TODO Auto-generated method stub return !this.isDead; } @Override public boolean canBePushed() { // TODO Auto-generated method stub return !this.isDead; } @Override public double getMountedYOffset() { // TODO Auto-generated method stub return this.height * 0.4; } } Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.
December 29, 20159 yr You need to call super for entityInit and the read/write NBT methods. Perhaps that will fix your issue, perhaps not, but it certainly is a problem not doing so. http://i.imgur.com/NdrFdld.png[/img]
December 29, 20159 yr I agree with coolAlias, many problems I've encountered with entities have stemmed from not calling the supers in each method I override. If that doesn't work, try slowly removing each method you override to see which one is causing the issue. Kain
December 29, 20159 yr The problematic method is Entity.func_180426_a(), which is called whenever the entity receives a position packet from the server. By default that method moves entities up if they're colliding with something, just override the method so it doesnt do that. "you seem to be THE best modder I've seen imo." ~spynathan ლ(́◉◞౪◟◉‵ლ
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.