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

So I was trying to change my entity from EntityMob to EntityTameable then to EntityAgeable. This suddenly caused it's speed to spike and it practically teleports when it walks. I have absolutely no idea why this is happening as I even set the AI Move speed and the attribute.

 

package io.github.mrnegablox.minefortress.entity;

import java.io.Console;

import scala.collection.concurrent.Debug;
import io.github.mrnegablox.minefortress.ai.EntityAIGoToWaypoint;
import io.github.mrnegablox.minefortress.item.ModItems;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveIndoors;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAIOpenDoor;
import net.minecraft.entity.ai.EntityAIRestrictOpenDoor;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class EntityDwarf extends EntityAgeable {

private boolean goingToWaypoint;
private int targetX;
private int targetY;
private int targetZ;

public EntityDwarf(World par1World) {		
	super(par1World);
	this.setAIMoveSpeed(0.1F);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5d);
	this.getNavigator().setEnterDoors(true);
	this.getNavigator().setBreakDoors(true);
	this.tasks.addTask(1, new EntityAISwimming(this));
	this.tasks.addTask(2, new EntityAIGoToWaypoint(this));
	//this.tasks.addTask(3, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
	this.tasks.addTask(3, new EntityAIMoveIndoors(this));
	this.tasks.addTask(4, new EntityAIRestrictOpenDoor(this));
	this.tasks.addTask(5, new EntityAIOpenDoor(this, true));
	this.tasks.addTask(6, new EntityAIMoveTowardsRestriction(this, 0.3F));
	this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
	this.tasks.addTask(8, new EntityAIWatchClosest(this,
			EntityPlayer.class, 8.0F));
	this.tasks.addTask(8, new EntityAIWatchClosest(this,
			EntityDwarf.class, 8.0F));
	this.tasks.addTask(9, new EntityAILookIdle(this));
	this.setSize(1.0F,0.5F);

}


@Override
public boolean interact(EntityPlayer player) {
	System.out.println("interact start");
        ItemStack cei=player.getCurrentEquippedItem();
	if(cei !=null && cei.getItem() == ModItems.staff){
		System.out.println("interact called");
                if (cei.stackTagCompound == null){
                    cei.setTagCompound(new NBTTagCompound());
                }
		cei.stackTagCompound.setInteger("target", this.getEntityId());
		System.out.println(this.getEntityId());
	}
	return super.interact(player);
}

public boolean isgoingToWaypoint(){
	return goingToWaypoint;
}

public void setgoingToWaypoint(boolean gotow){
	goingToWaypoint = gotow;
}




public boolean isAIEnabled() {
	return true;
}

public int gettargetX(){
	return targetX;
}

public int gettargetY(){
	return targetY;
}

public int gettargetZ(){
	return targetZ;
}

public void setTargetPos(int x, int y,int z){
	targetX = x;
	targetY = y;
	targetZ = z;
}

@Override
public void readFromNBT(NBTTagCompound nbt)
{
    super.readFromNBT(nbt);
    goingToWaypoint = nbt.getBoolean("goingToWaypoint");
    targetX = nbt.getInteger("targetX");
    targetY = nbt.getInteger("targetY");
    targetZ = nbt.getInteger("targetZ");
}

@Override
public void writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	nbt.setBoolean("goingToWaypoint", goingToWaypoint);
	nbt.setInteger("targetX", targetX);
	nbt.setInteger("targetY", targetY);
	nbt.setInteger("targetZ", targetZ);
}

@Override
public EntityAgeable createChild(EntityAgeable p_90011_1_) {
	// TODO Auto-generated method stub
	return null;
}




}

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.