Plaigon Posted April 26, 2017 Posted April 26, 2017 (edited) Hi, I'm trying to have identical value of size field (with data manager), but nothing works. My current code : public class EntityMutant extends EntityMob { private static final ItemStack defaultHeldItem; private static final DataParameter<Float> SIZE = EntityDataManager.<Float>createKey(EntityMutant.class, DataSerializers.FLOAT); public EntityMutant(World world) { super(world); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIAttackMelee(this, 0.5D, false)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.30D)); this.tasks.addTask(7, new EntityAIWander(this, 0.30D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[0])); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); } protected void entityInit() { super.entityInit(); this.dataManager.register(SIZE, Float.valueOf(1.0F)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(2.0D); } public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); compound.setFloat("Size", this.getSize()); } @Override public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); this.setCustomSize(compound.getFloat("Size")); } public int getTotalArmorValue() { return 2; } protected boolean canDespawn() { return false; } protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_ZOMBIE_AMBIENT; } protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_ZOMBIE_HURT; } protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_ZOMBIE_DEATH; } public EnumCreatureAttribute getCreatureAttribute() { return EnumCreatureAttribute.UNDEAD; } public void onUpdate() { super.onUpdate(); if(this.getAge() == 10) this.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(this)), (IEntityLivingData)null); } public void onLivingUpdate() { super.onLivingUpdate(); if(this.worldObj.isRemote && this.worldObj.getTotalWorldTime() % 4 * 20 == 0) { this.setCustomSize(this.getSize() + 1); this.getDataManager().setDirty(this.SIZE); } System.out.println("Side = " + this.worldObj.isRemote); System.out.println("size = " + this.getSize()); } @Override protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) { super.setEquipmentBasedOnDifficulty(difficulty); this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, defaultHeldItem); } @Override public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) { livingdata = super.onInitialSpawn(difficulty, livingdata); this.setEquipmentBasedOnDifficulty(difficulty); return livingdata; } /** * Returns the item that this EntityLiving is holding, if any. */ public ItemStack getHeldItem() { return defaultHeldItem; } public float getSize() { return this.dataManager.get(SIZE); } public void setCustomSize(float newSize) { this.dataManager.set(SIZE, newSize); } static { defaultHeldItem = new ItemStack(Items.WOODEN_AXE, 1); } } Thx in advance. Plaigon Edited April 26, 2017 by Plaigon Quote
Plaigon Posted April 26, 2017 Author Posted April 26, 2017 Yes, sorry. The server doesn't know the right value of size. Here is the output : [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 2.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 2.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 2.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 3.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 3.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 3.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 3.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 4.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 4.0 [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:19] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 4.0 [19:27:19] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 4.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 4.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 4.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 4.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 5.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 5.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 5.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 5.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 6.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 6.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 6.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 6.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:20] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 7.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:20] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:21] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:21] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:21] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:21] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:21] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = false [19:27:21] [Server thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 1.0 [19:27:21] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:120]: Side = true [19:27:21] [Client thread/INFO] [STDOUT]: [fr.plaigon.uranium.common.entity.agressive.EntityMutant:onLivingUpdate:121]: size = 7.0 Quote
Plaigon Posted April 26, 2017 Author Posted April 26, 2017 Thanks. I didn't know this speficity ! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.