Jump to content

SamTebbs33

Forge Modder
  • Posts

    79
  • Joined

  • Last visited

Posts posted by SamTebbs33

  1. canHarvestBlock(...) - DOESN'T allow, because it is player-specific check. Why the hell would you even use this check if player is NOT harvesting given block? Just don't use it. If you really need some safety check - do it yourself, write helper method similar to canHarvestBlock. What is so difficult?

     

    I just thought that canHarvestBlock() was the general (not player-specific) way of checking if a block is harvestable and thought I should be calling it in order to not harvest blocks that shouldn't be harvestable by a non-player entity/machine. Please don't get so hostile all of a sudden.

  2. I am writing some code that will harvest a number of blocks around it (all of which implement IGrowable) and to stop abuse and breaking the mechanics of other mods I will need to check if the block is harvest-able with canHarvestBlock(...) and then harvest it with harvestBlock(...) if it is. These methods require an EntityPlayer object, which isn't applicable since the code will be run from within a tile entity. I could pass null as the player value but I never like doing that due to the risk of running into an NPE. Is there some accepted or established method of checking if a block is harvest-able and then harvesting it without using an EntityPlayer object? I'm open to using libraries.

  3. My world generator is only called in ocean biome chunks (using scala).

     

    Code that prints the biome (worldGen.scala):

     

    override def generate(random: Random, chunkX: Int, chunkZ: Int, world: World, chunkGenerator: IChunkGenerator, chunkProvider: IChunkProvider): Unit = {
        println(world.getBiomeProvider.getBiomeGenerator(new BlockPos(chunkX, 0, chunkZ)))
    }

     

    Registration code (in common proxy init method):

     

    GameRegistry.registerWorldGenerator(new WorldGen, 10)

     

    When generating a new world or travelling over un-generated chunks (that aren't ocean biomes) it prints out BiomeOcean@xxxxx

  4. Back in 1.7 an before, I had made a system that assigned textures to blocks with support for their names and having different textures for different sides of the block (the code would handle displaying the relevant side by using metadata based on rotation), but now that metadata has been abandoned and textures have to be designated in a .json file (WHY MOJANG!?!?!?!!?), this system is completely broken. What was great about my old system was that I only had to provide the textures in the resource path and then give each block an unlocalised name and the rest was processed by the mod. How would I achieve a similar system but using the new (annoying) .json system?

  5. If you want to make a block that clings to the side of something, you'll need to change its block bounds. If you override the setBlockBoundsBasedOnState method in Block, you can set block bounds for distinct blocks in the world by using setBlockBounds(minx, minY, minZ, maxX, maxY, maxZ)

     

    Changing the block bounds will make your block less like a cube, depending on what you set them to.

     

  6. IF you want to create the item, you'll need to make an item class like normal and then override the onItemUse method in Item and use the following code in the overridden method.

     

    You will need to change Block.cocoaPlant.blockID to the ID of your grape block and Block.wood.blockID to the ID of the block you want to plant the grape on.

     

    int i1 = par3World.getBlockId(par4, par5, par6);

                    int j1 = par3World.getBlockMetadata(par4, par5, par6);

     

                    if (i1 == Block.wood.blockID && BlockLog.limitToValidMetadata(j1) == 3)

                    {

                        if (par7 == 0)

                        {

                            return false;

                        }

     

                        if (par7 == 1)

                        {

                            return false;

                        }

     

                        if (par7 == 2)

                        {

                            --par6;

                        }

     

                        if (par7 == 3)

                        {

                            ++par6;

                        }

     

                        if (par7 == 4)

                        {

                            --par4;

                        }

     

                        if (par7 == 5)

                        {

                            ++par4;

                        }

     

                        if (par3World.isAirBlock(par4, par5, par6))

                        {

                            int k1 = Block.blocksList[block.cocoaPlant.blockID].onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, 0);

                            par3World.setBlock(par4, par5, par6, Block.cocoaPlant.blockID, k1, 2);

     

                            if (!par2EntityPlayer.capabilities.isCreativeMode)

                            {

                                --par1ItemStack.stackSize;

                            }

                        }

     

                        return true;

                    }

  7. Hi, is it possible to get the coordinates of every wood block in a tree? I realise that this could be done by just searching for all wood blocks in a radius, but that would also return wood blocks not actually part of the tree and even blocks connected to the tree by leaves.

     

    I know that tree feller mods do this somehow.

     

    Thanks in advance

  8. Thanks for the feedback, but I tried it and the list size is 0 even if there are loads of items around the mod using this method:

     

    public static List getEntityItemsInRadius(World world,
        double x, double y, double z, int radius) {
    
    List list = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getAABBPool().getAABB(x-radius, y-radius, z-radius, x + radius, y + radius, z + radius));
    
    return list;
    
        }

     

    radius = 10

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.