mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bd5bb120d | ||
|
|
dbbb727576 | ||
|
|
dcf0fc83ad | ||
|
|
6ef91590cf | ||
|
|
856322b208 | ||
|
|
42425e3500 | ||
|
|
cde076e702 | ||
|
|
b5f60d73e3 | ||
|
|
f82d123b7f | ||
|
|
ca17801c86 | ||
|
|
33d1685713 | ||
|
|
69c024811f | ||
|
|
4dd95625e1 | ||
|
|
6adcde4a75 | ||
|
|
2f06c777b2 | ||
|
|
32f295b16c |
No files matched your search
+2
-2
@@ -1,9 +1,9 @@
|
||||
mcversion=1.9.4
|
||||
forgeversion=12.17.0.1940
|
||||
forgeversion=12.17.0.1950
|
||||
mcp_mappings=snapshot_20160525
|
||||
|
||||
jei_version=3.4.0.+
|
||||
|
||||
version_major=5
|
||||
version_minor=0
|
||||
version_patch=4
|
||||
version_patch=7
|
||||
@@ -49,7 +49,7 @@ import forestry.plugins.PluginManager;
|
||||
name = "Forestry",
|
||||
version = Constants.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
dependencies = "required-after:Forge@[12.17.0.1932,);"
|
||||
dependencies = "required-after:Forge@[12.17.0.1949,);"
|
||||
+ "after:Buildcraft|Core@[7.2,);"
|
||||
+ "after:BuildCraft|Energy@[7.2,);"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
@@ -22,7 +22,7 @@ public interface IGreenhouseState {
|
||||
|
||||
float getExactHumidity();
|
||||
|
||||
List<IInternalBlock> getInternalBlocks();
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
|
||||
Collection<IMultiblockComponent> getGreenhouseComponents();
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ import forestry.apiculture.multiblock.TileAlvearyStabiliser;
|
||||
import forestry.apiculture.multiblock.TileAlvearySwarmer;
|
||||
import forestry.apiculture.network.PacketRegistryApiculture;
|
||||
import forestry.apiculture.proxy.ProxyApiculture;
|
||||
import forestry.apiculture.proxy.ProxyApicultureClient;
|
||||
import forestry.apiculture.tiles.TileCandle;
|
||||
import forestry.apiculture.tiles.TileHive;
|
||||
import forestry.apiculture.worldgen.HiveDecorator;
|
||||
@@ -127,7 +128,6 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
public static ProxyApiculture proxy;
|
||||
private static final String CONFIG_CATEGORY = "apiculture";
|
||||
public static String beekeepingMode = "NORMAL";
|
||||
public static TextureAtlasSprite beeSprite;
|
||||
private static float secondPrincessChance = 0;
|
||||
public static final int ticksPerBeeWorkCycle = 550;
|
||||
public static boolean fancyRenderedBees = false;
|
||||
@@ -848,7 +848,7 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
for (int i = 0; i < ParticleSnow.sprites.length; i++) {
|
||||
ParticleSnow.sprites[i] = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/snow." + (i + 1)));
|
||||
}
|
||||
beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee"));
|
||||
ProxyApicultureClient.beeSprite = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/swarm_bee"));
|
||||
}
|
||||
|
||||
private static class EndFlowerAcceptableRule implements IFlowerAcceptableRule {
|
||||
|
||||
@@ -33,12 +33,8 @@ public enum BlockTypeApicultureTesr implements IBlockTypeTesr {
|
||||
@Nonnull
|
||||
private final IMachinePropertiesTesr<?> machineProperties;
|
||||
|
||||
<T extends TileForestry> BlockTypeApicultureTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, @Nullable AxisAlignedBB boundingBox) {
|
||||
if (boundingBox != null) {
|
||||
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0");
|
||||
} else {
|
||||
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, Constants.MOD_ID + ":blocks/" + name + ".0");
|
||||
}
|
||||
<T extends TileForestry> BlockTypeApicultureTesr(@Nonnull Class<T> teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer<? super T> renderer, AxisAlignedBB boundingBox) {
|
||||
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -12,20 +12,19 @@ package forestry.apiculture.entities;
|
||||
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
import forestry.apiculture.proxy.ProxyApicultureClient;
|
||||
|
||||
public class ParticleBeeExplore extends Particle {
|
||||
private final Vec3d origin;
|
||||
|
||||
public ParticleBeeExplore(World world, Vec3d origin, BlockPos destination, int color) {
|
||||
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
|
||||
setParticleTexture(PluginApiculture.beeSprite);
|
||||
setParticleTexture(ProxyApicultureClient.beeSprite);
|
||||
this.origin = origin;
|
||||
|
||||
this.motionX = (destination.getX() + 0.5 - this.posX) * 0.015;
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
import forestry.apiculture.proxy.ProxyApicultureClient;
|
||||
|
||||
public class ParticleBeeRoundTrip extends Particle {
|
||||
private final Vec3d origin;
|
||||
@@ -25,7 +25,7 @@ public class ParticleBeeRoundTrip extends Particle {
|
||||
|
||||
public ParticleBeeRoundTrip(World world, Vec3d origin, BlockPos destination, int color) {
|
||||
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
|
||||
setParticleTexture(PluginApiculture.beeSprite);
|
||||
setParticleTexture(ProxyApicultureClient.beeSprite);
|
||||
this.origin = origin;
|
||||
|
||||
this.destination = destination;
|
||||
|
||||
@@ -13,11 +13,10 @@ package forestry.apiculture.entities;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
import forestry.apiculture.proxy.ProxyApicultureClient;
|
||||
|
||||
public class ParticleBeeTargetEntity extends Particle {
|
||||
private final Vec3d origin;
|
||||
@@ -25,7 +24,7 @@ public class ParticleBeeTargetEntity extends Particle {
|
||||
|
||||
public ParticleBeeTargetEntity(World world, Vec3d origin, Entity entity, int color) {
|
||||
super(world, origin.xCoord, origin.yCoord, origin.zCoord, 0.0D, 0.0D, 0.0D);
|
||||
setParticleTexture(PluginApiculture.beeSprite);
|
||||
setParticleTexture(ProxyApicultureClient.beeSprite);
|
||||
|
||||
this.origin = origin;
|
||||
this.entity = entity;
|
||||
|
||||
@@ -12,10 +12,10 @@ package forestry.apiculture.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
|
||||
public class InventoryHygroregulator extends InventoryAdapterTile<TileAlvearyHygroregulator> {
|
||||
@@ -28,8 +28,8 @@ public class InventoryHygroregulator extends InventoryAdapterTile<TileAlvearyHyg
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
@@ -36,7 +36,7 @@ import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
|
||||
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IFluidHandler, IAlvearyComponent.Climatiser {
|
||||
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IAlvearyComponent.Climatiser {
|
||||
private final HygroregulatorRecipe[] recipes;
|
||||
|
||||
private final TankManager tankManager;
|
||||
@@ -55,7 +55,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
Fluid lava = Fluids.LAVA.getFluid();
|
||||
Fluid liquidIce = Fluids.ICE.getFluid();
|
||||
|
||||
this.liquidTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce);
|
||||
this.liquidTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(water, lava, liquidIce);
|
||||
|
||||
this.tankManager = new TankManager(this, liquidTank);
|
||||
|
||||
this.recipes = new HygroregulatorRecipe[]{new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
|
||||
@@ -91,7 +92,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
currentRecipe = getRecipe(liquidTank.getFluid());
|
||||
|
||||
if (currentRecipe != null) {
|
||||
liquidTank.drain(currentRecipe.liquid.amount, true);
|
||||
liquidTank.drainInternal(currentRecipe.liquid.amount, true);
|
||||
transferTime = currentRecipe.transferTime;
|
||||
}
|
||||
}
|
||||
@@ -150,33 +151,22 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,8 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.proxy;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
|
||||
public class ProxyApicultureClient extends ProxyApiculture {
|
||||
|
||||
public static TextureAtlasSprite beeSprite;
|
||||
|
||||
@Override
|
||||
public void initializeRendering() {
|
||||
// TODO: remove unused bee entity model completely
|
||||
|
||||
@@ -231,8 +231,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
if (damage > 0) {
|
||||
// Entities are not attacked if they wear a full set of apiarist's armor.
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems(entity, damageSourceBeeHive.damageType, true);
|
||||
damage -= damage / 4.0f * count;
|
||||
if (damage > 0) {
|
||||
if (entity.worldObj.rand.nextInt(4) >= count) {
|
||||
entity.attackEntityFrom(damageSourceBeeHive, damage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -40,7 +41,7 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
|
||||
private final EnumForestryWoodType woodType;
|
||||
|
||||
public BlockArbDoor(EnumForestryWoodType woodType) {
|
||||
super(MaterialArbWood.ARB_WOOD);
|
||||
super(Material.WOOD);
|
||||
this.woodType = woodType;
|
||||
|
||||
setHarvestLevel("axe", 0);
|
||||
|
||||
@@ -73,14 +73,16 @@ public class ItemBlockPile<B extends Block> extends ItemBlockForestry<Block> {
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
|
||||
|
||||
if(block == PluginArboriculture.blocks.piles.get(EnumPileType.WOOD)){
|
||||
if (block.hasTileEntity(newState)) {
|
||||
if (stack.hasTagCompound()) {
|
||||
TilePile tile = TileUtil.getTile(world, pos, TilePile.class);
|
||||
if (tile != null) {
|
||||
tile.readFromNBT(stack.getTagCompound());
|
||||
tile.setPos(pos);
|
||||
tile.markDirty();
|
||||
if (placed) {
|
||||
if (block == PluginArboriculture.blocks.piles.get(EnumPileType.WOOD)) {
|
||||
if (block.hasTileEntity(newState)) {
|
||||
if (stack.hasTagCompound()) {
|
||||
TilePile tile = TileUtil.getTile(world, pos, TilePile.class);
|
||||
if (tile != null) {
|
||||
tile.readFromNBT(stack.getTagCompound());
|
||||
tile.setPos(pos);
|
||||
tile.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,14 +92,14 @@ public class ModelLeaves extends ModelBlockDefault<BlockForestryLeaves> {
|
||||
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
|
||||
|
||||
// Render the plain leaf block.
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, leafSprite, 0);
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, leafSprite, 0);
|
||||
|
||||
// Render overlay for fruit leaves.
|
||||
ResourceLocation fruitSpriteLocation = tile.getFruitSprite();
|
||||
|
||||
if (fruitSpriteLocation != null) {
|
||||
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, pos, fruitSprite, 1);
|
||||
baker.addBlockModel(block, Block.FULL_BLOCK_AABB, null, fruitSprite, 1);
|
||||
}
|
||||
|
||||
// Set the particle sprite
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.core.fluids.Fluids;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -48,7 +49,6 @@ import forestry.core.commands.CommandPlugins;
|
||||
import forestry.core.commands.RootCommand;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.genetics.alleles.AlleleFactory;
|
||||
import forestry.core.genetics.alleles.AlleleHelper;
|
||||
import forestry.core.genetics.alleles.AlleleRegistry;
|
||||
@@ -336,9 +336,9 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
int bogEarthOutputCan = ForestryAPI.activeMode.getIntegerSetting("recipe.output.bogearth.can");
|
||||
if (bogEarthOutputCan > 0) {
|
||||
ItemStack bogEarth = blocks.bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, bogEarthOutputCan);
|
||||
ItemStack canWater = PluginFluids.items.getContainer(EnumContainerType.CAN, Fluids.WATER).getItemStack();
|
||||
ItemStack waxCapsuleWater = PluginFluids.items.getContainer(EnumContainerType.CAPSULE, Fluids.WATER).getItemStack();
|
||||
ItemStack refractoryWater = PluginFluids.items.getContainer(EnumContainerType.REFRACTORY, Fluids.WATER).getItemStack();
|
||||
ItemStack canWater = PluginFluids.items.getContainer(EnumContainerType.CAN, Fluids.WATER);
|
||||
ItemStack waxCapsuleWater = PluginFluids.items.getContainer(EnumContainerType.CAPSULE, Fluids.WATER);
|
||||
ItemStack refractoryWater = PluginFluids.items.getContainer(EnumContainerType.REFRACTORY, Fluids.WATER);
|
||||
RecipeUtil.addRecipe(bogEarth, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', canWater, 'Y', OreDictUtil.SAND);
|
||||
RecipeUtil.addRecipe(bogEarth, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', waxCapsuleWater, 'Y', OreDictUtil.SAND);
|
||||
RecipeUtil.addRecipe(bogEarth, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', refractoryWater, 'Y', OreDictUtil.SAND);
|
||||
|
||||
@@ -10,17 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.GeneratorFuel;
|
||||
@@ -28,15 +17,20 @@ import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.fluids.LiquidRegistryHelper;
|
||||
import forestry.core.items.EnumContainerType;
|
||||
import forestry.core.items.ItemLiquidContainer;
|
||||
import forestry.core.items.ItemRegistryFluids;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.FLUIDS, name = "Fluids", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.plugin.fluids.description")
|
||||
public class PluginFluids extends BlankForestryPlugin {
|
||||
@@ -99,25 +93,6 @@ public class PluginFluids extends BlankForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void doInit() {
|
||||
for (Fluids fluidType : Fluids.values()) {
|
||||
if (fluidType.getFluid() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (EnumContainerType type : EnumContainerType.values()) {
|
||||
ItemLiquidContainer container = items.getContainer(type, fluidType);
|
||||
if (container == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LiquidRegistryHelper.registerLiquidContainer(fluidType, container.getItemStack());
|
||||
}
|
||||
|
||||
for (ItemStack filledContainer : fluidType.getOtherContainers()) {
|
||||
LiquidRegistryHelper.registerLiquidContainer(fluidType, filledContainer);
|
||||
}
|
||||
}
|
||||
|
||||
if (RecipeManagers.squeezerManager != null) {
|
||||
RecipeManagers.squeezerManager.addContainerRecipe(10, items.canEmpty.getItemStack(), PluginCore.items.ingotTin.copy(), 0.05f);
|
||||
RecipeManagers.squeezerManager.addContainerRecipe(10, items.waxCapsuleEmpty.getItemStack(), PluginCore.items.beeswax.getItemStack(), 0.10f);
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -40,7 +39,9 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -51,7 +52,6 @@ import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.MachineParticleCallback;
|
||||
import forestry.core.render.MachineStateMapper;
|
||||
@@ -124,6 +124,14 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
|
||||
return definition.getBoundingBox(pos, blockState);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos) {
|
||||
IMachineProperties definition = getDefinition();
|
||||
return definition.getBoundingBox(pos, state).offset(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
IMachineProperties definition = getDefinition();
|
||||
@@ -139,10 +147,6 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
|
||||
/* INTERACTION */
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (playerIn.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileBase tile = TileUtil.getTile(worldIn, pos, TileBase.class);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
@@ -154,9 +158,12 @@ public class BlockBase<P extends Enum<P> & IBlockType & IStringSerializable> ext
|
||||
|
||||
IAccessHandler access = tile.getAccessHandler();
|
||||
|
||||
if (heldItem != null && heldItem.getItem() != Items.BUCKET && tile instanceof IFluidHandler && access.allowsAlteration(playerIn)) {
|
||||
if (FluidHelper.handleRightClick((IFluidHandler) tile, side, playerIn, true, tile.canDrainWithBucket())) {
|
||||
return true;
|
||||
if (!playerIn.isSneaking()) {
|
||||
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
|
||||
IFluidHandler tileFluidHandler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
|
||||
if (FluidUtil.interactWithFluidHandler(heldItem, tileFluidHandler, playerIn)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ public class Config {
|
||||
try {
|
||||
InputStream hintStream = Config.class.getResourceAsStream("/config/forestry/hints.properties");
|
||||
prop.load(hintStream);
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | NullPointerException e) {
|
||||
Log.error("Failed to load hints file.", e);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.core.config;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.api.core.IForestryConstants;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class Constants implements IForestryConstants {
|
||||
// System
|
||||
@@ -25,7 +26,6 @@ public class Constants implements IForestryConstants {
|
||||
public static final int FLAG_BLOCK_UPDATE = 1;
|
||||
public static final int FLAG_BLOCK_SYNC = 2;
|
||||
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
public static final int FLUID_PER_HONEY_DROP = 100;
|
||||
|
||||
public static final int[] SLOTS_NONE = new int[0];
|
||||
@@ -63,7 +63,7 @@ public class Constants implements IForestryConstants {
|
||||
public static final int APIARY_BREEDING_TIME = 100;
|
||||
|
||||
// Energy
|
||||
public static final int ENGINE_TANK_CAPACITY = 10 * BUCKET_VOLUME;
|
||||
public static final int ENGINE_TANK_CAPACITY = 10 * Fluid.BUCKET_VOLUME;
|
||||
public static final int ENGINE_CYCLE_DURATION_WATER = 1000;
|
||||
public static final int ENGINE_CYCLE_DURATION_JUICE = 2500;
|
||||
public static final int ENGINE_CYCLE_DURATION_HONEY = 2500;
|
||||
@@ -101,7 +101,7 @@ public class Constants implements IForestryConstants {
|
||||
public static final int ENGINE_TIN_MAX_EU_BATTERY = 100;
|
||||
|
||||
// Factory
|
||||
public static final int PROCESSOR_TANK_CAPACITY = 10 * BUCKET_VOLUME;
|
||||
public static final int PROCESSOR_TANK_CAPACITY = 10 * Fluid.BUCKET_VOLUME;
|
||||
|
||||
public static final int MACHINE_MAX_ENERGY = 5000;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class Constants implements IForestryConstants {
|
||||
public static final float ICE_COOLING_MULTIPLIER = 6f; // multiple of water's cooling value
|
||||
|
||||
// Storage
|
||||
public static final int RAINTANK_TANK_CAPACITY = 30 * BUCKET_VOLUME;
|
||||
public static final int RAINTANK_TANK_CAPACITY = 30 * Fluid.BUCKET_VOLUME;
|
||||
public static final int RAINTANK_AMOUNT_PER_UPDATE = 10;
|
||||
public static final int RAINTANK_FILLING_TIME = 12;
|
||||
public static final int CARPENTER_CRATING_CYCLES = 5;
|
||||
|
||||
@@ -14,16 +14,12 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.templates.EmptyFluidHandler;
|
||||
|
||||
import forestry.core.fluids.tanks.FakeTank;
|
||||
|
||||
public class FakeTankManager implements ITankManager {
|
||||
public class FakeTankManager extends EmptyFluidHandler implements ITankManager {
|
||||
public static final FakeTankManager instance = new FakeTankManager();
|
||||
|
||||
private FakeTankManager() {
|
||||
@@ -47,41 +43,21 @@ public class FakeTankManager implements ITankManager {
|
||||
|
||||
@Override
|
||||
public IFluidTank getTank(int tankIndex) {
|
||||
return FakeTank.INSTANCE;
|
||||
return EmptyFluidHandler.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFillFluidType(FluidStack fluidStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrainFluidType(FluidStack fluidStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTankUpdate(int tankIndex, FluidStack contents) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return FakeTank.INSTANCE.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return FakeTank.INSTANCE.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return FakeTank.INSTANCE.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return FakeTank.INFO;
|
||||
}
|
||||
}
|
||||
@@ -10,101 +10,22 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.fluids;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
|
||||
import forestry.core.PluginFluids;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
/**
|
||||
* @author CovertJaguar <http://www.railcraft.info>
|
||||
*/
|
||||
public final class FluidHelper {
|
||||
|
||||
private FluidHelper() {
|
||||
}
|
||||
|
||||
public static boolean handleRightClick(IFluidHandler tank, EnumFacing side, EntityPlayer player, boolean fill, boolean drain) {
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
ItemStack current = player.inventory.getCurrentItem();
|
||||
if (current != null) {
|
||||
|
||||
FluidStack liquid = getFluidStackInContainer(current);
|
||||
|
||||
if (fill && liquid != null) {
|
||||
int canUseAmount = tank.fill(side, liquid, false);
|
||||
if (canUseAmount == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack drainedContainer = getDrainedContainer(current, canUseAmount);
|
||||
if (ItemStackUtil.isIdenticalItem(current, drainedContainer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int usedAmount = tank.fill(side, liquid, true);
|
||||
if (usedAmount > 0) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (current.stackSize > 1) {
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
if (drainedContainer != null && !player.inventory.addItemStackToInventory(drainedContainer)) {
|
||||
player.dropItem(drainedContainer, false);
|
||||
}
|
||||
} else {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, drainedContainer);
|
||||
}
|
||||
player.inventory.markDirty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} else if (drain) {
|
||||
|
||||
FluidStack available = tank.drain(side, Integer.MAX_VALUE, false);
|
||||
if (available != null) {
|
||||
ItemStack filled = getFilledContainer(available, current);
|
||||
|
||||
liquid = getFluidStackInContainer(filled);
|
||||
if (liquid != null) {
|
||||
|
||||
if (current.stackSize > 1) {
|
||||
if (!player.inventory.addItemStackToInventory(filled)) {
|
||||
return false;
|
||||
}
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, InventoryUtil.depleteItem(current));
|
||||
player.inventory.markDirty();
|
||||
} else {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, InventoryUtil.depleteItem(current));
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, filled);
|
||||
player.inventory.markDirty();
|
||||
}
|
||||
|
||||
tank.drain(side, liquid.amount, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean areFluidStacksEqual(FluidStack fluidStack1, FluidStack fluidStack2) {
|
||||
if (fluidStack1 == null) {
|
||||
return fluidStack2 == null;
|
||||
@@ -117,10 +38,6 @@ public final class FluidHelper {
|
||||
SUCCESS, INVALID_INPUT, NO_FLUID, NO_SPACE
|
||||
}
|
||||
|
||||
public static FillStatus fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
|
||||
return fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill, true);
|
||||
}
|
||||
|
||||
public static FillStatus fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean doFill) {
|
||||
if (fluidToFill == null) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
@@ -132,30 +49,33 @@ public final class FluidHelper {
|
||||
}
|
||||
ItemStack output = inv.getStackInSlot(outputSlot);
|
||||
|
||||
int containerCapacity = getFluidCapacity(fluidToFill, input);
|
||||
ItemStack filled = input.copy();
|
||||
filled.stackSize = 1;
|
||||
|
||||
IFluidHandler fluidFilledHandler = FluidUtil.getFluidHandler(filled);
|
||||
if (fluidFilledHandler == null) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
|
||||
int containerCapacity = fluidFilledHandler.fill(new FluidStack(fluidToFill, Integer.MAX_VALUE), false);
|
||||
if (containerCapacity <= 0) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
|
||||
int fillAmount = containerCapacity;
|
||||
if (input.getItem() instanceof IFluidContainerItem) {
|
||||
fillAmount = Math.min(Constants.BUCKET_VOLUME, containerCapacity);
|
||||
}
|
||||
|
||||
FluidStack canDrain = fluidHandler.drain(null, new FluidStack(fluidToFill, fillAmount), false);
|
||||
FluidStack canDrain = fluidHandler.drain(new FluidStack(fluidToFill, containerCapacity), false);
|
||||
if (canDrain == null || canDrain.amount == 0) {
|
||||
return FillStatus.NO_FLUID;
|
||||
}
|
||||
|
||||
ItemStack filled = getFilledContainer(canDrain, input);
|
||||
if (filled == null) {
|
||||
if (fluidFilledHandler.fill(canDrain, true) <= 0) {
|
||||
return FillStatus.NO_FLUID; // standard containers will not fill if there isn't enough fluid
|
||||
}
|
||||
|
||||
FluidStack fluidInContainer = getFluidStackInContainer(filled);
|
||||
FluidStack fluidInContainer = fluidFilledHandler.drain(Integer.MAX_VALUE, false);
|
||||
if (fluidInContainer == null) {
|
||||
return FillStatus.INVALID_INPUT;
|
||||
}
|
||||
|
||||
boolean moveToOutput = fluidInContainer.amount >= containerCapacity;
|
||||
if (moveToOutput) {
|
||||
if (output != null && (output.stackSize >= output.getMaxStackSize() || !InventoryUtil.isItemEqual(filled, output))) {
|
||||
@@ -168,7 +88,7 @@ public final class FluidHelper {
|
||||
}
|
||||
|
||||
if (doFill) {
|
||||
fluidHandler.drain(null, canDrain, true);
|
||||
fluidHandler.drain(canDrain, true);
|
||||
if (moveToOutput) {
|
||||
if (output == null) {
|
||||
inv.setInventorySlotContents(outputSlot, filled);
|
||||
@@ -184,101 +104,93 @@ public final class FluidHelper {
|
||||
return FillStatus.SUCCESS;
|
||||
}
|
||||
|
||||
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int slot) {
|
||||
return drainContainers(fluidHandler, inv, slot, slot);
|
||||
}
|
||||
|
||||
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) {
|
||||
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot) {
|
||||
ItemStack input = inv.getStackInSlot(inputSlot);
|
||||
ItemStack output = inv.getStackInSlot(outputSlot);
|
||||
|
||||
if (input == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FluidStack fluidInContainer = getFluidStackInContainer(input);
|
||||
if (fluidInContainer == null) {
|
||||
ItemStack drainedItemSimulated = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, false);
|
||||
if (drainedItemSimulated == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (input.getItem() instanceof IFluidContainerItem) {
|
||||
if (fluidInContainer.amount > Constants.BUCKET_VOLUME) {
|
||||
fluidInContainer.amount = Constants.BUCKET_VOLUME;
|
||||
}
|
||||
}
|
||||
|
||||
int used = fluidHandler.fill(null, fluidInContainer, false);
|
||||
|
||||
ItemStack drainedItem = getDrainedContainer(input, used);
|
||||
if (ItemStack.areItemStacksEqual(input, drainedItem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// consume forestry containers if there is only one slot
|
||||
if (outputSlot == inputSlot && drainedItem != null) {
|
||||
Item item = drainedItem.getItem();
|
||||
if (PluginFluids.items.canEmpty == item || PluginFluids.items.waxCapsuleEmpty == item || PluginFluids.items.refractoryEmpty == item) {
|
||||
drainedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasRoomForDrainedContainer(input, output, drainedItem, inputSlot, outputSlot)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fluidHandler.fill(null, fluidInContainer, true);
|
||||
|
||||
if (drainedItem != null) {
|
||||
if (outputSlot == inputSlot) {
|
||||
inv.setInventorySlotContents(outputSlot, drainedItem);
|
||||
if (input.stackSize == 1 || drainedItemSimulated.stackSize == 0) {
|
||||
ItemStack drainedItem = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, true);
|
||||
if (drainedItem != null) {
|
||||
if (drainedItem.stackSize > 0) {
|
||||
inv.setInventorySlotContents(inputSlot, drainedItem);
|
||||
} else {
|
||||
inv.decrStackSize(inputSlot, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (output == null) {
|
||||
inv.setInventorySlotContents(outputSlot, drainedItem);
|
||||
} else {
|
||||
output.stackSize++;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isFillableContainerWithRoom(ItemStack container) {
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
|
||||
if (fluidHandler == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties();
|
||||
for (IFluidTankProperties properties : tankProperties) {
|
||||
if (properties.canFill() && properties.getCapacity() > 0) {
|
||||
FluidStack contents = properties.getContents();
|
||||
if (contents == null) {
|
||||
return true;
|
||||
} else if (contents.amount < properties.getCapacity()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
inv.decrStackSize(inputSlot, 1);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isFillableEmptyContainer(ItemStack empty) {
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(empty);
|
||||
if (fluidHandler == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties();
|
||||
for (IFluidTankProperties properties : tankProperties) {
|
||||
if (!properties.canFill()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FluidStack contents = properties.getContents();
|
||||
if (contents != null && contents.amount > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean hasRoomForDrainedContainer(ItemStack input, ItemStack output, ItemStack drainedItem, int inputSlot, int outputSlot) {
|
||||
if (output == null || drainedItem == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (outputSlot == inputSlot) {
|
||||
return input.stackSize == 1;
|
||||
}
|
||||
|
||||
if (!ItemStackUtil.isIdenticalItem(output, drainedItem)) {
|
||||
public static boolean isDrainableFilledContainer(ItemStack container) {
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
|
||||
if (fluidHandler == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return output.stackSize + drainedItem.stackSize <= output.getMaxStackSize();
|
||||
}
|
||||
IFluidTankProperties[] tankProperties = fluidHandler.getTankProperties();
|
||||
for (IFluidTankProperties properties : tankProperties) {
|
||||
if (!properties.canDrain()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEmptyContainer(ItemStack empty) {
|
||||
Item item = empty.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
IFluidContainerItem containerItem = (IFluidContainerItem) item;
|
||||
FluidStack fluid = containerItem.getFluid(empty);
|
||||
return fluid == null || fluid.amount == 0;
|
||||
FluidStack contents = properties.getContents();
|
||||
if (contents == null || contents.amount < properties.getCapacity()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return FluidContainerRegistry.isEmptyContainer(empty);
|
||||
}
|
||||
|
||||
public static boolean isFillableContainer(ItemStack container) {
|
||||
FluidStack fluid = getFluidStackInContainer(container);
|
||||
if (fluid == null || fluid.amount == 0) {
|
||||
return isEmptyContainer(container);
|
||||
}
|
||||
|
||||
int capacity = getFluidCapacity(fluid.getFluid(), container);
|
||||
return fluid.amount < capacity;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ItemStack getDrainedContainer(ItemStack container, int drainAmount) {
|
||||
@@ -290,127 +202,38 @@ public final class FluidHelper {
|
||||
return container;
|
||||
}
|
||||
|
||||
Item item = container.getItem();
|
||||
if (item == null) {
|
||||
container = container.copy();
|
||||
container.stackSize = 1;
|
||||
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
|
||||
if (fluidHandler == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
ItemStack drained = container.copy();
|
||||
drained.stackSize = 1;
|
||||
IFluidContainerItem containerItem = (IFluidContainerItem) item;
|
||||
containerItem.drain(drained, drainAmount, true);
|
||||
return drained;
|
||||
} else {
|
||||
int capacity = FluidContainerRegistry.getContainerCapacity(container);
|
||||
if (capacity > 0) {
|
||||
if (drainAmount < capacity) {
|
||||
return container;
|
||||
}
|
||||
return FluidContainerRegistry.drainFluidContainer(container);
|
||||
}
|
||||
fluidHandler.drain(drainAmount, true);
|
||||
if (container.stackSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
public static ItemStack getFilledContainer(FluidStack liquid, ItemStack stack) {
|
||||
if (liquid == null || stack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
stack = stack.copy();
|
||||
stack.stackSize = 1;
|
||||
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack);
|
||||
if (fluidHandler == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (fluidHandler.fill(liquid, true) > 0) {
|
||||
return stack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getEmptyContainer(ItemStack container) {
|
||||
if (container == null) {
|
||||
return null;
|
||||
}
|
||||
FluidStack fluidStack = FluidHelper.getFluidStackInContainer(container);
|
||||
if (fluidStack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return FluidHelper.getDrainedContainer(container, fluidStack.amount);
|
||||
}
|
||||
|
||||
public static List<ItemStack> getAllFilledContainers(ItemStack empty) {
|
||||
List<ItemStack> filledContainers = new ArrayList<>();
|
||||
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
|
||||
ItemStack filledContainer = getFilledContainer(fluid, empty);
|
||||
if (filledContainer != null) {
|
||||
filledContainers.add(filledContainer);
|
||||
}
|
||||
}
|
||||
return filledContainers;
|
||||
}
|
||||
|
||||
public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FluidStack fluidToFill = new FluidStack(fluid, Integer.MAX_VALUE);
|
||||
|
||||
return getFilledContainer(fluidToFill, empty);
|
||||
}
|
||||
|
||||
public static ItemStack getFilledContainer(FluidStack liquid, ItemStack empty) {
|
||||
if (liquid == null || empty == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Item item = empty.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
ItemStack full = ItemStackUtil.createSplitStack(empty, 1);
|
||||
IFluidContainerItem containerItem = (IFluidContainerItem) item;
|
||||
containerItem.fill(full, liquid, true);
|
||||
return full;
|
||||
}
|
||||
|
||||
return FluidContainerRegistry.fillFluidContainer(liquid, empty);
|
||||
}
|
||||
|
||||
public static FluidStack getFluidStackInContainer(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
IFluidContainerItem containerItem = (IFluidContainerItem) item;
|
||||
return containerItem.getFluid(stack);
|
||||
}
|
||||
|
||||
return FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
}
|
||||
|
||||
public static Fluid getFluidInContainer(ItemStack stack) {
|
||||
FluidStack fluidStack = getFluidStackInContainer(stack);
|
||||
return fluidStack != null ? fluidStack.getFluid() : null;
|
||||
}
|
||||
|
||||
public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
IFluidContainerItem containerItem = (IFluidContainerItem) item;
|
||||
FluidStack contained = containerItem.getFluid(stack);
|
||||
return contained != null && contained.containsFluid(fluidStack);
|
||||
}
|
||||
|
||||
return FluidContainerRegistry.containsFluid(stack, fluidStack);
|
||||
}
|
||||
|
||||
public static boolean containsFluid(ItemStack stack, Fluid fluid) {
|
||||
return containsFluidStack(stack, new FluidStack(fluid, 1));
|
||||
}
|
||||
|
||||
public static int getFluidCapacity(Fluid fluid, ItemStack container) {
|
||||
if (container == null) {
|
||||
return 0;
|
||||
}
|
||||
Item item = container.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
IFluidContainerItem containerItem = (IFluidContainerItem) item;
|
||||
return containerItem.getCapacity(container);
|
||||
}
|
||||
|
||||
if (fluid == null) {
|
||||
return FluidContainerRegistry.getContainerCapacity(container);
|
||||
} else {
|
||||
return FluidContainerRegistry.getContainerCapacity(new FluidStack(fluid, Constants.BUCKET_VOLUME), container);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import javax.annotation.Nullable;
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -30,10 +29,11 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import forestry.core.items.DrinkProperties;
|
||||
import forestry.core.items.EnumContainerType;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.ForestryResource;
|
||||
|
||||
@@ -44,32 +44,12 @@ public enum Fluids {
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this, 300, true);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
},
|
||||
BIOMASS(new Color(100, 132, 41), 400, 6560) {
|
||||
@Override
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this, 100, true);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
},
|
||||
GLASS(new Color(164, 164, 164), 2400, 10000) {
|
||||
@Override
|
||||
@@ -88,16 +68,6 @@ public enum Fluids {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DrinkProperties getDrinkProperties() {
|
||||
return new DrinkProperties(2, 0.2f, 64);
|
||||
@@ -113,16 +83,6 @@ public enum Fluids {
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
},
|
||||
JUICE(new Color(168, 201, 114)) {
|
||||
@Override
|
||||
@@ -130,16 +90,6 @@ public enum Fluids {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DrinkProperties getDrinkProperties() {
|
||||
return new DrinkProperties(2, 0.2f, 32);
|
||||
@@ -164,16 +114,6 @@ public enum Fluids {
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this, 2, true);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
},
|
||||
SHORT_MEAD(new Color(239, 154, 56), 1000, 1200) {
|
||||
@Override
|
||||
@@ -182,50 +122,11 @@ public enum Fluids {
|
||||
}
|
||||
},
|
||||
// Vanilla
|
||||
WATER(new Color(0x2432ec)) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
},
|
||||
LAVA(new Color(0xfd461f)) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
},
|
||||
WATER(new Color(0x2432ec)),
|
||||
LAVA(new Color(0xfd461f)),
|
||||
// BuildCraft
|
||||
FUEL(new Color(0xffff00)) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
},
|
||||
OIL(new Color(0x404040)) {
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.of(
|
||||
EnumContainerType.CAN,
|
||||
EnumContainerType.CAPSULE,
|
||||
EnumContainerType.REFRACTORY
|
||||
);
|
||||
}
|
||||
},
|
||||
FUEL(new Color(0xffff00)),
|
||||
OIL(new Color(0x404040)),
|
||||
// Railcraft
|
||||
CREOSOTE(new Color(0x635c03)),
|
||||
STEAM(new Color(0x91938F));
|
||||
@@ -309,7 +210,8 @@ public enum Fluids {
|
||||
}
|
||||
|
||||
public final boolean isContained(ItemStack containerStack) {
|
||||
return containerStack != null && FluidHelper.containsFluid(containerStack, getFluid());
|
||||
FluidStack fluidStackInContainer = FluidUtil.getFluidContained(containerStack);
|
||||
return fluidStackInContainer != null && fluidStackInContainer.getFluid() == getFluid();
|
||||
}
|
||||
|
||||
public static boolean areEqual(Fluid fluid, FluidStack fluidStack) {
|
||||
@@ -344,10 +246,19 @@ public enum Fluids {
|
||||
return Fluids.WATER.getColor();
|
||||
}
|
||||
|
||||
/** FluidBlock and Container registration */
|
||||
@Nonnull
|
||||
public EnumSet<EnumContainerType> getContainerTypes() {
|
||||
return EnumSet.noneOf(EnumContainerType.class);
|
||||
@Nullable
|
||||
public static Fluids getFluidDefinition(FluidStack fluidStack) {
|
||||
if (fluidStack != null) {
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid != null) {
|
||||
Fluids fluidDefinition = tagToFluid.get(fluid.getName());
|
||||
if (fluidDefinition != null) {
|
||||
return fluidDefinition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,7 +278,7 @@ public enum Fluids {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the properties for an ItemLiquidContainer before it gets registered.
|
||||
* Get the properties for an ItemFluidContainerForestry before it gets registered.
|
||||
*/
|
||||
@Nullable
|
||||
public DrinkProperties getDrinkProperties() {
|
||||
|
||||
@@ -16,8 +16,8 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
public interface ITankManager extends IFluidHandler {
|
||||
void containerAdded(Container container, IContainerListener crafter);
|
||||
@@ -28,6 +28,10 @@ public interface ITankManager extends IFluidHandler {
|
||||
|
||||
IFluidTank getTank(int tankIndex);
|
||||
|
||||
boolean canFillFluidType(FluidStack fluidStack);
|
||||
|
||||
boolean canDrainFluidType(FluidStack fluidStack);
|
||||
|
||||
/**
|
||||
* For updating tanks on the client
|
||||
*/
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.fluids;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import forestry.core.PluginFluids;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.items.EnumContainerType;
|
||||
import forestry.core.items.ItemLiquidContainer;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class LiquidRegistryHelper {
|
||||
|
||||
private static final EnumMap<EnumContainerType, ItemLiquidContainer> emptyContainers = new EnumMap<>(EnumContainerType.class);
|
||||
|
||||
static {
|
||||
emptyContainers.put(EnumContainerType.CAN, PluginFluids.items.canEmpty);
|
||||
emptyContainers.put(EnumContainerType.CAPSULE, PluginFluids.items.waxCapsuleEmpty);
|
||||
emptyContainers.put(EnumContainerType.REFRACTORY, PluginFluids.items.refractoryEmpty);
|
||||
}
|
||||
|
||||
public static void registerLiquidContainer(Fluids fluid, ItemStack filled) {
|
||||
Item item = filled.getItem();
|
||||
ItemStack empty = null;
|
||||
|
||||
if (item.getContainerItem() instanceof ItemBucket) {
|
||||
empty = new ItemStack(Items.BUCKET);
|
||||
} else if (item instanceof ItemLiquidContainer) {
|
||||
ItemLiquidContainer liquidContainer = (ItemLiquidContainer) item;
|
||||
EnumContainerType containerType = liquidContainer.getType();
|
||||
ItemLiquidContainer emptyContainer = emptyContainers.get(containerType);
|
||||
empty = emptyContainer.getItemStack();
|
||||
}
|
||||
|
||||
if (empty == null) {
|
||||
Log.warning("Unable to inject liquid container: " + filled);
|
||||
} else {
|
||||
registerLiquidContainer(fluid, Constants.BUCKET_VOLUME, filled, empty);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerLiquidContainer(Fluids fluid, int volume, ItemStack filled, ItemStack empty) {
|
||||
FluidStack contained = fluid.getFluid(volume);
|
||||
if (contained == null) {
|
||||
throw new IllegalArgumentException(String.format("Attempted to inject a liquid container for the non-existent liquid '%s'.", fluid));
|
||||
}
|
||||
|
||||
FluidContainerData container = new FluidContainerData(contained, filled, empty);
|
||||
FluidContainerRegistry.registerFluidContainer(container);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Table;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -26,16 +27,16 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.FluidTankPropertiesWrapper;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
import net.minecraftforge.fluids.capability.templates.EmptyFluidHandler;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import forestry.core.fluids.tanks.FakeTank;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
@@ -206,14 +207,14 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
for (StandardTank tank : tanks) {
|
||||
if (tankAcceptsFluid(tank, resource)) {
|
||||
return fill(tank.getTankIndex(), resource, doFill);
|
||||
}
|
||||
}
|
||||
|
||||
return FakeTank.INSTANCE.fill(resource, doFill);
|
||||
return EmptyFluidHandler.INSTANCE.fill(resource, doFill);
|
||||
}
|
||||
|
||||
public int fill(int tankIndex, FluidStack resource, boolean doFill) {
|
||||
@@ -222,7 +223,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
}
|
||||
|
||||
StandardTank tank = tanks.get(tankIndex);
|
||||
if (!tank.canBeFilledExternally()) {
|
||||
if (!tank.canFill()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -250,14 +251,15 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
public FluidStack drain(int maxDrain, boolean doDrain) {
|
||||
for (StandardTank tank : tanks) {
|
||||
if (tankCanDrain(tank)) {
|
||||
return drain(tank.getTankIndex(), maxDrain, doDrain);
|
||||
}
|
||||
}
|
||||
return FakeTank.INSTANCE.drain(maxDrain, doDrain);
|
||||
return EmptyFluidHandler.INSTANCE.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
public FluidStack drain(int tankIndex, int maxDrain, boolean doDrain) {
|
||||
@@ -266,7 +268,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
}
|
||||
|
||||
StandardTank tank = tanks.get(tankIndex);
|
||||
if (!tank.canBeDrainedExternally()) {
|
||||
if (!tank.canDrain()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -283,31 +285,12 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return drain(resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing direction) {
|
||||
FluidTankInfo[] info = new FluidTankInfo[tanks.size()];
|
||||
public IFluidTankProperties[] getTankProperties() {
|
||||
IFluidTankProperties[] properties = new IFluidTankProperties[tanks.size()];
|
||||
for (int i = 0; i < tanks.size(); i++) {
|
||||
info[i] = tanks.get(i).getInfo();
|
||||
properties[i] = new FluidTankPropertiesWrapper(tanks.get(i));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public FluidTankInfo[] getTankInfo() {
|
||||
return getTankInfo(null);
|
||||
return properties;
|
||||
}
|
||||
|
||||
public FluidTankInfo getTankInfo(int tankIndex) {
|
||||
@@ -322,13 +305,29 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
return tanks.get(tankIndex).getFluidAmount();
|
||||
}
|
||||
|
||||
public boolean accepts(Fluid fluid) {
|
||||
if (fluid == null) {
|
||||
@Override
|
||||
public boolean canFillFluidType(FluidStack fluidStack) {
|
||||
if (fluidStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (StandardTank tank : tanks) {
|
||||
if (tank.accepts(fluid)) {
|
||||
if (tank.canFillFluidType(fluidStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrainFluidType(FluidStack fluidStack) {
|
||||
if (fluidStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (StandardTank tank : tanks) {
|
||||
if (tank.canDrainFluidType(fluidStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -340,14 +339,14 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl
|
||||
if (fluidStack == null) {
|
||||
return false;
|
||||
}
|
||||
if (!tank.canBeFilledExternally()) {
|
||||
if (!tank.canFill()) {
|
||||
return false;
|
||||
}
|
||||
return tank.fill(fluidStack, false) > 0;
|
||||
}
|
||||
|
||||
private static boolean tankCanDrain(StandardTank tank) {
|
||||
if (!tank.canBeDrainedExternally()) {
|
||||
if (!tank.canDrain()) {
|
||||
return false;
|
||||
}
|
||||
FluidStack drained = tank.drain(1, false);
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.fluids.tanks;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
/**
|
||||
* @author CovertJaguar <http://www.railcraft.info>
|
||||
*/
|
||||
public final class FakeTank extends StandardTank {
|
||||
|
||||
public static final FakeTank INSTANCE = new FakeTank();
|
||||
public static final FakeTank[] ARRAY = new FakeTank[]{INSTANCE};
|
||||
public static final FluidTankInfo[] INFO = new FluidTankInfo[]{INSTANCE.getInfo()};
|
||||
|
||||
private FakeTank() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, boolean doDrain) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -33,41 +32,38 @@ public class FilteredTank extends StandardTank {
|
||||
|
||||
private final Set<String> filters = new HashSet<>(); // FluidNames
|
||||
|
||||
public FilteredTank(int capacity, Fluid... filters) {
|
||||
this(capacity, Arrays.asList(filters), null);
|
||||
public FilteredTank(int capacity) {
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
public FilteredTank(int capacity, Collection<Fluid> filters) {
|
||||
this(capacity, filters, null);
|
||||
public FilteredTank(int capacity, boolean canFill, boolean canDrain) {
|
||||
super(capacity, canFill, canDrain);
|
||||
}
|
||||
|
||||
public FilteredTank(int capacity, Collection<Fluid> filters, TileEntity tile) {
|
||||
super(capacity, tile);
|
||||
setFilters(filters);
|
||||
public FilteredTank setFilters(Fluid... filters) {
|
||||
return setFilters(Arrays.asList(filters));
|
||||
}
|
||||
|
||||
public void setFilters(Collection<Fluid> filters) {
|
||||
public FilteredTank setFilters(Collection<Fluid> filters) {
|
||||
this.filters.clear();
|
||||
for (Fluid fluid : filters) {
|
||||
this.filters.add(fluid.getName());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if (liquidMatchesFilter(resource)) {
|
||||
return super.fill(resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
public boolean canFillFluidType(FluidStack fluid) {
|
||||
return fluidMatchesFilter(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accepts(Fluid fluid) {
|
||||
return filters.contains(fluid.getName());
|
||||
public boolean canDrainFluidType(FluidStack fluid) {
|
||||
return fluidMatchesFilter(fluid);
|
||||
}
|
||||
|
||||
private boolean liquidMatchesFilter(FluidStack resource) {
|
||||
if (resource == null || filters == null) {
|
||||
private boolean fluidMatchesFilter(FluidStack resource) {
|
||||
if (resource == null || resource.getFluid() == null) {
|
||||
return false;
|
||||
}
|
||||
return filters.contains(resource.getFluid().getName());
|
||||
|
||||
@@ -14,14 +14,12 @@ import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
import forestry.core.fluids.FakeTankUpdateHandler;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.ITankUpdateHandler;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
@@ -34,37 +32,21 @@ import forestry.core.utils.Translator;
|
||||
* @author CovertJaguar <http://www.railcraft.info>
|
||||
*/
|
||||
public class StandardTank extends FluidTank implements IStreamable {
|
||||
// defines how the tank responds to IFluidHandler requests
|
||||
public enum TankMode {
|
||||
DEFAULT, OUTPUT, INPUT, INTERNAL
|
||||
}
|
||||
|
||||
public TankMode tankMode = TankMode.DEFAULT;
|
||||
private static final int DEFAULT_COLOR = 0xFFFFFF;
|
||||
@Nonnull
|
||||
private ITankUpdateHandler tankUpdateHandler = FakeTankUpdateHandler.instance;
|
||||
private int tankIndex;
|
||||
|
||||
public StandardTank(int capacity, boolean canFill, boolean canDrain) {
|
||||
super(capacity);
|
||||
setCanFill(canFill);
|
||||
setCanDrain(canDrain);
|
||||
}
|
||||
|
||||
public StandardTank(int capacity) {
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
public StandardTank(FluidStack fluid, int capacity) {
|
||||
this(capacity);
|
||||
setFluid(fluid);
|
||||
}
|
||||
|
||||
public StandardTank(int capacity, TileEntity tile) {
|
||||
this(capacity);
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public StandardTank(FluidStack fluid, int capacity, TileEntity tile) {
|
||||
this(capacity);
|
||||
this.tile = tile;
|
||||
setFluid(fluid);
|
||||
}
|
||||
|
||||
public void setTankIndex(int index) {
|
||||
this.tankIndex = index;
|
||||
}
|
||||
@@ -102,75 +84,17 @@ public class StandardTank extends FluidTank implements IStreamable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(final FluidStack resource, final boolean doFill) {
|
||||
if (resource == null) {
|
||||
return 0;
|
||||
}
|
||||
if (resource.amount <= 0) {
|
||||
return 0;
|
||||
}
|
||||
if (!accepts(resource.getFluid())) {
|
||||
return 0;
|
||||
}
|
||||
int filled = super.fill(resource, doFill);
|
||||
public int fillInternal(FluidStack resource, boolean doFill) {
|
||||
int filled = super.fillInternal(resource, doFill);
|
||||
if (doFill && filled > 0) {
|
||||
tankUpdateHandler.updateTankLevels(this);
|
||||
}
|
||||
return filled;
|
||||
}
|
||||
|
||||
public boolean accepts(Fluid fluid) {
|
||||
return fluid != null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public boolean canBeFilledExternally() {
|
||||
switch (tankMode) {
|
||||
case DEFAULT:
|
||||
case INPUT:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public boolean canBeDrainedExternally() {
|
||||
switch (tankMode) {
|
||||
case DEFAULT:
|
||||
case OUTPUT:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canFill(Fluid fluid, int amount) {
|
||||
if (fluid == null) {
|
||||
return false;
|
||||
}
|
||||
FluidStack fluidStack = new FluidStack(fluid, amount);
|
||||
return canFill(fluidStack);
|
||||
}
|
||||
|
||||
public boolean canFill(FluidStack fluidStack) {
|
||||
return fill(fluidStack, false) == fluidStack.amount;
|
||||
}
|
||||
|
||||
public boolean canDrain(int amount) {
|
||||
FluidStack drained = drain(amount, false);
|
||||
return drained != null && drained.amount == amount;
|
||||
}
|
||||
|
||||
public boolean canDrain(FluidStack toDrain) {
|
||||
FluidStack drained = drain(toDrain.amount, false);
|
||||
return FluidHelper.areFluidStacksEqual(drained, toDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, boolean doDrain) {
|
||||
if (maxDrain <= 0) {
|
||||
return null;
|
||||
}
|
||||
FluidStack drained = super.drain(maxDrain, doDrain);
|
||||
public FluidStack drainInternal(int maxDrain, boolean doDrain) {
|
||||
FluidStack drained = super.drainInternal(maxDrain, doDrain);
|
||||
if (doDrain && drained != null && drained.amount > 0) {
|
||||
tankUpdateHandler.updateTankLevels(this);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.api.core.IToolPipette;
|
||||
@@ -60,17 +61,21 @@ public class ContainerLiquidTanksHelper<T extends TileEntity & ILiquidTankTile>
|
||||
|
||||
if (pipette.canPipette(itemstack) && liquidAmount > 0) {
|
||||
if (liquidAmount > 0) {
|
||||
FluidStack fillAmount = tank.drain(1000, false);
|
||||
int filled = pipette.fill(itemstack, fillAmount, true);
|
||||
tank.drain(filled, true);
|
||||
player.updateHeldItem();
|
||||
if (tank instanceof FluidTank) {
|
||||
FluidStack fillAmount = ((FluidTank) tank).drainInternal(1000, false);
|
||||
int filled = pipette.fill(itemstack, fillAmount, true);
|
||||
tank.drain(filled, true);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false);
|
||||
if (potential != null) {
|
||||
int fill = tank.fill(potential, true);
|
||||
pipette.drain(itemstack, fill, true);
|
||||
player.updateHeldItem();
|
||||
if (tank instanceof FluidTank) {
|
||||
int fill = ((FluidTank) tank).fillInternal(potential, true);
|
||||
pipette.drain(itemstack, fill, true);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,12 @@ package forestry.core.inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.tiles.TileAnalyzer;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
@@ -41,8 +41,8 @@ public class InventoryAnalyzer extends InventoryAdapterTile<TileAnalyzer> {
|
||||
if (SlotUtil.isSlotInRange(slotIndex, SLOT_INPUT_1, SLOT_INPUT_COUNT)) {
|
||||
return AlleleManager.alleleRegistry.isIndividual(itemStack) || GeneticsUtil.getGeneticEquivalent(itemStack) != null;
|
||||
} else if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStackSimple;
|
||||
|
||||
public class FluidHandlerItemForestry extends FluidHandlerItemStackSimple.Consumable {
|
||||
private final EnumContainerType containerType;
|
||||
|
||||
public FluidHandlerItemForestry(ItemStack container, EnumContainerType containerType) {
|
||||
super(container, Fluid.BUCKET_VOLUME);
|
||||
this.containerType = containerType;
|
||||
}
|
||||
|
||||
private boolean contentsAllowed(FluidStack fluidStack) {
|
||||
if (fluidStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (containerType) {
|
||||
case CAPSULE:
|
||||
return fluid.getTemperature(fluidStack) < 310.15; // melting point of wax in kelvin
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFillFluidType(FluidStack fluid) {
|
||||
return contentsAllowed(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrainFluidType(FluidStack fluid) {
|
||||
return contentsAllowed(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setFluid(FluidStack fluid) {
|
||||
super.setFluid(fluid);
|
||||
container.setItemDamage(1); // show the filled container model
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,18 +58,20 @@ public class ItemBlockForestry<B extends Block> extends ItemBlock {
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
|
||||
|
||||
if (block.hasTileEntity(newState)) {
|
||||
if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) {
|
||||
TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class);
|
||||
if (tile != null) {
|
||||
tile.readFromNBT(stack.getTagCompound());
|
||||
tile.setPos(pos);
|
||||
if (placed) {
|
||||
if (block.hasTileEntity(newState)) {
|
||||
if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) {
|
||||
TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class);
|
||||
if (tile != null) {
|
||||
tile.readFromNBT(stack.getTagCompound());
|
||||
tile.setPos(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (block instanceof BlockBase) {
|
||||
((BlockBase) block).rotateAfterPlacement(player, world, pos, side);
|
||||
if (block instanceof BlockBase) {
|
||||
((BlockBase) block).rotateAfterPlacement(player, world, pos, side);
|
||||
}
|
||||
}
|
||||
|
||||
return placed;
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import forestry.core.fluids.Fluids;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.FoodStats;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.CreativeTabForestry;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class ItemFluidContainerForestry extends ItemForestry implements IColoredItem {
|
||||
private final EnumContainerType type;
|
||||
|
||||
public ItemFluidContainerForestry(EnumContainerType type) {
|
||||
super(CreativeTabForestry.tabForestry);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/* Models */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, 0, "liquids/" + type.toString().toLowerCase(Locale.ENGLISH) + "_empty");
|
||||
manager.registerItemModel(item, 1, "liquids/" + type.toString().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
|
||||
// empty
|
||||
subItems.add(new ItemStack(itemIn));
|
||||
|
||||
// filled
|
||||
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
|
||||
ItemStack itemStack = new ItemStack(itemIn);
|
||||
IFluidHandler fluidHandler = new FluidHandlerItemForestry(itemStack, type);
|
||||
if (fluidHandler.fill(new FluidStack(fluid, Fluid.BUCKET_VOLUME), true) == Fluid.BUCKET_VOLUME) {
|
||||
subItems.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack itemStack, int tintIndex) {
|
||||
if (tintIndex > 0) {
|
||||
FluidStack fluidStack = getContained(itemStack);
|
||||
return Fluids.getFluidColor(fluidStack).getRGB();
|
||||
} else {
|
||||
return 0xffffff;
|
||||
}
|
||||
}
|
||||
|
||||
public EnumContainerType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
protected FluidStack getContained(ItemStack itemStack) {
|
||||
if (itemStack.stackSize != 1) {
|
||||
itemStack = itemStack.copy();
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
IFluidHandler fluidHandler = new FluidHandlerItemForestry(itemStack, type);
|
||||
return fluidHandler.drain(Integer.MAX_VALUE, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemFluidContainerForestry) {
|
||||
FluidStack fluid = getContained(stack);
|
||||
if (fluid != null) {
|
||||
String exactTranslationKey = "item.for." + type.getName() + '.' + fluid.getFluid().getName() + ".name";
|
||||
if (Translator.canTranslateToLocal(exactTranslationKey)) {
|
||||
return Translator.translateToLocal(exactTranslationKey);
|
||||
} else {
|
||||
String grammarKey = "item.for." + type.getName() + ".grammar";
|
||||
return Translator.translateToLocalFormatted(grammarKey, fluid.getLocalizedName());
|
||||
}
|
||||
} else {
|
||||
String unlocalizedname = "item.for." + type.getName() + ".empty.name";
|
||||
return Translator.translateToLocal(unlocalizedname);
|
||||
}
|
||||
}
|
||||
return super.getItemStackDisplayName(stack);
|
||||
}
|
||||
|
||||
/** DRINKS */
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
||||
DrinkProperties drinkProperties = getDrinkProperties(stack);
|
||||
if (drinkProperties != null) {
|
||||
if (entityLiving instanceof EntityPlayer && !((EntityPlayer) entityLiving).capabilities.isCreativeMode) {
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
--stack.stackSize;
|
||||
}
|
||||
|
||||
if (!worldIn.isRemote) {
|
||||
FoodStats foodStats = player.getFoodStats();
|
||||
foodStats.addStats(drinkProperties.getHealAmount(), drinkProperties.getSaturationModifier());
|
||||
worldIn.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
player.addStat(StatList.getObjectUseStats(this));
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
protected DrinkProperties getDrinkProperties(ItemStack itemStack) {
|
||||
FluidStack contained = getContained(itemStack);
|
||||
if (contained != null) {
|
||||
Fluids definition = Fluids.getFluidDefinition(contained);
|
||||
if (definition != null) {
|
||||
return definition.getDrinkProperties();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack itemstack) {
|
||||
DrinkProperties drinkProperties = getDrinkProperties(itemstack);
|
||||
if (drinkProperties != null) {
|
||||
return drinkProperties.getMaxItemUseDuration();
|
||||
} else {
|
||||
return super.getMaxItemUseDuration(itemstack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack itemstack) {
|
||||
DrinkProperties drinkProperties = getDrinkProperties(itemstack);
|
||||
if (drinkProperties != null) {
|
||||
return EnumAction.DRINK;
|
||||
} else {
|
||||
return EnumAction.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
DrinkProperties drinkProperties = getDrinkProperties(itemStackIn);
|
||||
if (drinkProperties != null) {
|
||||
if (playerIn.canEat(false)) {
|
||||
playerIn.setActiveHand(hand);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
|
||||
} else {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
|
||||
}
|
||||
} else {
|
||||
return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
|
||||
{
|
||||
return new FluidHandlerItemForestry(stack, type);
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.CreativeTabForestry;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class ItemLiquidContainer extends ItemForestry implements IColoredItem {
|
||||
private final EnumContainerType type;
|
||||
private final int color;
|
||||
|
||||
public ItemLiquidContainer(EnumContainerType type, int color) {
|
||||
super(CreativeTabForestry.tabForestry);
|
||||
this.type = type;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
private static int getMatchingSlot(EntityPlayer player, ItemStack stack) {
|
||||
|
||||
for (int slot = 0; slot < player.inventory.mainInventory.length; slot++) {
|
||||
ItemStack slotStack = player.inventory.getStackInSlot(slot);
|
||||
|
||||
if (slotStack == null) {
|
||||
return slot;
|
||||
}
|
||||
|
||||
if (!slotStack.isItemEqual(stack)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int space = slotStack.getMaxStackSize() - slotStack.stackSize;
|
||||
if (space >= stack.stackSize) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
if (worldIn.isRemote) {
|
||||
return ActionResult.newResult(EnumActionResult.PASS, itemStackIn);
|
||||
}
|
||||
|
||||
RayTraceResult rayTraceResult = this.rayTrace(worldIn, playerIn, true);
|
||||
if (rayTraceResult == null || rayTraceResult.typeOfHit != RayTraceResult.Type.BLOCK) {
|
||||
return ActionResult.newResult(EnumActionResult.PASS, itemStackIn);
|
||||
}
|
||||
|
||||
BlockPos pos = rayTraceResult.getBlockPos();
|
||||
Block targetedBlock = worldIn.getBlockState(pos).getBlock();
|
||||
|
||||
FluidStack fluid = null;
|
||||
|
||||
if (targetedBlock instanceof IFluidBlock) {
|
||||
fluid = ((IFluidBlock) targetedBlock).drain(worldIn, pos, false);
|
||||
} else {
|
||||
if (targetedBlock == Blocks.WATER || targetedBlock == Blocks.FLOWING_WATER) {
|
||||
fluid = new FluidStack(FluidRegistry.WATER, 1000);
|
||||
} else if (targetedBlock == Blocks.LAVA || targetedBlock == Blocks.FLOWING_LAVA) {
|
||||
fluid = new FluidStack(FluidRegistry.LAVA, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
if (fluid == null) {
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, itemStackIn);
|
||||
}
|
||||
|
||||
ItemStack filledContainer = FluidHelper.getFilledContainer(fluid.getFluid(), itemStackIn);
|
||||
if (filledContainer == null) {
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, itemStackIn);
|
||||
}
|
||||
|
||||
// Search for a slot to stow a filled container in player's
|
||||
// inventory
|
||||
int slot = getMatchingSlot(playerIn, filledContainer);
|
||||
if (slot < 0) {
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, itemStackIn);
|
||||
}
|
||||
|
||||
if (playerIn.inventory.getStackInSlot(slot) == null) {
|
||||
playerIn.inventory.setInventorySlotContents(slot, filledContainer.copy());
|
||||
} else {
|
||||
playerIn.inventory.getStackInSlot(slot).stackSize++;
|
||||
}
|
||||
|
||||
// Remove consumed liquid block in world
|
||||
if (targetedBlock instanceof IFluidBlock) {
|
||||
((IFluidBlock) targetedBlock).drain(worldIn, pos, true);
|
||||
} else {
|
||||
worldIn.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
// Remove consumed empty container
|
||||
itemStackIn.stackSize--;
|
||||
|
||||
// Notify player that his inventory has changed.
|
||||
Proxies.net.inventoryChangeNotify(playerIn);
|
||||
|
||||
return ActionResult.newResult(EnumActionResult.SUCCESS, itemStackIn);
|
||||
}
|
||||
|
||||
/* Models */
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
if(color == 0){
|
||||
manager.registerItemModel(item, 0, "liquids/" + type.toString().toLowerCase(Locale.ENGLISH)+ "_empty");
|
||||
}else{
|
||||
manager.registerItemModel(item, 0, "liquids/" + type.toString().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack itemstack, int j) {
|
||||
if (j > 0) {
|
||||
return color;
|
||||
} else {
|
||||
return 0xffffff;
|
||||
}
|
||||
}
|
||||
|
||||
public EnumContainerType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemLiquidContainer) {
|
||||
FluidStack fluid = FluidHelper.getFluidStackInContainer(stack);
|
||||
if (fluid != null) {
|
||||
String exactTranslationKey = "item.for." + type.getName() + '.' + fluid.getFluid().getName() + ".name";
|
||||
if (Translator.canTranslateToLocal(exactTranslationKey)) {
|
||||
return Translator.translateToLocal(exactTranslationKey);
|
||||
} else {
|
||||
String grammarKey = "item.for." + type.getName() + ".grammar";
|
||||
return Translator.translateToLocalFormatted(grammarKey, fluid.getLocalizedName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getItemStackDisplayName(stack);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.FoodStats;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemLiquidContainerDrinkable extends ItemLiquidContainer {
|
||||
private final DrinkProperties properties;
|
||||
|
||||
public ItemLiquidContainerDrinkable(EnumContainerType type, int color, DrinkProperties properties) {
|
||||
super(type, color);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
||||
if (entityLiving instanceof EntityPlayer && !((EntityPlayer)entityLiving).capabilities.isCreativeMode) {
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
--stack.stackSize;
|
||||
}
|
||||
|
||||
if (!worldIn.isRemote) {
|
||||
FoodStats foodStats = player.getFoodStats();
|
||||
foodStats.addStats(properties.getHealAmount(), properties.getSaturationModifier());
|
||||
worldIn.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
player.addStat(StatList.getObjectUseStats(this));
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack itemstack) {
|
||||
return properties.getMaxItemUseDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack itemstack) {
|
||||
return EnumAction.DRINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
if (playerIn.canEat(false)) {
|
||||
playerIn.setActiveHand(hand);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
|
||||
} else {
|
||||
return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -27,7 +28,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IToolPipette;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.PipetteContents;
|
||||
|
||||
public class ItemPipette extends ItemForestry implements IToolPipette, IFluidContainerItem {
|
||||
@@ -163,6 +163,6 @@ public class ItemPipette extends ItemForestry implements IToolPipette, IFluidCon
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack pipette) {
|
||||
return Constants.BUCKET_VOLUME;
|
||||
return Fluid.BUCKET_VOLUME;
|
||||
}
|
||||
}
|
||||
@@ -10,51 +10,36 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Table;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.core.fluids.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
public class ItemRegistryFluids extends ItemRegistry {
|
||||
public final ItemLiquidContainer canEmpty;
|
||||
public final ItemLiquidContainer waxCapsuleEmpty;
|
||||
public final ItemLiquidContainer refractoryEmpty;
|
||||
public final ItemFluidContainerForestry canEmpty;
|
||||
public final ItemFluidContainerForestry waxCapsuleEmpty;
|
||||
public final ItemFluidContainerForestry refractoryEmpty;
|
||||
|
||||
private final Table<EnumContainerType, String, ItemLiquidContainer> containers = HashBasedTable.create();
|
||||
private final Map<EnumContainerType, ItemFluidContainerForestry> containers = new EnumMap<>(EnumContainerType.class);
|
||||
|
||||
public ItemLiquidContainer getContainer(EnumContainerType type, Fluids fluid) {
|
||||
return containers.get(type, fluid.getFluid().getName());
|
||||
public ItemStack getContainer(EnumContainerType type, Fluids fluid) {
|
||||
ItemStack container = new ItemStack(containers.get(type));
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
|
||||
fluidHandler.fill(fluid.getFluid(Integer.MAX_VALUE), true);
|
||||
return container;
|
||||
}
|
||||
|
||||
public ItemRegistryFluids() {
|
||||
canEmpty = registerEmptyContainer(EnumContainerType.CAN, "can.empty");
|
||||
waxCapsuleEmpty = registerEmptyContainer(EnumContainerType.CAPSULE, "capsule.empty");
|
||||
refractoryEmpty = registerEmptyContainer(EnumContainerType.REFRACTORY, "refractory.empty");
|
||||
canEmpty = registerItem(new ItemFluidContainerForestry(EnumContainerType.CAN), "can");
|
||||
waxCapsuleEmpty = registerItem(new ItemFluidContainerForestry(EnumContainerType.CAPSULE), "capsule");
|
||||
refractoryEmpty = registerItem(new ItemFluidContainerForestry(EnumContainerType.REFRACTORY), "refractory");
|
||||
|
||||
for (Fluids fluidType : Fluids.values()) {
|
||||
if (fluidType.getFluid() == null) {
|
||||
continue;
|
||||
}
|
||||
for (EnumContainerType type : fluidType.getContainerTypes()) {
|
||||
int color = fluidType.getColor().getRGB();
|
||||
|
||||
DrinkProperties drinkProperties = fluidType.getDrinkProperties();
|
||||
ItemLiquidContainer liquidContainer;
|
||||
if (drinkProperties == null) {
|
||||
liquidContainer = new ItemLiquidContainer(type, color);
|
||||
} else {
|
||||
liquidContainer = new ItemLiquidContainerDrinkable(type, color, drinkProperties);
|
||||
}
|
||||
|
||||
String name = type.getName() + '.' + fluidType.getTag();
|
||||
registerItem(liquidContainer, name);
|
||||
|
||||
containers.put(type, fluidType.getFluid().getName(), liquidContainer);
|
||||
}
|
||||
}
|
||||
containers.put(EnumContainerType.CAN, canEmpty);
|
||||
containers.put(EnumContainerType.CAPSULE, waxCapsuleEmpty);
|
||||
containers.put(EnumContainerType.REFRACTORY, refractoryEmpty);
|
||||
}
|
||||
|
||||
private static ItemLiquidContainer registerEmptyContainer(EnumContainerType type, String name) {
|
||||
return registerItem(new ItemLiquidContainer(type, 0), name);
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
@@ -47,7 +46,7 @@ import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler, IItemStackDisplay {
|
||||
public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankTile, IItemStackDisplay {
|
||||
private static final int TIME_TO_ANALYZE = 125;
|
||||
private static final int HONEY_REQUIRED = 100;
|
||||
private static final int ENERGY_PER_WORK_CYCLE = 20320;
|
||||
@@ -64,7 +63,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
public TileAnalyzer() {
|
||||
super("analyzer", 800, Constants.MACHINE_MAX_ENERGY);
|
||||
setInternalInventory(new InventoryAnalyzer(this));
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, Fluids.FOR_HONEY.getFluid());
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(Fluids.FOR_HONEY.getFluid());
|
||||
tankManager = new TankManager(this, resourceTank);
|
||||
invInput = new InventoryMapper(getInternalInventory(), InventoryAnalyzer.SLOT_INPUT_1, InventoryAnalyzer.SLOT_INPUT_COUNT);
|
||||
invOutput = new InventoryMapper(getInternalInventory(), InventoryAnalyzer.SLOT_OUTPUT_1, InventoryAnalyzer.SLOT_OUTPUT_COUNT);
|
||||
@@ -109,7 +108,8 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
}
|
||||
|
||||
if (!specimenToAnalyze.isAnalyzed()) {
|
||||
if (!resourceTank.canDrain(HONEY_REQUIRED)) {
|
||||
FluidStack drained = resourceTank.drain(HONEY_REQUIRED, false);
|
||||
if (drained == null || drained.amount != HONEY_REQUIRED) {
|
||||
return false;
|
||||
}
|
||||
resourceTank.drain(HONEY_REQUIRED, true);
|
||||
@@ -182,7 +182,8 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
hasSpace = InventoryUtil.tryAddStack(invOutput, specimen, true, false);
|
||||
|
||||
if (!specimenToAnalyze.isAnalyzed()) {
|
||||
hasResource = resourceTank.canDrain(HONEY_REQUIRED);
|
||||
FluidStack drained = resourceTank.drain(HONEY_REQUIRED, false);
|
||||
hasResource = drained != null && drained.amount == HONEY_REQUIRED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,35 +250,23 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class VectUtil {
|
||||
do {
|
||||
pos = nextPos();
|
||||
}
|
||||
while (pos != null && (pos.getX() > maxPos.getX() || pos.getZ() > maxPos.getZ() || pos.getX() < minPos.getX() || pos.getZ() < minPos.getZ()));
|
||||
while (pos != null && (pos.getX() > maxPos.getX() || pos.getY() > maxPos.getY() || pos.getZ() > maxPos.getZ() || pos.getX() < minPos.getX() || pos.getY() < minPos.getY() || pos.getZ() < minPos.getZ()));
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ package forestry.energy.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.energy.tiles.TileEngineBiogas;
|
||||
|
||||
@@ -28,8 +28,8 @@ public class InventoryEngineBiogas extends InventoryAdapterTile<TileEngineBiogas
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -12,9 +12,9 @@ package forestry.energy.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.energy.tiles.TileEuGenerator;
|
||||
|
||||
@@ -28,8 +28,8 @@ public class InventoryGenerator extends InventoryAdapterTile<TileEuGenerator> {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -20,11 +20,11 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.fuels.EngineBronzeFuel;
|
||||
@@ -44,7 +44,7 @@ import forestry.energy.gui.ContainerEngineBiogas;
|
||||
import forestry.energy.gui.GuiEngineBiogas;
|
||||
import forestry.energy.inventory.InventoryEngineBiogas;
|
||||
|
||||
public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILiquidTankTile, IFluidHandler {
|
||||
public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILiquidTankTile {
|
||||
private final FilteredTank fuelTank;
|
||||
private final FilteredTank heatingTank;
|
||||
private final StandardTank burnTank;
|
||||
@@ -57,12 +57,10 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
|
||||
|
||||
setInternalInventory(new InventoryEngineBiogas(this));
|
||||
|
||||
fuelTank = new FilteredTank(Constants.ENGINE_TANK_CAPACITY, FuelManager.bronzeEngineFuel.keySet());
|
||||
fuelTank.tankMode = StandardTank.TankMode.DEFAULT;
|
||||
heatingTank = new FilteredTank(Constants.ENGINE_TANK_CAPACITY, FluidRegistry.LAVA);
|
||||
heatingTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
burnTank = new StandardTank(Constants.BUCKET_VOLUME);
|
||||
burnTank.tankMode = StandardTank.TankMode.INTERNAL;
|
||||
fuelTank = new FilteredTank(Constants.ENGINE_TANK_CAPACITY).setFilters(FuelManager.bronzeEngineFuel.keySet());
|
||||
heatingTank = new FilteredTank(Constants.ENGINE_TANK_CAPACITY, true, false).setFilters(FluidRegistry.LAVA);
|
||||
burnTank = new StandardTank(Fluid.BUCKET_VOLUME, false, false);
|
||||
|
||||
this.tankManager = new TankManager(this, fuelTank, heatingTank, burnTank);
|
||||
}
|
||||
|
||||
@@ -103,7 +101,7 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
|
||||
|
||||
currentOutput = 0;
|
||||
|
||||
if (isRedstoneActivated() && (fuelTank.getFluidAmount() >= Constants.BUCKET_VOLUME || burnTank.getFluidAmount() > 0)) {
|
||||
if (isRedstoneActivated() && (fuelTank.getFluidAmount() >= Fluid.BUCKET_VOLUME || burnTank.getFluidAmount() > 0)) {
|
||||
|
||||
double heatStage = getHeatLevel();
|
||||
|
||||
@@ -126,7 +124,7 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
|
||||
currentOutput = determineFuelValue(drained.getFluid());
|
||||
energyManager.generateEnergy(currentOutput);
|
||||
} else {
|
||||
FluidStack fuel = fuelTank.drain(Constants.BUCKET_VOLUME, true);
|
||||
FluidStack fuel = fuelTank.drain(Fluid.BUCKET_VOLUME, true);
|
||||
int burnTime = determineBurnTime(fuel.getFluid());
|
||||
fuel.amount = burnTime;
|
||||
burnTank.setCapacity(burnTime);
|
||||
@@ -295,35 +293,23 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 3, burnTank.getCapacity());
|
||||
}
|
||||
|
||||
// IFluidHandler
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,16 +20,15 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
@@ -43,7 +42,7 @@ import forestry.energy.gui.GuiGenerator;
|
||||
import forestry.energy.inventory.InventoryGenerator;
|
||||
|
||||
// TODO: IC2 for 1.9
|
||||
public class TileEuGenerator extends TileBase implements ISidedInventory, ILiquidTankTile, IFluidHandler, IRenderableTile {
|
||||
public class TileEuGenerator extends TileBase implements ISidedInventory, ILiquidTankTile, IRenderableTile {
|
||||
private static final int maxEnergy = 30000;
|
||||
|
||||
private final TankManager tankManager;
|
||||
@@ -58,7 +57,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
|
||||
setInternalInventory(new InventoryGenerator(this));
|
||||
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet());
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY);
|
||||
resourceTank.setFilters(FuelManager.generatorFuel.keySet());
|
||||
|
||||
tankManager = new TankManager(this, resourceTank);
|
||||
|
||||
// if (PluginIC2.instance.isAvailable()) {
|
||||
@@ -137,7 +138,7 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
//
|
||||
// if (resourceTank.getFluidAmount() > 0) {
|
||||
// GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid());
|
||||
// if (resourceTank.canDrain(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) {
|
||||
// if (resourceTank.canDrainFluidType(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) {
|
||||
// ic2EnergySource.addEnergy(fuel.eu);
|
||||
// this.tickCount++;
|
||||
//
|
||||
@@ -194,43 +195,6 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
// }
|
||||
}
|
||||
|
||||
/* ILiquidTankTile */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
return new GuiGenerator(player.inventory, this);
|
||||
@@ -240,4 +204,29 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerGenerator(player.inventory, this);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
@@ -242,8 +243,8 @@ public class PluginFactory extends BlankForestryPlugin {
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.APICULTURE)) {
|
||||
ItemRegistryApiculture beeItems = PluginApiculture.items;
|
||||
FluidStack liquidGlass = Fluids.GLASS.getFluid(Constants.BUCKET_VOLUME);
|
||||
FluidStack liquidGlassX4 = Fluids.GLASS.getFluid(Constants.BUCKET_VOLUME * 4);
|
||||
FluidStack liquidGlass = Fluids.GLASS.getFluid(Fluid.BUCKET_VOLUME);
|
||||
FluidStack liquidGlassX4 = Fluids.GLASS.getFluid(Fluid.BUCKET_VOLUME * 4);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
RecipeManagers.fabricatorManager.addRecipe(beeItems.waxCast.getWildcard(), liquidGlass, new ItemStack(Blocks.STAINED_GLASS, 4, 15 - i), new Object[]{
|
||||
"#", "X",
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
@@ -32,9 +33,9 @@ public class InventoryBottler extends InventoryAdapterTile<TileBottler> {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_INPUT_EMPTY_CAN) {
|
||||
return FluidHelper.isFillableContainer(itemStack);
|
||||
return FluidHelper.isFillableContainerWithRoom(itemStack);
|
||||
} else if (slotIndex == SLOT_INPUT_FULL_CAN) {
|
||||
FluidStack fluidStack = FluidHelper.getFluidStackInContainer(itemStack);
|
||||
FluidStack fluidStack = FluidUtil.getFluidContained(itemStack);
|
||||
return fluidStack != null && FluidRegistry.isFluidRegistered(fluidStack.getFluid());
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -13,9 +13,9 @@ package forestry.factory.inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import forestry.factory.recipes.CarpenterRecipeManager;
|
||||
@@ -36,8 +36,8 @@ public class InventoryCarpenter extends InventoryAdapterTile<TileCarpenter> {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
} else if (slotIndex == SLOT_BOX) {
|
||||
return CarpenterRecipeManager.isBox(itemStack);
|
||||
} else if (canSlotAccept(SLOT_CAN_INPUT, itemStack) || canSlotAccept(SLOT_BOX, itemStack)) {
|
||||
|
||||
@@ -13,7 +13,8 @@ package forestry.factory.inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
@@ -37,10 +38,10 @@ public class InventoryFermenter extends InventoryAdapterTile<TileFermenter> {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return FermenterRecipeManager.isResource(itemStack);
|
||||
} else if (slotIndex == SLOT_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
} else if (slotIndex == SLOT_CAN_INPUT) {
|
||||
return FluidHelper.isFillableContainer(itemStack);
|
||||
return FluidHelper.isFillableContainerWithRoom(itemStack);
|
||||
} else if (slotIndex == SLOT_FUEL) {
|
||||
return FuelManager.fermenterFuel.containsKey(itemStack);
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ package forestry.factory.inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import forestry.factory.recipes.MoistenerRecipeManager;
|
||||
@@ -46,8 +46,8 @@ public class InventoryMoistener extends InventoryAdapterTile<TileMoistener> {
|
||||
}
|
||||
|
||||
if (slotIndex == SLOT_PRODUCT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -13,8 +13,11 @@ package forestry.factory.inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.factory.tiles.TileRaintank;
|
||||
|
||||
@@ -29,7 +32,10 @@ public class InventoryRaintank extends InventoryAdapterTile<TileRaintank> {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return FluidHelper.getFilledContainer(Fluids.WATER.getFluid(1000), itemStack) != null;
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(itemStack);
|
||||
if (fluidHandler != null) {
|
||||
return fluidHandler.fill(new FluidStack(FluidRegistry.WATER, Integer.MAX_VALUE), false) > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ public class InventorySqueezer extends InventoryAdapterTile<TileSqueezer> {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN_INPUT) {
|
||||
return FluidHelper.isEmptyContainer(itemStack);
|
||||
return FluidHelper.isFillableEmptyContainer(itemStack);
|
||||
}
|
||||
|
||||
if (slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) {
|
||||
if (FluidHelper.isEmptyContainer(itemStack)) {
|
||||
if (FluidHelper.isFillableEmptyContainer(itemStack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,6 @@ public class InventorySqueezer extends InventoryAdapterTile<TileSqueezer> {
|
||||
if (getStackInSlot(SLOT_CAN_INPUT) == null || fluidStack == null) {
|
||||
return;
|
||||
}
|
||||
FluidHelper.fillContainers(tankManager, this, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid());
|
||||
FluidHelper.fillContainers(tankManager, this, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid(), true);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ package forestry.factory.inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
@@ -31,10 +32,10 @@ public class InventoryStill extends InventoryAdapterTile<TileStill> {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return FluidHelper.isEmptyContainer(itemStack);
|
||||
return FluidHelper.isFillableEmptyContainer(itemStack);
|
||||
} else if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return tile.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,59 +12,44 @@ package forestry.factory.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
public class BottlerRecipe {
|
||||
public static BottlerRecipe create(Fluid res, ItemStack empty) {
|
||||
if (res == null || empty == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack filled = empty.copy();
|
||||
filled.stackSize = 1;
|
||||
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(filled);
|
||||
if (fluidHandler == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int fillAmount = fluidHandler.fill(new FluidStack(res, Integer.MAX_VALUE), true);
|
||||
if (fillAmount > 0) {
|
||||
return new BottlerRecipe(empty, new FluidStack(res, fillAmount), filled);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public final FluidStack input;
|
||||
public final ItemStack empty;
|
||||
public final ItemStack filled;
|
||||
|
||||
private BottlerRecipe(ItemStack empty, FluidStack input, ItemStack filled) {
|
||||
this.input = input;
|
||||
if (empty.getItem() instanceof IFluidContainerItem) {
|
||||
FluidStack emptyFluid = FluidHelper.getFluidStackInContainer(empty);
|
||||
if (emptyFluid != null) {
|
||||
this.input.amount -= emptyFluid.amount;
|
||||
}
|
||||
if (this.input.amount > Constants.BUCKET_VOLUME) {
|
||||
this.input.amount = Constants.BUCKET_VOLUME;
|
||||
}
|
||||
}
|
||||
this.empty = empty;
|
||||
this.filled = filled;
|
||||
}
|
||||
|
||||
public boolean matches(ItemStack emptyCan, FluidStack resource) {
|
||||
if (emptyCan == null || resource == null || !emptyCan.isItemEqual(empty)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty.getItem() instanceof IFluidContainerItem) {
|
||||
return true;
|
||||
} else {
|
||||
return resource.containsFluid(input);
|
||||
}
|
||||
}
|
||||
|
||||
public static BottlerRecipe getRecipe(FluidStack res, ItemStack empty) {
|
||||
if (res == null || empty == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack filled = FluidHelper.getFilledContainer(res.getFluid(), empty);
|
||||
if (filled == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FluidStack input = FluidHelper.getFluidStackInContainer(filled);
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BottlerRecipe(empty, input, filled);
|
||||
return emptyCan != null && resource != null && emptyCan.isItemEqual(empty) && resource.containsFluid(input);
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,9 @@ package forestry.factory.recipes;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class SqueezerContainerRecipe implements ISqueezerContainerRecipe {
|
||||
@@ -57,7 +57,7 @@ public class SqueezerContainerRecipe implements ISqueezerContainerRecipe {
|
||||
if (filledContainer == null) {
|
||||
return null;
|
||||
}
|
||||
FluidStack fluidOutput = FluidHelper.getFluidStackInContainer(filledContainer);
|
||||
FluidStack fluidOutput = FluidUtil.getFluidContained(filledContainer);
|
||||
if (fluidOutput == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -48,12 +48,11 @@ public class SqueezerRecipeManager implements ISqueezerManager {
|
||||
|
||||
@Nullable
|
||||
public static ISqueezerContainerRecipe findMatchingContainerRecipe(ItemStack filledContainer) {
|
||||
ItemStack emptyContainer = FluidHelper.getEmptyContainer(filledContainer);
|
||||
if (emptyContainer == null) {
|
||||
if (!FluidHelper.isDrainableFilledContainer(filledContainer)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return containerRecipes.get(emptyContainer);
|
||||
return containerRecipes.get(new ItemStack(filledContainer.getItem()));
|
||||
}
|
||||
|
||||
public static ISqueezerRecipe findMatchingRecipe(ItemStack[] items) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
|
||||
@@ -16,9 +17,12 @@ public class BottlerRecipeMaker {
|
||||
public static List<BottlerRecipeWrapper> getBottlerRecipes() {
|
||||
List<BottlerRecipeWrapper> recipes = new ArrayList<>();
|
||||
for (FluidContainerData container : FluidContainerRegistry.getRegisteredFluidContainerData()) {
|
||||
BottlerRecipe recipe = BottlerRecipe.getRecipe(container.fluid, container.emptyContainer);
|
||||
if (recipe != null) {
|
||||
recipes.add(new BottlerRecipeWrapper(recipe));
|
||||
FluidStack fluid = container.fluid;
|
||||
if (fluid != null) {
|
||||
BottlerRecipe recipe = BottlerRecipe.create(fluid.getFluid(), container.emptyContainer);
|
||||
if (recipe != null) {
|
||||
recipes.add(new BottlerRecipeWrapper(recipe));
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipes;
|
||||
|
||||
@@ -19,10 +19,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.core.config.Constants;
|
||||
@@ -41,7 +41,7 @@ import forestry.factory.gui.GuiBottler;
|
||||
import forestry.factory.inventory.InventoryBottler;
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
|
||||
public class TileBottler extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler {
|
||||
public class TileBottler extends TilePowered implements ISidedInventory, ILiquidTankTile {
|
||||
private static final int TICKS_PER_RECIPE_TIME = 5;
|
||||
private static final int ENERGY_PER_RECIPE_TIME = 1000;
|
||||
|
||||
@@ -98,22 +98,25 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
|
||||
@Override
|
||||
public boolean workCycle() {
|
||||
FluidHelper.FillStatus status = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_INPUT_EMPTY_CAN, InventoryBottler.SLOT_OUTPUT, currentRecipe.input.getFluid());
|
||||
FluidHelper.FillStatus status = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_INPUT_EMPTY_CAN, InventoryBottler.SLOT_OUTPUT, currentRecipe.input.getFluid(), true);
|
||||
return status == FluidHelper.FillStatus.SUCCESS;
|
||||
}
|
||||
|
||||
private void checkRecipe() {
|
||||
ItemStack emptyCan = getStackInSlot(InventoryBottler.SLOT_INPUT_EMPTY_CAN);
|
||||
FluidStack resource = resourceTank.getFluid();
|
||||
if (resource == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentRecipe == null || !currentRecipe.matches(emptyCan, resource)) {
|
||||
currentRecipe = BottlerRecipe.getRecipe(resource, emptyCan);
|
||||
currentRecipe = BottlerRecipe.create(resource.getFluid(), emptyCan);
|
||||
if (currentRecipe != null) {
|
||||
float viscosityMultiplier = resource.getFluid().getViscosity(resource) / 1000.0f;
|
||||
viscosityMultiplier = (viscosityMultiplier - 1f) / 20f + 1f; // scale down the effect
|
||||
|
||||
int fillAmount = Math.min(currentRecipe.input.amount, resource.amount);
|
||||
float fillTime = fillAmount / (float) Constants.BUCKET_VOLUME;
|
||||
float fillTime = fillAmount / (float) Fluid.BUCKET_VOLUME;
|
||||
fillTime *= viscosityMultiplier;
|
||||
|
||||
setTicksPerWorkCycle(Math.round(fillTime * TICKS_PER_RECIPE_TIME));
|
||||
@@ -164,33 +167,22 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
|
||||
@@ -22,10 +22,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.recipes.ICarpenterRecipe;
|
||||
@@ -50,7 +49,7 @@ import forestry.factory.inventory.InventoryCarpenter;
|
||||
import forestry.factory.inventory.InventoryGhostCrafting;
|
||||
import forestry.factory.recipes.CarpenterRecipeManager;
|
||||
|
||||
public class TileCarpenter extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler, IItemStackDisplay {
|
||||
public class TileCarpenter extends TilePowered implements ISidedInventory, ILiquidTankTile, IItemStackDisplay {
|
||||
private static final int TICKS_PER_RECIPE_TIME = 1;
|
||||
private static final int ENERGY_PER_WORK_CYCLE = 2040;
|
||||
private static final int ENERGY_PER_RECIPE_TIME = ENERGY_PER_WORK_CYCLE / 10;
|
||||
@@ -70,7 +69,7 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
public TileCarpenter() {
|
||||
super("carpenter", 1100, 4000);
|
||||
setEnergyPerWorkCycle(ENERGY_PER_WORK_CYCLE);
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, CarpenterRecipeManager.getRecipeFluids());
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(CarpenterRecipeManager.getRecipeFluids());
|
||||
|
||||
craftingInventory = new InventoryGhostCrafting<>(this, 10);
|
||||
craftPreviewInventory = new InventoryCraftResult();
|
||||
@@ -161,11 +160,12 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
|
||||
FluidStack fluid = currentRecipe.getFluidResource();
|
||||
if (fluid != null) {
|
||||
if (!resourceTank.canDrain(fluid)) {
|
||||
FluidStack drained = resourceTank.drainInternal(fluid, false);
|
||||
if (!FluidHelper.areFluidStacksEqual(drained, fluid)) {
|
||||
return false;
|
||||
}
|
||||
if (doRemove) {
|
||||
resourceTank.drain(fluid.amount, true);
|
||||
resourceTank.drainInternal(fluid, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,12 +243,6 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
craftPreviewInventory.setInventorySlotContents(0, itemStack);
|
||||
}
|
||||
|
||||
// IFLUIDCONTAINER IMPLEMENTATION
|
||||
@Override
|
||||
public int fill(EnumFacing direction, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(direction, resource, doFill);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
@@ -256,28 +250,22 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,20 +23,19 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.recipes.IFabricatorRecipe;
|
||||
import forestry.api.recipes.IFabricatorSmeltingRecipe;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
@@ -55,7 +54,7 @@ import forestry.factory.inventory.InventoryGhostCrafting;
|
||||
import forestry.factory.recipes.FabricatorRecipeManager;
|
||||
import forestry.factory.recipes.FabricatorSmeltingRecipeManager;
|
||||
|
||||
public class TileFabricator extends TilePowered implements ISlotPickupWatcher, ILiquidTankTile, IFluidHandler, ISidedInventory {
|
||||
public class TileFabricator extends TilePowered implements ISlotPickupWatcher, ILiquidTankTile, ISidedInventory {
|
||||
private static final int MAX_HEAT = 5000;
|
||||
|
||||
private final InventoryAdapterTile craftingInventory;
|
||||
@@ -69,8 +68,9 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
|
||||
setEnergyPerWorkCycle(200);
|
||||
craftingInventory = new InventoryGhostCrafting<>(this, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
|
||||
setInternalInventory(new InventoryFabricator(this));
|
||||
moltenTank = new FilteredTank(8 * Constants.BUCKET_VOLUME, Fluids.GLASS.getFluid());
|
||||
moltenTank.tankMode = StandardTank.TankMode.INTERNAL;
|
||||
|
||||
moltenTank = new FilteredTank(8 * Fluid.BUCKET_VOLUME, false, false).setFilters(Fluids.GLASS.getFluid());
|
||||
|
||||
tankManager = new TankManager(this, moltenTank);
|
||||
}
|
||||
|
||||
@@ -144,9 +144,9 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
|
||||
}
|
||||
|
||||
FluidStack smeltFluid = smelt.getProduct();
|
||||
if (moltenTank.canFill(smeltFluid)) {
|
||||
if (moltenTank.fillInternal(smeltFluid, false) == smeltFluid.amount) {
|
||||
this.decrStackSize(InventoryFabricator.SLOT_METAL, 1);
|
||||
moltenTank.fill(smeltFluid, true);
|
||||
moltenTank.fillInternal(smeltFluid, true);
|
||||
meltingPoint = smelt.getMeltingPoint();
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,8 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
|
||||
return;
|
||||
}
|
||||
|
||||
if (!moltenTank.canDrain(liquid)) {
|
||||
FluidStack drained = moltenTank.drainInternal(liquid, false);
|
||||
if (!FluidHelper.areFluidStacksEqual(drained, liquid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -249,7 +250,9 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
|
||||
if (recipe != null) {
|
||||
ItemStack[] crafting = InventoryUtil.getStacks(craftingInventory, InventoryGhostCrafting.SLOT_CRAFTING_1, InventoryGhostCrafting.SLOT_CRAFTING_COUNT);
|
||||
hasResources = removeFromInventory(crafting, null, false);
|
||||
hasLiquidResources = moltenTank.canDrain(recipe.getLiquid());
|
||||
FluidStack toDrain = recipe.getLiquid();
|
||||
FluidStack drained = moltenTank.drainInternal(toDrain, false);
|
||||
hasLiquidResources = FluidHelper.areFluidStacksEqual(drained, toDrain);
|
||||
} else {
|
||||
hasRecipe = false;
|
||||
}
|
||||
@@ -310,7 +313,6 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
|
||||
return craftingInventory;
|
||||
}
|
||||
|
||||
/* ILIQUIDCONTAINER */
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
@@ -318,33 +320,22 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,10 +21,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.fuels.FermenterFuel;
|
||||
@@ -36,7 +36,6 @@ import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.render.TankRenderInfo;
|
||||
@@ -47,7 +46,7 @@ import forestry.factory.gui.GuiFermenter;
|
||||
import forestry.factory.inventory.InventoryFermenter;
|
||||
import forestry.factory.recipes.FermenterRecipeManager;
|
||||
|
||||
public class TileFermenter extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler {
|
||||
public class TileFermenter extends TilePowered implements ISidedInventory, ILiquidTankTile {
|
||||
private final FilteredTank resourceTank;
|
||||
private final FilteredTank productTank;
|
||||
private final TankManager tankManager;
|
||||
@@ -64,10 +63,13 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
super("fermenter", 2000, 8000);
|
||||
setEnergyPerWorkCycle(4200);
|
||||
setInternalInventory(new InventoryFermenter(this));
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FermenterRecipeManager.recipeFluidInputs);
|
||||
resourceTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
productTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FermenterRecipeManager.recipeFluidOutputs);
|
||||
productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, true, false);
|
||||
resourceTank.setFilters(FermenterRecipeManager.recipeFluidInputs);
|
||||
|
||||
productTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, false, true);
|
||||
productTank.setFilters(FermenterRecipeManager.recipeFluidOutputs);
|
||||
|
||||
tankManager = new TankManager(this, resourceTank, productTank);
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
|
||||
FluidStack fluidStack = productTank.getFluid();
|
||||
if (fluidStack != null) {
|
||||
FluidHelper.fillContainers(tankManager, this, InventoryFermenter.SLOT_CAN_INPUT, InventoryFermenter.SLOT_CAN_OUTPUT, fluidStack.getFluid());
|
||||
FluidHelper.fillContainers(tankManager, this, InventoryFermenter.SLOT_CAN_INPUT, InventoryFermenter.SLOT_CAN_OUTPUT, fluidStack.getFluid(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +131,7 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
public boolean workCycle() {
|
||||
int fermented = Math.min(fermentationTime, fuelCurrentFerment);
|
||||
int productAmount = Math.round(fermented * currentRecipe.getModifier() * currentResourceModifier);
|
||||
productTank.fill(new FluidStack(currentRecipe.getOutput(), productAmount), true);
|
||||
productTank.fillInternal(new FluidStack(currentRecipe.getOutput(), productAmount), true);
|
||||
|
||||
fuelBurnTime--;
|
||||
resourceTank.drain(fermented, true);
|
||||
@@ -222,12 +224,15 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
boolean hasRecipe = currentRecipe != null;
|
||||
boolean hasFuel = fuelBurnTime > 0;
|
||||
boolean hasResource = fermentationTime > 0 || getStackInSlot(InventoryFermenter.SLOT_RESOURCE) != null;
|
||||
boolean hasFluidResource = resourceTank.canDrain(fermented);
|
||||
FluidStack drained = resourceTank.drain(fermented, false);
|
||||
boolean hasFluidResource = drained != null && drained.amount == fermented;
|
||||
boolean hasFluidSpace = true;
|
||||
|
||||
if (hasRecipe) {
|
||||
int productAmount = Math.round(fermented * currentRecipe.getModifier() * currentResourceModifier);
|
||||
hasFluidSpace = productTank.canFill(currentRecipe.getOutput(), productAmount);
|
||||
Fluid output = currentRecipe.getOutput();
|
||||
FluidStack fluidStack = new FluidStack(output, productAmount);
|
||||
hasFluidSpace = productTank.fillInternal(fluidStack, false) == fluidStack.amount;
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
@@ -291,43 +296,12 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
iCrafting.sendProgressBarUpdate(container, 3, fermentationTotalTime);
|
||||
}
|
||||
|
||||
/* ILiquidTankTile */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return resourceTank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int quantityMax, boolean doEmpty) {
|
||||
return tankManager.drain(from, quantityMax, doEmpty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
// TODO: BuildCraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@@ -348,4 +322,23 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerFermenter(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -22,11 +22,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
@@ -51,7 +49,7 @@ import forestry.factory.gui.GuiMoistener;
|
||||
import forestry.factory.inventory.InventoryMoistener;
|
||||
import forestry.factory.recipes.MoistenerRecipeManager;
|
||||
|
||||
public class TileMoistener extends TileBase implements ISidedInventory, ILiquidTankTile, IFluidHandler, IRenderableTile {
|
||||
public class TileMoistener extends TileBase implements ISidedInventory, ILiquidTankTile, IRenderableTile {
|
||||
private final FilteredTank resourceTank;
|
||||
private final TankManager tankManager;
|
||||
private IMoistenerRecipe currentRecipe;
|
||||
@@ -66,7 +64,7 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
public TileMoistener() {
|
||||
super("moistener");
|
||||
setInternalInventory(new InventoryMoistener(this));
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
|
||||
tankManager = new TankManager(this, resourceTank);
|
||||
}
|
||||
|
||||
@@ -480,43 +478,12 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
return TankRenderInfo.EMPTY;
|
||||
}
|
||||
|
||||
/* ILiquidTankTile */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
switch (i) {
|
||||
@@ -551,4 +518,23 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerMoistener(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,10 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.core.config.Constants;
|
||||
@@ -45,7 +44,7 @@ import forestry.factory.gui.ContainerRaintank;
|
||||
import forestry.factory.gui.GuiRaintank;
|
||||
import forestry.factory.inventory.InventoryRaintank;
|
||||
|
||||
public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTankTile, IFluidHandler {
|
||||
public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTankTile {
|
||||
private static final FluidStack STACK_WATER = Fluids.WATER.getFluid(Constants.RAINTANK_AMOUNT_PER_UPDATE);
|
||||
|
||||
private final FilteredTank resourceTank;
|
||||
@@ -57,7 +56,8 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
super("raintank");
|
||||
setInternalInventory(new InventoryRaintank(this));
|
||||
|
||||
resourceTank = new FilteredTank(Constants.RAINTANK_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
resourceTank = new FilteredTank(Constants.RAINTANK_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
|
||||
|
||||
tankManager = new TankManager(this, resourceTank);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
errorLogic.setCondition(!worldObj.isRainingAt(posAbove), EnumErrorCode.NOT_RAINING);
|
||||
|
||||
if (!errorLogic.hasErrors()) {
|
||||
resourceTank.fill(STACK_WATER, true);
|
||||
resourceTank.fillInternal(STACK_WATER, true);
|
||||
}
|
||||
|
||||
if (!ItemStackUtil.isIdenticalItem(usedEmpty, getStackInSlot(InventoryRaintank.SLOT_RESOURCE))) {
|
||||
@@ -126,7 +126,7 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
} else {
|
||||
fillingTime--;
|
||||
if (fillingTime <= 0) {
|
||||
FluidHelper.FillStatus filled = FluidHelper.fillContainers(tankManager, this, InventoryRaintank.SLOT_RESOURCE, InventoryRaintank.SLOT_PRODUCT, Fluids.WATER.getFluid());
|
||||
FluidHelper.FillStatus filled = FluidHelper.fillContainers(tankManager, this, InventoryRaintank.SLOT_RESOURCE, InventoryRaintank.SLOT_PRODUCT, Fluids.WATER.getFluid(), true);
|
||||
if (filled == FluidHelper.FillStatus.SUCCESS) {
|
||||
fillingTime = 0;
|
||||
}
|
||||
@@ -155,32 +155,6 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
iCrafting.sendProgressBarUpdate(container, 0, fillingTime);
|
||||
}
|
||||
|
||||
// / ILIQUIDCONTAINER IMPLEMENTATION
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
@@ -188,8 +162,22 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,10 +19,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.CircuitSocketType;
|
||||
@@ -49,7 +48,7 @@ import forestry.factory.gui.GuiSqueezer;
|
||||
import forestry.factory.inventory.InventorySqueezer;
|
||||
import forestry.factory.recipes.SqueezerRecipeManager;
|
||||
|
||||
public class TileSqueezer extends TilePowered implements ISocketable, ISidedInventory, ILiquidTankTile, IFluidHandler, ISpeedUpgradable {
|
||||
public class TileSqueezer extends TilePowered implements ISocketable, ISidedInventory, ILiquidTankTile, ISpeedUpgradable {
|
||||
private static final int TICKS_PER_RECIPE_TIME = 1;
|
||||
private static final int ENERGY_PER_WORK_CYCLE = 2000;
|
||||
private static final int ENERGY_PER_RECIPE_TIME = ENERGY_PER_WORK_CYCLE / 10;
|
||||
@@ -66,8 +65,7 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
super("squeezer", 1100, Constants.MACHINE_MAX_ENERGY);
|
||||
this.inventory = new InventorySqueezer(this);
|
||||
setInternalInventory(this.inventory);
|
||||
this.productTank = new StandardTank(Constants.PROCESSOR_TANK_CAPACITY);
|
||||
this.productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
this.productTank = new StandardTank(Constants.PROCESSOR_TANK_CAPACITY, false, true);
|
||||
this.tankManager = new TankManager(this, productTank);
|
||||
}
|
||||
|
||||
@@ -138,7 +136,7 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
}
|
||||
|
||||
FluidStack resultFluid = currentRecipe.getFluidOutput();
|
||||
productTank.fill(resultFluid, true);
|
||||
productTank.fillInternal(resultFluid, true);
|
||||
|
||||
if (currentRecipe.getRemnants() != null && worldObj.rand.nextFloat() < currentRecipe.getRemnantsChance()) {
|
||||
ItemStack remnant = currentRecipe.getRemnants().copy();
|
||||
@@ -186,7 +184,7 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
hasRecipe = currentRecipe != null;
|
||||
if (hasRecipe) {
|
||||
FluidStack resultFluid = currentRecipe.getFluidOutput();
|
||||
canFill = productTank.canFill(resultFluid);
|
||||
canFill = productTank.fillInternal(resultFluid, false) == resultFluid.amount;
|
||||
|
||||
if (currentRecipe.getRemnants() != null) {
|
||||
canAdd = inventory.addRemnant(currentRecipe.getRemnants(), false);
|
||||
@@ -208,43 +206,12 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
return new TankRenderInfo(productTank);
|
||||
}
|
||||
|
||||
/* ILIQUIDCONTAINER IMPLEMENTATION */
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
/* ISocketable */
|
||||
@Override
|
||||
public int getSocketCount() {
|
||||
@@ -289,6 +256,25 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
return CircuitSocketType.MACHINE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
return new GuiSqueezer(player.inventory, this);
|
||||
|
||||
@@ -18,10 +18,9 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.recipes.IStillRecipe;
|
||||
@@ -30,7 +29,6 @@ import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.render.TankRenderInfo;
|
||||
@@ -41,7 +39,7 @@ import forestry.factory.gui.GuiStill;
|
||||
import forestry.factory.inventory.InventoryStill;
|
||||
import forestry.factory.recipes.StillRecipeManager;
|
||||
|
||||
public class TileStill extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler {
|
||||
public class TileStill extends TilePowered implements ISidedInventory, ILiquidTankTile {
|
||||
private static final int ENERGY_PER_RECIPE_TIME = 200;
|
||||
|
||||
private final FilteredTank resourceTank;
|
||||
@@ -54,10 +52,12 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
public TileStill() {
|
||||
super("still", 1100, 8000);
|
||||
setInternalInventory(new InventoryStill(this));
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, StillRecipeManager.recipeFluidInputs);
|
||||
resourceTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
productTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, StillRecipeManager.recipeFluidOutputs);
|
||||
productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, true, false);
|
||||
resourceTank.setFilters(StillRecipeManager.recipeFluidInputs);
|
||||
|
||||
productTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, false, true);
|
||||
productTank.setFilters(StillRecipeManager.recipeFluidOutputs);
|
||||
|
||||
tankManager = new TankManager(this, resourceTank, productTank);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
|
||||
FluidStack fluidStack = productTank.getFluid();
|
||||
if (fluidStack != null) {
|
||||
FluidHelper.fillContainers(tankManager, this, InventoryStill.SLOT_RESOURCE, InventoryStill.SLOT_PRODUCT, fluidStack.getFluid());
|
||||
FluidHelper.fillContainers(tankManager, this, InventoryStill.SLOT_RESOURCE, InventoryStill.SLOT_PRODUCT, fluidStack.getFluid(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
FluidStack output = currentRecipe.getOutput();
|
||||
|
||||
FluidStack product = new FluidStack(output, output.amount * cycles);
|
||||
productTank.fill(product, true);
|
||||
productTank.fillInternal(product, true);
|
||||
|
||||
bufferedLiquid = null;
|
||||
|
||||
@@ -147,12 +147,14 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
boolean hasLiquidResource = true;
|
||||
|
||||
if (hasRecipe) {
|
||||
hasTankSpace = productTank.canFill(currentRecipe.getOutput());
|
||||
FluidStack fluidStack = currentRecipe.getOutput();
|
||||
hasTankSpace = productTank.fillInternal(fluidStack, false) == fluidStack.amount;
|
||||
if (bufferedLiquid == null) {
|
||||
int cycles = currentRecipe.getCyclesPerUnit();
|
||||
FluidStack input = currentRecipe.getInput();
|
||||
int drainAmount = cycles * input.amount;
|
||||
hasLiquidResource = resourceTank.canDrain(drainAmount);
|
||||
FluidStack drained = resourceTank.drain(drainAmount, false);
|
||||
hasLiquidResource = drained != null && drained.amount == drainAmount;
|
||||
if (hasLiquidResource) {
|
||||
bufferedLiquid = new FluidStack(input, drainAmount);
|
||||
resourceTank.drain(drainAmount, true);
|
||||
@@ -178,32 +180,6 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
return new TankRenderInfo(productTank);
|
||||
}
|
||||
|
||||
/* IFluidHandler */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int quantityMax, boolean doEmpty) {
|
||||
return tankManager.drain(from, quantityMax, doEmpty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
@@ -211,8 +187,22 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -146,7 +147,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
public FarmController(World world) {
|
||||
super(world, FarmMultiblockSizeLimits.instance);
|
||||
|
||||
this.resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
this.resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
|
||||
|
||||
this.tankManager = new TankManager(this, resourceTank);
|
||||
|
||||
this.inventory = new InventoryFarm(this);
|
||||
@@ -790,7 +792,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
|
||||
@Override
|
||||
public boolean hasLiquid(FluidStack liquid) {
|
||||
return resourceTank.canDrain(liquid);
|
||||
FluidStack drained = resourceTank.drainInternal(liquid, false);
|
||||
return FluidHelper.areFluidStacksEqual(drained, liquid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmInventory;
|
||||
@@ -75,8 +76,8 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
|
||||
} else if (SlotUtil.isSlotInRange(slotIndex, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT)) {
|
||||
return acceptsAsResource(itemStack);
|
||||
} else if (SlotUtil.isSlotInRange(slotIndex, SLOT_CAN, SLOT_CAN_COUNT)) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return farmController.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return farmController.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,50 +14,35 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
|
||||
public class TileFarmValve extends TileFarm implements ILiquidTankTile, IFluidHandler {
|
||||
|
||||
/* ILIQUIDTANKCONTAINER */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return getTankManager().fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return getTankManager().drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return getTankManager().drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return getTankManager().canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return getTankManager().canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return getTankManager().getTankInfo(from);
|
||||
}
|
||||
|
||||
public class TileFarmValve extends TileFarm implements ILiquidTankTile {
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITankManager getTankManager() {
|
||||
return getMultiblockLogic().getController().getTankManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(getTankManager());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.food;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.food.BeverageManager;
|
||||
@@ -18,10 +17,7 @@ import forestry.apiculture.PluginApiculture;
|
||||
import forestry.apiculture.items.EnumPollenCluster;
|
||||
import forestry.apiculture.items.ItemRegistryApiculture;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.fluids.LiquidRegistryHelper;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.food.items.EnumBeverage;
|
||||
import forestry.food.items.ItemRegistryFood;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
@@ -48,7 +44,7 @@ public class PluginFood extends BlankForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
LiquidRegistryHelper.registerLiquidContainer(Fluids.SHORT_MEAD, Constants.BUCKET_VOLUME, items.beverage.get(EnumBeverage.MEAD_SHORT, 1), new ItemStack(Items.GLASS_BOTTLE));
|
||||
// LiquidRegistryHelper.registerLiquidContainer(Fluids.SHORT_MEAD, Constants.BUCKET_VOLUME, items.beverage.get(EnumBeverage.MEAD_SHORT, 1), new ItemStack(Items.GLASS_BOTTLE));
|
||||
|
||||
ItemRegistryApiculture beeItems = PluginApiculture.items;
|
||||
if (beeItems != null) {
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.greenhouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
@@ -45,8 +45,8 @@ public class FakeGreenhouseState implements IGreenhouseState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IInternalBlock> getInternalBlocks() {
|
||||
return Collections.emptyList();
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.core.multiblock.IMultiblockControllerInternal;
|
||||
import forestry.core.multiblock.MultiblockRegistry;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
import forestry.greenhouse.multiblock.InternalBlockCheck;
|
||||
|
||||
public class GreenhouseHelper implements IGreenhouseHelper {
|
||||
|
||||
@@ -28,7 +29,7 @@ public class GreenhouseHelper implements IGreenhouseHelper {
|
||||
for (IMultiblockControllerInternal controllerInternal : MultiblockRegistry.getControllersFromWorld(world)) {
|
||||
if (controllerInternal instanceof IGreenhouseControllerInternal) {
|
||||
if (controllerInternal.isAssembled()) {
|
||||
if (isPosiotionInGreenhouse((IGreenhouseControllerInternal) controllerInternal, pos)) {
|
||||
if (isPositionInGreenhouse((IGreenhouseControllerInternal) controllerInternal, pos)) {
|
||||
return ((IGreenhouseControllerInternal) controllerInternal).createState();
|
||||
}
|
||||
}
|
||||
@@ -38,13 +39,9 @@ public class GreenhouseHelper implements IGreenhouseHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean isPosiotionInGreenhouse(IGreenhouseControllerInternal controller, BlockPos pos) {
|
||||
for (IInternalBlock internalBlock : controller.getInternalBlocks()) {
|
||||
if (internalBlock.getPos().equals(pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
private static boolean isPositionInGreenhouse(IGreenhouseControllerInternal controller, BlockPos pos) {
|
||||
IInternalBlock checkBlock = new InternalBlockCheck(pos);
|
||||
return controller.getInternalBlocks().contains(checkBlock);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
package forestry.greenhouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
@@ -24,10 +24,10 @@ public final class GreenhouseState implements IGreenhouseState {
|
||||
|
||||
private final float humidity;
|
||||
private final float temperature;
|
||||
private final List<IInternalBlock> internalBlocks;
|
||||
private final Set<IInternalBlock> internalBlocks;
|
||||
private final Collection<IMultiblockComponent> greenhouseComponents;
|
||||
|
||||
public GreenhouseState(float humidity, float temperature, List<IInternalBlock> internalBlocks, Collection<IMultiblockComponent> greenhouseComponents) {
|
||||
public GreenhouseState(float humidity, float temperature, Set<IInternalBlock> internalBlocks, Collection<IMultiblockComponent> greenhouseComponents) {
|
||||
this.humidity = humidity;
|
||||
this.temperature = temperature;
|
||||
this.internalBlocks = internalBlocks;
|
||||
@@ -59,7 +59,7 @@ public final class GreenhouseState implements IGreenhouseState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IInternalBlock> getInternalBlocks() {
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return internalBlocks;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ package forestry.greenhouse.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.TankManager;
|
||||
@@ -30,8 +31,8 @@ public class InventoryGreenhouse extends InventoryAdapterRestricted {
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return greenhouseController.getTankManager().accepts(fluid);
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return greenhouseController.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
|
||||
public void drainCan(TankManager tankManager) {
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.greenhouse.multiblock;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -97,8 +98,8 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IInternalBlock> getInternalBlocks() {
|
||||
return Collections.emptyList();
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,6 +64,7 @@ import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
import forestry.core.utils.CamouflageUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.energy.EnergyManager;
|
||||
@@ -76,7 +77,7 @@ import forestry.greenhouse.tiles.TileGreenhouseSprinkler;
|
||||
|
||||
public class GreenhouseController extends RectangularMultiblockControllerBase implements IGreenhouseControllerInternal, ILiquidTankTile {
|
||||
|
||||
private final List<IInternalBlock> internalBlocks = new ArrayList<>();
|
||||
private final Set<IInternalBlock> internalBlocks = new HashSet<>();
|
||||
private final Set<IGreenhouseComponent.Listener> listenerComponents = new HashSet<>();
|
||||
private final Set<IGreenhouseComponent.Climatiser> climatiserComponents = new HashSet<>();
|
||||
private final Set<IGreenhouseComponent.Active> activeComponents = new HashSet<>();
|
||||
@@ -100,7 +101,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
this.tempChange = 0;
|
||||
this.humidChange = 0;
|
||||
|
||||
this.resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
this.resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
|
||||
this.tankManager = new TankManager(this, resourceTank);
|
||||
this.energyManager = new EnergyManager(2000, 100000);
|
||||
this.inventory = new InventoryGreenhouse(this);
|
||||
@@ -288,35 +289,52 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
/* CAMOUFLAGE */
|
||||
@Override
|
||||
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
|
||||
ItemStack oldCamouflageBlock;
|
||||
switch (type) {
|
||||
case DEFAULT:
|
||||
camouflagePlainBlock = camouflageBlock;
|
||||
break;
|
||||
case GLASS:
|
||||
camouflageGlassBlock = camouflageBlock;
|
||||
break;
|
||||
case DOOR:
|
||||
camouflageDoorBlock = camouflageBlock;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
case DEFAULT:
|
||||
oldCamouflageBlock = camouflagePlainBlock;
|
||||
break;
|
||||
case GLASS:
|
||||
oldCamouflageBlock = camouflageGlassBlock;
|
||||
break;
|
||||
case DOOR:
|
||||
oldCamouflageBlock = camouflageDoorBlock;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
for (IMultiblockComponent comp : connectedParts) {
|
||||
if (comp instanceof ICamouflagedTile) {
|
||||
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
|
||||
if (camBlock.getCamouflageType() == type) {
|
||||
worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates());
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, oldCamouflageBlock)){
|
||||
switch (type) {
|
||||
case DEFAULT:
|
||||
camouflagePlainBlock = camouflageBlock;
|
||||
break;
|
||||
case GLASS:
|
||||
camouflageGlassBlock = camouflageBlock;
|
||||
break;
|
||||
case DOOR:
|
||||
camouflageDoorBlock = camouflageBlock;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
for (IMultiblockComponent comp : connectedParts) {
|
||||
if (comp instanceof ICamouflagedTile) {
|
||||
ICamouflagedTile camBlock = (ICamouflagedTile) comp;
|
||||
if (camBlock.getCamouflageType() == type) {
|
||||
worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates());
|
||||
}
|
||||
}
|
||||
}
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
|
||||
}
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true));
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(createState(), null, this, type));
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(createState(), null, this, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -726,7 +744,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IInternalBlock> getInternalBlocks() {
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return internalBlocks;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.greenhouse.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
@@ -53,7 +53,7 @@ public interface IGreenhouseControllerInternal extends IGreenhouseController, IM
|
||||
IGreenhouseState createState();
|
||||
|
||||
/**
|
||||
* @return A list with all internal block's of the greenhouse.
|
||||
* @return All internal blocks of the greenhouse.
|
||||
*/
|
||||
List<IInternalBlock> getInternalBlocks();
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
}
|
||||
@@ -74,4 +74,9 @@ public class InternalBlock implements IInternalBlock {
|
||||
IInternalBlock internalBlock = (IInternalBlock) obj;
|
||||
return internalBlock.getPos().equals(getPos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return pos.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package forestry.greenhouse.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.greenhouse.IInternalBlockFace;
|
||||
|
||||
/**
|
||||
* Used to check if a blockPos is in a collection of IInternalBlock
|
||||
*/
|
||||
public class InternalBlockCheck implements IInternalBlock {
|
||||
private final BlockPos pos;
|
||||
|
||||
public InternalBlockCheck(BlockPos pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IInternalBlock getRoot() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<IInternalBlockFace> getFaces() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof IInternalBlock)) {
|
||||
return false;
|
||||
}
|
||||
IInternalBlock internalBlock = (IInternalBlock) obj;
|
||||
return internalBlock.getPos().equals(getPos());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return pos.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.ITitled;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.gui.ContainerGreenhouse;
|
||||
@@ -93,15 +94,17 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
|
||||
@Override
|
||||
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
|
||||
this.camouflageBlock = camouflageBlock;
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
|
||||
this.camouflageBlock = camouflageBlock;
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TileGreenhouseControl extends TileGreenhouse implements IGreenhouse
|
||||
|
||||
@Override
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork) {
|
||||
return canWork && hasRedstoneSignal();
|
||||
return canWork && !hasRedstoneSignal();
|
||||
}
|
||||
|
||||
private boolean hasRedstoneSignal() {
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@@ -47,6 +48,7 @@ import forestry.core.config.Config;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
@@ -140,15 +142,17 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
/* CONSTRUCTION MATERIAL */
|
||||
@Override
|
||||
public void setCamouflageBlock(EnumCamouflageType type, ItemStack camouflageBlock) {
|
||||
this.camouflageBlock = camouflageBlock;
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
if(!ItemStackUtil.isIdenticalItem(camouflageBlock, this.camouflageBlock)){
|
||||
this.camouflageBlock = camouflageBlock;
|
||||
|
||||
if (worldObj != null) {
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -301,16 +305,20 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nonnull EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && getOutwardsTile() != null) {
|
||||
return getOutwardsTile().getCapability(capability, facing);
|
||||
if(getOutwardsTile() != null){
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return getOutwardsTile().getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nonnull EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && getOutwardsTile() != null) {
|
||||
return getOutwardsTile().hasCapability(capability, facing);
|
||||
if(getOutwardsTile() != null){
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return getOutwardsTile().hasCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@@ -14,50 +14,35 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
|
||||
public class TileGreenhouseValve extends TileGreenhouse implements ILiquidTankTile, IFluidHandler {
|
||||
|
||||
/* ILIQUIDTANKCONTAINER */
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
return getTankManager().fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
return getTankManager().drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
return getTankManager().drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
return getTankManager().canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
return getTankManager().canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return getTankManager().getTankInfo(from);
|
||||
}
|
||||
|
||||
public class TileGreenhouseValve extends TileGreenhouse implements ILiquidTankTile {
|
||||
@Nonnull
|
||||
@Override
|
||||
public ITankManager getTankManager() {
|
||||
return getMultiblockLogic().getController().getTankManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(getTankManager());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -191,6 +191,11 @@ public class TileCocoon extends TileEntity implements IStreamable, IOwnable, IBu
|
||||
}
|
||||
|
||||
public void onBlockTick() {
|
||||
if (caterpillar == null) {
|
||||
worldObj.setBlockToAir(getPos());
|
||||
return;
|
||||
}
|
||||
|
||||
maturationTime++;
|
||||
|
||||
IButterflyGenome caterpillarGenome = caterpillar.getGenome();
|
||||
|
||||
Reference in new issue
Block a user