Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/31/17 in all areas

  1. Hey, Looks like you forgot to check if the NBT tag is null in addInformation (or call stack.hasTagCompound()). For the right click one, you should use the player.getHeldItem(hand) instead of getActiveItem(), which is for items you're using over a time period, like food and bows. That is probably empty when that right click is called, which is returning an empty item in the result.
    2 points
  2. Creating Minecraft mods is very rewarding and fun, but the learning curve is very steep. I wanted to create a way for beginning programmers to be able to experience creating Minecraft mods without having to know Java programming. You might be familiar with Scratch – a graphical programming environment often used to teach programming to kids. (See http://scratch.mit.edu). I had used Scratch before, and I was thinking that a similar environment, but for creating Minecraft mods, would be very interesting. Well, after a lot of coding, I’ve created ScratchForge, which integrates a Scratch-like, graphical, drag-and-drop programming environment, with Minecraft Forge. Users can choose from a large number of elements to create custom blocks, items, commands, entities, recipes, and react to Minecraft events. Here is a simple example of creating a custom block named “Thor” that strikes lightning when you right click it. Currently ScratchForge works only on Windows computers; if there is interest and I have time I hope to create a Mac compatible version also. If you want to try it, please go to the project web site at http://scratchforge.golde.org/ and download the installer. I’m excited for people to try it out and tell me what you think. Please reply here with feedback, or click “Help” on the web site and click “Send me feedback”.
    1 point
  3. @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flag) { EntityPlayer playerIn = Minecraft.getMinecraft().player; super.addInformation(stack, worldIn, tooltip, flag); if (stack.getTagCompound() != null) { NBTTagCompound nbt = stack.getTagCompound(); if (nbt.getTag("usedOn") != null && nbt.hasKey("usedOn")) { NBTTagList list = (NBTTagList) nbt.getTag("usedOn"); for (int i = 0; i < list.tagCount(); ++i) { if (list.getStringTagAt(i) == playerIn.getUniqueID().toString()) { tooltip.add("Already used by " + playerIn.getDisplayName()); } } } } } Sorry, that's better.
    1 point
  4. I'm going to assume this is a typo, but you have nbt.hasKey() being called before nbt is initialized.
    1 point
  5. Hey, You likely shouldn't be creating your own TemplateManager... Use the one you can get from an instance of the World: world.getSaveHandler().getStructureTemplateManager() See if that works. It should put the structure in the structures folder for the save currently loaded.
    1 point
  6. @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) { EntityPlayer playerIn = Minecraft.getMinecraft().player; super.addInformation(stack, worldIn, tooltip, flagIn); if (stack.getTagCompound() != null && nbt.hasKey("usedOn")) { NBTTagCompound nbt = stack.getTagCompound(); if (nbt.getTag("usedOn") != null { NBTTagList list = (NBTTagList) nbt.getTag("usedOn"); for (int i = 0; i < list.tagCount(); ++i) { if (list.getStringTagAt(i) == playerIn.getUniqueID().toString()) { tooltip.add("Already used by " + playerIn.getDisplayName()); } } } } } There, that's better. You have to add null checks, not everything is present all the time.
    1 point
  7. Hey, The first two should really be done from the server (spawning an entity client-side can lead to phantom entities... and running an explosion client side lead to phantom client-side holes since the random number generator on the server doesn't always break the same blocks). If you have something spawning a mob or explosion from the client, it would probably be best to send a custom packet over to the server with info about what mob you want to spawn or about the explosion. I don't think there are vanilla packets for that, but I could be wrong. The third has a vanilla packet. I remember recently using it to create a hammer-like tool that has some custom block-breaking logic. Check out tryHarvestBlock in PlayerInteractionManager, it's sending a SPacketBlockChange packet on line 337 or so.
    1 point
  8. A simple glace through your IDE should have shown you that the World::rayTraceBlocks (there's three of 'em) are not annotated with any SideOnly. The reason EntityPlayer::rayTrace is Client-Side only, is because that is only where it is used. Way back (in 1.3?) when Minecraft split the Server & Client logic, it was determined that the server only needs that which it uses. Anything that could have been common, but was only used Client-Side, was forced to become Client-Side only, during this split.
    1 point
  9. If you are not using the annotation to supply an object to the field, then you've defeated the whole point of creating a proxy. The client will run server-only stuff and if there is any client-only code in that class, the server will run client-only stuff. THIS IS BAD.
    1 point
  10. As i said i'm new to enchantments, so which will be a good approach to add one? I've deleted that base class, so now i have only the enchantment class package com.mineworld.enchantments; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Enchantments; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; public class EnchantmentSmelting extends Enchantment { public EnchantmentSmelting() { super(Rarity.UNCOMMON, EnumEnchantmentType.DIGGER,new EntityEquipmentSlot[]{EntityEquipmentSlot.MAINHAND, EntityEquipmentSlot.OFFHAND}); this.setRegistryName("smelting"); } @Override public int getMaxLevel() { return 1; } @Override public String getName() { return "enchantment.smelting.name"; } @Override public boolean canApplyAtEnchantingTable(ItemStack stack) { return true; } @Override public boolean isAllowedOnBooks() { return true; } @Override public boolean canApplyTogether(Enchantment ench) { return super.canApplyTogether(ench) && ench != Enchantments.SILK_TOUCH; } @Override public int getMinEnchantability(int enchantmentLevel) { return 1 + 10 * (enchantmentLevel - 1); } @Override public int getMaxEnchantability(int enchantmentLevel) { return super.getMinEnchantability(enchantmentLevel) + 50; } } But looking at the function i can override in this class i don't find anything that could lead me to define what the performAction function do
    1 point
  11. totalWorldTime is the "number of ticks the world has been active in memory" (I don't believe that unloaded dimensions will see this number increase; e.g. mod-added dims, as the nether and end always have some portions loaded). worldTime on the other hand is closer to a "current date." It doesn't tick when DaylightCycle is false and is incremented to sunrise when the player sleeps. Use them well (and don't use setWorldTime() unless you have a damn good reason to).
    1 point
  12. the last time i downloaded forge, i catched a cold. i dont know if that was accidental. but that can happen... last time i downloaded minecraft i got diarrhea... viruses everywhere...
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.