-
Posts
1061 -
Joined
-
Last visited
Everything posted by NovaViper
-
[1.8] Help with executing movement animation from MCAnimator
NovaViper replied to NovaViper's topic in Modder Support
Huh, didn't know that. Hey.. I got a question also, the author of Dragon Mounts uses something similar to MCAnimator like these https://github.com/ata4/dragon-mounts/tree/master/src/main/java/info/ata4/minecraft/dragon/client/model Maybe I can use this? -
[1.8] Help with executing movement animation from MCAnimator
NovaViper replied to NovaViper's topic in Modder Support
Shoot, thanks anyway. -
[1.8] Help with executing movement animation from MCAnimator
NovaViper replied to NovaViper's topic in Modder Support
Well, I wanted to use the model from MCAnimator to have animations when my entity jumps and lands and swims in water, thats why I used MCAnimator. Since I can't use it, is there any alternative? -
[1.8] Help with executing movement animation from MCAnimator
NovaViper replied to NovaViper's topic in Modder Support
So, don't use MCAnimator at all then? -
Hey, I'm trying to execute this walking animation I created using MCAnimator ONLY when the entity is moving. But I'm having trouble achieving this Model Code package common.zeroquest.client.renderer.entity.model; import java.util.HashMap; import net.minecraft.client.model.ModelBase; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import common.zeroquest.client.mca.MCAModelRenderer; import common.zeroquest.client.mca.libary.MCAVersionChecker; import common.zeroquest.client.mca.libary.animation.AnimationHandler; import common.zeroquest.client.mca.libary.math.Matrix4f; import common.zeroquest.client.mca.libary.math.Quaternion; import common.zeroquest.entity.EntityRowarn; public class ModelRowarn extends ModelBase { public final int MCA_MIN_REQUESTED_VERSION = 5; public HashMap<String, MCAModelRenderer> parts = new HashMap<String, MCAModelRenderer>(); MCAModelRenderer neck1; MCAModelRenderer torso1; MCAModelRenderer tail1; MCAModelRenderer leftHindLeg1; MCAModelRenderer rightHindLeg1; MCAModelRenderer leftFrontLeg; MCAModelRenderer rightFrontLeg; MCAModelRenderer neck2; MCAModelRenderer torso2; MCAModelRenderer tail2; MCAModelRenderer leftHindLeg2; MCAModelRenderer rightHindLeg2; MCAModelRenderer leftFrontClaw1; MCAModelRenderer leftFrontClaw2; MCAModelRenderer rightFrontClaw1; MCAModelRenderer rightFrontClaw2; MCAModelRenderer topJaw; MCAModelRenderer tail3; MCAModelRenderer leftHindLeg3; MCAModelRenderer rightHindLeg3; MCAModelRenderer bottomJaw; MCAModelRenderer tail4; MCAModelRenderer leftHindClaw1; MCAModelRenderer leftHindClaw2; MCAModelRenderer rightHindClaw1; MCAModelRenderer rightHindClaw2; MCAModelRenderer fin1; MCAModelRenderer fin2; public ModelRowarn() { MCAVersionChecker.checkForLibraryVersion(getClass(), MCA_MIN_REQUESTED_VERSION); textureWidth = 256; textureHeight = 128; neck1 = new MCAModelRenderer(this, "Neck1", 21, 0); neck1.mirror = false; neck1.addBox(-2.0F, -2.0F, 1.0F, 4, 4, 6); neck1.setInitialRotationPoint(-0.5F, -11.0F, 9.0F); neck1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.16652437F, 0.0F, 0.0F, 0.9860373F)).transpose()); neck1.setTextureSize(256, 128); parts.put(neck1.boxName, neck1); torso1 = new MCAModelRenderer(this, "Torso1", 69, 0); torso1.mirror = false; torso1.addBox(-2.5F, -2.5F, -9.0F, 5, 5, 9); torso1.setInitialRotationPoint(-0.5F, -10.5F, 4.0F); torso1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.055739015F, 0.0F, 0.0F, 0.9984454F)).transpose()); torso1.setTextureSize(256, 128); parts.put(torso1.boxName, torso1); tail1 = new MCAModelRenderer(this, "Tail1", 99, 0); tail1.mirror = false; tail1.addBox(-2.0F, -2.0F, -10.0F, 4, 4, 10); tail1.setInitialRotationPoint(-0.5F, -11.5F, -4.0F); tail1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.055739015F, 0.0F, 0.0F, 0.9984454F)).transpose()); tail1.setTextureSize(256, 128); parts.put(tail1.boxName, tail1); leftHindLeg1 = new MCAModelRenderer(this, "LeftHindLeg1", 11, 17); leftHindLeg1.mirror = false; leftHindLeg1.addBox(-1.0F, -5.0F, -2.0F, 2, 5, 3); leftHindLeg1.setInitialRotationPoint(1.5F, -11.0F, -3.0F); leftHindLeg1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.14816688F, 0.0F, 0.0F, 0.98896235F)).transpose()); leftHindLeg1.setTextureSize(256, 128); parts.put(leftHindLeg1.boxName, leftHindLeg1); rightHindLeg1 = new MCAModelRenderer(this, "RightHindLeg1", 23, 17); rightHindLeg1.mirror = false; rightHindLeg1.addBox(-1.0F, -5.0F, -2.0F, 2, 5, 3); rightHindLeg1.setInitialRotationPoint(-2.5F, -11.0F, -3.0F); rightHindLeg1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.14816688F, 0.0F, 0.0F, 0.98896235F)).transpose()); rightHindLeg1.setTextureSize(256, 128); parts.put(rightHindLeg1.boxName, rightHindLeg1); leftFrontLeg = new MCAModelRenderer(this, "LeftFrontLeg", 0, 17); leftFrontLeg.mirror = false; leftFrontLeg.addBox(-1.0F, -11.0F, -1.0F, 2, 11, 2); leftFrontLeg.setInitialRotationPoint(2.0F, -11.0F, 8.0F); leftFrontLeg.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose()); leftFrontLeg.setTextureSize(256, 128); parts.put(leftFrontLeg.boxName, leftFrontLeg); rightFrontLeg = new MCAModelRenderer(this, "RightFrontLeg", 35, 17); rightFrontLeg.mirror = false; rightFrontLeg.addBox(-1.0F, -11.0F, -1.0F, 2, 11, 2); rightFrontLeg.setInitialRotationPoint(-3.0F, -11.0F, 8.0F); rightFrontLeg.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose()); rightFrontLeg.setTextureSize(256, 128); parts.put(rightFrontLeg.boxName, rightFrontLeg); neck2 = new MCAModelRenderer(this, "Neck2", 0, 0); neck2.mirror = false; neck2.addBox(-2.0F, -2.0F, 1.0F, 4, 4, 6); neck2.setInitialRotationPoint(0.0F, -0.4F, 5.0F); neck2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.1478094F, 0.0F, 0.0F, 0.9890159F)).transpose()); neck2.setTextureSize(256, 128); parts.put(neck2.boxName, neck2); neck1.addChild(neck2); torso2 = new MCAModelRenderer(this, "Torso2", 42, 0); torso2.mirror = false; torso2.addBox(-2.5F, -2.5F, -8.0F, 5, 5, ; torso2.setInitialRotationPoint(0.0F, -0.5F, 7.0F); torso2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.043619387F, 0.0F, 0.0F, 0.99904823F)).transpose()); torso2.setTextureSize(256, 128); parts.put(torso2.boxName, torso2); torso1.addChild(torso2); tail2 = new MCAModelRenderer(this, "Tail2", 129, 0); tail2.mirror = false; tail2.addBox(-1.5F, -1.5F, -10.0F, 3, 3, 10); tail2.setInitialRotationPoint(0.0F, 0.0F, -9.0F); tail2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.06104854F, 0.0F, 0.0F, 0.9981348F)).transpose()); tail2.setTextureSize(256, 128); parts.put(tail2.boxName, tail2); tail1.addChild(tail2); leftHindLeg2 = new MCAModelRenderer(this, "LeftHindLeg2", 11, 27); leftHindLeg2.mirror = false; leftHindLeg2.addBox(-1.0F, -4.0F, -1.0F, 2, 4, 2); leftHindLeg2.setInitialRotationPoint(0.0F, -4.3F, 0.3F); leftHindLeg2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.40673664F, 0.0F, 0.0F, 0.9135454F)).transpose()); leftHindLeg2.setTextureSize(256, 128); parts.put(leftHindLeg2.boxName, leftHindLeg2); leftHindLeg1.addChild(leftHindLeg2); rightHindLeg2 = new MCAModelRenderer(this, "RightHindLeg2", 23, 27); rightHindLeg2.mirror = false; rightHindLeg2.addBox(-1.0F, -4.0F, -1.0F, 2, 4, 2); rightHindLeg2.setInitialRotationPoint(0.0F, -4.3F, 0.3F); rightHindLeg2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.40673664F, 0.0F, 0.0F, 0.9135454F)).transpose()); rightHindLeg2.setTextureSize(256, 128); parts.put(rightHindLeg2.boxName, rightHindLeg2); rightHindLeg1.addChild(rightHindLeg2); leftFrontClaw1 = new MCAModelRenderer(this, "LeftFrontClaw1", 11, 43); leftFrontClaw1.mirror = false; leftFrontClaw1.addBox(-0.5F, -1.0F, 0.0F, 1, 1, 3); leftFrontClaw1.setInitialRotationPoint(-0.5F, -10.0F, 0.0F); leftFrontClaw1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, -0.09281317F, 0.0F, 0.99568355F)).transpose()); leftFrontClaw1.setTextureSize(256, 128); parts.put(leftFrontClaw1.boxName, leftFrontClaw1); leftFrontLeg.addChild(leftFrontClaw1); leftFrontClaw2 = new MCAModelRenderer(this, "LeftFrontClaw2", 11, 43); leftFrontClaw2.mirror = false; leftFrontClaw2.addBox(-0.5F, -1.0F, 0.0F, 1, 1, 3); leftFrontClaw2.setInitialRotationPoint(0.5F, -10.0F, 0.0F); leftFrontClaw2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.09281374F, 0.0F, 0.9956835F)).transpose()); leftFrontClaw2.setTextureSize(256, 128); parts.put(leftFrontClaw2.boxName, leftFrontClaw2); leftFrontLeg.addChild(leftFrontClaw2); rightFrontClaw1 = new MCAModelRenderer(this, "RightFrontClaw1", 23, 43); rightFrontClaw1.mirror = false; rightFrontClaw1.addBox(-0.5F, -1.0F, 0.0F, 1, 1, 3); rightFrontClaw1.setInitialRotationPoint(-0.5F, -10.0F, 0.0F); rightFrontClaw1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, -0.09281317F, 0.0F, 0.99568355F)).transpose()); rightFrontClaw1.setTextureSize(256, 128); parts.put(rightFrontClaw1.boxName, rightFrontClaw1); rightFrontLeg.addChild(rightFrontClaw1); rightFrontClaw2 = new MCAModelRenderer(this, "RightFrontClaw2", 23, 43); rightFrontClaw2.mirror = false; rightFrontClaw2.addBox(-0.5F, -1.0F, 0.0F, 1, 1, 3); rightFrontClaw2.setInitialRotationPoint(0.5F, -10.0F, 0.0F); rightFrontClaw2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.09281374F, 0.0F, 0.9956835F)).transpose()); rightFrontClaw2.setTextureSize(256, 128); parts.put(rightFrontClaw2.boxName, rightFrontClaw2); rightFrontLeg.addChild(rightFrontClaw2); topJaw = new MCAModelRenderer(this, "TopJaw", 0, 54); topJaw.mirror = false; topJaw.addBox(-2.0F, -1.0F, 0.5F, 5, 3, ; topJaw.setInitialRotationPoint(-0.5F, 1.5F, 6.0F); topJaw.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.2923717F, 0.0F, 0.0F, 0.9563048F)).transpose()); topJaw.setTextureSize(256, 128); parts.put(topJaw.boxName, topJaw); neck2.addChild(topJaw); tail3 = new MCAModelRenderer(this, "Tail3", 157, 0); tail3.mirror = false; tail3.addBox(-1.0F, -1.0F, -10.0F, 2, 2, 10); tail3.setInitialRotationPoint(0.0F, 0.0F, -8.0F); tail3.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.02617695F, 0.0F, 0.0F, 0.99965733F)).transpose()); tail3.setTextureSize(256, 128); parts.put(tail3.boxName, tail3); tail2.addChild(tail3); leftHindLeg3 = new MCAModelRenderer(this, "LeftHindLeg3", 11, 35); leftHindLeg3.mirror = false; leftHindLeg3.addBox(-1.0F, -4.0F, -1.0F, 2, 4, 2); leftHindLeg3.setInitialRotationPoint(0.0F, -3.4F, -0.2F); leftHindLeg3.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.27563736F, 0.0F, 0.0F, 0.9612617F)).transpose()); leftHindLeg3.setTextureSize(256, 128); parts.put(leftHindLeg3.boxName, leftHindLeg3); leftHindLeg2.addChild(leftHindLeg3); rightHindLeg3 = new MCAModelRenderer(this, "RightHindLeg3", 23, 35); rightHindLeg3.mirror = false; rightHindLeg3.addBox(-1.0F, -4.0F, -1.0F, 2, 4, 2); rightHindLeg3.setInitialRotationPoint(0.0F, -3.4F, -0.2F); rightHindLeg3.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.27563736F, 0.0F, 0.0F, 0.9612617F)).transpose()); rightHindLeg3.setTextureSize(256, 128); parts.put(rightHindLeg3.boxName, rightHindLeg3); rightHindLeg2.addChild(rightHindLeg3); bottomJaw = new MCAModelRenderer(this, "BottomJaw", 0, 68); bottomJaw.mirror = false; bottomJaw.addBox(-2.0F, -1.0F, 0.5F, 5, 2, 9); bottomJaw.setInitialRotationPoint(0.0F, -2.0F, 0.0F); bottomJaw.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose()); bottomJaw.setTextureSize(256, 128); parts.put(bottomJaw.boxName, bottomJaw); topJaw.addChild(bottomJaw); tail4 = new MCAModelRenderer(this, "Tail4", 182, 0); tail4.mirror = false; tail4.addBox(-0.5F, -0.5F, -9.0F, 1, 1, 9); tail4.setInitialRotationPoint(0.0F, 0.0F, -8.0F); tail4.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(-0.02617695F, 0.0F, 0.0F, 0.99965733F)).transpose()); tail4.setTextureSize(256, 128); parts.put(tail4.boxName, tail4); tail3.addChild(tail4); leftHindClaw1 = new MCAModelRenderer(this, "LeftHindClaw1", 11, 43); leftHindClaw1.mirror = false; leftHindClaw1.addBox(-0.5F, -1.0F, 0.0F, 1, 1, 3); leftHindClaw1.setInitialRotationPoint(-0.5F, -3.0F, 0.0F); leftHindClaw1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, -0.09281317F, 0.0F, 0.99568355F)).transpose()); leftHindClaw1.setTextureSize(256, 128); parts.put(leftHindClaw1.boxName, leftHindClaw1); leftHindLeg3.addChild(leftHindClaw1); leftHindClaw2 = new MCAModelRenderer(this, "LeftHindClaw2", 11, 43); leftHindClaw2.mirror = false; leftHindClaw2.addBox(-0.5F, -1.0F, 0.0F, 1, 1, 3); leftHindClaw2.setInitialRotationPoint(0.5F, -3.0F, 0.0F); leftHindClaw2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.09281276F, 0.0F, 0.99568355F)).transpose()); leftHindClaw2.setTextureSize(256, 128); parts.put(leftHindClaw2.boxName, leftHindClaw2); leftHindLeg3.addChild(leftHindClaw2); rightHindClaw1 = new MCAModelRenderer(this, "RightHindClaw1", 23, 43); rightHindClaw1.mirror = false; rightHindClaw1.addBox(-0.5F, -1.0F, 0.0F, 1, 1, 3); rightHindClaw1.setInitialRotationPoint(-0.5F, -3.0F, 0.0F); rightHindClaw1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, -0.09281317F, 0.0F, 0.99568355F)).transpose()); rightHindClaw1.setTextureSize(256, 128); parts.put(rightHindClaw1.boxName, rightHindClaw1); rightHindLeg3.addChild(rightHindClaw1); rightHindClaw2 = new MCAModelRenderer(this, "RightHindClaw2", 23, 43); rightHindClaw2.mirror = false; rightHindClaw2.addBox(-0.5F, -1.0F, 0.0F, 1, 1, 3); rightHindClaw2.setInitialRotationPoint(0.5F, -3.0F, 0.0F); rightHindClaw2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.09281276F, 0.0F, 0.99568355F)).transpose()); rightHindClaw2.setTextureSize(256, 128); parts.put(rightHindClaw2.boxName, rightHindClaw2); rightHindLeg3.addChild(rightHindClaw2); fin1 = new MCAModelRenderer(this, "Fin1", 182, 12); fin1.mirror = false; fin1.addBox(-5.0F, 0.0F, -8.0F, 5, 0, 7); fin1.setInitialRotationPoint(0.0F, 0.0F, -4.0F); fin1.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose()); fin1.setTextureSize(256, 128); parts.put(fin1.boxName, fin1); tail4.addChild(fin1); fin2 = new MCAModelRenderer(this, "Fin2", 182, 21); fin2.mirror = false; fin2.addBox(-0.5F, 0.0F, -8.0F, 5, 0, 7); fin2.setInitialRotationPoint(0.0F, 0.0F, -4.0F); fin2.setInitialRotationMatrix(new Matrix4f().set(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F)).transpose()); fin2.setTextureSize(256, 128); parts.put(fin2.boxName, fin2); tail4.addChild(fin2); } @Override public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { EntityRowarn entity = (EntityRowarn) par1Entity; AnimationHandler.performAnimationInModel(parts, entity); // Render every non-child part neck1.render(par7); torso1.render(par7); tail1.render(par7); leftHindLeg1.render(par7); rightHindLeg1.render(par7); leftFrontLeg.render(par7); rightFrontLeg.render(par7); } @Override public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { EntityRowarn entityRowarn = (EntityRowarn) par1EntityLivingBase; if (par2 != 0 && par3 != 0) { entityRowarn.getAnimationHandler().activateAnimation("walking", 0); } } @Override public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {} public MCAModelRenderer getModelRendererFromName(String name) { return parts.get(name); } } Entity Code package common.zeroquest.entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import common.zeroquest.client.mca.animations.AnimationHandlerRowarn; import common.zeroquest.client.mca.libary.IMCAnimatedEntity; import common.zeroquest.client.mca.libary.animation.AnimationHandler; public class EntityRowarn extends EntityAnimal implements IMCAnimatedEntity { protected AnimationHandler animHandler = new AnimationHandlerRowarn(this); private float field_175482_b; private final float field_175484_c; private float field_175483_bk; private float field_175485_bl; private float field_175486_bm; private int field_175479_bo; private boolean field_175480_bp; private EntityAIWander wander; private static final String __OBFID = "CL_00002213"; public EntityRowarn(World worldIn) { super(worldIn); this.experienceValue = 10; this.setSize(1F, 1F); EntityAIMoveTowardsRestriction entityaimovetowardsrestriction; this.tasks.addTask(5, entityaimovetowardsrestriction = new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(7, this.wander = new EntityAIWander(this, 1.0D, 80)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityRowarn.class, 12.0F, 0.01F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.wander.setMutexBits(3); entityaimovetowardsrestriction.setMutexBits(3); this.field_175484_c = this.field_175482_b = this.rand.nextFloat(); } @Override public AnimationHandler getAnimationHandler() { return animHandler; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0D); } @Override public EntityAgeable createChild(EntityAgeable ageable) { // TODO Auto-generated method stub return null; } } Rowarn Animation Handler package common.zeroquest.client.mca.animations; import java.util.HashMap; import common.zeroquest.client.mca.libary.IMCAnimatedEntity; import common.zeroquest.client.mca.libary.animation.AnimationHandler; import common.zeroquest.client.mca.libary.animation.Channel; public class AnimationHandlerRowarn extends AnimationHandler { /** Map with all the animations. */ public static HashMap<String, Channel> animChannels = new HashMap<String, Channel>(); static { animChannels.put("swimming", new ChannelSwimming("swimming", 30.0F, 40, Channel.LINEAR)); animChannels.put("leapinto", new ChannelLeapinto("leapinto", 20.0F, 50, Channel.LINEAR)); animChannels.put("walking", new ChannelWalking("walking", 15.0F, 20, Channel.LINEAR)); } public AnimationHandlerRowarn(IMCAnimatedEntity entity) { super(entity); } @Override public void activateAnimation(String name, float startingFrame) { super.activateAnimation(animChannels, name, startingFrame); } @Override public void stopAnimation(String name) { super.stopAnimation(animChannels, name); } @Override public void fireAnimationEventClientSide(Channel anim, float prevFrame, float frame) {} @Override public void fireAnimationEventServerSide(Channel anim, float prevFrame, float frame) {} } Main Animation Handler package common.zeroquest.client.mca.libary.animation; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import net.minecraft.entity.Entity; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import common.zeroquest.client.mca.MCAModelRenderer; import common.zeroquest.client.mca.libary.IMCAnimatedEntity; import common.zeroquest.client.mca.libary.math.Quaternion; import common.zeroquest.client.mca.libary.math.Vector3f; public abstract class AnimationHandler { public static AnimTickHandler animTickHandler; /** Owner of this handler. */ private final IMCAnimatedEntity animatedEntity; /** List of all the activate animations of this Entity. */ public ArrayList<Channel> animCurrentChannels = new ArrayList(); /** Previous time of every active animation. */ public HashMap<String, Long> animPrevTime = new HashMap<String, Long>(); /** Current frame of every active animation. */ public HashMap<String, Float> animCurrentFrame = new HashMap<String, Float>(); /** * Contains the unique names of the events that have been already fired * during each animation. It becomes empty at the end of every animation. * The key is the animation name and the value is the list of already-called * events. */ private final HashMap<String, ArrayList<String>> animationEvents = new HashMap<String, ArrayList<String>>(); public AnimationHandler(IMCAnimatedEntity entity) { if (animTickHandler == null) { animTickHandler = new AnimTickHandler(); } animTickHandler.addEntity(entity); animatedEntity = entity; } public IMCAnimatedEntity getEntity() { return animatedEntity; } public void activateAnimation(HashMap<String, Channel> animChannels, String name, float startingFrame) { if (animChannels.get(name) != null) { Channel selectedChannel = animChannels.get(name); int indexToRemove = animCurrentChannels.indexOf(selectedChannel); if (indexToRemove != -1) { animCurrentChannels.remove(indexToRemove); } animCurrentChannels.add(selectedChannel); animPrevTime.put(name, System.nanoTime()); animCurrentFrame.put(name, startingFrame); if (animationEvents.get(name) == null) { animationEvents.put(name, new ArrayList<String>()); } } else { System.out.println("The animation called " + name + " doesn't exist!"); } } public abstract void activateAnimation(String name, float startingFrame); public void stopAnimation(HashMap<String, Channel> animChannels, String name) { Channel selectedChannel = animChannels.get(name); if (selectedChannel != null) { int indexToRemove = animCurrentChannels.indexOf(selectedChannel); if (indexToRemove != -1) { animCurrentChannels.remove(indexToRemove); animPrevTime.remove(name); animCurrentFrame.remove(name); animationEvents.get(name).clear(); } } else { System.out.println("The animation called " + name + " doesn't exist!"); } } public abstract void stopAnimation(String name); public void animationsUpdate() { for (Iterator<Channel> it = animCurrentChannels.iterator(); it.hasNext() { Channel anim = it.next(); float prevFrame = animCurrentFrame.get(anim.name); boolean animStatus = updateAnimation(animatedEntity, anim, animPrevTime, animCurrentFrame); if (animCurrentFrame.get(anim.name) != null) { fireAnimationEvent(anim, prevFrame, animCurrentFrame.get(anim.name)); } if (!animStatus) { it.remove(); animPrevTime.remove(anim.name); animCurrentFrame.remove(anim.name); animationEvents.get(anim.name).clear(); } } } public boolean isAnimationActive(String name) { boolean animAlreadyUsed = false; for (Channel anim : animatedEntity.getAnimationHandler().animCurrentChannels) { if (anim.name.equals(name)) { animAlreadyUsed = true; break; } } return animAlreadyUsed; } private void fireAnimationEvent(Channel anim, float prevFrame, float frame) { if (isWorldRemote(animatedEntity)) { fireAnimationEventClientSide(anim, prevFrame, frame); } else { fireAnimationEventServerSide(anim, prevFrame, frame); } } @SideOnly(Side.CLIENT) public abstract void fireAnimationEventClientSide(Channel anim, float prevFrame, float frame); public abstract void fireAnimationEventServerSide(Channel anim, float prevFrame, float frame); /** Check if the animation event has already been called. */ public boolean alreadyCalledEvent(String animName, String eventName) { if (animationEvents.get(animName) == null) { System.out.println("Cannot check for event " + eventName + "! Animation " + animName + "does not exist or is not active."); return true; } return animationEvents.get(animName).contains(eventName); } /** Set the animation event as "called", so it won't be fired again. */ public void setCalledEvent(String animName, String eventName) { if (animationEvents.get(animName) != null) { animationEvents.get(animName).add(eventName); } else { System.out.println("Cannot set event " + eventName + "! Animation " + animName + "does not exist or is not active."); } } /** Update animation values. Return false if the animation should stop. */ public static boolean updateAnimation(IMCAnimatedEntity entity, Channel channel, HashMap<String, Long> prevTimeAnim, HashMap<String, Float> prevFrameAnim) { if (FMLCommonHandler.instance().getEffectiveSide().isServer() || (FMLCommonHandler.instance().getEffectiveSide().isClient() && !isGamePaused())) { if (!(channel.mode == Channel.CUSTOM)) { long prevTime = prevTimeAnim.get(channel.name); float prevFrame = prevFrameAnim.get(channel.name); long currentTime = System.nanoTime(); double deltaTime = (currentTime - prevTime) / 1000000000.0; float numberOfSkippedFrames = (float) (deltaTime * channel.fps); float currentFrame = prevFrame + numberOfSkippedFrames; if (currentFrame < channel.totalFrames - 1) // -1 as the first // frame mustn't be // "executed" as it // is the starting // situation { prevTimeAnim.put(channel.name, currentTime); prevFrameAnim.put(channel.name, currentFrame); return true; } else { if (channel.mode == Channel.LOOP) { prevTimeAnim.put(channel.name, currentTime); prevFrameAnim.put(channel.name, 0F); return true; } return false; } } else { return true; } } else { long currentTime = System.nanoTime(); prevTimeAnim.put(channel.name, currentTime); return true; } } @SideOnly(Side.CLIENT) private static boolean isGamePaused() { net.minecraft.client.Minecraft MC = net.minecraft.client.Minecraft.getMinecraft(); return MC.isSingleplayer() && MC.currentScreen != null && MC.currentScreen.doesGuiPauseGame() && !MC.getIntegratedServer().getPublic(); } /** * Apply animations if running or apply initial values. Must be called only * by the model class. */ @SideOnly(Side.CLIENT) public static void performAnimationInModel(HashMap<String, MCAModelRenderer> parts, IMCAnimatedEntity entity) { for (Map.Entry<String, MCAModelRenderer> entry : parts.entrySet()) { String boxName = entry.getKey(); MCAModelRenderer box = entry.getValue(); boolean anyRotationApplied = false; boolean anyTranslationApplied = false; boolean anyCustomAnimationRunning = false; for (Channel channel : entity.getAnimationHandler().animCurrentChannels) { if (channel.mode != Channel.CUSTOM) { float currentFrame = entity.getAnimationHandler().animCurrentFrame.get(channel.name); // Rotations KeyFrame prevRotationKeyFrame = channel.getPreviousRotationKeyFrameForBox(boxName, entity.getAnimationHandler().animCurrentFrame.get(channel.name)); int prevRotationKeyFramePosition = prevRotationKeyFrame != null ? channel.getKeyFramePosition(prevRotationKeyFrame) : 0; KeyFrame nextRotationKeyFrame = channel.getNextRotationKeyFrameForBox(boxName, entity.getAnimationHandler().animCurrentFrame.get(channel.name)); int nextRotationKeyFramePosition = nextRotationKeyFrame != null ? channel.getKeyFramePosition(nextRotationKeyFrame) : 0; float SLERPProgress = (currentFrame - prevRotationKeyFramePosition) / (nextRotationKeyFramePosition - prevRotationKeyFramePosition); if (SLERPProgress > 1F || SLERPProgress < 0F) { SLERPProgress = 1F; } if (prevRotationKeyFramePosition == 0 && prevRotationKeyFrame == null && !(nextRotationKeyFramePosition == 0)) { Quaternion currentQuat = new Quaternion(); currentQuat.slerp(parts.get(boxName).getDefaultRotationAsQuaternion(), nextRotationKeyFrame.modelRenderersRotations.get(boxName), SLERPProgress); box.getRotationMatrix().set(currentQuat).transpose(); anyRotationApplied = true; } else if (prevRotationKeyFramePosition == 0 && prevRotationKeyFrame != null && !(nextRotationKeyFramePosition == 0)) { Quaternion currentQuat = new Quaternion(); currentQuat.slerp(prevRotationKeyFrame.modelRenderersRotations.get(boxName), nextRotationKeyFrame.modelRenderersRotations.get(boxName), SLERPProgress); box.getRotationMatrix().set(currentQuat).transpose(); anyRotationApplied = true; } else if (!(prevRotationKeyFramePosition == 0) && !(nextRotationKeyFramePosition == 0)) { Quaternion currentQuat = new Quaternion(); currentQuat.slerp(prevRotationKeyFrame.modelRenderersRotations.get(boxName), nextRotationKeyFrame.modelRenderersRotations.get(boxName), SLERPProgress); box.getRotationMatrix().set(currentQuat).transpose(); anyRotationApplied = true; } // Translations KeyFrame prevTranslationKeyFrame = channel.getPreviousTranslationKeyFrameForBox(boxName, entity.getAnimationHandler().animCurrentFrame.get(channel.name)); int prevTranslationsKeyFramePosition = prevTranslationKeyFrame != null ? channel.getKeyFramePosition(prevTranslationKeyFrame) : 0; KeyFrame nextTranslationKeyFrame = channel.getNextTranslationKeyFrameForBox(boxName, entity.getAnimationHandler().animCurrentFrame.get(channel.name)); int nextTranslationsKeyFramePosition = nextTranslationKeyFrame != null ? channel.getKeyFramePosition(nextTranslationKeyFrame) : 0; float LERPProgress = (currentFrame - prevTranslationsKeyFramePosition) / (nextTranslationsKeyFramePosition - prevTranslationsKeyFramePosition); if (LERPProgress > 1F) { LERPProgress = 1F; } if (prevTranslationsKeyFramePosition == 0 && prevTranslationKeyFrame == null && !(nextTranslationsKeyFramePosition == 0)) { Vector3f startPosition = parts.get(boxName).getPositionAsVector(); Vector3f endPosition = nextTranslationKeyFrame.modelRenderersTranslations.get(boxName); Vector3f currentPosition = new Vector3f(startPosition); currentPosition.interpolate(endPosition, LERPProgress); box.setRotationPoint(currentPosition.x, currentPosition.y, currentPosition.z); anyTranslationApplied = true; } else if (prevTranslationsKeyFramePosition == 0 && prevTranslationKeyFrame != null && !(nextTranslationsKeyFramePosition == 0)) { Vector3f startPosition = prevTranslationKeyFrame.modelRenderersTranslations.get(boxName); Vector3f endPosition = nextTranslationKeyFrame.modelRenderersTranslations.get(boxName); Vector3f currentPosition = new Vector3f(startPosition); currentPosition.interpolate(endPosition, LERPProgress); box.setRotationPoint(currentPosition.x, currentPosition.y, currentPosition.z); } else if (!(prevTranslationsKeyFramePosition == 0) && !(nextTranslationsKeyFramePosition == 0)) { Vector3f startPosition = prevTranslationKeyFrame.modelRenderersTranslations.get(boxName); Vector3f endPosition = nextTranslationKeyFrame.modelRenderersTranslations.get(boxName); Vector3f currentPosition = new Vector3f(startPosition); currentPosition.interpolate(endPosition, LERPProgress); box.setRotationPoint(currentPosition.x, currentPosition.y, currentPosition.z); anyTranslationApplied = true; } } else { anyCustomAnimationRunning = true; ((CustomChannel) channel).update(parts, entity); } } // Set the initial values for each box if necessary if (!anyRotationApplied && !anyCustomAnimationRunning) { box.resetRotationMatrix(); } if (!anyTranslationApplied && !anyCustomAnimationRunning) { box.resetRotationPoint(); } } } public static boolean isWorldRemote(IMCAnimatedEntity animatedEntity) { return ((Entity) animatedEntity).worldObj.isRemote; } }
-
[1.8]Help with entity that swims like the Guardian
NovaViper replied to NovaViper's topic in Modder Support
I want it to get into the water when it detects it's attacker in the water and get out of the water and stay near it during the day, then go into the water at night. I have been at the zombie's entity coding, specifically the ones that have it move through the villages -
[1.8]Help with entity that swims like the Guardian
NovaViper replied to NovaViper's topic in Modder Support
Hey, how do I make the entity actually walk around first and only when it hits the water it swims like the Guardian? -
[1.8]Help with entity that swims like the Guardian
NovaViper replied to NovaViper's topic in Modder Support
Started happening ever since I updated the 1412 build of 1.8, which was 2 days ago -
[1.8]Help with entity that swims like the Guardian
NovaViper replied to NovaViper's topic in Modder Support
Also I've been getting this crash log whenver minecraft loads up [23:26:04] [main/INFO] [GradleStart]: Extra: [] [23:26:05] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/NovaPC/.gradle/caches/minecraft/assets, --assetIndex, 1.8, --accessToken, {REDACTED}, --version, 1.8, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [23:26:05] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [23:26:05] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [23:26:05] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [23:26:05] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker [23:26:05] [main/INFO] [FML]: Forge Mod Loader version 8.99.14.1416 for Minecraft 1.8 loading [23:26:05] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_25, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre1.8.0_25 [23:26:05] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [23:26:05] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [23:26:05] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin [23:26:05] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [23:26:05] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [23:26:05] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [23:26:05] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [23:26:05] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [23:26:05] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [23:26:05] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [23:26:06] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [23:26:10] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [23:26:10] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [23:26:10] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [23:26:11] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [23:26:11] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker [23:26:11] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker [23:26:11] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [23:26:15] [Client thread/INFO]: Setting user: Player901 [23:26:22] [Client thread/INFO]: LWJGL Version: 2.9.1 [23:26:23] [Client thread/INFO] [FML]: Could not load splash.properties, will create a default one [23:26:24] [Client thread/INFO] [sTDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:233]: ---- Minecraft Crash Report ---- // Shall we play a game? Time: 5/25/15 11:26 PM Description: Loading screen debug info This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.8 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_25, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 775727752 bytes (739 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: Loaded coremods (and transformers): GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.1.11156 Compatibility Profile Context' Renderer: 'AMD Radeon(TM) HD 6620G' But the game still comes up, should I be concerned about this? -
[1.8]Help with entity that swims like the Guardian
NovaViper replied to NovaViper's topic in Modder Support
That helped me a good bit.. but I'm still trying to see what pieces of code I don't need, since the guardian has parameters for the elder, I want to remove those and only leave the nagavitor switching codes package common.zeroquest.entity; import com.google.common.base.Predicate; import java.util.Iterator; import java.util.List; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.ai.EntityLookHelper; import net.minecraft.entity.ai.EntityMoveHelper; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntitySquid; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityFishHook; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemFishFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.S2BPacketChangeGameState; import net.minecraft.pathfinding.PathNavigate; import net.minecraft.pathfinding.PathNavigateSwimmer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.util.WeightedRandom; import net.minecraft.util.WeightedRandomFishable; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityRowarn extends EntityAnimal { private float field_175482_b; private float field_175484_c; private float field_175483_bk; private float field_175485_bl; private float field_175486_bm; private EntityLivingBase targetedEntity; private int field_175479_bo; private boolean field_175480_bp; private EntityAIWander wander; private static final String __OBFID = "CL_00002213"; public EntityRowarn(World worldIn) { super(worldIn); this.experienceValue = 10; this.setSize(0.85F, 0.85F); EntityAIMoveTowardsRestriction entityaimovetowardsrestriction; this.tasks.addTask(5, entityaimovetowardsrestriction = new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(7, this.wander = new EntityAIWander(this, 1.0D, 80)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityRowarn.class, 12.0F, 0.01F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.wander.setMutexBits(3); entityaimovetowardsrestriction.setMutexBits(3); this.moveHelper = new EntityRowarn.GuardianMoveHelper(); this.field_175484_c = this.field_175482_b = this.rand.nextFloat(); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0D); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); } /** * Returns new PathNavigateGround instance */ protected PathNavigate getNewNavigator(World worldIn) { return new PathNavigateSwimmer(this, worldIn); } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(16, Integer.valueOf(0)); } /** * Returns true if given flag is set */ private boolean isSyncedFlagSet(int flagId) { return (this.dataWatcher.getWatchableObjectInt(16) & flagId) != 0; } /** * Sets a flag state "on/off" on both sides (client/server) by using DataWatcher * * @param flagId flag byte */ private void setSyncedFlag(int flagId, boolean state) { int j = this.dataWatcher.getWatchableObjectInt(16); if (state) { this.dataWatcher.updateObject(16, Integer.valueOf(j | flagId)); } else { this.dataWatcher.updateObject(16, Integer.valueOf(j & ~flagId)); } } public boolean func_175472_n() { return this.isSyncedFlagSet(2); } private void func_175476_l(boolean p_175476_1_) { this.setSyncedFlag(2, p_175476_1_); } private void func_175463_b(int p_175463_1_) { this.dataWatcher.updateObject(17, Integer.valueOf(p_175463_1_)); } public boolean hasTargetedEntity() { return this.dataWatcher.getWatchableObjectInt(17) != 0; } public EntityLivingBase getTargetedEntity() { if (!this.hasTargetedEntity()) { return null; } else if (this.worldObj.isRemote) { if (this.targetedEntity != null) { return this.targetedEntity; } else { Entity entity = this.worldObj.getEntityByID(this.dataWatcher.getWatchableObjectInt(17)); if (entity instanceof EntityLivingBase) { this.targetedEntity = (EntityLivingBase)entity; return this.targetedEntity; } else { return null; } } } else { return this.getAttackTarget(); } } public void func_145781_i(int p_145781_1_) { super.func_145781_i(p_145781_1_); if (p_145781_1_ == 16) { this.field_175479_bo = 0; this.targetedEntity = null; } } /** * Get number of ticks, at least during which the living entity will be silent. */ public int getTalkInterval() { return 160; } /** * Returns the sound this mob makes while it's alive. */ protected String getLivingSound() { return !this.isInWater() ? "mob.guardian.land.idle" : "mob.guardian.idle"; } /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return !this.isInWater() ? "mob.guardian.land.hit" : "mob.guardian.hit"; } /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return !this.isInWater() ? "mob.guardian.land.death" :"mob.guardian.death"; } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } public float getEyeHeight() { return this.height * 0.5F; } public float getBlockPathWeight(BlockPos pos) { return this.worldObj.getBlockState(pos).getBlock().getMaterial() == Material.water ? 10.0F + this.worldObj.getLightBrightness(pos) - 0.5F : super.getBlockPathWeight(pos); } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { if (this.worldObj.isRemote) { this.field_175484_c = this.field_175482_b; if (!this.isInWater()) { this.field_175483_bk = 2.0F; if (this.motionY > 0.0D && this.field_175480_bp && !this.isSilent()) { this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.guardian.flop", 1.0F, 1.0F, false); } this.field_175480_bp = this.motionY < 0.0D && this.worldObj.isBlockNormalCube((new BlockPos(this)).down(), false); } else if (this.func_175472_n()) { if (this.field_175483_bk < 0.5F) { this.field_175483_bk = 4.0F; } else { this.field_175483_bk += (0.5F - this.field_175483_bk) * 0.1F; } } else { this.field_175483_bk += (0.125F - this.field_175483_bk) * 0.2F; } this.field_175482_b += this.field_175483_bk; this.field_175486_bm = this.field_175485_bl; if (!this.isInWater()) { this.field_175485_bl = this.rand.nextFloat(); } else if (this.func_175472_n()) { this.field_175485_bl += (0.0F - this.field_175485_bl) * 0.25F; } else { this.field_175485_bl += (1.0F - this.field_175485_bl) * 0.06F; } if (this.func_175472_n() && this.isInWater()) { Vec3 vec3 = this.getLook(0.0F); for (int i = 0; i < 2; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width - vec3.xCoord * 1.5D, this.posY + this.rand.nextDouble() * (double)this.height - vec3.yCoord * 1.5D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width - vec3.zCoord * 1.5D, 0.0D, 0.0D, 0.0D, new int[0]); } } if (this.hasTargetedEntity()) { EntityLivingBase entitylivingbase = this.getTargetedEntity(); if (entitylivingbase != null) { this.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F); this.getLookHelper().onUpdateLook(); double d5 = (double)this.func_175477_p(0.0F); double d0 = entitylivingbase.posX - this.posX; double d1 = entitylivingbase.posY + (double)(entitylivingbase.height * 0.5F) - (this.posY + (double)this.getEyeHeight()); double d2 = entitylivingbase.posZ - this.posZ; double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); d0 /= d3; d1 /= d3; d2 /= d3; double d4 = this.rand.nextDouble(); while (d4 < d3) { d4 += 1.8D - d5 + this.rand.nextDouble() * (1.7D - d5); this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX + d0 * d4, this.posY + d1 * d4 + (double)this.getEyeHeight(), this.posZ + d2 * d4, 0.0D, 0.0D, 0.0D, new int[0]); } } } } if (this.inWater) { this.setAir(300); } else if (this.onGround) { this.wander.startExecuting(); } if (this.hasTargetedEntity()) { this.rotationYaw = this.rotationYawHead; } super.onLivingUpdate(); } @SideOnly(Side.CLIENT) public float func_175471_a(float p_175471_1_) { return this.field_175484_c + (this.field_175482_b - this.field_175484_c) * p_175471_1_; } @SideOnly(Side.CLIENT) public float func_175469_o(float p_175469_1_) { return this.field_175486_bm + (this.field_175485_bl - this.field_175486_bm) * p_175469_1_; } public float func_175477_p(float p_175477_1_) { return ((float)this.field_175479_bo + p_175477_1_); } protected void updateAITasks() { super.updateAITasks(); if (!this.hasHome()) { this.setHomePosAndDistance(new BlockPos(this), 16); } } /** * Drop 0-2 items of this living's type */ protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { int j = this.rand.nextInt(3) + this.rand.nextInt(p_70628_2_ + 1); if (j > 0) { this.entityDropItem(new ItemStack(Items.prismarine_shard, j, 0), 1.0F); } if (this.rand.nextInt(3 + p_70628_2_) > 1) { this.entityDropItem(new ItemStack(Items.fish, 1, ItemFishFood.FishType.COD.getMetadata()), 1.0F); } else if (this.rand.nextInt(3 + p_70628_2_) > 1) { this.entityDropItem(new ItemStack(Items.prismarine_crystals, 1, 0), 1.0F); } } /** * Whether or not the current entity is in lava */ public boolean handleLavaMovement() { return this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this) && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty(); } /** * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently * use in wolves. */ public int getVerticalFaceSpeed() { return 180; } /** * Moves the entity based on the specified heading. Args: strafe, forward */ public void moveEntityWithHeading(float strafe, float forward) { if (this.isServerWorld()) { if (this.isInWater()) { this.moveFlying(strafe, forward, 0.1F); this.moveEntity(this.motionX, this.motionY, this.motionZ); this.motionX *= 0.8999999761581421D; this.motionY *= 0.8999999761581421D; this.motionZ *= 0.8999999761581421D; if (!this.func_175472_n() && this.getAttackTarget() == null) { this.motionY -= 0.005D; } } else { super.moveEntityWithHeading(strafe, forward); } } else { super.moveEntityWithHeading(strafe, forward); } } class GuardianMoveHelper extends EntityMoveHelper { private EntityRowarn entityGuardian = EntityRowarn.this; private static final String __OBFID = "CL_00002209"; public GuardianMoveHelper() { super(EntityRowarn.this); } public void onUpdateMoveHelper() { if (this.update && !this.entityGuardian.getNavigator().noPath()) { double d0 = this.posX - this.entityGuardian.posX; double d1 = this.posY - this.entityGuardian.posY; double d2 = this.posZ - this.entityGuardian.posZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; d3 = (double)MathHelper.sqrt_double(d3); d1 /= d3; float f = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; this.entityGuardian.rotationYaw = this.limitAngle(this.entityGuardian.rotationYaw, f, 30.0F); this.entityGuardian.renderYawOffset = this.entityGuardian.rotationYaw; float f1 = (float)(this.speed * this.entityGuardian.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); this.entityGuardian.setAIMoveSpeed(this.entityGuardian.getAIMoveSpeed() + (f1 - this.entityGuardian.getAIMoveSpeed()) * 0.125F); double d4 = Math.sin((double)(this.entityGuardian.ticksExisted + this.entityGuardian.getEntityId()) * 0.5D) * 0.05D; double d5 = Math.cos((double)(this.entityGuardian.rotationYaw * (float)Math.PI / 180.0F)); double d6 = Math.sin((double)(this.entityGuardian.rotationYaw * (float)Math.PI / 180.0F)); this.entityGuardian.motionX += d4 * d5; this.entityGuardian.motionZ += d4 * d6; d4 = Math.sin((double)(this.entityGuardian.ticksExisted + this.entityGuardian.getEntityId()) * 0.75D) * 0.05D; this.entityGuardian.motionY += d4 * (d6 + d5) * 0.25D; this.entityGuardian.motionY += (double)this.entityGuardian.getAIMoveSpeed() * d1 * 0.1D; EntityLookHelper entitylookhelper = this.entityGuardian.getLookHelper(); double d7 = this.entityGuardian.posX + d0 / d3 * 2.0D; double d8 = (double)this.entityGuardian.getEyeHeight() + this.entityGuardian.posY + d1 / d3 * 1.0D; double d9 = this.entityGuardian.posZ + d2 / d3 * 2.0D; double d10 = entitylookhelper.getLookPosX(); double d11 = entitylookhelper.getLookPosY(); double d12 = entitylookhelper.getLookPosZ(); if (!entitylookhelper.getIsLooking()) { d10 = d7; d11 = d8; d12 = d9; } this.entityGuardian.getLookHelper().setLookPosition(d10 + (d7 - d10) * 0.125D, d11 + (d8 - d11) * 0.125D, d12 + (d9 - d12) * 0.125D, 10.0F, 40.0F); this.entityGuardian.func_175476_l(true); } else { this.entityGuardian.setAIMoveSpeed(0.0F); this.entityGuardian.func_175476_l(false); } } } @Override public EntityAgeable createChild(EntityAgeable ageable) { // TODO Auto-generated method stub return null; } } -
[1.8]Help with entity that swims like the Guardian
NovaViper replied to NovaViper's topic in Modder Support
Ok, I started coping code from the Guardian and resulted with this package common.zeroquest.entity; import java.util.Iterator; import java.util.List; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.ai.EntityLookHelper; import net.minecraft.entity.ai.EntityMoveHelper; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntitySquid; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityFishHook; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemFishFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.S2BPacketChangeGameState; import net.minecraft.pathfinding.PathNavigate; import net.minecraft.pathfinding.PathNavigateSwimmer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.util.WeightedRandom; import net.minecraft.util.WeightedRandomFishable; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import com.google.common.base.Predicate; public class EntityRowarn extends EntityAnimal { private float field_175482_b; private float field_175484_c; private float field_175483_bk; private float field_175485_bl; private float field_175486_bm; private EntityLivingBase field_175478_bn; private int field_175479_bo; private boolean field_175480_bp; private EntityAIWander wander; private static final String __OBFID = "CL_00002213"; public EntityRowarn(World worldIn) { super(worldIn); this.experienceValue = 10; this.setSize(0.85F, 0.85F); this.tasks.addTask(4, new EntityRowarn.AIGuardianAttack()); EntityAIMoveTowardsRestriction entityaimovetowardsrestriction; this.tasks.addTask(5, entityaimovetowardsrestriction = new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(7, this.wander = new EntityAIWander(this, 1.0D, 80)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityRowarn.class, 12.0F, 0.01F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.wander.setMutexBits(3); entityaimovetowardsrestriction.setMutexBits(3); this.moveHelper = new EntityRowarn.GuardianMoveHelper(); this.field_175484_c = this.field_175482_b = this.rand.nextFloat(); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(30.0D); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ @Override public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); } @Override protected PathNavigate func_175447_b(World worldIn) { return new PathNavigateSwimmer(this, worldIn); } @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(16, Integer.valueOf(0)); this.dataWatcher.addObject(17, Integer.valueOf(0)); } private boolean func_175468_a(int p_175468_1_) { return (this.dataWatcher.getWatchableObjectInt(16) & p_175468_1_) != 0; } private void func_175473_a(int p_175473_1_, boolean p_175473_2_) { int j = this.dataWatcher.getWatchableObjectInt(16); if (p_175473_2_) { this.dataWatcher.updateObject(16, Integer.valueOf(j | p_175473_1_)); } else { this.dataWatcher.updateObject(16, Integer.valueOf(j & ~p_175473_1_)); } } public boolean func_175472_n() { return this.func_175468_a(2); } private void func_175476_l(boolean p_175476_1_) { this.func_175473_a(2, p_175476_1_); } @SideOnly(Side.CLIENT) public void func_175465_cm() { this.field_175486_bm = this.field_175485_bl = 1.0F; } private void func_175463_b(int p_175463_1_) { this.dataWatcher.updateObject(17, Integer.valueOf(p_175463_1_)); } public boolean func_175474_cn() { return this.dataWatcher.getWatchableObjectInt(17) != 0; } public EntityLivingBase getTargetedEntity() { if (!this.func_175474_cn()) { return null; } else if (this.worldObj.isRemote) { if (this.field_175478_bn != null) { return this.field_175478_bn; } else { Entity entity = this.worldObj.getEntityByID(this.dataWatcher.getWatchableObjectInt(17)); if (entity instanceof EntityLivingBase) { this.field_175478_bn = (EntityLivingBase) entity; return this.field_175478_bn; } else { return null; } } } else { return this.getAttackTarget(); } } @Override public void func_145781_i(int p_145781_1_) { super.func_145781_i(p_145781_1_); if (p_145781_1_ == 16) { this.field_175479_bo = 0; this.field_175478_bn = null; } } /** * Get number of ticks, at least during which the living entity will be * silent. */ @Override public int getTalkInterval() { return 160; } /** * Returns the sound this mob makes while it's alive. */ @Override protected String getLivingSound() { return !this.isInWater() ? "mob.guardian.land.idle" : "mob.guardian.idle"; } /** * Returns the sound this mob makes when it is hurt. */ @Override protected String getHurtSound() { return !this.isInWater() ? "mob.guardian.land.hit" : "mob.guardian.hit"; } /** * Returns the sound this mob makes on death. */ @Override protected String getDeathSound() { return !this.isInWater() ? "mob.guardian.land.death" : "mob.guardian.death"; } /** * returns if this entity triggers Block.onEntityWalking on the blocks they * walk on. used for spiders and wolves to prevent them from trampling crops */ @Override protected boolean canTriggerWalking() { return false; } @Override public float getEyeHeight() { return this.height * 0.5F; } @Override public float func_180484_a(BlockPos p_180484_1_) { return this.worldObj.getBlockState(p_180484_1_).getBlock().getMaterial() == Material.water ? 10.0F + this.worldObj.getLightBrightness(p_180484_1_) - 0.5F : super.func_180484_a(p_180484_1_); } /** * Called frequently so the entity can update its state every tick as * required. For example, zombies and skeletons use this to react to * sunlight and start to burn. */ @Override public void onLivingUpdate() { if (this.worldObj.isRemote) { this.field_175484_c = this.field_175482_b; if (!this.isInWater()) { this.field_175483_bk = 2.0F; if (this.motionY > 0.0D && this.field_175480_bp && !this.isSilent()) { this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.guardian.flop", 1.0F, 1.0F, false); } this.field_175480_bp = this.motionY < 0.0D && this.worldObj.isBlockNormalCube((new BlockPos(this)).down(), false); } else if (this.func_175472_n()) { if (this.field_175483_bk < 0.5F) { this.field_175483_bk = 4.0F; } else { this.field_175483_bk += (0.5F - this.field_175483_bk) * 0.1F; } } else { this.field_175483_bk += (0.125F - this.field_175483_bk) * 0.2F; } this.field_175482_b += this.field_175483_bk; this.field_175486_bm = this.field_175485_bl; if (!this.isInWater()) { this.field_175485_bl = this.rand.nextFloat(); } else if (this.func_175472_n()) { this.field_175485_bl += (0.0F - this.field_175485_bl) * 0.25F; } else { this.field_175485_bl += (1.0F - this.field_175485_bl) * 0.06F; } if (this.func_175472_n() && this.isInWater()) { Vec3 vec3 = this.getLook(0.0F); for (int i = 0; i < 2; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX + (this.rand.nextDouble() - 0.5D) * this.width - vec3.xCoord * 1.5D, this.posY + this.rand.nextDouble() * this.height - vec3.yCoord * 1.5D, this.posZ + (this.rand.nextDouble() - 0.5D) * this.width - vec3.zCoord * 1.5D, 0.0D, 0.0D, 0.0D, new int[0]); } } if (this.func_175474_cn()) { EntityLivingBase entitylivingbase = this.getTargetedEntity(); if (entitylivingbase != null) { this.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F); this.getLookHelper().onUpdateLook(); double d5 = 0.0F; double d0 = entitylivingbase.posX - this.posX; double d1 = entitylivingbase.posY + entitylivingbase.height * 0.5F - (this.posY + this.getEyeHeight()); double d2 = entitylivingbase.posZ - this.posZ; double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); d0 /= d3; d1 /= d3; d2 /= d3; double d4 = this.rand.nextDouble(); while (d4 < d3) { d4 += 1.8D - d5 + this.rand.nextDouble() * (1.7D - d5); this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX + d0 * d4, this.posY + d1 * d4 + this.getEyeHeight(), this.posZ + d2 * d4, 0.0D, 0.0D, 0.0D, new int[0]); } } } } if (this.inWater) { this.setAir(300); } else if (this.onGround) { this.motionY += 0.5D; this.motionX += (this.rand.nextFloat() * 2.0F - 1.0F) * 0.4F; this.motionZ += (this.rand.nextFloat() * 2.0F - 1.0F) * 0.4F; this.rotationYaw = this.rand.nextFloat() * 360.0F; this.onGround = false; this.isAirBorne = true; } if (this.func_175474_cn()) { this.rotationYaw = this.rotationYawHead; } super.onLivingUpdate(); } @SideOnly(Side.CLIENT) public float func_175471_a(float p_175471_1_) { return this.field_175484_c + (this.field_175482_b - this.field_175484_c) * p_175471_1_; } @SideOnly(Side.CLIENT) public float func_175469_o(float p_175469_1_) { return this.field_175486_bm + (this.field_175485_bl - this.field_175486_bm) * p_175469_1_; } @Override protected void updateAITasks() { super.updateAITasks(); if (!this.hasHome()) { this.func_175449_a(new BlockPos(this), 16); } } /** * Drop 0-2 items of this living's type */ @Override protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { int j = this.rand.nextInt(3) + this.rand.nextInt(p_70628_2_ + 1); if (j > 0) { this.entityDropItem(new ItemStack(Items.prismarine_shard, j, 0), 1.0F); } if (this.rand.nextInt(3 + p_70628_2_) > 1) { this.entityDropItem(new ItemStack(Items.fish, 1, ItemFishFood.FishType.COD.getMetadata()), 1.0F); } else if (this.rand.nextInt(3 + p_70628_2_) > 1) { this.entityDropItem(new ItemStack(Items.prismarine_crystals, 1, 0), 1.0F); } } /** * Makes entity wear random armor based on difficulty */ @Override protected void addRandomArmor() { ItemStack itemstack = ((WeightedRandomFishable) WeightedRandom.getRandomItem(this.rand, EntityFishHook.func_174855_j())).getItemStack(this.rand); this.entityDropItem(itemstack, 1.0F); } /** * Checks to make sure the light is not too bright where the mob is spawning */ protected boolean isValidLightLevel() { return true; } /** * Whether or not the current entity is in lava */ @Override public boolean handleLavaMovement() { return this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this) && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty(); } /** * Checks if the entity's current position is a valid location to spawn this * entity. */ @Override public boolean getCanSpawnHere() { return (this.rand.nextInt(20) == 0 || !this.worldObj.canBlockSeeSky(new BlockPos(this))) && super.getCanSpawnHere(); } /** * Called when the entity is attacked. */ @Override public boolean attackEntityFrom(DamageSource source, float amount) { if (!this.func_175472_n() && !source.isMagicDamage() && source.getSourceOfDamage() instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase) source.getSourceOfDamage(); if (!source.isExplosion()) { entitylivingbase.attackEntityFrom(DamageSource.causeThornsDamage(this), 2.0F); entitylivingbase.playSound("damage.thorns", 0.5F, 1.0F); } } this.wander.func_179480_f(); return super.attackEntityFrom(source, amount); } /** * The speed it takes to move the entityliving's rotationPitch through the * faceEntity method. This is only currently use in wolves. */ @Override public int getVerticalFaceSpeed() { return 180; } /** * Moves the entity based on the specified heading. Args: strafe, forward */ @Override public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) { if (this.isServerWorld()) { if (this.isInWater()) { this.moveFlying(p_70612_1_, p_70612_2_, 0.1F); this.moveEntity(this.motionX, this.motionY, this.motionZ); this.motionX *= 0.8999999761581421D; this.motionY *= 0.8999999761581421D; this.motionZ *= 0.8999999761581421D; if (!this.func_175472_n() && this.getAttackTarget() == null) { this.motionY -= 0.005D; } } else { super.moveEntityWithHeading(p_70612_1_, p_70612_2_); } } else { super.moveEntityWithHeading(p_70612_1_, p_70612_2_); } } class AIGuardianAttack extends EntityAIBase { private final EntityRowarn field_179456_a = EntityRowarn.this; private int field_179455_b; private static final String __OBFID = "CL_00002211"; public AIGuardianAttack() { this.setMutexBits(3); } /** * Returns whether the EntityAIBase should begin execution. */ @Override public boolean shouldExecute() { EntityLivingBase entitylivingbase = this.field_179456_a.getAttackTarget(); return entitylivingbase != null && entitylivingbase.isEntityAlive(); } /** * Returns whether an in-progress EntityAIBase should continue executing */ @Override public boolean continueExecuting() { return super.continueExecuting() && this.field_179456_a.getDistanceSqToEntity(this.field_179456_a.getAttackTarget()) > 9.0D; } /** * Execute a one shot task or start executing a continuous task */ @Override public void startExecuting() { this.field_179455_b = -10; this.field_179456_a.getNavigator().clearPathEntity(); this.field_179456_a.getLookHelper().setLookPositionWithEntity(this.field_179456_a.getAttackTarget(), 90.0F, 90.0F); this.field_179456_a.isAirBorne = true; } /** * Resets the task */ @Override public void resetTask() { this.field_179456_a.func_175463_b(0); this.field_179456_a.setAttackTarget((EntityLivingBase) null); this.field_179456_a.wander.func_179480_f(); } /** * Updates the task */ @Override public void updateTask() { EntityLivingBase entitylivingbase = this.field_179456_a.getAttackTarget(); this.field_179456_a.getNavigator().clearPathEntity(); this.field_179456_a.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F); if (!this.field_179456_a.canEntityBeSeen(entitylivingbase)) { this.field_179456_a.setAttackTarget((EntityLivingBase) null); } else { ++this.field_179455_b; if (this.field_179455_b == 0) { this.field_179456_a.func_175463_b(this.field_179456_a.getAttackTarget().getEntityId()); this.field_179456_a.worldObj.setEntityState(this.field_179456_a, (byte) 21); } else if (this.field_179455_b >= 60 && this.field_179455_b % 20 == 0) { ; } super.updateTask(); } } } class GuardianMoveHelper extends EntityMoveHelper { private final EntityRowarn field_179930_g = EntityRowarn.this; private static final String __OBFID = "CL_00002209"; public GuardianMoveHelper() { super(EntityRowarn.this); } @Override public void onUpdateMoveHelper() { if (this.update && !this.field_179930_g.getNavigator().noPath()) { double d0 = this.posX - this.field_179930_g.posX; double d1 = this.posY - this.field_179930_g.posY; double d2 = this.posZ - this.field_179930_g.posZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; d3 = MathHelper.sqrt_double(d3); d1 /= d3; float f = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; this.field_179930_g.rotationYaw = this.limitAngle(this.field_179930_g.rotationYaw, f, 30.0F); this.field_179930_g.renderYawOffset = this.field_179930_g.rotationYaw; float f1 = (float) (this.speed * this.field_179930_g.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); this.field_179930_g.setAIMoveSpeed(this.field_179930_g.getAIMoveSpeed() + (f1 - this.field_179930_g.getAIMoveSpeed()) * 0.125F); double d4 = Math.sin((this.field_179930_g.ticksExisted + this.field_179930_g.getEntityId()) * 0.5D) * 0.05D; double d5 = Math.cos(this.field_179930_g.rotationYaw * (float) Math.PI / 180.0F); double d6 = Math.sin(this.field_179930_g.rotationYaw * (float) Math.PI / 180.0F); this.field_179930_g.motionX += d4 * d5; this.field_179930_g.motionZ += d4 * d6; d4 = Math.sin((this.field_179930_g.ticksExisted + this.field_179930_g.getEntityId()) * 0.75D) * 0.05D; this.field_179930_g.motionY += d4 * (d6 + d5) * 0.25D; this.field_179930_g.motionY += this.field_179930_g.getAIMoveSpeed() * d1 * 0.1D; EntityLookHelper entitylookhelper = this.field_179930_g.getLookHelper(); double d7 = this.field_179930_g.posX + d0 / d3 * 2.0D; double d8 = this.field_179930_g.getEyeHeight() + this.field_179930_g.posY + d1 / d3 * 1.0D; double d9 = this.field_179930_g.posZ + d2 / d3 * 2.0D; double d10 = entitylookhelper.func_180423_e(); double d11 = entitylookhelper.func_180422_f(); double d12 = entitylookhelper.func_180421_g(); if (!entitylookhelper.func_180424_b()) { d10 = d7; d11 = d8; d12 = d9; } this.field_179930_g.getLookHelper().setLookPosition(d10 + (d7 - d10) * 0.125D, d11 + (d8 - d11) * 0.125D, d12 + (d9 - d12) * 0.125D, 10.0F, 40.0F); this.field_179930_g.func_175476_l(true); } else { this.field_179930_g.setAIMoveSpeed(0.0F); this.field_179930_g.func_175476_l(false); } } } @Override public EntityAgeable createChild(EntityAgeable ageable) { // TODO Auto-generated method stub return null; } } -
[1.8]Help with entity that swims like the Guardian
NovaViper replied to NovaViper's topic in Modder Support
Well.. at first, I entirely copied the Guardian's code into the model, then I completely cleared it out since I was still working on the model for the entity at the time, so this is what I have so far package common.zeroquest.entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.pathfinding.PathNavigateGround; import net.minecraft.world.World; import com.google.common.base.Predicate; public class EntityRowarn extends EntityAnimal { public EntityRowarn(World worldIn) { super(worldIn); this.setSize(0.6F, 2.6F); this.stepHeight = 1; ((PathNavigateGround) this.getNavigator()).func_179688_b(true); } @Override public EntityAgeable createChild(EntityAgeable ageable) { // TODO Auto-generated method stub return null; } } -
[1.8]Help with entity that swims like the Guardian
NovaViper replied to NovaViper's topic in Modder Support
Anyone? -
I'm trying to create an entity that moves around on land like a normal entity, but also when it enters water, it swims smoothly in the water like the Guardian and have it attack entities on land and water. How am I to achieve this?
-
[1.8][SOLVED]Help with custom block item icon
NovaViper replied to NovaViper's topic in Modder Support
Woop, nevermind, I got it right! Thanks for the help -
[1.8][SOLVED]Help with custom block item icon
NovaViper replied to NovaViper's topic in Modder Support
Nvm! I fixed it and also, I want it to sit upward instead of on the side, like on the pictures posted already -
[1.8][SOLVED]Help with custom block item icon
NovaViper replied to NovaViper's topic in Modder Support
That works, but the bottom parts don't render the parts like the top http://i1319.photobucket.com/albums/t661/Nova_Leary/2015-05-23_19.22.04_zpsqnrztycu.png[/img] json file { "textures": { "TablePart": "zero_quest:blocks/nileTable/part", "TableTop": "zero_quest:blocks/nileTable/top", "TableSide": "zero_quest:blocks/nileTable/side", "particle": "zero_quest:blocks/nileTable/particle" }, "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 3, 16 ], "__comment": "Base", "faces": { "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"} } }, { "from": [ 2, 3, 2 ], "to": [ 14, 10, 14 ], "__comment": "Pole", "faces": { "north": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "south": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "east": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "west": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "up": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "down": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"} } }, { "from": [ 0, 9, 0 ], "to": [ 16, 15, 16 ], "__comment": "Top", "faces": { "north": { "uv": [ 0, 0, 16, 6 ], "texture": "#TableSide"}, "south": { "uv": [ 0, 0, 16, 6 ], "texture": "#TableSide"}, "east": { "uv": [ 0, 0, 16, 6 ], "texture": "#TableSide"}, "west": { "uv": [ 0, 0, 16, 6 ], "texture": "#TableSide"}, "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#TableTop"}, "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"} } } ] } -
[1.8][SOLVED]Help with custom block item icon
NovaViper replied to NovaViper's topic in Modder Support
I had to get off of my computer, so I won't be able to test it for a few hours I think. I'll let you know when it works -
[1.8][SOLVED]Help with custom block item icon
NovaViper replied to NovaViper's topic in Modder Support
I've used that tool to get the model, but for some reason I cannot get the 3D viewer to come up, Im using Java 8 and my computer is Windows 7 64 bit -
But I'm also able to have the entities naturally spawn.
-
I use that and I am still able to use the vanilla eggs. Actually, when I updated to 1.8, I wasn't able to use custom egg items, only the vanilla ones
-
[1.8][SOLVED]Help with custom block item icon
NovaViper replied to NovaViper's topic in Modder Support
Basically, I want it look like it was in 1.7.10 1st Person and Inventory View http://i1319.photobucket.com/albums/t661/Nova_Leary/Nile%20CraftingTable%201.7.10%20Inventory%20and%201st%20person_zpsewebfryc.png[/img] 3rd Person View http://i1319.photobucket.com/albums/t661/Nova_Leary/Nile%20CraftingTable%201.7.10%203rd_zpstpwl7c07.png[/img] -
Do something like this: public class ModEntities { public static final String tag = "EntityName"; public static int startEntityId = 300; // Put Renderers in ClientProxy// // Put Guis in CommonProxy// // Put Creature SFX in Sound and sounds.json// public static void loadCreatures() { registerEntity(EntityZertum.class, "Zertum", 0); registerEntityEgg(EntityZertum.class, 0xCCCCCC, 0x33FFFF); registerEntity(EntityRedZertum.class, "RedZertum", 1); registerEntityEgg(EntityRedZertum.class, 0xCCCCCC, 0xFF0000); registerEntity(EntityDestroZertum.class, "DestroZertum", 2); registerEntityEgg(EntityDestroZertum.class, 0xCCCCCC, 0xE6CC80); registerEntity(EntityIceZertum.class, "IceZertum", 3); registerEntityEgg(EntityIceZertum.class, 0xCCCCCC, 0x6699FF); registerEntity(EntityForisZertum.class, "ForisZertum", 4); registerEntityEgg(EntityForisZertum.class, 0xCCCCCC, 0x33CC33); registerEntity(EntityMetalZertum.class, "MetalZertum", 5); registerEntityEgg(EntityMetalZertum.class, 0xCCCCCC, 0x666699); registerEntity(EntityJakan.class, "Jakan", 30); registerEntityEgg(EntityJakan.class, 0x0033CC, 0x00CCFF); registerEntity(EntityKortor.class, "Kortor", 31); registerEntityEgg(EntityKortor.class, 0x6699FF, 0xD1E0FF); registerEntity(EntityRiggator.class, "Riggator", 32); registerEntityEgg(EntityRiggator.class, 0x1D302C, 0x671734); } public static void loadDarkCreatures() { registerEntity(EntityDarkZertum.class, "DarkZertum", 40); registerEntityEgg(EntityDarkZertum.class, 0xCCCCCC, 0x470047); registerEntity(EntityKurr.class, "Kurr", 41); registerEntityEgg(EntityKurr.class, 0xFF0000, 0x660000); } public static void loadSpawns() { addSpawn(EntityZertum.class, 100, 4, 5, EnumCreatureType.CREATURE, ModBiomes.bioZone, ModBiomes.nileSavanna, ModBiomes.nileSavannaPlateau, ModBiomes.nileSwampland, ModBiomes.pinkZone); addSpawn(EntityRedZertum.class, 100, 4, 5, EnumCreatureType.CREATURE, ModBiomes.redSeed); addSpawn(EntityDestroZertum.class, 100, 4, 5, EnumCreatureType.CREATURE, ModBiomes.destroZone, ModBiomes.destroZoneHills); addSpawn(EntityIceZertum.class, 100, 4, 5, EnumCreatureType.CREATURE, ModBiomes.blueTaiga, ModBiomes.blueTaigaHills, ModBiomes.blueColdTaiga, ModBiomes.blueColdTaigaHills); addSpawn(EntityForisZertum.class, 100, 4, 5, EnumCreatureType.CREATURE, ModBiomes.nileJungle, ModBiomes.nileJungleHills, ModBiomes.nileJungleEdge, ModBiomes.nileSwampland); addSpawn(EntityMetalZertum.class, 100, 4, 5, EnumCreatureType.CREATURE, ModBiomes.walRockland); addSpawn(EntityJakan.class, 100, 2, 3, EnumCreatureType.CREATURE, ModBiomes.walRockland); addSpawn(EntityKortor.class, 100, 2, 3, EnumCreatureType.CREATURE, ModBiomes.nileSavanna, ModBiomes.nileSavannaPlateau, ModBiomes.nileJungle, ModBiomes.nileJungleEdge, ModBiomes.nileJungleHills); addSpawn(EntityRiggator.class, 100, 2, 3, EnumCreatureType.MONSTER, ModBiomes.bioZone, ModBiomes.nileSwampland, ModBiomes.nileMesa, ModBiomes.nileMesaPlateau, ModBiomes.nileMesaPlateau_F); } public static void loadDarkSpawns() { addSpawn(EntityDarkZertum.class, 100, 4, 5, EnumCreatureType.CREATURE, ModBiomes.darkWasteland); addSpawn(EntityKurr.class, 100, 2, 3, EnumCreatureType.MONSTER, ModBiomes.darkWasteland); } public static void loadOthers() { registerTileEntity(TileEntityNileWorkbench.class, "Nile Worktable"); registerTileEntity(TileEntityFoodBowl.class, "Food Bowl"); registerProjectileEntity(EntityFlamingPoisonball.class, "FPoisonball", 400); registerProjectileEntity(EntityGrenade.class, "Grenade", 401); registerProjectileEntity(EntityIceball.class, "Iceball", 402); } public static void addSpawn(Class entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, BiomeGenBase... biomes) { EntityRegistry.addSpawn(entityClass, weightedProb, min, max, typeOfCreature, biomes); } public static void registerEntity(Class entityClass, String saveName, int id) { EntityRegistry.registerModEntity(entityClass, saveName, id, ZeroQuest.instance, 120, 1, true); } public static void registerEntityEgg(Class<? extends Entity> entity, int main, int spots) { int id = getUniqueEntityId(); EntityList.idToClassMapping.put(id, entity); EntityList.entityEggs.put(id, new EntityList.EntityEggInfo(id, main, spots)); } public static void registerTileEntity(Class entityTileClass, String saveName) { GameRegistry.registerTileEntity(entityTileClass, saveName); } public static void registerProjectileEntity(Class entityClass, String saveName, int id) { EntityRegistry.registerModEntity(entityClass, saveName, id, ZeroQuest.instance, 128, 1, true); } public static int getUniqueEntityId() { do { startEntityId++; } while (EntityList.getStringFromID(startEntityId) != null); return startEntityId; } }
-
[1.8][SOLVED]Help with custom block item icon
NovaViper replied to NovaViper's topic in Modder Support
Anyone know what I'm doing wrong? -
Hey, I need help making the item icon for my custom modeled block, but it's not coming out as I wanted. It comes out as this First Person http://i1319.photobucket.com/albums/t661/Nova_Leary/Nile%20CraftingTable%20Item%20View%201st%20Person_zpsb1ku68wh.png[/img] Third Person http://i1319.photobucket.com/albums/t661/Nova_Leary/Nile%20CraftingTable%20Item%20View%203rd%20Person_zpskqma5rw7.png[/img] Inventory View http://i1319.photobucket.com/albums/t661/Nova_Leary/Nile%20CraftingTable%20Item%20View_zpsmbjnjpiu.png[/img] Here is my textures on Github: https://github.com/NovaViper/ZeroQuest/tree/master/src/main/resources/assets/zero_quest/textures/blocks/nileTable Block model json { "textures": { "TablePart": "zero_quest:blocks/nileTable/part", "TableTop": "zero_quest:blocks/nileTable/top", "particle": "zero_quest:blocks/nileTable/particle" }, "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 3, 16 ], "__comment": "Base", "faces": { "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"}, "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#TablePart"} } }, { "from": [ 2, 3, 2 ], "to": [ 14, 10, 14 ], "__comment": "Pole", "faces": { "north": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "south": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "east": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "west": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "up": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "down": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"} } }, { "from": [ 0, 9, 0 ], "to": [ 16, 15, 16 ], "__comment": "Top", "faces": { "north": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "south": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "east": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "west": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"}, "up": { "uv": [ 0, 0, 0, 0 ], "texture": "#TableTop"}, "down": { "uv": [ 0, 0, 0, 0 ], "texture": "#TablePart"} } } ] } Item model json { "parent": "zero_quest:block/crafting_table_nile", "display": { "thirdperson": { "rotation": [ -90, 0, 0 ], "translation": [ 0, 1, -3 ], "scale": [ 0.55, 0.55, 0.55 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } } }