The great format and clean up. IMPORTANT: Read below.

All devs and contributors should use the provided formatter settings. 
If your IDE does not support the format, the rules are simple, it is the
default java formatting rules, with 200char line lengths and 1 extra
line after class definitions.
This commit is contained in:
tterrag1098 committed 2015-01-07 19:50:18 -05:00
1 parent 06c5f5930f
commit 82792ed22e
136 files changed
+10365 -11272

No files matched your search

@@ -1,12 +1,8 @@
package com.cricketcraft.chisel.block;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
import com.cricketcraft.chisel.carving.CarvableHelper;
import com.cricketcraft.chisel.carving.CarvableVariation;
import com.cricketcraft.chisel.inventory.InventoryLargePresent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Iterator;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -25,293 +21,303 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.Iterator;
import java.util.Random;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
import com.cricketcraft.chisel.carving.CarvableHelper;
import com.cricketcraft.chisel.carving.CarvableVariation;
import com.cricketcraft.chisel.inventory.InventoryLargePresent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockPresent extends BlockChest implements ICarvable {
private final Random random = new Random();
private int type;
public CarvableHelper carverHelper;
public BlockPresent(int type) {
super(1);
this.type = type;
carverHelper = new CarvableHelper();
setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0875F, 0.9365F);
}
private final Random random = new Random();
private int type;
public CarvableHelper carverHelper;
public String getKindOfChest(int type){
switch (type){
case 0:
return "textures/blocks/present/presentChest0";
case 1:
return "textures/blocks/present/presentChest1";
case 2:
return "textures/blocks/present/presentChest2";
case 3:
return "textures/blocks/present/presentChest3";
case 4:
return "textures/blocks/present/presentChest4";
case 5:
return "textures/blocks/present/presentChest5";
case 6:
return "textures/blocks/present/presentChest6";
case 7:
return "textures/blocks/present/presentChest7";
case 8:
return "textures/blocks/present/presentChest8";
case 9:
return "textures/blocks/present/presentChest9";
case 10:
return "textures/blocks/present/presentChest10";
case 11:
return "textures/blocks/present/presentChest11";
case 12:
return "textures/blocks/present/presentChest12";
case 13:
return "textures/blocks/present/presentChest13";
case 14:
return "textures/blocks/present/presentChest14";
case 15:
return "textures/blocks/present/presentChest15";
default:
return null;
}
}
public BlockPresent(int type) {
super(1);
this.type = type;
carverHelper = new CarvableHelper();
setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0875F, 0.9365F);
}
private static boolean isCatSittingOnMe(World world, int x, int y, int z) {
Iterator iterator = world.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)).iterator();
EntityOcelot ocelot;
public String getKindOfChest(int type) {
switch (type) {
case 0:
return "textures/blocks/present/presentChest0";
case 1:
return "textures/blocks/present/presentChest1";
case 2:
return "textures/blocks/present/presentChest2";
case 3:
return "textures/blocks/present/presentChest3";
case 4:
return "textures/blocks/present/presentChest4";
case 5:
return "textures/blocks/present/presentChest5";
case 6:
return "textures/blocks/present/presentChest6";
case 7:
return "textures/blocks/present/presentChest7";
case 8:
return "textures/blocks/present/presentChest8";
case 9:
return "textures/blocks/present/presentChest9";
case 10:
return "textures/blocks/present/presentChest10";
case 11:
return "textures/blocks/present/presentChest11";
case 12:
return "textures/blocks/present/presentChest12";
case 13:
return "textures/blocks/present/presentChest13";
case 14:
return "textures/blocks/present/presentChest14";
case 15:
return "textures/blocks/present/presentChest15";
default:
return null;
}
}
do {
if (!iterator.hasNext()) {
return false;
}
private static boolean isCatSittingOnMe(World world, int x, int y, int z) {
Iterator iterator = world.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getBoundingBox(x, y + 1, z, x + 1, y + 2, z + 1)).iterator();
EntityOcelot ocelot;
Entity entity = (Entity) iterator.next();
ocelot = (EntityOcelot) entity;
} while (!ocelot.isSitting());
do {
if (!iterator.hasNext()) {
return false;
}
return true;
}
Entity entity = (Entity) iterator.next();
ocelot = (EntityOcelot) entity;
} while (!ocelot.isSitting());
@Override
public boolean isOpaqueCube() {
return false;
}
return true;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLivingBase, ItemStack itemStack) {
Block front = world.getBlock(x, y, z - 1);
Block back = world.getBlock(x, y, z + 1);
Block left = world.getBlock(x - 1, y, z);
Block right = world.getBlock(x + 1, y, z);
byte metadata = 0;
int rot = MathHelper.floor_double((entityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
@Override
public int getRenderType() {
return -1;
}
if (rot == 0) {
metadata = 2;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLivingBase, ItemStack itemStack) {
Block front = world.getBlock(x, y, z - 1);
Block back = world.getBlock(x, y, z + 1);
Block left = world.getBlock(x - 1, y, z);
Block right = world.getBlock(x + 1, y, z);
byte metadata = 0;
int rot = MathHelper.floor_double((entityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (rot == 1) {
metadata = 5;
}
if (rot == 0) {
metadata = 2;
}
if (rot == 2) {
metadata = 3;
}
if (rot == 1) {
metadata = 5;
}
if (rot == 3) {
metadata = 4;
}
if (rot == 2) {
metadata = 3;
}
if (front != this && back != this && left != this && right != this) {
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
} else {
if ((front == this || back == this) && (metadata == 4 || metadata == 5)) {
if (front == this) {
world.setBlockMetadataWithNotify(x, y, z - 1, metadata, 3);
} else {
world.setBlockMetadataWithNotify(x, y, z + 1, metadata, 3);
}
if (rot == 3) {
metadata = 4;
}
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
}
if (front != this && back != this && left != this && right != this) {
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
} else {
if ((front == this || back == this) && (metadata == 4 || metadata == 5)) {
if (front == this) {
world.setBlockMetadataWithNotify(x, y, z - 1, metadata, 3);
} else {
world.setBlockMetadataWithNotify(x, y, z + 1, metadata, 3);
}
if ((left == this || right == this) && (metadata == 2 || metadata == 3)) {
if (left == this) {
world.setBlockMetadataWithNotify(x - 1, y, z, metadata, 3);
} else {
world.setBlockMetadataWithNotify(x + 1, y, z, metadata, 3);
}
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
}
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
}
}
}
if ((left == this || right == this) && (metadata == 2 || metadata == 3)) {
if (left == this) {
world.setBlockMetadataWithNotify(x - 1, y, z, metadata, 3);
} else {
world.setBlockMetadataWithNotify(x + 1, y, z, metadata, 3);
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
int l = 0;
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
}
}
}
if (world.getBlock(x - 1, y, z) == this) {
++l;
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
int l = 0;
if (world.getBlock(x + 1, y, z) == this) {
++l;
}
if (world.getBlock(x - 1, y, z) == this) {
++l;
}
if (world.getBlock(x, y, z - 1) == this) {
++l;
}
if (world.getBlock(x + 1, y, z) == this) {
++l;
}
if (world.getBlock(x, y, z + 1) == this) {
++l;
}
if (world.getBlock(x, y, z - 1) == this) {
++l;
}
return l > 1 ? false : (areSurroundingBlocksMe(world, x, y - 1, z) ? false : (areSurroundingBlocksMe(world, x, y + 1, z) ? false : (areSurroundingBlocksMe(world, x, y, z - 1) ? false : !areSurroundingBlocksMe(world, x, y, z + 1))));
}
if (world.getBlock(x, y, z + 1) == this) {
++l;
}
private boolean areSurroundingBlocksMe(World world, int x, int y, int z) {
return world.getBlock(x, y, z) != this ? false : (world.getBlock(x - 1, y, z) == this ? true : (world.getBlock(x + 1, y, z) == this ? true : (world.getBlock(x, y, z - 1) == this ? true : world.getBlock(x, y, z + 1) == this)));
}
return l > 1 ? false : (areSurroundingBlocksMe(world, x, y - 1, z) ? false : (areSurroundingBlocksMe(world, x, y + 1, z) ? false : (areSurroundingBlocksMe(world, x, y, z - 1) ? false
: !areSurroundingBlocksMe(world, x, y, z + 1))));
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) {
super.onNeighborBlockChange(world, x, y, z, neighbor);
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
private boolean areSurroundingBlocksMe(World world, int x, int y, int z) {
return world.getBlock(x, y, z) != this ? false : (world.getBlock(x - 1, y, z) == this ? true : (world.getBlock(x + 1, y, z) == this ? true : (world.getBlock(x, y, z - 1) == this ? true
: world.getBlock(x, y, z + 1) == this)));
}
if (tileEntityPresent != null) {
tileEntityPresent.updateContainingBlockInfo();
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) {
super.onNeighborBlockChange(world, x, y, z, neighbor);
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
@Override
public void breakBlock(World world, int x, int y, int z, Block present, int meta) {
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
if (tileEntityPresent != null) {
tileEntityPresent.updateContainingBlockInfo();
}
}
if (tileEntityPresent != null) {
for (int c = 0; c < tileEntityPresent.getSizeInventory(); c++) {
ItemStack itemStack = tileEntityPresent.getStackInSlot(c);
@Override
public void breakBlock(World world, int x, int y, int z, Block present, int meta) {
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
if (itemStack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem;
if (tileEntityPresent != null) {
for (int c = 0; c < tileEntityPresent.getSizeInventory(); c++) {
ItemStack itemStack = tileEntityPresent.getStackInSlot(c);
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemStack.stackSize > 0; world.spawnEntityInWorld(entityItem)) {
int stack = random.nextInt(21) + 10;
if (itemStack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem;
if (stack > itemStack.stackSize) {
stack = itemStack.stackSize;
}
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemStack.stackSize > 0; world.spawnEntityInWorld(entityItem)) {
int stack = random.nextInt(21) + 10;
itemStack.stackSize -= stack;
entityItem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemStack.getItem(), stack, itemStack.getItemDamage()));
float motion = 0.05F;
entityItem.motionX = random.nextGaussian() * motion;
entityItem.motionY = random.nextGaussian() * motion + 0.2F;
entityItem.motionZ = random.nextGaussian() * motion;
if (stack > itemStack.stackSize) {
stack = itemStack.stackSize;
}
if (itemStack.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
}
}
}
itemStack.stackSize -= stack;
entityItem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemStack.getItem(), stack, itemStack.getItemDamage()));
float motion = 0.05F;
entityItem.motionX = random.nextGaussian() * motion;
entityItem.motionY = random.nextGaussian() * motion + 0.2F;
entityItem.motionZ = random.nextGaussian() * motion;
world.func_147453_f(x, y, z, this);
}
if (itemStack.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
}
}
}
super.breakBlock(world, x, y, z, this, meta);
}
world.func_147453_f(x, y, z, this);
}
@Override
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityPresent(type);
}
super.breakBlock(world, x, y, z, this, meta);
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int strength) {
if (!canProvidePower()) {
return 0;
} else {
int players = ((TileEntityPresent) world.getTileEntity(x, y, z)).numPlayersUsing;
return MathHelper.clamp_int(players, 0, 15);
}
}
@Override
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityPresent(type);
}
@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int strength) {
return strength == 1 ? isProvidingWeakPower(world, x, y, z, strength) : 0;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int strength) {
if (!canProvidePower()) {
return 0;
} else {
int players = ((TileEntityPresent) world.getTileEntity(x, y, z)).numPlayersUsing;
return MathHelper.clamp_int(players, 0, 15);
}
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int strength) {
return strength == 1 ? isProvidingWeakPower(world, x, y, z, strength) : 0;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int strength) {
return Container.calcRedstoneFromInventory(getInventory(world, x, y, z));
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
this.blockIcon = register.registerIcon("planks_oak");
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int strength) {
return Container.calcRedstoneFromInventory(getInventory(world, x, y, z));
}
public IInventory getInventory(World world, int x, int y, int z) {
Object object = world.getTileEntity(x, y, z);
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
this.blockIcon = register.registerIcon("planks_oak");
}
if (object == null) {
return null;
} else if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
return null;
} else if (isCatSittingOnMe(world, x, y, z)) {
return null;
} else if (world.getBlock(x - 1, y, z) == this && (world.isSideSolid(x - 1, y + 1, z, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y - 1, z))) {
return null;
} else if (world.getBlock(x + 1, y, z) == this && (world.isSideSolid(x + 1, y + 1, z, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y + 1, z))) {
return null;
} else if (world.getBlock(x, y, z - 1) == this && (world.isSideSolid(x, y + 1, z - 1, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y, z - 1))) {
return null;
} else if (world.getBlock(x, y, z + 1) == this && (world.isSideSolid(x, y + 1, z + 1, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y, z + 1))) {
return null;
} else {
if (world.getBlock(x - 1, y, z) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x - 1, y, z), (IInventory) object);
}
public IInventory getInventory(World world, int x, int y, int z) {
Object object = world.getTileEntity(x, y, z);
if (world.getBlock(x + 1, y, z) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x + 1, y, z), (IInventory) object);
}
if (object == null) {
return null;
} else if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
return null;
} else if (isCatSittingOnMe(world, x, y, z)) {
return null;
} else if (world.getBlock(x - 1, y, z) == this && (world.isSideSolid(x - 1, y + 1, z, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y - 1, z))) {
return null;
} else if (world.getBlock(x + 1, y, z) == this && (world.isSideSolid(x + 1, y + 1, z, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y + 1, z))) {
return null;
} else if (world.getBlock(x, y, z - 1) == this && (world.isSideSolid(x, y + 1, z - 1, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y, z - 1))) {
return null;
} else if (world.getBlock(x, y, z + 1) == this && (world.isSideSolid(x, y + 1, z + 1, ForgeDirection.DOWN) || isCatSittingOnMe(world, x, y, z + 1))) {
return null;
} else {
if (world.getBlock(x - 1, y, z) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x - 1, y, z), (IInventory) object);
}
if (world.getBlock(x, y, z - 1) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x, y, z - 1), (IInventory) object);
}
if (world.getBlock(x + 1, y, z) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x + 1, y, z), (IInventory) object);
}
if (world.getBlock(x, y, z + 1) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x, y, z + 1), (IInventory) object);
}
if (world.getBlock(x, y, z - 1) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x, y, z - 1), (IInventory) object);
}
return (IInventory) object;
}
}
if (world.getBlock(x, y, z + 1) == this) {
object = new InventoryLargePresent("container.chestDouble", (TileEntityPresent) world.getTileEntity(x, y, z + 1), (IInventory) object);
}
@Override
public CarvableVariation getVariation(int metadata) {
return carverHelper.getVariation(metadata);
}
return (IInventory) object;
}
}
@Override
public CarvableVariation getVariation(int metadata) {
return carverHelper.getVariation(metadata);
}
}