ok i took a look at both client & server code for the Wolf. I found i'm using datawatchers already in the same way wolf.class does. So is there a special way to use datawatcher to get them to link from server to client.
here is client side EntityGuard class
package net.minecraft.src.GSM;
import java.util.*;
import net.minecraft.src.*;
public class EntityGuardBase extends EntityCreature {
/** How much damage this mob's attacks deal */
protected static int attackStrength;
public static int team;
public static int type;
public EntityGuardBase(World par1World)
{
this(par1World,1, 1);
}
public EntityGuardBase(World par1World, int Team, int Type)
{
super(par1World);
attackStrength = 5;
experienceValue = 5;
this.moveSpeed = 0.3F;
team = Team;
type = Type;
this.setProfession(Type);
this.setTeam(Team);
this.setTextureTeamType();
//tasks
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAvoidEntity(this, EntityCreeper.class, 2.0F, 0.3F, 0.35F));
if(Type == 1){this.tasks.addTask(3, new EntityAIArrowAttack(this, this.moveSpeed, 1, 50));}
this.tasks.addTask(9, new EntityAIWander(this, this.moveSpeed));
this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityMob.class, 16.0F, 0, true));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, false));
}
public void setTextureTeamType() {
texture = "/mob/char.png";
if(this.getTeam() ==1)
{
texture = "/GSM/NPC/Red" + this.getProfession() + ".png";
}
if(this.getTeam() == 2)
{
texture = "/GSM/NPC/Blue" + this.getProfession() + ".png";
}
}
protected boolean canDespawn()
{
return false;
}
public void onLivingUpdate(){super.onLivingUpdate();}
public void onUpdate(){
super.onUpdate();
if(worldObj.isRemote)
{
updateFromSmp();
}
}
public boolean getCanSpawnHere(){return true;}
public int getMaxHealth(){return 50;}
public boolean isAIEnabled(){return true;}
protected Entity findPlayerToAttack()
{
EntityPlayer entityplayer = worldObj.getClosestVulnerablePlayerToEntity(this, 16D);
if (entityplayer != null && canEntityBeSeen(entityplayer))
{
return entityplayer;
}
else
{
return null;
}
}
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
if (super.attackEntityFrom(par1DamageSource, par2))
{
Entity entity = par1DamageSource.getEntity();
if (riddenByEntity == entity || ridingEntity == entity)
{
return true;
}
if (entity != this || entity.entityId != this.entityId )
{
entityToAttack = entity;
}
return true;
}
else
{
return false;
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = attackStrength;
if (isPotionActive(Potion.damageBoost))
{
i += 3 << getActivePotionEffect(Potion.damageBoost).getAmplifier();
}
if (isPotionActive(Potion.weakness))
{
i -= 2 << getActivePotionEffect(Potion.weakness).getAmplifier();
}
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), i);
}
protected void attackEntity(Entity par1Entity, float par2)
{
if (attackTime <= 0 && par2 < 2.0F && par1Entity.boundingBox.maxY > boundingBox.minY && par1Entity.boundingBox.minY < boundingBox.maxY)
{
attackTime = 20;
attackEntityAsMob(par1Entity);
}
}
public float getBlockPathWeight(int par1, int par2, int par3)
{
return 0.5F + worldObj.getLightBrightness(par1, par2, par3);
}
//Write
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("Profession", this.getProfession());
par1NBTTagCompound.setInteger("Team", this.getTeam());
}
//Read
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setProfession(par1NBTTagCompound.getInteger("Profession"));
this.setTeam(par1NBTTagCompound.getInteger("Team"));
this.setTextureTeamType();
this.getHeldItem();
}
public void updateFromSmp()
{
setTeam(net.minecraft.src.mod_Guardsman.coords[0]);
setProfession(net.minecraft.src.mod_Guardsman.coords[1]);
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(20, Integer.valueOf(0));
this.dataWatcher.addObject(21, Integer.valueOf(0));
}
public void setProfession(int par1)
{
this.dataWatcher.updateObject(20, Integer.valueOf(par1));
}
public int getProfession()
{
return this.dataWatcher.getWatchableObjectInt(20);
}
public void setTeam(int par1)
{
this.dataWatcher.updateObject(21, Integer.valueOf(par1));
}
public int getTeam()
{
return this.dataWatcher.getWatchableObjectInt(21);
}
@Override
public ItemStack getHeldItem()
{
if(this.getProfession() == 1)
{
return new ItemStack(Item.bow, 1);
}
else
{
return null;
}
}
}
And here is the server side
package net.minecraft.src.GSM;
import java.io.*;
import java.util.*;
import net.minecraft.src.*;
public class EntityGuardBase extends EntityCreature implements IAnimals {
/** How much damage this mob's attacks deal */
protected static int attackStrength;
public static int team;
public static int type;
public EntityGuardBase(World par1World)
{
this(par1World,1, 1);
}
public EntityGuardBase(World par1World, int Team, int Type)
{
super(par1World);
attackStrength = 5;
experienceValue = 5;
this.moveSpeed = 0.3F;
team = Team;
type = Type;
this.setProfession(Type);
this.setTeam(Team);
//tasks
this.tasks.addTask(2, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAvoidEntity(this, EntityCreeper.class, 2.0F, 0.3F, 0.35F));
if(Type == 1){this.tasks.addTask(3, new EntityAIArrowAttack(this, this.moveSpeed, 1, 50));}
this.tasks.addTask(9, new EntityAIWander(this, this.moveSpeed));
this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, IMob.class, 16.0F, 0, true));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, false));
}
private String[] getTeamList() {
if(getTeam() == 1)
{
return net.minecraft.src.GSM.ConfigMaker.red;
}
if(getTeam() == 2)
{
return net.minecraft.src.GSM.ConfigMaker.blue;
}
return null;
}
public void SendType(int i, int j, Entity entity)
{
int k = entity.entityId;
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
DataOutputStream data = new DataOutputStream(bytes);
try
{
int[] coords = {i, j, k};
for(int a = 0; a < 3; a++)
{
data.writeInt(coords[a]);
}
}
catch(IOException e)
{
e.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "mod_Guardsman"; // CHANNEL MAX 16 CHARS
packet.data = bytes.toByteArray();
packet.length = packet.data.length;
ModLoader.getMinecraftServerInstance().configManager.sendPacketToAllPlayers(packet);
}
protected boolean canDespawn()
{
return false;
}
public void onLivingUpdate(){super.onLivingUpdate();}
public void onUpdate(){
super.onUpdate();
findPlayerToAttack();
SendType(getTeam(), getProfession(), this);
}
public boolean getCanSpawnHere(){return true;}
public int getMaxHealth(){return 50;}
public boolean isAIEnabled(){return true;}
protected Entity findPlayerToAttack()
{
EntityPlayer entityplayer = worldObj.getClosestVulnerablePlayerToEntity(this, 16D);
if (entityplayer != null && canEntityBeSeen(entityplayer))
{
if(getTeam() == 1)
{
for(int j = 0; j > 21; j++)
{
if (entityplayer.username.equals(net.minecraft.src.GSM.ConfigMaker.red[j]))
{
return null;
}
}
}
if(getTeam() == 2)
{
for(int j = 0; j > 21; j++)
{
if (entityplayer.username.equals(net.minecraft.src.GSM.ConfigMaker.blue[j]))
{
return null;
}
}
}
}
return entityplayer;
}
private boolean compareNameToTeam (String name, String[] Team)
{
if (Team != null && name != null )
{
}
return true;
}
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
{
if (super.attackEntityFrom(par1DamageSource, par2))
{
Entity entity = par1DamageSource.getEntity();
if (riddenByEntity == entity || ridingEntity == entity)
{
return true;
}
if (entity != this || entity.entityId != this.entityId )
{
entityToAttack = entity;
}
return true;
}
else
{
return false;
}
}
public boolean attackEntityAsMob(Entity par1Entity)
{
int i = attackStrength;
if (isPotionActive(Potion.damageBoost))
{
i += 3 << getActivePotionEffect(Potion.damageBoost).getAmplifier();
}
if (isPotionActive(Potion.weakness))
{
i -= 2 << getActivePotionEffect(Potion.weakness).getAmplifier();
}
return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), i);
}
protected void attackEntity(Entity par1Entity, float par2)
{
if (attackTime <= 0 && par2 < 2.0F && par1Entity.boundingBox.maxY > boundingBox.minY && par1Entity.boundingBox.minY < boundingBox.maxY)
{
attackTime = 20;
attackEntityAsMob(par1Entity);
}
}
public float getBlockPathWeight(int par1, int par2, int par3)
{
return 0.5F + worldObj.getLightBrightness(par1, par2, par3);
}
//Write
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeEntityToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("Profession", this.getProfession());
par1NBTTagCompound.setInteger("Team", this.getTeam());
}
//Read
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readEntityFromNBT(par1NBTTagCompound);
this.setProfession(par1NBTTagCompound.getInteger("Profession"));
this.setTeam(par1NBTTagCompound.getInteger("Team"));
this.getHeldItem();
}
protected void entityInit()
{
super.entityInit();
this.dataWatcher.addObject(20, Integer.valueOf(0));
this.dataWatcher.addObject(21, Integer.valueOf(0));
}
public void setProfession(int par1)
{
this.dataWatcher.updateObject(20, Integer.valueOf(par1));
}
public int getProfession()
{
return this.dataWatcher.getWatchableObjectInt(20);
}
public void setTeam(int par1)
{
this.dataWatcher.updateObject(21, Integer.valueOf(par1));
}
public int getTeam()
{
return this.dataWatcher.getWatchableObjectInt(21);
}
public ItemStack getHeldItem()
{
if(this.getProfession() == 1)
{
return new ItemStack(Item.bow, 1);
}
else
{
return null;
}
}
}