Reputation: 67
Lately I have been having an issue with my game, this:
@Override
public Tile getPlace(List args)
{
return new CraftingTableTile(Integer.valueOf((String)args.get(0),
Integer.valueOf((String)args.get(1)).intValue()).intValue(), this.healthrep);
}
as well as:
s.map[selectedx][selectedy] = s.mp.inven.i[s.mp.invsel].getPlace(args);
gives an error:
Exception in thread "main" java.lang.NumberFormatException: radix 482 greater than Character.MAX_RADIX
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
at net.spideynn.miner2d.CraftingTableItem.getPlace(CraftingTableItem.java:21)
at net.spideynn.miner2d.MainGame.mousePressed(MainGame.java:851)
at org.newdawn.slick.Input.poll(Input.java:1217)
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:641)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:411)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:321)
at net.spideynn.miner2d.MainGame.main(MainGame.java:2074)
Any Ideas?
(Sorry if the answer is easy, I couldn't find a solution.)
Upvotes: 1
Views: 2549
Reputation: 178263
It appears that your are attempting to pass 3 values into your CraftingTableTile
constructor, but because of a mistake in your parentheses, you are passing only 2 arguments:
// v This parenthesis...
Integer.valueOf((String)args.get(0),
// is balanced by this parenthesis v
Integer.valueOf((String)args.get(1)).intValue()).intValue()
and
this.healthrep
Because of the parentheses mixup, two arguments are being passed to Integer.valueOf
, with the second being interpreted as a radix. The exception comes from 482
being greater than the maximum possible radix.
You probably meant to pass these 3 arguments:
Integer.valueOf((String)args.get(0))
and
Integer.valueOf((String)args.get(1)).intValue()
and
this.healthrep
Like this:
return new CraftingTableTile(
Integer.valueOf((String)args.get(0)),
Integer.valueOf((String)args.get(1)).intValue(),
this.healthrep);
Incidentally, your constructor probably is taking int
s, in which case you can use parseInt
. The only difference between parseInt
and valueOf
is that parseInt
returns an int
and valueOf
returns an Integer
.
return new CraftingTableTile(
Integer.parseInt((String)args.get(0)),
Integer.parseInt((String)args.get(1)),
this.healthrep);
Upvotes: 3