Skip to content

Commit

Permalink
Merge pull request #769 from SkyblockerMod/1.21
Browse files Browse the repository at this point in the history
1.21
  • Loading branch information
AzureAaron authored Jun 18, 2024
2 parents 265c09b + 9d7604c commit d6b220a
Show file tree
Hide file tree
Showing 81 changed files with 262 additions and 215 deletions.
2 changes: 1 addition & 1 deletion 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.7-SNAPSHOT'
id 'maven-publish'
id "me.modmuss50.mod-publish-plugin" version "0.5.1"
}
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ org.gradle.parallel=true

# Fabric Properties (https://fabricmc.net/versions.html)
## 1.20
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10
minecraft_version=1.21
yarn_mappings=1.21+build.1
loader_version=0.15.11

#Fabric api
## 1.20
fabric_api_version=0.100.0+1.20.6
fabric_api_version=0.100.1+1.21

# Minecraft Mods
## YACL (https://github.com/isXander/YetAnotherConfigLib)
yacl_version=3.5.0+1.20.6
yacl_version=3.5.0+1.21
## Mod Menu (https://modrinth.com/mod/modmenu/versions)
mod_menu_version = 10.0.0-beta.1
mod_menu_version = 11.0.0-beta.1
## REI (https://modrinth.com/mod/rei/versions?l=fabric)
rei_version = 13.0.666
## EMI (https://modrinth.com/mod/emi/versions)
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/hysky/skyblocker/SkyblockerScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SkyblockerScreen extends Screen {
static {
LocalDate date = LocalDate.now();

ICON = date.getMonthValue() == 4 && date.getDayOfMonth() == 1 ? new Identifier(SkyblockerMod.NAMESPACE, "icons.png") : new Identifier(SkyblockerMod.NAMESPACE, "icon.png");
ICON = date.getMonthValue() == 4 && date.getDayOfMonth() == 1 ? Identifier.of(SkyblockerMod.NAMESPACE, "icons.png") : Identifier.of(SkyblockerMod.NAMESPACE, "icon.png");
}

private SkyblockerScreen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* EMI integration
*/
public class SkyblockerEMIPlugin implements EmiPlugin {
public static final Identifier SIMPLIFIED_TEXTURES = new Identifier("emi", "textures/gui/widgets.png");
public static final Identifier SIMPLIFIED_TEXTURES = Identifier.of("emi", "textures/gui/widgets.png");
// TODO: Custom simplified texture for Skyblock
public static final EmiRecipeCategory SKYBLOCK = new EmiRecipeCategory(new Identifier(SkyblockerMod.NAMESPACE, "skyblock"), EmiStack.of(ItemUtils.getSkyblockerStack()), new EmiTexture(SIMPLIFIED_TEXTURES, 240, 240, 16, 16));
public static final EmiRecipeCategory SKYBLOCK = new EmiRecipeCategory(Identifier.of(SkyblockerMod.NAMESPACE, "skyblock"), EmiStack.of(ItemUtils.getSkyblockerStack()), new EmiTexture(SIMPLIFIED_TEXTURES, 240, 240, 16, 16));

@Override
public void register(EmiRegistry registry) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/hysky/skyblocker/config/ConfigUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static <E extends Enum<E>> Function<Option<E>, ControllerBuilder<E>> getE
public static OptionDescription withImage(Path imagePath, @Nullable Text... texts) {
return OptionDescription.createBuilder()
.text(ArrayUtils.isNotEmpty(texts) ? texts : new Text[] {})
.image(IMAGE_DIRECTORY.resolve(imagePath), new Identifier(SkyblockerMod.NAMESPACE, "config_image_" + FileUtils.normalizePath(imagePath)))
.image(IMAGE_DIRECTORY.resolve(imagePath), Identifier.of(SkyblockerMod.NAMESPACE, "config_image_" + FileUtils.normalizePath(imagePath)))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ public static class ItemInfoDisplay {
}

public enum RarityBackgroundStyle {
CIRCULAR(new Identifier(SkyblockerMod.NAMESPACE, "item_rarity_background_circular")),
SQUARE(new Identifier(SkyblockerMod.NAMESPACE, "item_rarity_background_square"));
CIRCULAR(Identifier.of(SkyblockerMod.NAMESPACE, "item_rarity_background_circular")),
SQUARE(Identifier.of(SkyblockerMod.NAMESPACE, "item_rarity_background_square"));

public final Identifier tex;

Expand All @@ -181,8 +181,8 @@ public static class ItemProtection {
}

public enum SlotLockStyle {
CLASSIC(new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/slot_lock.png")),
FANCY(new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/fancy_slot_lock.png"));
CLASSIC(Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/slot_lock.png")),
FANCY(Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/fancy_slot_lock.png"));

public final Identifier tex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public ItemData(String item) {
}

public ItemData(String item, int count, String components) {
this(Registries.ITEM.get(new Identifier(item)), count, components);
this(Registries.ITEM.get(Identifier.ofVanilla(item)), count, components);
}

public ItemData(Item item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static DataFixer build() {
Schema schema3 = builder.addSchema(3, Schema::new);
builder.addFixer(new ConfigFix2QuickNav(schema3, true));

return builder.buildUnoptimized();
return builder.build().fixer();
}

private static JsonObject loadConfig(Path path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ private <T> Dynamic<T> fix(Dynamic<T> dynamic) {
}

private <T> Dynamic<T> fixButton(Dynamic<T> button) {
return button.renameAndFixField("item", "itemData", itemData -> itemData.renameAndFixField("id", "item", id -> id.createString(new Identifier(id.asString().getOrThrow()).toString())));
return button.renameAndFixField("item", "itemData", itemData -> itemData.renameAndFixField("id", "item", id -> id.createString(Identifier.of(id.asString().getOrThrow()).toString())));
}
}
5 changes: 3 additions & 2 deletions src/main/java/de/hysky/skyblocker/events/HudRenderEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderTickCounter;

/**
* HUD render events that allow for proper layering between different HUD elements.
Expand Down Expand Up @@ -43,8 +44,8 @@ public interface HudRenderStage {
* Called sometime during a specific HUD render stage.
*
* @param drawContext The {@link DrawContext} instance
* @param tickDelta Progress for linearly interpolating between the previous and current game state
* @param tickCounter The {@link RenderTickCounter} instance
*/
void onRender(DrawContext context, float tickDelta);
void onRender(DrawContext context, RenderTickCounter tickCounter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import de.hysky.skyblocker.utils.Utils;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.component.ComponentHolder;
import net.minecraft.component.DataComponentType;
import net.minecraft.component.ComponentType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.item.trim.ArmorTrim;
Expand All @@ -21,7 +21,7 @@ public interface ComponentHolderMixin {

@SuppressWarnings("unchecked")
@ModifyReturnValue(method = "get", at = @At("RETURN"))
private <T> T skyblocker$customArmorTrims(T original, DataComponentType<? extends T> dataComponentType) {
private <T> T skyblocker$customArmorTrims(T original, ComponentType<? extends T> dataComponentType) {
if (Utils.isOnSkyblock() && ((Object) this) instanceof ItemStack stack) {
if (dataComponentType == DataComponentTypes.TRIM) {
Object2ObjectOpenHashMap<String, CustomArmorTrims.ArmorTrimId> customTrims = SkyblockerConfigManager.get().general.customArmorTrims;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
private static final int OUT_OF_BOUNDS_SLOT = -999;

@Unique
private static final Identifier ITEM_PROTECTION = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/item_protection.png");
private static final Identifier ITEM_PROTECTION = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/item_protection.png");

@Unique
private static final Set<String> FILLER_ITEMS = Set.of(
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/de/hysky/skyblocker/mixins/InGameHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class InGameHudMixin {
private static final Supplier<Identifier> SLOT_LOCK_ICON = () -> SkyblockerConfigManager.get().general.itemProtection.slotLockStyle.tex;

@Unique
private static final Identifier ITEM_PROTECTION = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/item_protection.png");
private static final Identifier ITEM_PROTECTION = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/item_protection.png");
@Unique
private static final Pattern DICER_TITLE_BLACKLIST = Pattern.compile(".+? DROP!");

Expand All @@ -58,7 +58,7 @@ public abstract class InGameHudMixin {
@Final
private LayeredDrawer layeredDrawer;

@Inject(method = "renderHotbar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;renderHotbarItem(Lnet/minecraft/client/gui/DrawContext;IIFLnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;I)V", ordinal = 0))
@Inject(method = "renderHotbar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;renderHotbarItem(Lnet/minecraft/client/gui/DrawContext;IILnet/minecraft/client/render/RenderTickCounter;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;I)V", ordinal = 0))
public void skyblocker$renderHotbarItemLockOrRarityBg(CallbackInfo ci, @Local(argsOnly = true) DrawContext context, @Local(ordinal = 4, name = "m") int index, @Local(ordinal = 5, name = "n") int x, @Local(ordinal = 6, name = "o") int y, @Local PlayerEntity player) {
if (Utils.isOnSkyblock()) {
// slot lock
Expand Down Expand Up @@ -141,17 +141,17 @@ public abstract class InGameHudMixin {

@ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/LayeredDrawer;addLayer(Lnet/minecraft/client/gui/LayeredDrawer$Layer;)Lnet/minecraft/client/gui/LayeredDrawer;", ordinal = 2))
private LayeredDrawer.Layer skyblocker$afterMainHud(LayeredDrawer.Layer mainHudLayer) {
return (context, tickDelta) -> {
mainHudLayer.render(context, tickDelta);
HudRenderEvents.AFTER_MAIN_HUD.invoker().onRender(context, tickDelta);
return (context, tickCounter) -> {
mainHudLayer.render(context, tickCounter);
HudRenderEvents.AFTER_MAIN_HUD.invoker().onRender(context, tickCounter);
};
}

@ModifyArg(method = "<init>", slice = @Slice(from = @At(value = "NEW", target = "Lnet/minecraft/client/gui/LayeredDrawer;", ordinal = 1)), at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/LayeredDrawer;addLayer(Lnet/minecraft/client/gui/LayeredDrawer$Layer;)Lnet/minecraft/client/gui/LayeredDrawer;", ordinal = 5))
private LayeredDrawer.Layer skyblocker$beforeChat(LayeredDrawer.Layer beforeChatLayer) {
return (context, tickDelta) -> {
HudRenderEvents.BEFORE_CHAT.invoker().onRender(context, tickDelta);
beforeChatLayer.render(context, tickDelta);
return (context, tickCounter) -> {
HudRenderEvents.BEFORE_CHAT.invoker().onRender(context, tickCounter);
beforeChatLayer.render(context, tickCounter);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.component.ComponentHolder;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.item.TooltipAppender;
import net.minecraft.item.tooltip.TooltipAppender;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.text.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public interface BeaconBlockEntityRendererInvoker {
@SuppressWarnings("unused")
@Invoker("renderBeam")
static void renderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, float[] color) {
static void renderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float tickDelta, long worldTime, int yOffset, int maxY, int color) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static void render(WorldRenderContext wrc, int range) {
render(wrc, blockHitResult);
} else if (client.interactionManager != null && range > client.player.getAttributeInstance(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE).getValue()) {
@SuppressWarnings("DataFlowIssue")
HitResult result = client.player.raycast(range, wrc.tickDelta(), false);
HitResult result = client.player.raycast(range, wrc.tickCounter().getTickDelta(true), false);
if (result.getType() == HitResult.Type.BLOCK && result instanceof BlockHitResult blockHitResult) {
render(wrc, blockHitResult);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@

public class AuctionBrowserScreen extends AbstractCustomHypixelGUI<AuctionHouseScreenHandler> {
private static final Logger LOGGER = LoggerFactory.getLogger(AuctionBrowserScreen.class);
private static final Identifier TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background.png");
private static final Identifier SCROLLER_TEXTURE = new Identifier("container/creative_inventory/scroller");
private static final Identifier TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background.png");
private static final Identifier SCROLLER_TEXTURE = Identifier.ofVanilla("container/creative_inventory/scroller");

private static final Identifier up_arrow_tex = new Identifier(SkyblockerMod.NAMESPACE, "up_arrow_even"); // Put them in their own fields to avoid object allocation on each frame
private static final Identifier down_arrow_tex = new Identifier(SkyblockerMod.NAMESPACE, "down_arrow_even");
private static final Identifier up_arrow_tex = Identifier.of(SkyblockerMod.NAMESPACE, "up_arrow_even"); // Put them in their own fields to avoid object allocation on each frame
private static final Identifier down_arrow_tex = Identifier.of(SkyblockerMod.NAMESPACE, "down_arrow_even");
public static final Supplier<Sprite> UP_ARROW = () -> MinecraftClient.getInstance().getGuiAtlasManager().getSprite(up_arrow_tex);
public static final Supplier<Sprite> DOWN_ARROW = () -> MinecraftClient.getInstance().getGuiAtlasManager().getSprite(down_arrow_tex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.concurrent.atomic.AtomicReference;

public class AuctionViewScreen extends AbstractCustomHypixelGUI<AuctionHouseScreenHandler> {
protected static final Identifier BACKGROUND_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background_view.png");
protected static final Identifier BACKGROUND_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/browser/background_view.png");

public static final int BACK_BUTTON_SLOT = 49;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public enum Option implements SliderWidget.OptionInfo {

private final Identifier texture;
private static final String prefix = "textures/gui/auctions_gui/auction_type_widget/";
private static final Identifier HOVER_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "hover.png");
private static final Identifier BACK_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "back.png");
private static final Identifier HOVER_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, prefix + "hover.png");
private static final Identifier BACK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, prefix + "back.png");

Option(String textureName) {
texture = new Identifier(SkyblockerMod.NAMESPACE, prefix + textureName);
texture = Identifier.of(SkyblockerMod.NAMESPACE, prefix + textureName);
}

private static final AuctionTypeWidget.Option[] values = values();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import de.hysky.skyblocker.utils.render.gui.SideTabButtonWidget;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.item.TooltipType;
import net.minecraft.item.Item.TooltipContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;

import org.jetbrains.annotations.NotNull;

public class CategoryTabWidget extends SideTabButtonWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

public class RarityWidget extends ClickableWidget {

private static final Identifier HOVER_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/rarity_widget/hover.png");
private static final Identifier TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/rarity_widget/background.png");
private static final Identifier HOVER_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/rarity_widget/hover.png");
private static final Identifier TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, "textures/gui/auctions_gui/rarity_widget/background.png");
private final SlotClickHandler onClick;
private int slotId = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public enum Option implements SliderWidget.OptionInfo {

private final Identifier texture;
private static final String prefix = "textures/gui/auctions_gui/sort_widget/";
private static final Identifier HOVER_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "hover.png");
private static final Identifier BACK_TEXTURE = new Identifier(SkyblockerMod.NAMESPACE, prefix + "back.png");
private static final Identifier HOVER_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, prefix + "hover.png");
private static final Identifier BACK_TEXTURE = Identifier.of(SkyblockerMod.NAMESPACE, prefix + "back.png");

Option(String textureName) {
texture = new Identifier(SkyblockerMod.NAMESPACE, prefix + textureName);
texture = Identifier.of(SkyblockerMod.NAMESPACE, prefix + textureName);
}

public Identifier getOptionTexture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.hysky.skyblocker.events.HudRenderEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;

Expand All @@ -13,11 +14,11 @@ public class ChatRuleAnnouncementScreen {
private static Text text = null;

public static void init() {
HudRenderEvents.BEFORE_CHAT.register((context, tickDelta) -> {
HudRenderEvents.BEFORE_CHAT.register((context, tickCounter) -> {
if (timer <= 0 || text == null) {
return;
}
render(context, tickDelta);
render(context, tickCounter);
});
}

Expand All @@ -26,10 +27,10 @@ public static void init() {
* @param context render context
* @param tickDelta difference from last render to remove from timer
*/
private static void render(DrawContext context, float tickDelta) {
private static void render(DrawContext context, RenderTickCounter tickCounter) {
int scale = SkyblockerConfigManager.get().chat.chatRuleConfig.announcementScale;
//decrement timer
timer -= tickDelta;
timer -= tickCounter.getTickDelta(true);
//scale text up and center
MatrixStack matrices = context.getMatrices();
matrices.push();
Expand Down
Loading

0 comments on commit d6b220a

Please sign in to comment.