Search in sources :

Example 11 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class ItemPaintbrush 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 (player.isSneaking() & block == ModBlocks.colourMixer) {
        TileEntity te = world.getTileEntity(x, y, z);
        if (te != null && te instanceof IPantable) {
            if (!world.isRemote) {
                int colour = ((IPantable) te).getColour(0);
                PaintType paintType = ((IPantable) te).getPaintType(0);
                setToolColour(stack, colour);
                setToolPaintType(stack, paintType);
            }
        }
        return true;
    }
    if (block instanceof IPantableBlock) {
        int newColour = getToolColour(stack);
        if (!world.isRemote) {
            UndoManager.begin(player);
            if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
                for (int i = 0; i < 6; i++) {
                    usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, i);
                }
            } else {
                usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, side);
            }
            UndoManager.end(player);
            if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
                world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.PAINT, 1.0F, world.rand.nextFloat() * 0.1F + 0.9F);
            } else {
                world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.PAINT, 1.0F, world.rand.nextFloat() * 0.1F + 1.5F);
            }
        } else {
            spawnPaintParticles(world, x, y, z, side, newColour);
        }
        return true;
    }
    if (block == ModBlocks.armourerBrain & player.isSneaking()) {
        if (!world.isRemote) {
            TileEntity te = world.getTileEntity(x, y, z);
            if (te != null && te instanceof TileEntityArmourer) {
                ((TileEntityArmourer) te).toolUsedOnArmourer(this, world, stack, player);
            }
        }
        ModLogger.log("armourer");
        return true;
    }
    if (block == ModBlocks.mannequin) {
        if (!world.isRemote) {
            TileEntity te = ((BlockMannequin) block).getMannequinTileEntity(world, x, y, z);
            if (te != null && te instanceof TileEntityMannequin) {
                int newColour = getToolColour(stack);
                if (player.isSneaking()) {
                    ((TileEntityMannequin) te).setHairColour(newColour);
                } else {
                    ((TileEntityMannequin) te).setSkinColour(newColour);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockMannequin(riskyken.armourersWorkshop.common.blocks.BlockMannequin) TileEntityArmourer(riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer) Block(net.minecraft.block.Block) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock) IPantable(riskyken.armourersWorkshop.api.common.painting.IPantable) PaintType(riskyken.armourersWorkshop.common.painting.PaintType) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 12 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class MessageClientGuiMannequinData method onMessage.

@Override
public IMessage onMessage(MessageClientGuiMannequinData message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    if (player == null) {
        return null;
    }
    Container container = player.openContainer;
    if (container != null && container instanceof ContainerMannequin) {
        TileEntityMannequin tileEntity = ((ContainerMannequin) container).getTileEntity();
        tileEntity.gotUpdateFromClient(message.xOffset, message.yOffset, message.zOffset, message.skinColour, message.hairColour, message.username, message.renderExtras, message.flying, message.visible, message.textureType);
    }
    return null;
}
Also used : ContainerMannequin(riskyken.armourersWorkshop.common.inventory.ContainerMannequin) Container(net.minecraft.inventory.Container) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)

Example 13 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class BlockDoll method randomDisplayTick.

@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
    if (isValentins) {
        if (random.nextFloat() * 100 > 80) {
            world.spawnParticle("heart", x + 0.2D + random.nextFloat() * 0.6F, y + 1D, z + 0.2D + random.nextFloat() * 0.6F, 0, 0, 0);
        }
    }
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity != null && tileEntity instanceof TileEntityMannequin) {
        TileEntityMannequin te = (TileEntityMannequin) tileEntity;
        if (te.isRenderExtras() & te.isVisible()) {
            Contributor contributor = Contributors.INSTANCE.getContributor(te.getGameProfile());
            if (contributor != null) {
                EntityFX entityfx = new EntitySpellParticleFX(world, x + random.nextFloat() * 1F, y, z + random.nextFloat() * 1F, 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 : TileEntity(net.minecraft.tileentity.TileEntity) 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 14 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class BlockDoll method breakBlock.

@Override
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
    if (!world.isRemote) {
        TileEntity te = world.getTileEntity(x, y, z);
        if (te != null && te instanceof TileEntityMannequin) {
            ItemStack dropStack = ((TileEntityMannequin) te).getDropStack();
            UtilItems.spawnItemInWorld(world, x, y, z, dropStack);
        }
        BlockUtils.dropInventoryBlocks(world, x, y, z);
    }
    super.breakBlock(world, x, y, z, block, metadata);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin) ItemStack(net.minecraft.item.ItemStack)

Example 15 with TileEntityMannequin

use of riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin in project Armourers-Workshop by RiskyKen.

the class BlockDoll method onBlockPlacedBy.

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