Search in sources :

Example 6 with TileEntityMannequin

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) GameProfile(com.mojang.authlib.GameProfile) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)

Example 7 with TileEntityMannequin

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)

Example 8 with TileEntityMannequin

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);
            }
        }
    }
}
Also used : ItemBlockMannequin(riskyken.armourersWorkshop.common.items.block.ItemBlockMannequin) TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)

Example 9 with TileEntityMannequin

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);
                }
            }
        }
    }
}
Also used : EntitySpellParticleFX(net.minecraft.client.particle.EntitySpellParticleFX) Contributor(riskyken.armourersWorkshop.common.Contributors.Contributor) EntityFX(net.minecraft.client.particle.EntityFX) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 10 with TileEntityMannequin

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BipedRotations(riskyken.armourersWorkshop.common.data.BipedRotations) Block(net.minecraft.block.Block) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)

Aggregations

TileEntityMannequin (riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)19 TileEntity (net.minecraft.tileentity.TileEntity)14 ItemStack (net.minecraft.item.ItemStack)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 Block (net.minecraft.block.Block)3 GameProfile (com.mojang.authlib.GameProfile)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 EntityFX (net.minecraft.client.particle.EntityFX)2 EntitySpellParticleFX (net.minecraft.client.particle.EntitySpellParticleFX)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 Container (net.minecraft.inventory.Container)2 Contributor (riskyken.armourersWorkshop.common.Contributors.Contributor)2 ContainerMannequin (riskyken.armourersWorkshop.common.inventory.ContainerMannequin)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IPantable (riskyken.armourersWorkshop.api.common.painting.IPantable)1 IPantableBlock (riskyken.armourersWorkshop.api.common.painting.IPantableBlock)1 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)1 BlockMannequin (riskyken.armourersWorkshop.common.blocks.BlockMannequin)1 BipedRotations (riskyken.armourersWorkshop.common.data.BipedRotations)1 ItemBlockMannequin (riskyken.armourersWorkshop.common.items.block.ItemBlockMannequin)1