Skip to content

Adds packager cycle config #8577

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

Open
wants to merge 2 commits into
base: mc1.20.1/dev
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 @@ -7,6 +7,8 @@
import java.util.Set;
import java.util.UUID;

import com.simibubi.create.infrastructure.config.AllConfigs;

import org.jetbrains.annotations.Nullable;

import com.simibubi.create.AllBlocks;
Expand Down Expand Up @@ -76,7 +78,7 @@ public class PackagerBlockEntity extends SmartBlockEntity {
public PackagerItemHandler inventory;
private final LazyOptional<IItemHandler> invProvider;

public static final int CYCLE = 20;
public static final int CYCLE = AllConfigs.server().logistics.packagePackCycle.get();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config value is only applied after the game is reloaded, when used this way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CYCLE is also used outside PackagerBlockEntity.java, which this PR doesn't account for.

public int animationTicks;
public boolean animationInward;

Expand Down Expand Up @@ -133,21 +135,21 @@ public void tick() {
if (!level.isClientSide() && !queuedExitingPackages.isEmpty() && heldBox.isEmpty()) {
BigItemStack entry = queuedExitingPackages.get(0);
heldBox = entry.stack.copy();

entry.count--;
if (entry.count <= 0)
queuedExitingPackages.remove(0);

animationInward = false;
animationTicks = CYCLE;
animationTicks = AllConfigs.server().logistics.packagePackCycle.get();;
notifyUpdate();
}

return;
}

if (level.isClientSide) {
if (animationTicks == CYCLE - (animationInward ? 5 : 1))
if (animationTicks == AllConfigs.server().logistics.packagePackCycle.get() - (animationInward ? 5 : 1))
AllSoundEvents.PACKAGER.playAt(level, worldPosition, 1, 1, true);
if (animationTicks == (animationInward ? 1 : 5))
level.playLocalSound(worldPosition, SoundEvents.IRON_TRAPDOOR_CLOSE, SoundSource.BLOCKS, 0.25f, 0.75f,
Expand Down Expand Up @@ -353,7 +355,7 @@ public boolean unwrapBox(ItemStack box, boolean simulate) {
if (unpacked && !simulate) {
previouslyUnwrapped = box;
animationInward = true;
animationTicks = CYCLE;
animationTicks = AllConfigs.server().logistics.packagePackCycle.get();
notifyUpdate();
}

Expand Down Expand Up @@ -494,7 +496,7 @@ public void attemptToSend(List<PackagingRequest> queuedRequests) {

heldBox = createdBox;
animationInward = false;
animationTicks = CYCLE;
animationTicks = AllConfigs.server().logistics.packagePackCycle.get();

advancements.awardPlayer(AllAdvancements.PACKAGER);
triggerStockCheck();
Expand Down Expand Up @@ -593,15 +595,15 @@ public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {

public float getTrayOffset(float partialTicks) {
float tickCycle = animationInward ? animationTicks - partialTicks : animationTicks - 5 - partialTicks;
float progress = Mth.clamp(tickCycle / (CYCLE - 5) * 2 - 1, -1, 1);
float progress = Mth.clamp(tickCycle / (AllConfigs.server().logistics.packagePackCycle.get() - 5) * 2 - 1, -1, 1);
progress = 1 - progress * progress;
return progress * progress;
}

public ItemStack getRenderedBox() {
if (animationInward)
return animationTicks <= CYCLE / 2 ? ItemStack.EMPTY : previouslyUnwrapped;
return animationTicks >= CYCLE / 2 ? ItemStack.EMPTY : heldBox;
return animationTicks <= AllConfigs.server().logistics.packagePackCycle.get() / 2 ? ItemStack.EMPTY : previouslyUnwrapped;
return animationTicks >= AllConfigs.server().logistics.packagePackCycle.get() / 2 ? ItemStack.EMPTY : heldBox;
}

public boolean isTargetingSameInventory(@Nullable IdentifiedInventory inventory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class CLogistics extends ConfigBase {
public final ConfigInt psiTimeout = i(60, 1, "psiTimeout", Comments.psiTimeout);
public final ConfigInt mechanicalArmRange = i(5, 1, "mechanicalArmRange", Comments.mechanicalArmRange);
public final ConfigInt packagePortRange = i(5, 1, "packagePortRange", Comments.packagePortRange);
public final ConfigInt packagePackCycle = i(20, 5, "packagePackCycle", Comments.packagePackCycle);
public final ConfigInt linkRange = i(256, 1, "linkRange", Comments.linkRange);
public final ConfigInt displayLinkRange = i(64, 1, "displayLinkRange", Comments.displayLinkRange);
public final ConfigInt vaultCapacity = i(20, 1, 2048, "vaultCapacity", Comments.vaultCapacity);
Expand All @@ -32,6 +33,7 @@ private static class Comments {
"The amount of ticks a portable storage interface waits for transfers until letting contraptions move along.";
static String mechanicalArmRange = "Maximum distance in blocks a Mechanical Arm can reach across.";
static String packagePortRange = "Maximum distance in blocks a Package Port can be placed at from its target.";
static String packagePackCycle = "The amount of ticks the packager waits to pack the next package";
static String vaultCapacity = "The total amount of stacks a vault can hold per block in size.";
static String chainConveyorCapacity = "The amount of packages a chain conveyor can carry at a time.";
static String brassTunnelTimer = "The amount of ticks a brass tunnel waits between distributions.";
Expand Down