Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

This is the code causing me few problems:

Lvl0Id[count] = world.getBlockId(x, y, z);

                        count++;

 

 

int count = 0;
        int y = pos.getY() - 1;
        boolean Test = true;
            for (int x = pos.getX() + 3; x > pos.getX() - 4; x--)
            {
                for (int z = pos.getZ() - 2; z < pos.getZ() + 2; z++)
                {
                    if (x == pos.getX() + 3 && z == pos.getZ() - 2 || x == pos.getX() + 3 && z == pos.getZ() + 1 || x == pos.getX() - 3 && z == pos.getZ() - 2 || x == pos.getX() - 3 && z == pos.getZ() + 1)
                    {
                        continue;
                    } else
                    {
[b]Original code[/b]
                        Lvl0Id[count] = world.getBlockId(x, y, z);
                        count++;
[b]was experimenting with block states but couldn't return an int.[/b]
                        Lvl0Id[count] = state.getValue(x,y,z);
                        count++;

                        Lvl0Id[count] = worldIn.getBlockState(new BlockPos(x,y,z)).getBlock());
                        count++;
                        if (worldIn.isBlockFullCube(new BlockPos(x,y,z)))
                        {
                            continue;
                        } else
                        {
                            //Error = "error code here";
                            //Test = false;
                            continue;
                        }
                    }
                }
            }

 

 

Been awhile since I've done any modding, thought someone could help shine some light :)

Developer of CampCraft

World#getBlockState

returns the current state of the block at the specified position.

 

Numeric block IDs are automatically assigned per-world and can change on world load. You should avoid using them if at all possible.

 

What are you actually trying to do? What is the

Lvl0Id

array for?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

Was trying to use a loop to check if an area of blocks is flat and if a block is missing return an-ingame error message to the player.

 

using the array to check number of blocks on the ground

 

Lvl0Id = new int[24];

Developer of CampCraft

I don't understand why you need an array of block IDs, but you should probably replace it with an array of

Block

s (the block type) or

IBlockState

s (essentially a

Block

and metadata).

 

You can read more about block states here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

What version are you upgrading from? MC 1.6.2?

 

Why to 1.8.9? If upgrading, you should if possible aim for the latest MC version supported by Forge.

 

And what are the problems? Do you have a crash report or Forge log to post?

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

  • Author

 

 

Thanks for the link, got code working :) when I first started coding was easier to check the block ids as mc didn't have many blocks, I've got the code checking the block material types which seems to be working fine now :)

 

 

 

Was upgrading from 1.5.2. Problem was I was checking for the block ids of a loop of blocks to check no blocks are missing but couldn't call the block id as we have blockstates now,

 

When I started few weeks ago wasn't a recommended 1.9 version and plan was to update to 1.8.9 then update to 1.9. Code shouldn't of changed to much between versions.

 

Developer of CampCraft

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.