Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Everything posted by PegBeard

  1. Thanks for the advice. I had been trying to do something rather ghetto. Those methods look much more sensible.
  2. Simple question, is it possible to give an item a random tool material when it is created? I have tried a few things, but nothing fruitful.
  3. Nevermind - I had a case of the dumb. Had a snack and worked it out.
  4. Before 1.9 I was using this piece of code to add a direct heal when food was eaten. @SubscribeEvent public void onUseItem(PlayerUseItemEvent.Finish event) { if (event.item.getItem() instanceof ItemFood) { float h = 0.3F * (((ItemFood)event.item.getItem()).getHealAmount(event.item)); event.entityPlayer.heal(h); } } Obviously, this applied the heal to all food, which was what I wanted. In 1.9, I have switched to the 'LivingEntityUseItemEvent.Finish' event, but this doesn't work in the same way. My main problem is that 'event.getItem()' does not allow me to check if the item is an instance of 'ItemFood' and I am unsure how to do this for 1.9. I do want this to cover all food, so matching the item to each individual food would be impractical. Any suggestions would be much appreciated. (this effect is only added if natural regen is off, I just trimmed the code because that still works)
  5. In 1.8 I used this piece of code to drop a random enchanted book from the list of registered enchantments. Enchantment enchant = Enchantment.enchantmentsBookList[itemRand.nextInt(Enchantment.enchantmentsBookList.length)]; int level = MathHelper.getRandomIntegerInRange(itemRand, enchant.getMinLevel(), enchant.getMaxLevel()); ItemStack book = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchant, level)); player.entityDropItem(book, 1); However, in 1.9.4 'enchantmentsBookList cannot be resolved'. I have done some searching, but I have been unable to find a replacement. Is there a method I can use to fix this piece of code, or should I try something different.
  6. It seems the LivingJumpEvent is detecting a change in the entity Ymotion (I may be wrong). This has caused some unexpected issues. I have noticed, while using LivingJumpEvent, the event triggers when climbing ladders. I have used !player.isOnLadder() to avoid this, but the event still triggers when the player reaches the top of a ladder. The event also triggers when the player is attacked (knocked back), but only when on a server.
  7. That is what I thought. It just seemed silly to have a tile entity that does literally nothing. Thanks
  8. Pretty simple question: Do I need a tile entity? Specifically, if I make a functional block, such as a block breaker, but don't give it an inventory, do I still need a tile entity? I have looked at tutorials for functional blocks, but they have all used inventories and none of them discussed the necessity of tile entities.
  9. Wow, that did the trick. Thanks. Funny thing is, I looked at that earlier today and must have just completely glanced over it.
  10. I have a couple of custom enchants, and I have the effects for when my item is enchanted. Everything works fine in that regard. My problem is that my enchants are being applied to vanilla items. Currently, my custom item extends ItemBow, thus my enchants use the EnumEnchantmentType.BOW. I have been looking around for a way to prevent my enchants from appearing on vanilla items, and/or for a way to specify a custom enchant type, but most tutorials/requests for help only go into adding effects to vanilla stuff (the opposite of what I want) I have tried this, on suggestion from a search result: But this seems do have done utterly nothing (that I can see). My question is; how can I set a custom Enchant Type (if possible), or how can I prevent my enchants on going on vanilla items?
  11. I have an item that causes the player to 'slowfall', while wearing the item and sneaking. This code works as intended but after a few seconds (if playing on a server) the player is kicked for flying. I am aware that I can set 'allowFlying' to true, in the armour tick, and false, in a tick handler. But I had some concerns about this and would appreciate some clarification. Firstly, would setting allowFlying to false in a tick handler cause issues with other mods trying to grant permission for a similar reason? Second, I don't actually want to grant the player the ability to fly, as this item is not intended to completely protect the player from falling or enable them to go higher, so is there a way I can prevent being kicked without using flight permissions? If it makes a difference, I am using player.motionY to limit the player's falling speed, and ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(player)) to update the player.
  12. I had guessed it was something like checking the Y motion, or what not. Just thought it was really odd, as it seems like a bug. I can work around it with a keybind for my item, instead of livingJump (just didn't really want to), unless anyone has a good idea on a work around. Also, would it be a good idea to report this as a bug?
  13. I would rather do this without using the jump boost potion effect on armour tick, and like I said I have already got a working jump boost. My question wasn't how to make the player jump higher, but why does livingJump trigger when the player is knocked and how can I prevent it.
  14. I have piece of armour that increases the player's jump height when worn. I have achieved this by using the living jump event, which works fine in single player, but on multiplayer the effect triggers when the player wearing the item is attack or otherwise knocked back/upward. I am trying to avoid using keybinds, which is why I am using the jump event. I am just not sure why it fires when the jump key isn't pressed. I have tried checking is the player was recently hurt and not proceeding if true, but that doesn't seem like a great way to do it. I've been trying to fix this for several days, and that's the best I could come up with, so suggestions would be greatly appreciated.
  15. Cool cool. I figured that would be the case. Thank you for the help.
  16. I have a feeling this is a really simple thing to do and probably a dumb question, but I have been searching for a while and not really found what I am looking for. What I want to do is, detect when the player selects an item (scrolls to it, or presses the hotbar number). I have attempted to check the player's currently equipped item and compare it to the previously equipped item (as in the last held item), but I couldn't find a method for previously equipped items. I did attempt a LivingUpdateEvent, to check and store the held item, but it didn't seem like the most practical way to do it, so I was wondering if anyone could advise me on a better way to detect when the player changes their held item.
  17. I have made a new block, extending BlockPane. Initially, I had the texture set to the vanilla Iron Bars. This didn't require me to register any textures (obviously), just declare the already registered texture, when initialising the block, like so: public static Block poweredFence = new REFence("iron_bars", "iron_bars", Material.rock, false).setBlockName(Names.Traps.POWEREDFENCE); Now that I have gotten the block functioning as I want it to, I am attempting to add my own texture to it. I tried registering the texture as normal, in the block class - and adjusting the block initialisation: public static Block poweredFence = new REFence("powered_fence", "powered_fence", Material.rock, false).setBlockName(Names.Traps.POWEREDFENCE); @SideOnly(Side.CLIENT) @Override public void registerBlockIcons(IIconRegister icon) { blockIcon = icon.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); } This has worked for everything else I have done, and does retexture the in-hand icon, but when placed in the world the game crashes with a null pointer exception. I know that I need to register the texture file, and the way I have it works, but I am not sure why it causes a crash when the block is placed. I presume I need to register the icon somewhere else, though I am not sure where/how, as registering the icon in my client proxy was unsuccessful and I couldn't find a sufficient tutorial that explained/solved my problem. Here is the crash report too:
  18. Haha. I can't believe it was something simple. I'll admit, I probably misunderstood one of the tutorials I used, but the trouble I find is that most people tell you what to do and not why. Never the less, it is working now. Thank you.
  19. Based on more than one tutorial, I was under the impression that in "(Material.Armor.GOLDPLATE, 27, 0)" was "amour material, unique model id, armourslot(helmet, boots, etc.)". From what you say, I presume, if I change the '27' to '0' my armour would render as vanilla cloth armour? or would it render my specified textures? I do apologise for what is probably a dumb question, but I'm still fairly new to making an MC mod and just lack some experience.
  20. Armour class Item register Main class I don't have my own renderer, because none of the tutorials I followed even hinted that I needed one, and I don't call a vanilla renderer specifically for the armour for the same reason. I am presuming that is the problem, but I am still unfamiliar with many methods, as I'm still fairly new to MC modding (and never done armour before).
  21. I have followed several tutorials and I have my armour working as intended, the only issue is - when worn, the armour is not being displayed on the player. The item icons work properly, and MC recognises each armour piece as either helmet, boots, etc. But I can't work out why the armour is not displayed on the player when worn. This is the code I am using, based on the tutorials I have followed. This is for 1.7.10 and it is the first time I have tried to do armour. In my client proxy I have 'registerRenderThings', for registering some entities, but none of the tutorials have mentioned using that for rendering the armour on the player. Not sure if that is relevant or not. Also, I get this in the system log, when I open the inventory with the armour equipped.
  22. I'm looking at potions, at the moment, to see how thrown potions know what effects to do. I think I get the idea. Thanks.
  23. To be fair, diesieben07, I am new to Minecraft modding and I still have things to learn - I am doing my best to get by, by looking for answers in vanilla code, but obviously I don't know the best methods, or even all of them. That's why I was asking for the best way t do what I wanted to do. I am by no means an idiot just because I am uninformed, so I won't take your reaction personally. But thanks for the pointer in the right direction.
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.