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

Notunknown

Members
  • Posts

    156
  • Joined

  • Last visited

Everything posted by Notunknown

  1. Its passed the (initially empty) list in the deprecated getDrops. All you need to do is populate it.
  2. You dont unless you want to override dropBlockAsItemWithChance, which you most likely dont.
  3. Use NonNullList<ItemStack>#add(ItemStack). Look at the example that I provided earlier.
  4. Yeah, so basically dont use getDrops(IBlockAccess, BlockPos, IBlockState, int) as it will probably be removed entirely by 1.13 and doesnt do anything important, either. As for dropBlockAsItem and dropBlockAsItemWithChance, for most blocks you will not need to override either of those.
  5. Ah, the old getDrops just creates a NonNullList and then calls the new getDrops before returning the list.
  6. Oh, and onBlockDestroyedByPlayer and onBlockDestroyedByExplosion are empty, so only override them if you need some functionality to occur in those situations (such as giving an advancement or something, presumably)
  7. No, dropBlockAsItem calls dropBlockAsItemWithChance, which calls getDrops. Override getDrops and it will affect the other two, but you can override them all if your situation requires it.
  8. I doubt the list would be in the Block, but in whatever function calls getDrops. Your drops should be added to the NonNullList provided. For example: public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { super.getDrops(drops, world, pos, state, fortune); drops.add(new ItemStack(Items.IRON_INGOT)); drops.add(new ItemStack(Items.GOLD_INGOT)); drops.add(new ItemStack(Items.DIAMOND)); }
  9. For these types of functions the list would simply be passed in already created (you dont have to make it yourself with 'new') and you simply add the drops to the list provided. Because its passed by reference then the list will be the same once your function has completed, ready for forge to drop the items onto the ground (or more likely go through the event system first so other mods can make changes to the drops) So just add a, b and c to drops
  10. Well, I have just decided to store the data in the ItemStacks NBT data instead, so I guess I wont need an answer.
  11. Should I even be using Capabilities for this? When should I store data in Capabilities and when should I just store it in NBT?
  12. I have packets - as I said, when a player has the item in their inventory it syncs, it's just that it is flickering when it does this, and I don't know what methods to use to ensure it syncs in all situations.
  13. So I am creating a Capability for an ItemStack and have two major issues and a couple of questions: The first issue is that the capabilities appear to sync fine, but the data flickers back to the default values on the client what appears to be randomly. On the server the values are always correct, however. I am thinking this is a serialization issue, but the serialization issue that I had in the past manifested itself differently to this (not being random). I have checked the incoming packets used to sync the data, and they are correct. The second issue is that I cannot figure out how to sync the item data for other players than the player who is holding the item. What is the best method for syncing this data to all players, regardless of whether the ItemStack is on the ground, in a container or being held by something? Finally, I have a few questions regarding Capabilities and some other information: First, the onUpdate for my Item is fairly simple and could be run on the client (at least partially). It only needs to be synced when the player picks up the ItemStack, drops it or opens a UI (all of which seem to also cause deserialization, so that would be the perfect time to sync). However, I cannot seem to figure out how to do this. Secondly (not a Capabilities question, but doesn't seem worthy of a separate thread), are proxies still needed? I have references to client-only classes (such as a reference to Minecraft in the sync message) without the server exploding.
  14. Also, is that the exact way we should be structuring our mods? I have taken a different approach: giving the Mod.EventBusSubscriber annotation to CommonProxy , and Mod.EventBusSubscriber(Side.CLIENT) and SideOnly(Side.CLIENT) annotations to ClientProxy , the providing each with the necessary events. It works (at least it does not crash when I launch clients or servers). Or maybe I am being an idiot and should just do what was suggested.
  15. That does not make much sense, so I am going to assume that Forge is doing something under the hood. Is there any documentation on how any of this actually works? Learned to read. EDIT: Also, @SideOnly(CLIENT) - is this not "forbidden"?
  16. Not 100% sure if this will work, but here is something you could try: double damage = 0; for (AttributeModifier modifier : player.getHeldItemMainhand().getAttributeModifiers(EntityEquipmentSlot.MAINHAND).get(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName())) { damage += modifier.getAmount(); }
  17. You could provide with another value - the number of health bars remaining. When it dies, subtract 1 from the remaining bar count and restore it to full health, unless the bar count is reduced to 0. For example, if an enemy has 2000 health, give it 1000 health and 2 health bars.
  18. I have been looking for a way to prevent an item from being placed in all contains which I do not approve (as they need to be constantly ticking). However, I could not see any method which I could override, or any event to cancel, which would allow me to do this. Does Forge allow it, or is it something I will have to deal with in some other way. Alternatively, could I simply do something to the ItemStack when it is placed in any invalid inventory? Also, I have noticed that an item held by the cursor does not tick, is there something I need to do to have the item held update? Note that it may result in the ItemStack being replaced by another ItemStack or completely destroyed.
  19. I randomly found out about this: It uses itemstack.getItem() == Items.elytra . Oh well, no need to extend ItemElytra. Here is the code which is run when flying with an elytra: if (this.motionY > -0.5D) { this.fallDistance = 1.0F; } Vec3d vec3d = this.getLookVec(); float f = this.rotationPitch * 0.017453292F; double d6 = Math.sqrt(vec3d.xCoord * vec3d.xCoord + vec3d.zCoord * vec3d.zCoord); double d8 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); double d1 = vec3d.lengthVector(); float f4 = MathHelper.cos(f); f4 = (float)((double)f4 * (double)f4 * Math.min(1.0D, d1 / 0.4D)); this.motionY += -0.08D + (double)f4 * 0.06D; if (this.motionY < 0.0D && d6 > 0.0D) { double d2 = this.motionY * -0.1D * (double)f4; this.motionY += d2; this.motionX += vec3d.xCoord * d2 / d6; this.motionZ += vec3d.zCoord * d2 / d6; } if (f < 0.0F) { double d9 = d8 * (double)(-MathHelper.sin(f)) * 0.04D; this.motionY += d9 * 3.2D; this.motionX -= vec3d.xCoord * d9 / d6; this.motionZ -= vec3d.zCoord * d9 / d6; } if (d6 > 0.0D) { this.motionX += (vec3d.xCoord / d6 * d8 - this.motionX) * 0.1D; this.motionZ += (vec3d.zCoord / d6 * d8 - this.motionZ) * 0.1D; } this.motionX *= 0.9900000095367432D; this.motionY *= 0.9800000190734863D; this.motionZ *= 0.9900000095367432D; this.moveEntity(this.motionX, this.motionY, this.motionZ); if (this.isCollidedHorizontally && !this.worldObj.isRemote) { double d10 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); double d3 = d8 - d10; float f5 = (float)(d3 * 10.0D - 3.0D); if (f5 > 0.0F) { this.playSound(this.getFallSound((int)f5), 1.0F, 1.0F); this.attackEntityFrom(DamageSource.flyIntoWall, f5); } } if (this.onGround && !this.worldObj.isRemote) { this.setFlag(7, false); //Disables elytra flight }
  20. Does Minecraft ever use a non-IReloadableResourceManager? Because it doesn't return one.
  21. Is there an event which fires when Resource Packs are reloaded for reloading custom content?
  22. Because I had not thought of that, of course!
  23. Its for a sort of book, and the information that it contains is quite complex, with text where some lines can have their own font, it can display images, crafting and furnace recipes in the middle of pages and some lines, paragraphs, images, etc can be disabled/enabled by some arbitrary conditions. This is what a typical file could contain:
  24. I forgot that! How can I do this? There isn't a "language changed" event.
  25. My mod requires localization based on JSON files. I am going to go about this by having a subfolder under assets/myMod which contains more subfolders named after the languages (IE: en_US), which the contains a load of different json files. The JSON files are loaded whenever the language is changed and stored somewhere, allowing for localization whilst giving me more power to customize the content of what I am loading.
×
×
  • Create New...

Important Information

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