Search in sources :

Example 6 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project minecolonies by Minecolonies.

the class ItemStackUtils method getListOfStackForEntity.

/**
 * Adds entities to the builder building if he needs it.
 *
 * @param entity the entity object.
 * @param placer the entity placer.
 * @return a list of stacks.
 */
public static List<ItemStorage> getListOfStackForEntity(final Entity entity, final Entity placer) {
    if (entity != null) {
        final List<ItemStorage> request = new ArrayList<>();
        if (entity instanceof ItemFrameEntity) {
            final ItemStack stack = ((ItemFrameEntity) entity).getItem();
            if (!ItemStackUtils.isEmpty(stack)) {
                ItemStackUtils.setSize(stack, 1);
                request.add(new ItemStorage(stack));
            }
            request.add(new ItemStorage(new ItemStack(Items.ITEM_FRAME, 1)));
        } else if (entity instanceof ArmorStandEntity) {
            request.add(new ItemStorage(entity.getPickedResult(new EntityRayTraceResult(placer))));
            entity.getArmorSlots().forEach(item -> request.add(new ItemStorage(item)));
            entity.getHandSlots().forEach(item -> request.add(new ItemStorage(item)));
        }
        return request.stream().filter(stack -> !stack.getItemStack().isEmpty()).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
Also used : EntityType(net.minecraft.entity.EntityType) java.util(java.util) SMELTABLE_SLOT(com.minecolonies.api.util.constant.Constants.SMELTABLE_SLOT) ModTags.fungi(com.minecolonies.api.items.ModTags.fungi) Compatibility(com.minecolonies.api.compatibility.Compatibility) CompoundNBT(net.minecraft.nbt.CompoundNBT) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) JsonToNBT(net.minecraft.nbt.JsonToNBT) MinecoloniesAPIProxy(com.minecolonies.api.MinecoloniesAPIProxy) ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) Lists(com.google.common.collect.Lists) Block(net.minecraft.block.Block) EntityRayTraceResult(net.minecraft.util.math.EntityRayTraceResult) ModItems(com.minecolonies.api.items.ModItems) FUEL_SLOT(com.minecolonies.api.util.constant.Constants.FUEL_SLOT) ListNBT(net.minecraft.nbt.ListNBT) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ItemTags(net.minecraft.tags.ItemTags) World(net.minecraft.world.World) Predicate(java.util.function.Predicate) IColonyManager(com.minecolonies.api.colony.IColonyManager) net.minecraft.item(net.minecraft.item) FurnaceTileEntity(net.minecraft.tileentity.FurnaceTileEntity) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) ResourceLocation(net.minecraft.util.ResourceLocation) ToolType(com.minecolonies.api.util.constant.ToolType) ItemStorage(com.minecolonies.api.crafting.ItemStorage) IToolType(com.minecolonies.api.util.constant.IToolType) NotNull(org.jetbrains.annotations.NotNull) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) ForgeRegistries(net.minecraftforge.registries.ForgeRegistries) EntityRayTraceResult(net.minecraft.util.math.EntityRayTraceResult) ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 7 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project ChocolateQuestRepoured by TeamChocoQuest.

the class RoomDecorArmorStand method createEntityDecoration.

@Override
protected void createEntityDecoration(World world, BlockPos pos, BlockStateGenArray genArray, Direction side) {
    // Need to add 0.5 to each position amount so it spawns in the middle of the tile
    ArmorStandEntity stand = new ArmorStandEntity(world);
    float rotation = side.getHorizontalAngle();
    stand.setPosition((pos.getX() + 0.5), (pos.getY() + 0.5), (pos.getZ() + 0.5));
    stand.rotationYaw = rotation;
    genArray.addEntity(BlockPos.ORIGIN, stand);
}
Also used : ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity)

Example 8 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project ChocolateQuestRepoured by TeamChocoQuest.

the class ModelCustomArmorBase method setupAnim.

@Override
public void setupAnim(T pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) {
    super.setupAnim(pEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch);
    if (pEntity instanceof ArmorStandEntity) {
        ArmorStandEntity entityarmorstand = (ArmorStandEntity) pEntity;
        this.head.xRot = 0.017453292F * entityarmorstand.getHeadPose().getX();
        this.head.yRot = 0.017453292F * entityarmorstand.getHeadPose().getY();
        this.head.zRot = 0.017453292F * entityarmorstand.getHeadPose().getZ();
        this.head.setPos(0.0F, 1.0F, 0.0F);
        this.body.xRot = 0.017453292F * entityarmorstand.getBodyPose().getX();
        this.body.yRot = 0.017453292F * entityarmorstand.getBodyPose().getY();
        this.body.zRot = 0.017453292F * entityarmorstand.getBodyPose().getZ();
        this.leftArm.xRot = 0.017453292F * entityarmorstand.getLeftArmPose().getX();
        this.leftArm.yRot = 0.017453292F * entityarmorstand.getLeftArmPose().getY();
        this.leftArm.zRot = 0.017453292F * entityarmorstand.getLeftArmPose().getZ();
        this.rightArm.xRot = 0.017453292F * entityarmorstand.getRightArmPose().getX();
        this.rightArm.yRot = 0.017453292F * entityarmorstand.getRightArmPose().getY();
        this.rightArm.zRot = 0.017453292F * entityarmorstand.getRightArmPose().getZ();
        this.leftLeg.xRot = 0.017453292F * entityarmorstand.getLeftLegPose().getX();
        this.leftLeg.yRot = 0.017453292F * entityarmorstand.getLeftLegPose().getY();
        this.leftLeg.zRot = 0.017453292F * entityarmorstand.getLeftLegPose().getZ();
        this.leftLeg.setPos(1.9F, 11.0F, 0.0F);
        this.rightLeg.xRot = 0.017453292F * entityarmorstand.getRightLegPose().getX();
        this.rightLeg.yRot = 0.017453292F * entityarmorstand.getRightLegPose().getY();
        this.rightLeg.zRot = 0.017453292F * entityarmorstand.getRightLegPose().getZ();
        this.rightLeg.setPos(-1.9F, 11.0F, 0.0F);
        this.rightArm.copyFrom(this.head);
    }
}
Also used : ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity)

Example 9 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project Mekanism by mekanism.

the class ClientTickHandler method setModelVisibility.

private static void setModelVisibility(LivingEntity entity, BipedModel<?> entityModel, boolean showModel) {
    if (entity.getItemBySlot(EquipmentSlotType.HEAD).getItem() instanceof ItemMekaSuitArmor) {
        entityModel.head.visible = showModel;
        entityModel.hat.visible = showModel;
        if (entityModel instanceof PlayerModel) {
            PlayerModel<?> playerModel = (PlayerModel<?>) entityModel;
            playerModel.ear.visible = showModel;
        }
    }
    ItemStack chest = entity.getItemBySlot(EquipmentSlotType.CHEST);
    if (chest.getItem() instanceof ItemMekaSuitArmor) {
        entityModel.body.visible = showModel;
        if (!(entity instanceof ArmorStandEntity)) {
            // Don't adjust arms for armor stands as the model will end up changing them anyway and then we may incorrectly activate them
            entityModel.leftArm.visible = showModel;
            entityModel.rightArm.visible = showModel;
        }
        if (entityModel instanceof PlayerModel) {
            PlayerModel<?> playerModel = (PlayerModel<?>) entityModel;
            playerModel.cloak.visible = showModel;
            playerModel.jacket.visible = showModel;
            playerModel.leftSleeve.visible = showModel;
            playerModel.rightSleeve.visible = showModel;
        } else if (entityModel instanceof ArmorStandModel) {
            ArmorStandModel armorStandModel = (ArmorStandModel) entityModel;
            armorStandModel.bodyStick1.visible = showModel;
            armorStandModel.bodyStick2.visible = showModel;
            armorStandModel.shoulderStick.visible = showModel;
        }
    } else if (chest.getItem() instanceof ItemHDPEElytra && entityModel instanceof PlayerModel) {
        // Hide the player's cape if they have an HDPE elytra as it will be part of the elytra's layer and shouldn't be rendered
        PlayerModel<?> playerModel = (PlayerModel<?>) entityModel;
        playerModel.cloak.visible = showModel;
    }
    if (entity.getItemBySlot(EquipmentSlotType.LEGS).getItem() instanceof ItemMekaSuitArmor) {
        entityModel.leftLeg.visible = showModel;
        entityModel.rightLeg.visible = showModel;
        if (entityModel instanceof PlayerModel) {
            PlayerModel<?> playerModel = (PlayerModel<?>) entityModel;
            playerModel.leftPants.visible = showModel;
            playerModel.rightPants.visible = showModel;
        }
    }
}
Also used : ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) PlayerModel(net.minecraft.client.renderer.entity.model.PlayerModel) ArmorStandModel(net.minecraft.client.renderer.entity.model.ArmorStandModel) ItemHDPEElytra(mekanism.common.item.gear.ItemHDPEElytra) ItemStack(net.minecraft.item.ItemStack) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity)

Example 10 with ArmorStandEntity

use of net.minecraft.entity.item.ArmorStandEntity in project minecolonies by ldtteam.

the class ItemStackUtils method getListOfStackForEntity.

/**
 * Adds entities to the builder building if he needs it.
 *
 * @param entity the entity object.
 * @param placer the entity placer.
 * @return a list of stacks.
 */
public static List<ItemStorage> getListOfStackForEntity(final Entity entity, final Entity placer) {
    if (entity != null) {
        final List<ItemStorage> request = new ArrayList<>();
        if (entity instanceof ItemFrameEntity) {
            final ItemStack stack = ((ItemFrameEntity) entity).getItem();
            if (!ItemStackUtils.isEmpty(stack)) {
                ItemStackUtils.setSize(stack, 1);
                request.add(new ItemStorage(stack));
            }
            request.add(new ItemStorage(new ItemStack(Items.ITEM_FRAME, 1)));
        } else if (entity instanceof ArmorStandEntity) {
            request.add(new ItemStorage(entity.getPickedResult(new EntityRayTraceResult(placer))));
            entity.getArmorSlots().forEach(item -> request.add(new ItemStorage(item)));
            entity.getHandSlots().forEach(item -> request.add(new ItemStorage(item)));
        }
        return request.stream().filter(stack -> !stack.getItemStack().isEmpty()).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
Also used : EntityType(net.minecraft.entity.EntityType) java.util(java.util) SMELTABLE_SLOT(com.minecolonies.api.util.constant.Constants.SMELTABLE_SLOT) ModTags.fungi(com.minecolonies.api.items.ModTags.fungi) Compatibility(com.minecolonies.api.compatibility.Compatibility) CompoundNBT(net.minecraft.nbt.CompoundNBT) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) JsonToNBT(net.minecraft.nbt.JsonToNBT) MinecoloniesAPIProxy(com.minecolonies.api.MinecoloniesAPIProxy) ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) Lists(com.google.common.collect.Lists) Block(net.minecraft.block.Block) EntityRayTraceResult(net.minecraft.util.math.EntityRayTraceResult) ModItems(com.minecolonies.api.items.ModItems) FUEL_SLOT(com.minecolonies.api.util.constant.Constants.FUEL_SLOT) ListNBT(net.minecraft.nbt.ListNBT) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ItemTags(net.minecraft.tags.ItemTags) World(net.minecraft.world.World) Predicate(java.util.function.Predicate) IColonyManager(com.minecolonies.api.colony.IColonyManager) net.minecraft.item(net.minecraft.item) FurnaceTileEntity(net.minecraft.tileentity.FurnaceTileEntity) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) ResourceLocation(net.minecraft.util.ResourceLocation) ToolType(com.minecolonies.api.util.constant.ToolType) ItemStorage(com.minecolonies.api.crafting.ItemStorage) IToolType(com.minecolonies.api.util.constant.IToolType) NotNull(org.jetbrains.annotations.NotNull) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) ForgeRegistries(net.minecraftforge.registries.ForgeRegistries) EntityRayTraceResult(net.minecraft.util.math.EntityRayTraceResult) ItemFrameEntity(net.minecraft.entity.item.ItemFrameEntity) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Aggregations

ArmorStandEntity (net.minecraft.entity.item.ArmorStandEntity)11 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 Entity (net.minecraft.entity.Entity)3 LivingEntity (net.minecraft.entity.LivingEntity)3 ItemFrameEntity (net.minecraft.entity.item.ItemFrameEntity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 net.minecraft.item (net.minecraft.item)3 CompoundNBT (net.minecraft.nbt.CompoundNBT)3 Lists (com.google.common.collect.Lists)2 MinecoloniesAPIProxy (com.minecolonies.api.MinecoloniesAPIProxy)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 Compatibility (com.minecolonies.api.compatibility.Compatibility)2 ItemStorage (com.minecolonies.api.crafting.ItemStorage)2 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)2 ModItems (com.minecolonies.api.items.ModItems)2 ModTags.fungi (com.minecolonies.api.items.ModTags.fungi)2 FUEL_SLOT (com.minecolonies.api.util.constant.Constants.FUEL_SLOT)2 SMELTABLE_SLOT (com.minecolonies.api.util.constant.Constants.SMELTABLE_SLOT)2 IToolType (com.minecolonies.api.util.constant.IToolType)2