BiomesOPlenty/src/minecraft/biomesoplenty/handlers/BOPLiquidEventHandler.java

50 lines
1.2 KiB
Java
Raw Normal View History

package biomesoplenty.handlers;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent;
2013-07-09 04:10:57 +00:00
import biomesoplenty.api.Fluids;
public class BOPLiquidEventHandler
{
@ForgeSubscribe
2013-05-31 10:34:02 +00:00
public void onBucketFill(FillBucketEvent event)
{
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
return;
event.result = result;
event.setResult(Result.ALLOW);
}
2013-05-31 10:34:02 +00:00
public ItemStack fillCustomBucket(World world, MovingObjectPosition pos)
{
int blockID = world.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
int meta = world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
2013-07-09 04:10:57 +00:00
if ((blockID == Fluids.springWater.get().blockID) && meta == 0)
{
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
return new ItemStack(Item.bucketWater);
2013-05-31 10:34:02 +00:00
}
2013-07-09 04:10:57 +00:00
if ((blockID == Fluids.liquidPoison.get().blockID) && meta == 0)
{
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
2013-07-09 04:10:57 +00:00
return new ItemStack(Fluids.bopBucket.get(), 1, 2);
}
else
{
2013-05-31 10:34:02 +00:00
return null;
}
}
}