Search in sources :

Example 1 with ArmorStandEntity

use of net.minecraft.entity.decoration.ArmorStandEntity in project MCDoom by AzureDoom.

the class SentinelDoomArmor method predicate.

private <P extends IAnimatable> PlayState predicate(AnimationEvent<P> event) {
    LivingEntity livingEntity = event.getExtraDataOfType(LivingEntity.class).get(0);
    if (livingEntity instanceof ArmorStandEntity) {
        return PlayState.STOP;
    }
    event.getController().setAnimation(new AnimationBuilder().addAnimation("idle", true));
    return PlayState.CONTINUE;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity)

Example 2 with ArmorStandEntity

use of net.minecraft.entity.decoration.ArmorStandEntity in project MCDoom by AzureDoom.

the class ZombieDoomArmor method predicate.

private <P extends IAnimatable> PlayState predicate(AnimationEvent<P> event) {
    LivingEntity livingEntity = event.getExtraDataOfType(LivingEntity.class).get(0);
    if (livingEntity instanceof ArmorStandEntity) {
        return PlayState.STOP;
    }
    event.getController().setAnimation(new AnimationBuilder().addAnimation("idle", true));
    return PlayState.CONTINUE;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity)

Example 3 with ArmorStandEntity

use of net.minecraft.entity.decoration.ArmorStandEntity in project ArmorStandEditor by Patbox.

the class Events method modifyArmorStand.

public static void modifyArmorStand(ServerPlayerEntity player, ArmorStandEntity armorStand, int val, Entity realEntity) {
    SPEInterface spei = (SPEInterface) player;
    ArmorStandEntityAccessor asea = (ArmorStandEntityAccessor) armorStand;
    double power = spei.getArmorStandEditorPower();
    int dX = spei.getArmorStandEditorXYZ() == 0 ? 1 : 0;
    int dY = spei.getArmorStandEditorXYZ() == 1 ? 1 : 0;
    int dZ = spei.getArmorStandEditorXYZ() == 2 ? 1 : 0;
    double posX = armorStand.getX();
    double posY = armorStand.getY();
    double posZ = armorStand.getZ();
    float angleChange = (float) (val * power * 30);
    EulerAngle angle;
    switch(spei.getArmorStandEditorAction()) {
        case MOVE:
            armorStand.teleport(posX + dX * power * val, posY + dY * power * val, posZ + dZ * power * val);
            break;
        case ROTATE:
            armorStand.setYaw(armorStand.getYaw(1.0F) + angleChange);
            armorStand.updatePositionAndAngles(posX, posY, posZ, armorStand.getYaw(1.0F), 0);
            break;
        case TOGGLE_GRAVITY:
            armorStand.setNoGravity(!armorStand.hasNoGravity());
            break;
        case TOGGLE_BASE:
            asea.callSetHideBasePlate(!armorStand.shouldHideBasePlate());
            break;
        case TOGGLE_SIZE:
            asea.callSetSmall(!armorStand.isSmall());
            break;
        case TOGGLE_ARMS:
            asea.callSetShowArms(!armorStand.shouldShowArms());
            break;
        case TOGGLE_VISIBILITY:
            armorStand.setInvisible(!armorStand.isInvisible());
            break;
        case MODIFY_HEAD:
            angle = armorStand.getHeadRotation();
            armorStand.setHeadRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
            break;
        case MODIFY_BODY:
            angle = armorStand.getBodyRotation();
            armorStand.setBodyRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
            break;
        case MODIFY_LEFT_ARM:
            angle = asea.getLeftArmRotation();
            armorStand.setLeftArmRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
            break;
        case MODIFY_RIGHT_ARM:
            angle = asea.getRightArmRotation();
            armorStand.setRightArmRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
            break;
        case MODIFY_LEFT_LEG:
            angle = asea.getLeftLegRotation();
            armorStand.setLeftLegRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
            break;
        case MODIFY_RIGHT_LEG:
            angle = asea.getRightLegRotation();
            armorStand.setRightLegRotation(new EulerAngle(angle.getPitch() + dX * angleChange, angle.getYaw() + dY * angleChange, angle.getRoll() + dZ * angleChange));
            break;
        case RESET_POSE:
            armorStand.setHeadRotation(new EulerAngle(0, 0, 0));
            armorStand.setBodyRotation(new EulerAngle(0, 0, 0));
            armorStand.setLeftArmRotation(new EulerAngle(0, 0, 0));
            armorStand.setRightArmRotation(new EulerAngle(0, 0, 0));
            armorStand.setLeftLegRotation(new EulerAngle(0, 0, 0));
            armorStand.setRightLegRotation(new EulerAngle(0, 0, 0));
            break;
        case FLIP_POSE:
            ArmorStandData data = new ArmorStandData(armorStand);
            armorStand.setHeadRotation(new EulerAngle(data.headRotation.getPitch(), 360 - data.headRotation.getYaw(), 360 - data.headRotation.getRoll()));
            armorStand.setBodyRotation(new EulerAngle(data.bodyRotation.getPitch(), 360 - data.bodyRotation.getYaw(), 360 - data.bodyRotation.getRoll()));
            armorStand.setRightArmRotation(new EulerAngle(data.leftArmRotation.getPitch(), 360 - data.leftArmRotation.getYaw(), 360 - data.leftArmRotation.getRoll()));
            armorStand.setLeftArmRotation(new EulerAngle(data.rightArmRotation.getPitch(), 360 - data.rightArmRotation.getYaw(), 360 - data.rightArmRotation.getRoll()));
            armorStand.setRightLegRotation(new EulerAngle(data.leftLegRotation.getPitch(), 360 - data.leftLegRotation.getYaw(), 360 - data.leftLegRotation.getRoll()));
            armorStand.setLeftLegRotation(new EulerAngle(data.rightLegRotation.getPitch(), 360 - data.rightLegRotation.getYaw(), 360 - data.rightLegRotation.getRoll()));
            break;
        case COPY:
            spei.setArmorStandEditorData(new ArmorStandData(armorStand));
            spei.setArmorStandEditorAction(EditorActions.PASTE);
            player.sendMessage(new TranslatableText("armorstandeditor.message.copied"), true);
            break;
        case PASTE:
            if (spei.getArmorStandEditorData() != null) {
                ArmorStandData base = spei.getArmorStandEditorData();
                base.apply(armorStand, player.isCreative());
                if (realEntity != null) {
                    realEntity.setCustomNameVisible(base.customNameVisible);
                    if (base.customName != null) {
                        realEntity.setCustomName(base.customName);
                    }
                    if (player.isCreative() && realEntity instanceof LivingEntity) {
                        realEntity.equipStack(EquipmentSlot.HEAD, base.headItem);
                        realEntity.equipStack(EquipmentSlot.CHEST, base.chestItem);
                        realEntity.equipStack(EquipmentSlot.LEGS, base.legsItem);
                        realEntity.equipStack(EquipmentSlot.FEET, base.feetItem);
                        realEntity.equipStack(EquipmentSlot.MAINHAND, base.mainHandItem);
                        realEntity.equipStack(EquipmentSlot.OFFHAND, base.offhandItem);
                    }
                }
                player.sendMessage(new TranslatableText("armorstandeditor.message.pasted"), true);
            }
            break;
        case INVENTORY:
            if (realEntity instanceof LivingEntity) {
                EditorGuis.openInventoryEditor(player, (LivingEntity) realEntity);
            } else {
                EditorGuis.openInventoryEditor(player, armorStand);
            }
            break;
        case RENAME:
            Entity nameTarget = realEntity != null ? realEntity : armorStand;
            EditorGuis.openRenaming(player, nameTarget);
            break;
    }
    if (realEntity != null) {
        ((EntityDisguise) realEntity).disguiseAs(armorStand);
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) LivingEntity(net.minecraft.entity.LivingEntity) ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) SPEInterface(eu.pb4.armorstandeditor.helpers.SPEInterface) ArmorStandEntityAccessor(eu.pb4.armorstandeditor.mixin.ArmorStandEntityAccessor) ArmorStandData(eu.pb4.armorstandeditor.helpers.ArmorStandData) EulerAngle(net.minecraft.util.math.EulerAngle) EntityDisguise(xyz.nucleoid.disguiselib.casts.EntityDisguise)

Example 4 with ArmorStandEntity

use of net.minecraft.entity.decoration.ArmorStandEntity in project ArmorStandEditor by Patbox.

the class ServerPlayerEntityMixin method showInvisible.

@Inject(method = "playerTick", at = @At("HEAD"))
private void showInvisible(CallbackInfo ci) {
    try {
        if (ConfigManager.getConfig().configData.holdingToolSpawnsParticles) {
            tickTimer++;
            if (tickTimer > 10 && this.getMainHandStack().getItem() == ConfigManager.getConfig().armorStandTool) {
                tickTimer = 0;
                List<ArmorStandEntity> armorStands = this.world.getEntitiesByClass(ArmorStandEntity.class, new Box(this.getBlockPos().add(10, 10, 10), this.getBlockPos().add(-10, -10, -10)), null);
                ParticleEffect particleEffect = new DustParticleEffect(0.8f, 0.2f, 0.2f, 1f);
                for (ArmorStandEntity armorStand : armorStands) {
                    this.networkHandler.sendPacket(new ParticleS2CPacket(particleEffect, false, armorStand.getX(), armorStand.getY() + armorStand.getHeight() / 2, armorStand.getZ(), 0.2f, 0.2f, 0.2f, 0.1f, 3));
                }
                List<ItemFrameEntity> itemFrames = this.world.getEntitiesByClass(ItemFrameEntity.class, new Box(this.getBlockPos().add(10, 10, 10), this.getBlockPos().add(-10, -10, -10)), null);
                ParticleEffect particleEffect2 = new DustParticleEffect(0.2f, 0.8f, 0.2f, 1f);
                for (ItemFrameEntity itemFrame : itemFrames) {
                    this.networkHandler.sendPacket(new ParticleS2CPacket(particleEffect2, false, itemFrame.getX(), itemFrame.getY() + itemFrame.getHeight() / 2, itemFrame.getZ(), 0.2f, 0.2f, 0.2f, 0.1f, 3));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DustParticleEffect(net.minecraft.particle.DustParticleEffect) ParticleEffect(net.minecraft.particle.ParticleEffect) ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) DustParticleEffect(net.minecraft.particle.DustParticleEffect) Box(net.minecraft.util.math.Box) ParticleS2CPacket(net.minecraft.network.packet.s2c.play.ParticleS2CPacket) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with ArmorStandEntity

use of net.minecraft.entity.decoration.ArmorStandEntity in project MCDungeonsWeapons by chronosacaria.

the class PlayerAttackHelper method attackTargetEntityWitCurrentOffhandItemAsSuper.

public static void attackTargetEntityWitCurrentOffhandItemAsSuper(PlayerEntity player, Entity target) {
    if (target.isAttackable() && !target.handleAttack(player)) {
        // get attack damage attribute value
        float f_attackDamage = (float) player.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE);
        float h_enchantmentEffectsTargetBonus;
        if (target instanceof LivingEntity) {
            h_enchantmentEffectsTargetBonus = EnchantmentHelper.getAttackDamage(player.getOffHandStack(), ((LivingEntity) target).getGroup());
        } else {
            h_enchantmentEffectsTargetBonus = EnchantmentHelper.getAttackDamage(player.getOffHandStack(), EntityGroup.DEFAULT);
        }
        float i_cooledAttackStrength = player.getAttackCooldownProgress(0.5F);
        f_attackDamage *= 0.2F + i_cooledAttackStrength * i_cooledAttackStrength * 0.8F;
        h_enchantmentEffectsTargetBonus *= i_cooledAttackStrength;
        if (f_attackDamage > 0.0F || h_enchantmentEffectsTargetBonus > 0.0F) {
            boolean bl_flag = i_cooledAttackStrength > 0.9F;
            boolean bl2_flag1 = false;
            int j = 0;
            j = j + EnchantmentHelper.getKnockback(player);
            if (player.isSprinting() && bl_flag) {
                player.world.playSound(null, target.getX(), target.getY(), target.getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1.0F, 1.0F);
                ++j;
                bl2_flag1 = true;
            }
            boolean bl3_flag2 = bl_flag && player.fallDistance > 0.0F && !player.isOnGround() && !player.isHoldingOntoLadder() && !player.isSwimming() && !player.hasStatusEffect(StatusEffects.BLINDNESS) && !player.hasVehicle() && target instanceof LivingEntity;
            bl3_flag2 = bl3_flag2 && !player.isSprinting();
            if (bl3_flag2) {
                f_attackDamage *= 1.5f;
            }
            f_attackDamage += h_enchantmentEffectsTargetBonus;
            boolean bl4 = false;
            double d = (double) (player.horizontalSpeed - player.prevHorizontalSpeed);
            if (bl_flag && !bl3_flag2 && !bl2_flag1 && player.isOnGround() && d < (double) player.getMovementSpeed()) {
                ItemStack itemStack = player.getStackInHand(Hand.MAIN_HAND);
                if (itemStack.getItem() instanceof SwordItem) {
                    bl4 = true;
                }
            }
            float k = 0.0F;
            boolean bl5 = false;
            int l = EnchantmentHelper.getFireAspect(player);
            if (target instanceof LivingEntity) {
                k = ((LivingEntity) target).getHealth();
                if (l > 0 && !target.isOnFire()) {
                    bl5 = true;
                    target.setOnFireFor(1);
                }
            }
            Vec3d vec3d = target.getVelocity();
            boolean bl6 = target.damage(DamageSource.player(player), f_attackDamage);
            if (bl6) {
                if (j > 0) {
                    if (target instanceof LivingEntity) {
                        ((LivingEntity) target).takeKnockback((float) j * 0.5F, (double) MathHelper.sin(player.yaw * 0.017453292F), (double) (-MathHelper.cos(player.yaw * 0.017453292F)));
                    } else {
                        target.addVelocity((double) (-MathHelper.sin(player.yaw * 0.017453292F) * (float) j * 0.5F), 0.1D, (double) (MathHelper.cos(player.yaw * 0.017453292F) * (float) j * 0.5F));
                    }
                    player.setVelocity(player.getVelocity().multiply(0.6D, 1.0D, 0.6D));
                    player.setSprinting(false);
                }
                if (bl4) {
                    float m = 1.0F + EnchantmentHelper.getSweepingMultiplier(player) * f_attackDamage;
                    List<LivingEntity> list = player.world.getNonSpectatingEntities(LivingEntity.class, target.getBoundingBox().expand(1.0D, 0.25D, 1.0D));
                    Iterator var19 = list.iterator();
                    label166: while (true) {
                        LivingEntity livingEntity;
                        do {
                            do {
                                do {
                                    do {
                                        if (!var19.hasNext()) {
                                            player.world.playSound((PlayerEntity) null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, player.getSoundCategory(), 1.0F, 1.0F);
                                            player.spawnSweepAttackParticles();
                                            break label166;
                                        }
                                        livingEntity = (LivingEntity) var19.next();
                                    } while (livingEntity == player);
                                } while (livingEntity == target);
                            } while (player.isTeammate(livingEntity));
                        } while (livingEntity instanceof ArmorStandEntity && ((ArmorStandEntity) livingEntity).isMarker());
                        if (player.squaredDistanceTo(livingEntity) < 9.0D) {
                            livingEntity.takeKnockback(0.4F, (double) MathHelper.sin(player.yaw * 0.017453292F), (double) (-MathHelper.cos(player.yaw * 0.017453292F)));
                            livingEntity.damage(DamageSource.player(player), m);
                        }
                    }
                }
                if (target instanceof ServerPlayerEntity && target.velocityModified) {
                    ((ServerPlayerEntity) target).networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(target));
                    target.velocityModified = false;
                    target.setVelocity(vec3d);
                }
                if (bl3_flag2) {
                    player.world.playSound((PlayerEntity) null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_CRIT, player.getSoundCategory(), 1.0F, 1.0F);
                    player.addCritParticles(target);
                }
                if (!bl3_flag2 && !bl4) {
                    if (bl_flag) {
                        player.world.playSound((PlayerEntity) null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_STRONG, player.getSoundCategory(), 1.0F, 1.0F);
                    } else {
                        player.world.playSound((PlayerEntity) null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, player.getSoundCategory(), 1.0F, 1.0F);
                    }
                }
                if (h_enchantmentEffectsTargetBonus > 0.0F) {
                    player.addEnchantedHitParticles(target);
                }
                player.onAttacking(target);
                if (target instanceof LivingEntity) {
                    EnchantmentHelper.onUserDamaged((LivingEntity) target, player);
                }
                EnchantmentHelper.onTargetDamaged(player, target);
                ItemStack itemStack2 = player.getMainHandStack();
                Entity entity = target;
                if (target instanceof EnderDragonPart) {
                    entity = ((EnderDragonPart) target).owner;
                }
                if (!player.world.isClient && !itemStack2.isEmpty() && entity instanceof LivingEntity) {
                    itemStack2.postHit((LivingEntity) entity, player);
                    if (itemStack2.isEmpty()) {
                        player.setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
                    }
                }
                if (target instanceof LivingEntity) {
                    float n = k - ((LivingEntity) target).getHealth();
                    player.increaseStat(Stats.DAMAGE_DEALT, Math.round(n * 10.0F));
                    if (l > 0) {
                        target.setOnFireFor(l * 4);
                    }
                    if (player.world instanceof ServerWorld && n > 2.0F) {
                        int o = (int) ((double) n * 0.5D);
                        ((ServerWorld) player.world).spawnParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getBodyY(0.5D), target.getZ(), o, 0.1D, 0.0D, 0.1D, 0.2D);
                    }
                }
                player.addExhaustion(0.1F);
            } else {
                player.world.playSound((PlayerEntity) null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, player.getSoundCategory(), 1.0F, 1.0F);
                if (bl5) {
                    target.extinguish();
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) SwordItem(net.minecraft.item.SwordItem) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) EntityVelocityUpdateS2CPacket(net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket) LivingEntity(net.minecraft.entity.LivingEntity) ServerWorld(net.minecraft.server.world.ServerWorld) EnderDragonPart(net.minecraft.entity.boss.dragon.EnderDragonPart) Iterator(java.util.Iterator) ItemStack(net.minecraft.item.ItemStack) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity)

Aggregations

ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)10 LivingEntity (net.minecraft.entity.LivingEntity)8 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 Entity (net.minecraft.entity.Entity)4 ItemFrameEntity (net.minecraft.entity.decoration.ItemFrameEntity)4 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)4 AnimationBuilder (software.bernie.geckolib3.core.builder.AnimationBuilder)4 ItemStack (net.minecraft.item.ItemStack)3 ArmorStandData (eu.pb4.armorstandeditor.helpers.ArmorStandData)2 SPEInterface (eu.pb4.armorstandeditor.helpers.SPEInterface)2 ArmorStandEntityAccessor (eu.pb4.armorstandeditor.mixin.ArmorStandEntityAccessor)2 Vec3d (net.minecraft.util.math.Vec3d)2 ArmorStandPreset (eu.pb4.armorstandeditor.config.ArmorStandPreset)1 Config (eu.pb4.armorstandeditor.config.Config)1 ConfigManager (eu.pb4.armorstandeditor.config.ConfigManager)1 ArmorStandInventory (eu.pb4.armorstandeditor.helpers.ArmorStandInventory)1 ItemFrameInventory (eu.pb4.armorstandeditor.helpers.ItemFrameInventory)1 ItemFrameEntityAccessor (eu.pb4.armorstandeditor.mixin.ItemFrameEntityAccessor)1 ClickType (eu.pb4.sgui.api.ClickType)1 GuiElement (eu.pb4.sgui.api.elements.GuiElement)1