Search in sources :

Example 1 with Monster

use of net.minecraft.entity.mob.Monster in project MCDungeonsWeapons by chronosacaria.

the class ProspectorEnchantmentMixin method onProspectorEnchantmentKill.

@Inject(at = @At("HEAD"), method = "onDeath", cancellable = true)
private void onProspectorEnchantmentKill(DamageSource source, CallbackInfo ci) {
    if (!(source.getAttacker() instanceof PlayerEntity))
        return;
    LivingEntity user = (LivingEntity) source.getAttacker();
    LivingEntity target = (LivingEntity) (Object) this;
    ItemStack mainHandStack = null;
    if (user != null) {
        mainHandStack = user.getMainHandStack();
    }
    if (McdwEnchantsConfig.getValue("prospector")) {
        if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.PROSPECTOR, mainHandStack) >= 1)) {
            int level = EnchantmentHelper.getLevel(EnchantsRegistry.PROSPECTOR, mainHandStack);
            float prospectorChance = 0.05F * level;
            float prospectorRand = user.getRandom().nextFloat();
            if (prospectorRand <= prospectorChance) {
                if (target instanceof Monster) {
                    ItemEntity emeraldDrop = new ItemEntity(target.world, target.getX(), target.getY(), target.getZ(), new ItemStack(Items.EMERALD, 1));
                    user.world.spawnEntity(emeraldDrop);
                }
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ItemEntity(net.minecraft.entity.ItemEntity) Monster(net.minecraft.entity.mob.Monster) ItemStack(net.minecraft.item.ItemStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with Monster

use of net.minecraft.entity.mob.Monster in project KiwiClient by TangyKiwi.

the class Nametags method onWorldRender.

@Subscribe
@AllowConcurrentEvents
public void onWorldRender(WorldRenderEvent.Post event) {
    for (Entity entity : mc.world.getEntities()) {
        Vec3d rPos = entity.getPos().subtract(RenderUtils.getInterpolationOffset(entity)).add(0, entity.getHeight(), 0);
        double d = entity.squaredDistanceTo(mc.cameraEntity);
        if (!(d > 4096.0D)) {
            float scale = 1f;
            if (Math.sqrt(d) > 10)
                scale *= Math.sqrt(d) / 10;
            if (entity instanceof ItemEntity && getSetting(3).asToggle().state) {
                ItemEntity itemEntity = (ItemEntity) entity;
                String name = itemEntity.getName().getString();
                String customName = itemEntity.getStack().getName().getString();
                String amount = "[x" + itemEntity.getStack().getCount() + "]";
                if (!customName.equals(name)) {
                    double up = 0.7 + 0.9 * (Math.sqrt(d / 4096));
                    RenderUtils.drawWorldText(name + " " + getEmptyString(amount), rPos.x, rPos.y + up, rPos.z, scale, 0xFFAA00, true);
                    RenderUtils.drawWorldText(getEmptyString(name) + " " + amount, rPos.x, rPos.y + up, rPos.z, scale, 0xFFFF55, true);
                    RenderUtils.drawWorldText(customName, rPos.x, rPos.y + 0.5, rPos.z, scale, 0xFFAA00, true);
                } else {
                    // RenderUtils.drawWorldText("\u00a76" + name + " " + "\u00a7e" + amount, rPos.x, rPos.y + 0.5, rPos.z, scale, -1, true);
                    RenderUtils.drawWorldText(name + " " + getEmptyString(amount), rPos.x, rPos.y + 0.5, rPos.z, scale, 0xFFAA00, true);
                    RenderUtils.drawWorldText(getEmptyString(name) + " " + amount, rPos.x, rPos.y + 0.5, rPos.z, scale, 0xFFFF55, true);
                }
            } else if (entity instanceof LivingEntity) {
                if (entity == mc.player || entity.hasPassenger(mc.player) || mc.player.hasPassenger(entity)) {
                    continue;
                }
                if ((EntityUtils.isAnimal(entity) && getSetting(1).asToggle().state) || (entity instanceof Monster && getSetting(2).asToggle().state) || (entity instanceof PlayerEntity && getSetting(0).asToggle().state) || (entity instanceof ItemEntity && getSetting(3).asToggle().state)) {
                    LivingEntity livingEntity = (LivingEntity) entity;
                    String name = livingEntity.getName().getString();
                    String health = String.format("%.1f", livingEntity.getHealth());
                    RenderUtils.drawWorldText(name + " " + getEmptyString(health), rPos.x, rPos.y + 0.5, rPos.z, scale, 0xFFFFFF, true);
                    RenderUtils.drawWorldText(getEmptyString(name) + " " + health, rPos.x, rPos.y + 0.5, rPos.z, scale, getHealthColor(livingEntity), true);
                    int armorAmount = 0;
                    for (ItemStack i : livingEntity.getArmorItems()) {
                        if (!i.isEmpty()) {
                            armorAmount++;
                        }
                    }
                    double c = -3 + 0.5 * (4 - armorAmount);
                    double lscale = scale * 0.4;
                    double up = 0.7 + 0.9 * (Math.sqrt(d / 4096));
                    int height = 0;
                    height = Math.min(height, drawItem(rPos.x, rPos.y + up, rPos.z, 0.5 * (armorAmount + 1), 0, lscale, livingEntity.getEquippedStack(EquipmentSlot.MAINHAND)));
                    height = Math.min(height, drawItem(rPos.x, rPos.y + up, rPos.z, -0.5 * (armorAmount + 1), 0, lscale, livingEntity.getEquippedStack(EquipmentSlot.OFFHAND)));
                    for (ItemStack i : livingEntity.getArmorItems()) {
                        height = Math.min(height, drawItem(rPos.x, rPos.y + up, rPos.z, c + 1.5, 0, lscale, i));
                        if (!i.isEmpty()) {
                            c++;
                        }
                    }
                }
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ItemEntity(net.minecraft.entity.ItemEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ItemEntity(net.minecraft.entity.ItemEntity) Monster(net.minecraft.entity.mob.Monster) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with Monster

use of net.minecraft.entity.mob.Monster 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)

Aggregations

ItemEntity (net.minecraft.entity.ItemEntity)3 LivingEntity (net.minecraft.entity.LivingEntity)3 Monster (net.minecraft.entity.mob.Monster)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 Entity (net.minecraft.entity.Entity)2 ItemStack (net.minecraft.item.ItemStack)2 Vec3d (net.minecraft.util.math.Vec3d)2 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)1 Subscribe (com.google.common.eventbus.Subscribe)1 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)1 FoxEntity (net.minecraft.entity.passive.FoxEntity)1 HorseBaseEntity (net.minecraft.entity.passive.HorseBaseEntity)1 TameableEntity (net.minecraft.entity.passive.TameableEntity)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1