Created a Liquids API
This commit is contained in:
parent
167c9cb52c
commit
219cdaca8f
3 changed files with 36 additions and 23 deletions
17
src/minecraft/biomesoplenty/api/Liquids.java
Normal file
17
src/minecraft/biomesoplenty/api/Liquids.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package biomesoplenty.api;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
public class Liquids
|
||||
{
|
||||
public static Optional<? extends Block> springWaterFlowing = Optional.absent();
|
||||
public static Optional<? extends Block> springWaterStill = Optional.absent();
|
||||
|
||||
public static Optional<? extends Item> bucketSpringWater = Optional.absent();
|
||||
|
||||
public static Optional<? extends LiquidStack> springWaterLiquid = Optional.absent();
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package biomesoplenty.configuration;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -10,6 +12,7 @@ import net.minecraftforge.liquids.LiquidContainerData;
|
|||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidDictionary;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import biomesoplenty.api.Liquids;
|
||||
import biomesoplenty.items.ItemBOPBucket;
|
||||
import biomesoplenty.liquids.BlockSpringWaterFlowing;
|
||||
import biomesoplenty.liquids.BlockSpringWaterStill;
|
||||
|
@ -20,13 +23,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class BOPLiquids
|
||||
{
|
||||
public static Block springWaterFlowing;
|
||||
public static Block springWaterStill;
|
||||
|
||||
public static Item bucketSpringWater;
|
||||
|
||||
public static LiquidStack springWaterLiquid;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
initializeLiquids();
|
||||
|
@ -38,33 +34,33 @@ public class BOPLiquids
|
|||
|
||||
private static void initializeLiquids()
|
||||
{
|
||||
springWaterFlowing = (new BlockSpringWaterFlowing(BOPConfiguration.springWaterStillID - 1).setUnlocalizedName("springWaterFlowing"));
|
||||
springWaterStill = (new BlockSpringWaterStill(BOPConfiguration.springWaterStillID).setUnlocalizedName("springWaterStill"));
|
||||
Liquids.springWaterFlowing = Optional.of(new BlockSpringWaterFlowing(BOPConfiguration.springWaterStillID - 1).setUnlocalizedName("springWaterFlowing"));
|
||||
Liquids.springWaterStill = Optional.of(new BlockSpringWaterStill(BOPConfiguration.springWaterStillID).setUnlocalizedName("springWaterStill"));
|
||||
|
||||
springWaterLiquid = LiquidDictionary.getOrCreateLiquid("Spring Water", new LiquidStack(springWaterStill, 1));
|
||||
Liquids.springWaterLiquid = Optional.of(LiquidDictionary.getOrCreateLiquid("Spring Water", new LiquidStack(Liquids.springWaterStill.get(), 1)));
|
||||
}
|
||||
|
||||
private static void initializeContainers()
|
||||
{
|
||||
bucketSpringWater = (new ItemBOPBucket(BOPConfiguration.springWaterBucketID, springWaterStill.blockID)).setMaxStackSize(1).setUnlocalizedName("bucketSpringWater").setContainerItem(Item.bucketEmpty);
|
||||
Liquids.bucketSpringWater = Optional.of((new ItemBOPBucket(BOPConfiguration.springWaterBucketID, Liquids.springWaterStill.get().blockID)).setMaxStackSize(1).setUnlocalizedName("bucketSpringWater").setContainerItem(Item.bucketEmpty));
|
||||
|
||||
LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getLiquid("Spring Water", LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketSpringWater), new ItemStack(Item.bucketEmpty)));
|
||||
LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getLiquid("Spring Water", LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(Liquids.bucketSpringWater.get()), new ItemStack(Item.bucketEmpty)));
|
||||
}
|
||||
|
||||
private static void registerLiquids()
|
||||
{
|
||||
GameRegistry.registerBlock(springWaterFlowing, "springWaterFlowing");
|
||||
GameRegistry.registerBlock(springWaterStill, "springWaterStill");
|
||||
GameRegistry.registerBlock(Liquids.springWaterFlowing.get(), "springWaterFlowing");
|
||||
GameRegistry.registerBlock(Liquids.springWaterStill.get(), "springWaterStill");
|
||||
}
|
||||
|
||||
private static void registerContainerNames()
|
||||
{
|
||||
LanguageRegistry.addName(bucketSpringWater, "Spring Water Bucket");
|
||||
LanguageRegistry.addName(Liquids.bucketSpringWater.get(), "Spring Water Bucket");
|
||||
}
|
||||
|
||||
private static void registerLiquidNames()
|
||||
{
|
||||
LanguageRegistry.addName(springWaterFlowing, "Spring Water");
|
||||
LanguageRegistry.addName(springWaterStill, "Spring Water");
|
||||
LanguageRegistry.addName(Liquids.springWaterFlowing.get(), "Spring Water");
|
||||
LanguageRegistry.addName(Liquids.springWaterStill.get(), "Spring Water");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package biomesoplenty.helpers;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import biomesoplenty.configuration.BOPLiquids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -11,6 +8,9 @@ import net.minecraftforge.event.Event.Result;
|
|||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.liquids.LiquidDictionary;
|
||||
import biomesoplenty.api.Liquids;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BOPLiquidHelper
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ public class BOPLiquidHelper
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void textureHook(TextureStitchEvent.Post event)
|
||||
{
|
||||
LiquidDictionary.getCanonicalLiquid("Spring Water").setRenderingIcon(BOPLiquids.springWaterStill.getBlockTextureFromSide(1)).setTextureSheet("/terrain.png");
|
||||
LiquidDictionary.getCanonicalLiquid("Spring Water").setRenderingIcon(Liquids.springWaterStill.get().getBlockTextureFromSide(1)).setTextureSheet("/terrain.png");
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
|
@ -39,11 +39,11 @@ public class BOPLiquidHelper
|
|||
{
|
||||
int blockID = world.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
if ((blockID == BOPLiquids.springWaterStill.blockID || blockID == BOPLiquids.springWaterFlowing.blockID) && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0)
|
||||
if ((blockID == Liquids.springWaterStill.get().blockID || blockID == Liquids.springWaterFlowing.get().blockID) && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0)
|
||||
{
|
||||
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
|
||||
|
||||
return new ItemStack(BOPLiquids.bucketSpringWater);
|
||||
return new ItemStack(Liquids.bucketSpringWater.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue