Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6801021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:02:50+00:00 2026-05-26T19:02:50+00:00

I am getting things returned as null, everything is always set, and it works

  • 0

I am getting things returned as null, everything is always set, and it works up to a point…

I dont understand why i’m getting this issue… please help,

Everything should be set, but I’m getting the chunk returned as null

package com.blazingkin.world;
import java.util.HashMap;
import java.util.Map;

import com.blazingkin.atrox.AtroxAdventrum;

public class World {

    public World(AtroxAdventrum aa){
        chunks = new HashMap<Integer,Map<Integer,Chunk>>();
    }



    public void setBlock(int x, int y, int newBlock){

    }

    public void setMetadata(int x, int y, int newMeta){

    }

    private void setChunk(int x, int y, Chunk c) {
        if(chunks.get(x) == null) {
            chunks.put(x, new HashMap<Integer, Chunk>());
            System.out.println("Created new chunk "+ x);
        }
        chunks.get(x).put(y, c);
        System.out.println("Set Chunk: "+x+", "+y);
    }
    private Chunk getChunk(int x, int y) {
        if(chunks.get(x) == null){
        Chunk c = new Chunk(y*64, x, y);
        setChunk(x, y, c);
        return c;
        }
        return chunks.get(x).get(y);
    }


    public int getChunkX(int x){
        return x/64 - x%64;
    }
    public int getChunkY(int y){
        return y/64 - y%64;
    }

    public int getBlock(int x, int y){
        return getChunk(getChunkX(x), getChunkY(y)).getBlock(x&64, y%64);
    }

    public int getMetadata(int x, int y){
        return 1;
    }



    Map<Integer,Map<Integer,Chunk>> chunks;

}

Error Message:

...

Created new chunk -23

Set Chunk: -23, 16


Exception in thread "main" java.lang.NullPointerException
    at com.blazingkin.world.World.getBlock(World.java:49)
    at com.blazingkin.render.ScreenOutput.render(ScreenOutput.java:30)
    at com.blazingkin.atrox.AtroxAdventrum.draw(AtroxAdventrum.java:34)
    at com.blazingkin.atrox.Core.gameLoop(Core.java:60)
    at com.blazingkin.atrox.Core.run(Core.java:27)
    at com.blazingkin.atrox.AtroxAdventrum.main(AtroxAdventrum.java:14)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:02:51+00:00Added an answer on May 26, 2026 at 7:02 pm

    You have a check that does this: if(chunks.get(x) == null){

    But you never check about chunks.get(x).get(y) and if the get(y) is null! :-O

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create my own plugin. But I'm having trouble getting things right.
It seems that I have more trouble getting standard Unix things to run on
new Date(05-MAY-09 03.55.50) is any thing wrong with this ? i am getting illegalArgumentException
I'm trying to get data from a website- xml. Everything works fine. But the
I need help getting my head around the difference between my current OOP notion
I'm having an issue getting XPath to return anything. I've only tried in Firefox,
I have just cURL'd a page and am getting a javascript string returned. I
One thing that's really been making life difficult in getting up to speed on
I am new to the whole MVP thing and slowly getting my head around
I'm getting a little tired of building web applications. Feels like same thing over

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.