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

Quantum Chest Voiding + Quantum Storage Improvements #2078

Merged
merged 57 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
701755a
improve qchests handler
ghzdude Jul 19, 2023
9852058
more small fixes
ghzdude Sep 11, 2023
2de26dc
implement excess voiding for qchests
ghzdude Jul 19, 2023
42229a6
move item voiding button slightly
ghzdude Jul 19, 2023
03788ac
add texture for item voiding button
ghzdude Jul 19, 2023
046e370
move voiding logic to the end
ghzdude Sep 11, 2023
9c90b4e
fix tests
ghzdude Nov 2, 2023
40df68f
remove usage of deprecated method
ghzdude Nov 2, 2023
96aa823
remove early return
ghzdude Nov 2, 2023
c9a4e27
fix count of `virtualItemStack` being sent on packets
ghzdude Nov 2, 2023
4cf8bcc
fix qchest allowing insertion through output face despite default
ghzdude Nov 2, 2023
d45897f
address a few reviews
ghzdude Nov 7, 2023
3ff6690
use combinedInvntory instead of itemInventory
ghzdude Nov 7, 2023
b4d305e
add method to TextFormattingUtil
ghzdude Nov 7, 2023
91ec506
format display name with newlines
ghzdude Nov 7, 2023
4c8f848
initial work on creating tests for qchests
ghzdude Nov 8, 2023
98449cd
make certain variables protected for tests
ghzdude Nov 8, 2023
40376ed
more work on tests
ghzdude Nov 8, 2023
4b30290
fix setVoiding
ghzdude Nov 8, 2023
a148893
greatly simplify and improve insertion logic
ghzdude Nov 8, 2023
79073cf
improve tests for overflow
ghzdude Nov 8, 2023
e4a6a08
start test for extraction
ghzdude Nov 8, 2023
05c4c14
done with chest tests for now
ghzdude Nov 8, 2023
db930fa
make certain methods/variables protected for tests
ghzdude Nov 8, 2023
e826953
implement some tests for quantum tanks
ghzdude Nov 8, 2023
2d14b64
add assertion for wrong item voiding
ghzdude Nov 8, 2023
d1b378a
fix test name
ghzdude Nov 8, 2023
ac013d4
add new test for qchest
ghzdude Nov 8, 2023
69c8685
replace with todo for testing filled buckets
ghzdude Nov 8, 2023
2e27197
clean up some comments in insertion logic
ghzdude Nov 8, 2023
f69df41
add test for extraction
ghzdude Nov 8, 2023
f1af014
simplify update method
ghzdude Nov 9, 2023
5d14107
return item inventory instead of combined inventory
ghzdude Nov 9, 2023
6c823b0
extract from export slot if there's an item
ghzdude Nov 9, 2023
3c5cf0d
fix init of remaining stack
ghzdude Nov 9, 2023
46cd49f
implement special case for getting the combined items in `getStackInS…
ghzdude Nov 9, 2023
3429122
add test for `getStackInSlot()`
ghzdude Nov 9, 2023
7cb1178
remove special slot case
ghzdude Nov 9, 2023
6dd01bc
use itemInventory for the output inventory
ghzdude Nov 9, 2023
dba6a44
remove test for special slot case
ghzdude Nov 9, 2023
22af060
improve test reasonings
ghzdude Nov 9, 2023
72c9b28
further improve update method
ghzdude Nov 9, 2023
8e71e85
make `outputItemInventory` and export only handler of `combinedInvent…
ghzdude Nov 9, 2023
9f1cf4a
use `GTTransferUtils#insertItem` along with the combined inventory
ghzdude Nov 9, 2023
cb9347e
remove inserting/extracting for export slot
ghzdude Nov 9, 2023
7c97908
rework tests to work with the changes to qchests
ghzdude Nov 9, 2023
f294022
small fixes
ghzdude Nov 9, 2023
d422fe6
send voiding to client as packet
ghzdude Nov 9, 2023
ae27ae0
send voiding to client as packet on qtank as well
ghzdude Nov 9, 2023
bffcead
optimize imports for qtank test
ghzdude Nov 9, 2023
fefb807
don't return too early for checking if item is valid
ghzdude Nov 9, 2023
0dea1b8
get name from item in export slot instead of virtual item stack
ghzdude Nov 9, 2023
3f8fa63
update the displayed count with export as well
ghzdude Nov 9, 2023
a296764
make the item tooltip show export size instead of in the display GUI
ghzdude Nov 9, 2023
5c5aba2
address reviews
ghzdude Nov 12, 2023
d938551
remove commented out code
ghzdude Nov 12, 2023
7de3255
don't use java 15 method for string builder
ghzdude Nov 12, 2023
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 @@ -21,6 +21,7 @@ public static int assignId() {
public static final int UPDATE_OUTPUT_FACING = assignId();
public static final int UPDATE_AUTO_OUTPUT_ITEMS = assignId();
public static final int UPDATE_AUTO_OUTPUT_FLUIDS = assignId();
public static final int UPDATE_IS_VOIDING = assignId();

// Drum
public static final int UPDATE_AUTO_OUTPUT = assignId();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gregtech/api/gui/GuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class GuiTextures {
public static final TextureArea BUTTON_FLUID_OUTPUT = TextureArea.fullImage("textures/gui/widget/button_fluid_output_overlay.png");
public static final TextureArea BUTTON_ITEM_OUTPUT = TextureArea.fullImage("textures/gui/widget/button_item_output_overlay.png");
public static final TextureArea BUTTON_LOCK = TextureArea.fullImage("textures/gui/widget/button_lock.png");
public static final TextureArea BUTTON_VOID = TextureArea.fullImage("textures/gui/widget/button_void.png");
public static final TextureArea BUTTON_FLUID_VOID = TextureArea.fullImage("textures/gui/widget/button_fluid_void.png");
public static final TextureArea BUTTON_ITEM_VOID = TextureArea.fullImage("textures/gui/widget/button_item_void.png");
TechLord22 marked this conversation as resolved.
Show resolved Hide resolved
public static final TextureArea BUTTON_VOID_NONE = TextureArea.fullImage("textures/gui/widget/button_void_none.png");
public static final TextureArea BUTTON_VOID_MULTIBLOCK = TextureArea.fullImage("textures/gui/widget/button_void_multiblock.png");
public static final TextureArea BUTTON_LEFT = TextureArea.fullImage("textures/gui/widget/left.png");
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/gregtech/api/util/TextFormattingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,32 @@ public static String formatNumbers(double number) {
public static String formatNumbers(Object number) {
return NUMBER_FORMAT.format(number);
}

/**
* Formats a string to multiple lines, attempting to place a new line at the closest space from "maxLength" characters away.
* @param toFormat the string to be formatted to multiple lines.
* @param maxLength the length where a newline should be placed in the nearest space.
* @return a string formatted with newlines.
*/
public static String formatStringWithNewlines(String toFormat, int maxLength) {
String[] name = toFormat.split(" ");
StringBuilder builder = new StringBuilder();
int length = 0;
for (String s : name) {
length += s.length();

if (length > maxLength) {
builder.append("\n");
builder.append(s);
length = 0;
continue;
}

if (builder.length() != 0)
builder.append(" ");

builder.append(s);
}
return builder.toString();
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public class MetaTileEntityQuantumTank extends MetaTileEntity implements ITiered
protected IFluidHandler outputFluidInventory;

@Nullable
private FluidStack previousFluid;
private boolean locked;
private boolean voiding;
protected FluidStack previousFluid;
protected boolean locked;
protected boolean voiding;
@Nullable
private FluidStack lockedFluid;

Expand Down Expand Up @@ -135,7 +135,7 @@ public void update() {
}

// should only be called on the server
private void updatePreviousFluid(FluidStack currentFluid) {
protected void updatePreviousFluid(FluidStack currentFluid) {
previousFluid = currentFluid == null ? null : currentFluid.copy();
writeCustomData(UPDATE_FLUID, buf -> buf.writeCompoundTag(currentFluid == null ? null : currentFluid.writeToNBT(new NBTTagCompound())));
}
Expand Down Expand Up @@ -337,7 +337,7 @@ protected ModularUI createUI(EntityPlayer entityPlayer) {
.setTooltipText("gregtech.gui.fluid_lock.tooltip")
.shouldUseBaseBackground())
.widget(new ToggleButtonWidget(43, 64, 18, 18,
GuiTextures.BUTTON_VOID, this::isVoiding, this::setVoiding)
GuiTextures.BUTTON_FLUID_VOID, this::isVoiding, this::setVoiding)
.setTooltipText("gregtech.gui.fluid_voiding.tooltip")
.shouldUseBaseBackground())
.bindPlayerInventory(entityPlayer.inventory)
Expand Down Expand Up @@ -440,6 +440,8 @@ public void receiveCustomData(int dataId, PacketBuffer buf) {
stack.amount = Math.min(buf.readInt(), fluidTank.getCapacity());
scheduleRenderUpdate();
}
} else if (dataId == UPDATE_IS_VOIDING) {
setVoiding(buf.readBoolean());
}
}

Expand All @@ -455,6 +457,7 @@ public void writeInitialSyncData(PacketBuffer buf) {
buf.writeBoolean(autoOutputFluids);
buf.writeBoolean(locked);
buf.writeCompoundTag(fluidTank.getFluid() == null ? null : fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
buf.writeBoolean(voiding);
}

@Override
Expand All @@ -476,6 +479,7 @@ public void receiveInitialSyncData(PacketBuffer buf) {
} catch (IOException e) {
GTLog.logger.warn("Failed to load fluid from NBT in a quantum tank at " + this.getPos() + " on initial server/client sync");
}
this.voiding = buf.readBoolean();
}

public void setOutputFacing(EnumFacing outputFacing) {
Expand Down Expand Up @@ -559,11 +563,11 @@ public void setAutoOutputFluids(boolean autoOutputFluids) {
}
}

private boolean isLocked() {
protected boolean isLocked() {
return this.locked;
}

private void setLocked(boolean locked) {
protected void setLocked(boolean locked) {
if (this.locked == locked) return;
this.locked = locked;
if (!getWorld().isRemote) {
Expand All @@ -577,13 +581,14 @@ private void setLocked(boolean locked) {
this.lockedFluid = null;
}

private boolean isVoiding() {
protected boolean isVoiding() {
return voiding;
}

private void setVoiding(boolean isPartialVoid) {
protected void setVoiding(boolean isPartialVoid) {
this.voiding = isPartialVoid;
if (!getWorld().isRemote) {
writeCustomData(UPDATE_IS_VOIDING, buf -> buf.writeBoolean(this.voiding));
markDirty();
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -5190,7 +5190,7 @@ gregtech.universal.tooltip.energy_storage_capacity=§cEnergy Capacity: §f%,d EU
gregtech.universal.tooltip.energy_tier_range=§aAllowed Voltage Tiers: §f%s §f- %s
gregtech.universal.tooltip.item_storage_capacity=§6Item Slots: §f%,d
gregtech.universal.tooltip.item_storage_total=§6Item Capacity: §f%,d items
gregtech.universal.tooltip.item_stored=§dItem Stored: §f%s, %,d items
gregtech.universal.tooltip.item_stored=§dItem Stored: §f%s, %,d + %,d items
gregtech.universal.tooltip.item_transfer_rate=§bTransfer Rate: §f%,d items/s
gregtech.universal.tooltip.item_transfer_rate_stacks=§bTransfer Rate: §f%,d stacks/s
gregtech.universal.tooltip.fluid_storage_capacity=§9Fluid Capacity: §f%,d L
Expand Down Expand Up @@ -5295,6 +5295,8 @@ gregtech.gui.fluid_lock.tooltip.enabled=Fluid Locking Enabled
gregtech.gui.fluid_lock.tooltip.disabled=Fluid Locking Disabled
gregtech.gui.fluid_voiding.tooltip.enabled=Excess Fluid Voiding Enabled
gregtech.gui.fluid_voiding.tooltip.disabled=Excess Fluid Voiding Disabled
gregtech.gui.item_voiding.tooltip.enabled=Excess Item Voiding Enabled
gregtech.gui.item_voiding.tooltip.disabled=Excess Item Voiding Disabled
gregtech.gui.multiblock_item_voiding=Voiding Mode/n§7Voiding §6Items
gregtech.gui.multiblock_fluid_voiding=Voiding Mode/n§7Voiding §9Fluids
gregtech.gui.multiblock_item_fluid_voiding=Voiding Mode/n§7Voiding §6Items §7and §9Fluids
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading