| 1 | package net.minecraft.entity.item;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import java.util.List;
|
| 5 | import net.minecraft.entity.Entity;
|
| 6 | import net.minecraft.entity.EntityHanging;
|
| 7 | import net.minecraft.entity.player.EntityPlayer;
|
| 8 | import net.minecraft.init.Items;
|
| 9 | import net.minecraft.item.ItemStack;
|
| 10 | import net.minecraft.nbt.NBTTagCompound;
|
| 11 | import net.minecraft.util.BlockPos;
|
| 12 | import net.minecraft.util.EnumFacing;
|
| 13 | import net.minecraft.world.World;
|
| 14 |
|
| 15 | public class EntityPainting extends EntityHanging
|
| 16 | {
|
| 17 | public EntityPainting.EnumArt art;
|
| 18 |
|
| 19 | public EntityPainting(World worldIn)
|
| 20 | {
|
| 21 | super(worldIn);
|
| 22 | }
|
| 23 |
|
| 24 | public EntityPainting(World worldIn, BlockPos pos, EnumFacing facing)
|
| 25 | {
|
| 26 | super(worldIn, pos);
|
| 27 | List<EntityPainting.EnumArt> list = Lists.<EntityPainting.EnumArt>newArrayList();
|
| 28 |
|
| 29 | for (EntityPainting.EnumArt entitypainting$enumart : EntityPainting.EnumArt.values())
|
| 30 | {
|
| 31 | this.art = entitypainting$enumart;
|
| 32 | this.updateFacingWithBoundingBox(facing);
|
| 33 |
|
| 34 | if (this.onValidSurface())
|
| 35 | {
|
| 36 | list.add(entitypainting$enumart);
|
| 37 | }
|
| 38 | }
|
| 39 |
|
| 40 | if (!list.isEmpty())
|
| 41 | {
|
| 42 | this.art = (EntityPainting.EnumArt)list.get(this.rand.nextInt(list.size()));
|
| 43 | }
|
| 44 |
|
| 45 | this.updateFacingWithBoundingBox(facing);
|
| 46 | }
|
| 47 |
|
| 48 | public EntityPainting(World worldIn, BlockPos pos, EnumFacing facing, String title)
|
| 49 | {
|
| 50 | this(worldIn, pos, facing);
|
| 51 |
|
| 52 | for (EntityPainting.EnumArt entitypainting$enumart : EntityPainting.EnumArt.values())
|
| 53 | {
|
| 54 | if (entitypainting$enumart.title.equals(title))
|
| 55 | {
|
| 56 | this.art = entitypainting$enumart;
|
| 57 | break;
|
| 58 | }
|
| 59 | }
|
| 60 |
|
| 61 | this.updateFacingWithBoundingBox(facing);
|
| 62 | }
|
| 63 |
|
| 64 | /**
|
| 65 | * (abstract) Protected helper method to write subclass entity data to NBT.
|
| 66 | */
|
| 67 | public void writeEntityToNBT(NBTTagCompound tagCompound)
|
| 68 | {
|
| 69 | tagCompound.setString("Motive", this.art.title);
|
| 70 | super.writeEntityToNBT(tagCompound);
|
| 71 | }
|
| 72 |
|
| 73 | /**
|
| 74 | * (abstract) Protected helper method to read subclass entity data from NBT.
|
| 75 | */
|
| 76 | public void readEntityFromNBT(NBTTagCompound tagCompund)
|
| 77 | {
|
| 78 | String s = tagCompund.getString("Motive");
|
| 79 |
|
| 80 | for (EntityPainting.EnumArt entitypainting$enumart : EntityPainting.EnumArt.values())
|
| 81 | {
|
| 82 | if (entitypainting$enumart.title.equals(s))
|
| 83 | {
|
| 84 | this.art = entitypainting$enumart;
|
| 85 | }
|
| 86 | }
|
| 87 |
|
| 88 | if (this.art == null)
|
| 89 | {
|
| 90 | this.art = EntityPainting.EnumArt.KEBAB;
|
| 91 | }
|
| 92 |
|
| 93 | super.readEntityFromNBT(tagCompund);
|
| 94 | }
|
| 95 |
|
| 96 | public int getWidthPixels()
|
| 97 | {
|
| 98 | return this.art.sizeX;
|
| 99 | }
|
| 100 |
|
| 101 | public int getHeightPixels()
|
| 102 | {
|
| 103 | return this.art.sizeY;
|
| 104 | }
|
| 105 |
|
| 106 | /**
|
| 107 | * Called when this entity is broken. Entity parameter may be null.
|
| 108 | */
|
| 109 | public void onBroken(Entity brokenEntity)
|
| 110 | {
|
| 111 | if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
|
| 112 | {
|
| 113 | if (brokenEntity instanceof EntityPlayer)
|
| 114 | {
|
| 115 | EntityPlayer entityplayer = (EntityPlayer)brokenEntity;
|
| 116 |
|
| 117 | if (entityplayer.capabilities.isCreativeMode)
|
| 118 | {
|
| 119 | return;
|
| 120 | }
|
| 121 | }
|
| 122 |
|
| 123 | this.entityDropItem(new ItemStack(Items.painting), 0.0F);
|
| 124 | }
|
| 125 | }
|
| 126 |
|
| 127 | /**
|
| 128 | * Sets the location and Yaw/Pitch of an entity in the world
|
| 129 | */
|
| 130 | public void setLocationAndAngles(double x, double y, double z, float yaw, float pitch)
|
| 131 | {
|
| 132 | BlockPos blockpos = this.hangingPosition.add(x - this.posX, y - this.posY, z - this.posZ);
|
| 133 | this.setPosition((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
|
| 134 | }
|
| 135 |
|
| 136 | public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_)
|
| 137 | {
|
| 138 | BlockPos blockpos = this.hangingPosition.add(x - this.posX, y - this.posY, z - this.posZ);
|
| 139 | this.setPosition((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
|
| 140 | }
|
| 141 |
|
| 142 | public static enum EnumArt
|
| 143 | {
|
| 144 | KEBAB("Kebab", 16, 16, 0, 0),
|
| 145 | AZTEC("Aztec", 16, 16, 16, 0),
|
| 146 | ALBAN("Alban", 16, 16, 32, 0),
|
| 147 | AZTEC_2("Aztec2", 16, 16, 48, 0),
|
| 148 | BOMB("Bomb", 16, 16, 64, 0),
|
| 149 | PLANT("Plant", 16, 16, 80, 0),
|
| 150 | WASTELAND("Wasteland", 16, 16, 96, 0),
|
| 151 | POOL("Pool", 32, 16, 0, 32),
|
| 152 | COURBET("Courbet", 32, 16, 32, 32),
|
| 153 | SEA("Sea", 32, 16, 64, 32),
|
| 154 | SUNSET("Sunset", 32, 16, 96, 32),
|
| 155 | CREEBET("Creebet", 32, 16, 128, 32),
|
| 156 | WANDERER("Wanderer", 16, 32, 0, 64),
|
| 157 | GRAHAM("Graham", 16, 32, 16, 64),
|
| 158 | MATCH("Match", 32, 32, 0, 128),
|
| 159 | BUST("Bust", 32, 32, 32, 128),
|
| 160 | STAGE("Stage", 32, 32, 64, 128),
|
| 161 | VOID("Void", 32, 32, 96, 128),
|
| 162 | SKULL_AND_ROSES("SkullAndRoses", 32, 32, 128, 128),
|
| 163 | WITHER("Wither", 32, 32, 160, 128),
|
| 164 | FIGHTERS("Fighters", 64, 32, 0, 96),
|
| 165 | POINTER("Pointer", 64, 64, 0, 192),
|
| 166 | PIGSCENE("Pigscene", 64, 64, 64, 192),
|
| 167 | BURNING_SKULL("BurningSkull", 64, 64, 128, 192),
|
| 168 | SKELETON("Skeleton", 64, 48, 192, 64),
|
| 169 | DONKEY_KONG("DonkeyKong", 64, 48, 192, 112);
|
| 170 |
|
| 171 | public static final int field_180001_A = "SkullAndRoses".length();
|
| 172 | public final String title;
|
| 173 | public final int sizeX;
|
| 174 | public final int sizeY;
|
| 175 | public final int offsetX;
|
| 176 | public final int offsetY;
|
| 177 |
|
| 178 | private EnumArt(String titleIn, int width, int height, int textureU, int textureV)
|
| 179 | {
|
| 180 | this.title = titleIn;
|
| 181 | this.sizeX = width;
|
| 182 | this.sizeY = height;
|
| 183 | this.offsetX = textureU;
|
| 184 | this.offsetY = textureV;
|
| 185 | }
|
| 186 | }
|
| 187 | }
|
| 188 |
|