Inital Fluid system update, untested. Still in progress.

This commit is contained in:
Lex Manos 2014-01-29 18:34:23 -08:00
parent 51b008c391
commit 2b9a2b5c1a
14 changed files with 295 additions and 343 deletions

View File

@ -1,6 +1,9 @@
package net.minecraftforge.common.network;
import net.minecraftforge.fluids.FluidRegistry;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
@ -9,7 +12,7 @@ public class FluidIdRegistryMessageHandler extends SimpleChannelInboundHandler<F
@Override
protected void channelRead0(ChannelHandlerContext ctx, ForgeMessage.FluidIdMapMessage msg) throws Exception
{
// Do something with the message
FluidRegistry.initFluidIDs(msg.fluidIds);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception

View File

@ -1,8 +1,13 @@
package net.minecraftforge.common.network;
import java.util.Map;
import net.minecraftforge.fluids.FluidRegistry;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
public abstract class ForgeMessage {
@ -39,27 +44,24 @@ public abstract class ForgeMessage {
@Override
void toBytes(ByteBuf bytes)
{
/*
bytes.writeInt(FluidRegistry.maxID);
for (Map.Entry<String, Integer> entry : FluidRegistry.fluidIDs.entrySet())
Map<String, Integer> ids = FluidRegistry.getRegisteredFluidIDs();
bytes.writeInt(ids.size());
for (Map.Entry<String, Integer> entry : ids.entrySet())
{
ByteBufUtils.writeUTF8String(bytes,entry.getKey());
bytes.writeInt(entry.getValue());
}
*/
}
@Override
void fromBytes(ByteBuf bytes)
{
/*
int listSize = bytes.readInt();
for (int i = 0; i < listSize; i++) {
String fluidName = ByteBufUtils.readUTF8String(bytes);
int fluidId = bytes.readInt();
fluidIds.put(fluidName, fluidId);
}
*/
}
}

View File

@ -4,9 +4,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
@ -23,18 +27,17 @@ import net.minecraft.world.World;
@SuppressWarnings("unused")
public abstract class BlockFluidBase extends Block implements IFluidBlock
{
/*
protected final static Map<Integer, Boolean> defaultDisplacementIds = new HashMap<Integer, Boolean>();
protected final static Map<Block, Boolean> defaultDisplacements = Maps.newHashMap();
static
{
defaultDisplacementIds.put(Block.doorWood.blockID, false);
defaultDisplacementIds.put(Block.doorIron.blockID, false);
defaultDisplacementIds.put(Block.signPost.blockID, false);
defaultDisplacementIds.put(Block.signWall.blockID, false);
defaultDisplacementIds.put(Block.reed.blockID, false);
defaultDisplacements.put(Blocks.wooden_door, false);
defaultDisplacements.put(Blocks.iron_door, false);
defaultDisplacements.put(Blocks.standing_sign, false);
defaultDisplacements.put(Blocks.wall_sign, false);
defaultDisplacements.put(Blocks.reeds, false);
}
protected Map<Integer, Boolean> displacementIds = new HashMap<Integer, Boolean>();
protected Map<Block, Boolean> displacements = Maps.newHashMap();
protected int quantaPerBlock = 8;
protected float quantaPerBlockFloat = 8F;
@ -47,14 +50,13 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
protected int maxScaledLight = 0;
protected final String fluidName;
*/
public BlockFluidBase(int id, Fluid fluid, Material material)
public BlockFluidBase(Fluid fluid, Material material)
{
super(material);
/*
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
this.setTickRandomly(true);
this.disableStats();
this.func_149676_a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
this.func_149675_a(true);
this.func_149649_H();
this.fluidName = fluid.getName();
this.density = fluid.density;
@ -62,12 +64,11 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
this.maxScaledLight = fluid.luminosity;
this.tickRate = fluid.viscosity / 200;
this.densityDir = fluid.density > 0 ? -1 : 1;
fluid.setBlockID(id);
fluid.setBlock(this);
displacementIds.putAll(defaultDisplacementIds);
*/
displacements.putAll(defaultDisplacements);
}
/*
public BlockFluidBase setQuantaPerBlock(int quantaPerBlock)
{
if (quantaPerBlock > 16 || quantaPerBlock < 1) quantaPerBlock = 8;
@ -111,25 +112,25 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
/**
* Returns true if the block at (x, y, z) is displaceable. Does not displace the block.
* /
*/
public boolean canDisplace(IBlockAccess world, int x, int y, int z)
{
if (world.isAirBlock(x, y, z)) return true;
if (world.func_147439_a(x, y, z).isAir(world, x, y, z)) return true;
int bId = world.getBlockId(x, y, z);
Block block = world.func_147439_a(x, y, z);
if (bId == blockID)
if (block == this)
{
return false;
}
if (displacementIds.containsKey(bId))
if (displacements.containsKey(block))
{
return displacementIds.get(bId);
return displacements.get(block);
}
Material material = Block.blocksList[bId].blockMaterial;
if (material.blocksMovement() || material == Material.portal)
Material material = block.func_149688_o();
if (material.blocksMovement() || material == Material.field_151567_E)
{
return false;
}
@ -152,32 +153,32 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
/**
* Attempt to displace the block at (x, y, z), return true if it was displaced.
* /
*/
public boolean displaceIfPossible(World world, int x, int y, int z)
{
if (world.isAirBlock(x, y, z))
if (world.func_147439_a(x, y, z).isAir(world, x, y, z))
{
return true;
}
int bId = world.getBlockId(x, y, z);
if (bId == blockID)
Block block = world.func_147439_a(x, y, z);
if (block == this)
{
return false;
}
if (displacementIds.containsKey(bId))
if (displacements.containsKey(block))
{
if (displacementIds.get(bId))
if (displacements.get(block))
{
Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
block.func_149697_b(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
return true;
}
return false;
}
Material material = Block.blocksList[bId].blockMaterial;
if (material.blocksMovement() || material == Material.portal)
Material material = block.func_149688_o();
if (material.blocksMovement() || material == Material.field_151567_E)
{
return false;
}
@ -185,7 +186,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
int density = getDensity(world, x, y, z);
if (density == Integer.MAX_VALUE)
{
Block.blocksList[bId].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
block.func_149697_b(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
return true;
}
@ -202,62 +203,62 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
public abstract int getQuantaValue(IBlockAccess world, int x, int y, int z);
@Override
public abstract boolean canCollideCheck(int meta, boolean fullHit);
public abstract boolean func_149678_a(int meta, boolean fullHit);
public abstract int getMaxRenderHeightMeta();
/* BLOCK FUNCTIONS * /
/* BLOCK FUNCTIONS */
@Override
public void onBlockAdded(World world, int x, int y, int z)
public void func_149726_b(World world, int x, int y, int z)
{
world.scheduleBlockUpdate(x, y, z, blockID, tickRate);
world.func_147464_a(x, y, z, this, tickRate);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockId)
public void func_149695_a(World world, int x, int y, int z, Block block)
{
world.scheduleBlockUpdate(x, y, z, blockID, tickRate);
world.func_147464_a(x, y, z, this, tickRate);
}
// Used to prevent updates on chunk generation
@Override
public boolean func_82506_l()
public boolean func_149698_L()
{
return false;
}
@Override
public boolean getBlocksMovement(IBlockAccess world, int x, int y, int z)
public boolean func_149655_b(IBlockAccess world, int x, int y, int z)
{
return true;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
public AxisAlignedBB func_149668_a(World world, int x, int y, int z)
{
return null;
}
@Override
public int idDropped(int par1, Random par2Random, int par3)
public Item func_149650_a(int par1, Random par2Random, int par3)
{
return null;
}
@Override
public int func_149745_a(Random par1Random)
{
return 0;
}
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
@Override
public int tickRate(World world)
public int func_149738_a(World world)
{
return tickRate;
}
@Override
public void velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec)
public void func_149640_a(World world, int x, int y, int z, Entity entity, Vec3 vec)
{
if (densityDir > 0) return;
Vec3 vec_flow = this.getFlowVector(world, x, y, z);
@ -278,33 +279,35 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
}
@Override
public int getRenderType()
public int func_149645_b()
{
return FluidRegistry.renderIdFluid;
}
@Override
public boolean isOpaqueCube()
public boolean func_149662_c()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
public boolean func_149686_d()
{
return false;
}
/* Never used...?
@Override
public float getBlockBrightness(IBlockAccess world, int x, int y, int z)
public float getBlockBrightness(World world, int x, int y, int z)
{
float lightThis = world.getLightBrightness(x, y, z);
float lightUp = world.getLightBrightness(x, y + 1, z);
return lightThis > lightUp ? lightThis : lightUp;
}
*/
@Override
public int getMixedBrightnessForBlock(IBlockAccess world, int x, int y, int z)
public int func_149677_c(IBlockAccess world, int x, int y, int z)
{
int lightThis = world.getLightBrightnessForSkyBlocks(x, y, z, 0);
int lightUp = world.getLightBrightnessForSkyBlocks(x, y + 1, z, 0);
@ -317,26 +320,26 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
}
@Override
public int getRenderBlockPass()
public int func_149701_w()
{
return renderPass;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side)
public boolean func_149646_a(IBlockAccess world, int x, int y, int z, int side)
{
if (world.getBlockId(x, y, z) != blockID)
Block block = world.func_147439_a(x, y, z);
if (block != this)
{
return !world.isBlockOpaqueCube(x, y, z);
return !block.func_149662_c();
}
Material mat = world.getBlockMaterial(x, y, z);
return mat == this.blockMaterial ? false : super.shouldSideBeRendered(world, x, y, z, side);
return block.func_149688_o() == this.func_149688_o() ? false : super.func_149646_a(world, x, y, z, side);
}
/* FLUID FUNCTIONS * /
/* FLUID FUNCTIONS */
public static final int getDensity(IBlockAccess world, int x, int y, int z)
{
Block block = Block.blocksList[world.getBlockId(x, y, z)];
Block block = world.func_147439_a(x, y, z);
if (!(block instanceof BlockFluidBase))
{
return Integer.MAX_VALUE;
@ -346,7 +349,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
public static final int getTemperature(IBlockAccess world, int x, int y, int z)
{
Block block = Block.blocksList[world.getBlockId(x, y, z)];
Block block = world.func_147439_a(x, y, z);
if (!(block instanceof BlockFluidBase))
{
return Integer.MAX_VALUE;
@ -356,8 +359,8 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
public static double getFlowDirection(IBlockAccess world, int x, int y, int z)
{
Block block = Block.blocksList[world.getBlockId(x, y, z)];
if (!world.getBlockMaterial(x, y, z).isLiquid())
Block block = world.func_147439_a(x, y, z);
if (!block.func_149688_o().isLiquid())
{
return -1000.0;
}
@ -412,7 +415,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
int otherDecay = quantaPerBlock - getQuantaValue(world, x2, y, z2);
if (otherDecay >= quantaPerBlock)
{
if (!world.getBlockMaterial(x2, y, z2).blocksMovement())
if (!world.func_147439_a(x2, y, z2).func_149688_o().blocksMovement())
{
otherDecay = quantaPerBlock - getQuantaValue(world, x2, y - 1, z2);
if (otherDecay >= 0)
@ -429,17 +432,17 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
}
}
if (world.getBlockId(x, y + 1, z) == blockID)
if (world.func_147439_a(x, y + 1, z) == this)
{
boolean flag =
isBlockSolid(world, x, y, z - 1, 2) ||
isBlockSolid(world, x, y, z + 1, 3) ||
isBlockSolid(world, x - 1, y, z, 4) ||
isBlockSolid(world, x + 1, y, z, 5) ||
isBlockSolid(world, x, y + 1, z - 1, 2) ||
isBlockSolid(world, x, y + 1, z + 1, 3) ||
isBlockSolid(world, x - 1, y + 1, z, 4) ||
isBlockSolid(world, x + 1, y + 1, z, 5);
func_149747_d(world, x, y, z - 1, 2) ||
func_149747_d(world, x, y, z + 1, 3) ||
func_149747_d(world, x - 1, y, z, 4) ||
func_149747_d(world, x + 1, y, z, 5) ||
func_149747_d(world, x, y + 1, z - 1, 2) ||
func_149747_d(world, x, y + 1, z + 1, 3) ||
func_149747_d(world, x - 1, y + 1, z, 4) ||
func_149747_d(world, x + 1, y + 1, z, 5);
if (flag)
{
@ -450,7 +453,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
return vec;
}
/* IFluidBlock * /
/* IFluidBlock */
@Override
public Fluid getFluid()
{
@ -465,5 +468,4 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
if (remaining > 1) remaining = 1.0f;
return remaining * (density > 0 ? 1 : -1);
}
*/
}

View File

@ -4,6 +4,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@ -15,21 +16,18 @@ import net.minecraft.world.World;
* @author King Lemming
*
*/
@SuppressWarnings("unused")
public class BlockFluidClassic extends BlockFluidBase
{
/*
protected boolean[] isOptimalFlowDirection = new boolean[4];
protected int[] flowCost = new int[4];
protected FluidStack stack;
*/
public BlockFluidClassic(int id, Fluid fluid, Material material)
public BlockFluidClassic(Fluid fluid, Material material)
{
super(id, fluid, material);
//stack = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME);
super(fluid, material);
stack = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME);
}
/*
public BlockFluidClassic setFluidStack(FluidStack stack)
{
this.stack = stack;
@ -45,12 +43,12 @@ public class BlockFluidClassic extends BlockFluidBase
@Override
public int getQuantaValue(IBlockAccess world, int x, int y, int z)
{
if (world.getBlockId(x, y, z) == 0)
if (world.func_147439_a(x, y, z) == Blocks.air)
{
return 0;
}
if (world.getBlockId(x, y, z) != blockID)
if (world.func_147439_a(x, y, z) != this)
{
return -1;
}
@ -60,7 +58,7 @@ public class BlockFluidClassic extends BlockFluidBase
}
@Override
public boolean canCollideCheck(int meta, boolean fullHit)
public boolean func_149678_a(int meta, boolean fullHit)
{
return fullHit && meta == 0;
}
@ -83,7 +81,7 @@ public class BlockFluidClassic extends BlockFluidBase
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand)
public void func_149674_a(World world, int x, int y, int z, Random rand)
{
int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z);
int expQuanta = -101;
@ -93,11 +91,11 @@ public class BlockFluidClassic extends BlockFluidBase
{
int y2 = y - densityDir;
if (world.getBlockId(x, y2, z ) == blockID ||
world.getBlockId(x - 1, y2, z ) == blockID ||
world.getBlockId(x + 1, y2, z ) == blockID ||
world.getBlockId(x, y2, z - 1) == blockID ||
world.getBlockId(x, y2, z + 1) == blockID)
if (world.func_147439_a(x, y2, z ) == this ||
world.func_147439_a(x - 1, y2, z ) == this ||
world.func_147439_a(x + 1, y2, z ) == this ||
world.func_147439_a(x, y2, z - 1) == this ||
world.func_147439_a(x, y2, z + 1) == this)
{
expQuanta = quantaPerBlock - 1;
}
@ -119,13 +117,13 @@ public class BlockFluidClassic extends BlockFluidBase
if (expQuanta <= 0)
{
world.setBlockToAir(x, y, z);
world.func_147449_b(x, y, z, Blocks.air);
}
else
{
world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3);
world.scheduleBlockUpdate(x, y, z, blockID, tickRate);
world.notifyBlocksOfNeighborChange(x, y, z, blockID);
world.func_147464_a(x, y, z, this, tickRate);
world.func_147459_d(x, y, z, this);
}
}
}
@ -151,7 +149,7 @@ public class BlockFluidClassic extends BlockFluidBase
if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z))
{
if (world.getBlockId(x, y - densityDir, z) == blockID)
if (world.func_147439_a(x, y - densityDir, z) == this)
{
flowMeta = 1;
}
@ -166,13 +164,13 @@ public class BlockFluidClassic extends BlockFluidBase
public boolean isFlowingVertically(IBlockAccess world, int x, int y, int z)
{
return world.getBlockId(x, y + densityDir, z) == blockID ||
(world.getBlockId(x, y, z) == blockID && canFlowInto(world, x, y + densityDir, z));
return world.func_147439_a(x, y + densityDir, z) == this ||
(world.func_147439_a(x, y, z) == this && canFlowInto(world, x, y + densityDir, z));
}
public boolean isSourceBlock(IBlockAccess world, int x, int y, int z)
{
return world.getBlockId(x, y, z) == blockID && world.getBlockMetadata(x, y, z) == 0;
return world.func_147439_a(x, y, z) == this && world.getBlockMetadata(x, y, z) == 0;
}
protected boolean[] getOptimalFlowDirections(World world, int x, int y, int z)
@ -277,30 +275,30 @@ public class BlockFluidClassic extends BlockFluidBase
if (meta < 0) return;
if (displaceIfPossible(world, x, y, z))
{
world.setBlock(x, y, z, this.blockID, meta, 3);
world.func_147465_d(x, y, z, this, meta, 3);
}
}
protected boolean canFlowInto(IBlockAccess world, int x, int y, int z)
{
if (world.isAirBlock(x, y, z)) return true;
if (world.func_147439_a(x, y, z).isAir(world, x, y, z)) return true;
int bId = world.getBlockId(x, y, z);
if (bId == blockID)
Block block = world.func_147439_a(x, y, z);
if (block == this)
{
return true;
}
if (displacementIds.containsKey(bId))
if (displacements.containsKey(block))
{
return displacementIds.get(bId);
return displacements.get(block);
}
Material material = Block.blocksList[bId].blockMaterial;
Material material = block.func_149688_o();
if (material.blocksMovement() ||
material == Material.water ||
material == Material.lava ||
material == Material.portal)
material == Material.field_151586_h ||
material == Material.field_151587_i ||
material == Material.field_151567_E)
{
return false;
}
@ -330,12 +328,11 @@ public class BlockFluidClassic extends BlockFluidBase
}
return quantaRemaining >= compare ? quantaRemaining : compare;
}
*/
/* IFluidBlock */
@Override
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
{
/*
if (!isSourceBlock(world, x, y, z))
{
return null;
@ -343,12 +340,10 @@ public class BlockFluidClassic extends BlockFluidBase
if (doDrain)
{
world.setBlockToAir(x, y, z);
world.func_147449_b(x, y, z, Blocks.air);
}
return stack.copy();
*/
return null;
}
@Override

View File

@ -3,8 +3,8 @@ package net.minecraftforge.fluids;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@ -16,23 +16,22 @@ import net.minecraft.world.World;
* @author OvermindDL1, KingLemming
*
*/
@SuppressWarnings("unused")
public class BlockFluidFinite extends BlockFluidBase
{
public BlockFluidFinite(int id, Fluid fluid, Material material)
public BlockFluidFinite(Fluid fluid, Material material)
{
super(id, fluid, material);
super(fluid, material);
}
/*
@Override
public int getQuantaValue(IBlockAccess world, int x, int y, int z)
{
if (world.isAirBlock(x, y, z))
if (world.func_147439_a(x, y, z).isAir(world, x, y, z))
{
return 0;
}
if (world.getBlockId(x, y, z) != blockID)
if (world.func_147439_a(x, y, z) != this)
{
return -1;
}
@ -42,7 +41,7 @@ public class BlockFluidFinite extends BlockFluidBase
}
@Override
public boolean canCollideCheck(int meta, boolean fullHit)
public boolean func_149678_a(int meta, boolean fullHit)
{
return fullHit && meta == quantaPerBlock - 1;
}
@ -54,7 +53,7 @@ public class BlockFluidFinite extends BlockFluidBase
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand)
public void func_149674_a(World world, int x, int y, int z, Random rand)
{
boolean changed = false;
int quantaRemaining = world.getBlockMetadata(x, y, z) + 1;
@ -83,10 +82,10 @@ public class BlockFluidFinite extends BlockFluidBase
// Flow out if possible
int lowerthan = quantaRemaining - 1;
if (displaceIfPossible(world, x, y, z - 1)) world.setBlock(x, y, z - 1, 0);
if (displaceIfPossible(world, x, y, z + 1)) world.setBlock(x, y, z + 1, 0);
if (displaceIfPossible(world, x - 1, y, z )) world.setBlock(x - 1, y, z, 0);
if (displaceIfPossible(world, x + 1, y, z )) world.setBlock(x + 1, y, z, 0);
if (displaceIfPossible(world, x, y, z - 1)) world.func_147449_b(x, y, z - 1, Blocks.air);
if (displaceIfPossible(world, x, y, z + 1)) world.func_147449_b(x, y, z + 1, Blocks.air);
if (displaceIfPossible(world, x - 1, y, z )) world.func_147449_b(x - 1, y, z, Blocks.air);
if (displaceIfPossible(world, x + 1, y, z )) world.func_147449_b(x + 1, y, z, Blocks.air);
int north = getQuantaValueBelow(world, x, y, z - 1, lowerthan);
int south = getQuantaValueBelow(world, x, y, z + 1, lowerthan);
int west = getQuantaValueBelow(world, x - 1, y, z, lowerthan);
@ -142,13 +141,13 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (newnorth == 0)
{
world.setBlock(x, y, z - 1, 0);
world.func_147449_b(x, y, z - 1, Blocks.air);
}
else
{
world.setBlock(x, y, z - 1, blockID, newnorth - 1, 2);
world.func_147465_d(x, y, z - 1, this, newnorth - 1, 2);
}
world.scheduleBlockUpdate(x, y, z - 1, blockID, tickRate);
world.func_147464_a(x, y, z - 1, this, tickRate);
}
--count;
}
@ -166,13 +165,13 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (newsouth == 0)
{
world.setBlock(x, y, z + 1, 0);
world.func_147449_b(x, y, z + 1, Blocks.air);
}
else
{
world.setBlock(x, y, z + 1, blockID, newsouth - 1, 2);
world.func_147465_d(x, y, z + 1, this, newsouth - 1, 2);
}
world.scheduleBlockUpdate(x, y, z + 1, blockID, tickRate);
world.func_147464_a(x, y, z + 1, this, tickRate);
}
--count;
}
@ -189,13 +188,13 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (newwest == 0)
{
world.setBlock(x - 1, y, z, 0);
world.func_147449_b(x - 1, y, z, Blocks.air);
}
else
{
world.setBlock(x - 1, y, z, blockID, newwest - 1, 2);
world.func_147465_d(x - 1, y, z, this, newwest - 1, 2);
}
world.scheduleBlockUpdate(x - 1, y, z, blockID, tickRate);
world.func_147464_a(x - 1, y, z, this, tickRate);
}
--count;
}
@ -213,13 +212,13 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (neweast == 0)
{
world.setBlock(x + 1, y, z, 0);
world.func_147449_b(x + 1, y, z, Blocks.air);
}
else
{
world.setBlock(x + 1, y, z, blockID, neweast - 1, 2);
world.func_147465_d(x + 1, y, z, this, neweast - 1, 2);
}
world.scheduleBlockUpdate(x + 1, y, z, blockID, tickRate);
world.func_147464_a(x + 1, y, z, this, tickRate);
}
--count;
}
@ -236,7 +235,7 @@ public class BlockFluidFinite extends BlockFluidBase
int otherY = y + densityDir;
if (otherY < 0 || otherY >= world.getHeight())
{
world.setBlockToAir(x, y, z);
world.func_147449_b(x, y, z, Blocks.air);
return 0;
}
@ -246,15 +245,15 @@ public class BlockFluidFinite extends BlockFluidBase
amt += amtToInput;
if (amt > quantaPerBlock)
{
world.setBlock(x, otherY, z, blockID, quantaPerBlock - 1, 3);
world.scheduleBlockUpdate(x, otherY, z, blockID, tickRate);
world.func_147465_d(x, otherY, z, this, quantaPerBlock - 1, 3);
world.func_147464_a(x, otherY, z, this, tickRate);
return amt - quantaPerBlock;
}
else if (amt > 0)
{
world.setBlock(x, otherY, z, blockID, amt - 1, 3);
world.scheduleBlockUpdate(x, otherY, z, blockID, tickRate);
world.setBlockToAir(x, y, z);
world.func_147465_d(x, otherY, z, this, amt - 1, 3);
world.func_147464_a(x, otherY, z, this, tickRate);
world.func_147449_b(x, y, z, Blocks.air);
return 0;
}
return amtToInput;
@ -266,9 +265,9 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (displaceIfPossible(world, x, otherY, z))
{
world.setBlock(x, otherY, z, blockID, amtToInput - 1, 3);
world.scheduleBlockUpdate(x, otherY, z, blockID, tickRate);
world.setBlockToAir(x, y, z);
world.func_147465_d(x, otherY, z, this, amtToInput - 1, 3);
world.func_147464_a(x, otherY, z, this, tickRate);
world.func_147449_b(x, y, z, Blocks.air);
return 0;
}
else
@ -281,13 +280,12 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (density_other < density) // then swap
{
int bId = world.getBlockId(x, otherY, z);
BlockFluidBase block = (BlockFluidBase) Block.blocksList[bId];
BlockFluidBase block = (BlockFluidBase)world.func_147439_a(x, otherY, z);
int otherData = world.getBlockMetadata(x, otherY, z);
world.setBlock(x, otherY, z, blockID, amtToInput - 1, 3);
world.setBlock(x, y, z, bId, otherData, 3);
world.scheduleBlockUpdate(x, otherY, z, blockID, tickRate);
world.scheduleBlockUpdate(x, y, z, bId, block.tickRate(world));
world.func_147465_d(x, otherY, z, this, amtToInput - 1, 3);
world.func_147465_d(x, y, z, block, otherData, 3);
world.func_147464_a(x, otherY, z, this, tickRate);
world.func_147464_a(x, y, z, block, block.func_149738_a(world));
return 0;
}
}
@ -295,13 +293,12 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (density_other > density)
{
int bId = world.getBlockId(x, otherY, z);
BlockFluidBase block = (BlockFluidBase) Block.blocksList[bId];
BlockFluidBase block = (BlockFluidBase)world.func_147439_a(x, otherY, z);
int otherData = world.getBlockMetadata(x, otherY, z);
world.setBlock(x, otherY, z, blockID, amtToInput - 1, 3);
world.setBlock(x, y, z, bId, otherData, 3);
world.scheduleBlockUpdate(x, otherY, z, blockID, tickRate);
world.scheduleBlockUpdate(x, y, z, bId, block.tickRate(world));
world.func_147465_d(x, otherY, z, this, amtToInput - 1, 3);
world.func_147465_d(x, y, z, block, otherData, 3);
world.func_147464_a(x, otherY, z, this, tickRate);
world.func_147464_a(x, y, z, block, block.func_149738_a(world));
return 0;
}
}

View File

@ -172,12 +172,10 @@ public class Fluid
return this.fluidName;
}
/*
public final int getID()
{
return FluidRegistry.getFluidID(this.fluidName);
}
*/
public final Block getBlock()
{

View File

@ -8,6 +8,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@ -26,10 +29,37 @@ import net.minecraftforge.common.MinecraftForge;
@SuppressWarnings("unused")
public abstract class FluidContainerRegistry
{
/*
private static Map<List, FluidContainerData> containerFluidMap = new HashMap();
private static Map<List, FluidContainerData> filledContainerMap = new HashMap();
private static Set<List> emptyContainers = new HashSet();
// Holder object that implements HashCode for an ItemStack,
// the local maps are not guaranteed to have the same internal generic structure,
// but the external interface for checking ItemStacks will still exist.
private static class ContainerKey
{
ItemStack container;
FluidStack fluid;
private ContainerKey(ItemStack container)
{
this.container = container;
}
private ContainerKey(ItemStack container, FluidStack fluid)
{
this(container);
this.fluid = fluid;
}
@Override
public int hashCode()
{
int code = 1;
code = 31*code + container.hashCode();
code = 31*code + container.getItemDamage();
if (fluid != null)
code = 31*code + fluid.fluidID;
return code;
}
}
private static Map<ContainerKey, FluidContainerData> containerFluidMap = Maps.newHashMap();
private static Map<ContainerKey, FluidContainerData> filledContainerMap = Maps.newHashMap();
private static Set<ContainerKey> emptyContainers = Sets.newHashSet();
public static final int BUCKET_VOLUME = 1000;
public static final ItemStack EMPTY_BUCKET = new ItemStack(Items.bucket);
@ -55,7 +85,7 @@ public abstract class FluidContainerRegistry
* @param emptyContainer
* ItemStack representing the container when it is empty.
* @return True if container was successfully registered; false if it already is.
* /
*/
public static boolean registerFluidContainer(FluidStack stack, ItemStack filledContainer, ItemStack emptyContainer)
{
return registerFluidContainer(new FluidContainerData(stack, filledContainer, emptyContainer));
@ -72,7 +102,7 @@ public abstract class FluidContainerRegistry
* @param emptyContainer
* ItemStack representing the container when it is empty.
* @return True if container was successfully registered; false if it already is.
* /
*/
public static boolean registerFluidContainer(Fluid fluid, ItemStack filledContainer, ItemStack emptyContainer)
{
if (!FluidRegistry.isFluidRegistered(fluid))
@ -90,7 +120,7 @@ public abstract class FluidContainerRegistry
* @param filledContainer
* ItemStack representing the container when it is full.
* @return True if container was successfully registered; false if it already is.
* /
*/
public static boolean registerFluidContainer(FluidStack stack, ItemStack filledContainer)
{
return registerFluidContainer(new FluidContainerData(stack, filledContainer, null, true));
@ -105,7 +135,7 @@ public abstract class FluidContainerRegistry
* @param filledContainer
* ItemStack representing the container when it is full.
* @return True if container was successfully registered; false if it already is.
* /
*/
public static boolean registerFluidContainer(Fluid fluid, ItemStack filledContainer)
{
if (!FluidRegistry.isFluidRegistered(fluid))
@ -121,19 +151,19 @@ public abstract class FluidContainerRegistry
* @param data
* See {@link FluidContainerData}.
* @return True if container was successfully registered; false if it already is.
* /
*/
public static boolean registerFluidContainer(FluidContainerData data)
{
if (isFilledContainer(data.filledContainer))
{
return false;
}
containerFluidMap.put(Arrays.asList(data.filledContainer, data.filledContainer.getItemDamage()), data);
containerFluidMap.put(new ContainerKey(data.filledContainer), data);
if (data.emptyContainer != null && data.emptyContainer != NULL_EMPTYCONTAINER)
{
filledContainerMap.put(Arrays.asList(data.emptyContainer, data.emptyContainer.getItemDamage(), data.fluid.fluidID), data);
emptyContainers.add(Arrays.asList(data.emptyContainer, data.emptyContainer.getItemDamage()));
filledContainerMap.put(new ContainerKey(data.emptyContainer, data.fluid), data);
emptyContainers.add(new ContainerKey(data.emptyContainer));
}
MinecraftForge.EVENT_BUS.post(new FluidContainerRegisterEvent(data));
@ -146,7 +176,7 @@ public abstract class FluidContainerRegistry
* @param container
* The fluid container.
* @return FluidStack representing stored fluid.
* /
*/
public static FluidStack getFluidForFilledItem(ItemStack container)
{
if (container == null)
@ -154,7 +184,7 @@ public abstract class FluidContainerRegistry
return null;
}
FluidContainerData data = containerFluidMap.get(Arrays.asList(container, container.getItemDamage()));
FluidContainerData data = containerFluidMap.get(new ContainerKey(container));
return data == null ? null : data.fluid.copy();
}
@ -168,7 +198,7 @@ public abstract class FluidContainerRegistry
* @param container
* ItemStack representing the empty container.
* @return Filled container if successful, otherwise null.
* /
*/
public static ItemStack fillFluidContainer(FluidStack fluid, ItemStack container)
{
if (container == null || fluid == null)
@ -176,7 +206,7 @@ public abstract class FluidContainerRegistry
return null;
}
FluidContainerData data = filledContainerMap.get(Arrays.asList(container, container.getItemDamage(), fluid.fluidID));
FluidContainerData data = filledContainerMap.get(new ContainerKey(container, fluid));
if (data != null && fluid.amount >= data.fluid.amount)
{
return data.filledContainer.copy();
@ -186,7 +216,7 @@ public abstract class FluidContainerRegistry
/**
* Determines if a container holds a specific fluid.
* /
*/
public static boolean containsFluid(ItemStack container, FluidStack fluid)
{
if (container == null || fluid == null)
@ -194,7 +224,7 @@ public abstract class FluidContainerRegistry
return false;
}
FluidContainerData data = filledContainerMap.get(Arrays.asList(container, container.getItemDamage(), fluid.fluidID));
FluidContainerData data = filledContainerMap.get(new ContainerKey(container, fluid));
return data == null ? false : data.fluid.isFluidEqual(fluid);
}
@ -210,7 +240,7 @@ public abstract class FluidContainerRegistry
return true;
}
FluidContainerData data = containerFluidMap.get(Arrays.asList(container, container.getItemDamage()));
FluidContainerData data = containerFluidMap.get(new ContainerKey(container));
return data != null && data.emptyContainer.isItemEqual(EMPTY_BUCKET);
}
@ -221,7 +251,7 @@ public abstract class FluidContainerRegistry
public static boolean isEmptyContainer(ItemStack container)
{
return container != null && emptyContainers.contains(Arrays.asList(container, container.getItemDamage()));
return container != null && emptyContainers.contains(new ContainerKey(container));
}
public static boolean isFilledContainer(ItemStack container)
@ -237,7 +267,7 @@ public abstract class FluidContainerRegistry
/**
* Wrapper class for the registry entries. Ensures that none of the attempted registrations
* contain null references unless permitted.
* /
*/
public static class FluidContainerData
{
public final FluidStack fluid;
@ -277,5 +307,4 @@ public abstract class FluidContainerRegistry
this.data = data.copy();
}
}
*/
}

View File

@ -1,53 +0,0 @@
package net.minecraftforge.fluids;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
@SuppressWarnings("unused")
public class FluidIdMapPacket// extends ForgePacket
{
/*
private BiMap<String, Integer> fluidIds = HashBiMap.create();
@Override
public byte[] generatePacket()
{
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
dat.writeInt(FluidRegistry.maxID);
for (Map.Entry<String, Integer> entry : FluidRegistry.fluidIDs.entrySet())
{
dat.writeUTF(entry.getKey());
dat.writeInt(entry.getValue());
}
return dat.toByteArray();
}
@Override
public ForgePacket consumePacket(byte[] data)
{
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
int listSize = dat.readInt();
for (int i = 0; i < listSize; i++) {
String fluidName = dat.readUTF();
int fluidId = dat.readInt();
fluidIds.put(fluidName, fluidId);
}
return this;
}
@Override
public void execute(INetworkManager network, EntityPlayer player)
{
FluidRegistry.initFluidIDs(fluidIds);
}
*/
}

View File

@ -4,12 +4,14 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.MinecraftForge;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.eventhandler.Event;
@ -19,13 +21,11 @@ import cpw.mods.fml.common.eventhandler.Event;
* @author King Lemming, CovertJaguar (LiquidDictionary)
*
*/
@SuppressWarnings("unused")
public abstract class FluidRegistry
{
/*
static int maxID = 0;
static HashMap<String, Fluid> fluids = new HashMap();
static HashMap<String, Fluid> fluids = Maps.newHashMap();
static BiMap<String, Integer> fluidIDs = HashBiMap.create();
static BiMap<Block, Fluid> fluidBlocks;
@ -34,14 +34,14 @@ public abstract class FluidRegistry
public String getLocalizedName() {
return StatCollector.translateToLocal("tile.water.name");
}
}.setBlockID(Block.waterStill.blockID).setUnlocalizedName(Block.waterStill.getUnlocalizedName());
}.setBlock(Blocks.water).setUnlocalizedName(Blocks.water.func_149739_a());
public static final Fluid LAVA = new Fluid("lava") {
@Override
public String getLocalizedName() {
return StatCollector.translateToLocal("tile.lava.name");
}
}.setBlockID(Block.lavaStill.blockID).setLuminosity(15).setDensity(3000).setViscosity(6000).setTemperature(1300).setUnlocalizedName(Block.lavaStill.getUnlocalizedName());
}.setBlock(Blocks.lava).setLuminosity(15).setDensity(3000).setViscosity(6000).setTemperature(1300).setUnlocalizedName(Blocks.lava.func_149739_a());
public static int renderIdFluid = -1;
@ -55,8 +55,9 @@ public abstract class FluidRegistry
/**
* Called by Forge to prepare the ID map for server -> client sync.
* /
static void initFluidIDs(BiMap<String, Integer> newfluidIDs)
* Modders, DO NOT call this.
*/
public static void initFluidIDs(BiMap<String, Integer> newfluidIDs)
{
maxID = newfluidIDs.size();
fluidIDs.clear();
@ -69,7 +70,7 @@ public abstract class FluidRegistry
* @param fluid
* The fluid to register.
* @return True if the fluid was successfully registered; false if there is a name clash.
* /
*/
public static boolean registerFluid(Fluid fluid)
{
if (fluidIDs.containsKey(fluid.getName()))
@ -129,7 +130,7 @@ public abstract class FluidRegistry
/**
* Returns a read-only map containing Fluid Names and their associated Fluids.
* /
*/
public static Map<String, Fluid> getRegisteredFluids()
{
return ImmutableMap.copyOf(fluids);
@ -137,7 +138,7 @@ public abstract class FluidRegistry
/**
* Returns a read-only map containing Fluid Names and their associated IDs.
* /
*/
public static Map<String, Integer> getRegisteredFluidIDs()
{
return ImmutableMap.copyOf(fluidIDs);
@ -150,9 +151,9 @@ public abstract class FluidRegistry
fluidBlocks = HashBiMap.create();
for (Fluid fluid : fluids.values())
{
if (fluid.canBePlacedInWorld() && Block.blocksList[fluid.getBlockID()] != null)
if (fluid.canBePlacedInWorld() && fluid.getBlock() != null)
{
fluidBlocks.put(Block.blocksList[fluid.getBlockID()], fluid);
fluidBlocks.put(fluid.getBlock(), fluid);
}
}
}
@ -170,5 +171,9 @@ public abstract class FluidRegistry
this.fluidID = fluidID;
}
}
*/
public static int getMaxID()
{
return maxID;
}
}

View File

@ -16,10 +16,8 @@ import net.minecraft.nbt.NBTTagCompound;
* @author King Lemming, SirSengir (LiquidStack)
*
*/
@SuppressWarnings("unused")
public class FluidStack
{
/*
public int fluidID;
public int amount;
public NBTTagCompound tag;
@ -54,7 +52,7 @@ public class FluidStack
/**
* This provides a safe method for retrieving a FluidStack - if the Fluid is invalid, the stack
* will return as null.
* /
*/
public static FluidStack loadFluidStackFromNBT(NBTTagCompound nbt)
{
if (nbt == null)
@ -104,7 +102,7 @@ public class FluidStack
/**
* @return A copy of this FluidStack
* /
*/
public FluidStack copy()
{
return new FluidStack(fluidID, amount, tag);
@ -116,7 +114,7 @@ public class FluidStack
* @param other
* The FluidStack for comparison
* @return true if the Fluids (IDs and NBT Tags) are the same
* /
*/
public boolean isFluidEqual(FluidStack other)
{
return other != null && fluidID == other.fluidID && isFluidStackTagEqual(other);
@ -129,7 +127,7 @@ public class FluidStack
/**
* Determines if the NBT Tags are equal. Useful if the FluidIDs are known to be equal.
* /
*/
public static boolean areFluidStackTagsEqual(FluidStack stack1, FluidStack stack2)
{
return stack1 == null && stack2 == null ? true : stack1 == null || stack2 == null ? false : stack1.isFluidStackTagEqual(stack2);
@ -140,7 +138,7 @@ public class FluidStack
*
* @param other
* @return true if this FluidStack contains the other FluidStack (same fluid and >= amount)
* /
*/
public boolean containsFluid(FluidStack other)
{
return isFluidEqual(other) && amount >= other.amount;
@ -152,7 +150,7 @@ public class FluidStack
* @param other
* - the FluidStack for comparison
* @return true if the two FluidStacks are exactly the same
* /
*/
public boolean isFluidStackIdentical(FluidStack other)
{
return isFluidEqual(other) && amount == other.amount;
@ -165,7 +163,7 @@ public class FluidStack
* @param other
* The ItemStack for comparison
* @return true if the Fluids (IDs and NBT Tags) are the same
* /
*/
public boolean isFluidEqual(ItemStack other)
{
if (other == null)
@ -191,7 +189,7 @@ public class FluidStack
* Default equality comparison for a FluidStack. Same functionality as isFluidEqual().
*
* This is included for use in data structures.
* /
*/
@Override
public final boolean equals(Object o)
{
@ -202,5 +200,4 @@ public class FluidStack
return isFluidEqual((FluidStack) o);
}
*/
}

View File

@ -10,16 +10,8 @@ import net.minecraft.tileentity.TileEntity;
* @author King Lemming, cpw (LiquidTank)
*
*/
@SuppressWarnings("unused")
public class FluidTank implements IFluidTank
{
@Override public FluidStack getFluid() { return null; }
@Override public int getFluidAmount() { return 0; }
@Override public int getCapacity() { return 0; }
@Override public FluidTankInfo getInfo() { return null; }
@Override public int fill(FluidStack resource, boolean doFill) { return 0; }
@Override public FluidStack drain(int maxDrain, boolean doDrain){ return null; }
/*
protected FluidStack fluid;
protected int capacity;
protected TileEntity tile;
@ -77,7 +69,7 @@ public class FluidTank implements IFluidTank
this.capacity = capacity;
}
/* IFluidTank * /
/* IFluidTank */
@Override
public FluidStack getFluid()
{
@ -193,5 +185,4 @@ public class FluidTank implements IFluidTank
}
return stack;
}
*/
}

View File

@ -10,14 +10,8 @@ import net.minecraft.nbt.NBTTagCompound;
* @author King Lemming
*
*/
@SuppressWarnings("unused")
public class ItemFluidContainer extends Item implements IFluidContainerItem
{
@Override public FluidStack getFluid(ItemStack container){ return null; }
@Override public int getCapacity(ItemStack container){ return 0; }
@Override public int fill(ItemStack container, FluidStack resource, boolean doFill) { return 0; }
@Override public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain){ return null; }
/*
protected int capacity;
public ItemFluidContainer(int itemID)
@ -37,7 +31,7 @@ public class ItemFluidContainer extends Item implements IFluidContainerItem
return this;
}
/* IFluidContainerItem * /
/* IFluidContainerItem */
@Override
public FluidStack getFluid(ItemStack container)
{
@ -161,5 +155,4 @@ public class ItemFluidContainer extends Item implements IFluidContainerItem
}
return stack;
}
*/
}

View File

@ -1,8 +1,10 @@
package net.minecraftforge.fluids;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
@ -14,14 +16,8 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
* @author King Lemming
*
*/
@SuppressWarnings("unused")
public class RenderBlockFluid implements ISimpleBlockRenderingHandler
{
@Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {}
@Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return false; }
@Override public boolean shouldRender3DInInventory(int modelId) { return false; }
@Override public int getRenderId() { return 0; }
/*
public static RenderBlockFluid instance = new RenderBlockFluid();
static final float LIGHT_Y_NEG = 0.5F;
@ -59,9 +55,9 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
public float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, BlockFluidBase block)
{
if (world.getBlockId(x, y, z) == block.blockID)
if (world.func_147439_a(x, y, z) == block)
{
if (world.getBlockMaterial(x, y - block.densityDir, z).isLiquid())
if (world.func_147439_a(x, y - block.densityDir, z).func_149688_o().isLiquid())
{
return 1;
}
@ -71,10 +67,10 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
return 0.875F;
}
}
return !world.getBlockMaterial(x, y, z).isSolid() && world.getBlockId(x, y - block.densityDir, z) == block.blockID ? 1 : block.getQuantaPercentage(world, x, y, z) * 0.875F;
return !world.func_147439_a(x, y, z).func_149688_o().isSolid() && world.func_147439_a(x, y - block.densityDir, z) == block ? 1 : block.getQuantaPercentage(world, x, y, z) * 0.875F;
}
/* ISimpleBlockRenderingHandler * /
/* ISimpleBlockRenderingHandler */
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer){}
@ -87,7 +83,7 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
}
Tessellator tessellator = Tessellator.instance;
int color = block.colorMultiplier(world, x, y, z);
int color = block.func_149720_d(world, x, y, z);
float red = (color >> 16 & 255) / 255.0F;
float green = (color >> 8 & 255) / 255.0F;
float blue = (color & 255) / 255.0F;
@ -95,16 +91,16 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
BlockFluidBase theFluid = (BlockFluidBase) block;
int bMeta = world.getBlockMetadata(x, y, z);
boolean renderTop = world.getBlockId(x, y - theFluid.densityDir, z) != theFluid.blockID;
boolean renderTop = world.func_147439_a(x, y - theFluid.densityDir, z) != theFluid;
boolean renderBottom = block.shouldSideBeRendered(world, x, y + theFluid.densityDir, z, 0) && world.getBlockId(x, y + theFluid.densityDir, z) != theFluid.blockID;
boolean renderBottom = block.func_149646_a(world, x, y + theFluid.densityDir, z, 0) && world.func_147439_a(x, y + theFluid.densityDir, z) != theFluid;
boolean[] renderSides = new boolean[]
{
block.shouldSideBeRendered(world, x, y, z - 1, 2),
block.shouldSideBeRendered(world, x, y, z + 1, 3),
block.shouldSideBeRendered(world, x - 1, y, z, 4),
block.shouldSideBeRendered(world, x + 1, y, z, 5)
block.func_149646_a(world, x, y, z - 1, 2),
block.func_149646_a(world, x, y, z + 1, 3),
block.func_149646_a(world, x - 1, y, z, 4),
block.func_149646_a(world, x + 1, y, z, 5)
};
if (!renderTop && !renderBottom && !renderSides[0] && !renderSides[1] && !renderSides[2] && !renderSides[3])
@ -142,15 +138,15 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
}
boolean rises = theFluid.densityDir == 1;
if (renderer.renderAllFaces || renderTop)
if (renderer.field_147837_f || renderTop)
{
rendered = true;
Icon iconStill = block.getIcon(1, bMeta);
IIcon iconStill = getIcon(block.func_149691_a(1, bMeta));
float flowDir = (float) BlockFluidBase.getFlowDirection(world, x, y, z);
if (flowDir > -999.0F)
{
iconStill = block.getIcon(2, bMeta);
iconStill = getIcon(block.func_149691_a(2, bMeta));
}
heightNW -= RENDER_OFFSET;
@ -185,7 +181,7 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
v3 = iconStill.getInterpolatedV(8.0F + (-zFlow - xFlow) * 16.0F);
}
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
tessellator.setBrightness(block.func_149677_c(world, x, y, z));
tessellator.setColorOpaque_F(LIGHT_Y_POS * red, LIGHT_Y_POS * green, LIGHT_Y_POS * blue);
if (!rises)
@ -204,19 +200,19 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
}
}
if (renderer.renderAllFaces || renderBottom)
if (renderer.field_147837_f || renderBottom)
{
rendered = true;
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y - 1, z));
tessellator.setBrightness(block.func_149677_c(world, x, y - 1, z));
if (!rises)
{
tessellator.setColorOpaque_F(LIGHT_Y_NEG * red, LIGHT_Y_NEG * green, LIGHT_Y_NEG * blue);
renderer.renderFaceYNeg(block, x, y + RENDER_OFFSET, z, block.getIcon(0, bMeta));
renderer.func_147768_a(block, x, y + RENDER_OFFSET, z, getIcon(block.func_149691_a(0, bMeta)));
}
else
{
tessellator.setColorOpaque_F(LIGHT_Y_POS * red, LIGHT_Y_POS * green, LIGHT_Y_POS * blue);
renderer.renderFaceYPos(block, x, y + RENDER_OFFSET, z, block.getIcon(1, bMeta));
renderer.func_147806_b(block, x, y + RENDER_OFFSET, z, getIcon(block.func_149691_a(1, bMeta)));
}
}
@ -233,8 +229,8 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
case 3: ++x2; break;
}
Icon iconFlow = block.getIcon(side + 2, bMeta);
if (renderer.renderAllFaces || renderSides[side])
IIcon iconFlow = getIcon(block.func_149691_a(side + 2, bMeta));
if (renderer.field_147837_f || renderSides[side])
{
rendered = true;
@ -287,7 +283,7 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
float v1Flow = iconFlow.getInterpolatedV((1.0D - ty1) * 16.0D * 0.5D);
float v2Flow = iconFlow.getInterpolatedV((1.0D - ty2) * 16.0D * 0.5D);
float v3Flow = iconFlow.getInterpolatedV(8.0D);
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x2, y, z2));
tessellator.setBrightness(block.func_149677_c(world, x2, y, z2));
float sideLighting = 1.0F;
if (side < 2)
@ -317,18 +313,24 @@ public class RenderBlockFluid implements ISimpleBlockRenderingHandler
}
}
}
renderer.renderMinY = 0;
renderer.renderMaxY = 1;
renderer.field_147855_j = 0;
renderer.field_147857_k = 1;
return rendered;
}
}
@Override
public boolean shouldRender3DInInventory(){ return false; }
public boolean shouldRender3DInInventory(int modelId){ return false; }
@Override
public int getRenderId()
{
return FluidRegistry.renderIdFluid;
}
*/
private IIcon getIcon(IIcon icon)
{
if (icon != null) return icon;
return ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
}
}

View File

@ -11,33 +11,25 @@ import net.minecraftforge.common.util.ForgeDirection;
* @author King Lemming
*
*/
@SuppressWarnings("unused")
public class TileFluidHandler extends TileEntity implements IFluidHandler
{
@Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { return 0; }
@Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return null; }
@Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { return null; }
@Override public boolean canFill(ForgeDirection from, Fluid fluid) { return false; }
@Override public boolean canDrain(ForgeDirection from, Fluid fluid) { return false; }
@Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { return null; }
/*
protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
@Override
public void readFromNBT(NBTTagCompound tag)
public void func_145839_a(NBTTagCompound tag)
{
super.readFromNBT(tag);
tank.writeToNBT(tag);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
super.func_145839_a(tag);
tank.readFromNBT(tag);
}
/* IFluidHandler * /
@Override
public void func_145841_b(NBTTagCompound tag)
{
super.func_145841_b(tag);
tank.writeToNBT(tag);
}
/* IFluidHandler */
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
@ -77,5 +69,4 @@ public class TileFluidHandler extends TileEntity implements IFluidHandler
{
return new FluidTankInfo[] { tank.getInfo() };
}
*/
}