Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.

Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
This commit is contained in:
Lex Manos committed 2014-11-26 00:00:54 -08:00
1 parent 0e91787efb
commit 53659fca06
410 files changed
+8717 -14103

No files matched your search

@@ -4,18 +4,20 @@ package net.minecraftforge.fluids;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
/**
* This is a cellular-automata based finite fluid block implementation.
*
*
* It is highly recommended that you use/extend this class for finite fluid blocks.
*
*
* @author OvermindDL1, KingLemming
*
*
*/
public class BlockFluidFinite extends BlockFluidBase
{
@@ -25,26 +27,25 @@ public class BlockFluidFinite extends BlockFluidBase
}
@Override
public int getQuantaValue(IBlockAccess world, int x, int y, int z)
public int getQuantaValue(IBlockAccess world, BlockPos pos)
{
if (world.getBlock(x, y, z).isAir(world, x, y, z))
IBlockState state = world.getBlockState(pos);
if (state.getBlock().isAir(world, pos))
{
return 0;
}
if (world.getBlock(x, y, z) != this)
if (state.getBlock() != this)
{
return -1;
}
int quantaRemaining = world.getBlockMetadata(x, y, z) + 1;
return quantaRemaining;
return ((Integer)state.getValue(LEVEL)) + 1;
}
@Override
public boolean canCollideCheck(int meta, boolean fullHit)
public boolean canCollideCheck(IBlockState state, boolean fullHit)
{
return fullHit && meta == quantaPerBlock - 1;
return fullHit && ((Integer)state.getValue(LEVEL)) == quantaPerBlock - 1;
}
@Override
@@ -54,14 +55,14 @@ public class BlockFluidFinite extends BlockFluidBase
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand)
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
{
boolean changed = false;
int quantaRemaining = world.getBlockMetadata(x, y, z) + 1;
int quantaRemaining = ((Integer)state.getValue(LEVEL)) + 1;
// Flow vertically if possible
int prevRemaining = quantaRemaining;
quantaRemaining = tryToFlowVerticallyInto(world, x, y, z, quantaRemaining);
quantaRemaining = tryToFlowVerticallyInto(world, pos, quantaRemaining);
if (quantaRemaining < 1)
{
@@ -72,7 +73,7 @@ public class BlockFluidFinite extends BlockFluidBase
changed = true;
if (quantaRemaining == 1)
{
world.setBlockMetadataWithNotify(x, y, z, quantaRemaining - 1, 2);
world.setBlockState(pos, state.withProperty(LEVEL, quantaRemaining - 1), 2);
return;
}
}
@@ -83,192 +84,110 @@ 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, Blocks.air);
if (displaceIfPossible(world, x, y, z + 1)) world.setBlock(x, y, z + 1, Blocks.air);
if (displaceIfPossible(world, x - 1, y, z )) world.setBlock(x - 1, y, z, Blocks.air);
if (displaceIfPossible(world, x + 1, y, z )) world.setBlock(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);
int east = getQuantaValueBelow(world, x + 1, y, z, lowerthan);
int total = quantaRemaining;
int count = 1;
if (north >= 0)
for (EnumFacing side : EnumFacing.Plane.HORIZONTAL)
{
count++;
total += north;
}
BlockPos off = pos.offset(side);
if (displaceIfPossible(world, off))
world.setBlockToAir(off);
if (south >= 0)
{
count++;
total += south;
}
if (west >= 0)
{
count++;
total += west;
}
if (east >= 0)
{
++count;
total += east;
int quanta = getQuantaValueBelow(world, off, lowerthan);
if (quanta >= 0)
{
count++;
total += quanta;
}
}
if (count == 1)
{
if (changed)
{
world.setBlockMetadataWithNotify(x, y, z, quantaRemaining - 1, 2);
world.setBlockState(pos, state.withProperty(LEVEL, quantaRemaining - 1), 2);
}
return;
}
int each = total / count;
int rem = total % count;
if (north >= 0)
for (EnumFacing side : EnumFacing.Plane.HORIZONTAL)
{
int newnorth = each;
if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0)
BlockPos off = pos.offset(side);
int quanta = getQuantaValueBelow(world, off, lowerthan);
if (quanta >= 0)
{
++newnorth;
--rem;
}
int newquanta = each;
if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0)
{
++newquanta;
--rem;
}
if (newnorth != north)
{
if (newnorth == 0)
if (newquanta != quanta)
{
world.setBlock(x, y, z - 1, Blocks.air);
if (newquanta == 0)
{
world.setBlockToAir(off);
}
else
{
world.setBlockState(off, getDefaultState().withProperty(LEVEL, newquanta - 1), 2);
}
world.scheduleUpdate(off, this, tickRate);
}
else
{
world.setBlock(x, y, z - 1, this, newnorth - 1, 2);
}
world.scheduleBlockUpdate(x, y, z - 1, this, tickRate);
--count;
}
--count;
}
if (south >= 0)
{
int newsouth = each;
if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0)
{
++newsouth;
--rem;
}
if (newsouth != south)
{
if (newsouth == 0)
{
world.setBlock(x, y, z + 1, Blocks.air);
}
else
{
world.setBlock(x, y, z + 1, this, newsouth - 1, 2);
}
world.scheduleBlockUpdate(x, y, z + 1, this, tickRate);
}
--count;
}
if (west >= 0)
{
int newwest = each;
if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0)
{
++newwest;
--rem;
}
if (newwest != west)
{
if (newwest == 0)
{
world.setBlock(x - 1, y, z, Blocks.air);
}
else
{
world.setBlock(x - 1, y, z, this, newwest - 1, 2);
}
world.scheduleBlockUpdate(x - 1, y, z, this, tickRate);
}
--count;
}
if (east >= 0)
{
int neweast = each;
if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0)
{
++neweast;
--rem;
}
if (neweast != east)
{
if (neweast == 0)
{
world.setBlock(x + 1, y, z, Blocks.air);
}
else
{
world.setBlock(x + 1, y, z, this, neweast - 1, 2);
}
world.scheduleBlockUpdate(x + 1, y, z, this, tickRate);
}
--count;
}
if (rem > 0)
{
++each;
}
world.setBlockMetadataWithNotify(x, y, z, each - 1, 2);
world.setBlockState(pos, state.withProperty(LEVEL, each - 1), 2);
}
public int tryToFlowVerticallyInto(World world, int x, int y, int z, int amtToInput)
public int tryToFlowVerticallyInto(World world, BlockPos pos, int amtToInput)
{
int otherY = y + densityDir;
if (otherY < 0 || otherY >= world.getHeight())
IBlockState myState = world.getBlockState(pos);
BlockPos other = pos.add(0, densityDir, 0);
if (other.getY() < 0 || other.getY() >= world.getHeight())
{
world.setBlock(x, y, z, Blocks.air);
world.setBlockToAir(pos);
return 0;
}
int amt = getQuantaValueBelow(world, x, otherY, z, quantaPerBlock);
int amt = getQuantaValueBelow(world, other, quantaPerBlock);
if (amt >= 0)
{
amt += amtToInput;
if (amt > quantaPerBlock)
{
world.setBlock(x, otherY, z, this, quantaPerBlock - 1, 3);
world.scheduleBlockUpdate(x, otherY, z, this, tickRate);
world.setBlockState(other, myState.withProperty(LEVEL, quantaPerBlock - 1), 3);
world.scheduleUpdate(other, this, tickRate);
return amt - quantaPerBlock;
}
else if (amt > 0)
{
world.setBlock(x, otherY, z, this, amt - 1, 3);
world.scheduleBlockUpdate(x, otherY, z, this, tickRate);
world.setBlock(x, y, z, Blocks.air);
world.setBlockState(other, myState.withProperty(LEVEL, amt - 1), 3);
world.scheduleUpdate(other, this, tickRate);
world.setBlockToAir(pos);
return 0;
}
return amtToInput;
}
else
{
int density_other = getDensity(world, x, otherY, z);
int density_other = getDensity(world, other);
if (density_other == Integer.MAX_VALUE)
{
if (displaceIfPossible(world, x, otherY, z))
if (displaceIfPossible(world, other))
{
world.setBlock(x, otherY, z, this, amtToInput - 1, 3);
world.scheduleBlockUpdate(x, otherY, z, this, tickRate);
world.setBlock(x, y, z, Blocks.air);
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1), 3);
world.scheduleUpdate(other, this, tickRate);
world.setBlockToAir(pos);
return 0;
}
else
@@ -281,12 +200,11 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (density_other < density) // then swap
{
BlockFluidBase block = (BlockFluidBase)world.getBlock(x, otherY, z);
int otherData = world.getBlockMetadata(x, otherY, z);
world.setBlock(x, otherY, z, this, amtToInput - 1, 3);
world.setBlock(x, y, z, block, otherData, 3);
world.scheduleBlockUpdate(x, otherY, z, this, tickRate);
world.scheduleBlockUpdate(x, y, z, block, block.tickRate(world));
IBlockState state = world.getBlockState(other);
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1), 3);
world.setBlockState(pos, state, 3);
world.scheduleUpdate(other, this, tickRate);
world.scheduleUpdate(pos, state.getBlock(), state.getBlock().tickRate(world));
return 0;
}
}
@@ -294,12 +212,11 @@ public class BlockFluidFinite extends BlockFluidBase
{
if (density_other > density)
{
BlockFluidBase block = (BlockFluidBase)world.getBlock(x, otherY, z);
int otherData = world.getBlockMetadata(x, otherY, z);
world.setBlock(x, otherY, z, this, amtToInput - 1, 3);
world.setBlock(x, y, z, block, otherData, 3);
world.scheduleBlockUpdate(x, otherY, z, this, tickRate);
world.scheduleBlockUpdate(x, y, z, block, block.tickRate(world));
IBlockState state = world.getBlockState(other);
world.setBlockState(other, myState.withProperty(LEVEL, amtToInput - 1), 3);
world.setBlockState(other, state, 3);
world.scheduleUpdate(other, this, tickRate);
world.scheduleUpdate(other, state.getBlock(), state.getBlock().tickRate(world));
return 0;
}
}
@@ -309,20 +226,20 @@ public class BlockFluidFinite extends BlockFluidBase
/* IFluidBlock */
@Override
public FluidStack drain(World world, int x, int y, int z, boolean doDrain)
public FluidStack drain(World world, BlockPos pos, boolean doDrain)
{
if (doDrain)
{
world.setBlock(x, y, z, Blocks.air);
world.setBlockToAir(pos);
}
return new FluidStack(getFluid(),
MathHelper.floor_float(getQuantaPercentage(world, x, y, z) * FluidContainerRegistry.BUCKET_VOLUME));
MathHelper.floor_float(getQuantaPercentage(world, pos) * FluidContainerRegistry.BUCKET_VOLUME));
}
@Override
public boolean canDrain(World world, int x, int y, int z)
public boolean canDrain(World world, BlockPos pos)
{
return true;
}
}
}