Search in sources :

Example 1 with HornedSpearEntity

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);
    }
}
Also used : Entity(net.minecraft.entity.Entity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) DragonsBloodBroomEntity(moriyashiine.bewitchment.common.entity.DragonsBloodBroomEntity) SilverArrowEntity(moriyashiine.bewitchment.common.entity.projectile.SilverArrowEntity) BroomEntity(moriyashiine.bewitchment.api.entity.BroomEntity) ElderBroomEntity(moriyashiine.bewitchment.common.entity.ElderBroomEntity) JuniperBroomEntity(moriyashiine.bewitchment.common.entity.JuniperBroomEntity) HornedSpearEntity(moriyashiine.bewitchment.common.entity.projectile.HornedSpearEntity) ElderBroomEntity(moriyashiine.bewitchment.common.entity.ElderBroomEntity) DragonsBloodBroomEntity(moriyashiine.bewitchment.common.entity.DragonsBloodBroomEntity) BroomEntity(moriyashiine.bewitchment.api.entity.BroomEntity) ElderBroomEntity(moriyashiine.bewitchment.common.entity.ElderBroomEntity) JuniperBroomEntity(moriyashiine.bewitchment.common.entity.JuniperBroomEntity) SilverArrowEntity(moriyashiine.bewitchment.common.entity.projectile.SilverArrowEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) HornedSpearEntity(moriyashiine.bewitchment.common.entity.projectile.HornedSpearEntity) JuniperBroomEntity(moriyashiine.bewitchment.common.entity.JuniperBroomEntity) DragonsBloodBroomEntity(moriyashiine.bewitchment.common.entity.DragonsBloodBroomEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with HornedSpearEntity

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);
}
Also used : HornedSpearEntity(moriyashiine.bewitchment.common.entity.projectile.HornedSpearEntity) ItemStack(net.minecraft.item.ItemStack)

Aggregations

HornedSpearEntity (moriyashiine.bewitchment.common.entity.projectile.HornedSpearEntity)2 BroomEntity (moriyashiine.bewitchment.api.entity.BroomEntity)1 DragonsBloodBroomEntity (moriyashiine.bewitchment.common.entity.DragonsBloodBroomEntity)1 ElderBroomEntity (moriyashiine.bewitchment.common.entity.ElderBroomEntity)1 JuniperBroomEntity (moriyashiine.bewitchment.common.entity.JuniperBroomEntity)1 SilverArrowEntity (moriyashiine.bewitchment.common.entity.projectile.SilverArrowEntity)1 Entity (net.minecraft.entity.Entity)1 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)1 ItemStack (net.minecraft.item.ItemStack)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1