Posted May 2, 20214 yr My custom entity: public class BeamAttackEntity extends Entity { private Vec3d to; private int lifeTicksRemaining; private Entity sourceEntity; public BeamAttackEntity(EntityType<? extends BeamAttackEntity> entityType, World world) { super(entityType, world); } public BeamAttackEntity(Vec3d from, Vec3d to, int lifeTicks, World world) { super(ModEntityTypes.BEAM_ATTACK.get(), world); this.setPosition(from.x, from.y, from.z); this.to = to; this.lifeTicksRemaining = lifeTicks; this.sourceEntity = null; } public BeamAttackEntity(Entity sourceEntity, Vec3d to, int lifeTicks, World world) { super(ModEntityTypes.BEAM_ATTACK.get(), world); Vec3d entityPos = sourceEntity.getPositionVec(); this.setPosition(entityPos.x, entityPos.y, entityPos.z); this.to = to; this.lifeTicksRemaining = lifeTicks; } @Override protected void registerData() { } @Override protected void readAdditional(CompoundNBT compound) { } @Override protected void writeAdditional(CompoundNBT compound) { final CompoundNBT beamData = new CompoundNBT(); } @Override public IPacket<?> createSpawnPacket() { return new SSpawnObjectPacket(this); } @Override public void tick() { CelticShift.LOGGER.info("in entity {}", this.lifeTicksRemaining); if (this.lifeTicksRemaining > 0) { this.lifeTicksRemaining--; } else { this.remove(); } } public int getLifeTicksRemaining() { return this.lifeTicksRemaining; } } Deferred registry: public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, CelticShift.MOD_ID); public static final RegistryObject<EntityType<BeamAttackEntity>> BEAM_ATTACK = ENTITY_TYPES.register("beam_attack", () -> EntityType.Builder.<BeamAttackEntity>create(BeamAttackEntity::new, EntityClassification.MISC) .size(0.5f, 0.5f) .build(new ResourceLocation(CelticShift.MOD_ID, "beam_attack").toString())); Context in which I'm spawning it (in the AI goal for another, functional entity -- modeled after how the Ghast spawns fireballs): BeamAttackEntity beamAttackEntity = new BeamAttackEntity(this.subject, this.subject.getPositionVec().add(10, 0, 10), 30, world); world.addEntity(beamAttackEntity); What I am observing is that the logger message in the entity class prints out for the server, but not the client. There's also no evidence (using dev tools, since I do not have a renderer set up yet) that the entity is coming client side at all. Am I missing a step somewhere? Edited May 2, 20214 yr by Woodside solved
May 2, 20214 yr The Spawn Packet must be made with the static function in NetworkHooks, do not use the vanilla packet. That should solve the problem.
May 2, 20214 yr Author 18 minutes ago, Curle said: The Spawn Packet must be made with the static function in NetworkHooks, do not use the vanilla packet. That should solve the problem. 19 minutes ago, diesieben07 said: SSpawnObjectPacket only works for vanilla entities. You have to use NetworkHooks.getEntitySpawningPacket. Grand. Thank you both!
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.