• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hello I am noticing lags spikes when using my mod what ways are there to identify what part of my mod is causing this?
    • I just want to change the villager MerchantOffers when rightclickt with a custom item. So i creat this the offer will set but when i close the gui and open it again the offers will reset but why have i to save them? or is there something wrong/is there a better way to do this?   @SubscribeEvent public static void EntityInteractSpecific(PlayerInteractEvent.EntityInteractSpecific event) { PlayerEntity player = event.getPlayer(); LivingEntity target = (LivingEntity) event.getTarget(); World world = event.getWorld(); if (target instanceof VillagerEntity) { VillagerEntity villager = (VillagerEntity) target; MerchantOffers offers = villager.getOffers(); MerchantOffers newOffers = new MerchantOffers(offers.write()); String uuid = villager.getUniqueID().toString().replace("-", ""); int uniqueInteger = Integer.parseInt(uniqueHex(uuid, 2), 16) / 10; player.sendMessage(new StringTextComponent("uniqueInteger: " + uniqueInteger), player.getUniqueID()); if (world.getDayTime() >= 3000 && world.getDayTime() <= 10000) { for (MerchantOffer merchantOffer : offers) { merchantOffer.resetUses(); } } if (player.getHeldItem(event.getHand()).getItem() == CaveItems.RUBY_APPLE.get()) { if (!player.abilities.isCreativeMode) { player.getHeldItem(event.getHand()).shrink(1); } for (MerchantOffer merchantOffer : newOffers) { player.sendMessage(new StringTextComponent("getSpecialPrice: " + merchantOffer.getSpecialPrice() * (-1)), player.getUniqueID()); ItemStack buyingStack = merchantOffer.getBuyingStackFirst(); ItemStack sellingStack = merchantOffer.getSellingStack(); if (buyingStack.getCount() > 1) { merchantOffer.setSpecialPrice(uniqueInteger * (-1)); } else if (sellingStack.getCount() > 1) { } } villager.setOffers(newOffers); } } }  
    • Finally i fixed the all problems. I added this condition and thats all. world.chunkExists(specialItemEntity.chunkCoordX,specialItemEntity.chunkCoordZ)   Final code is :   EventHandler class package com.azizd.thunderbird.events; import com.azizd.thunderbird.Thunderbird; import com.azizd.thunderbird.entities.SpecialItemEntity; import com.azizd.thunderbird.init.itemInit; import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(modid = Thunderbird.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class EventHandler { public static void register(){} @SubscribeEvent public static void crimsonIngotCraft(EntityJoinWorldEvent event){ Entity entity = event.getEntity(); World world = entity.world; double posX = entity.getPosX(); double posY = entity.getPosY(); double posZ = entity.getPosZ(); SpecialItemEntity specialItemEntity = new SpecialItemEntity(world, posX, posY, posZ); if(entity instanceof ItemEntity && !(entity instanceof SpecialItemEntity)){ ItemEntity itemEntity = (ItemEntity) event.getEntity(); ItemStack item = itemEntity.getItem(); if(item.getItem() == itemInit.RED_PEARL.get()){ if(world.chunkExists(specialItemEntity.chunkCoordX,specialItemEntity.chunkCoordZ)) { event.setCanceled(true); specialItemEntity.setItem(itemEntity.getItem().getStack()); specialItemEntity.setPickupDelay(30); specialItemEntity.setMotion(itemEntity.getMotion()); world.addEntity(specialItemEntity); } } } } }   SpecialItemEntity class package com.azizd.thunderbird.entities; import com.azizd.thunderbird.init.itemInit; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class SpecialItemEntity extends ItemEntity { private ItemEntity entity = new ItemEntity(this.world,this.getPosX(),this.getPosY(),this.getPosZ()); public SpecialItemEntity(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } @Override public void tick() { if(this.inWater && !this.world.isRemote){ this.setDead(); int count = this.getItem().getCount(); entity.setPosition(this.getPosX(),this.getPosY(),this.getPosZ()); entity.setItem(new ItemStack(itemInit.CRIMSON_INGOT.get())); entity.getItem().setCount(count); this.world.addEntity(entity); } else{ super.tick(); } } }  
    • I want to propose to user few options, which he/she may craft from items in inventory. Client will prepare all combinations, than select only few best (in my context). Server will validate only this few combinations. Ofcouse I plans to add precheck how many combination client may construct and prevent few-seconds freezes with message like "Sorry, so many ingredients for autocompletion."
    • Sorry I posted this comment, because I was inattentive.
  • Topics

  • Who's Online (See full list)