-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new pumps #84
new pumps #84
Conversation
сюда случайно попал коммит на новый баланс статов нефтекачек, но это тоже нужно, так что не думаю что проблема |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Приношу свои извинения, но очень сильно захотелось так сделать.
@Override | ||
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { | ||
super.onPostTick(aBaseMetaTileEntity, aTick); | ||
if (aBaseMetaTileEntity.isServerSide()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сделать return, если тикает у клиента.
if (aBaseMetaTileEntity.isServerSide()) { | |
if (this.isClientSide(aBaseMetaTileEntity)) { | |
mMaxProgresstime = 0; | |
return; | |
} | |
... | |
private bool isClientSide(IGregTechTileEntity aBaseMetaTileEntity) | |
{ | |
return !aBaseMetaTileEntity.isServerSide(); | |
} |
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { | ||
super.onPostTick(aBaseMetaTileEntity, aTick); | ||
if (aBaseMetaTileEntity.isServerSide()) { | ||
if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isUniversalEnergyStored(ENERGY[mTier] * (SPEED[mTier] - mProgresstime)) && hasFreeSpace()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Было бы круто вынести в отдельный метод проверки связанные с TE
if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isUniversalEnergyStored(ENERGY[mTier] * (SPEED[mTier] - mProgresstime)) && hasFreeSpace()) { | |
if ( | |
isTEAllowedToWorkAndStoredEnoughEnergy(aBaseMetaTileEntity) | |
&& hasFreeSpace() | |
) { | |
... | |
private bool isTEAllowedToWorkAndStoredEnoughEnergy(IGregTechTileEntity aBaseMetaTileEntity) | |
{ | |
return aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isUniversalEnergyStored(ENERGY[mTier] * (SPEED[mTier] - mProgresstime)); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нет ни малейшего смысла создавать функции которые будут использованы ровно 1 раз, функции нужны для упрощения понимания или для уменьшения количества кода, тут имхо ни того, ни другого
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
К сожалению, с этой стороны есть только мое имхо по которому и я предложил данное изменение.
if (aBaseMetaTileEntity.isServerSide()) { | ||
if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isUniversalEnergyStored(ENERGY[mTier] * (SPEED[mTier] - mProgresstime)) && hasFreeSpace()) { | ||
miningPipe: | ||
if (waitMiningPipe) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно вынести весь цикл в метод и, возможно, избавиться от флага waitMiningPipe.
if (waitMiningPipe) { | |
if (waitMiningPipe && noMiningPipesInInput()) { | |
mMaxProgresstime = 0; | |
return; | |
} | |
... | |
private bool noMiningPipesInInput() | |
{ | |
for (int i = 0; i < mInputSlotCount; i++) { | |
ItemStack s = getInputAt(i); | |
if (s != null && s.getItem() == MINING_PIPE.getItem() && s.stackSize > 0) { | |
waitMiningPipe = false; | |
return false; | |
} | |
} | |
return true; | |
} |
@@ -87,7 +87,7 @@ protected void setElectricityStats() { | |||
this.mEfficiencyIncrease = 10000; | |||
int tier = Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); | |||
this.mEUt = -3 * (1 << (tier << 1)); | |||
this.mMaxProgresstime = (workState == STATE_AT_BOTTOM ? (1280 * getRangeInChunks() * getRangeInChunks() / (1 << getMinTier())) : 80) / (1 << tier); | |||
this.mMaxProgresstime = (workState == STATE_AT_BOTTOM ? 320 : 80) / (1 << tier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не может ли быть такого, что эти значения уже вынесены в константы?
В любом случае их лучше вынести в константы.
mMaxProgresstime = 0; | ||
return; | ||
} | ||
if (mProgresstime == SPEED[mTier] - 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выражение SPEED[mTier] - 1 стоит тоже вынести, но его смысл для меня непонятен, поэтому на ваше усмотрение.
if (mProgresstime == SPEED[mTier] - 1) { | |
if (mProgresstime != SPEED[mTier] - 1) { | |
return; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это самый банальный счетчик тиков, если поставить =! то будет работать каждый тик за исключением заданного значения => неверная работа
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Обращаю внимание на 68 строку в ченже.
return; | ||
} | ||
if (mProgresstime == SPEED[mTier] - 1) { | ||
if (isPickingPipes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
После предыдущего ченжа будет логичнее избавиться от return'a и превратить конструкцию в
if (isPickingPipes) { | |
if (isPickingPipes) { | |
} else { | |
} |
} | ||
return; | ||
} | ||
if (drillY == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выражение drillY == 0 || drillZ > RADIUS[mTier] тоже стоит вынести в отдельную функцию, но название для меня вообще не очевидно, поэтому на ваше усмотрение.
if (drillY == 0) { | |
if (drillY == 0 || drillZ > RADIUS[mTier]) { | |
moveOneDown(aBaseMetaTileEntity); | |
} else { | |
while (drillZ <= RADIUS[mTier]) { | |
while (drillX <= RADIUS[mTier]) { | |
if(workBlock(aBaseMetaTileEntity)) | |
return; | |
drillX++; | |
} | |
drillX = -RADIUS[mTier]; | |
drillZ++; | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
эта проверка совершенно лишняя, помпа не может добывать жидкости на том же уровне на котором находится контроллер
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Объединил оригинальные 80 и 84 строки, чтобы избавиться от return'ов.
if (drillY == 0) { | ||
aBaseMetaTileEntity.disableWorking(); | ||
isPickingPipes = false; | ||
} else if (aBaseMetaTileEntity.getBlockOffset(0, drillY, 0) == MINING_PIPE_TIP_BLOCK || aBaseMetaTileEntity.getBlockOffset(0, drillY, 0) == MINING_PIPE_BLOCK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if (aBaseMetaTileEntity.getBlockOffset(0, drillY, 0) == MINING_PIPE_TIP_BLOCK || aBaseMetaTileEntity.getBlockOffset(0, drillY, 0) == MINING_PIPE_BLOCK) { | |
} else if (isPipeBelowTEOnOffset(drillY) { | |
... | |
private bool isPipeBelowTEOnOffset(int offset) | |
{ | |
return aBaseMetaTileEntity.getBlockOffset(0, offset, 0) == MINING_PIPE_TIP_BLOCK | |
|| aBaseMetaTileEntity.getBlockOffset(0, offset, 0) == MINING_PIPE_BLOCK; | |
} |
} | ||
} else { | ||
ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta)); | ||
if (association != null && association.mPrefix.toString().startsWith("ore")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Немного странно, что "ore" за столько лет не вынесли в константу )
if (association != null && association.mPrefix.toString().startsWith("ore")) { | |
if (doesBlockHaveOreAssociation(block, blockMeta)) { | |
... | |
private bool doesBlockHaveOreAssociation(Block block, int blockMeta) | |
{ | |
ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta)); | |
return association != null && association.mPrefix.toString().startsWith("ore"); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а смысл констранты из 3х букв? думаешь это может изменится в будущем ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это скорее nit, просто выразил удивление, что нет стандарта для наименований.
int blockMeta = aBaseMetaTileEntity.getMetaIDOffset(drillX, drillY, drillZ); | ||
if (block instanceof GT_Block_Ores_Abstract) { | ||
TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(drillX, drillY, drillZ); | ||
if (tTileEntity != null && tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (tTileEntity != null && tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural) { | |
if (tTileEntity != null && isNaturalOre(tTileEntity )) { | |
... | |
private bool isNaturalOre(TileEntity tTileEntity) | |
{ | |
return tTileEntity instanceof GT_TileEntity_Ores | |
&& ((GT_TileEntity_Ores) tTileEntity).mNatural; | |
} |
переписал помпы, теперь аналогичны майнерам