Skip to content
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

Stocking hatch & bus disabling #4013

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,9 @@ public void enableWorking() {
if (!mWorks) mWorkUpdate = true;
mWorks = true;
setShutdownStatus(false);
if (hasValidMetaTileEntity()) {
mMetaTileEntity.onEnableWorking();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public void onTickFail(IGregTechTileEntity baseMetaTileEntity, long tick) {}

public void onSetActive(boolean active) {}

public void onEnableWorking() {}

public void onDisableWorking() {}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH_ACTIVE;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -136,17 +137,30 @@ public ITexture[] getTexturesInactive(ITexture aBaseTexture) {

@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
if (getBaseMetaTileEntity().isServerSide()) {
if (aBaseMetaTileEntity.isServerSide()) {
if (aTimer % autoPullRefreshTime == 0 && autoPullItemList) {
refreshItemList();
}
if (aTimer % 20 == 0) {
getBaseMetaTileEntity().setActive(isActive());
aBaseMetaTileEntity.setActive(isActive());
}
}
super.onPostTick(aBaseMetaTileEntity, aTimer);
}

protected boolean isAllowedToWork() {
IGregTechTileEntity igte = getBaseMetaTileEntity();

return igte != null && igte.isAllowedToWork();
}

@Override
public void onEnableWorking() {
if (expediteRecipeCheck) {
justHadNewItems = true;
}
}

@Override
public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
super.onFirstTick(aBaseMetaTileEntity);
Expand Down Expand Up @@ -433,7 +447,7 @@ public boolean setStackToZeroInsteadOfNull(int aIndex) {

@Override
public boolean justUpdated() {
if (expediteRecipeCheck) {
if (expediteRecipeCheck && isAllowedToWork()) {
boolean ret = justHadNewItems;
justHadNewItems = false;
return ret;
Expand All @@ -456,22 +470,37 @@ public void setInventorySlotContents(int aIndex, ItemStack aStack) {
@Override
public ItemStack getStackInSlot(int aIndex) {
if (!processingRecipe) return super.getStackInSlot(aIndex);

if (aIndex < 0 || aIndex > mInventory.length) return null;
if (aIndex >= SLOT_COUNT && aIndex < SLOT_COUNT * 2)
// Display slots
return null;

// Display slots
if (aIndex >= SLOT_COUNT && aIndex < SLOT_COUNT * 2) return null;

if (aIndex == getCircuitSlot() || aIndex == getManualSlot()) return mInventory[aIndex];

if (mInventory[aIndex] != null) {

AENetworkProxy proxy = getProxy();
if (proxy == null || !proxy.isActive()) {
return null;
}

if (!isAllowedToWork()) {
this.shadowInventory[aIndex] = null;
this.savedStackSizes[aIndex] = 0;
super.setInventorySlotContents(aIndex + SLOT_COUNT, null);
return null;
}

try {
IMEMonitor<IAEItemStack> sg = proxy.getStorage()
.getItemInventory();

IAEItemStack request = AEItemStack.create(mInventory[aIndex]);
request.setStackSize(Integer.MAX_VALUE);

IAEItemStack result = sg.extractItems(request, Actionable.SIMULATE, getRequestSource());

if (result != null) {
this.shadowInventory[aIndex] = result.getItemStack();
this.savedStackSizes[aIndex] = this.shadowInventory[aIndex].stackSize;
Expand Down Expand Up @@ -597,6 +626,14 @@ public ItemStack updateInformationSlot(int aIndex, ItemStack aStack) {
super.setInventorySlotContents(aIndex + SLOT_COUNT, null);
return null;
}

if (!isAllowedToWork()) {
this.shadowInventory[aIndex] = null;
this.savedStackSizes[aIndex] = 0;
super.setInventorySlotContents(aIndex + SLOT_COUNT, null);
return null;
}

try {
IMEMonitor<IAEItemStack> sg = proxy.getStorage()
.getItemInventory();
Expand Down Expand Up @@ -764,12 +801,23 @@ private boolean containsSuchStack(ItemStack tStack) {
boolean isActive = isActive();
boolean isPowered = isPowered();
boolean isBooting = isBooting();
EnumChatFormatting color = (isActive && isPowered) ? EnumChatFormatting.GREEN : EnumChatFormatting.DARK_RED;
return color + WailaText.getPowerState(isActive, isPowered, isBooting);

String state = WailaText.getPowerState(isActive, isPowered, isBooting);

if (isActive && isPowered) {
return MessageFormat.format(
"{0}{1}§f ({2})",
EnumChatFormatting.GREEN,
state,
StatCollector
.translateToLocal(isAllowedToWork() ? "GT5U.gui.text.enabled" : "GT5U.gui.text.disabled"));
} else {
return EnumChatFormatting.DARK_RED + state;
}
})
.setTextAlignment(Alignment.Center)
.setSize(90, 9)
.setPos(43, 84))
.setSize(130, 9)
.setPos(23, 84))
.widget(
new SlotWidget(inventoryHandler, getManualSlot())
// ghost slots are prioritized over manual slot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_FLUID_HATCH;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_FLUID_HATCH_ACTIVE;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
Expand Down Expand Up @@ -145,17 +146,30 @@ public ITexture[] getTexturesInactive(ITexture aBaseTexture) {

@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
if (getBaseMetaTileEntity().isServerSide()) {
if (aBaseMetaTileEntity.isServerSide()) {
if (aTimer % autoPullRefreshTime == 0 && autoPullFluidList) {
refreshFluidList();
}
if (aTimer % 20 == 0) {
getBaseMetaTileEntity().setActive(isActive());
aBaseMetaTileEntity.setActive(isActive());
}
}
super.onPostTick(aBaseMetaTileEntity, aTimer);
}

protected boolean isAllowedToWork() {
IGregTechTileEntity igte = getBaseMetaTileEntity();

return igte != null && igte.isAllowedToWork();
}

@Override
public void onEnableWorking() {
if (expediteRecipeCheck) {
justHadNewFluids = true;
}
}

private void refreshFluidList() {
AENetworkProxy proxy = getProxy();
if (proxy == null || !proxy.isActive()) {
Expand Down Expand Up @@ -228,7 +242,7 @@ public FluidStack[] getStoredFluids() {

@Override
public boolean justUpdated() {
if (expediteRecipeCheck) {
if (expediteRecipeCheck && isAllowedToWork()) {
boolean ret = justHadNewFluids;
justHadNewFluids = false;
return ret;
Expand Down Expand Up @@ -415,6 +429,11 @@ public void updateInformationSlot(int index) {
return;
}

if (!isAllowedToWork()) {
storedInformationFluids[index] = null;
return;
}

try {
IMEMonitor<IAEFluidStack> sg = proxy.getStorage()
.getFluidInventory();
Expand Down Expand Up @@ -820,13 +839,23 @@ public void buildTooltip(List<Text> tooltip) {
boolean isActive = isActive();
boolean isPowered = isPowered();
boolean isBooting = isBooting();
EnumChatFormatting color = (isActive && isPowered) ? EnumChatFormatting.GREEN
: EnumChatFormatting.DARK_RED;
return color + WailaText.getPowerState(isActive, isPowered, isBooting);

String state = WailaText.getPowerState(isActive, isPowered, isBooting);

if (isActive && isPowered) {
return MessageFormat.format(
"{0}{1}§f ({2})",
EnumChatFormatting.GREEN,
state,
StatCollector
.translateToLocal(isAllowedToWork() ? "GT5U.gui.text.enabled" : "GT5U.gui.text.disabled"));
} else {
return EnumChatFormatting.DARK_RED + state;
}
})
.setTextAlignment(Alignment.Center)
.setSize(90, 9)
.setPos(43, 84));
.setSize(130, 9)
.setPos(23, 84));
}

private FluidStackTank createTankForFluidStack(FluidStack[] fluidStacks, int slotIndex, int capacity) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/gregtech/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,8 @@ GT5U.gui.too_many_hatches=Too many %ses (max %s)
GT5U.gui.text.power_panel=Power Control Panel
GT5U.gui.text.too_uncertain=Too Uncertain.
GT5U.gui.text.invalid_parameters=Invalid Parameters.
GT5U.gui.text.enabled=§aEnabled§f
GT5U.gui.text.disabled=§cDisabled§f


GT5U.gui.config.client=Client
Expand Down