Conversation
67 tasks
Justxs
reviewed
Jan 6, 2026
| } | ||
|
|
||
| @Override | ||
| public void setStackInSlot(int slot, ItemStack stack) { |
There was a problem hiding this comment.
you could reduce nesting here
@Override
public void setStackInSlot(int slot, ItemStack stack) {
validateSlotIndex(slot);
if (isEmpty(stack)) {
super.setStackInSlot(slot, null);
onContentsChanged(slot);
return;
}
for (int i = 0; i < getSlots() && stack.stackSize > 0; i++) {
if (i == slot) {
continue;
}
ItemStack existing = getStackInSlot(i);
if (!canMerge(existing, stack)) {
continue;
}
long transferable = Math.min(
stack.stackSize,
Math.min(getSlotLimit(i), getRemainingCapacity())
);
if (transferable <= 0) {
continue;
}
existing.stackSize += transferable;
stack.stackSize -= transferable;
onContentsChanged(i);
}
super.setStackInSlot(slot, stack.stackSize > 0 ? stack : null);
onContentsChanged(slot);
}
private static boolean isEmpty(ItemStack stack) {
return stack == null || stack.stackSize <= 0;
}
private static boolean canMerge(ItemStack existing, ItemStack incoming) {
return existing != null
&& incoming != null
&& ItemHandlerHelper.canItemStacksStack(existing, incoming);
}| updateCounts(); | ||
| } | ||
|
|
||
| public void updateCounts() { |
There was a problem hiding this comment.
also nesting can be reduced here too
public void updateCounts() {
itemCount = 0;
usedSlotCount = 0;
ItemStack firstStack = null;
for (ItemStack stack : stacks) {
if (!isValidStack(stack)) {
continue;
}
usedSlotCount++;
itemCount += stack.stackSize;
if (firstStack == null) {
firstStack = stack;
}
}
itemMatcher = firstStack == null
? null
: cabinet.extractMatcher(firstStack);
}
private static boolean isValidStack(ItemStack stack) {
return stack != null && stack.stackSize > 0;
}isValidStack method could be reused in other places too
| this.yaw = yaw; | ||
| } | ||
|
|
||
| public static FacingRotation calculateFacingRotation(EntityLivingBase placer) { |
There was a problem hiding this comment.
this could be divided more:
public static FacingRotation calculateFacingRotation(EntityLivingBase placer) {
ForgeDirection yaw = yawFromRotation(placer.rotationYaw);
ForgeDirection facing = facingFromPitch(placer.rotationPitch, yaw);
return new FacingRotation(facing, yaw);
}
private static ForgeDirection yawFromRotation(float rotationYaw) {
int yawIndex =
MathHelper.floor_double((rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
switch (yawIndex) {
case 1: return ForgeDirection.EAST;
case 2: return ForgeDirection.SOUTH;
case 3: return ForgeDirection.WEST;
default: return ForgeDirection.NORTH;
}
}
private static ForgeDirection facingFromPitch(float pitch, ForgeDirection yaw) {
if (pitch > 55) {
return ForgeDirection.UP;
}
if (pitch < -45) {
return ForgeDirection.DOWN;
}
return yaw;
}| * | ||
| * This rotation value is NOT based on ForgeDirection.ordinal(). | ||
| */ | ||
| default ForgeDirection getRotationForSide(ForgeDirection side, int meta) { |
There was a problem hiding this comment.
this could be a bit simpler
default ForgeDirection getRotationForSide(ForgeDirection side, int meta) {
if (side != ForgeDirection.UP && side != ForgeDirection.DOWN) {
return ForgeDirection.NORTH;
}
ForgeDirection facing = getFacing();
if (facing != ForgeDirection.UP && facing != ForgeDirection.DOWN) {
return ForgeDirection.NORTH;
}
ForgeDirection yaw = getYaw();
return facing == ForgeDirection.UP
? yaw.getOpposite()
: yaw;
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Still missing:
Texture for the buttons
Texture for the elite cabinet
Tweak the GUI to look better
todo:
add upgrade item
and possibility switch to GTNHLib json models