TerraFirmaCraft

TerraFirmaCraft

2M Downloads

BlockHarvestDropsEvent of crafttweaker dont work for plants

Woody-0w0 opened this issue · 1 comments

commented

Describe the bug
Make sure to include:

  1. custom drop loot table of plants in tfc. (e.g. break sapphire_tower drop apple)
  2. crafttweaker dont work , drop nothing. and tfc knife still works(when knife in hand, drop plant itself).
  3. not a crash.
    To Reproduce
    Attention to detail is important!
    the zs code for crafttweaker break sapphire_tower drop apple :
import crafttweaker.event.BlockHarvestDropsEvent;
import crafttweaker.block.IBlock;
import mods.ctutils.utils.Math;

events.onBlockHarvestDrops(function(event as BlockHarvestDropsEvent) {
    if (!event.world.remote) { 
        if (event.drops.length == 0 || event.silkTouch /*|| event.player.currentItem != air(i dont know ,with hand ,not a knife)*/) {
            return; 
        }
        val block as IBlock = event.block; 
        if (block.definition.id == "tfc:plants/sapphire_tower" && block.meta == 0) { 
            event.drops = [<item:minecraft:apple> % 50]; 
        } else if (block.definition.id == "tfc:plants/sapphire_tower" && block.meta == 1) { 
            event.drops = [<item:minecraft:apple> % 70]; 
        }else if (block.definition.id == "tfc:plants/sapphire_tower" && block.meta == 2) { 
            event.drops = [<item:minecraft:apple> % 100]; /
        }else if (block.definition.id == "tfc:plants/sapphire_tower" && block.meta == 3) { 
            event.drops = [<item:minecraft:apple> % 100]; 
            event.addItem(<item:minecraft:apple>  % 20);
        }
	}
});

show no bug report ,but it just dont work.
the code works if change the blocks to something not a plant.
Meta Info

  • TFC Version: 1.5.2.152
  • other mods included: CraftTweaker2-1.12-4.1.20.562, CrafttweakerUtils-0.6
commented

i found the problem :line7:event.drops.length == 0 dust delete will fix it.