• 0

    posted a message on [1.7.2] [Forge] ColouredBlocks - The uncolourable can become colourable!

    Yes, that was made using this.
    What is the ColouredBlocks mod? Well, have you ever wanted to make something, but the default textures just didn't have the right colours? Well, this mod will help you with that, hopefully.
    Content:

    The mod adds 2 new items, and 3 new blocks.Items:
    • Crayons
    • Coloured Essense
    Blocks:
    • Coloured Block
    • Underside Icon Block
    • Dye Blocks
    The mod is pretty simple, crayons have 256 uses and will change a coloured block/underside icon block's colour to it's own, shift-click to drain the colour from a coloured block, coloured essense functions as a one-use crayon and as an ingredient.
    General Run-Down:

    The first thing you need to know how to craft is colouring essense. This is the bread and butter for your aesthetic journey.This can be crafted by surrounding a piece of mundane sugar with 8 pieces of vanilla dye (That's bone meal, ink sacs, cocoa beans, lapis lazuli, etc. None of that BoP stuff).For those of you that are more graphically inclined, here are two pictures:


    Now that that's out of the way, what exactly can we do with it? Well, we can craft all sorts of things with it, but it's not very interesting, it's just black! How about we change that :) You can change the colour that the essense contains by using shapeless recipes in an additional manner. That is, starting from black, you add in the colours. Appending an ink sac to the recipe seems to invert the results, and make the recipe work in a subtractional manner.Explaination time: That gibberish basically means this -1) Start with your black essense, and put it in a crafting table.2) Add some dyes to it3) ???4) PROFIT!Ok, seriously though. Starting from black, you can add colours in through the 3 rudimentary dyes - Rose Red, Cactus Green and Lapis Lazuli. Each of these dyes will add 8 to the Red, Green and Blue points respectively.Now, the problem comes in when you just need 1 of each point. Which is why you have noted that using Orange Dye, Lime Green and Cyan Dye respectively add 1 of Red, Green or Blue!Also, Ink Sacs seem to invert the additions into subtractions when used in a recipe, and when used by themselves will subtract 1 point from each colour.So, now that we've made some faaancy colours, it'd be nice to use them, right?First off, we need a crayon. This is what you will be using to actually colour the blocks.Craft one like so:NB: The crayon will have the same colour properties as the essense used to craft it.Now then, we need something to actually colour! So, let's make some coloured blocks.NB: By default, coloured blocks will NOT have the same colour properties on crafting as the essense used.You can change this in the config. Also, you can supplement the Monster Spawners for any other block'Hmm, this is nice, but what if I want to colour the orientation of a log, for instance, or something that I can't pick up?'That's why we have the Underside Icon Block! Crafted by surrounding one iron ingot with 8 essense, this magical block will reuse the texture of the block below it! And it is colourable!'Yay! But, I have so many dyes, is it possible to store them somehow?'Absolutely! Added in, we have these mystical dye blocks:These blocks aren't your typical storage block, no. Not only do they look super fancy, they use up 8 dye (for those with OCD out there), function in the same manner as their normal dye counterparts times eight for dying essense, but also are immune to crafting mistakes! Unfortunately, as a side effect, they must be disassembled by shift + right clicking on them in the world, returning you the dye and the quartz blocks.
    Configuration:

    "enableRareNames":true

    Disable if you don't want some of the fancy names (eg: Jaded Block instead of Block of Purple Dye)
    "colourAddition":{

    A map of all the different items/blocks and their colour changes:
    "Name:Orange Dye, Damage:14, NBT:null"

    Simple enough, the format is:
    "Name:[DisplayName], Damage:[ItemDamage/Metadata], NBT:[NBT Data]"

    { "Blue":8, "Red":0, "Green":0},

    These seemed to get muddled, but they're just the RGB point additions for the item
    "intensity":{ "Name:Block of Black Dye, Damage:0, NBT:null":8},

    Same name format as above, the 'intensity', or in this case, 8, is the amount of points to drop all of the RGB by when this is used. ONLY possible if the net RGB addition/subtraction would normally be 0 (Put a mapping for items, and give them 0 0 0 for RGB point addition)
    "transferColourToBlock":false,

    When a coloured block is crafted, should the game transfer the colour to the block?
    "useEightBlocks":true

    Should the recipe for coloured blocks use eight blocks? If false, inverts the recipe (8 essense, 1 block)
    Developers: If you want to use the colours from these beautiful crayons, or want to learn how the mod works, head over to https://github.com/U.../ColouredBlocks for the source for this mod.

    Downloads:
    1.7.2 Colour
    1.7.2 Colored
    Posted in: Minecraft Mods
  • 1

    posted a message on [1.7.2] Implementing IGrowable
    Override this method in your sapling
        protected boolean canPlaceBlockOn(Block block)
        {
    	    return block == Blocks.grass || block == Blocks.dirt || block == Blocks.farmland;
        }


    If you don't want it to grow on anything but your blocks, just make that:
        protected boolean canPlaceBlockOn(Block block)
        {
    	    return block == MyMod.myBlock;
        }
    Posted in: Modification Development
  • 0

    posted a message on [1.7.2] [Forge] TileEntities not reloading/Blocks not re-rendering?
    Ok, I fixed the problem. Lil' hacky, but whatever.

    First off, I created a new class:

    package org.abimon.mods.minecraft.colouredBlocks;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.world.World;
    
    public class UpdateThread extends Thread
    {
        World w;
        int x, y, z;
        int milliseconds;
        
        public UpdateThread(World w, int x, int y, int z, int milliseconds)
        {
            this.w = w;
            this.x = x;
            this.y = y;
            this.z = z;
            this.milliseconds = milliseconds;
        }
        
        public void run()
        {
            while(true)
            {
                try
                {
                    if(milliseconds == 0)
                    {
                        Minecraft.getMinecraft().renderGlobal.markBlockForUpdate(x, y, z);
                        w.markBlockForUpdate(x, y, z);
                        break;
                    }
                    milliseconds--;
                    Thread.sleep(1);
                }
                catch(Throwable th){}
            }
        }
    }


    Then, above the 'return false', I have this:
            UpdateThread ut = new UpdateThread(world, x, y, z, 100);
            ut.start();
    Posted in: Modification Development
  • 0

    posted a message on [1.7.2] [Forge] TileEntities not reloading/Blocks not re-rendering?
    Quote from SynthTones
    Try marking the block for an update? That seemed to fix some sync issues for me.


    Like this?

    Quote from UnderMybrella

    Minecraft.getMinecraft().renderGlobal.markBlockForUpdate(x, y, z); return true; } } else; Minecraft.getMinecraft().renderGlobal.markBlockForUpdate(x, y, z); return false; }
    Posted in: Modification Development
  • 0

    posted a message on [1.7.2] [Forge] TileEntities not reloading/Blocks not re-rendering?
    So I recently started work on a mod, and I ran into an issue - my TileEntities weren't reloading, or at least the client wasn't showing it!

    The issue is that my block, which gets its colour from the TileEntity, won't update accordingly, when the TileEntity is. I've put in the appropriate packet sending data, a function to update the block, but it's not showing the new colour!

    The other interesting thing is that, when I reload the world, the block displays the correct colour, so that's something.

    Anyone got any ideas?

    Code:

    BlockColoured:

    package org.abimon.mods.minecraft.colouredBlocks;
    
    import java.awt.Color;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.block.Block;
    import net.minecraft.block.ITileEntityProvider;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.Minecraft;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.IIcon;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    
    public class BlockColoured extends Block implements ITileEntityProvider, IColourable{
    
        public BlockColoured() {
            super(Material.cake);
        }
    
        @Override
        public TileEntity createNewTileEntity(World var1, int var2) {
            return new TileEntityColoured();
        }
    
        public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int face, float posX, float posY, float posZ)
        {
            System.out.println("Activated!");
            ItemStack item = player.getHeldItem();
            if(!(item.getItem() instanceof IColouring))
                return false;
            if(!world.isRemote)
                if(!player.isSneaking())
                {
                    TileEntity te = world.getTileEntity(x, y, z);
                    if(te instanceof TileEntityColoured)
                    {
                        ((TileEntityColoured) world.getTileEntity(x, y, z)).setColor(((IColouring) item.getItem()).getColour(item));
                        Minecraft.getMinecraft().renderGlobal.markBlockForUpdate(x, y, z);
                        return true;
                    }
                }
                else;
            Minecraft.getMinecraft().renderGlobal.markBlockForUpdate(x, y, z);
            return false;
        }
    
        @Override
        public void clearColour(World world, int x, int y, int z, EntityPlayer player)
        {    
            if(!world.isRemote)
            {
                TileEntity te = world.getTileEntity(x, y, z);
                if(te instanceof TileEntityColoured)
                    ((TileEntityColoured) te).setColor(Color.WHITE);
            }
        }
    
        @SideOnly(Side.CLIENT)
        public int colorMultiplier(IBlockAccess access, int x, int y, int z)
        {
            TileEntity te = access.getTileEntity(x, y, z);
            if(te instanceof TileEntityColoured)
            {
                return ((TileEntityColoured) te).getColor();
            }
            return 16777215;
        }
    
        @Override
        public Color getColour(World world, int x, int y, int z, EntityPlayer player) {
            if(!world.isRemote)
            {
                TileEntity te = world.getTileEntity(x, y, z);
                if(te instanceof TileEntityColoured)
                    return ((TileEntityColoured) te).color;
            }
            return Color.WHITE;
        }
        
        @SideOnly(Side.CLIENT)
        public IIcon getIcon(IBlockAccess access, int x, int y, int z, int p_149673_5_)
        {
            Block below = access.getBlock(x, y - 1, z);
            if(below == null)
                return this.blockIcon;
    	    return below.getIcon(access, x, y - 1, z, p_149673_5_);
        }
    
    }


    TileEntityColoured:

    package org.abimon.mods.minecraft.colouredBlocks;
    
    import java.awt.Color;
    
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.network.NetworkManager;
    import net.minecraft.network.Packet;
    import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
    import net.minecraft.tileentity.TileEntity;
    
    public class TileEntityColoured extends TileEntity
    {
        Color color = new Color(255, 0, 255);
        int rgb = color.getRGB();
        
        public void readFromNBT(NBTTagCompound nbt)
        {
            super.readFromNBT(nbt);
            color = new Color(nbt.getInteger("Red"), nbt.getInteger("Green"), nbt.getInteger("Blue"));
            rgb = color.getRGB();
        }
        
        public void writeToNBT(NBTTagCompound nbt)
        {
            super.writeToNBT(nbt);
            nbt.setInteger("Red", color.getRed());
            nbt.setInteger("Green", color.getGreen());
            nbt.setInteger("Blue", color.getBlue());
        }
        
        public int getColor()
        {
            return rgb;
        }
        
        public void setColor(Color color)
        {
            this.color = color;
            rgb = color.getRGB();
            NBTTagCompound nbt = new NBTTagCompound();
            writeToNBT(nbt);
            nbt.setInteger("Red", color.getRed());
            nbt.setInteger("Green", color.getGreen());
            nbt.setInteger("Blue", color.getBlue());
            readFromNBT(nbt);
        }
        
    
        public Packet getDescriptionPacket()
        {
            NBTTagCompound nbttagcompound = new NBTTagCompound();
            this.writeToNBT(nbttagcompound);
            return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 17, nbttagcompound);
        }
    
        /**
         * Called when you receive a TileEntityData packet for the location this
         * TileEntity is currently in. On the client, the NetworkManager will always
         * be the remote server. On the server, it will be whomever is responsible for
         * sending the packet.
         *
         * @param net The NetworkManager the packet originated from
         * @param pkt The data packet
         */
        public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
        {
            readFromNBT(pkt.func_148857_g());
        }
    }

    Posted in: Modification Development
  • 0

    posted a message on [1.6.4 Forge] How Do I Save Player Names Into A .txt or ,cfg file
    Quote from Pokeyletsplays

    mind sending me a tutorial or something that explains item nbt?


    I essentially taught myself, but NBT isn't that hard.

    It works on a key-value system, with a bunch of different tag types. You have Integers, IntegerArrays, Strings, Floats, Booleans, Lists and even another Compound.
    ItemStacks have a method called getTagCompound(). This will return the itemstack's NBTTagCompound, if it has one. I highly recommend putting in a null check:
    if(nbt == null)
    {
    //Initialise default variables
    itemstack.setTagCompound(nbt);
    }

    The methods you need to worry about are .set<tag type>(key, tag), and .get<tag type>(key)

    For your needs, when it's defined, we need to set lifeSteal to it's default value (Unless that's 0, in which case don't bother).
    Since lifeSteal is an integer, all we need to do is:
    nbt.setInteger("LifeSteal", 4); //Or default value
    itemstack.setTagCompound(nbt);

    Every time we increase it, similar deal:
    nbt.setInteger("LifeSteal", nbt.getInteger("LifeSteal") + 1);
    itemstack.setTagCompound(nbt);
    Posted in: Modification Development
  • 1

    posted a message on [1.6.4 Forge] How Do I Save Player Names Into A .txt or ,cfg file
    Quote from Puredarkness

    That would be true if lifeSteal was static, which it isn't.


    Actually, regardless of if it's static or not, it's a class variable in a variable that is initialised once, and once alone.

    Minecraft handles items and blocks interestingly. If variables were unique per instance, then what would the point of TileEntities and ItemStacks be? We could just store that data in BlockChest or ItemEnchantedBook/whatever.

    That's why it's important to use NBT data when you're dealing with unique data - you need to keep it separate from other items/blocks.
    Posted in: Modification Development
  • 1

    posted a message on [1.6.4 Forge] How Do I Save Player Names Into A .txt or ,cfg file
    lifeSteal is not unique per item - it is universal for every instance of that item. Have a look at NBT data, that is stored per item. You can then map the using players name to that if necessary
    Posted in: Modification Development
  • 0

    posted a message on Removing Blocks from Search?
    That's weird, my items aren't. What code are you using?
    Posted in: Modification Development
  • 0

    posted a message on Removing Blocks from Search?
    If we're talking Creative Mode search:
    Just don't give it a creative tab
    Posted in: Modification Development
  • 1

    posted a message on Removing Enchantment from Enchanting Table
    Here ya go. I even gave it fancy JavaDocs :)

    /** Removes an enchantment from the possible enchantments
      * @param enchantment - The enchantment to remove
      * @param removeFromBooks - Should the enchantment be removed from books?
      * @param removeFromTools - Should the enchantment be removed from tools?
      */
    public static void removeEnchantment(Enchantment enchantment, boolean removeFromBooks, boolean removeFromTools)
    {
      if(removeFromBooks)
       Enchantment.enchantmentsBookList[enchantment.effectId] = null;
      if(removeFromTools)
       Enchantment.enchantmentsList[enchantment.effectId] = null;
    }
    Posted in: Modification Development
  • 0

    posted a message on Decrease item amount in inventory over time?
    I see 2 problems with your code:

    1) Minecraft doesn't initialise separate items from the item class. That's why ItemStack exists. Therefore, if I have 100 people on the server, each wearing 1 piece of armor, 't' is gonna increase by 100 each tick.

    2, or actually 1a) The more armor you have, the faster it decreases (Not sure if intended)

    Solution: You have two ways of doing this - The best one is to use NBT Data to store 't' per itemstack. Increase 't' by 1 every tick using the NBT data.

    The other way is to store a static HashMap of player names/UUID's to 't', and save and load it, etc.
    Posted in: Modification Development
  • 0

    posted a message on [Solved][Forge][1.7.2] Saving data about player when clicking block
    Quote from coolAlias

    It's nothing to worry about; getTileEntity will give you the instance for the coordinates x, y, z, if a TileEntity exists there, and, barring any bizarre circumstances, this instance will be the correct type for the block that exists there. As long as you type-check before casting, you will never get a class cast exception, and probably would never get them anyway without it, but it's cheap to do.

    My point to the OP was simply that modifying the variable after getting and casting the TileEntity instance is sufficient, as you are already modifying the TileEntity directly that way, so calling setTileEntity(the_same_instance_that_it_already_is) is redundant at best, and could have weird unforeseen consequences at worst (unlikely as those may be).


    Hm, thanks for that. I haven't noticed any side effects, so I'll take that out of my code. Thanks!
    Posted in: Modification Development
  • 0

    posted a message on [Solved][Forge][1.7.2] Saving data about player when clicking block
    Quote from UnderMybrella
    Probably not related, but in onBlockClicked: Change: if(tex.playerName == player.getCommandSenderName()) to if(tex.playerName.equals(player.getCommandSenderName())) Java doesn't compare strings with ==, it uses .equals()

    Not sure if you saw this, but I think it might be tricking you into thinking it doesn't save the data - that statement is *almost* always, if not always, going to return false! Change == to .equals(...)

    Quote from coolAlias
    One other thing I noticed, that probably isn't breaking your code but is still not necessary and is probably harmful, is that you use 'world.setTileEntity' with the tile entity that you just got and modified, but there is no reason to set the tile entity unless you are changing the type of tile entity that is at that location (which you should never do anyway).


    Could you expand on this? I know that Minecraft does some fancy pointer stuff, but does that also apply to .getTileEntity()? If it does, then modifying the variable should be sufficient, but otherwise you'd need to save your changes (Also, not sure how casting affects it?)
    Posted in: Modification Development
  • 0

    posted a message on [Solved][Forge][1.7.2] Saving data about player when clicking block
    Probably not related, but in onBlockClicked:
    Change:
    if(tex.playerName == player.getCommandSenderName())
    to
    if(tex.playerName.equals(player.getCommandSenderName()))

    Java doesn't compare strings with ==, it uses .equals()
    Posted in: Modification Development
  • To post a comment, please or register a new account.