2013-05-25 04:08:06 +00:00
|
|
|
package biomesoplenty.helpers;
|
|
|
|
|
2013-05-29 01:05:27 +00:00
|
|
|
import net.minecraft.block.BlockFluid;
|
2013-06-21 09:32:10 +00:00
|
|
|
import net.minecraft.item.Item;
|
2013-05-25 04:08:06 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
import net.minecraft.world.World;
|
2013-05-25 08:57:21 +00:00
|
|
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
2013-05-25 04:08:06 +00:00
|
|
|
import net.minecraftforge.event.Event.Result;
|
|
|
|
import net.minecraftforge.event.ForgeSubscribe;
|
|
|
|
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
2013-05-30 09:41:07 +00:00
|
|
|
import net.minecraftforge.fluids.FluidRegistry;
|
2013-05-31 11:42:41 +00:00
|
|
|
import net.minecraftforge.liquids.LiquidDictionary;
|
2013-05-25 09:25:46 +00:00
|
|
|
import biomesoplenty.api.Liquids;
|
2013-06-21 09:32:10 +00:00
|
|
|
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-25 04:08:06 +00:00
|
|
|
|
2013-05-31 10:34:02 +00:00
|
|
|
public class BOPLiquidHelper
|
2013-05-25 04:08:06 +00:00
|
|
|
{
|
2013-05-25 08:57:21 +00:00
|
|
|
@ForgeSubscribe
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-05-31 10:34:02 +00:00
|
|
|
public void textureHook(TextureStitchEvent.Post event)
|
2013-05-25 08:57:21 +00:00
|
|
|
{
|
2013-05-30 08:18:07 +00:00
|
|
|
//TODO: Remove upon Fluid API being integrated into Forge
|
2013-05-29 01:05:27 +00:00
|
|
|
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"));
|
2013-05-31 11:42:41 +00:00
|
|
|
|
|
|
|
//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-25 08:57:21 +00:00
|
|
|
}
|
2013-05-31 10:34:02 +00:00
|
|
|
|
2013-05-25 04:08:06 +00:00
|
|
|
@ForgeSubscribe
|
2013-05-31 10:34:02 +00:00
|
|
|
public void onBucketFill(FillBucketEvent event)
|
2013-05-25 04:08:06 +00:00
|
|
|
{
|
|
|
|
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)
|
2013-05-25 04:08:06 +00:00
|
|
|
{
|
|
|
|
int blockID = world.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
|
2013-05-29 01:05:27 +00:00
|
|
|
int meta = world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
|
2013-05-25 04:08:06 +00:00
|
|
|
|
2013-05-31 10:34:02 +00:00
|
|
|
if ((blockID == Liquids.springWater.get().blockID) && meta == 0)
|
2013-05-25 04:08:06 +00:00
|
|
|
{
|
|
|
|
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
|
|
|
|
|
2013-06-21 09:32:10 +00:00
|
|
|
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)
|
2013-05-25 13:22:37 +00:00
|
|
|
{
|
|
|
|
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;
|
2013-05-25 04:08:06 +00:00
|
|
|
}
|
|
|
|
}
|