Skip to content

Instantly share code, notes, and snippets.

@triphion

triphion/EntityClottIce Secret

Last active Oct 8, 2017
Embed
What would you like to do?
package com.triphion.ancient.entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWanderAvoidWater;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.world.World;
public class EntityClottIce extends EntityMob
{
public EntityClottIce(World worldIn) {
super(worldIn);
this.experienceValue = 1;
this.setSize(0.5F, 0.5F);
}
@Override
protected void initEntityAI() {
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIWander(this, 1.0D));
this.tasks.addTask(2, new EntityAIPanic(this, 1.7D));
this.tasks.addTask(3, new EntityAITempt(this, 1.2D, Items.WHEAT, false));
this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 1.0D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(7, new EntityAILookIdle(this));
this.applyEntityAI();
}
protected void applyEntityAI() {
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, EntityClottIce.class));
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(6.0D);
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.18000002417232513D);
}
@Override
public float getEyeHeight() {
return 0.15F;
}
@Override
protected Item getDropItem() {
return super.getDropItem();
}
}
package com.triphion.ancient.client.model;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelClottIce extends ModelBase
{
public ModelRenderer body;
/**
* Rotation point xz is the halved number of glscaled xz
*/
public ModelClottIce() {
this.body = new ModelRenderer(this, 0, 0);
this.body.setRotationPoint(-4F, 16F, -4F);
this.body.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1, 0.0F);
this.body.setTextureSize(textureWidth, textureHeight);
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
GL11.glPushMatrix();
GL11.glTranslatef(this.body.offsetX, this.body.offsetY, this.body.offsetZ);
GL11.glTranslatef(this.body.rotationPointX * f5, this.body.rotationPointY * f5, this.body.rotationPointZ * f5);
GL11.glScaled(8.0D, 8.0D, 8.0D);
GL11.glTranslatef(-this.body.offsetX, -this.body.offsetY, -this.body.offsetZ);
GL11.glTranslatef(-this.body.rotationPointX * f5, -this.body.rotationPointY * f5, -this.body.rotationPointZ * f5);
this.body.render(f5);
GL11.glPopMatrix();
}
/**
* Helps with the rotations
*/
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
package com.triphion.ancient.client.entity;
import com.triphion.ancient.Reference;
import com.triphion.ancient.client.model.ModelClottIce;
import com.triphion.ancient.entity.EntityClottIce;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderClottIce extends RenderLiving<EntityClottIce>{
private static final ResourceLocation CLOTT_ICE = new ResourceLocation(Reference.MODID +":textures/entity/clottice/clottice.png");
public RenderClottIce(RenderManager rendermanagerIn) {
super(rendermanagerIn, new ModelClottIce(), 0.0F);
}
@Override
protected ResourceLocation getEntityTexture(EntityClottIce entity) {
return CLOTT_ICE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.