Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

I agree with coolAlias, many problems I've encountered with entities have stemmed from not calling the supers in each method I override.  ;D

 

If that doesn't work, try slowly removing each method you override to see which one is causing the issue.

Kain

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.

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.