Jump to content

Recommended Posts

Posted (edited)

Edit: altered the title to more accurately reflect the problem. Please see four posts down almost up-to-date information.

 

I set up all of the loot tables for my blocks and discovered one of them is not working. I have tried various versions of the file, Even the most simple table possible had noeffect. The version below is a direct copy paste from vanilla cobweb and hasn't even had the drops altered.

 

Spoiler

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:alternatives",
          "children": [
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:alternative",
                  "terms": [
                    {
                      "condition": "minecraft:match_tool",
                      "predicate": {
                        "item": "minecraft:shears"
                      }
                    },
                    {
                      "condition": "minecraft:match_tool",
                      "predicate": {
                        "enchantments": [
                          {
                            "enchantment": "minecraft:silk_touch",
                            "levels": {
                              "min": 1
                            }
                          }
                        ]
                      }
                    }
                  ]
                }
              ],
              "name": "minecraft:cobweb"
            },
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:survives_explosion"
                }
              ],
              "name": "minecraft:string"
            }
          ]
        }
      ]
    }
  ]
}

 

I have used breakpoints on every single piece of code in the block class that references dropping blocks and none of them appear to be triggered. I have been able to verify that the block item is being registered (again, this is one amongst a dozen blocks all being registered in the same way). There are no errors/crashes in the console. Simply, nothing seems to drop. The block item registry name is set by calling the blocks registry name. There doesn't appear to be any other spelling issues. I have got to be missing something very simple.

Also, the blocks class is an extension of the ladder class, comprised of an override for on entity collision which slows down any entities on the custom block and a redundant override of getitem() and getDrops() which was done to insert a system out (which produced nothing).

Edited by salvestrom
Clarification
Posted (edited)

Whoops, it didn't copy correctly. Valid json is valid. Hmm.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Update/clarification:
I set breakpoints on every single getDrops and spawnDrops method in block, as well as getLootTable and spawnAsEntity (simultaneously). I also overrode getLootTable in two of my block classes, using system counts to state that it had arrived at the code as well as display what the result of the super call is. The results were this:

  • During model loading the breakpoints for getLootTable were triggered for every single block, including mine, including the climbing web. This method was triggered again on world load.
  • I broke three blocks: dirt, a random one of mine and climbing web. The first two triggered multiple breakpoints in succession, the climbing web breaking triggered none of it.

How can the game recognise the loot table while loading yet not even try to drop loot once in game?

Again I note that my block extends the ladder, but the ladder itself contains nothing unusual. Besides, I have another ladder which doesn't have any issues.

Posted

Additional Breakpoint testing has revealed the issue is centred around this piece of code from the PlayerInteractionManager class. The flag and flag1 if statement is not being passed and so harvest block is not being run.

               boolean flag1 = blockstate.canHarvestBlock(this.world, pos, this.player);
               itemstack.onBlockDestroyed(this.world, blockstate, pos, this.player);
               if (itemstack.isEmpty() && !copy.isEmpty()) {
                  net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.player, copy, Hand.MAIN_HAND);
               }
               boolean flag = removeBlock(pos, flag1);
               if (flag && flag1) {
                  ItemStack itemstack1 = itemstack.isEmpty() ? ItemStack.EMPTY : itemstack.copy();
                  block.harvestBlock(this.world, this.player, pos, blockstate, tileentity, itemstack1);
               }

Remove block seemed pretty innocuous so I focused on canHarvestBlock. Looking into this led me to realise/discover that my climbing web, since it is using Material.WEB has a requires tool check and swords and shears are hardcoded for the Cobweb block. Quite how this is affecting things, I don't know, but when I changed the material to WOOD which has no tool requirement, the items began dropping correctly.If I want to continue using web as the material am I going to need to use the forge hook for canHarvestBlock? Or is there something else I'm missing…

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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