My game crash when i run my mincraft mod
public class ArnorMod implements ModInitializer {
public static final String MODID = "armorermod";
@Override
public void onInitialize() {
UseEntityCallback.EVENT.register(this::onPlayerInteract); } private ActionResult onPlayerInteract(PlayerEntity player, World world, Hand hand, Entity entity, EntityHitResult hitResult) { if (entity instanceof VillagerEntity) { VillagerEntity villager = (VillagerEntity) entity; if (villager.getVillagerData().getProfession() == VillagerProfession.ARMORER) {
rotatePlayerCamera(player);
boolean hasMoreTrades; do { hasMoreTrades = false; for (TradeOffer trade : villager.getOffers()) { ItemStack tradeItem = trade.getSellItem();
if (EnchantmentHelper.hasEnchantments(tradeItem) && trade.getDisplayedFirstBuyItem().getCount() == 1) {
if (player.getInventory().count(Items.EMERALD) >= 1) {
player.getInventory().removeStack(player.getInventory().getSlotWithStack(new ItemStack(Items.EMERALD)), 1); player.giveItemStack(tradeItem.copy());
player.dropItem(tradeItem, false);
hasMoreTrades = true; } } } } while (hasMoreTrades);
rotatePlayerCamera(player); } } return ActionResult.PASS; } private void rotatePlayerCamera(PlayerEntity player) { player.setYaw(player.getYaw() + 180); // چرخش 180 درجه player.setHeadYaw(player.getHeadYaw() + 180); // چرخش سر بازیکن } }
UseEntityCallback.EVENT.register(this::onPlayerInteract); } private ActionResult onPlayerInteract(PlayerEntity player, World world, Hand hand, Entity entity, EntityHitResult hitResult) { if (entity instanceof VillagerEntity) { VillagerEntity villager = (VillagerEntity) entity; if (villager.getVillagerData().getProfession() == VillagerProfession.ARMORER) {
rotatePlayerCamera(player);
boolean hasMoreTrades; do { hasMoreTrades = false; for (TradeOffer trade : villager.getOffers()) { ItemStack tradeItem = trade.getSellItem();
if (EnchantmentHelper.hasEnchantments(tradeItem) && trade.getDisplayedFirstBuyItem().getCount() == 1) {
if (player.getInventory().count(Items.EMERALD) >= 1) {
player.getInventory().removeStack(player.getInventory().getSlotWithStack(new ItemStack(Items.EMERALD)), 1); player.giveItemStack(tradeItem.copy());
player.dropItem(tradeItem, false);
hasMoreTrades = true; } } } } while (hasMoreTrades);
rotatePlayerCamera(player); } } return ActionResult.PASS; } private void rotatePlayerCamera(PlayerEntity player) { player.setYaw(player.getYaw() + 180); // چرخش 180 درجه player.setHeadYaw(player.getHeadYaw() + 180); // چرخش سر بازیکن } }
8 Replies
⌛
This post has been reserved for your question.
Hey @Dangerboy25! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
Please format your code to make it more readable. For java, it should look like this:
Its my mincraft mod code
It suppose to drop all the diamond arrmor that villiger sell for 1 emerald and rotate player 180 degrees when right click on a armorer villiger
And also rotate again when i close the traid
But when i right click on a villager my game crash
are you sure this loop isnt crashing the game
Maybe how to fix it
i added thread sleep 1000
add it too
and try it
if you dont crash then that means the problem is with the loop
if you crash anyway the problem is somewhere else
I'll try it
It didn't worked
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.