summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2019-08-22 20:01:40 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2019-08-22 20:01:40 -0400
commit20bef6e26d948698398bd16aeab8c9e6b89110e4 (patch)
tree8a21e17f78b330435f4ce2d4355d72b773230aa7 /src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java
parent26fb28edd1ebb6390f8803fed3876d222cb8fdba (diff)
Format/import cleanup
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java')
-rwxr-xr-xsrc/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java362
1 files changed, 68 insertions, 294 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java
index 6d88443..35381c3 100755
--- a/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java
+++ b/src/main/java/darkknight/jewelrycraft/block/BlockMoltenMetal.java
@@ -22,12 +22,11 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
-public class BlockMoltenMetal extends BlockFluidClassic
- implements ITileEntityProvider {
+public class BlockMoltenMetal extends BlockFluidClassic implements ITileEntityProvider {
@SideOnly(Side.CLIENT)
- protected IIcon stillIcon;
+ protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
- protected IIcon flowingIcon;
+ protected IIcon flowingIcon;
public BlockMoltenMetal(Fluid fluid, Material material) {
super(fluid, material);
@@ -45,31 +44,26 @@ public class BlockMoltenMetal extends BlockFluidClassic
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
- stillIcon = register.registerIcon(
- Variables.MODID + ":moltenMetalStill");
- flowingIcon = register.registerIcon(
- Variables.MODID + ":moltenMetalFlow");
+ stillIcon = register.registerIcon(Variables.MODID + ":moltenMetalStill");
+ flowingIcon = register.registerIcon(Variables.MODID + ":moltenMetalFlow");
}
@Override
- public boolean canDisplace(IBlockAccess world, int x, int y,
- int z) {
+ public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid())
return false;
return super.canDisplace(world, x, y, z);
}
@Override
- public boolean displaceIfPossible(World world, int x, int y,
- int z) {
+ public boolean displaceIfPossible(World world, int x, int y, int z) {
if (world.getBlock(x, y, z).getMaterial().isLiquid())
return false;
return super.displaceIfPossible(world, x, y, z);
}
@Override
- protected boolean canFlowInto(IBlockAccess world, int x, int y,
- int z) {
+ protected boolean canFlowInto(IBlockAccess world, int x, int y, int z) {
if (world.getBlock(x, y, z).isAir(world, x, y, z))
return true;
Block block = world.getBlock(x, y, z);
@@ -78,8 +72,7 @@ public class BlockMoltenMetal extends BlockFluidClassic
if (displacements.containsKey(block))
return displacements.get(block);
Material material = block.getMaterial();
- if (material.blocksMovement() || material == Material.water
- || material == Material.lava
+ if (material.blocksMovement() || material == Material.water || material == Material.lava
|| material == Material.portal)
return false;
int densty = getDensity(world, x, y, z);
@@ -93,8 +86,7 @@ public class BlockMoltenMetal extends BlockFluidClassic
@Override
@SideOnly(Side.CLIENT)
- public int colorMultiplier(IBlockAccess world, int i, int j,
- int k) {
+ public int colorMultiplier(IBlockAccess world, int i, int j, int k) {
try {
return color(world, i, j, k, false, null);
} catch (IOException e) {
@@ -104,212 +96,55 @@ public class BlockMoltenMetal extends BlockFluidClassic
}
@Override
- public void updateTick(World world, int x, int y, int z,
- Random rand) {
- if (getTileEntity(world, x, y, z) == null
- || (getTileEntity(world, x, y, z)
- .getMetal() == null))
+ public void updateTick(World world, int x, int y, int z, Random rand) {
+ if (getTileEntity(world, x, y, z) == null || (getTileEntity(world, x, y, z).getMetal() == null))
world.setBlockToAir(x, y, z);
else {
- int quantaRemaining = quantaPerBlock
- - world.getBlockMetadata(x, y, z);
+ int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z);
int expQuanta = -101;
// check adjacent block levels if non-source
if (quantaRemaining < quantaPerBlock) {
int y2 = y - densityDir;
- if ((world.getBlock(x, y2, z) == this
- && getTileEntity(world, x,
- y2,
- z) != null
- && getTileEntity(world, x,
- y,
- z) != null
- && areMetalsEqual(world, x,
- y2, z, x,
- y, z))
- || (world.getBlock(x - 1,
- y2,
- z) == this
- && getTileEntity(
- world,
- x - 1,
- y2,
- z) != null
- && getTileEntity(
- world,
- x,
- y,
- z) != null
- && areMetalsEqual(
- world,
- x - 1,
- y2,
- z,
- x,
- y,
- z))
- || (world.getBlock(x + 1,
- y2,
- z) == this
- && getTileEntity(
- world,
- x + 1,
- y2,
- z) != null
- && getTileEntity(
- world,
- x,
- y,
- z) != null
- && areMetalsEqual(
- world,
- x + 1,
- y2,
- z,
- x,
- y,
- z))
- || (world.getBlock(x, y2, z
- - 1) == this
- && getTileEntity(
- world,
- x,
- y2,
- z - 1) != null
- && getTileEntity(
- world,
- x,
- y,
- z) != null
- && areMetalsEqual(
- world,
- x,
- y2,
- z - 1,
- x,
- y,
- z))
- || (world.getBlock(x, y2, z
- + 1) == this
- && getTileEntity(
- world,
- x,
- y2,
- z + 1) != null
- && getTileEntity(
- world,
- x,
- y,
- z) != null
- && areMetalsEqual(
- world,
- x,
- y2,
- z + 1,
- x,
- y,
- z)))
+ if ((world.getBlock(x, y2, z) == this && getTileEntity(world, x, y2, z) != null
+ && getTileEntity(world, x, y, z) != null && areMetalsEqual(world, x, y2, z, x, y, z))
+ || (world.getBlock(x - 1, y2, z) == this && getTileEntity(world, x - 1, y2, z) != null
+ && getTileEntity(world, x, y, z) != null
+ && areMetalsEqual(world, x - 1, y2, z, x, y, z))
+ || (world.getBlock(x + 1, y2, z) == this && getTileEntity(world, x + 1, y2, z) != null
+ && getTileEntity(world, x, y, z) != null
+ && areMetalsEqual(world, x + 1, y2, z, x, y, z))
+ || (world.getBlock(x, y2, z - 1) == this && getTileEntity(world, x, y2, z - 1) != null
+ && getTileEntity(world, x, y, z) != null
+ && areMetalsEqual(world, x, y2, z - 1, x, y, z))
+ || (world.getBlock(x, y2, z + 1) == this && getTileEntity(world, x, y2, z + 1) != null
+ && getTileEntity(world, x, y, z) != null
+ && areMetalsEqual(world, x, y2, z + 1, x, y, z)))
expQuanta = quantaPerBlock - 1;
else {
int maxQuanta = -100;
- if (getTileEntity(world, x, y,
- z) != null
- && getTileEntity(
- world,
- x - 1,
- y,
- z) != null
- && areMetalsEqual(
- world,
- x,
- y,
- z,
- x - 1,
- y,
- z))
- maxQuanta = getLargerQuanta(
- world,
- x - 1, y,
- z,
- maxQuanta);
- if (getTileEntity(world, x, y,
- z) != null
- && getTileEntity(
- world,
- x + 1,
- y,
- z) != null
- && areMetalsEqual(
- world,
- x,
- y,
- z,
- x + 1,
- y,
- z))
- maxQuanta = getLargerQuanta(
- world,
- x + 1, y,
- z,
- maxQuanta);
- if (getTileEntity(world, x, y,
- z) != null
- && getTileEntity(
- world,
- x,
- y,
- z - 1) != null
- && areMetalsEqual(
- world,
- x,
- y,
- z,
- x,
- y,
- z - 1))
- maxQuanta = getLargerQuanta(
- world, x,
- y, z - 1,
- maxQuanta);
- if (getTileEntity(world, x, y,
- z) != null
- && getTileEntity(
- world,
- x,
- y,
- z + 1) != null
- && areMetalsEqual(
- world,
- x,
- y,
- z,
- x,
- y,
- z + 1))
- maxQuanta = getLargerQuanta(
- world, x,
- y, z + 1,
- maxQuanta);
+ if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x - 1, y, z) != null
+ && areMetalsEqual(world, x, y, z, x - 1, y, z))
+ maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta);
+ if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x + 1, y, z) != null
+ && areMetalsEqual(world, x, y, z, x + 1, y, z))
+ maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta);
+ if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x, y, z - 1) != null
+ && areMetalsEqual(world, x, y, z, x, y, z - 1))
+ maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta);
+ if (getTileEntity(world, x, y, z) != null && getTileEntity(world, x, y, z + 1) != null
+ && areMetalsEqual(world, x, y, z, x, y, z + 1))
+ maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta);
expQuanta = maxQuanta - 1;
}
// decay calculation
if (expQuanta != quantaRemaining) {
quantaRemaining = expQuanta;
if (expQuanta <= 0)
- world.setBlock(x, y, z,
- Blocks.air);
+ world.setBlock(x, y, z, Blocks.air);
else {
- world.setBlockMetadataWithNotify(
- x, y, z,
- quantaPerBlock - expQuanta,
- 3);
- world.scheduleBlockUpdate(
- x, y, z,
- this,
- tickRate);
- world.notifyBlocksOfNeighborChange(
- x, y, z,
- this);
+ world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3);
+ world.scheduleBlockUpdate(x, y, z, this, tickRate);
+ world.notifyBlocksOfNeighborChange(x, y, z, this);
}
}
}
@@ -317,126 +152,65 @@ public class BlockMoltenMetal extends BlockFluidClassic
// send a
// server only update
else if (quantaRemaining >= quantaPerBlock)
- world.setBlockMetadataWithNotify(x, y, z,
- 0, 2);
+ world.setBlockMetadataWithNotify(x, y, z, 0, 2);
// Flow vertically if possible
if (canDisplace(world, x, y + densityDir, z)) {
- if (getTileEntity(world, x, y + densityDir,
- z) != null
- && getTileEntity(world, x,
- y,
- z) != null)
- BlockMoltenMetal.getTileEntity(
- world, x,
- y + densityDir, z)
- .setMetal(getTileEntity(
- world,
- x,
- y,
- z).getMetal());
- flowIntoBlock(world, x, y + densityDir, z,
- 1,
- getTileEntity(world, x, y,
- z).getMetal());
+ if (getTileEntity(world, x, y + densityDir, z) != null && getTileEntity(world, x, y, z) != null)
+ BlockMoltenMetal.getTileEntity(world, x, y + densityDir, z)
+ .setMetal(getTileEntity(world, x, y, z).getMetal());
+ flowIntoBlock(world, x, y + densityDir, z, 1, getTileEntity(world, x, y, z).getMetal());
return;
}
// Flow outward if possible
- int flowMeta = quantaPerBlock - quantaRemaining
- + 1;
+ int flowMeta = quantaPerBlock - quantaRemaining + 1;
if (flowMeta >= quantaPerBlock)
return;
- if (isSourceBlock(world, x, y, z)
- || !isFlowingVertically(world, x,
- y, z)) {
- if (world.getBlock(x, y - densityDir,
- z) == this
- && getTileEntity(world, x,
- y,
- z) != null
- && getTileEntity(world, x,
- y - densityDir,
- z) != null
- && areMetalsEqual(world, x,
- y, z, x,
- y - densityDir,
- z))
+ if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)) {
+ if (world.getBlock(x, y - densityDir, z) == this && getTileEntity(world, x, y, z) != null
+ && getTileEntity(world, x, y - densityDir, z) != null
+ && areMetalsEqual(world, x, y, z, x, y - densityDir, z))
flowMeta = 1;
- boolean flowTo[] = getOptimalFlowDirections(
- world, x, y, z);
+ boolean flowTo[] = getOptimalFlowDirections(world, x, y, z);
if (flowTo[0])
- flowIntoBlock(world, x - 1, y, z,
- flowMeta,
- getTileEntity(world,
- x,
- y,
- z).getMetal());
+ flowIntoBlock(world, x - 1, y, z, flowMeta, getTileEntity(world, x, y, z).getMetal());
if (flowTo[1])
- flowIntoBlock(world, x + 1, y, z,
- flowMeta,
- getTileEntity(world,
- x,
- y,
- z).getMetal());
+ flowIntoBlock(world, x + 1, y, z, flowMeta, getTileEntity(world, x, y, z).getMetal());
if (flowTo[2])
- flowIntoBlock(world, x, y, z - 1,
- flowMeta,
- getTileEntity(world,
- x,
- y,
- z).getMetal());
+ flowIntoBlock(world, x, y, z - 1, flowMeta, getTileEntity(world, x, y, z).getMetal());
if (flowTo[3])
- flowIntoBlock(world, x, y, z + 1,
- flowMeta,
- getTileEntity(world,
- x,
- y,
- z).getMetal());
+ flowIntoBlock(world, x, y, z + 1, flowMeta, getTileEntity(world, x, y, z).getMetal());
}
}
}
- public void flowIntoBlock(World world, int x, int y, int z,
- int meta, ItemStack metal) {
+ public void flowIntoBlock(World world, int x, int y, int z, int meta, ItemStack metal) {
if (meta < 0 || world.isRemote)
return;
if (displaceIfPossible(world, x, y, z)) {
world.setBlock(x, y, z, this, meta, 3);
if (getTileEntity(world, x, y, z) != null)
- getTileEntity(world, x, y, z)
- .setMetal(metal);
+ getTileEntity(world, x, y, z).setMetal(metal);
}
}
- public static TileEntityMoltenMetal getTileEntity(World world,
- int x, int y, int z) {
+ public static TileEntityMoltenMetal getTileEntity(World world, int x, int y, int z) {
TileEntity moltenLiquid = world.getTileEntity(x, y, z);
- if (moltenLiquid != null
- && moltenLiquid instanceof TileEntityMoltenMetal)
+ if (moltenLiquid != null && moltenLiquid instanceof TileEntityMoltenMetal)
return (TileEntityMoltenMetal) moltenLiquid;
return null;
}
- public static boolean areMetalsEqual(World world, int x1, int y1,
- int z1, int x2, int y2, int z2) {
- return ItemStack.areItemStacksEqual(
- getTileEntity(world, x1, y1, z1)
- .getMetal(),
- getTileEntity(world, x2, y2, z2)
- .getMetal());
+ public static boolean areMetalsEqual(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
+ return ItemStack.areItemStacksEqual(getTileEntity(world, x1, y1, z1).getMetal(),
+ getTileEntity(world, x2, y2, z2).getMetal());
}
@SideOnly(Side.CLIENT)
- public static int color(IBlockAccess world, int i, int j, int k,
- boolean forcecolor, Item itemC)
+ public static int color(IBlockAccess world, int i, int j, int k, boolean forcecolor, Item itemC)
throws IOException {
TileEntity te = world.getTileEntity(i, j, k);
- if (te instanceof TileEntityMoltenMetal
- && ((TileEntityMoltenMetal) te)
- .getMetal() != null)
- return JewelrycraftUtil.getColor(
- ((TileEntityMoltenMetal) te)
- .getMetal()
- .copy());
+ if (te instanceof TileEntityMoltenMetal && ((TileEntityMoltenMetal) te).getMetal() != null)
+ return JewelrycraftUtil.getColor(((TileEntityMoltenMetal) te).getMetal().copy());
return 16777215;
}