use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.
the class BlockMannequin method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityMannequin) {
int l = MathHelper.floor_double((double) (player.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15;
((TileEntityMannequin) te).setRotation(l);
if (!world.isRemote) {
if (stack.hasTagCompound()) {
NBTTagCompound compound = stack.getTagCompound();
GameProfile gameProfile = null;
if (compound.hasKey(TAG_OWNER, 10)) {
gameProfile = NBTUtil.func_152459_a(compound.getCompoundTag(TAG_OWNER));
((TileEntityMannequin) te).setGameProfile(gameProfile);
}
if (compound.hasKey(TAG_IMAGE_URL, Constants.NBT.TAG_STRING)) {
((TileEntityMannequin) te).setImageUrl(compound.getString(TAG_IMAGE_URL));
}
}
}
}
world.setBlock(x, y + 1, z, this, 1, 2);
}
use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.
the class BlockMannequin method getMannequinTileEntity.
public TileEntityMannequin getMannequinTileEntity(World world, int x, int y, int z) {
int offset = 0;
if (isTopOfMannequin(world, x, y, z)) {
offset = -1;
}
TileEntity te = world.getTileEntity(x, y + offset, z);
if (te != null && te instanceof TileEntityMannequin) {
return (TileEntityMannequin) te;
}
return null;
}
use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.
the class BlockMannequin method convertToDoll.
public void convertToDoll(World world, int x, int y, int z) {
if (isTopOfMannequin(world, x, y, z)) {
Block block = world.getBlock(x, y - 1, z);
if (block == this) {
((BlockMannequin) block).convertToDoll(world, x, y - 1, z);
}
return;
}
if (world.getBlock(x, y + 1, z) == this) {
TileEntityMannequin te = getMannequinTileEntity(world, x, y, z);
if (te != null) {
te.setDropItems(false);
NBTTagCompound compound = new NBTTagCompound();
te.writeCommonToNBT(compound);
te.writeItemsToNBT(compound);
world.setBlockToAir(x, y + 1, z);
world.setBlock(x, y, z, ModBlocks.doll, 0, 3);
TileEntity newTe = world.getTileEntity(x, y, z);
if (newTe != null && newTe instanceof TileEntityMannequin) {
((TileEntityMannequin) newTe).readCommonFromNBT(compound);
((TileEntityMannequin) newTe).readItemsFromNBT(compound);
((TileEntityMannequin) newTe).setDoll(true);
}
}
}
}
use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.
the class BlockMannequin method randomDisplayTick.
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (isTopOfMannequin(world, x, y, z)) {
if (isValentins) {
if (random.nextFloat() * 100 > 75) {
world.spawnParticle("heart", x + 0.2D + random.nextFloat() * 0.6F, y + 1D, z + 0.2D + random.nextFloat() * 0.6F, 0, 0, 0);
}
}
TileEntityMannequin te = getMannequinTileEntity(world, x, y, z);
if (te != null && te.isRenderExtras()) {
Contributor contributor = Contributors.INSTANCE.getContributor(te.getGameProfile());
if (contributor != null & te.isVisible()) {
for (int i = 0; i < 4; i++) {
EntityFX entityfx = new EntitySpellParticleFX(world, x - 1 + random.nextFloat() * 3F, y - 1D, z - 1 + random.nextFloat() * 3F, 0, 0, 0);
((EntitySpellParticleFX) entityfx).setBaseSpellTextureIndex(144);
entityfx.setRBGColorF((float) (contributor.r & 0xFF) / 255F, (float) (contributor.g & 0xFF) / 255F, (float) (contributor.b & 0xFF) / 255F);
Minecraft.getMinecraft().effectRenderer.addEffect(entityfx);
}
}
}
}
}
use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.
the class ItemMannequinTool method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if (block != null && (block == ModBlocks.mannequin | block == ModBlocks.doll)) {
TileEntity te;
int meta = world.getBlockMetadata(x, y, z);
if (meta == 0) {
te = world.getTileEntity(x, y, z);
} else {
te = world.getTileEntity(x, y - 1, z);
}
if (te != null && te instanceof TileEntityMannequin) {
TileEntityMannequin teMan = (TileEntityMannequin) te;
if (player.isSneaking()) {
setRotationDataOnStack(stack, teMan.getBipedRotations());
} else {
BipedRotations bipedRotations = getRotationDataFromStack(stack);
if (bipedRotations != null) {
teMan.setBipedRotations(bipedRotations);
}
}
return true;
}
}
return false;
}
Aggregations