Posted April 21, 201411 yr Trying to limit the ability to hold a specific item when the condition isnt met. it works fine although the player cant hold the item when the condition IS met either any ideas, also its set that upon deletion of the item, the relative materials are added back the the players inventory BUT theyre also glitching out and rather then adding only one instance of the materials theyre flooding the inventory by the bucketfull code as follows package com.MCR.MinecraftReloaded.Event; import com.MCR.MinecraftReloaded.Items.ModItems; import com.MCR.MinecraftReloaded.LevelingLib.StorageMiningExperience; import com.MCR.MinecraftReloaded.LevelingLib.StorageMiningLevel; import com.MCR.MinecraftReloaded.LevelingLib.StorageWoodCuttingExperience; import com.MCR.MinecraftReloaded.LevelingLib.StorageWoodCuttingLevel; import com.MCR.MinecraftReloaded.LevelingLib.SyncPlayerPropsPacketMiningLevel; import com.MCR.MinecraftReloaded.Main.MinecraftReloaded; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; public class PlayerLivingUpdateEvent { @SubscribeEvent public void onPlayerUpdate(LivingUpdateEvent event) { if(event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entityLiving; if(player.inventory.hasItem(ModItems.CastrealmPickaxe) && StorageMiningLevel.get(player).GetLevel() < 5);{ player.inventory.consumeInventoryItem(ModItems.CastrealmPickaxe); player.inventory.addItemStackToInventory(new ItemStack(Items.stick, 2)); player.inventory.addItemStackToInventory(new ItemStack(ModItems.CastrealmIngot, 3)); } } } }
April 21, 201411 yr You could try: @SubscribeEvent public void onPlayerUpdate(LivingUpdateEvent event) { if(event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.entityLiving; boolean given = false; if(player.inventory.hasItem(ModItems.CastrealmPickaxe) && StorageMiningLevel.get(player).GetLevel() < 5 && !given){ player.inventory.consumeInventoryItem(ModItems.CastrealmPickaxe); player.inventory.addItemStackToInventory(new ItemStack(Items.stick, 2)); player.inventory.addItemStackToInventory(new ItemStack(ModItems.CastrealmIngot, 3)); given = true; } } } Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
April 21, 201411 yr Author thanks for the advice but it i tried the code and it didnt stop the mass spamming of additions to the inventory nor the inability to hold the pickaxe EVEN if the condition (level) is met i dont see why its doing this, the if statement states that IF the players holding both a pickaxe AND has a level lower than 5, run the contents of {} but i dont even have a pickaxe in my inventory and its spamming ingots and sticks into it
April 21, 201411 yr I just fixed it, you had ");{" on this line: if(player.inventory.hasItem(ModItems.CastrealmPickaxe) && StorageMiningLevel.get(player).GetLevel() < 5 && !given){ Maybe that will help Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods
April 21, 201411 yr Author OMG thats it! thankyou, i cant believe i overlooked something so simple!!! serves me right for being lazy and copying "StorageMiningLevel.get(player).GetLevel());" from another class in my mod to save time +1000 karma for you mate :) :) :)
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.