Small improvements

This commit is contained in:
Raoul Van den Berge
2016-07-08 14:27:43 +02:00
parent b04589e77e
commit 35e2f1d9cf
12 changed files with 23 additions and 31 deletions

View File

@@ -56,7 +56,7 @@ public abstract class BlockBase extends Block {
return createBlockStateBuilder().build();
}
public Item createItemForBlock() {
public Item createItem() {
return new ItemBlockBase(this, false);
}
@@ -73,11 +73,7 @@ public abstract class BlockBase extends Block {
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
if (getDirectionType() != null) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileBase) {
return state.withProperty(DIRECTION, ((TileBase) tile).getDirection());
}
return state.withProperty(DIRECTION, ((TileBase) world.getTileEntity(pos)).getDirection());
}
return state;
@@ -91,15 +87,13 @@ public abstract class BlockBase extends Block {
@Override
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) {
if (!world.isRemote && getDirectionType() != null) {
TileEntity tile = world.getTileEntity(pos);
TileBase tile = (TileBase) world.getTileEntity(pos);
if (tile instanceof TileBase) {
((TileBase) tile).setDirection(getDirectionType().getNext(((TileBase) tile).getDirection()));
tile.setDirection(getDirectionType().getNext(tile.getDirection()));
RefinedStorageUtils.updateBlock(world, pos);
RefinedStorageUtils.updateBlock(world, pos);
return true;
}
return true;
}
return false;
@@ -110,17 +104,15 @@ public abstract class BlockBase extends Block {
super.onBlockPlacedBy(world, pos, state, player, stack);
if (getDirectionType() != null) {
TileEntity tile = world.getTileEntity(pos);
TileBase tile = (TileBase) world.getTileEntity(pos);
if (tile instanceof TileBase) {
EnumFacing facing = getDirectionType().getFrom(pos, player);
EnumFacing facing = getDirectionType().getFrom(pos, player);
if (player.isSneaking() && getDirectionType() == EnumDirectionType.ANY) {
facing = facing.getOpposite();
}
((TileBase) tile).setDirection(facing);
if (player.isSneaking() && getDirectionType() == EnumDirectionType.ANY) {
facing = facing.getOpposite();
}
tile.setDirection(facing);
}
}

View File

@@ -55,7 +55,7 @@ public class BlockCable extends BlockNode {
.withProperty(DOWN, hasConnectionWith(world, pos.down()));
}
public static boolean hasConnectionWith(IBlockAccess world, BlockPos pos) {
private boolean hasConnectionWith(IBlockAccess world, BlockPos pos) {
return world.getBlockState(pos).getBlock() == RefinedStorageBlocks.CONTROLLER || world.getTileEntity(pos) instanceof INetworkNode;
}

View File

@@ -145,7 +145,7 @@ public class BlockController extends BlockBase {
}
@Override
public Item createItemForBlock() {
public Item createItem() {
return new ItemBlockController();
}
}

View File

@@ -67,7 +67,7 @@ public class BlockGrid extends BlockNode {
}
@Override
public Item createItemForBlock() {
public Item createItem() {
return new ItemBlockBase(this, true);
}
}

View File

@@ -101,7 +101,7 @@ public class BlockStorage extends BlockNode {
}
@Override
public Item createItemForBlock() {
public Item createItem() {
return new ItemBlockStorage();
}

View File

@@ -23,7 +23,7 @@ public class BasicItemHandler extends ItemStackHandler {
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
if (validators.length > 0) {
for (IItemValidator validator : validators) {
if (validator.valid(stack)) {
if (validator.isValid(stack)) {
return super.insertItem(slot, stack, simulate);
}
}

View File

@@ -17,7 +17,7 @@ public class BasicItemValidator implements IItemValidator {
}
@Override
public boolean valid(ItemStack stack) {
public boolean isValid(ItemStack stack) {
if (stack.getItem() == item) {
if (damage != -1 && stack.getItemDamage() != damage) {
return false;

View File

@@ -3,5 +3,5 @@ package refinedstorage.inventory;
import net.minecraft.item.ItemStack;
public interface IItemValidator {
boolean valid(ItemStack stack);
boolean isValid(ItemStack stack);
}

View File

@@ -486,7 +486,7 @@ public class CommonProxy {
private void registerBlock(BlockBase block) {
GameRegistry.<Block>register(block);
GameRegistry.register(block.createItemForBlock());
GameRegistry.register(block.createItem());
}
private void registerItem(Item item) {

View File

@@ -24,7 +24,7 @@ import refinedstorage.item.ItemUpgrade;
public class TileCrafter extends TileNode implements ICraftingPatternContainer {
private BasicItemHandler patterns = new BasicItemHandler(9, this, new IItemValidator() {
@Override
public boolean valid(ItemStack stack) {
public boolean isValid(ItemStack stack) {
return stack.getItem() == RefinedStorageItems.PATTERN && ItemPattern.isValid(stack);
}
}) {

View File

@@ -78,8 +78,7 @@ public class TileSolderer extends TileNode {
recipe = null;
progress = 0;
// Don't set working to false yet, wait till the next update because we may have
// another stack waiting.
// Don't set working to false yet, wait till the next update because we may have another stack waiting.
markDirty();
}