Merge pull request #86 from CovertJaguar/master
Added filling of generic liquid containers to the Tank
This commit is contained in:
commit
57760812bd
3 changed files with 20 additions and 48 deletions
common/net/minecraft/src
|
@ -24,7 +24,6 @@ import net.minecraft.src.buildcraft.factory.BptBlockFrame;
|
|||
import net.minecraft.src.buildcraft.factory.BptBlockRefinery;
|
||||
import net.minecraft.src.buildcraft.factory.BptBlockTank;
|
||||
import net.minecraft.src.buildcraft.factory.GuiHandler;
|
||||
import net.minecraft.src.buildcraft.factory.TankBucketHandler;
|
||||
import net.minecraft.src.buildcraft.factory.TileAssemblyTable;
|
||||
import net.minecraft.src.buildcraft.factory.TileAutoWorkbench;
|
||||
import net.minecraft.src.buildcraft.factory.TileHopper;
|
||||
|
@ -99,8 +98,6 @@ public class BuildCraftFactory {
|
|||
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
|
||||
MinecraftForge.registerCustomBucketHandler(new TankBucketHandler());
|
||||
|
||||
miningWellBlock = new BlockMiningWell(Integer.parseInt(minigWellId.value));
|
||||
CoreProxy.registerBlock(miningWellBlock.setBlockName("miningWellBlock"));
|
||||
CoreProxy.addName(miningWellBlock, "Mining Well");
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.src.Material;
|
|||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
|
||||
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.core.Utils;
|
||||
|
@ -88,8 +89,10 @@ public class BlockTank extends BlockContainer implements ITextureProvider {
|
|||
@Override
|
||||
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
|
||||
|
||||
if (entityplayer.getCurrentEquippedItem() != null) {
|
||||
int liquidId = BuildCraftAPI.getLiquidForFilledItem(entityplayer.getCurrentEquippedItem());
|
||||
ItemStack current = entityplayer.inventory.getCurrentItem();
|
||||
if (current != null) {
|
||||
|
||||
int liquidId = LiquidManager.getLiquidForFilledItem(current);
|
||||
|
||||
TileTank tank = (TileTank) world.getBlockTileEntity(i, j, k);
|
||||
|
||||
|
@ -98,10 +101,24 @@ public class BlockTank extends BlockContainer implements ITextureProvider {
|
|||
|
||||
if (qty != 0 && !BuildCraftCore.debugMode) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem,
|
||||
Utils.consumeItem(entityplayer.inventory.getCurrentItem()));
|
||||
Utils.consumeItem(current));
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
ItemStack filled = LiquidManager.fillLiquidContainer(tank.getLiquidId(), current);
|
||||
|
||||
int qty = tank.empty(BuildCraftAPI.BUCKET_VOLUME, false);
|
||||
|
||||
if(filled != null && qty >= BuildCraftAPI.BUCKET_VOLUME){
|
||||
if(current.stacksize > 1 && !entityplayer.inventory.addItemStackToInventory(filled)){
|
||||
return false;
|
||||
}
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem,
|
||||
Utils.consumeItem(current));
|
||||
tank.empty(BuildCraftAPI.BUCKET_VOLUME, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.minecraft.src.buildcraft.factory;
|
||||
|
||||
import net.minecraft.src.BuildCraftFactory;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
|
||||
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
|
||||
import net.minecraft.src.forge.IBucketHandler;
|
||||
|
||||
public class TankBucketHandler implements IBucketHandler {
|
||||
|
||||
@Override
|
||||
public ItemStack fillCustomBucket(World w, int i, int j, int k) {
|
||||
if (w.getBlockId(i, j, k) == BuildCraftFactory.tankBlock.blockID) {
|
||||
|
||||
TileTank tank = (TileTank) w.getBlockTileEntity(i, j, k);
|
||||
|
||||
int qty = tank.empty(BuildCraftAPI.BUCKET_VOLUME, false);
|
||||
|
||||
ItemStack filledBucket = LiquidManager.fillLiquidContainer(tank.getLiquidId(), new ItemStack(Item.bucketEmpty));
|
||||
|
||||
if (qty >= BuildCraftAPI.BUCKET_VOLUME && filledBucket != null) {
|
||||
tank.empty(BuildCraftAPI.BUCKET_VOLUME, true);
|
||||
|
||||
return filledBucket;
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue