Fix Crash Caused by wrong Container/Gui Constructor.
This commit is contained in:
parent
bfca3e04e0
commit
2a60d619de
|
@ -177,7 +177,7 @@ public enum GuiBridge implements IGuiHandler
|
||||||
Constructor[] c = Container.getConstructors();
|
Constructor[] c = Container.getConstructors();
|
||||||
if ( c.length == 0 )
|
if ( c.length == 0 )
|
||||||
throw new AppEngException( "Invalid Gui Class" );
|
throw new AppEngException( "Invalid Gui Class" );
|
||||||
return c[0].newInstance( inventory, tE );
|
return findConstructor( c, inventory, tE ).newInstance( inventory, tE );
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,8 @@ public enum GuiBridge implements IGuiHandler
|
||||||
Constructor[] c = Gui.getConstructors();
|
Constructor[] c = Gui.getConstructors();
|
||||||
if ( c.length == 0 )
|
if ( c.length == 0 )
|
||||||
throw new AppEngException( "Invalid Gui Class" );
|
throw new AppEngException( "Invalid Gui Class" );
|
||||||
return c[0].newInstance( inventory, tE );
|
|
||||||
|
return findConstructor( c, inventory, tE ).newInstance( inventory, tE );
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
|
@ -200,6 +201,20 @@ public enum GuiBridge implements IGuiHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Constructor findConstructor(Constructor[] c, InventoryPlayer inventory, Object tE)
|
||||||
|
{
|
||||||
|
for (Constructor con : c)
|
||||||
|
{
|
||||||
|
Class[] types = con.getParameterTypes();
|
||||||
|
if ( types.length == 2 )
|
||||||
|
{
|
||||||
|
if ( types[0] == inventory.getClass() && types[1].isAssignableFrom( tE.getClass() ) )
|
||||||
|
return con;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private Object updateGui(Object newContainer, World w, int x, int y, int z, ForgeDirection side)
|
private Object updateGui(Object newContainer, World w, int x, int y, int z, ForgeDirection side)
|
||||||
{
|
{
|
||||||
if ( newContainer instanceof AEBaseContainer )
|
if ( newContainer instanceof AEBaseContainer )
|
||||||
|
|
Loading…
Reference in a new issue