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 906c730a3c
commit 4cfcc874dc
136 files changed
+10365 -11272

No files matched your search

@@ -10,77 +10,71 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class BaseItem extends Item {
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4){
getWrappedDesc(list, itemStack);
}
public static void getWrappedDesc(List<String> list, ItemStack stack)
{
String[] wrappedDesc;
wrappedDesc = wrap(StatCollector.translateToLocal(stack.getUnlocalizedName() + ".desc"), 35);
for (String element : wrappedDesc)
list.add(element.trim());
}
public static String[] wrap(String input, int len)
{
// return empty array for null text
if (input == null)
return new String[] {};
// return text if len is zero or less
if (len <= 0)
return new String[] { input };
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
getWrappedDesc(list, itemStack);
}
// return text if less than length
if (input.length() <= len)
return new String[] { input };
public static void getWrappedDesc(List<String> list, ItemStack stack) {
String[] wrappedDesc;
wrappedDesc = wrap(StatCollector.translateToLocal(stack.getUnlocalizedName() + ".desc"), 35);
for (String element : wrappedDesc)
list.add(element.trim());
}
char[] chars = input.toCharArray();
Vector lines = new Vector();
StringBuffer line = new StringBuffer();
StringBuffer word = new StringBuffer();
public static String[] wrap(String input, int len) {
// return empty array for null text
if (input == null)
return new String[] {};
for (char c : chars)
{
word.append(c);
// return text if len is zero or less
if (len <= 0)
return new String[] { input };
if (c == ' ')
{
if ((line.length() + word.length()) > len)
{
lines.add(line.toString());
line.delete(0, line.length());
}
// return text if less than length
if (input.length() <= len)
return new String[] { input };
line.append(word);
word.delete(0, word.length());
}
}
char[] chars = input.toCharArray();
Vector lines = new Vector();
StringBuffer line = new StringBuffer();
StringBuffer word = new StringBuffer();
// handle any extra chars in current word
if (word.length() > 0)
{
if ((line.length() + word.length()) > len)
{
for (char c : chars) {
word.append(c);
if (c == ' ') {
if ((line.length() + word.length()) > len) {
lines.add(line.toString());
line.delete(0, line.length());
}
line.append(word);
word.delete(0, word.length());
}
// handle extra line
if (line.length() > 0)
{
lines.add(line.toString());
}
String[] ret = new String[lines.size()];
int c = 0; // counter
for (Enumeration e = lines.elements(); e.hasMoreElements(); c++)
{
ret[c] = (String) e.nextElement();
}
return ret;
}
// handle any extra chars in current word
if (word.length() > 0) {
if ((line.length() + word.length()) > len) {
lines.add(line.toString());
line.delete(0, line.length());
}
line.append(word);
}
// handle extra line
if (line.length() > 0) {
lines.add(line.toString());
}
String[] ret = new String[lines.size()];
int c = 0; // counter
for (Enumeration e = lines.elements(); e.hasMoreElements(); c++) {
ret[c] = (String) e.nextElement();
}
return ret;
}
}
@@ -6,31 +6,26 @@ import net.minecraft.world.World;
import com.cricketcraft.chisel.entity.EntityBallOMoss;
public class ItemBallOMoss extends BaseItem
{
public class ItemBallOMoss extends BaseItem {
public ItemBallOMoss()
{
super();
setUnlocalizedName("ballMoss");
}
public ItemBallOMoss() {
super();
setUnlocalizedName("ballMoss");
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if(!par3EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
if (!par3EntityPlayer.capabilities.isCreativeMode) {
--par1ItemStack.stackSize;
}
if(par2World.isRemote)
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (par2World.isRemote)
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if(!par2World.isRemote)
{
par2World.spawnEntityInWorld(new EntityBallOMoss(par2World, par3EntityPlayer));
}
if (!par2World.isRemote) {
par2World.spawnEntityInWorld(new EntityBallOMoss(par2World, par3EntityPlayer));
}
return par1ItemStack;
}
return par1ItemStack;
}
}
@@ -14,45 +14,43 @@ import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.carving.CarvableVariation;
import com.cricketcraft.chisel.utils.General;
public class ItemCarvable extends ItemBlock
{
public class ItemCarvable extends ItemBlock {
public ItemCarvable(Block block)
{
super(block);
setMaxDamage(0);
setHasSubtypes(true);
}
public ItemCarvable(Block block) {
super(block);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public int getMetadata(int i)
{
return i;
}
@Override
public int getMetadata(int i) {
return i;
}
@Override
public IIcon getIconFromDamage(int damage)
{
return Block.getBlockFromItem(this).getIcon(2, damage);
}
@Override
public IIcon getIconFromDamage(int damage) {
return Block.getBlockFromItem(this).getIcon(2, damage);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips)
{
if(!Configurations.blockDescriptions) return;
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List lines, boolean advancedTooltips) {
if (!Configurations.blockDescriptions)
return;
Item item = General.getItem(stack);
if(item == null) return;
Item item = General.getItem(stack);
if (item == null)
return;
Block block = Block.getBlockFromItem(this);
if(!(block instanceof ICarvable)) return;
Block block = Block.getBlockFromItem(this);
if (!(block instanceof ICarvable))
return;
ICarvable carvable = (ICarvable) block;
CarvableVariation var = carvable.getVariation(stack.getItemDamage());
if(var == null)
return;
ICarvable carvable = (ICarvable) block;
CarvableVariation var = carvable.getVariation(stack.getItemDamage());
if (var == null)
return;
lines.add(var.description);
}
lines.add(var.description);
}
}
@@ -193,7 +193,7 @@ public class ItemChisel extends Item implements IChiselMode {
y = buf.readInt();
z = buf.readInt();
block = buf.readInt();
meta = (byte) buf.readByte();
meta = buf.readByte();
}
}
@@ -6,30 +6,26 @@ import net.minecraft.world.World;
import com.cricketcraft.chisel.entity.EntityCloudInABottle;
public class ItemCloudInABottle extends BaseItem
{
public class ItemCloudInABottle extends BaseItem {
public ItemCloudInABottle()
{
super();
setUnlocalizedName("cloudBottle");
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if(!par3EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
public ItemCloudInABottle() {
super();
setUnlocalizedName("cloudBottle");
}
if(par2World.isRemote)
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
if (!par3EntityPlayer.capabilities.isCreativeMode) {
--par1ItemStack.stackSize;
}
if(!par2World.isRemote)
{
par2World.spawnEntityInWorld(new EntityCloudInABottle(par2World, par3EntityPlayer));
}
if (par2World.isRemote)
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
return par1ItemStack;
}
if (!par2World.isRemote) {
par2World.spawnEntityInWorld(new EntityCloudInABottle(par2World, par3EntityPlayer));
}
return par1ItemStack;
}
}
@@ -8,113 +8,101 @@ import net.minecraft.world.World;
import com.cricketcraft.chisel.block.BlockMarbleSlab;
public class ItemMarbleSlab extends ItemCarvable
{
public class ItemMarbleSlab extends ItemCarvable {
public ItemMarbleSlab(Block block)
{
super(block);
}
public ItemMarbleSlab(Block block) {
super(block);
}
@Override
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack)
{
BlockMarbleSlab block = (BlockMarbleSlab) Block.getBlockFromItem(this);
@Override
public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) {
BlockMarbleSlab block = (BlockMarbleSlab) Block.getBlockFromItem(this);
switch(side)
{
case 0:
--y;
break;
case 1:
++y;
break;
case 2:
--z;
break;
case 3:
++z;
break;
case 4:
--x;
break;
case 5:
++x;
break;
}
switch (side) {
case 0:
--y;
break;
case 1:
++y;
break;
case 2:
--z;
break;
case 3:
++z;
break;
case 4:
--x;
break;
case 5:
++x;
break;
}
Block targetBlock = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
Block targetBlock = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
return (targetBlock.equals(block) || targetBlock.equals(block.top)) && meta == stack.getItemDamage() || world.canPlaceEntityOnSide(block, x, y, z, false, side, (Entity) null, stack);
return (targetBlock.equals(block) || targetBlock.equals(block.top)) && meta == stack.getItemDamage() || world.canPlaceEntityOnSide(block, x, y, z, false, side, (Entity) null, stack);
}
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hx, float hy, float hz) {
BlockMarbleSlab block = (BlockMarbleSlab) Block.getBlockFromItem(this);
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hx, float hy, float hz)
{
BlockMarbleSlab block = (BlockMarbleSlab) Block.getBlockFromItem(this);
Block targetBlock = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
boolean metaMatches = meta == stack.getItemDamage();
Block targetBlock = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
boolean metaMatches = meta == stack.getItemDamage();
if (metaMatches && side == 0 && targetBlock.equals(block.top)) {
world.setBlock(x, y, z, block.master, meta, 2);
stack.stackSize -= 1;
return true;
} else if (metaMatches && side == 1 && targetBlock.equals(block.bottom)) {
world.setBlock(x, y, z, block.master, meta, 2);
stack.stackSize -= 1;
return true;
}
if(metaMatches && side == 0 && targetBlock.equals(block.top))
{
world.setBlock(x, y, z, block.master, meta, 2);
stack.stackSize -= 1;
return true;
} else if(metaMatches && side == 1 && targetBlock.equals(block.bottom))
{
world.setBlock(x, y, z, block.master, meta, 2);
stack.stackSize -= 1;
return true;
}
boolean result = super.onItemUse(stack, player, world, x, y, z, side, hz, hy, hz);
boolean result = super.onItemUse(stack, player, world, x, y, z, side, hz, hy, hz);
switch (side) {
case 0:
--y;
break;
case 1:
++y;
break;
case 2:
--z;
break;
case 3:
++z;
break;
case 4:
--x;
break;
case 5:
++x;
break;
}
targetBlock = world.getBlock(x, y, z);
meta = world.getBlockMetadata(x, y, z);
switch(side)
{
case 0:
--y;
break;
case 1:
++y;
break;
case 2:
--z;
break;
case 3:
++z;
break;
case 4:
--x;
break;
case 5:
++x;
break;
}
if (!result && (targetBlock.equals(block.top) || targetBlock.equals(block.bottom)) && meta == stack.getItemDamage()) {
world.setBlock(x, y, z, block.master, meta, 2);
return true;
}
targetBlock = world.getBlock(x, y, z);
meta = world.getBlockMetadata(x, y, z);
if (!result)
return false;
if(!result && (targetBlock.equals(block.top) || targetBlock.equals(block.bottom)) && meta == stack.getItemDamage())
{
world.setBlock(x, y, z, block.master, meta, 2);
return true;
}
if (side != 0 && (side == 1 || hy <= 0.5D))
return true;
if(!result)
return false;
if(side != 0 && (side == 1 || hy <= 0.5D))
return true;
//TODO allow top slabs
//world.setBlock(x, y, z, block.top, meta, 2);
return true;
}
// TODO allow top slabs
// world.setBlock(x, y, z, block.top, meta, 2);
return true;
}
}
@@ -6,32 +6,26 @@ import net.minecraft.world.World;
import com.cricketcraft.chisel.entity.EntitySmashingRock;
public class ItemSmashingRock extends BaseItem
{
public class ItemSmashingRock extends BaseItem {
public ItemSmashingRock()
{
super();
setUnlocalizedName("smashingRock");
}
public ItemSmashingRock() {
super();
setUnlocalizedName("smashingRock");
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if(!par3EntityPlayer.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
if (!par3EntityPlayer.capabilities.isCreativeMode) {
--par1ItemStack.stackSize;
}
if(par2World.isRemote)
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (par2World.isRemote)
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if(!par2World.isRemote)
{
par2World.spawnEntityInWorld(new EntitySmashingRock(par2World, par3EntityPlayer));
}
if (!par2World.isRemote) {
par2World.spawnEntityInWorld(new EntitySmashingRock(par2World, par3EntityPlayer));
}
return par1ItemStack;
}
return par1ItemStack;
}
}
@@ -14,59 +14,60 @@ import net.minecraft.world.World;
import com.cricketcraft.chisel.Chisel;
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
public class ItemUpgrade extends BaseItem{
public class ItemUpgrade extends BaseItem {
public IIcon[] icons = new IIcon[3];
public IIcon[] icons = new IIcon[3];
public ItemUpgrade(String unlocalizedName) {
super();
this.setUnlocalizedName(unlocalizedName);
this.setCreativeTab(CreativeTabs.tabMaterials);
}
public ItemUpgrade(String unlocalizedName) {
super();
this.setUnlocalizedName(unlocalizedName);
this.setCreativeTab(CreativeTabs.tabMaterials);
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int size, float hitX, float hitY, float hitZ){
if(world.isRemote) return false;
TileEntity tile = world.getTileEntity(x, y, z);
if(tile != null && tile instanceof TileEntityAutoChisel){
}
return true;
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int size, float hitX, float hitY, float hitZ) {
if (world.isRemote)
return false;
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TileEntityAutoChisel) {
}
return true;
}
@Override
public IIcon getIconFromDamage(int meta) {
if (meta > 3)
meta = 0;
@Override
public IIcon getIconFromDamage(int meta) {
if (meta > 3)
meta = 0;
return this.icons[meta];
}
return this.icons[meta];
}
@Override
public void registerIcons(IIconRegister reg) {
for (int i = 0; i < 3; i ++) {
this.icons[i] = reg.registerIcon(Chisel.MOD_ID + ":upgradeItem_" + i);
}
}
@Override
public void registerIcons(IIconRegister reg) {
for (int i = 0; i < 3; i++) {
this.icons[i] = reg.registerIcon(Chisel.MOD_ID + ":upgradeItem_" + i);
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 3; i ++) {
list.add(new ItemStack(item, 1, i));
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 3; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
switch (stack.getItemDamage()) {
case 0:
return this.getUnlocalizedName() + "_speed";
case 1:
return this.getUnlocalizedName() + "_automation";
case 2:
return this.getUnlocalizedName() + "_stack";
default:
return this.getUnlocalizedName();
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
switch (stack.getItemDamage()) {
case 0:
return this.getUnlocalizedName() + "_speed";
case 1:
return this.getUnlocalizedName() + "_automation";
case 2:
return this.getUnlocalizedName() + "_stack";
default:
return this.getUnlocalizedName();
}
}
}