Fix custom item entities not showing on the client

Fix crystal growth not syncing
This commit is contained in:
Sebastian Hartte
2020-06-13 20:25:00 +02:00
parent b9381fc2e1
commit 0db7e70722
19 changed files with 111 additions and 51 deletions
@@ -39,9 +39,11 @@ import appeng.api.features.AEFeature;
import appeng.util.Platform;
public final class EntityGrowingCrystal extends ItemEntity
public final class EntityGrowingCrystal extends AEBaseEntityItem
{
public static EntityType<EntityGrowingCrystal> TYPE;
private int progress_1000 = 0;
public EntityGrowingCrystal(EntityType<? extends EntityGrowingCrystal> type, World world) {
@@ -50,7 +52,7 @@ public final class EntityGrowingCrystal extends ItemEntity
public EntityGrowingCrystal(final World w, final double x, final double y, final double z, final ItemStack is )
{
super( w, x, y, z, is );
super( TYPE, w, x, y, z, is );
this.setNoDespawn();
}
@@ -143,7 +145,10 @@ public final class EntityGrowingCrystal extends ItemEntity
if( this.progress_1000 > 1000 )
{
this.progress_1000 -= 1000;
this.setItem( cry.triggerGrowth( is ) );
// We need to copy the stack or the change detection will not work and not sync
// this new stack to the client
ItemStack newItem = cry.triggerGrowth(is.copy());
this.setItem(newItem);
}
}
}
@@ -195,4 +200,11 @@ public final class EntityGrowingCrystal extends ItemEntity
return te instanceof ICrystalGrowthAccelerator && ( (ICrystalGrowthAccelerator) te ).isPowered();
}
// Don't let seeds "float" on water surface
@Override
protected void applyFloatMotion() {
}
}