Search in sources :

Example 6 with PaintingEntity

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

the class PreparableEntityInfo method prepareNormal.

@Override
public GeneratableEntityInfo prepareNormal(World world, DungeonPlacement placement) {
    Entity entity = EntityList.createEntityFromNBT(this.entityData, world);
    double x;
    double y;
    double z;
    if (entity instanceof HangingEntity) {
        x = this.entityData.getInteger("TileX");
        y = this.entityData.getInteger("TileY");
        z = this.entityData.getInteger("TileZ");
        if (entity instanceof PaintingEntity && placement.getMirror() != Mirror.NONE) {
            int n = ((((PaintingEntity) entity).art.sizeX >> 4) + 1) & 1;
            switch(((PaintingEntity) entity).facingDirection.rotateYCCW()) {
                case NORTH:
                    z -= n;
                    break;
                case EAST:
                    x += n;
                    break;
                case SOUTH:
                    z += n;
                    break;
                case WEST:
                    x -= n;
                    break;
                default:
                    break;
            }
        }
        BlockPos pos = placement.transform((int) x, (int) y, (int) z);
        x = pos.getX();
        y = pos.getY();
        z = pos.getZ();
    } else {
        ListNBT tagList = this.entityData.getTagList("Pos", Constants.NBT.TAG_DOUBLE);
        MutableVec3d vec = placement.transform(tagList.getDoubleAt(0), tagList.getDoubleAt(1), tagList.getDoubleAt(2));
        x = vec.x;
        y = vec.y;
        z = vec.z;
    }
    float transformedYaw = placement.transform(entity);
    entity.setLocationAndAngles(x, y, z, transformedYaw, entity.rotationPitch);
    entity.setRenderYawOffset(transformedYaw);
    entity.setRotationYawHead(transformedYaw);
    return new GeneratableEntityInfo(entity);
}
Also used : Entity(net.minecraft.entity.Entity) PaintingEntity(net.minecraft.entity.item.PaintingEntity) HangingEntity(net.minecraft.entity.item.HangingEntity) HangingEntity(net.minecraft.entity.item.HangingEntity) ListNBT(net.minecraft.nbt.ListNBT) PaintingEntity(net.minecraft.entity.item.PaintingEntity) BlockPos(net.minecraft.util.math.BlockPos) MutableVec3d(team.cqr.cqrepoured.world.structure.generation.generation.DungeonPlacement.MutableVec3d) GeneratableEntityInfo(team.cqr.cqrepoured.world.structure.generation.generation.generatable.GeneratableEntityInfo)

Example 7 with PaintingEntity

use of net.minecraft.entity.item.PaintingEntity in project Magma-1.16.x by magmafoundation.

the class CraftPainting method setArt.

@Override
public boolean setArt(Art art, boolean force) {
    PaintingEntity painting = this.getHandle();
    PaintingType oldArt = painting.motive;
    painting.motive = CraftArt.BukkitToNotch(art);
    painting.setDirection(painting.getDirection());
    if (!force && !painting.survives()) {
        // Revert painting since it doesn't fit
        painting.motive = oldArt;
        painting.setDirection(painting.getDirection());
        return false;
    }
    this.update();
    return true;
}
Also used : PaintingEntity(net.minecraft.entity.item.PaintingEntity) PaintingType(net.minecraft.entity.item.PaintingType)

Aggregations

PaintingEntity (net.minecraft.entity.item.PaintingEntity)7 HangingEntity (net.minecraft.entity.item.HangingEntity)3 BlockPos (net.minecraft.util.math.BlockPos)3 ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)2 MobEntity (net.minecraft.entity.MobEntity)2 LightningBoltEntity (net.minecraft.entity.effect.LightningBoltEntity)2 ArmorStandEntity (net.minecraft.entity.item.ArmorStandEntity)2 BoatEntity (net.minecraft.entity.item.BoatEntity)2 ExperienceOrbEntity (net.minecraft.entity.item.ExperienceOrbEntity)2 FallingBlockEntity (net.minecraft.entity.item.FallingBlockEntity)2 ItemEntity (net.minecraft.entity.item.ItemEntity)2 ItemFrameEntity (net.minecraft.entity.item.ItemFrameEntity)2 LeashKnotEntity (net.minecraft.entity.item.LeashKnotEntity)2 TNTEntity (net.minecraft.entity.item.TNTEntity)2 ChestMinecartEntity (net.minecraft.entity.item.minecart.ChestMinecartEntity)2 FurnaceMinecartEntity (net.minecraft.entity.item.minecart.FurnaceMinecartEntity)2