Added Spring Water Buckets and tweaked Spring Water

This commit is contained in:
Adubbz 2013-05-25 14:08:06 +10:00
parent c9e2d6ee07
commit e2a0160088
8 changed files with 122 additions and 17 deletions

View file

@ -19,6 +19,7 @@ import biomesoplenty.configuration.BOPItems;
import biomesoplenty.configuration.BOPLiquids; import biomesoplenty.configuration.BOPLiquids;
import biomesoplenty.configuration.BOPVanillaCompat; import biomesoplenty.configuration.BOPVanillaCompat;
import biomesoplenty.helpers.AchievementHelper; import biomesoplenty.helpers.AchievementHelper;
import biomesoplenty.helpers.BOPBucketHelper;
import biomesoplenty.helpers.BOPCraft; import biomesoplenty.helpers.BOPCraft;
import biomesoplenty.helpers.BonemealUse; import biomesoplenty.helpers.BonemealUse;
import biomesoplenty.helpers.CreativeTabsBOP; import biomesoplenty.helpers.CreativeTabsBOP;
@ -128,6 +129,7 @@ public class BiomesOPlenty
MinecraftForge.EVENT_BUS.register(new AchievementHelper()); MinecraftForge.EVENT_BUS.register(new AchievementHelper());
MinecraftForge.EVENT_BUS.register(new BonemealUse()); MinecraftForge.EVENT_BUS.register(new BonemealUse());
MinecraftForge.EVENT_BUS.register(new EntitiesHelper()); MinecraftForge.EVENT_BUS.register(new EntitiesHelper());
MinecraftForge.EVENT_BUS.register(new BOPBucketHelper());
proxy.registerRenderers(); proxy.registerRenderers();

View file

@ -205,6 +205,8 @@ public class BOPConfiguration {
public static int dartBlowerID; public static int dartBlowerID;
public static int dartID; public static int dartID;
public static int springWaterBucketID;
public static int swordMudID; public static int swordMudID;
public static int shovelMudID; public static int shovelMudID;
public static int pickaxeMudID; public static int pickaxeMudID;
@ -750,6 +752,8 @@ public class BOPConfiguration {
flowerBandID = config.getItem("Flower Band ID", 21078, null).getInt(); flowerBandID = config.getItem("Flower Band ID", 21078, null).getInt();
springWaterBucketID = config.getItem("Spring Water Bucket ID", 21079, null).getInt();
//Liquid Ids //Liquid Ids
springWaterStillID = config.get("Liquid IDs", "Spring Water Still ID (ID before this must be free!)", 1971, null).getInt(); springWaterStillID = config.get("Liquid IDs", "Spring Water Still ID (ID before this must be free!)", 1971, null).getInt();

View file

@ -1,19 +1,21 @@
package biomesoplenty.configuration; package biomesoplenty.configuration;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.liquids.LiquidContainerData;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidStack;
import biomesoplenty.api.Blocks; import biomesoplenty.items.ItemBOPBucket;
import biomesoplenty.items.ItemBOPMud;
import biomesoplenty.liquids.BlockSpringWaterFlowing; import biomesoplenty.liquids.BlockSpringWaterFlowing;
import biomesoplenty.liquids.BlockSpringWaterStill; import biomesoplenty.liquids.BlockSpringWaterStill;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.LanguageRegistry;
public class BOPLiquids { public class BOPLiquids
{
public static Block springWaterFlowing; public static Block springWaterFlowing;
public static Block springWaterStill; public static Block springWaterStill;
@ -24,25 +26,41 @@ public class BOPLiquids {
public static void init() public static void init()
{ {
initializeLiquids(); initializeLiquids();
initializeContainers();
registerLiquids(); registerLiquids();
registerNames(); registerContainerNames();
registerLiquidNames();
} }
private static void initializeLiquids() private static void initializeLiquids()
{ {
springWaterFlowing = (new BlockSpringWaterFlowing(BOPConfiguration.springWaterStillID - 1).setUnlocalizedName("springWaterFlowing")); springWaterFlowing = (new BlockSpringWaterFlowing(BOPConfiguration.springWaterStillID - 1).setUnlocalizedName("springWaterFlowing"));
springWaterStill = (new BlockSpringWaterStill(BOPConfiguration.springWaterStillID).setUnlocalizedName("springWaterStill")); springWaterStill = (new BlockSpringWaterStill(BOPConfiguration.springWaterStillID).setUnlocalizedName("springWaterStill"));
springWaterLiquid = LiquidDictionary.getOrCreateLiquid("Spring Water", new LiquidStack(springWaterStill, 1));
}
private static void initializeContainers()
{
bucketSpringWater = (new ItemBOPBucket(BOPConfiguration.springWaterBucketID, springWaterStill.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)));
} }
private static void registerLiquids() private static void registerLiquids()
{ {
GameRegistry.registerBlock(springWaterFlowing, "springWaterFlowing"); GameRegistry.registerBlock(springWaterFlowing, "springWaterFlowing");
GameRegistry.registerBlock(springWaterStill, "springWaterStill"); GameRegistry.registerBlock(springWaterStill, "springWaterStill");
} }
private static void registerNames() private static void registerContainerNames()
{ {
LanguageRegistry.addName(springWaterFlowing, "Spring Water"); LanguageRegistry.addName(bucketSpringWater, "Spring Water Bucket");
LanguageRegistry.addName(springWaterStill, "Spring Water"); }
private static void registerLiquidNames()
{
LanguageRegistry.addName(springWaterFlowing, "Spring Water");
LanguageRegistry.addName(springWaterStill, "Spring Water");
} }
} }

View file

@ -0,0 +1,42 @@
package biomesoplenty.helpers;
import biomesoplenty.configuration.BOPLiquids;
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;
public class BOPBucketHelper
{
@ForgeSubscribe
public void onBucketFill(FillBucketEvent event)
{
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
{
return;
}
event.result = result;
event.setResult(Result.ALLOW);
}
public ItemStack fillCustomBucket(World world, MovingObjectPosition pos)
{
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)
{
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
return new ItemStack(BOPLiquids.bucketSpringWater);
}
else
{
return null;
}
}
}

View file

@ -0,0 +1,25 @@
package biomesoplenty.items;
import biomesoplenty.BiomesOPlenty;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StringUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBOPBucket extends ItemBucket
{
public ItemBOPBucket(int i, int liquidID)
{
super(i, liquidID);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon("BiomesOPlenty:spring_water_bucket");
}
}

View file

@ -20,7 +20,7 @@ public class BlockSpringWaterFlowing extends BlockFlowing
super(id, Material.water); super(id, Material.water);
this.blockHardness = 100F; this.blockHardness = 100F;
this.setLightOpacity(3); this.setLightOpacity(0);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
} }

View file

@ -21,11 +21,25 @@ public class BlockSpringWaterStill extends BlockStationary
super(id, Material.water); super(id, Material.water);
this.blockHardness = 100F; this.blockHardness = 100F;
this.setLightOpacity(3); this.setLightOpacity(0);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
this.disableStats(); this.disableStats();
} }
@Override
public void onBlockAdded(World par1World, int x, int y, int z)
{
this.setSpringWaterNotStationary(par1World, x, y, z);;
}
public void setSpringWaterNotStationary(World par1World, int par2, int par3, int par4)
{
int l = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlock(par2, par3, par4, this.blockID - 1, l, 2);
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID - 1, this.tickRate(par1World));
}
@Override @Override
public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity) public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity)
{ {