Jump to content

Recommended Posts

Posted

Im trying to replace a specific set of blocks with air... I'm trying to replace 35 blocks at once by redstone activation.

Any help is apreciated.

 

Here's the error:

 

  Reveal hidden contents

 

 

And the class file:

 

  Reveal hidden contents

 

I took over Hunting Traps Mod and work on helping the forge community as much as I can. View my work here: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1443756-1-7-2-1-6-4-1-5-2-1-4-7-hunting-traps-mod-v-0-4-0

Posted

You are trying to replace the blocks in your block's constructor.

 

There are two problems with this:

 

1) The constructor happens before the game has reached the main menu

2) You are trying to access methods of a null object.  That is, your world variable is declared but not defined.  For obvious reasons.  Not to mention that i, j, and k are also null!

 

You should be doing this code either onEntityCollidedWithBlock or onBlockActivated or similar.  Where the world is passed to your block class.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You may want to take a look at your variables i j and k, This may be causing your null pointer. Also, be careful using static variables here because you could get problems concerning threading. Try putting this into the block or a TileEntity instead as a local method and pass it the required parameters through the method.

 

Personally i'd also suggest (just as a bit of cleanup) that you reuse your parX variables so you only have one, and reassign it new values, this will just free up a small amount of memory space and make things look nicer.

 

public class MyTE extends TileEntity
{
    @Override
    public void onUpdate()
    {
        if(this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))
        {
            int id = this.worldObj.getBlockId(xCoord+1, yCoord, zCoord);
            if(id==1)
                world.setBlockId(xCoord+1, yCoord, zCoord, 0);
            id = this.worldObj.getBlockId(xCoord+1, yCoord+1, zCoord);
            if(id==1)
                world.setBlockId(xCoord+1, yCoord+1, zCoord, 0);
            //and so on
        }
    }
}

 

 

  On 6/16/2013 at 2:27 PM, Draco18s said:

You are trying to replace the blocks in your block's constructor.

 

There are two problems with this:

 

1) The constructor happens before the game has reached the main menu

2) You are trying to access methods of a null object.  That is, your world variable is declared but not defined.  For obvious reasons.  Not to mention that i, j, and k are also null!

 

You should be doing this code either onEntityCollidedWithBlock or onBlockActivated or similar.  Where the world is passed to your block class.

 

He is calling this from his block, in the on neighbor block changed, so it is called only when the block is in the world

  Quote

2013-06-16 02:08:03  [sTDERR]    at huntingTraps.Resources.PitfallHandler.iftrap(PitfallHandler.java:13)

2013-06-16 02:08:03  [sTDERR]    at huntingTraps.Traps.Pitfall.onNeighborBlockChange(Pitfall.java:29)

however yes he should be doing it in his block/tileEntity

Posted

I am indeed throwing this method only when needed by another block. this is my attempt at only changing certain blocks.

 

I'm trying to write the coordinates to a variable then have the file each variable checked against certain id numbers. if it is on a predetermined list then it gets turned to air.

I took over Hunting Traps Mod and work on helping the forge community as much as I can. View my work here: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1443756-1-7-2-1-6-4-1-5-2-1-4-7-hunting-traps-mod-v-0-4-0

Posted

Just so you know:

 

par12 == (1|2|3|4|12|13)

 

That won't do what you think it does.

 

1|2|3|4|12|13 == 16.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 6/16/2013 at 4:58 PM, dontrell94 said:

how do i do or?

 

par12 == 1 || par12 ==2 || par12 == 3...

 

This is a fundamental basic understanding of programming.  The fact that you had to ask this question means you're not actually ready to mod Minecraft.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 6/16/2013 at 4:58 PM, Draco18s said:

  Quote

how do i do or?

 

par12 == 1 || par12 ==2 || par12 == 3...

 

This is a fundamental basic understanding of programming.  The fact that you had to ask this question means you're not actually ready to mod Minecraft.

Another of the many shortcomings of Java. With Python, you can do

if par12 in (1,2,3,4,12,13):
    #stuff

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted
  On 6/16/2013 at 4:58 PM, Draco18s said:

  Quote

how do i do or?

 

par12 == 1 || par12 ==2 || par12 == 3...

 

This is a fundamental basic understanding of programming.  The fact that you had to ask this question means you're not actually ready to mod Minecraft.

 

No I'm still learning as I go, I forgot about that.......I feel stupid

I took over Hunting Traps Mod and work on helping the forge community as much as I can. View my work here: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1443756-1-7-2-1-6-4-1-5-2-1-4-7-hunting-traps-mod-v-0-4-0

Posted

I feel like a know all in this situation...

 

try something like this:

package huntingTraps.Resources;

import net.minecraft.world.World;

public class PitfallHandler
{  
    public static World world; // the world you are using
    public static int i, j, k; // X, Y, and Z axis variables

    public PitfallHandler(World world, int x, int y, int x)
    {
        this.world = world; // the world
        this.i = x; // X axis
        this.j = y; // Y axis
        this.k = z; // Z axis
    }
    
    public static void generatePitfall()
    {
        // this nested for loop will make a 'block' of air to the dimensions specified in numOfBlocksOn***
        for(int x = 0; x < numOfBlocksOnXAxis; ++x)
        {
            for(int y = 0; y < numOfBlocksOnYAxis; ++y)
            {
                for(int z = 0; z < numOfBlocksOnZAxis; ++z)
                {
                    world.setBlock(
                       i + x, // this makes blocks of air go out however many numOfBlocksOnXAxis was
                       j - y, // this makes blocks of air go out however many numOfBlocksOnYAxis was
                       k + z, // this makes blocks of air go out however many numOfBlocksOnZAxis was
                       00 // the block of air
                       );
                }
            }
        }
    }
}

 

Then in the onBlockActivated() method, have something like this inside it:

PitfallHandler pit = new Pitfallhandler(Minecraft.getMinecraft().theWorld, (location of block x, y and z coords in the next 3 paramaters) xLocation, yLocation, zLocation);
pit.generatePitfall();

 

I garuntee that the PitfallHandler will work, the other... well :P

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Posted
  On 6/17/2013 at 6:03 AM, Mew said:

I feel like a know all in this situation...

 

try something like this:

~snip~

 

 

I garuntee that the PitfallHandler will work, the other... well :P

 

I think the NPE you're getting comes from code order.

 

If you can single-step the code at the function, you can find the exact point where the NPE is thrown.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Posted

then surround

world.setBlock(
                       i + x, // this makes blocks of air go out however many numOfBlocksOnXAxis was
                       j - y, // this makes blocks of air go out however many numOfBlocksOnYAxis was
                       k + z, // this makes blocks of air go out however many numOfBlocksOnZAxis was
                       00 // the block of air
                       );

with

if(world.getBlockId(i+x, j-y, k+z) == Block.stone.blockId)//or whatever blockId you want

Posted

Just as an FYI on Mew's code.

 

Don't make x y and z static...or hell, even the world (there's a different world object for each dimension!)

 

As soon as you have two of these suckers placed things will Go Weird.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 6/17/2013 at 6:42 PM, dontrell94 said:

It didn't look right as static, so mine isn't

 

Are you passing them to generatePitfall()?  Or are you pretending that they get magically set every time you want to use them?

That is:

Dynamic class-level variables aren't going to fix it alone.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Tell me if i'm wrong....

 

Main block:

 

  Reveal hidden contents

 

 

Handler:

 

  Reveal hidden contents

 

I took over Hunting Traps Mod and work on helping the forge community as much as I can. View my work here: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1443756-1-7-2-1-6-4-1-5-2-1-4-7-hunting-traps-mod-v-0-4-0

Posted

I'm surprised this didn't throw an error.  You don't have enough parameters.

 

world.setBlock(
                                i + x, // this makes blocks of air go out however many numOfBlocksOnXAxis was
                                j - y, // this makes blocks of air go out however many numOfBlocksOnYAxis was
                                k + z, // this makes blocks of air go out however many numOfBlocksOnZAxis was
                                00, // the block of air
                                3 //tells the client and server that a block update is required.
                                );

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

My bad.

Ever since they changed things from "setBlock/setBlockWithNotify/setBlockAndMetadata/setBlockAndMetadataWithNotify" to only one function (actually, two) they've thrown me for a loop.

 

You are correct, yours works and passes an implied metadata of 0 and a notify flag of 3.

 

Just out of curiosity:

You are doing this with the block on top of stone, yes?  It's only clearing a 2x2x2 cube at the moment, and only stone.

 

(Side note:

new PitfallHandler(Minecraft.getMinecraft().theWorld, i, j, k);

You can just use:

new PitfallHandler(world, i, j, k);

As the world is passed to the neighborChanged function)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

    • Looks like an issue with biomeswevegone
    • In the server.properties, set max-tick-time to -1   if there are further issues, make a test without distanthorizons
    • Verified user can get a $300 off TℰℳU Coupon code using the code ((“{{ '[''com31844'']}}”)). This TℰℳU $100Off code is specifically for new and existing customers both and can be redeemed to receive a $100discount on your purchase. Our exclusive TℰℳU Coupon code offers a flat $100off your purchase, plus an additional 100% discount on top of that. You can slash prices by up to $100as a new TℰℳU customer using code ((“{{ '[''com31844'']}}”)). Existing users can enjoy $100off their next haul with this code. But that’s not all! With our TℰℳU Coupon codes for 2025, you can get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our TℰℳU codes provide extra discounts tailored just for you. Save up to 100% with these current TℰℳU Coupons ["^"{{ '[''com31844'']}} "^"] for April 2025. The latest TℰℳU coupon codes at here. New users at TℰℳU receive a $100discount on orders over $100Use the code ((“{{ '[''com31844'']}}”)) during checkout to get TℰℳU Coupon $100Off For New Users. You can save $100Off your first order with the coupon code available for a limited time only. TℰℳU 90% Off promo code ((“{{ '[''com31844'']}}”)) will save you $100on your order. To get a discount, click on the item to purchase and enter the coe. Yes, offers $100Off coupon code “{{ '[''com31844'']}}” for first time users. You can get a $100bonus plus $100Off any purchase at TℰℳU with the $100Coupon Bundle at TℰℳU if you sign up with the referral code ((“{{ '[''com31844'']}}”)) and make a first purchase of $100or more. Free TℰℳU codes $100off — ((“{{ '[''com31844'']}}”)) Get a $100discount on your TℰℳU order with the promo code "{{ '[''com31844'']}}". You can get a discount by clicking on the item to purchase and entering this TℰℳU Coupon code $100off ((“{{ '[''com31844'']}}”)). ŢℰNew User Coupon ((“{{ '[''com31844'']}})): Up To $100OFF For First-Time Users Our TℰℳU first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on TℰℳU To maximize your savings, download the TℰℳU app and apply our TℰℳU new user coupon during checkout. TℰℳU Coupon Codes For Existing Users ((“{{ '[''com31844'']}}”)): $100Price Slash Have you been shopping on TℰℳU or a while? Our TℰℳU Coupon for existing customers is here to reward you for your continued support, offering incredible discounts on your favorite products. TℰℳU Coupon For $100Off ((“{{ '[''com31844'']}}”)): Get A Flat $100Discount On Order Value Get ready to save big with our incredible TℰℳU Coupon for $100off! Our amazing ŢℰM$100off coupon code will give you a flat $100discount on your order value, making your shopping experience even more rewarding. TℰℳU Coupon Code For $100Off ((“{{ '[''com31844'']}}”)): For Both New And Existing Customers Our incredible TℰℳU Coupon code for $100off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our $100off code for TℰℳU will give you an additional discount! TℰℳU Coupon Bundle ((“{{ '[''com31844'']}}”)): Flat $100Off + Up To $100Discount Get ready for an unbelievable deal with our TℰℳU Coupon bundle for 2025! Our TℰℳU Coupon bundles will give you a flat $100discount and an additional $100off on top of it. Free TℰℳU Coupons ((“{{ '[''com31844'']}}”)): Unlock Unlimited Savings! Get ready to unlock a world of savings with our free TℰℳU Coupons! We’ve got you covered with a wide range of TℰℳU Coupon code options that will help you maximize your shopping experience. 100% Off TℰℳU Coupons, Promo Codes + 25% Cash Back ((“{{ '[''com31844'']}}”)) Redeem TℰℳU Coupon Code ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FOR EXISTING CUSTOMERS ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FIRST ORDER ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF REDDIT ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FOR EXISTING CUSTOMERS REDDIT ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF CODE ((“{{ '[''com31844'']}}”)) TℰℳU 70 OFF COUPON 2025 ((“{{ '[''com31844'']}}”)) DOMINOS 70 RS OFF COUPON CODE ((“{{ '[''com31844'']}}”)) WHAT IS A COUPON RATE ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FOR EXISTING CUSTOMERS ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FIRST ORDER ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FREE SHIPPING ((“{{ '[''com31844'']}}”)) You can get an exclusive $100off discount on your TℰℳU purchase with the code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}].This code is specially designed for new customers and offers a significant price cut on your shopping. Make your first purchase on TℰℳU more rewarding by using this code to get $100off instantly.   TℰℳU Coupon Code For $100Off [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]: Get A Flat $100Discount On Order Value Get ready to save big with our incredible TℰℳU coupon for $100off! Our coupon code will give you a flat $100discount on your order value, making your shopping experience even more rewarding.   Exclusive TℰℳU Discount Code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]: Flat $300 OFF for New and Existing Customers Using our TℰℳU promo code you can get A$ 200 off your order and 100% off using our TℰℳU promo code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]. As a new TℰℳU customer, you can save up to $100using this promo code. For returning users, our TℰℳU promo code offers a $100price slash on your next shopping spree. This is our way of saying thank you for shopping with us! Get ready to save big with our incredible TℰℳU Coupon code for $300 off! Our amazing TℰℳU $300 off coupon code will give you a flat $300 discount on your order value, making your shopping experience even more rewarding.   TℰℳU Coupon Code For 40% Off ["{com31844}"] For Both New And Existing Customers   Our incredible TℰℳU Coupon code for 40% off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our 40% off code for TℰℳU will give you an additional discount!   TℰℳU Coupon Bundle ["{com31844}"]: Flat $300 Off + Up To 90% Discount   Get ready for an unbelievable deal with our TℰℳU Coupon bundle for 2025! Our TℰℳU Coupon bundles will give you a flat $300 discount and an additional 40% off on top of it.   Free TℰℳU Coupons ["{com31844}"]: Unlock Unlimited Savings!   Get ready to unlock a world of savings with our free TℰℳU Coupons! We’ve got you covered with a wide range of TℰℳU Coupon code options that will help you maximize your shopping experience.   50% Off TℰℳU Coupons, Promo Codes + 25% Cash Back ["{com31844}"]   Redeem TℰℳU Coupon Code ["{com31844}"]   TℰℳU Coupon $300 OFF ["{com31844}"]   TℰℳU Coupon $300 OFF ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS ["{com31844}"]   TℰℳU Coupon $300 OFF FIRST ORDER ["{com31844}"]   TℰℳU Coupon $300 OFF FIRST ORDER ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS FREE SHIPPING USA ["{com31844}"]   TℰℳU Coupon $300 OFF HOW DOES IT WORK ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS CANADA ["{com31844}"]   TℰℳU Coupon $300 OFF 2025 ["{com31844}"]   TℰℳU Coupon $300 OFF FOR NEW CUSTOMERS ["{com31844}"]   TℰℳU Coupon $300 OFF CANADA ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS FIRST ORDER ["{com31844}"]   TℰℳU 300 OFF COUPON BUNDLE ["{com31844}"]   This TℰℳU coupon $300 off is designed to provide substantial savings on your purchases, making shopping for your favorite items easier than ever. With our $300 off TℰℳU coupon, you'll be amazed at how much you can save on your next order. Here are the key benefits you can expect when using our coupon code {com31844} "OR" {com31844}: {com31844} "OR" {com31844}: Flat $300 off on your purchase {com31844} "OR" {com31844}: $300 coupon pack for multiple uses {com31844} "OR" {com31844}: $300 flat discount for new customers {com31844} "OR" {com31844}: Extra $300 promo code for existing customers {com31844} "OR" {com31844}: $300 coupon exclusively for USA/Canada users H2: TℰℳU Coupon Code $300 Off For New Users In 2024 New users can reap the highest benefits by using our coupon code on the TℰℳU app. This TℰℳU coupon $300 off is specifically designed to welcome new customers with incredible savings  
    • Now the serve runs for a bit, then crashes after 20 minutes of running, what's the issue here? apologies if I need to start a new post and didn't https://pastebin.com/uBpp5bCz  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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