Jump to content

yooksi

Members
  • Posts

    112
  • Joined

  • Last visited

Everything posted by yooksi

  1. I've tried this right now: public Entity createEntity(World world, Entity location, ItemStack itemstack) { return new MyEntityItem(world, location.posX, location.posY, location.posZ, itemstack, location.motionX, location.motionY, location.motionZ); } public MyEntityItem(World worldObj, double posX, double d0, double posZ, ItemStack stack, double motionX, double motionY, double motionZ) { super(worldObj, posX, d0, posZ, stack); } It didn't seem to work at all. It also might be important to note that the when I register the EntityItem it requires a standard EntityItem constructor - MyEntityItem(World). Don't know if that is relevant or not but it looks like it's getting constructed twice, once with that constructor and once with my custom one. If I don't construct it with the custom one passing the location the entity just doesn't appear in the world.
  2. Had the same problem, managed to solve it with determined experimentation. It took a while as well, too bad I didn't see this sooner.
  3. I've been trying to find an efficient way of registering my custom EntityItems with Forge for a while. The problem arises when I see how the items behave when tossed and dropped in the world. The motion is way off and there is a few second delay before the items is teleported to a new location a few blocks away from where it once was. If seems like quite a high price to pay just to have them conveniently saved and loaded in your world. Did someone else encounter these issues, and is there a known way to fix this? My main question though would be, what is the proper way of registering and handling an EntityItem? When I do not register the entities and manually spawn them in the world by overriding some methods. everything works fine but as I said, they are not loaded or saved from the world. My current registration method is this: EntityRegistry.registerModEntity(MyEntityItem.class, "my_entity_item, 0, MyMod.instance, 40, 40, false); The way I am handling entity creation when using the registration method: @Override public boolean hasCustomEntity(ItemStack stack) { return true; } @Override public Entity createEntity(World world, Entity location, ItemStack itemstack) { return new MyEntityItem(world, location.posX, location.posY, location.posZ, itemstack); } I've been trying to solve this problem on many ways for some time now and I am slowly loosing patience. Any help would really be appreciated. Thank you in advance guys. EDIT: changed 'hasCustomEntity' return value from false to true, thanks to larsgerrits for spotting the mistake.
  4. It took me a around two weeks to update my mod from 1.8 to 1.10, so it just depends on how large your mod is. You will probably not need rewrite everything, however my recommendation would be to update that which your IDE tells you first (the function names, variables etc.). Then just fire up your mod and see what's working and what's not.
  5. Thank you, was wondering the same thing. Any idea what we are suppose to use? I mean since the alternative is deprecated.
  6. I recently wrote started a new blog, where I would like to write about Minecraft stuff. Of course one of the topics I am very interested in writing about is Minecraft mod development, so I decided that my first post is going to be about that. As I've spent days researching and putting everything together, it was a good opportunity to go back to the very basics of modding. However the more important reason for writing this guide was the fact that I felt obliged in some matter to give something back to the community. The article linked below is a complete guide on how to start developing your first mod. If people find it interesting and helpful I will write much more. It's written for Minecraft 1.10 but it should work for 1.8 and 1.9. You can find it here: http://yooksidoesminecraft.blogspot.com/2016/08/getting-started-with-minecraft-modding.html I would be really grateful if you could help me by reviewing the article, letting me know if some parts of text are outright wrong or confusing. Any addition and design suggestions are welcome as well.
  7. Have you removed plank and log vanilla recipes before adding custom ones?
  8. Use Block#setUnlocalizedName and Item#setUnlozalizedName for items.
  9. If you have followed and completed all the steps in the Forge installation instructions you should find the Forge source jar in your IDE workspace, project explorer (listed right under "JRE System Library" for Eclipse in my case). These are the instructions that worked for me several times for 1.8: http://www.minecraftforge.net/wiki/Installation/Source
  10. /** * LivingJumpEvent is fired when an Entity jumps.<br> * This event is fired whenever an Entity jumps in * EntityLivingBase#jump(), EntityMagmaCube#jump(), * and EntityHorse#jump().<br> * <br> * This event is fired via the {@link ForgeHooks#onLivingJump(EntityLivingBase)}.<br> * <br> * This event is not {@link Cancelable}.<br> * <br> * This event does not have a result. {@link HasResult}<br> * <br> * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ public static class LivingJumpEvent extends LivingEvent { public LivingJumpEvent(EntityLivingBase e){ super(e); } } I think coolAlias's solution is quite good. My first thought was to cancel the event, however it would seem that this particular even cannot be cancelled.
  11. I removed the post, was just trying to help out, my apologies.
  12. Another way to get the distance (in a perhaps more cleaner way) could be like this: Vec3 lastPosVec = new Vec3(prev_posx, prev_posy, prev_posz); Vec3 currentPosVec = new Vec3(player.x, player.y, player.z); // Euclidean distance between your last and current position. double distanceTraveled = lastPosVec.distanceTo(currentPosVec); As for handling the gui, I am afraid I cannot be of any help there as I have no experience in that. If you haven't so far, you should perhaps read this: http://www.minecraftforge.net/wiki/Gui_Overlay
  13. Since this issue is now resolved, could you lock this topic and mark it as SOLVED?
  14. Knowing why something doesn't work from two lines of code is more often then not close to impossible. Please provide more information so that we can be of some assistance to you in solving your issue.
  15. You can store and later retrieve metadata from blockstate. Override this class in your custom block class, extract the metadata from blockstate and invoke the tile entity constructor with metadata as your argument: /** * Called throughout the code as a replacement for ITileEntityProvider.createNewTileEntity * Return the same thing you would from that function. * This will fall back to ITileEntityProvider.createNewTileEntity(World) if this block is a ITileEntityProvider * * @param metadata The Metadata of the current block * @return A instance of a class extending TileEntity */ public TileEntity createTileEntity(World world, IBlockState state) { if (isTileProvider) { return ((ITileEntityProvider)this).createNewTileEntity(world, getMetaFromState(state)); } return null; }
  16. What exactly are you confused with? Just create a new class in your core mod that will serve as a global item library for all your other mods and move your items there. Remember to import that package to all your other mod classes and like this you will have access to them from any mod package.
  17. In case you also want to include liquids in your search, this would be one way to do it: /** * This method is intended to be called right after an item was right-clicked, and no <i>'blockHit'</i> was found. <br> * It will search for the first occurrence of a block made of specific material in the direction where the player <br> * is looking, limiting the search with the specified range of item's reach. * * @param player EntityPlayer using the item <b>(unchecked)</b> * @param world Instance of the world the player and his item are in <b>(unchecked)</b> * @param material The material type to check if item is used on * @param itemReach User defined reach of the item being used <i>(should be > 1)</i> * @return True if the block made from designated material has been found * * @see EntityPlayer#rayTrace(double, float) * @throws java.lang.NullPointerException if EntityPlayer or World instances are <code>null</code> */ public static boolean willItemTouchMaterialOnUse(final EntityPlayer player, final World world, Material material, int itemReach) { final Vec3 vec3 = player.getPositionEyes(1.0F); final Vec3 vec31 = player.getLook(1.0F); for (int i = 1; i <= itemReach; i++) // Manually traverse the vector { Vec3 vec32 = vec3.addVector(vec31.xCoord * i, vec31.yCoord * i, vec31.zCoord * i); BlockPos blockpos = new BlockPos(vec32.xCoord, vec32.yCoord, vec32.zCoord); IBlockState iblockstate = world.getBlockState(blockpos); if (iblockstate != null && iblockstate.getBlock().getMaterial() == material) return true; } return false; }
  18. I've managed to resolve my issue and everything works fine now. This is the method I created to find out if the player is currently breaking a block: /** * Checks if the player is in the process of hitting a block. <br> * <i>If the game is played in multiplayer, this should be validated only on client.</i> * * @return True if the player is holding mouse left-click and is mousing over a block. */ public static boolean isPlayerBreakingBlock() { // TODO: Find a better place for this method, it belongs to more of a general purpose category. final Minecraft minecraft = Minecraft.getMinecraft(); final net.minecraft.util.MovingObjectPosition mouseOver = minecraft.objectMouseOver; boolean isAttackKeyDown = minecraft.gameSettings.keyBindAttack.isKeyDown(); boolean isMouseOverBlock = mouseOver != null && mouseOver.typeOfHit == net.minecraft.util.MovingObjectPosition.MovingObjectType.BLOCK; return isAttackKeyDown && isMouseOverBlock; }
  19. Try adding this line of code above your main mod class: @Mod(modid = mod.MODID, version = mod.VERSION, name= mod.NAME, acceptedMinecraftVersions = "[1.8,)") I am not exactly sure if this will work as I've not tried it, however it was a logical conclusion after reading what is written in net.minecraftforge.fml.common.versioning.VersionRange: * Create a version range from a string representation * <p/> * Some spec examples are * <ul> * <li><code>1.0</code> Version 1.0</li> * <li><code>[1.0,2.0)</code> Versions 1.0 (included) to 2.0 (not included)</li> * <li><code>[1.0,2.0]</code> Versions 1.0 to 2.0 (both included)</li> * <li><code>[1.5,)</code> Versions 1.5 and higher</li> * <li><code>(,1.0],[1.2,)</code> Versions up to 1.0 (included) and 1.2 or higher</li> * </ul> Hope this helped and that you can continue solving your issue alone from here. EDIT: Corrected the version range, thanks to GotoLink.
  20. The "bouncing weapon" issue has been resolved a long time ago, read this thread for more info: http://www.minecraftforge.net/forum/index.php/topic,30937.0.html It certainly is possible to modify the reach of your weapons, here's an article I found that talks about it: http://jabelarminecraft.blogspot.de/p/minecraft-modding-extending-reach-of.html Concerning the mining animation speed, I would not know how to go about changing that, however I don't think it should be too big of a problem figuring out. Read the content of the articles pointed to by the links above and let me know if that has helped answer your questions, after you get those things done and still don't know how to handle the animation speed; I promise to take a closer look at it.
  21. You can create an NBT for the inner item (the one inside the backpack) and then save that NBT as an entry in the outer item (backpack) NBT. Let me show you an example of what I'm thinking: public static void SaveBackpack(ItemStack backpack, ItemStack item) { if (stack != null && stack.hasTagCompound() && item != null && item.hasTagCompound()) { stack.getTagCompound().setTag("backpackItems", NBTBase.createNewByType((byte)10)); NBTTagCompound backpackItems = extendedProperties.getCompoundTag("backpackItems"); backpackItems = item.getTagCompound(); } } This code would save the NBT of an item to the NBT of the backpack. I believe you were looking for a way to save NBT subtags, this is the way to do it. Hope this helps, feel free to try it out and let us know if it worked.
  22. Okay that sounds like a good plan, I will try it out as as soon as possible and let you know how it worked. Thank you again for helping out.
  23. /** * Determine if the player switching between these two item stacks * @param oldStack The old stack that was equipped * @param newStack The new stack * @param slotChanged If the current equipped slot was changed, * Vanilla does not play the animation if you switch between two * slots that hold the exact same item. * @return True to play the item change animation */ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return !ItemStack.areItemStacksEqual(oldStack, newStack); } Are you talking about this method? This only affects the "bobbing" animation. The cause of the problem is in PlayerControllerMP.
  24. I was unable to find that method in Item, could you give me more information about it? After closely examining my plan I realized I have no clue how to figure out when the player has stopped breaking the block. Some ideas I had were reading the block destruction progress and overriding the PlayerControllerMP class. For the first one I need access to RenderGlobal.damagedBlocks which is private, for the second idea I don't have enough knowledge on how does the controller interact with the world. A perfect solution would be to listen for a forge event that fires when a player stops breaking a block. Any ideas where to go from this point? Thanks for trying to help.
  25. A method like that does not exist in Block, however you can take a look at ItemStack#canPlaceOn. I've never used it so I am unsure about what exactly does it do but I believe it's worth to take a look.
×
×
  • Create New...

Important Information

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