Better naming

This commit is contained in:
Raoul Van den Berge
2016-05-20 19:40:39 +02:00
parent e3b1ac694a
commit 4490eea1e9
10 changed files with 24 additions and 20 deletions

View File

@@ -47,7 +47,7 @@ public class MessageWirelessGridCraftingStart extends MessageHandlerPlayerToServ
public void handle(MessageWirelessGridCraftingStart message, EntityPlayerMP player) {
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.controllerX, message.controllerY, message.controllerZ));
if (tile instanceof TileController && ((TileController) tile).canRun()) {
if (tile instanceof TileController && ((TileController) tile).mayRun()) {
((TileController) tile).onCraftingRequested(message.id, message.quantity);
}
}

View File

@@ -47,7 +47,7 @@ public class MessageWirelessGridStoragePull extends MessageHandlerPlayerToServer
public void handle(MessageWirelessGridStoragePull message, EntityPlayerMP player) {
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.controllerX, message.controllerY, message.controllerZ));
if (tile instanceof TileController && ((TileController) tile).canRun()) {
if (tile instanceof TileController && ((TileController) tile).mayRun()) {
((TileController) tile).handleStoragePull(message.id, message.flags, player);
}
}

View File

@@ -47,7 +47,7 @@ public class MessageWirelessGridStoragePush extends MessageHandlerPlayerToServer
public void handle(MessageWirelessGridStoragePush message, EntityPlayerMP player) {
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.controllerX, message.controllerY, message.controllerZ));
if (tile instanceof TileController && ((TileController) tile).canRun()) {
if (tile instanceof TileController && ((TileController) tile).mayRun()) {
((TileController) tile).handleStoragePush(message.playerSlot, message.one, player);
}
}

View File

@@ -20,7 +20,7 @@ public class DiskStorage extends NBTStorage {
}
@Override
public boolean canPush(ItemStack stack) {
return ModeConfigUtils.doesNotViolateMode(diskDrive.getInventory(), diskDrive.getModeConfig(), diskDrive.getCompare(), stack) && super.canPush(stack);
public boolean mayPush(ItemStack stack) {
return ModeConfigUtils.doesNotViolateMode(diskDrive.getInventory(), diskDrive.getModeConfig(), diskDrive.getCompare(), stack) && super.mayPush(stack);
}
}

View File

@@ -11,7 +11,7 @@ public interface IStorage {
ItemStack take(ItemStack stack, int flags);
boolean canPush(ItemStack stack);
boolean mayPush(ItemStack stack);
int getPriority();
}

View File

@@ -124,7 +124,7 @@ public abstract class NBTStorage implements IStorage {
}
@Override
public boolean canPush(ItemStack stack) {
public boolean mayPush(ItemStack stack) {
return capacity == -1 || (getStored(tag) + stack.stackSize) <= capacity;
}

View File

@@ -19,7 +19,7 @@ public class StorageBlockStorage extends NBTStorage {
}
@Override
public boolean canPush(ItemStack stack) {
return ModeConfigUtils.doesNotViolateMode(storage.getInventory(), storage, storage.getCompare(), stack) && super.canPush(stack);
public boolean mayPush(ItemStack stack) {
return ModeConfigUtils.doesNotViolateMode(storage.getInventory(), storage, storage.getCompare(), stack) && super.mayPush(stack);
}
}

View File

@@ -122,7 +122,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
int lastEnergy = energy.getEnergyStored();
if (canRun()) {
if (mayRun()) {
if (ticks % 20 == 0) {
syncMachines();
}
@@ -157,8 +157,8 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
disconnectAll();
}
if (couldRun != canRun()) {
couldRun = canRun();
if (couldRun != mayRun()) {
couldRun = mayRun();
worldObj.notifyNeighborsOfStateChange(pos, RefinedStorageBlocks.CONTROLLER);
}
@@ -174,7 +174,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
if (!RefinedStorageUtils.compareStack(consumer.getWirelessGrid(), consumer.getPlayer().getHeldItem(consumer.getHand()))) {
consumer.getPlayer().closeScreen(); // This will call onContainerClosed on the Container and remove it from the list
} else {
if (canRun()) {
if (mayRun()) {
RefinedStorage.NETWORK.sendTo(new MessageWirelessGridItems(this), (EntityPlayerMP) consumer.getPlayer());
}
}
@@ -365,7 +365,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
public boolean push(ItemStack stack) {
for (IStorage storage : storages) {
if (storage.canPush(stack)) {
if (storage.mayPush(stack)) {
storage.push(stack);
syncItems();
@@ -559,7 +559,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
return true;
}
public boolean canRun() {
public boolean mayRun() {
return energy.getEnergyStored() > 0 && energy.getEnergyStored() >= energyUsage && redstoneMode.isEnabled(worldObj, pos);
}

View File

@@ -134,7 +134,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
}
@Override
public boolean canPush(ItemStack stack) {
public boolean mayPush(ItemStack stack) {
if (ModeConfigUtils.doesNotViolateMode(inventory, this, compare, stack)) {
TileEntity connectedTile = getConnectedTile();

View File

@@ -55,8 +55,8 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
searchController(worldObj);
}
if (wasConnected != (isConnected() && mayUpdate()) && maySendConnectivityData()) {
wasConnected = isConnected() && mayUpdate();
if (wasConnected != isActive() && maySendConnectivityData()) {
wasConnected = isActive();
RefinedStorageUtils.updateBlock(worldObj, pos);
}
@@ -71,6 +71,10 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
return redstoneMode.isEnabled(worldObj, pos);
}
public boolean isActive() {
return connected && mayUpdate();
}
public void onConnected(World world, TileController controller) {
if (tryConnect(controller)) {
world.notifyNeighborsOfStateChange(pos, block);
@@ -78,7 +82,7 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
}
private boolean tryConnect(TileController controller) {
if (!controller.canRun()) {
if (!controller.mayRun()) {
return false;
}
@@ -155,7 +159,7 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
public void writeToDescriptionPacketNBT(NBTTagCompound tag) {
super.writeToDescriptionPacketNBT(tag);
tag.setBoolean(NBT_DESC_CONNECTED, isConnected() && mayUpdate());
tag.setBoolean(NBT_DESC_CONNECTED, isActive());
}
public void readFromDescriptionPacketNBT(NBTTagCompound tag) {