I'm not very good at debugging and haven't been with java for long enough to see any errors.
So, how I'm making my crafting system is in four steps:
1) I test if the player is in a crafting block with
if(!Crafting.isOpen())
return;
2) If that is true then I test if the player has specific items with
if(inventoryItems.contains(//certain item) && inventoryItems.contains(// certain item) {
g.fillRect(100, 100, 100, 20);
g.setColor(Color.white);
g.drawString("Craft " + // certain item, 110, 111);
} else
return;
3) If all of that is true I test if the mouse touches the craft "button" with
if(Mouse.MouseX() >= 100 && Mouse.MouseX() <= 200 && Mouse.MouseY() >= 100 & Mouse.MouseY() <= 120) {
inventoryItems.add(// certain item);
}
I feel like step 2 is wrong, but I can't find any error; also, is there any alternative to .contains();
?
Aucun commentaire:
Enregistrer un commentaire