Jump to content

Recommended Posts

Posted

ok next problem, this block should be placeable on itself but is not also sometimes when it grows it auto breaks i think this is linked to the first error, it is a sugar cane esq block

package ashtonsmod.common;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.IPlantable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockIngotBush extends Block implements IPlantable
{
    protected BlockIngotBush(int par1)
    {
        super(par1, Material.plants);
        float f = 0.375F;
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f);
        this.setTickRandomly(true);
    }

    /**
     * Ticks the block if it's been scheduled
     */
    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (par1World.isAirBlock(par2, par3 + 1, par4))
        {
            int l;

            for (l = 1; par1World.getBlockId(par2, par3 - l, par4) == this.blockID; ++l)
            {
                ;
            }

            if (l < 3)
            {
                int i1 = par1World.getBlockMetadata(par2, par3, par4);

                if (i1 == 15)
                {
                    par1World.setBlock(par2, par3 + 1, par4, this.blockID);
                    par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 4);
                }
                else
                {
                    par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 + 1, 4);
                }
            }
        }
    }


    /**
     * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
     */
    public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
    {
        Block block = Block.blocksList[par1World.getBlockId(par2, par3 - 1, par4)];
        return (block != null && block.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this));
    }

    /**
     * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
     * their own) Args: x, y, z, neighbor blockID
     */
    public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
    {
        this.checkBlockCoordValid(par1World, par2, par3, par4);
    }

    /**
     * Checks if current block pos is valid, if not, breaks the block as dropable item. Used for reed and cactus.
     */
    protected final void checkBlockCoordValid(World par1World, int par2, int par3, int par4)
    {
        if (!this.canBlockStay(par1World, par2, par3, par4))
        {
            this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
            par1World.setBlockToAir(par2, par3, par4);
        }
    }
    /**
     * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
     */
    public boolean canBlockStay(World par1World, int par2, int par3, int par4)
    {
        return this.canPlaceBlockAt(par1World, par2, par3, par4);
    }

//drops
    public int idDropped(int par1, Random par2Random, int par3)
    {
       
                    int w = par2Random.nextInt(;
                    if (w == 0)
                    {
                            return ashtonsmod.IngotBush.blockID;
                    }
                    if (w == 1)
                    {
                            return ashtonsmod.Amethyst.itemID;
                    }
                    if (w == 2)
                    {
                            return ashtonsmod.LightSteelNugget.itemID;
                    }
                    if (w == 3)
                    {
                            return Item.ingotGold.itemID;
                    }
                    if (w == 4)
                    {
                            return Item.ingotIron.itemID;
                    }
                    if (w == 5)
                    {
                            return Item.emerald.itemID;
                    }
                    if (w == 6)
                    {
                            return Block.obsidian.blockID;
                    }
                    if (w == 7)
                    {
                            return Item.coal.itemID;
                    }
                    else
                    {
                            return Item.diamond.itemID;
                    }                
    }

    public int quantityDroppedWithBonus(int par1, Random par2Random)
    {
            return quantityDropped(par2Random) + par2Random.nextInt(par1 + 1);
    }

    public int quantityDropped(Random par1Random)
    {
            return 1 + par1Random.nextInt(2); 
    }

    /**
     * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
     * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
     */
    public boolean isOpaqueCube()
    {
        return false;
    }

    /**
     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
     */
    public boolean renderAsNormalBlock()
    {
        return false;
    }

    /**
     * The type of render function that is called for this block
     */
    public int getRenderType()
    {
        return 1;
    }

    @SideOnly(Side.CLIENT)

    /**
     * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
     */
    public int idPicked(World par1World, int par2, int par3, int par4)
    {
        return ashtonsmod.IngotBush.blockID;
    }

    @Override
    public EnumPlantType getPlantType(World world, int x, int y, int z)
    {
        return EnumPlantType.Beach;
    }

    @Override
    public int getPlantID(World world, int x, int y, int z)
    {
        return blockID;
    }

    @Override
    public int getPlantMetadata(World world, int x, int y, int z)
    {
        return world.getBlockMetadata(x, y, z);
        
    }
    @Override
    public void registerIcons(IconRegister par1IconRegister)
    {
        this.blockIcon = par1IconRegister.registerIcon("ashtonsmod:BlockIngotBush");
    }

Use examples, i have aspergers.

Examples make sense to me.

Posted

Place breakpoints inside the relevant methods, and see what happens when the IF statments are executed, see how the variables and then you should be able to tell why it's not placed correctly.

If you guys dont get it.. then well ya.. try harder...

Posted

whats a breakpoint?

and isnt there one specific area of code that allows sugar can to be allowed to be placed on itself?

Use examples, i have aspergers.

Examples make sense to me.

Posted

[lmgtfy=breakpoints debugging eclipse]Learn all about breakpoints, debugging and debuggers by clicking this link.[/lmgtfy]

 

Debugging is an essential skill to have as a programmer of ANY language.

print out statements and of course the use of the integrated debugger of eclipse is a MUST to learn about!

If you guys dont get it.. then well ya.. try harder...

Posted

i did and as i was i realized that it was hard and i don't know a lot of java, before you go tell me to go learn it i own a java for dummies book already and am starting ok?

Use examples, i have aspergers.

Examples make sense to me.

Posted

Good you are learning Java, and the basics of how breakpoints work can't be that hard to grasp.

it's a way to stop the program at a certain point inn the code, to see what's going on.

Just being able to stop and step by step look at what it does ain't that hard to understand I would believe?

 

The reasons why I tell you to learn this ain't to be a jerk, it's because it will be a vital skill for you to have when coding and creating programs/mods.

 

But honestly if setting a break point is hard, then I suggest you focus more on learning java than on modding first :) I would recommend watching CS106a from stanford, it's a brilliant lecture series and it's freely available here: http://see.stanford.edu/see/lecturelist.aspx?coll=824a47e1-135f-4508-a5aa-866adcae1111

 

If you have doubts wether or not it's for you then just check out the first video. also all handouts and assignments etc. are included for download on the page. Even tough this is a course from a university it's aimed towards people who have NO prior coding experience and no special education inn computers at all!

I just finished watching the later lecture series and I recommend it to anyone wanting to learn programming :)

 

 

as for your problem with the plant, I would check the method "canPlaceBlockAt" since the problem is it's breaking when it shouldnt.

If you guys dont get it.. then well ya.. try harder...

Posted

i think the problem is the block list that it is getting doesnt have my custom block in it,

 Block block = Block.blocksList[par1World.getBlockId(par2, par3 - 1, par4)]; 

this is where the blocklist is declared

public static final Block[] blocksList = new Block[4096];

 

but i dont know what the 4096 stands for? its not block id, i think i need to make a new blocklist with my own block in it but i am not sure how?

 

this is my best guess on how to fix this error :)

Use examples, i have aspergers.

Examples make sense to me.

Posted

That is the main block list which stores ALL the blocks inn the game.

If you block is a block at all, then it will be inn that list.

As long as your block extends Block then it will have a constructor asking for an ID which is used to store it inside the block list.

 

4096 is the decleared size of the Block[](Block Array)

If you guys dont get it.. then well ya.. try harder...

Posted

still havnt solved this cos i am a derp :P i tried for a bit and looked at arrays as you suggested, i just keep putting it off now it is hard :/

Use examples, i have aspergers.

Examples make sense to me.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

×
×
  • Create New...

Important Information

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