Unless there is a bug, I don't see anything wrong. I've tested entity egg spawns many times and they never despawned, unless made to. So the entity is spawned but not saved I guess? If I was having this problem I would debug when minecraft's server shuts down, and when the entity saves it's NBT data.
So what do you think I should do?
also I've added 2 more methods to the Entity class, attempting to fix the problem.
@Override
public void onLivingUpdate()
{
super.onLivingUpdate();
}
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
}
I dont know much about entity NBT :/
Also, another bug I forgot to mention, when my mobs spawn, they spawn textured, with the exception of the head, which remains white, any help on this as well?
its not at all the same though they may look similar its obvious that your code automatically assumes alt by typecasting up without a instanceof check. Whatever object your casting can be a BlockFenceObsidian. So this is not necessarily the thread to help you with your problem since your problem has nothing to do with entities. It will rarely be an entity problem when dealing with blocks.
oh yea and i figured this out by the line java.lang.ClassCastException: BlockFenceObsidian cannot be cast to alt
why didn't i find this post faster!
I had the same problems and it took me the entire day to fix this.
my solution was just to erase the casting "byte". why is the highest entity id 3000 anyways?
from my research, the highest entity id was 200 from the end crystal (http://www.minecraftxl.com/data-values).
and why limit mobs to 256 (actually less than that since there are already other entities preoccupying the id's)?
kudos for you for solving the problem!
Good you found this thread If you read my recent post for Forge, you can have more than 256 ids and they won't interfere with other mods installed.
why is the highest entity id 3000 anyways?
Before the update that caused these errors, Modloader already had 3000 as the highest entity Id. After that Modloader never changed it so people had all these stack trace reports as seen in my first post. That's why I recommend Forge
and why limit mobs to 256
The packet writes a byte value for the mob Id, but it could of been fixed by writing an integer instead. If you remove the byte cast it will work but try to open in LAN while playing. That will call the read/write packet methods and cause errors since it's not a byte.
This is my favorite post ever. So much great information! I was plagued by the entity limit a few weeks ago when cramming a bunch of mods into my game. And now I've managed to register some mobs and now I can get to the fun part of mod-making. Many thanks!
if (var6.shootingEntity != null) {
var4 = new Packet23VehicleSpawn(
this.myEntity,
63,
((EntityFireball) this.myEntity).shootingEntity.entityId);
} else {
var4 = new Packet23VehicleSpawn(this.myEntity, 63,
0);
}
var4.speedX = (int) (var6.accelerationX * 8000.0D);
var4.speedY = (int) (var6.accelerationY * 8000.0D);
var4.speedZ = (int) (var6.accelerationZ * 8000.0D);
return var4;
} else if (this.myEntity instanceof EntityEgg) {
return new Packet23VehicleSpawn(this.myEntity, 62);
} else if (this.myEntity instanceof EntityTNTPrimed) {
return new Packet23VehicleSpawn(this.myEntity, 50);
} else if (this.myEntity instanceof EntityEnderCrystal) {
return new Packet23VehicleSpawn(this.myEntity, 51);
} else if (this.myEntity instanceof EntityFallingSand) {
EntityFallingSand var5 = (EntityFallingSand) this.myEntity;
return new Packet23VehicleSpawn(this.myEntity, 70,
var5.blockID | var5.field_70285_b << 16);
} else if (this.myEntity instanceof EntityPainting) {
return new Packet25EntityPainting(
(EntityPainting) this.myEntity);
} else if (this.myEntity instanceof EntityXPOrb) {
return new Packet26EntityExpOrb(
(EntityXPOrb) this.myEntity);
}
}
} else {
this.lastHeadMotion = MathHelper.floor_float(this.myEntity
.func_70079_am() * 256.0F / 360.0F);
return new Packet24MobSpawn((EntityLiving) this.myEntity);
}
}
return null;
}
I gave the errors an Underline and bold text.
The error for field_70285_b is: field_70285_b cannot be resolved or is not a field
The error for func_70079_am is: The method func_70079_am() is undefined for the type Entity
HELP I did everything you said, my mob is still invisible.
(I removed blocks items and other non mob-related feature so don't say that it's because an item dosn't exist)
(I have no eclipse errors)
(I have no crash)
mod_***
package net.minecraft.src;
import java.awt.Color;
import java.util.Map;
import java.util.Random;
public class mod_wizardofoz extends BaseMod
{
public void load()
/**
* MODLOADER FUNCTIONS/FINAL DECLARATIONS
*/
{
/**
* MOB DECLARATION
*/
//REGISTER MOB
ModLoader.registerEntityID(EntityTinMan.class, "TinMan", 255);
ModLoader.registerEntityID(EntityScareCrow.class, "ScareCrow", 254);
//CLASSIFYING AND GROUPING
ModLoader.addSpawn("TinMan", 15, -1, 3, EnumCreatureType.creature);
ModLoader.addSpawn("ScareCrow", 15, -1, 2, EnumCreatureType.creature);
//SET EGG NAME
ModLoader.addLocalization("entity.TinMan.name", "TinMan");
ModLoader.addLocalization("entity.ScareCrow.name", "ScareCrow");
//COLOR EGGS
EntityList.entityEggs.put(Integer.valueOf(255), new EntityEggInfo(255, 0x444444, 0x777777));
EntityList.entityEggs.put(Integer.valueOf(254), new EntityEggInfo(254, 0xffff99, 0x664400));
}
}
/**
* ENTITY RENDERING
*/
public void addRenderer(Map var1)
{
var1.put(EntityTinMan.class, new RenderLiving(new ModelTinMan(),.5f));
var1.put(EntityScareCrow.class, new RenderLiving(new ModelScareCrow(),.5f));
}
/**
* MOD DESCRIPTION
*/
public String getName() {
return "Wizard of Oz";
}
public String getVersion() {
return "WoOz v1";
}
}
EntityTinMan
package net.minecraft.src;
public class EntityTinMan extends EntityCreature
{
public EntityTinMan(World par1World)
{
super(par1World);
this.texture = "/mob/TinMan.png";
this.moveSpeed = 0.4f;
isImmuneToFire = true;
////ARTIFICIAL-INTELEGENCE////
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIMoveTwardsRestriction(this, this.moveSpeed));
this.tasks.addTask(3, new EntityAIWander(this, this.moveSpeed));
this.tasks.addTask(4, new EntityAILookIdle(this));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.getNavigator().setAvoidsWater(true);
}
protected void fall(float par1) {}
/**
* ENTITY FUNCTIONS (NOT AI)
*/
//MAX HEALTH 1 = 1/2 heart
public int getMaxHealth()
{
return 20;
}
//TOOLS AND ARMOR 0 = tool, 1-4 = armor
protected void func_82164_bB()
{
this.setCurrentItemOrArmor(0, new ItemStack(Item.axeSteel));
}
//SOUNDS
protected String getLivingSound()
{
return "mob.pig.say";
}
protected String getHurtSound()
{
return "mob.pig.say";
}
protected String getDeathSound()
{
return "mob.pig.death";
}
//DROPPED ITEM
protected int getDropItemId()
{
return Item.ingotIron.shiftedIndex;
}
//DESPAWNING
protected boolean canDespawn()
{
return true;
}
//ENABLING AI (ALWAYS TRUE
protected boolean isAIEnabled()
{
return true;
}
}
RenderTinMan
package net.minecraft.src;
public class RederTinMan extends RenderLiving
{
public RederTinMan(ModelBase par1ModelBase, float par2)
{
super(par1ModelBase, par2);
}
public void renderTinMan(EntityTinMan par1EntityTinMan, double par2, double par4, double par6, float par8, float par9)
{
super.doRenderLiving(par1EntityTinMan, par2, par4, par6, par8, par9);
}
public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
{
this.renderTinMan((EntityTinMan)par1EntityLiving, par2, par4, par6, par8, par9);
}
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.renderTinMan((EntityTinMan)par1Entity, par2, par4, par6, par8, par9);
}
}
I currently have this small weird issue with Entity tracking with Forge. I did what you said and implemented all my mobs as a modEntity with the tracker variable in there. The variable is 3 for all mobs because most of them are creatures. However when a decent amount of mobs spawned the entity update is so slow and you see them moving in steps of a second or so. It just looks bad. Is the Tracking Fps independent? Probably. Could also be that I maybe messed something up in the proxy but I doubt it. I'm just wondering if anyone else had this problem before or just knows how to fix it.
Thanks in Advance,
Daveyx0
EDIT: I read through some other posts. Maybe I should implement IAnimals just to be sure.
I looked at your mod and it probably has to do with how many mobs you have on the screen at once Id simply try different tracker values to see if one worked better than others. The tracker tells minecraft how often the entity should be updated so keep that in mind when working with large amounts of entities.
IAnimals is made to handle the tracking of mobs a lot maybe u should look at its tracking parameters
Ok, so I added IAnimals to most of my creatures and IMobs to most of my mobs, however the problem is still there. Increasing the updateFrequency just makes it worse instead of fixing it. Decreasing it seems to improve it, but I dont want everyone else's cpu to lag. Is there a way to register mod entities (with forge) without adding tracking so I can make IAnimals do all the work? If that's even different from putting it in manualy which I actually doubt. This is like the only thing that bothers me right now.
How did DrZhark do this? >.>
EDIT; He just uses a updatefrequency of 1.... yup, doing it.
The Meaning of Life, the Universe, and Everything.
Join Date:
5/16/2012
Posts:
50
Member Details
Hi guys, I've been trying to follow along with the help provided in this thread but I seem to have gotten stuck with something. Originally my problem was that my custom texture was appearing on a villager, not on the custom model I had made. After I tried a couple of fixes I read here, my mob became invisible. Now it just seems to crash the game. Here are my relevent class files:
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
renderFireDrone((EntityFireDrone)par1Entity, par2, par4, par6, par8, par9);
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
/* public boolean interact(EntityPlayer par1EntityPlayer)
{
if (par1World.isRemote)
{
return true;
}
else
{
TileFireDrone var10 = (TileFireDrone)par1World.getBlockTileEntity(par2, par3, par4);
if (var10 != null)
{
par5EntityPlayer.displayGUIFireDrone(var10);
}
return true;
}
}
*/
public EntityAgeable func_90011_a(EntityAgeable var1) {
// TODO Auto-generated method stub
return null;
}
}
public class ClientProxyKanohi extends CommonProxyKanohi
{
@Override
public void init() {
MinecraftForgeClient.preloadTexture("/Kanohi/Fire Drone Final.png");
RenderingRegistry.registerEntityRenderingHandler(EntityFireDrone.class,
new RenderFireDrone(new ModelFireDrone(), 0.5F));
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
switch (ID)
{
case 0: /* your guis go here */
}
}
return tileEntity;
}
@Override
public void registerRenderThings()
{
MinecraftForgeClient.preloadTexture("/Kanohi/Fire Drone Final.png");
}
}
public class CommonProxyKanohi implements IGuiHandler
{
@Override
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
@Override
public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
I tried putting in the exact same values as IAnimals for my mobs as well as implenting IAnimals to all of my mobs however I still get this lagging entity problem.... while my character walks without any lag and can break blocks without any lag. It's really weird and really frustrating, because I cant seem to find a solution. Could it be that Entity tracking for mod entities is broken? However I can conclude that it DOES affect the entity tracking of the mobs, because a higher number equals a larger step for each entity tracking tick.
I myself only get the problem when I unleash 300 + mobs. However other players need lower amounts to get the problem. There must be something I'm doing wrong, but I just can't find it.
Looking into DrZharks mod file, it seems that he just registers both a mod and global entity for the same entity and uses a range of 128 and updatefreq of 1, which doesnt make any sense. So references won't help me.....
I tried putting in the exact same values as IAnimals for my mobs as well as implenting IAnimals to all of my mobs however I still get this lagging entity problem.... while my character walks without any lag and can break blocks without any lag. It's really weird and really frustrating, because I cant seem to find a solution. Could it be that Entity tracking for mod entities is broken? However I can conclude that it DOES affect the entity tracking of the mobs, because a higher number equals a larger step for each entity tracking tick.
I myself only get the problem when I unleash 300 + mobs. However other players need lower amounts to get the problem. There must be something I'm doing wrong, but I just can't find it.
>.< T_T
If you are getting a lag then it's most likely a high update frequency. How are you registering entities?
The arguments left to right are, EntityClass, EntityName, Id, mod, viewDistance, updateFrequency, and track motion.
When registering global entities, IAnimals interface is important but in Forge you always add your own tracking data. Adding it won't effect how an entity is tracked.
Looking into DrZharks mod file, it seems that he just registers both a mod and global entity for the same entity and uses a range of 128 and updatefreq of 1, which doesnt make any sense. So references won't help me.....
I wouldn't use him as a reference or anyone else unless it's an example mod.
I'm very interested in changing the vanilla tracking distance, specifically for Villagers. Do you know of any safe way to do this (using Forge)? I've tried a few methods of removing and re-adding the entities and can't find a good solution.
So what do you think I should do?
also I've added 2 more methods to the Entity class, attempting to fix the problem.
I dont know much about entity NBT :/
Also, another bug I forgot to mention, when my mobs spawn, they spawn textured, with the exception of the head, which remains white, any help on this as well?
But, however, I still have the bug where the head is still blank.
Any ideas on how to fix this?
Thanks so much!
its not at all the same though they may look similar its obvious that your code automatically assumes alt by typecasting up without a instanceof check. Whatever object your casting can be a BlockFenceObsidian. So this is not necessarily the thread to help you with your problem since your problem has nothing to do with entities. It will rarely be an entity problem when dealing with blocks.
oh yea and i figured this out by the line java.lang.ClassCastException: BlockFenceObsidian cannot be cast to alt
OMG IT's SimJoo xD
its the 0 in the function it needs to be any other number
I had the same problems and it took me the entire day to fix this.
my solution was just to erase the casting "byte". why is the highest entity id 3000 anyways?
from my research, the highest entity id was 200 from the end crystal (http://www.minecraftxl.com/data-values).
and why limit mobs to 256 (actually less than that since there are already other entities preoccupying the id's)?
kudos for you for solving the problem!
Before the update that caused these errors, Modloader already had 3000 as the highest entity Id. After that Modloader never changed it so people had all these stack trace reports as seen in my first post. That's why I recommend Forge
The packet writes a byte value for the mob Id, but it could of been fixed by writing an integer instead. If you remove the byte cast it will work but try to open in LAN while playing. That will call the read/write packet methods and cause errors since it's not a byte.
http://www.minecraft...ob-performance/
private Packet getPacketForThisEntity() {
if (this.myEntity.isDead) {
System.out.println("Fetching addPacket for removed entity");
}
Iterator iterator = ModLoader.getTrackers()
.values().iterator();
EntityTrackerNonliving var3;
while (iterator.hasNext()) {
var3 = iterator.next();
if (var3.entityClass.isAssignableFrom(this.myEntity.getClass()))
return var3.mod.getSpawnPacket(this.myEntity, var3.id);
}
if (this.myEntity instanceof EntityItem) {
EntityItem var11 = (EntityItem) this.myEntity;
Packet21PickupSpawn var8 = new Packet21PickupSpawn(var11);
var11.posX = (double) var8.xPosition / 32.0D;
var11.posY = (double) var8.yPosition / 32.0D;
var11.posZ = (double) var8.zPosition / 32.0D;
return var8;
} else if (this.myEntity instanceof EntityPlayerMP) {
return new Packet20NamedEntitySpawn((EntityPlayer) this.myEntity);
} else {
EntityMinecart var1;
if (this.myEntity instanceof EntityMinecart) {
var1 = (EntityMinecart) this.myEntity;
if (var1.minecartType == 0) {
return new Packet23VehicleSpawn(this.myEntity, 10);
}
if (var1.minecartType == 1) {
return new Packet23VehicleSpawn(this.myEntity, 11);
}
if (var1.minecartType == 2) {
return new Packet23VehicleSpawn(this.myEntity, 12);
}
}
if (this.myEntity instanceof EntityBoat) {
return new Packet23VehicleSpawn(this.myEntity, 1);
} else if (!(this.myEntity instanceof IAnimals)
&& !(this.myEntity instanceof EntityDragon)) {
if (this.myEntity instanceof EntityFishHook) {
EntityPlayer var10 = ((EntityFishHook) this.myEntity).angler;
return new Packet23VehicleSpawn(this.myEntity, 90,
var10 != null ? var10.entityId
: this.myEntity.entityId);
} else if (this.myEntity instanceof EntityArrow) {
Entity var9 = ((EntityArrow) this.myEntity).shootingEntity;
return new Packet23VehicleSpawn(this.myEntity, 60,
var9 != null ? var9.entityId
: this.myEntity.entityId);
} else if (this.myEntity instanceof EntitySnowball) {
return new Packet23VehicleSpawn(this.myEntity, 61);
} else if (this.myEntity instanceof EntityPotion) {
return new Packet23VehicleSpawn(this.myEntity, 73,
((EntityPotion) this.myEntity).getPotionDamage());
} else if (this.myEntity instanceof EntityExpBottle) {
return new Packet23VehicleSpawn(this.myEntity, 75);
} else if (this.myEntity instanceof EntityEnderPearl) {
return new Packet23VehicleSpawn(this.myEntity, 65);
} else if (this.myEntity instanceof EntityEnderEye) {
return new Packet23VehicleSpawn(this.myEntity, 72);
} else {
Packet23VehicleSpawn var4;
if (this.myEntity instanceof EntitySmallFireball) {
EntitySmallFireball var7 = (EntitySmallFireball) this.myEntity;
var1 = null;
if (var7.shootingEntity != null) {
var4 = new Packet23VehicleSpawn(this.myEntity, 64,
var7.shootingEntity.entityId);
} else {
var4 = new Packet23VehicleSpawn(this.myEntity, 64,
0);
}
var4.speedX = (int) (var7.accelerationX * 8000.0D);
var4.speedY = (int) (var7.accelerationY * 8000.0D);
var4.speedZ = (int) (var7.accelerationZ * 8000.0D);
return var4;
} else if (this.myEntity instanceof EntityFireball) {
EntityFireball var6 = (EntityFireball) this.myEntity;
var1 = null;
if (var6.shootingEntity != null) {
var4 = new Packet23VehicleSpawn(
this.myEntity,
63,
((EntityFireball) this.myEntity).shootingEntity.entityId);
} else {
var4 = new Packet23VehicleSpawn(this.myEntity, 63,
0);
}
var4.speedX = (int) (var6.accelerationX * 8000.0D);
var4.speedY = (int) (var6.accelerationY * 8000.0D);
var4.speedZ = (int) (var6.accelerationZ * 8000.0D);
return var4;
} else if (this.myEntity instanceof EntityEgg) {
return new Packet23VehicleSpawn(this.myEntity, 62);
} else if (this.myEntity instanceof EntityTNTPrimed) {
return new Packet23VehicleSpawn(this.myEntity, 50);
} else if (this.myEntity instanceof EntityEnderCrystal) {
return new Packet23VehicleSpawn(this.myEntity, 51);
} else if (this.myEntity instanceof EntityFallingSand) {
EntityFallingSand var5 = (EntityFallingSand) this.myEntity;
return new Packet23VehicleSpawn(this.myEntity, 70,
var5.blockID | var5.field_70285_b << 16);
} else if (this.myEntity instanceof EntityPainting) {
return new Packet25EntityPainting(
(EntityPainting) this.myEntity);
} else if (this.myEntity instanceof EntityXPOrb) {
return new Packet26EntityExpOrb(
(EntityXPOrb) this.myEntity);
}
}
} else {
this.lastHeadMotion = MathHelper.floor_float(this.myEntity
.func_70079_am() * 256.0F / 360.0F);
return new Packet24MobSpawn((EntityLiving) this.myEntity);
}
}
return null;
}
I gave the errors an Underline and bold text.
The error for field_70285_b is: field_70285_b cannot be resolved or is not a field
The error for func_70079_am is: The method func_70079_am() is undefined for the type Entity
(I removed blocks items and other non mob-related feature so don't say that it's because an item dosn't exist)
(I have no eclipse errors)
(I have no crash)
mod_***
EntityTinMan
RenderTinMan
ModelTinMan
I currently have this small weird issue with Entity tracking with Forge. I did what you said and implemented all my mobs as a modEntity with the tracker variable in there. The variable is 3 for all mobs because most of them are creatures. However when a decent amount of mobs spawned the entity update is so slow and you see them moving in steps of a second or so. It just looks bad. Is the Tracking Fps independent? Probably. Could also be that I maybe messed something up in the proxy but I doubt it. I'm just wondering if anyone else had this problem before or just knows how to fix it.
Thanks in Advance,
Daveyx0
EDIT: I read through some other posts. Maybe I should implement IAnimals just to be sure.
IAnimals is made to handle the tracking of mobs a lot maybe u should look at its tracking parameters
How did DrZhark do this? >.>
EDIT; He just uses a updatefrequency of 1.... yup, doing it.
When you register an entity with Forge, you need to put tracking as well. The update frequency is the interval between each update.
I wouldn't use 1 unless it really needs it. Look at this chart with all of minecraft's entities
https://docs.google.com/spreadsheet/pub?key=0Ap8gssssFFPAdFRXREZGSzZRY3k1WE8wcUE4S09xWXc&output=html
IAnimals is 3
Main mod class:
package Kanohi.common;
import java.util.Map;
import net.minecraft.src.BaseMod;
import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.Block;
import net.minecraft.src.EntityEggInfo;
import net.minecraft.src.EntityList;
import net.minecraft.src.EnumCreatureType;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import Kanohi.client.ClientPacketHandler;
import Kanohi.client.ClientProxyKanohi;
import Kanohi.client.ServerPacketHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "Slamdance_Kanohimod", name = "The Kanohi Mod", version = "0.1")
@NetworkMod (clientSideRequired = true, serverSideRequired = false,
clientPacketHandlerSpec =
@SidedPacketHandler(channels = {"Kanohi"}, packetHandler = ClientPacketHandler.class),
serverPacketHandlerSpec =
@SidedPacketHandler(channels = {"Kanohi"}, packetHandler = ServerPacketHandler.class))
public class Kanohi extends BaseMod
{
@SidedProxy (clientSide = "Kanohi.client.ClientProxyKanohi", serverSide = "Kanohi.common.CommonProxyKanohi")
public static CommonProxyKanohi proxy;
@Instance ("The Kanohi Mod")
public static Kanohi instance = new Kanohi();
private GuiHandler guiHandler = new GuiHandler();
public static Block protodermisBlock;
public static Block firedroneBlock;
public static Item staffFire;
public static Item ingotProtodermis;
public static Item spawnerFireDrone;
@PreInit
public void load (FMLPreInitializationEvent event)
{
NetworkRegistry.instance().registerGuiHandler(this, this.proxy);
instance = this;
}
@Init
public void load(FMLInitializationEvent event)
{
proxy.init();
proxy.registerRenderThings();
EntityRegistry.registerModEntity(EntityFireDrone.class, "Fire Drone",1, this, 80, 3, true);
EntityRegistry.addSpawn(EntityFireDrone.class, 0, 0, 50, EnumCreatureType.creature);
EntityList.IDtoClassMapping.put(300, EntityFireDrone.class);
EntityList.entityEggs.put(300, new EntityEggInfo(300,12698049, 12698049));
EntityRegistry.addSpawn(EntityFireDrone.class, 10, 2, 4, EnumCreatureType.monster,
BiomeGenBase.beach, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge,
BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills,
BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.ocean, BiomeGenBase.plains,
BiomeGenBase.river, BiomeGenBase.swampland);
protodermisBlock = new BlockProtodermisBlock(250,0).setBlockName("protodermisBlock");
firedroneBlock = new BlockFireDroneBlock (251).setBlockName("firedroneBlock");
staffFire = new ItemFireStaff(550).setIconIndex(1).setItemName("staffFire");
ingotProtodermis = new IngotProtodermis(551).setIconIndex(2).setItemName("ingotProtodermis");
spawnerFireDrone = new SpawnerFireDrone(552).setIconIndex(3).setItemName("spawnerFireDrone");
GameRegistry.registerBlock(protodermisBlock);
GameRegistry.registerBlock(firedroneBlock);
GameRegistry.registerTileEntity(TileFireDrone.class, "tileEntityFireDrone");
GameRegistry.registerWorldGenerator(new WorldgeneratorKanohi());
GameRegistry.addRecipe(new ItemStack(staffFire,1),
new Object []
{
"XYX","XZX","XZX", 'X', Item.stick, 'Y', Item.bucketLava, 'Z', ingotProtodermis
});
GameRegistry.addRecipe(new ItemStack(spawnerFireDrone,1),
new Object []
{
"XXX", "XYX", "XXX", 'X', ingotProtodermis, 'Y', staffFire
});
GameRegistry.addSmelting(protodermisBlock.blockID, new ItemStack(ingotProtodermis),0.1F);
LanguageRegistry.addName(protodermisBlock, "Protodermis Ore");
LanguageRegistry.addName(firedroneBlock, "Fire Drone Block");
LanguageRegistry.addName(staffFire, "Mask Makers Fire Staff");
LanguageRegistry.addName (ingotProtodermis, "Protodermis Ingot");
LanguageRegistry.addName (spawnerFireDrone, "Fire Drone");
LanguageRegistry.instance().addStringLocalization("entity.Slamdance_Kanohimod.FireDrone.name", "Fire Drone");
NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
}
@Override
public String getVersion() {
// TODO Auto-generated method stub
return null;
}
@Override
public void load() {
// TODO Auto-generated method stub
}
}
Model class
package Kanohi.common;
import javax.swing.text.html.parser.Entity;
import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer;
public class ModelFireDrone extends ModelBase
{
//fields
ModelRenderer Head;
ModelRenderer Left_Foot;
ModelRenderer Right_Foot;
ModelRenderer Left_Toe;
ModelRenderer Right_Toe;
ModelRenderer Left_Leg;
ModelRenderer Biggieleft;
ModelRenderer pinkieleft;
ModelRenderer Biggieright;
ModelRenderer pinkieright;
ModelRenderer Right_Leg;
ModelRenderer Body;
ModelRenderer neck;
ModelRenderer Left_Arm;
ModelRenderer Right_Arm;
ModelRenderer Left_Hand;
ModelRenderer Right_Hand;
ModelRenderer finger1left;
ModelRenderer finger3left;
ModelRenderer finger3right;
ModelRenderer finger1right;
ModelRenderer finger2left;
ModelRenderer finger2right;
public ModelFireDrone()
{
textureWidth = 64;
textureHeight = 64;
Head = new ModelRenderer(this, 42, 0);
Head.addBox(-2F, -3F, -2F, 4, 3, 4);
Head.setRotationPoint(0F, 7F, -2F);
Head.setTextureSize(64, 64);
Head.mirror = true;
setRotation(Head, 0F, 0F, 0F);
Left_Foot = new ModelRenderer(this, 52, 59);
Left_Foot.addBox(-1F, 0F, -2F, 3, 2, 3);
Left_Foot.setRotationPoint(3F, 22F, -1F);
Left_Foot.setTextureSize(64, 64);
Left_Foot.mirror = true;
setRotation(Left_Foot, 0F, 0F, 0F);
Right_Foot = new ModelRenderer(this, 39, 59);
Right_Foot.addBox(-2F, 0F, -2F, 3, 2, 3);
Right_Foot.setRotationPoint(-3F, 22F, -1F);
Right_Foot.setTextureSize(64, 64);
Right_Foot.mirror = true;
setRotation(Right_Foot, 0F, 0F, 0F);
Left_Toe = new ModelRenderer(this, 54, 56);
Left_Toe.addBox(-1F, 0F, -1F, 3, 1, 1);
Left_Toe.setRotationPoint(3F, 23F, -3F);
Left_Toe.setTextureSize(64, 64);
Left_Toe.mirror = true;
setRotation(Left_Toe, 0F, 0F, 0F);
Right_Toe = new ModelRenderer(this, 41, 56);
Right_Toe.addBox(-2F, 0F, -1F, 3, 1, 1);
Right_Toe.setRotationPoint(-3F, 23F, -3F);
Right_Toe.setTextureSize(64, 64);
Right_Toe.mirror = true;
setRotation(Right_Toe, 0F, 0F, 0F);
Left_Leg = new ModelRenderer(this, 54, 48);
Left_Leg.addBox(-1F, 0F, -1F, 2, 4, 2);
Left_Leg.setRotationPoint(3F, 18F, -1F);
Left_Leg.setTextureSize(64, 64);
Left_Leg.mirror = true;
setRotation(Left_Leg, 0.1487144F, 0F, 0F);
Biggieleft = new ModelRenderer(this, 56, 44);
Biggieleft.addBox(-1F, 0F, -1F, 1, 1, 1);
Biggieleft.setRotationPoint(3F, 23F, -4F);
Biggieleft.setTextureSize(64, 64);
Biggieleft.mirror = true;
setRotation(Biggieleft, 0F, -0.4089647F, 0F);
pinkieleft = new ModelRenderer(this, 56, 44);
pinkieleft.addBox(0F, 0F, -1F, 1, 1, 1);
pinkieleft.setRotationPoint(4F, 23F, -4F);
pinkieleft.setTextureSize(64, 64);
pinkieleft.mirror = true;
setRotation(pinkieleft, 0F, 0.3717861F, 0F);
Biggieright = new ModelRenderer(this, 43, 44);
Biggieright.addBox(0F, 0F, -1F, 1, 1, 1);
Biggieright.setRotationPoint(-3F, 23F, -4F);
Biggieright.setTextureSize(64, 64);
Biggieright.mirror = true;
setRotation(Biggieright, 0F, 0.2602503F, 0F);
pinkieright = new ModelRenderer(this, 43, 44);
pinkieright.addBox(-1F, 0F, -1F, 1, 1, 1);
pinkieright.setRotationPoint(-4F, 23F, -4F);
pinkieright.setTextureSize(64, 64);
pinkieright.mirror = true;
setRotation(pinkieright, 0F, -0.4461433F, 0F);
Right_Leg = new ModelRenderer(this, 41, 48);
Right_Leg.addBox(-1F, 0F, -1F, 2, 4, 2);
Right_Leg.setRotationPoint(-3F, 18F, -1F);
Right_Leg.setTextureSize(64, 64);
Right_Leg.mirror = true;
setRotation(Right_Leg, 0.1487144F, 0F, 0F);
Body = new ModelRenderer(this, 33, 26);
Body.addBox(-4F, -3F, -2F, 8, 7, 7);
Body.setRotationPoint(0F, 14F, 0F);
Body.setTextureSize(64, 64);
Body.mirror = true;
setRotation(Body, 0F, 0F, 0F);
neck = new ModelRenderer(this, 51, 13);
neck.addBox(-1F, -4F, -1F, 2, 4, 1);
neck.setRotationPoint(0F, 11F, -1F);
neck.setTextureSize(64, 64);
neck.mirror = true;
setRotation(neck, -0.2230717F, 0F, -0.0174533F);
Left_Arm = new ModelRenderer(this, 23, 0);
Left_Arm.addBox(0F, 0F, -5F, 1, 1, 5);
Left_Arm.setRotationPoint(4F, 11F, 0F);
Left_Arm.setTextureSize(64, 64);
Left_Arm.mirror = true;
setRotation(Left_Arm, 0F, 0F, 0F);
Right_Arm = new ModelRenderer(this, 23, 9);
Right_Arm.addBox(-1F, 0F, -5F, 1, 1, 5);
Right_Arm.setRotationPoint(-4F, 11F, 0F);
Right_Arm.setTextureSize(64, 64);
Right_Arm.mirror = true;
setRotation(Right_Arm, 0F, 0F, 0F);
Left_Hand = new ModelRenderer(this, 11, 0);
Left_Hand.addBox(0F, -2F, -3F, 1, 3, 3);
Left_Hand.setRotationPoint(4F, 12F, -5F);
Left_Hand.setTextureSize(64, 64);
Left_Hand.mirror = true;
setRotation(Left_Hand, 0F, 0F, 0F);
Right_Hand = new ModelRenderer(this, 11, 9);
Right_Hand.addBox(-1F, -1F, -3F, 1, 3, 3);
Right_Hand.setRotationPoint(-4F, 11F, -5F);
Right_Hand.setTextureSize(64, 64);
Right_Hand.mirror = true;
setRotation(Right_Hand, 0F, 0F, 0F);
finger1left = new ModelRenderer(this, 3, 26);
finger1left.addBox(0F, -2F, -1F, 1, 2, 1);
finger1left.setRotationPoint(4F, 10F, -6F);
finger1left.setTextureSize(64, 64);
finger1left.mirror = true;
setRotation(finger1left, 0F, 0F, -0.5576792F);
finger3left = new ModelRenderer(this, 3, 26);
finger3left.addBox(0F, 0F, 0F, 1, 2, 1);
finger3left.setRotationPoint(4F, 13F, -7F);
finger3left.setTextureSize(64, 64);
finger3left.mirror = true;
setRotation(finger3left, 0F, 0F, 0.5205006F);
finger3right = new ModelRenderer(this, 12, 26);
finger3right.addBox(-1F, 0F, 0F, 1, 2, 1);
finger3right.setRotationPoint(-4F, 13F, -7F);
finger3right.setTextureSize(64, 64);
finger3right.mirror = true;
setRotation(finger3right, 0F, 0F, -0.4461433F);
finger1right = new ModelRenderer(this, 12, 26);
finger1right.addBox(-1F, -2F, -1F, 1, 2, 1);
finger1right.setRotationPoint(-4F, 10F, -6F);
finger1right.setTextureSize(64, 64);
finger1right.mirror = true;
setRotation(finger1right, 0F, 0F, 0.5205006F);
finger2left = new ModelRenderer(this, 8, 37);
finger2left.addBox(0F, -1F, -2F, 1, 1, 2);
finger2left.setRotationPoint(4F, 12F, -8F);
finger2left.setTextureSize(64, 64);
finger2left.mirror = true;
setRotation(finger2left, 0F, 0.5205006F, 0F);
finger2right = new ModelRenderer(this, 8, 37);
finger2right.addBox(-1F, -1F, -2F, 1, 1, 2);
finger2right.setRotationPoint(-4F, 12F, -8F);
finger2right.setTextureSize(64, 64);
finger2right.mirror = true;
setRotation(finger2right, 0F, -0.6320364F, 0F);
}
public void render(EntityFireDrone entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5);
Head.render(f5);
Left_Foot.render(f5);
Right_Foot.render(f5);
Left_Toe.render(f5);
Right_Toe.render(f5);
Left_Leg.render(f5);
Biggieleft.render(f5);
pinkieleft.render(f5);
Biggieright.render(f5);
pinkieright.render(f5);
Right_Leg.render(f5);
Body.render(f5);
neck.render(f5);
Left_Arm.render(f5);
Right_Arm.render(f5);
Left_Hand.render(f5);
Right_Hand.render(f5);
finger1left.render(f5);
finger3left.render(f5);
finger3right.render(f5);
finger1right.render(f5);
finger2left.render(f5);
finger2right.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5, null);
}
}
Render class
package Kanohi.common;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.ModelBase;
import net.minecraft.src.RenderLiving;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderFireDrone extends RenderLiving
{
protected ModelFireDrone modelFireDroneMain;
protected float field_40296_d;
private ModelFireDrone FireDroneModel;
public RenderFireDrone(ModelFireDrone modelFireDrone, float f)
{
super(new ModelFireDrone(), 0.5F);
this.FireDroneModel = (ModelFireDrone) this.mainModel;
}
public void renderCow(EntityFireDrone par1EntityFireDrone, double par2, double par4, double par6, float par8, float par9)
{
super.doRenderLiving(par1EntityFireDrone, par2, par4, par6, par8, par9);
}
public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
{
renderFireDrone((EntityFireDrone)par1EntityLiving, par2, par4, par6, par8, par9);
}
private void renderFireDrone(EntityFireDrone par1EntityLiving, double par2,
double par4, double par6, float par8, float par9) {
// TODO Auto-generated method stub
}
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
renderFireDrone((EntityFireDrone)par1Entity, par2, par4, par6, par8, par9);
}
}
Entity class
package Kanohi.common;
import net.minecraft.src.EntityAISwimming;
import net.minecraft.src.EntityAIWander;
import net.minecraft.src.EntityAIWatchClosest;
import net.minecraft.src.EntityAgeable;
import net.minecraft.src.EntityAnimal;
import net.minecraft.src.EntityCreature;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IAnimals;
import net.minecraft.src.Item;
import net.minecraft.src.World;
public class EntityFireDrone extends EntityAnimal
{
private boolean isPlaying;
public EntityFireDrone(World par1World)
{
super(par1World);
this.texture="/Kanohi/Fire Drone Final.png";
this.moveSpeed = 0.4F;
isImmuneToFire = true;
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(2, new EntityAIWander(this, 0.3F));
}
protected void fall(float par1){}
protected boolean isAIEnabled()
{
return true;
}
protected boolean canDespawn()
{
return false;
}
@Override
public int getMaxHealth() {
return 20;
}
public int getTotalArmourValue()
{
return 10;
}
protected String getLivingSound()
{
return "none";
}
protected String getHurtSound()
{
return "mob.irongolem.hit";
}
protected String getDeathSound()
{
return "mob.irongolem.death";
}
protected void playStepSound(int par1, int par2, int par3, int par4)
{
this.worldObj.playSoundAtEntity(this, "mob.irongolem.walk", 1.0F, 1.0F);
}
protected int getDropItemId()
{
return Kanohi.ingotProtodermis.shiftedIndex;
}
protected void dropRareDrop(int par1)
{
switch (this.rand.nextInt(1))
{
case 0:
this.dropItem(Kanohi.staffFire.shiftedIndex,1);
break;
}
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
/* public boolean interact(EntityPlayer par1EntityPlayer)
{
if (par1World.isRemote)
{
return true;
}
else
{
TileFireDrone var10 = (TileFireDrone)par1World.getBlockTileEntity(par2, par3, par4);
if (var10 != null)
{
par5EntityPlayer.displayGUIFireDrone(var10);
}
return true;
}
}
*/
public EntityAgeable func_90011_a(EntityAgeable var1) {
// TODO Auto-generated method stub
return null;
}
}
Client proxy
package Kanohi.client;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraftforge.client.MinecraftForgeClient;
import Kanohi.common.CommonProxyKanohi;
import Kanohi.common.EntityFireDrone;
import Kanohi.common.ModelFireDrone;
import Kanohi.common.RenderFireDrone;
public class ClientProxyKanohi extends CommonProxyKanohi
{
@Override
public void init() {
MinecraftForgeClient.preloadTexture("/Kanohi/Fire Drone Final.png");
RenderingRegistry.registerEntityRenderingHandler(EntityFireDrone.class,
new RenderFireDrone(new ModelFireDrone(), 0.5F));
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
switch (ID)
{
case 0: /* your guis go here */
}
}
return tileEntity;
}
@Override
public void registerRenderThings()
{
MinecraftForgeClient.preloadTexture("/Kanohi/Fire Drone Final.png");
}
}
Common proxy
package Kanohi.common;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class CommonProxyKanohi implements IGuiHandler
{
@Override
public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
@Override
public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity != null)
{
switch (ID)
{
case 0: //ContainerFireDrone;
}
}
return tileEntity;
}
public static String TEXTURE_FIREDRONE = "/Kanohi/Fire Drone Final.png";
public void init(){
}
public void registerRenderThings(){};
{
}
public void RegisterRenderInformation()
{
}
}
I appreciate any help you may be able to give me
Ermmmm....anyone else?
I tried putting in the exact same values as IAnimals for my mobs as well as implenting IAnimals to all of my mobs however I still get this lagging entity problem.... while my character walks without any lag and can break blocks without any lag. It's really weird and really frustrating, because I cant seem to find a solution. Could it be that Entity tracking for mod entities is broken? However I can conclude that it DOES affect the entity tracking of the mobs, because a higher number equals a larger step for each entity tracking tick.
I myself only get the problem when I unleash 300 + mobs. However other players need lower amounts to get the problem. There must be something I'm doing wrong, but I just can't find it.
Looking into DrZharks mod file, it seems that he just registers both a mod and global entity for the same entity and uses a range of 128 and updatefreq of 1, which doesnt make any sense. So references won't help me.....
>.< T_T
If you are getting a lag then it's most likely a high update frequency. How are you registering entities?
The arguments left to right are, EntityClass, EntityName, Id, mod, viewDistance, updateFrequency, and track motion.
When registering global entities, IAnimals interface is important but in Forge you always add your own tracking data. Adding it won't effect how an entity is tracked.
I wouldn't use him as a reference or anyone else unless it's an example mod.
I'm very interested in changing the vanilla tracking distance, specifically for Villagers. Do you know of any safe way to do this (using Forge)? I've tried a few methods of removing and re-adding the entities and can't find a good solution.
http://www.minecraft...ob-performance/