Post-merge fixes and item generator fix.
This commit is contained in:
@@ -314,7 +314,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends HandledScr
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
// Forward left mouse button up events to the scrollbar
|
||||
if (button == 0 && this.getScrollBar() != null) {
|
||||
if (this.getScrollBar().mouseUp(mouseX - this.guiLeft, mouseY - this.guiTop)) {
|
||||
if (this.getScrollBar().mouseUp(mouseX - this.x, mouseY - this.y)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@ package appeng.client.gui.widgets;
|
||||
import java.time.Duration;
|
||||
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.Rect2i;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.renderer.Rectangle2d;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
@@ -55,20 +53,20 @@ public class Scrollbar extends DrawableHelper implements IScrollSource {
|
||||
/**
|
||||
* Texture containing the scrollbar handle sprites.
|
||||
*/
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("minecraft",
|
||||
private static final Identifier TEXTURE = new Identifier("minecraft",
|
||||
"textures/gui/container/creative_inventory/tabs.png");
|
||||
|
||||
/**
|
||||
* Rectangle in the source texture that contains the sprite for an enabled
|
||||
* handle.
|
||||
*/
|
||||
private static final Rectangle2d ENABLED = new Rectangle2d(232, 0, HANDLE_WIDTH, HANDLE_HEIGHT);
|
||||
private static final Rect2i ENABLED = new Rect2i(232, 0, HANDLE_WIDTH, HANDLE_HEIGHT);
|
||||
|
||||
/**
|
||||
* Rectangle in the source texture that contains the sprite for a disabled
|
||||
* handle.
|
||||
*/
|
||||
private static final Rectangle2d DISABLED = new Rectangle2d(232 + HANDLE_WIDTH, 0, HANDLE_WIDTH, HANDLE_HEIGHT);
|
||||
private static final Rect2i DISABLED = new Rect2i(232 + HANDLE_WIDTH, 0, HANDLE_WIDTH, HANDLE_HEIGHT);
|
||||
|
||||
/**
|
||||
* The screen x-coordinate of the scrollbar's inner track.
|
||||
@@ -115,7 +113,7 @@ public class Scrollbar extends DrawableHelper implements IScrollSource {
|
||||
* background.
|
||||
*/
|
||||
public void draw(MatrixStack matrices, final AEBaseScreen<?> g) {
|
||||
setBlitOffset(g.getBlitOffset());
|
||||
setZOffset(g.getZOffset());
|
||||
|
||||
// Draw the track (nice for debugging)
|
||||
// fill(matrices, displayX, displayY, this.displayX + width, this.displayY +
|
||||
@@ -124,7 +122,7 @@ public class Scrollbar extends DrawableHelper implements IScrollSource {
|
||||
g.bindTexture(TEXTURE);
|
||||
|
||||
int yOffset;
|
||||
Rectangle2d sourceRect;
|
||||
Rect2i sourceRect;
|
||||
if (this.getRange() == 0) {
|
||||
yOffset = 0;
|
||||
sourceRect = DISABLED;
|
||||
@@ -133,7 +131,7 @@ public class Scrollbar extends DrawableHelper implements IScrollSource {
|
||||
sourceRect = ENABLED;
|
||||
}
|
||||
|
||||
blit(matrices, this.displayX, this.displayY + yOffset, sourceRect.getX(), sourceRect.getY(),
|
||||
drawTexture(matrices, this.displayX, this.displayY + yOffset, sourceRect.getX(), sourceRect.getY(),
|
||||
sourceRect.getWidth(), sourceRect.getHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import alexiil.mc.lib.attributes.AttributeList;
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.ItemExtractable;
|
||||
import alexiil.mc.lib.attributes.item.filter.ExactItemStackFilter;
|
||||
import alexiil.mc.lib.attributes.item.filter.ItemFilter;
|
||||
@@ -43,7 +44,7 @@ public class ItemGenBlockEntity extends AEBaseBlockEntity {
|
||||
|
||||
private static final Queue<ItemStack> POSSIBLE_ITEMS = new ArrayDeque<>();
|
||||
|
||||
private final ItemExtractable handler = new QueuedItemHandler();
|
||||
private final QueuedItemHandler handler = new QueuedItemHandler();
|
||||
|
||||
public ItemGenBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
@@ -77,22 +78,24 @@ public class ItemGenBlockEntity extends AEBaseBlockEntity {
|
||||
to.offer(handler);
|
||||
}
|
||||
|
||||
class QueuedItemHandler implements ItemExtractable {
|
||||
static class QueuedItemHandler implements FixedItemInv {
|
||||
|
||||
@Override
|
||||
public ItemStack attemptExtraction(ItemFilter itemFilter, int maxAmount, Simulation simulation) {
|
||||
// When item filter asks for a specific item, just return that
|
||||
if (itemFilter instanceof ExactItemStackFilter) {
|
||||
return ((ExactItemStackFilter) itemFilter).stack.copy();
|
||||
}
|
||||
public ItemExtractable getExtractable() {
|
||||
return (itemFilter, i, simulation) -> {
|
||||
// When item filter asks for a specific item, just return that
|
||||
if (itemFilter instanceof ExactItemStackFilter) {
|
||||
return ((ExactItemStackFilter) itemFilter).stack.copy();
|
||||
}
|
||||
|
||||
final ItemStack is = POSSIBLE_ITEMS.peek();
|
||||
final ItemStack is = POSSIBLE_ITEMS.peek();
|
||||
|
||||
if (is == null || !itemFilter.matches(is)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (is == null || !itemFilter.matches(is)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return simulation == Simulation.SIMULATE ? is.copy() : this.getNextItem();
|
||||
return simulation == Simulation.SIMULATE ? is.copy() : getNextItem();
|
||||
};
|
||||
}
|
||||
|
||||
private ItemStack getNextItem() {
|
||||
@@ -101,7 +104,28 @@ public class ItemGenBlockEntity extends AEBaseBlockEntity {
|
||||
POSSIBLE_ITEMS.add(is);
|
||||
return is.copy();
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
@Override
|
||||
public int getSlotCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getInvStack(int i) {
|
||||
return POSSIBLE_ITEMS.peek().copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setInvStack(int i, ItemStack itemStack, Simulation simulation) {
|
||||
if (itemStack.isEmpty()) {
|
||||
getNextItem(); // Go to next item
|
||||
}
|
||||
return itemStack.isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user