All in the mob works good, but the problem it's on the render.
The butterflys are rendering how a frost blaze, and the deers whit her ice charge
I need help because the butterflys apear frequently and sees ugly in this form
This is my code (Ice Charge
//Ice Charge Class
package morestuff.entities.projectile;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import morestuff.core.MoreStuffCore;
import morestuff.particle.TANParticleTypes;
public class EntityIceball extends Entity implements IProjectile
{
private int xTile = -1;
private int yTile = -1;
private int zTile = -1;
private Block inTile;
private boolean inGround;
public EntityLivingBase shootingEntity;
private int ticksAlive;
private int ticksInAir;
public double accelerationX;
public double accelerationY;
public double accelerationZ;
public EntityIceball(World worldIn)
{
super(worldIn);
this.setSize(0.3125F, 0.3125F);
}
@Override
protected void entityInit()
{
}
@Override
@SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance)
{
double d0 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D;
if (Double.isNaN(d0))
{
d0 = 4.0D;
}
d0 = d0 * 64.0D;
return distance < d0 * d0;
}
public EntityIceball(World worldIn, double x, double y, double z, double accelX, double accelY, double accelZ)
{
super(worldIn);
this.setSize(1.0F, 1.0F);
this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch);
this.setPosition(x, y, z);
double d0 = (double)MathHelper.sqrt(accelX * accelX + accelY * accelY + accelZ * accelZ);
this.accelerationX = accelX / d0 * 0.1D;
this.accelerationY = accelY / d0 * 0.1D;
this.accelerationZ = accelZ / d0 * 0.1D;
}
public EntityIceball(World worldIn, EntityLivingBase shooter, double accelX, double accelY, double accelZ)
{
super(worldIn);
this.shootingEntity = shooter;
this.setSize(1.0F, 1.0F);
this.setLocationAndAngles(shooter.posX, shooter.posY, shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);
this.setPosition(this.posX, this.posY, this.posZ);
this.motionX = this.motionY = this.motionZ = 0.0D;
accelX = accelX + this.rand.nextGaussian() * 0.4D;
accelY = accelY + this.rand.nextGaussian() * 0.4D;
accelZ = accelZ + this.rand.nextGaussian() * 0.4D;
double d0 = (double)MathHelper.sqrt(accelX * accelX + accelY * accelY + accelZ * accelZ);
this.accelerationX = accelX / d0 * 0.1D;
this.accelerationY = accelY / d0 * 0.1D;
this.accelerationZ = accelZ / d0 * 0.1D;
}
@Override
public void onUpdate()
{
if (this.world.isRemote || (this.shootingEntity == null || !this.shootingEntity.isDead) && this.world.isBlockLoaded(new BlockPos(this)))
{
super.onUpdate();
if (this.inGround)
{
if (this.world.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock() == this.inTile)
{
++this.ticksAlive;
if (this.ticksAlive == 600)
{
this.setDead();
}
return;
}
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.ticksAlive = 0;
this.ticksInAir = 0;
}
else
{
++this.ticksInAir;
}
Vec3d vec3 = new Vec3d(this.posX, this.posY, this.posZ);
Vec3d vec31 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
RayTraceResult movingobjectposition = this.world.rayTraceBlocks(vec3, vec31);
vec3 = new Vec3d(this.posX, this.posY, this.posZ);
vec31 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec31 = new Vec3d(movingobjectposition.hitVec.x, movingobjectposition.hitVec.y, movingobjectposition.hitVec.z);
}
Entity entity = null;
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
for (int i = 0; i < list.size(); ++i)
{
Entity entity1 = (Entity)list.get(i);
if (entity1.canBeCollidedWith() && (!entity1.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25))
{
float f = 0.3F;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand((double)f, (double)f, (double)f);
RayTraceResult movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);
if (movingobjectposition1 != null)
{
double d1 = vec3.squareDistanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new RayTraceResult(entity);
}
if (movingobjectposition != null)
{
this.onImpact(movingobjectposition);
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float f1 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(MathHelper.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F;
for (this.rotationPitch = (float)(MathHelper.atan2((double)f1, this.motionY) * 180.0D / Math.PI) - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f2 = this.getMotionFactor();
if (this.isInWater())
{
for (int j = 0; j < 4; ++j)
{
float f3 = 0.25F;
this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ, new int[0]);
}
f2 = 0.8F;
}
this.motionX += this.accelerationX;
this.motionY += this.accelerationY;
this.motionZ += this.accelerationZ;
this.motionX *= (double)f2;
this.motionY *= (double)f2;
this.motionZ *= (double)f2;
MoreStuffCore.proxy.spawnParticle(TANParticleTypes.SNOWFLAKE, this.world, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
this.setPosition(this.posX, this.posY, this.posZ);
}
else
{
this.setDead();
}
}
protected float getMotionFactor()
{
return 0.95F;
}
protected void onImpact(RayTraceResult movingObject)
{
if (!this.world.isRemote)
{
if (movingObject.entityHit != null)
{
boolean flag = movingObject.entityHit.attackEntityFrom(DamageSource.GENERIC, 5.0F);
if (flag)
{
this.applyEnchantments(this.shootingEntity, movingObject.entityHit);
/*if (!movingObject.entityHit.isImmuneToFire())
{
movingObject.entityHit.setFire(5);
}*/
}
}
else
{
boolean flag1 = true;
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLiving)
{
flag1 = this.world.getGameRules().getBoolean("mobGriefing");
}
if (flag1)
{
BlockPos blockpos = movingObject.getBlockPos().offset(movingObject.sideHit);
/*if (this.world.isAirBlock(blockpos))
{
this.world.setBlockState(blockpos, Blocks.snow_layer.getDefaultState());
}*/
}
}
this.setDead();
}
}
@Override
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setShort("xTile", (short)this.xTile);
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
ResourceLocation resourcelocation = (ResourceLocation)Block.REGISTRY.getNameForObject(this.inTile);
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
tagCompound.setTag("direction", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ}));
}
@Override
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
this.xTile = tagCompund.getShort("xTile");
this.yTile = tagCompund.getShort("yTile");
this.zTile = tagCompund.getShort("zTile");
if (tagCompund.hasKey("inTile", 8))
{
this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
}
else
{
this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
}
this.inGround = tagCompund.getByte("inGround") == 1;
if (tagCompund.hasKey("direction", 9))
{
NBTTagList nbttaglist = tagCompund.getTagList("direction", 6);
this.motionX = nbttaglist.getDoubleAt(0);
this.motionY = nbttaglist.getDoubleAt(1);
this.motionZ = nbttaglist.getDoubleAt(2);
}
else
{
this.setDead();
}
}
@Override
public boolean canBeCollidedWith()
{
return true;
}
@Override
public float getCollisionBorderSize()
{
return 0.5F;
}
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (this.isEntityInvulnerable(source))
{
return false;
}
else
{
this.setBeenAttacked();
if (source.getTrueSource() != null)
{
Vec3d vec3 = source.getTrueSource().getLookVec();
if (vec3 != null)
{
this.motionX = vec3.x;
this.motionY = vec3.y;
this.motionZ = vec3.z;
this.accelerationX = this.motionX * 0.1D;
this.accelerationY = this.motionY * 0.1D;
this.accelerationZ = this.motionZ * 0.1D;
}
if (source.getTrueSource() instanceof EntityLivingBase)
{
this.shootingEntity = (EntityLivingBase)source.getTrueSource();
}
return true;
}
else
{
return false;
}
}
}
@Override
public void setThrowableHeading(double x, double y, double z,
float velocity, float inaccuracy) {
// TODO Auto-generated method stub
}
//IceCharge render class
package morestuff.entities.projectile;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import morestuff.api.item.TANItems;
@SideOnly(Side.CLIENT)
public class RenderIceball extends Render<EntityIceball>
{
private final RenderItem renderItem;
public RenderIceball(RenderManager renderManagerIn)
{
super(renderManagerIn);
this.renderItem = Minecraft.getMinecraft().getRenderItem();
}
@Override
public void doRender(EntityIceball entity, double x, double y, double z, float entityYaw, float partialTicks)
{
GlStateManager.pushMatrix();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.enableRescaleNormal();
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
this.renderItem.renderItem(this.getItemStack(entity), ItemCameraTransforms.TransformType.GROUND);
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
public ItemStack getItemStack(EntityIceball entity)
{
return new ItemStack(TANItems.ice_charge, 1, 0);
}
@Override
protected ResourceLocation getEntityTexture(EntityIceball entity)
{
return TextureMap.LOCATION_BLOCKS_TEXTURE;
}
}
):
Thats is the entitys class. Please help me because is very very urgent :C
//This is the butterfly render
package morestuff.entities.render;
import morestuff.entities.EntityButterfly;
import morestuff.entities.model.ModelButterfly;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderButterfly extends RenderLiving<EntityButterfly>
{
private static final ResourceLocation orangeTextures = new ResourceLocation("morestuff:textures/entity/orange.png");
private static final ResourceLocation blueTextures = new ResourceLocation("morestuff:textures/entity/blue.png");
private static final ResourceLocation purpleTextures = new ResourceLocation("morestuff:textures/entity/purple.png");
private static final ResourceLocation whiteTextures = new ResourceLocation("morestuff:textures/entity/white.png");
private static final ResourceLocation yellowTextures = new ResourceLocation("morestuff:textures/entity/yellow.png");
public RenderButterfly(RenderManager renderManager)
{
super(renderManager, new ModelButterfly(), 0.25F);
this.shadowSize = 0.0F;
}
@Override
protected ResourceLocation getEntityTexture(EntityButterfly entity)
{
switch (entity.getButterflyType())
{
case 0:
default:
return orangeTextures;
case 1:
return blueTextures;
case 2:
return purpleTextures;
case 3:
return whiteTextures;
case 4:
return yellowTextures;
}
}
}
//This is the Deer render
package morestuff.entities.render;
import morestuff.entities.EntityDeer;
import morestuff.entities.model.ModelDeer;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderDeer extends RenderLiving<EntityDeer>
{
private static final ResourceLocation buckTextures = new ResourceLocation("morestuff:textures/entity/buck.png");
private static final ResourceLocation doeTextures = new ResourceLocation("morestuff:textures/entity/doe.png");
private static final ResourceLocation fawnTextures = new ResourceLocation("morestuff:textures/entity/fawn.png");
public RenderDeer(RenderManager renderManager)
{
super(renderManager, new ModelDeer(), 0.7F);
}
@Override
protected ResourceLocation getEntityTexture(EntityDeer entity)
{
if (entity.isChild())
{
return fawnTextures;
}
else
{
switch (entity.getDeerType())
{
case 1:
return doeTextures;
case 0:
default:
return buckTextures;
}
}
}
}
//This is the FrostBlaze render
package morestuff.entities.render;
import morestuff.entities.EntityFreeze;
import morestuff.entities.model.ModelFreeze;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderFreeze extends RenderLiving<EntityFreeze>
{
private static final ResourceLocation freezeTextures = new ResourceLocation("morestuff:textures/entity/freeze.png");
public RenderFreeze(RenderManager renderManagerIn)
{
super(renderManagerIn, new ModelFreeze(), 0.5F);
}
@Override
protected ResourceLocation getEntityTexture(EntityFreeze entity)
{
return freezeTextures;
}
}
//Mod Entities class
package morestuff.init;
import java.util.Map;
import com.google.common.collect.Maps;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Biomes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration;
import morestuff.core.MoreStuffCore;
import morestuff.entities.EntityFreeze;
import morestuff.entities.projectile.EntityIceball;
public class ModEntities
{
public static final Map<Integer, String> idToTANEntityName = Maps.<Integer, String>newLinkedHashMap();
private static int nextTANEntityId = 1;
public static void init()
{
// projectiles
registerTANEntity(EntityIceball.class, "iceball", 64, 10, true);
// mobs
registerTANEntityWithSpawnEgg(EntityFreeze.class, "freeze", 80, 3, true, 0xECFAF4, 0x439FC3, 3, 1, 3, EnumCreatureType.MONSTER, Biomes.ICE_PLAINS, Biomes.ICE_MOUNTAINS);
}
// register an entity
public static int registerTANEntity(Class<? extends Entity> entityClass, String entityName, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
int tanEntityId = nextTANEntityId;
nextTANEntityId++;
EntityRegistry.registerModEntity(new ResourceLocation(MoreStuffCore.MOD_ID, entityName), entityClass, entityName, tanEntityId, MoreStuffCore.instance, trackingRange, updateFrequency, sendsVelocityUpdates);
idToTANEntityName.put(tanEntityId, entityName);
return tanEntityId;
}
// register an entity and in addition create a spawn egg for it
public static int registerTANEntityWithSpawnEgg(Class<? extends EntityLiving> entityClass, String entityName, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, int eggBackgroundColor, int eggForegroundColor, int spawnWeight, int spawnMin, int spawnMax, EnumCreatureType enumCreatureType, Biome... entityBiomes)
{
int tanEntityId = registerTANEntity(entityClass, entityName, trackingRange, updateFrequency, sendsVelocityUpdates);
EntityRegistry.registerEgg(new ResourceLocation(MoreStuffCore.MOD_ID, entityName), eggBackgroundColor, eggForegroundColor);
EntityRegistry.addSpawn(entityClass, spawnWeight, spawnMin, spawnMax, enumCreatureType, entityBiomes);
return tanEntityId;
}
public static Entity createEntityByID(int tanEntityId, World worldIn)
{
Entity entity = null;
ModContainer mc = FMLCommonHandler.instance().findContainerFor(MoreStuffCore.instance);
EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, tanEntityId);
if (er != null)
{
Class<? extends Entity> clazz = er.getEntityClass();
try
{
if (clazz != null)
{
entity = (Entity)clazz.getConstructor(new Class[] {World.class}).newInstance(new Object[] {worldIn});
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
if (entity == null)
{
MoreStuffCore.logger.warn("Skipping MoreStuff Entity with id " + tanEntityId);
}
return entity;
}
}
//Mod Entities Fauna class
package morestuff.init;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Maps;
import morestuff.core.MoreStuffCore;
import morestuff.entities.EntityButterfly;
import morestuff.entities.EntityDeer;
import morestuff.entities.EntitySnail;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList.EntityEggInfo;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.init.Biomes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.SpawnListEntry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration;
public class ModEntitiesFauna
{
public static final Map<Integer, String> idToBEEntityName = Maps.<Integer, String>newLinkedHashMap();
private static int nextFFEntityId = 1;
public static Biome[] DEER_BIOMES = new Biome[] {Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS,
Biomes.MUTATED_BIRCH_FOREST, Biomes.MUTATED_BIRCH_FOREST_HILLS, Biomes.FOREST, Biomes.FOREST_HILLS,
Biomes.MUTATED_FOREST, Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.REDWOOD_TAIGA, Biomes.REDWOOD_TAIGA_HILLS,
Biomes.MUTATED_REDWOOD_TAIGA, Biomes.MUTATED_REDWOOD_TAIGA_HILLS, Biomes.MUTATED_TAIGA,
Biomes.EXTREME_HILLS, Biomes.EXTREME_HILLS_EDGE, Biomes.EXTREME_HILLS_WITH_TREES,
Biomes.MUTATED_EXTREME_HILLS, Biomes.MUTATED_EXTREME_HILLS_WITH_TREES, Biomes.ROOFED_FOREST,
Biomes.MUTATED_ROOFED_FOREST, Biomes.COLD_TAIGA, Biomes.COLD_TAIGA_HILLS, Biomes.MUTATED_TAIGA_COLD};
public static Biome[] BUTTERFLY_BIOMES = new Biome[] {Biomes.PLAINS, Biomes.MUTATED_PLAINS, Biomes.FOREST,
Biomes.FOREST_HILLS, Biomes.MUTATED_FOREST, Biomes.JUNGLE, Biomes.JUNGLE_EDGE, Biomes.JUNGLE_HILLS,
Biomes.MUTATED_JUNGLE, Biomes.MUTATED_JUNGLE_EDGE};
public static Biome[] SNAIL_BIOMES = new Biome[] {Biomes.SWAMPLAND, Biomes.MUTATED_SWAMPLAND};
public static void init()
{
//Deer
//Remove cows from the biomes deer spawn in
registerFFEntityWithSpawnEgg(EntityDeer.class, "morestuff.deer", 80, 3, true, 0x765134, 0xF7EFE6, EnumCreatureType.CREATURE, 9, 2, 4, DEER_BIOMES);
//Butterfly
registerFFEntityWithSpawnEgg(EntityButterfly.class, "morestuff.butterfly", 80, 3, true, 0x282828, 0xEF6F1F, EnumCreatureType.AMBIENT, 2, 2, 4, BUTTERFLY_BIOMES);
//Snail
registerFFEntityWithSpawnEgg(EntitySnail.class, "morestuff.snail", 80, 3, true, 0xA694BC, 0xCDA26E, EnumCreatureType.AMBIENT, 1, 1, 1, SNAIL_BIOMES);
}
// register an entity
public static int registerFFEntity(Class<? extends Entity> entityClass, String entityName, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
int ffEntityId = nextFFEntityId;
nextFFEntityId++;
EntityRegistry.registerModEntity(new ResourceLocation(MoreStuffCore.MOD_ID, entityName), entityClass, entityName, ffEntityId, MoreStuffCore.instance, trackingRange, updateFrequency, sendsVelocityUpdates);
idToBEEntityName.put(ffEntityId, entityName);
return ffEntityId;
}
// register an entity and in addition create a spawn egg for it
public static int registerFFEntityWithSpawnEgg(Class<? extends EntityLiving> entityClass, String entityName, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, int eggBackgroundColor, int eggForegroundColor, EnumCreatureType enumCreatureType, int spawnWeight, int spawnMin, int spawnMax, Biome... biomes)
{
int ffEntityId = registerFFEntity(entityClass, entityName, trackingRange, updateFrequency, sendsVelocityUpdates);
EntityRegistry.registerEgg(new ResourceLocation(MoreStuffCore.MOD_ID, entityName), eggBackgroundColor, eggForegroundColor);
addSpawn(entityClass, spawnWeight, spawnMin, spawnMax, enumCreatureType, biomes);
return ffEntityId;
}
public static Entity createEntityByID(int tanEntityId, World worldIn)
{
Entity entity = null;
ModContainer mc = FMLCommonHandler.instance().findContainerFor(MoreStuffCore.instance);
EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, tanEntityId);
if (er != null)
{
Class<? extends Entity> clazz = er.getEntityClass();
try
{
if (clazz != null)
{
entity = (Entity)clazz.getConstructor(new Class[] {World.class}).newInstance(new Object[] {worldIn});
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
if (entity == null)
{
MoreStuffCore.logger.warn("Skipping FF Entity with id " + tanEntityId);
}
return entity;
}
public static void addSpawn(Class <? extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, Biome... biomes)
{
for (Biome biome : biomes)
{
if (biome != null)
{
List<SpawnListEntry> spawns = biome.getSpawnableList(typeOfCreature);
boolean found = false;
for (SpawnListEntry entry : spawns)
{
//Adjusting an existing spawn entry
if (entry.entityClass == entityClass)
{
entry.itemWeight = weightedProb;
entry.minGroupCount = min;
entry.maxGroupCount = max;
found = true;
break;
}
}
if (!found)
spawns.add(new SpawnListEntry(entityClass, weightedProb, min, max));
}
}
}
public static void removeSpawn(Class <? extends EntityLiving > entityClass, EnumCreatureType typeOfCreature, Biome... biomes)
{
for (Biome biome : biomes)
{
if (biome != null)
{
Iterator<SpawnListEntry> spawns = biome.getSpawnableList(typeOfCreature).iterator();
while (spawns.hasNext())
{
SpawnListEntry entry = spawns.next();
if (entry.entityClass == entityClass)
{
spawns.remove();
}
}
}
}
}
}
//Main Class
package morestuff.core;
import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import akka.io.Tcp.Register;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import morestuff.command.TANCommand;
import morestuff.config.ConfigurationHandler;
import morestuff.config.GuiConfigurationxlfoodmod;
import morestuff.config.TANConfig;
import morestuff.entities.projectile.EntityProjectile;
import morestuff.entities.render.gun.ModelOverrides;
import morestuff.entities.render.gun.model.ModelChainGun;
import morestuff.handler.BlockHarvestEventHandler;
import morestuff.handler.LootTableEventHandler;
import morestuff.init.BlockListxlfoodmod;
import morestuff.init.ItemFoodxlfoodmod;
import morestuff.init.ItemListxlfoodmod;
import morestuff.init.ItemSeedsxlfoodmod;
import morestuff.init.ModBlocks;
import morestuff.init.ModConfig;
import morestuff.init.ModConfiguration;
import morestuff.init.ModCrafting;
import morestuff.init.ModEntities;
import morestuff.init.ModEntitiesFauna;
import morestuff.init.ModGuns;
import morestuff.init.ModHandlers;
import morestuff.init.ModItems;
import morestuff.init.ModItemsFauna;
import morestuff.init.ModLootTable;
import morestuff.init.ModPotions;
import morestuff.init.ModSounds;
import morestuff.init.ModStats;
import morestuff.init.ModVanillaCompat;
import morestuff.util.inventory.TabGun;
import morestuff.util.inventory.XLFoodModTab;
import morestuff.world.WorldGeneratorGrassxlfoodmod;
import morestuff.world.WorldGeneratorRockSaltxlfoodmod;
import morestuff.world.WorldGeneratorVanillaFlowerxlfoodmod;
@Mod(modid = MoreStuffCore.MOD_ID, version = MoreStuffCore.MOD_VERSION, name = MoreStuffCore.MOD_NAME, dependencies = "required-after:forge@[1.0.0.0,)", guiFactory = MoreStuffCore.GUI_FACTORY)
public class MoreStuffCore
{
public static final String MOD_NAME = "MoreStuffMod";
public static final String MOD_ID = "morestuff";
public static final String MOD_VERSION = "DevelopmentBuild";
public static final String GUI_FACTORY = "morestuff.client.gui.GuiFactory";
public static final String GUI_FFFACTORY = "morestuff.client.gui.GuiFFFactory";
@Instance(MOD_ID)
public static MoreStuffCore instance;
@SidedProxy(clientSide = "morestuff.core.ClientProxy", serverSide = "morestuff.core.CommonProxy")
public static CommonProxy proxy;
public static Configuration config;
public static final FoodTab tabXLFoodMod = new FoodTab();
public static final CreativeTabs GUN_TAB = new TabGun();
public static Logger logger = LogManager.getLogger(MOD_ID);
public static File configDirectory;
@EventHandler
public void preInit(FMLPreInitializationEvent preEvent)
{
configDirectory = new File(preEvent.getModConfigurationDirectory(), "morestuff");
this.proxy.preInit(preEvent);
config = new Configuration(preEvent.getSuggestedConfigurationFile());
if(!GuiConfigurationxlfoodmod.WorldGen.RockGen) {
GameRegistry.registerWorldGenerator(new WorldGeneratorRockSaltxlfoodmod(), 0);
}
if(!GuiConfigurationxlfoodmod.WorldGen.GrassGen) {
GameRegistry.registerWorldGenerator(new WorldGeneratorGrassxlfoodmod(), 2);
}
if(!GuiConfigurationxlfoodmod.WorldGen.FlowerGen) {
GameRegistry.registerWorldGenerator(new WorldGeneratorVanillaFlowerxlfoodmod(), 1);
}
ModConfiguration.init(configDirectory);
ModConfig.init(configDirectory);
ModBlocks.init();
ModEntities.init();
ModEntitiesFauna.init();
ModItemsFauna.init();
ModItems.init();
ModStats.init();
ModPotions.init();
ModVanillaCompat.init();
ModHandlers.init();
ModCrafting.init();
ModSounds.init();
ModLootTable.init();
ModGuns.init();
ItemListxlfoodmod.register();
BlockListxlfoodmod.register();
proxy.preInit();
MinecraftForge.EVENT_BUS.register(new LootTableEventHandler());
MinecraftForge.EVENT_BUS.register(new BlockHarvestEventHandler());
proxy.registerRenderers();
FMLCommonHandler.instance().bus().register(instance);
}
//This other thing, for guns. Ignore that
@EventHandler
public void init(FMLInitializationEvent event)
{
TANConfig.init(configDirectory);
ConfigurationHandler.init(configDirectory);
EntityRegistry.registerModEntity(new ResourceLocation("morestuff:projectile"), EntityProjectile.class, "morestuffProjectile", 0, this, 64, 80, true);
proxy.init();
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent postEvent)
{
this.proxy.postInit(postEvent);
}
@EventHandler
public void init(FMLLoadCompleteEvent event)
{
if(event.getSide() == Side.CLIENT)
{
ModelOverrides.register(new ResourceLocation("morestuff:chain_gun"), new ModelChainGun());
}
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(new TANCommand());
}
}
I Use diferent class for block and items because in the ModBlock And ModItems are items more hard, and for stay whitout confusion i do in that form