Some code improvement

This commit is contained in:
kordum committed 2017-07-04 19:11:23 +03:00
1 parent 3bd8c53273
commit 784fa0ad30
7 files changed
+41 -30

No files matched your search

@@ -24,13 +24,16 @@ public class MachineComponent implements INBTTagable {
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
// ignored
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
// ignored
}
public void onUpdate() {
// ignored
}
public Class[] getComponentInterfaces() {
@@ -38,6 +41,7 @@ public class MachineComponent implements INBTTagable {
}
public void onInventoryUpdate() {
// ignored
}
public MachinePayload getPayload() {
@@ -52,6 +52,7 @@ public abstract class ComponentProcessIndefinate extends MachineComponent implem
} else if (isInProgress()) {
onCancelTask();
}
if (actionPauseProcess > 0.0f) {
actionPauseProcess--;
}
@@ -32,30 +32,32 @@ public enum BinnieCorePacketID implements IPacketID {
((INetworkedEntity) tile).readFromPacket(packet.payload);
}
} else if (this == BinnieCorePacketID.TileMetadata) {
MessageMetadata packet2 = new MessageMetadata(message);
TileEntity tile = packet2.getTileEntity(BinnieCore.proxy.getWorld());
MessageMetadata packet = new MessageMetadata(message);
TileEntity tile = packet.getTileEntity(BinnieCore.proxy.getWorld());
if (tile instanceof TileEntityMetadata) {
((TileEntityMetadata) tile).setTileMetadata(packet2.meta, true);
((TileEntityMetadata) tile).setTileMetadata(packet.meta, true);
}
} else if (this == BinnieCorePacketID.CraftGUIAction && context.side == Side.CLIENT) {
MessageCraftGUI packet3 = new MessageCraftGUI(message);
EntityPlayer player = BinnieCore.proxy.getPlayer();
if (player.openContainer instanceof ContainerCraftGUI && packet3.getTagCompound() != null) {
((ContainerCraftGUI) player.openContainer).recieveNBT(Side.CLIENT, player, packet3.getTagCompound());
}
} else if (this == BinnieCorePacketID.CraftGUIAction && context.side == Side.SERVER && context.netHandler instanceof NetHandlerPlayServer) {
MessageCraftGUI packet3 = new MessageCraftGUI(message);
EntityPlayer player = ((NetHandlerPlayServer) context.netHandler).playerEntity;
if (player.openContainer instanceof ContainerCraftGUI && packet3.getTagCompound() != null) {
((ContainerCraftGUI) player.openContainer).recieveNBT(Side.SERVER, player, packet3.getTagCompound());
} else if (this == BinnieCorePacketID.CraftGUIAction) {
if (context.side == Side.CLIENT) {
MessageCraftGUI packet = new MessageCraftGUI(message);
EntityPlayer player = BinnieCore.proxy.getPlayer();
if (player.openContainer instanceof ContainerCraftGUI && packet.getTagCompound() != null) {
((ContainerCraftGUI) player.openContainer).recieveNBT(Side.CLIENT, player, packet.getTagCompound());
}
} else if (context.netHandler instanceof NetHandlerPlayServer) {
MessageCraftGUI packet = new MessageCraftGUI(message);
EntityPlayer player = ((NetHandlerPlayServer) context.netHandler).playerEntity;
if (player.openContainer instanceof ContainerCraftGUI && packet.getTagCompound() != null) {
((ContainerCraftGUI) player.openContainer).recieveNBT(Side.SERVER, player, packet.getTagCompound());
}
}
} else if (this == BinnieCorePacketID.TileDescriptionSync && context.side == Side.CLIENT) {
MessageTileNBT packet4 = new MessageTileNBT(message);
TileEntity tile = packet4.getTarget(BinnieCore.proxy.getWorld());
if (tile != null && packet4.getTagCompound() != null) {
MessageTileNBT packet = new MessageTileNBT(message);
TileEntity tile = packet.getTarget(BinnieCore.proxy.getWorld());
if (tile != null && packet.getTagCompound() != null) {
IMachine machine = Machine.getMachine(tile);
if (machine != null && machine instanceof INetwork.TilePacketSync) {
((INetwork.TilePacketSync) machine).syncFromNBT(packet4.getTagCompound());
((INetwork.TilePacketSync) machine).syncFromNBT(packet.getTagCompound());
}
}
}
@@ -65,14 +65,16 @@ public class AcclimatiserComponentLogic extends ComponentProcessIndefinate {
ItemStack acc = acclms.get(getUtil().getRandom().nextInt(acclms.size()));
ItemStack acclimed = Acclimatiser.acclimatise(getUtil().getStack(Acclimatiser.SLOT_TARGET), acc);
if (acclimed != null) {
getUtil().setStack(Acclimatiser.SLOT_TARGET, acclimed);
boolean removed = false;
for (int i : Acclimatiser.SLOT_ACCLIMATISER) {
if (!removed && getUtil().getStack(i) != null && getUtil().getStack(i).isItemEqual(acc)) {
getUtil().decreaseStack(i, 1);
removed = true;
}
if (acclimed == null) {
return;
}
getUtil().setStack(Acclimatiser.SLOT_TARGET, acclimed);
boolean removed = false;
for (int i : Acclimatiser.SLOT_ACCLIMATISER) {
if (!removed && getUtil().getStack(i) != null && getUtil().getStack(i).isItemEqual(acc)) {
getUtil().decreaseStack(i, 1);
removed = true;
}
}
}
@@ -9,6 +9,8 @@ public class Genepool {
public static final int RF_COST = 8000;
public static final int TIME_PERIOD = 400;
public static final float ENZYME_PER_PROCESS = 0.25f;
public static final float ETHANOL_PER_PROCESS = 50.0f;
public static final int ETHANOL_PER_TICK = 1;
public static final int POWER_CAPACITY = 1600;
public static final int TANK_DNA_CAPACITY = 2000;
public static final int TANK_ETHANOL_CAPACITY = 1000;
}
@@ -80,7 +80,7 @@ public class GenepoolComponentLogic extends ComponentProcessSetCost implements I
protected void onTickTask() {
ethanolDrain += getDNAAmount(getUtil().getStack(Genepool.TANK_DNA)) * 1.2f * getProgressPerTick() / 100.0f;
if (ethanolDrain >= 1.0f) {
getUtil().drainTank(Genepool.TANK_ETHANOL, 1);
getUtil().drainTank(Genepool.TANK_ETHANOL, Genepool.ETHANOL_PER_TICK);
ethanolDrain--;
}
@@ -44,10 +44,10 @@ public class GenepoolPackage extends PackageGeneticBase implements IMachineInfor
}
ComponentTankContainer tanks = new ComponentTankContainer(machine);
TankSlot dnaSlot = tanks.addTank(Genepool.TANK_DNA, "output", 2000);
TankSlot dnaSlot = tanks.addTank(Genepool.TANK_DNA, "output", Genepool.TANK_DNA_CAPACITY);
dnaSlot.setReadOnly();
TankSlot ethanolSlot = tanks.addTank(Genepool.TANK_ETHANOL, "input", 1000);
TankSlot ethanolSlot = tanks.addTank(Genepool.TANK_ETHANOL, "input", Genepool.TANK_ETHANOL_CAPACITY);
ethanolSlot.forbidExtraction();
ethanolSlot.setValidator(new EthanolTankValidator());