Search in sources :

Example 1 with FoxEntity

use of net.minecraft.entity.passive.FoxEntity in project WK by witches-kitchen.

the class PhasingStatusEffect method applyUpdateEffect.

@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
    World world = entity.getEntityWorld();
    if (!world.isClient) {
        double d = entity.getX();
        double e = entity.getY();
        double f = entity.getZ();
        for (int i = 0; i < 16; ++i) {
            double g = entity.getX() + (entity.getRandom().nextDouble() - 0.5D) * 16.0D;
            double h = MathHelper.clamp(entity.getY() + (double) (entity.getRandom().nextInt(16) - 8), world.getBottomY(), world.getBottomY() + ((ServerWorld) world).getLogicalHeight() - 1);
            double j = entity.getZ() + (entity.getRandom().nextDouble() - 0.5D) * 16.0D;
            if (entity.hasVehicle()) {
                entity.stopRiding();
            }
            if (entity.teleport(g, h, j, true)) {
                SoundEvent soundEvent = entity instanceof FoxEntity ? SoundEvents.ENTITY_FOX_TELEPORT : SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT;
                world.playSound(null, d, e, f, soundEvent, SoundCategory.PLAYERS, 1.0F, 1.0F);
                entity.playSound(soundEvent, 1.0F, 1.0F);
                break;
            }
        }
    }
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) FoxEntity(net.minecraft.entity.passive.FoxEntity) World(net.minecraft.world.World) ServerWorld(net.minecraft.server.world.ServerWorld)

Example 2 with FoxEntity

use of net.minecraft.entity.passive.FoxEntity in project Arclight by IzzelAliz.

the class FoxEntity_MateGoalMixin method spawnBaby.

/**
 * @author IzzekAkuz
 * @reason
 */
@Overwrite
protected void spawnBaby() {
    FoxEntity foxentity = (FoxEntity) this.animal.createChild(this.targetMate);
    if (foxentity != null) {
        ServerPlayerEntity serverplayerentity = this.animal.getLoveCause();
        ServerPlayerEntity serverplayerentity1 = this.targetMate.getLoveCause();
        ServerPlayerEntity serverplayerentity2 = serverplayerentity;
        if (serverplayerentity != null) {
            ((FoxEntityBridge) foxentity).bridge$addTrustedUUID(serverplayerentity.getUniqueID());
        } else {
            serverplayerentity2 = serverplayerentity1;
        }
        if (serverplayerentity1 != null && serverplayerentity != serverplayerentity1) {
            ((FoxEntityBridge) foxentity).bridge$addTrustedUUID(serverplayerentity1.getUniqueID());
        }
        int experience = this.animal.getRNG().nextInt(7) + 1;
        final EntityBreedEvent entityBreedEvent = CraftEventFactory.callEntityBreedEvent(foxentity, this.animal, this.targetMate, serverplayerentity, ((AnimalEntityBridge) this.animal).bridge$getBreedItem(), experience);
        if (entityBreedEvent.isCancelled()) {
            return;
        }
        experience = entityBreedEvent.getExperience();
        if (serverplayerentity2 != null) {
            serverplayerentity2.addStat(Stats.ANIMALS_BRED);
            CriteriaTriggers.BRED_ANIMALS.trigger(serverplayerentity2, this.animal, this.targetMate, foxentity);
        }
        int i = 6000;
        this.animal.setGrowingAge(6000);
        this.targetMate.setGrowingAge(6000);
        this.animal.resetInLove();
        this.targetMate.resetInLove();
        foxentity.setGrowingAge(-24000);
        foxentity.setLocationAndAngles(this.animal.posX, this.animal.posY, this.animal.posZ, 0.0F, 0.0F);
        ((WorldBridge) this.world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.BREEDING);
        this.world.addEntity(foxentity);
        this.world.setEntityState(this.animal, (byte) 18);
        if (this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
            if (experience > 0) {
                this.world.addEntity(new ExperienceOrbEntity(this.world, this.animal.posX, this.animal.posY, this.animal.posZ, experience));
            }
        }
    }
}
Also used : EntityBreedEvent(org.bukkit.event.entity.EntityBreedEvent) WorldBridge(io.izzel.arclight.common.bridge.world.WorldBridge) FoxEntity(net.minecraft.entity.passive.FoxEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ExperienceOrbEntity(net.minecraft.entity.item.ExperienceOrbEntity) FoxEntityBridge(io.izzel.arclight.common.bridge.entity.passive.FoxEntityBridge) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 3 with FoxEntity

use of net.minecraft.entity.passive.FoxEntity in project BleachHack by BleachDrinker420.

the class Nametags method onWorldRender.

@BleachSubscribe
public void onWorldRender(EventWorldRender.Post event) {
    for (Entity entity : mc.world.getEntities()) {
        if (entity == mc.player || entity.hasPassenger(mc.player) || mc.player.hasPassenger(entity)) {
            continue;
        }
        Vec3d rPos = entity.getPos().subtract(Renderer.getInterpolationOffset(entity)).add(0, entity.getHeight() + 0.25, 0);
        if (entity instanceof PlayerEntity && getSetting(1).asToggle().getState()) {
            double scale = Math.max(getSetting(1).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
            List<Text> lines = getPlayerLines((PlayerEntity) entity);
            drawLines(rPos.x, rPos.y, rPos.z, scale, lines);
            if (getSetting(1).asToggle().getChild(1).asToggle().getState()) {
                drawItems(rPos.x, rPos.y + (lines.size() + 1) * 0.25 * scale, rPos.z, scale, getMainEquipment(entity));
            }
        } else if (EntityUtils.isAnimal(entity) && getSetting(2).asToggle().getState()) {
            double scale = Math.max(getSetting(2).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
            List<Text> lines = getAnimalLines((LivingEntity) entity);
            drawLines(rPos.x, rPos.y, rPos.z, scale, lines);
            if (getSetting(2).asToggle().getChild(1).asToggle().getState() && entity instanceof FoxEntity) {
                drawItems(rPos.x, rPos.y + (lines.size() + 1) * 0.25 * scale, rPos.z, scale, List.of(((FoxEntity) entity).getMainHandStack()));
            }
        } else if (entity instanceof Monster && getSetting(3).asToggle().getState()) {
            double scale = Math.max(getSetting(3).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
            List<Text> lines = getMobLines((LivingEntity) entity);
            drawLines(rPos.x, rPos.y, rPos.z, scale, lines);
            if (getSetting(3).asToggle().getChild(1).asToggle().getState()) {
                drawItems(rPos.x, rPos.y + (lines.size() + 1) * 0.25 * scale, rPos.z, scale, getMainEquipment(entity));
            }
        } else if (entity instanceof ItemEntity && getSetting(4).asToggle().getState()) {
            double scale = Math.max(getSetting(4).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
            List<Text> lines = getItemLines((ItemEntity) entity);
            drawLines(rPos.x, rPos.y, rPos.z, scale, lines);
        } else if (entity instanceof ArmorStandEntity && getSetting(5).asToggle().getState()) {
            double scale = Math.max(getSetting(5).asToggle().getChild(0).asSlider().getValue() * (mc.cameraEntity.distanceTo(entity) / 20), 1);
            drawItems(rPos.x, rPos.y + 0.25 * scale, rPos.z, scale, getMainEquipment(entity));
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ItemEntity(net.minecraft.entity.ItemEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) FoxEntity(net.minecraft.entity.passive.FoxEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) ItemEntity(net.minecraft.entity.ItemEntity) FoxEntity(net.minecraft.entity.passive.FoxEntity) Monster(net.minecraft.entity.mob.Monster) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with FoxEntity

use of net.minecraft.entity.passive.FoxEntity in project ChaosAwakens by ChaosAwakens.

the class RandomTeleportBlock method stepOn.

@Override
public void stepOn(World worldIn, BlockPos pos, Entity entityIn) {
    if (!worldIn.isClientSide && entityIn instanceof LivingEntity) {
        double d0 = entityIn.getX();
        double d1 = entityIn.getY();
        double d2 = entityIn.getZ();
        for (int i = 0; i < 16; ++i) {
            double d3 = entityIn.getX() + (getRNG().nextDouble() - 0.5D) * 16.0D;
            double d4 = MathHelper.clamp(entityIn.getY() + (double) (getRNG().nextInt(16) - 8), 0.0D, (worldIn.getHeight() - 1));
            double d5 = entityIn.getZ() + (getRNG().nextDouble() - 0.5D) * 16.0D;
            if (entityIn.isPassenger())
                entityIn.stopRiding();
            LivingEntity livingEntityIn = (LivingEntity) entityIn;
            EntityTeleportEvent.ChorusFruit event = ForgeEventFactory.onChorusFruitTeleport(livingEntityIn, d3, d4, d5);
            if (livingEntityIn.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) {
                SoundEvent soundevent = entityIn instanceof FoxEntity ? SoundEvents.FOX_TELEPORT : SoundEvents.CHORUS_FRUIT_TELEPORT;
                worldIn.playSound(null, d0, d1, d2, soundevent, SoundCategory.PLAYERS, 1.0F, 1.0F);
                entityIn.playSound(soundevent, 1.0F, 1.0F);
                break;
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) SoundEvent(net.minecraft.util.SoundEvent) FoxEntity(net.minecraft.entity.passive.FoxEntity) EntityTeleportEvent(net.minecraftforge.event.entity.living.EntityTeleportEvent)

Aggregations

FoxEntity (net.minecraft.entity.passive.FoxEntity)4 LivingEntity (net.minecraft.entity.LivingEntity)2 FoxEntityBridge (io.izzel.arclight.common.bridge.entity.passive.FoxEntityBridge)1 WorldBridge (io.izzel.arclight.common.bridge.world.WorldBridge)1 Entity (net.minecraft.entity.Entity)1 ItemEntity (net.minecraft.entity.ItemEntity)1 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)1 ExperienceOrbEntity (net.minecraft.entity.item.ExperienceOrbEntity)1 Monster (net.minecraft.entity.mob.Monster)1 HorseBaseEntity (net.minecraft.entity.passive.HorseBaseEntity)1 TameableEntity (net.minecraft.entity.passive.TameableEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 ServerWorld (net.minecraft.server.world.ServerWorld)1 SoundEvent (net.minecraft.sound.SoundEvent)1 SoundEvent (net.minecraft.util.SoundEvent)1 Vec3d (net.minecraft.util.math.Vec3d)1 World (net.minecraft.world.World)1 EntityTeleportEvent (net.minecraftforge.event.entity.living.EntityTeleportEvent)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1