Jump to content

[1.7.10] Unreported exception thrown when setting blockbounds


Jstylezzz

Recommended Posts

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 :$

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been trying to give a little transparency to a block and a custom model, but I'm running into the same issue with the transparency of the block Some guides say I use ItemBlockRenderTypes.setRenderLayer in a ClientEvent class but its deprecated, I already tried to set a Properties in Properties.copy(Blocks.FLOWERPOT) But the render in game still doesn't has transparency, only as an Item  
    • My friends and I are modding to survive But recently I want to use cmd to open the server instead of making the single player game public But when I used two methods to start the server, I encountered two problems first A I used forge to install the server files Created using the original server jar The server was installed successfully and the mod was also loaded successfully. But after I replaced the world file with my survival map, I found that the mod items inside disappeared but could be taken from creation again. So I tried to install the server using forge first B I have studied forge for a long time but successfully installed it. But when I put in mods it crashed But mods can be installed on the server   我和我的朋友們正在mod為了生存 但是最近我想用cmd打開伺服器而不是把單人遊戲公開 但是當我使用兩種方法啟動伺服器時,我遇到了兩個問題 首先AI使用forge安裝伺服器檔案使用原始伺服器jar 建立伺服器已成功安裝,mod 也已成功載入。但是當我用我的生存地圖替換世界文件後,我發現裡面的mod物品消失了,但可以再次從創建中取出。所以我嘗試先使用forge安裝伺服器,BI研究了forge很久但成功安裝了它。但是當我安裝 mods 時它崩潰了但是 mods 可以安裝在伺服器上 我和我的朋友正在mod生存 但最近我想使用cmd開啟伺服器而不是單人遊戲公開   但是當我使用了兩種方法開啟伺服器時遇到了兩種問題   第1個A 我使用了forge安裝伺服器文件 在使用原版伺服器jar建立    伺服器安裝成功 mod也順利加載  但是我將我的生存地圖替換世界文件後發現裡面的mod物品消失了但可以再次從創造拿取  所以我嘗試使用forge安裝伺服器   第2個B forge我研究了很久但也成功安裝了 但是當我放入 mods 之後發生了崩潰 但是mods在1A伺服器上是可以安裝的 Ps 我用谷歌翻譯 so    
    • That’s probably not it because as I stated I’ve done it before. I did it like deadass 10 - 20 times when trying to learn to make this mod pack because I kept wanting to reset my profiles and such. So it definitely works, it looks like maybe the creephosting files were the things that couldn’t be reached I tried reading the crash log
    • I don't know if this is the right place or not, but I have put together a custom modpack and I am in need of others to help me. It's a questing modpack with a lore book i'm currently writing out through Patchouli, and i am in need of somebody who will assist me in making the quests for the pack. It's a Zombie apocalypse modpack inspired by Deceasedcraft  with a tinge of magic and RPG mechanics via Mine and slash. Is there anybody willing to assist me as i'm one person building a modpack I could also use help with optimizations since that's not really my strong suite. 
    • File a report to SPYRECOVERY36 @ gmail com he can legitimately assist in proper review and recovery of all your assets that was stolen. Endeavor to submit your request for a refund to his mail . He also spy and hack any device remotely without any trace. Contact via spyrecovery36 @ gm ail com  
  • Topics

×
×
  • Create New...

Important Information

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