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:

 

  Reveal hidden contents

 

 

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.

 

  On 1/25/2015 at 1:59 PM, Trynthlas said:

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

    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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