use of moriyashiine.bewitchment.common.entity.projectile.HornedSpearEntity in project bewitchment by MoriyaShiine.
the class ClientPlayNetworkHandlerMixin method onEntitySpawn.
@Inject(method = "onEntitySpawn", at = @At("TAIL"))
private void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo callbackInfo) {
EntityType<?> type = packet.getEntityTypeId();
double x = packet.getX();
double y = packet.getY();
double z = packet.getZ();
Entity entity = null;
if (type == BWEntityTypes.JUNIPER_BROOM) {
entity = new JuniperBroomEntity(BWEntityTypes.JUNIPER_BROOM, world);
} else if (type == BWEntityTypes.CYPRESS_BROOM) {
entity = new BroomEntity(BWEntityTypes.CYPRESS_BROOM, world);
} else if (type == BWEntityTypes.ELDER_BROOM) {
entity = new ElderBroomEntity(BWEntityTypes.ELDER_BROOM, world);
} else if (type == BWEntityTypes.DRAGONS_BLOOD_BROOM) {
entity = new DragonsBloodBroomEntity(BWEntityTypes.DRAGONS_BLOOD_BROOM, world);
} else if (type == BWEntityTypes.SILVER_ARROW) {
entity = new SilverArrowEntity(world, x, y, z);
} else if (type == BWEntityTypes.HORNED_SPEAR) {
entity = new HornedSpearEntity(world, x, y, z);
}
if (entity != null) {
if (entity instanceof PersistentProjectileEntity) {
Entity owner = world.getEntityById(packet.getEntityData());
if (owner != null) {
((PersistentProjectileEntity) entity).setOwner(owner);
}
}
int id = packet.getId();
entity.updateTrackedPosition(x, y, z);
entity.refreshPositionAfterTeleport(x, y, z);
entity.setPitch((float) (packet.getPitch() * 360) / 256f);
entity.setYaw((float) (packet.getYaw() * 360) / 256f);
entity.setId(id);
entity.setUuid(packet.getUuid());
world.addEntity(id, entity);
}
}
use of moriyashiine.bewitchment.common.entity.projectile.HornedSpearEntity in project bewitchment by MoriyaShiine.
the class SyncHornedSpearPacket method handle.
public static void handle(MinecraftClient client, ClientPlayNetworkHandler network, PacketByteBuf buf, PacketSender sender) {
int entityId = buf.readInt();
ItemStack spear = buf.readItemStack();
client.execute(() -> ((HornedSpearEntity) client.world.getEntityById(entityId)).spear = spear);
}
Aggregations