Jump to content

[1.7.10] Unreported exception thrown when setting blockbounds


Recommended Posts

Posted

Hello everyone

 

This is my first post here, so my apologies in advance if I do anything wrong! So, I've been following a few tutorials and things seem to go pretty smooth. The only problem that I have is when I set the blockbounds of a block inside the AxisAlignedBB function. In the crash log I get 'Unreported exception thrown'.

Here is my full crash thingie that I get in the Eclipse console:

 

 

[13:01:05] [Client thread/FATAL]: Unreported exception thrown!
java.lang.NullPointerException
at com.jstylezzz.allincluded.block.UICopperCable.getCollisionBoundingBoxFromPool(UICopperCable.java:40) ~[uICopperCable.class:?]
at net.minecraft.world.World.canPlaceEntityOnSide(World.java:3647) ~[World.class:?]
at net.minecraft.item.ItemBlock.func_150936_a(ItemBlock.java:172) ~[itemBlock.class:?]
at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:383) ~[PlayerControllerMP.class:?]
at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1519) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2034) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1029) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_31]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]
[13:01:05] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----
// Hey, that tickles! Hehehe!

Time: 1/25/15 1:01 PM
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
at com.jstylezzz.allincluded.block.UICopperCable.getCollisionBoundingBoxFromPool(UICopperCable.java:40)
at net.minecraft.world.World.canPlaceEntityOnSide(World.java:3647)
at net.minecraft.item.ItemBlock.func_150936_a(ItemBlock.java:172)
at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:383)
at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1519)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2034)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1029)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78)
at GradleStart.main(GradleStart.java:45)

 

 

 

It only happens when the following function is not commented out:

this.setBlockBounds(11*pixel/2, 11*pixel/2, 11*pixel/2-(cable.connections[3] !=null?(11*pixel/2):0), 1-11*pixel/2, 1-11*pixel/2, 1-11*pixel/2);

 

The whole callback is as follows

public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
	TileEntityCable cable = (TileEntityCable) world.getTileEntity(x, y, z);
	float pixel = 1F/16;
	this.setBlockBounds(11*pixel/2, 11*pixel/2, 11*pixel/2-(cable.connections[3] !=null?(11*pixel/2):0), 1-11*pixel/2, 1-11*pixel/2, 1-11*pixel/2);
	return AxisAlignedBB.getBoundingBox((double)x+minX, (double)y+minY,(double)z+minZ, (double)x+maxX, (double)y+maxY, (double)z+maxZ);
}

 

Note, that Minecraft only crashes if I place the block down. If a block is already placed down in the world, it does not make minecraft crash, but it also doesn't change the blockbounds.

 

I'm sure that there is something that I'm doing wrong, but I really can't seem to find out what it is..

 

I hope someone here knows what's going on, all the help is much appreciated.

Thanks in advance!

 

EDIT: lol, I'm sorry for those posts (which I removed again), it seems I pressed the wrong button :$

Posted

No, the

connections

array is null, so when trying to access

connections[3]

, it will throw a NPE.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Ah I see, thanks for the heads up :) I'm not really sure what I should change though, the 'connections' is basically this

public ForgeDirection [] connections = new ForgeDirection[6];

//and then

public void updateConnections() //Called on updateEntity
{
	if(worldObj.getTileEntity(xCoord, yCoord+1, zCoord) instanceof TileEntityCable) connections[0] = ForgeDirection.UP;
	else connections[0] = null;

	if(worldObj.getTileEntity(xCoord, yCoord-1, zCoord) instanceof TileEntityCable) connections[1] = ForgeDirection.DOWN;
	else connections[1] = null;

	if(worldObj.getTileEntity(xCoord, yCoord, zCoord-1) instanceof TileEntityCable) connections[2] = ForgeDirection.NORTH;
	else connections[2] = null;

	if(worldObj.getTileEntity(xCoord+1, yCoord, zCoord) instanceof TileEntityCable) connections[3] = ForgeDirection.EAST;
	else connections[3] = null;

	if(worldObj.getTileEntity(xCoord, yCoord, zCoord+1) instanceof TileEntityCable) connections[4] = ForgeDirection.SOUTH;
	else connections[4] = null;

	if(worldObj.getTileEntity(xCoord-1, yCoord, zCoord) instanceof TileEntityCable) connections[5] = ForgeDirection.WEST;
	else connections[5] = null;

}

 

Is there a way to get around that NPE?

 

Thanks for the answers so far :)

Posted

Then the only other thing that can be null on that line is

cable

. Can you post your full block class?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Sure I can :)

package com.jstylezzz.allincluded.block;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;

import com.jstylezzz.allincluded.AllIncluded;
import com.jstylezzz.allincluded.entity.TileEntityCable;

public class UICopperCable extends BlockContainer {

public UICopperCable() {
	super(Material.cloth);
	setStepSound(Block.soundTypeStone);
	setCreativeTab(CreativeTabs.tabBlock);
	setCreativeTab(AllIncluded.allIncluded);
	setBlockName("uiCopperCable");
	setBlockTextureName("allincluded:uiCopperCable");
	setHardness(1.0f);
	useNeighborBrightness=true;
	float pixel = 1F/16;
	setBlockBounds(11*pixel/2, 11*pixel/2, 11*pixel/2, 1-11*pixel/2, 1-11*pixel/2, 1-11*pixel/2);

}

public TileEntity createNewTileEntity(World world, int i)
{
	return new TileEntityCable();
}

public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
	TileEntityCable cable = (TileEntityCable) world.getTileEntity(x, y, z);
	float pixel = 1F/16;
	float f = 0;
	if(cable.connections[3] == null) f = 0;
	else f = 11*pixel/2;

	this.setBlockBounds(11*pixel/2,  11*pixel/2, 11*pixel/2-(f), 1-11*pixel/2, 1-11*pixel/2, 1-11*pixel/2);
	return AxisAlignedBB.getBoundingBox((double)x+minX, (double)y+minY,(double)z+minZ, (double)x+maxX, (double)y+maxY, (double)z+maxZ);
}

public int getRenderType(){
	return -1;
}
public boolean isOpaqueCube(){
	return false;
}
public boolean renderAsNormalBlock()
{
	return false;
}
}

 

Here is the UICopperCable class.

 

if connections[x] != null 
    do it with the connection
else
    do something else

?

 

I tried something like this, but it still doesn't like it very much. Thanks anyways!

Posted

You need to have the

public boolean hasTileEntity(int meta)

in your block class and make it return true.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

I added

public boolean hasTileEntity(int meta)
{
return true;
}

 

into the UICopperCable class file. It still crashes when I place down the block though. Is there anything else a tileEntity block should have in it's class that I missed?

Posted

Ah, now I see the issue. You have called your method

createNewTileEntity

while it should be

createTileEntity

. In the future, add the

@Override

annotation to all your methods you expect to override a method, as it will throw an error if the method doesn't exist in one of the super classes.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Ah, thanks a lot for looking :) I think we nearly solved this problem, yey

 

I added the override

@Override
public TileEntity createNewTileEntity(World world, int i)
{
	return new TileEntityCable();
}

 

When I change createNewTileEntity to createTileEntity it gives me an error, so I tried it like I paste above. It still crashes on me though :|

Thanks for helping me, and sorry for being so difficult!

Posted

So this is giving you an error?

@Override
public TileEntity createTileEntity(World world, int meta)
{
    return new TileEntityCable();
}

It should work if it's like that. You still have the

hasTileEntity

method?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Yeah, I still have it. This is what Eclipse says: 'The type UICopperCable must implement the inherited abstract method ITileEntityProvider.createNewTileEntity(World, int)'. It has the option to add the unimplemented method, but that just adds the createNewTileEntity thing that we just changed..

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

    • Hi all,  I have the following issue: I'd like to parse some json using gson and rely on the (somewhat new) java record types. This is supported in gson 2.10+. Gson is already a dependency used by minecraft, however it's 2.8.x for 1.19.2 which I'm targeting at the moment. My idea was to include the newer version of the library in my mod and then shadow it so it gets used inside the scope of my mod instead of the older 2.8. This works fine for building the jar: If I decompile my mod.jar, I can see that it's correctly using the shadowed classes. However obviously when using the runClient intellj config, the shadowing doesn't get invoked. Is there any way of invoking shadow when using runClient, or am I on the wrong track and there's a better way of doing this entirely? Thanks in advance!
    • Yep I did upgrade just because it showed me a new version available.  I'll redownload the mod list and make sure anything works.  Thanks!
    • The latest log was taken down by pastebin for some reason. Did you try removing the mods you added? The mods you updated, was there a specific reason you updated, or just because? It's possible the updates introduced incompatibilitie, or even need a newer build of forge. If you didn't need the updates for a specific reason, you could also try downgrading those mods.
    • Please read the FAQ, and post logs as described there. https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/
    • I am using forge 1.20.1 (version 47.3.0). My pc has an RTX 4080 super and an i9 14900 KF, I am on the latest Nvidia graphics driver, latest windows 10 software, I have java 23, forge 1.12.2 works and so does all vanilla versions but for some reason no version of forge 1.20.1 works and instead the game just crashes with the error code "-1." I have no mods in my mods fodler, I have deleted my options.txt and forge.cfg files in case my settings were causing a crash and have tried removing my forge version from the installations folder and reinstalling but no matter what I still crash with the same code and my log doesn't tell me anything: 18:34:53.924 game 2025-02-06 18:34:53,914 main WARN Advanced terminal features are not available in this environment 18:34:54.023 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, mrmirchi, --version, 1.20.1-forge-47.3.0, --gameDir, C:\Users\aryam\AppData\Roaming\.minecraft, --assetsDir, C:\Users\aryam\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 2db00ea8d678420a8956109a85d90e9d, --accessToken, ????????, --clientId, ZWI3NThkNzMtNmNlZS00MGI5LTgyZTgtYmZkNzcwMTM5MGMx, --xuid, 2535436222989555, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\aryam\AppData\Roaming\.minecraft\quickPlay\java\1738838092785.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.3.0, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] 18:34:54.027 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 18:34:54.132 game [18:34:54] [main/INFO] [ne.mi.fm.lo.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow 18:34:54.191 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 18:34:54.303 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 18:34:54.367 monitor Process Monitor Process crashed with exit code -1     screenshot of log: https://drive.google.com/file/d/1WdkH88H865XErvmIqAKjlg7yrmj8EYy7/view?usp=sharing
  • Topics

×
×
  • Create New...

Important Information

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