mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 06:24:43 +00:00
Add a harvestblock event, to allow mods to intercept and change the drops for blocks. Don't abuse this, or we'll have to take safety measures.
Fires for both silktouch and non-silktouch harvesting, and provides the player. Note, you may need to change your break overrides to pass on the player for best results.
This commit is contained in:
1 parent
c84d99aa22
commit
ca0e32cfd2
6 files changed
+205
-40
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package net.minecraftforge.event.world;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.Event;
|
||||
|
||||
public class BlockEvent extends Event {
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final World world;
|
||||
public final Block block;
|
||||
public final int blockMetadata;
|
||||
public BlockEvent(int x, int y, int z, World world, Block block, int blockMetadata)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
this.block = block;
|
||||
this.blockMetadata = blockMetadata;
|
||||
}
|
||||
|
||||
public static class HarvestDropsEvent extends BlockEvent {
|
||||
public final int fortuneLevel;
|
||||
public final ArrayList<ItemStack> drops;
|
||||
public final boolean isSilkTouching;
|
||||
public float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops
|
||||
public final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines
|
||||
|
||||
public HarvestDropsEvent(int x, int y, int z, World world, Block block, int blockMetadata, int fortuneLevel, float dropChance, ArrayList<ItemStack> drops, EntityPlayer harvester, boolean isSilkTouching)
|
||||
{
|
||||
super(x, y, z, world, block, blockMetadata);
|
||||
this.fortuneLevel = fortuneLevel;
|
||||
this.dropChance = dropChance;
|
||||
this.drops = drops;
|
||||
this.isSilkTouching = isSilkTouching;
|
||||
this.harvester = harvester;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user