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);
}
}
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();
}
}
use of net.minecraft.entity.decoration.ArmorStandEntity in project Overlord by The-Fireplace-Minecraft-Mods.
the class MeleeAttackExecutorImpl method dealSweepDamage.
private void dealSweepDamage(LivingEntity attacker, Entity target, float baseAttackDamage) {
float multiplier = 1.0F + EnchantmentHelper.getSweepingMultiplier(attacker) * baseAttackDamage;
List<LivingEntity> entitiesInSweepRange = attacker.world.getNonSpectatingEntities(LivingEntity.class, target.getBoundingBox().expand(1.0D, 0.25D, 1.0D));
for (LivingEntity livingEntity : entitiesInSweepRange) {
if (livingEntity instanceof ArmorStandEntity && ((ArmorStandEntity) livingEntity).isMarker() || attacker.isTeammate(livingEntity) || livingEntity == target || livingEntity == attacker) {
continue;
}
if (attacker.squaredDistanceTo(livingEntity) < 9.0D) {
livingEntity.takeKnockback(0.4F, MathHelper.sin(attacker.getYaw() * (float) Math.PI / 180), -MathHelper.cos(attacker.getYaw() * (float) Math.PI / 180));
livingEntity.damage(DamageSource.mob(attacker), multiplier);
}
}
attacker.world.playSound(null, attacker.getX(), attacker.getY(), attacker.getZ(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, attacker.getSoundCategory(), 1.0F, 1.0F);
showSweepParticles(attacker);
}
use of net.minecraft.entity.decoration.ArmorStandEntity in project EmissiveMod by Traben-0.
the class MixinShulkerBoxBlockEntityRenderer method etf$injected.
@Inject(method = "render(Lnet/minecraft/block/entity/ShulkerBoxBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "HEAD"))
private void etf$injected(ShulkerBoxBlockEntity shulkerBoxBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) {
if (ETFConfigData.enableCustomTextures) {
etf$vertexConsumerProviderOfThis = vertexConsumerProvider;
try {
etf$shulkerBoxStandInDummy = new ArmorStandEntity(EntityType.ARMOR_STAND, shulkerBoxBlockEntity.getWorld());
etf$shulkerBoxStandInDummy.setPos(shulkerBoxBlockEntity.getPos().getX(), shulkerBoxBlockEntity.getPos().getY(), shulkerBoxBlockEntity.getPos().getZ());
String identifier = "shulker" + shulkerBoxBlockEntity.getPos().toString();
etf$shulkerBoxStandInDummy.setCustomName(shulkerBoxBlockEntity.getCustomName());
etf$shulkerBoxStandInDummy.setCustomNameVisible(shulkerBoxBlockEntity.hasCustomName());
if (shulkerBoxBlockEntity.hasCustomName()) {
// noinspection ConstantConditions
identifier += shulkerBoxBlockEntity.getCustomName().getString();
}
// shulker boxes don't have uuid so set UUID from something repeatable this uses blockPos & container name
etf$shulkerBoxStandInDummy.setUuid(UUID.nameUUIDFromBytes(identifier.getBytes()));
} catch (Exception e) {
ETFUtils.logError("shulker box custom rendering failed during setup, " + e);
}
}
}
use of net.minecraft.entity.decoration.ArmorStandEntity in project Flan by Flemmli97.
the class EntityInteractEvents method useAtEntity.
public static ActionResult useAtEntity(PlayerEntity player, World world, Hand hand, Entity entity, /* Nullable */
EntityHitResult hitResult) {
if (player.world.isClient || player.isSpectator() || canInteract(entity))
return ActionResult.PASS;
ClaimStorage storage = ClaimStorage.get((ServerWorld) world);
BlockPos pos = entity.getBlockPos();
IPermissionContainer claim = storage.getForPermissionCheck(pos);
if (claim != null) {
if (entity instanceof ArmorStandEntity) {
if (!claim.canInteract((ServerPlayerEntity) player, PermissionRegistry.ARMORSTAND, pos, true))
return ActionResult.FAIL;
}
}
return ActionResult.PASS;
}
Aggregations