BiomesOPlenty/src/minecraft/biomesoplenty/helpers/BOPLiquidHelper.java

74 lines
2.4 KiB
Java
Raw Normal View History

package biomesoplenty.helpers;
import net.minecraft.block.BlockFluid;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.liquids.LiquidDictionary;
2013-05-25 09:25:46 +00:00
import biomesoplenty.api.Liquids;
import biomesoplenty.configuration.BOPConfiguration;
2013-05-25 09:25:46 +00:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2013-05-31 10:34:02 +00:00
public class BOPLiquidHelper
{
@ForgeSubscribe
@SideOnly(Side.CLIENT)
2013-05-31 10:34:02 +00:00
public void textureHook(TextureStitchEvent.Post event)
{
//TODO: Remove upon Fluid API being integrated into Forge
FluidRegistry.WATER.setIcons(BlockFluid.func_94424_b("water"), BlockFluid.func_94424_b("water_flow"));
FluidRegistry.LAVA.setIcons(BlockFluid.func_94424_b("lava"), BlockFluid.func_94424_b("lava_flow"));
//TODO: Remove upon Fluid API being integrated into Forge
LiquidDictionary.getCanonicalLiquid("Spring Water").setRenderingIcon(Liquids.springWater.get().getBlockTextureFromSide(1)).setTextureSheet("/terrain.png");
LiquidDictionary.getCanonicalLiquid("Liquid Poison").setRenderingIcon(Liquids.liquidPoison.get().getBlockTextureFromSide(1)).setTextureSheet("/terrain.png");
}
2013-05-31 10:34:02 +00:00
@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-05-31 10:34:02 +00:00
if ((blockID == Liquids.springWater.get().blockID) && meta == 0)
{
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
if (BOPConfiguration.springWaterPickup)
{
return new ItemStack(Liquids.bopBucket.get(), 1, 0);
}
else
{
return new ItemStack(Item.bucketWater);
}
2013-05-31 10:34:02 +00:00
}
if ((blockID == Liquids.liquidPoison.get().blockID) && meta == 0)
{
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
return new ItemStack(Liquids.bopBucket.get(), 1, 1);
2013-05-31 10:34:02 +00:00
} else
return null;
}
}