Résolu Problème d'achievement lors du craft d'un bloc
-
J’ai quelques achievements fonctionnels, dont certains sont un craft. Il y a des crafts d’épées et de blocs. Ceux d’épées fonctionnent alors que ceux des blocs ne marchent jamais ( on ne peut pas obtenir l’achievement ). Voici ma classe UpdateAchievement :
import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemSmeltedEvent; public class UpdateAchievements { @SubscribeEvent public void craftEvent(PlayerEvent.ItemCraftedEvent event) { // Alliages if (event.crafting.getItem().equals(ModTest.ingotSteel)) { event.player.addStat(ModTest.alloySteel, 1); } else if (event.crafting.getItem().equals(ModTest.ingotBronze)) { event.player.addStat(ModTest.alloyBronze, 1); } // Épées else if (event.crafting.getItem().equals(ModTest.steelSword)) { event.player.addStat(ModTest.craftSteelSword, 1); } else if (event.crafting.getItem().equals(ModTest.bronzeSword)) { event.player.addStat(ModTest.craftBronzeSword, 1); } else if (event.crafting.getItem().equals(ModTest.copperSword)) { event.player.addStat(ModTest.craftCopperSword, 1); } else if (event.crafting.getItem().equals(ModTest.tinSword)) { event.player.addStat(ModTest.craftTinSword, 1); } // Blocs else if (event.crafting.getItem().equals(ModTest.blockSteel)) { event.player.addStat(ModTest.craftSteelBlock, 1); } else if (event.crafting.getItem().equals(ModTest.blockBronze)) { event.player.addStat(ModTest.craftBronzeBlock, 1); } else if (event.crafting.getItem().equals(ModTest.blockCopper)) { event.player.addStat(ModTest.craftCopperBlock, 1); } else if (event.crafting.getItem().equals(ModTest.blockTin)) { event.player.addStat(ModTest.craftTinBlock, 1); } else if (event.crafting.getItem().equals(ModTest.blockCarbon)) { event.player.addStat(ModTest.craftCarbonBlock, 1); } } @SubscribeEvent public void smeltEvent(ItemSmeltedEvent event) { if (event.smelting.getItem().equals(Items.diamond)) { event.player.addStat(ModTest.craftDiamond, 1); } } @SubscribeEvent public void pickUpEvent(ItemPickupEvent event) { if(event.pickedUp.getEntityItem().isItemEqual(new ItemStack(ModTest.carbon))) { if(event.player != null) event.player.addStat(ModTest.findCarbon, 1); } else if(event.pickedUp.getEntityItem().isItemEqual(new ItemStack(ModTest.oreCopper))) { if(event.player != null) event.player.addStat(ModTest.findCopper, 1); } else if(event.pickedUp.getEntityItem().isItemEqual(new ItemStack(ModTest.oreTin))) { if(event.player != null) event.player.addStat(ModTest.findTin, 1); } } }
Voici la déclaration des achievements dans les variables de la classe principale :
public static Achievement findCarbon, findCopper, findTin, alloySteel, alloyBronze, // Trouver et alliages craftSteelSword, craftBronzeSword, craftCopperSword, craftTinSword, // Épées craftSteelBlock, craftBronzeBlock, craftCopperBlock, craftTinBlock, craftCarbonBlock, // Blocs craftDiamond; // Spéciaux
Et voici l’enregistrement des achievements :
// Trouver et alliages findCarbon = new Achievement("findCarbon", "findCarbon", -1, 0, oreCarbon, (Achievement)null).initIndependentStat().registerStat(); findCopper = new Achievement("findCopper", "findCopper", 0, 0, oreCopper, (Achievement)null).initIndependentStat().registerStat(); findTin = new Achievement("findTin", "findTin", 1, 0, oreTin, (Achievement)null).initIndependentStat().registerStat(); alloySteel = new Achievement("alloySteel", "alloySteel", -3, 0, ingotSteel, findCarbon).registerStat(); alloyBronze = new Achievement("alloyBronze", "alloyBronze", 3, 0, ingotBronze, findTin).registerStat(); // Craft épées craftSteelSword = new Achievement("craftSteelSword", "craftSteelSword", -3, -2, steelSword, alloySteel).registerStat(); craftBronzeSword = new Achievement("craftBronzeSword", "craftBronzeSword", 3, -2, bronzeSword, alloyBronze).registerStat(); craftCopperSword = new Achievement("craftCopperSword", "craftCopperSword", 0, -2, copperSword, findCopper).registerStat(); craftTinSword = new Achievement("craftTinSword", "craftTinSword", 1, -2, tinSword, findTin).registerStat(); // Craft blocs craftSteelBlock = new Achievement("craftSteelBlock", "craftSteelBlock", -3, 2, blockSteel, alloySteel).registerStat(); craftBronzeBlock = new Achievement("craftBronzeBlock", "craftBronzeBlock", 3, 2, blockBronze, alloyBronze).registerStat(); craftCopperBlock = new Achievement("craftCopperBlock", "craftCopperBlock", 0, 2, blockCopper, findCopper).registerStat(); craftTinBlock = new Achievement("craftTinBlock", "craftTinBlock", 1, 2, blockTin, findTin).registerStat(); craftCarbonBlock = new Achievement("craftCarbonBlock", "craftCarbonBlock", -1, 2, blockCarbon, findCarbon).registerStat(); // Spéciaux craftDiamond = new Achievement("craftDiamond", "craftDiamond", -1, -2, Items.diamond, findCarbon).setSpecial().registerStat();
Quel est mon problème ?
-
Pour les blocs,
Item.getBlockFormItem(tonBlock) -
Merci beaucoup !