Skip to content

Commit

Permalink
Update to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaocihua committed Oct 27, 2024
1 parent 56554ac commit 4a6b0a0
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 44 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Publish on Github, Curseforge & Modrinth
on: [ workflow_dispatch ]

env:
RELEASE_NAME: 0.5.10 for Minecraft 1.21-1.21.1
RELEASE_NAME: 0.5.10 for Minecraft 1.21.2-1.21.3
VERSION: 0.5.10
MC_VERSION: mc1.21.1
MC_VERSION: mc1.21.3

permissions:
contents: write
Expand Down Expand Up @@ -54,8 +54,8 @@ jobs:

loaders: fabric
game-versions: |
1.21
1.21.1
1.21.2
1.21.3
java: |
21
22
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -38,7 +38,7 @@ repositories.named("Mojang", MavenArtifactRepository) {
loom {
runs {
client {
runDir = "run1.21.1"
runDir = "run1.21.3"
vmArgs("-XX:+AllowEnhancedClassRedefinition", "-XX:HotswapAgent=fatjar")
programArgs("--width=1280", "--height=720")
}
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.5
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.7

# Fabric API
fabric_version=0.104.0+1.21.1
fabric_version=0.107.0+1.21.3

# https://github.com/CottonMC/LibGui/releases
LibGui_version=11.0.0+1.21
LibGui_version=12.0.0+1.21.2

# https://github.com/TerraformersMC/ModMenu/releases
modmenu_version=11.0.1
modmenu_version=12.0.0-beta.1

# https://github.com/emilyploszaj/emi/releases
emi_version=1.1.7+1.21
emi_version=1.1.16+1.21.1

# https://modrinth.com/mod/rei/versions
rei_version=16.0.729
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mojang.blaze3d.systems.RenderSystem;
import io.github.xiaocihua.stacktonearbychests.event.ClickSlotCallback;
import io.github.xiaocihua.stacktonearbychests.event.DisconnectCallback;
import io.github.xiaocihua.stacktonearbychests.mixin.HandledScreenAccessor;
Expand All @@ -15,6 +14,7 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.texture.Sprite;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
Expand Down Expand Up @@ -333,8 +333,10 @@ public static void drawFavoriteItemStyle(DrawContext context, Slot slot, boolean
Sprite sprite = MinecraftClient.getInstance()
.getSpriteAtlas(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE)
.apply(Identifier.of(id.getNamespace(), "item/" + id.getPath()));
RenderSystem.setShaderTexture(0, sprite.getAtlasId());
context.drawSprite(slot.x, slot.y, isForeground ? 300 : 200, 16, 16, sprite);
//RenderSystem.setShaderTexture(0, sprite.getAtlasId());
//context.drawSprite(slot.x, slot.y, isForeground ? 300 : 200, 16, 16, sprite);
context.drawSpriteStretched(isForeground ? RenderLayer::getGuiTexturedOverlay : RenderLayer::getGuiTextured,
sprite, slot.x, slot.y, 16, 16);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ private void addButtonsAndKeys(MinecraftClient client, Screen screen, int scaled
ModOptions.Appearance appearanceOption = ModOptions.get().appearance;
boolean showButtonTooltip = appearanceOption.showButtonTooltip.booleanValue();

if (screen instanceof AbstractInventoryScreen<?> inventoryScreen) {
if (screen instanceof InventoryScreen || screen instanceof CreativeInventoryScreen) {

if (screen instanceof InventoryScreen
|| screen instanceof CreativeInventoryScreen && appearanceOption.showTheButtonsOnTheCreativeInventoryScreen.booleanValue()) {
addButtonsOnInventoryScreen((ScreenExtensions) screen, inventoryScreen, showButtonTooltip, appearanceOption);
if (appearanceOption.showTheButtonsOnTheCreativeInventoryScreen.booleanValue()) {
addButtonsOnInventoryScreen((HandledScreen<?>) screen, showButtonTooltip, appearanceOption);
}

ScreenKeyboardEvents.afterKeyPress(screen).register((scr, key, scancode, modifiers) -> {
Expand All @@ -93,7 +92,7 @@ private void addButtonsAndKeys(MinecraftClient client, Screen screen, int scaled

boolean triggered = false;

Slot focusedSlot = ((HandledScreenAccessor) inventoryScreen).getFocusedSlot();
Slot focusedSlot = ((HandledScreenAccessor) screen).getFocusedSlot();
if (focusedSlot != null && focusedSlot.hasStack()) {
triggered = keymap.quickStackItemsOfTheSameTypeAsTheOneUnderTheCursorToNearbyContainersKey
.testThenRun(() -> InventoryActions.stackToNearbyContainers(focusedSlot.getStack().getItem()));
Expand Down Expand Up @@ -137,15 +136,15 @@ private void addButtonsAndKeys(MinecraftClient client, Screen screen, int scaled
}
}

private static void addButtonsOnInventoryScreen(ScreenExtensions screen, AbstractInventoryScreen<?> inventoryScreen, boolean showButtonTooltip, ModOptions.Appearance appearanceOption) {
private static void addButtonsOnInventoryScreen(HandledScreen<?> screen, boolean showButtonTooltip, ModOptions.Appearance appearanceOption) {
if (ModOptions.get().appearance.showStackToNearbyContainersButton.booleanValue()) {
var buttonWidget = new PosUpdatableButtonWidget.Builder(inventoryScreen)
var buttonWidget = new PosUpdatableButtonWidget.Builder(screen)
.setTextures(getButtonTextures("quick_stack_to_nearby_containers_button"))
.setTooltip(showButtonTooltip ? getTooltipWithHint("stack-to-nearby-chests.tooltip.stackToNearbyContainersButton") : null)
.setPosUpdater(parent -> new Vec2i(parent.getX() + appearanceOption.stackToNearbyContainersButtonPosX.intValue(),
parent.getY() + appearanceOption.stackToNearbyContainersButtonPosY.intValue()))
.setPressAction(button -> {
ScreenHandler screenHandler = inventoryScreen.getScreenHandler();
ScreenHandler screenHandler = screen.getScreenHandler();
ItemStack cursorStack = screenHandler.getCursorStack();
if (cursorStack.isEmpty()) {
InventoryActions.stackToNearbyContainers();
Expand All @@ -167,11 +166,11 @@ private static void addButtonsOnInventoryScreen(ScreenExtensions screen, Abstrac

currentStackToNearbyContainersButton = Optional.ofNullable(buttonWidget);

screen.fabric_getRemoveEvent().register(s -> currentStackToNearbyContainersButton = Optional.empty());
((ScreenExtensions) screen).fabric_getRemoveEvent().register(s -> currentStackToNearbyContainersButton = Optional.empty());
}

if (ModOptions.get().appearance.showRestockFromNearbyContainersButton.booleanValue()) {
new PosUpdatableButtonWidget.Builder(inventoryScreen)
new PosUpdatableButtonWidget.Builder(screen)
.setTextures(getButtonTextures("restock_from_nearby_containers_button"))
.setTooltip(showButtonTooltip ? getTooltipWithHint("stack-to-nearby-chests.tooltip.restockFromNearbyContainersButton") : null)
.setPosUpdater(parent -> new Vec2i(parent.getX() + appearanceOption.restockFromNearbyContainersButtonPosX.intValue(),
Expand Down Expand Up @@ -227,7 +226,8 @@ public static boolean isContainerScreen(Screen screen) {
|| screen instanceof MerchantScreen
|| screen instanceof ForgingScreen<?>
|| screen instanceof StonecutterScreen
|| screen instanceof AbstractInventoryScreen<?>
|| screen instanceof InventoryScreen
|| screen instanceof CreativeInventoryScreen
) {
return false;
} else if (screen instanceof HorseScreen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import io.github.xiaocihua.stacktonearbychests.ModOptions;
import io.github.xiaocihua.stacktonearbychests.StackToNearbyChests;
import io.github.xiaocihua.stacktonearbychests.mixin.HandledScreenAccessor;
import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;

public class EmiPluginImpl implements EmiPlugin {
@Override
public void register(EmiRegistry registry) {
registry.addGenericExclusionArea((screen, consumer) -> {
ModOptions.Appearance appearanceOption = ModOptions.get().appearance;

if (screen instanceof AbstractInventoryScreen<?> inventoryScreen) {
int parentX = ((HandledScreenAccessor) inventoryScreen).getX();
int parentY = ((HandledScreenAccessor) inventoryScreen).getY();
if (screen instanceof InventoryScreen || screen instanceof CreativeInventoryScreen) {
int parentX = ((HandledScreenAccessor) screen).getX();
int parentY = ((HandledScreenAccessor) screen).getY();

if (ModOptions.get().appearance.showStackToNearbyContainersButton.booleanValue()) {
consumer.accept(new Bounds(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.screen.ExclusionZones;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -20,9 +21,9 @@ public void registerExclusionZones(ExclusionZones exclusionZones) {
List<Rectangle> zones = new ArrayList<>();
ModOptions.Appearance appearanceOption = ModOptions.get().appearance;

if (screen instanceof AbstractInventoryScreen<?> inventoryScreen) {
int parentX = ((HandledScreenAccessor) inventoryScreen).getX();
int parentY = ((HandledScreenAccessor) inventoryScreen).getY();
if (screen instanceof InventoryScreen || screen instanceof CreativeInventoryScreen) {
int parentX = ((HandledScreenAccessor) screen).getX();
int parentY = ((HandledScreenAccessor) screen).getY();

if (ModOptions.get().appearance.showStackToNearbyContainersButton.booleanValue()) {
zones.add(new Rectangle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BlockContainerEntry extends SelectableEntryList.Entry<Identifier> {

public BlockContainerEntry(Identifier id) {
super(id);
Optional<Block> block = Registries.BLOCK.getOrEmpty(id);
Optional<Block> block = Registries.BLOCK.getOptionalValue(id);
icon = block.map(b -> new ItemIcon(b.asItem()));
name = block.<Text>map(Block::getName).orElse(Text.of(id.toString()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class EntityContainerEntry extends SelectableEntryList.Entry<Identifier>{

public EntityContainerEntry(Identifier id) {
super(id);
name = Registries.ENTITY_TYPE.getOrEmpty(id).map(EntityType::getName).orElse(Text.of(id.toString()));
name = Registries.ENTITY_TYPE.getOptionalValue(id).map(EntityType::getName).orElse(Text.of(id.toString()));
}

public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import io.github.cottonmc.cotton.gui.widget.data.Axis;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
import io.github.cottonmc.cotton.gui.widget.data.Insets;
import io.github.cottonmc.cotton.gui.widget.data.Texture;
import juuxel.libninepatch.NinePatch;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -106,7 +108,8 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {

@Override
public BackgroundPainter getBackgroundPainter() {
return BackgroundPainter.createNinePatch(Identifier.of(MOD_ID, "textures/background_dark_bordered.png"));
return BackgroundPainter.createNinePatch(new Texture(Identifier.of(MOD_ID, "textures/background_dark_bordered.png")),
builder -> builder.mode(NinePatch.Mode.STRETCHING).cornerSize(4).cornerUv(0.25f));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ItemEntry extends SelectableEntryList.Entry<Identifier> {

public ItemEntry(Identifier id) {
super(id);
Optional<Item> item = Registries.ITEM.getOrEmpty(id);
Optional<Item> item = Registries.ITEM.getOptionalValue(id);
icon = item.<Icon>map(ItemIcon::new).orElse(new TextureIcon(MissingSprite.getMissingSpriteId()));
name = item.map(Item::getName).orElse(Text.of(id.toString()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.client.gui.widget.TexturedButtonWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;
Expand All @@ -39,8 +38,9 @@ private PosUpdatableButtonWidget(int width,
@Override
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
posUpdater.ifPresent(updater -> setPos(updater.apply((HandledScreenAccessor) parent)));
Identifier identifier = this.textures.get(this.isNarratable(), this.isHovered());
context.drawGuiTexture(identifier, this.getX(), this.getY(), this.width, this.height);
super.renderWidget(context, mouseX, mouseY, delta);
// Identifier identifier = this.textures.get(this.isNarratable(), this.isHovered());
// context.drawGuiTexture(identifier, this.getX(), this.getY(), this.width, this.height);
}

public void setPos(Vec2i pos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import io.github.cottonmc.cotton.gui.widget.WWidget;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
import io.github.cottonmc.cotton.gui.widget.data.InputResult;
import io.github.cottonmc.cotton.gui.widget.data.Texture;
import juuxel.libninepatch.NinePatch;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawContext;
Expand Down Expand Up @@ -219,7 +221,8 @@ public static abstract class Entry<D> extends WWidget {

protected static final int TEXT_COLOR = 16119285;
private static final BackgroundPainter UNSELECTED = BackgroundPainter.createNinePatch(Identifier.of(MOD_ID, "textures/background_dark.png"));
private static final BackgroundPainter SELECTED = BackgroundPainter.createNinePatch(Identifier.of(MOD_ID, "textures/background_dark_selected.png"));
private static final BackgroundPainter SELECTED = BackgroundPainter.createNinePatch(new Texture(Identifier.of(MOD_ID, "textures/background_dark_selected.png")),
builder -> builder.mode(NinePatch.Mode.STRETCHING).cornerSize(4).cornerUv(0.25f));
protected Optional<SelectableEntryList<D>> parentList = Optional.empty();
protected boolean isSelected = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import io.github.cottonmc.cotton.gui.widget.data.Axis;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
import io.github.cottonmc.cotton.gui.widget.data.InputResult;
import io.github.cottonmc.cotton.gui.widget.data.Texture;
import io.github.cottonmc.cotton.gui.widget.icon.Icon;
import io.github.xiaocihua.stacktonearbychests.ModOptions;
import juuxel.libninepatch.NinePatch;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -267,7 +269,8 @@ public void accept(TooltipBuilder builder) {
@Environment(EnvType.CLIENT)
final static class Painters {
static final BackgroundPainter SELECTED_TAB =
BackgroundPainter.createNinePatch(Identifier.of(ModOptions.MOD_ID, "textures/selected_tab.png"));
BackgroundPainter.createNinePatch(new Texture(Identifier.of(ModOptions.MOD_ID, "textures/selected_tab.png")),
builder -> builder.mode(NinePatch.Mode.STRETCHING).cornerSize(4).cornerUv(0.25f));
static final BackgroundPainter UNSELECTED_TAB =
BackgroundPainter.createNinePatch(Identifier.of(ModOptions.MOD_ID, "textures/background_dark.png"));
}
Expand Down

0 comments on commit 4a6b0a0

Please sign in to comment.