Auto Format code

This commit is contained in:
modmuss50 2016-10-08 20:46:16 +01:00
parent 112b1657cf
commit 796df6c055
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
503 changed files with 12260 additions and 16291 deletions

View file

@ -1,9 +1,5 @@
package techreborn.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
@ -28,41 +24,40 @@ import techreborn.init.ModSounds;
import techreborn.items.ItemParts;
import techreborn.items.tools.ItemTreeTap;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* Created by modmuss50 on 19/02/2016.
*/
public class BlockRubberLog extends Block implements ITexturedBlock
{
public class BlockRubberLog extends Block implements ITexturedBlock {
public static PropertyDirection SAP_SIDE = PropertyDirection.create("sapside", EnumFacing.Plane.HORIZONTAL);
public static PropertyBool HAS_SAP = PropertyBool.create("hassap");
public BlockRubberLog()
{
public BlockRubberLog() {
super(Material.WOOD);
setUnlocalizedName("techreborn.rubberlog");
setCreativeTab(TechRebornCreativeTabMisc.instance);
this.setHardness(2.0F);
RebornCore.jsonDestroyer.registerObject(this);
this.setDefaultState(
this.getDefaultState().withProperty(SAP_SIDE, EnumFacing.NORTH).withProperty(HAS_SAP, false));
this.getDefaultState().withProperty(SAP_SIDE, EnumFacing.NORTH).withProperty(HAS_SAP, false));
this.setTickRandomly(true);
this.setSoundType(SoundType.WOOD);
Blocks.FIRE.setFireInfo(this, 5, 5);
Blocks.FIRE.setFireInfo(this, 5, 5);
}
protected BlockStateContainer createBlockState()
{
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, SAP_SIDE, HAS_SAP);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
public IBlockState getStateFromMeta(int meta) {
boolean hasSap = false;
int tempMeta = meta;
if (meta > 3)
{
if (meta > 3) {
hasSap = true;
tempMeta -= 3;
}
@ -71,12 +66,10 @@ public class BlockRubberLog extends Block implements ITexturedBlock
}
@Override
public int getMetaFromState(IBlockState state)
{
public int getMetaFromState(IBlockState state) {
int tempMeta = 0;
EnumFacing facing = state.getValue(SAP_SIDE);
switch (facing)
{
switch (facing) {
case SOUTH:
tempMeta = 0;
break;
@ -89,24 +82,19 @@ public class BlockRubberLog extends Block implements ITexturedBlock
case EAST:
tempMeta = 3;
}
if (state.getValue(HAS_SAP))
{
if (state.getValue(HAS_SAP)) {
tempMeta += 4;
}
return tempMeta;
}
@Override
public String getTextureNameFromState(IBlockState IBlockState, EnumFacing enumFacing)
{
if (enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.UP)
{
public String getTextureNameFromState(IBlockState IBlockState, EnumFacing enumFacing) {
if (enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.UP) {
return "techreborn:blocks/rubber_log_top";
}
if (IBlockState.getValue(HAS_SAP))
{
if (IBlockState.getValue(SAP_SIDE) == enumFacing)
{
if (IBlockState.getValue(HAS_SAP)) {
if (IBlockState.getValue(SAP_SIDE) == enumFacing) {
return "techreborn:blocks/rubber_log_sap";
}
}
@ -114,34 +102,27 @@ public class BlockRubberLog extends Block implements ITexturedBlock
}
@Override
public int amountOfStates()
{
public int amountOfStates() {
return 8;
}
@Override
public boolean canSustainLeaves(IBlockState state, IBlockAccess world, BlockPos pos)
{
public boolean canSustainLeaves(IBlockState state, IBlockAccess world, BlockPos pos) {
return true;
}
@Override
public boolean isWood(net.minecraft.world.IBlockAccess world, BlockPos pos)
{
public boolean isWood(net.minecraft.world.IBlockAccess world, BlockPos pos) {
return true;
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
int i = 4;
int j = i + 1;
if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j)))
{
for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i)))
{
if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j))) {
for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i))) {
IBlockState state1 = worldIn.getBlockState(blockpos);
if (state1.getBlock().isLeaves(state1, worldIn, blockpos))
{
if (state1.getBlock().isLeaves(state1, worldIn, blockpos)) {
state1.getBlock().beginLeavesDecay(state1, worldIn, blockpos);
}
}
@ -149,17 +130,13 @@ public class BlockRubberLog extends Block implements ITexturedBlock
}
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
super.updateTick(worldIn, pos, state, rand);
if (!state.getValue(HAS_SAP))
{
if (rand.nextInt(50) == 0)
{
if (!state.getValue(HAS_SAP)) {
if (rand.nextInt(50) == 0) {
EnumFacing facing = EnumFacing.getHorizontal(rand.nextInt(4));
if (worldIn.getBlockState(pos.down()).getBlock() == this
&& worldIn.getBlockState(pos.up()).getBlock() == this)
{
&& worldIn.getBlockState(pos.up()).getBlock() == this) {
worldIn.setBlockState(pos, state.withProperty(HAS_SAP, true).withProperty(SAP_SIDE, facing));
}
}
@ -168,26 +145,22 @@ public class BlockRubberLog extends Block implements ITexturedBlock
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
if (playerIn.getHeldItem(EnumHand.MAIN_HAND) != null
&& playerIn.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemTreeTap)
if (state.getValue(HAS_SAP))
{
if (state.getValue(SAP_SIDE) == side)
{
&& playerIn.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemTreeTap)
if (state.getValue(HAS_SAP)) {
if (state.getValue(SAP_SIDE) == side) {
worldIn.setBlockState(pos,
state.withProperty(HAS_SAP, false).withProperty(SAP_SIDE, EnumFacing.getHorizontal(0)));
state.withProperty(HAS_SAP, false).withProperty(SAP_SIDE, EnumFacing.getHorizontal(0)));
worldIn.playSound(null, pos.getX(), pos.getY(),
pos.getZ(), ModSounds.extract,
SoundCategory.BLOCKS, 0.6F, 1F);
if (!worldIn.isRemote)
{
pos.getZ(), ModSounds.extract,
SoundCategory.BLOCKS, 0.6F, 1F);
if (!worldIn.isRemote) {
Random rand = new Random();
BlockPos itemPos = pos.offset(side);
EntityItem item = new EntityItem(worldIn, itemPos.getX(), itemPos.getY(), itemPos.getZ(),
ItemParts.getPartByName("rubberSap").copy());
ItemParts.getPartByName("rubberSap").copy());
float factor = 0.05F;
playerIn.getHeldItem(EnumHand.MAIN_HAND).damageItem(1, playerIn);
item.motionX = rand.nextGaussian() * factor;
@ -202,20 +175,16 @@ public class BlockRubberLog extends Block implements ITexturedBlock
}
@Override
public int damageDropped(IBlockState state)
{
public int damageDropped(IBlockState state) {
return 0;
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
List<ItemStack> drops = new ArrayList<>();
drops.add(new ItemStack(this));
if (state.getValue(HAS_SAP))
{
if (new Random().nextInt(4) == 0)
{
if (state.getValue(HAS_SAP)) {
if (new Random().nextInt(4) == 0) {
drops.add(ItemParts.getPartByName("rubberSap"));
}
}