Skip to content

Commit

Permalink
update to minecraft 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Oct 14, 2023
1 parent 2307dc3 commit 3e73805
Show file tree
Hide file tree
Showing 67 changed files with 304 additions and 308 deletions.
4 changes: 2 additions & 2 deletions common/src/main/java/hunternif/mc/api/AtlasAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.registry.Registries;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -33,7 +33,7 @@ public static int getVersion() {
}

public static Item getAtlasItem() {
return Registry.ITEM.get(new Identifier("antiqueatlas:antique_atlas"));
return Registries.ITEM.get(new Identifier("antiqueatlas:antique_atlas"));
}

/**
Expand Down
13 changes: 6 additions & 7 deletions common/src/main/java/hunternif/mc/impl/atlas/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceReloader;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;

import java.util.Map;
Expand Down Expand Up @@ -63,15 +62,15 @@ public void initClient() {
* we need the ClientWorld loaded here.
*/
public static void assignCustomBiomeTextures(ClientWorld world) {
for (Map.Entry<RegistryKey<Biome>, Biome> biome : BuiltinRegistries.BIOME.getEntrySet()) {
Identifier id = BuiltinRegistries.BIOME.getId(biome.getValue());
for (Map.Entry<RegistryKey<Biome>, Biome> biome : world.getRegistryManager().get(RegistryKeys.BIOME).getEntrySet()) {
Identifier id = world.getRegistryManager().get(RegistryKeys.BIOME).getId(biome.getValue());
if (!TileTextureMap.instance().isRegistered(id)) {
TileTextureMap.instance().autoRegister(id, biome.getKey());
}
}

for (Map.Entry<RegistryKey<Biome>, Biome> entry : world.getRegistryManager().get(Registry.BIOME_KEY).getEntrySet()) {
Identifier id = world.getRegistryManager().get(Registry.BIOME_KEY).getId(entry.getValue());
for (Map.Entry<RegistryKey<Biome>, Biome> entry : world.getRegistryManager().get(RegistryKeys.BIOME).getEntrySet()) {
Identifier id = world.getRegistryManager().get(RegistryKeys.BIOME).getId(entry.getValue());
if (!TileTextureMap.instance().isRegistered(id)) {
TileTextureMap.instance().autoRegister(id, entry.getKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.registry.RegistryKey;
import net.minecraft.world.World;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.mojang.blaze3d.systems.RenderSystem;
import hunternif.mc.api.client.AtlasClientAPI;
import hunternif.mc.impl.atlas.AntiqueAtlasMod;
import hunternif.mc.impl.atlas.item.AntiqueAtlasItems;
import hunternif.mc.impl.atlas.client.gui.GuiAtlas;
import hunternif.mc.impl.atlas.core.WorldData;
import hunternif.mc.impl.atlas.item.AntiqueAtlasItems;
import hunternif.mc.impl.atlas.item.AtlasItem;
import hunternif.mc.impl.atlas.marker.DimensionMarkersData;
import hunternif.mc.impl.atlas.marker.Marker;
Expand All @@ -16,21 +16,20 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3f;
import net.minecraft.world.World;
import org.joml.Quaternionf;
import org.lwjgl.opengl.GL11;

import java.util.List;

@Environment(EnvType.CLIENT)
public class OverlayRenderer extends DrawableHelper {
public class OverlayRenderer {
/**
* Number of blocks per chunk in minecraft. This is certianly stored
* somewhere else, but I couldn't be bothered to find it.
Expand Down Expand Up @@ -148,7 +147,7 @@ private void drawPlayer(VertexConsumerProvider buffer, MatrixStack matrices, int
matrices.push();

matrices.translate((int) ((GuiAtlas.WIDTH * 1.5F) / 2F), (int) ((GuiAtlas.HEIGHT * 1.5F) / 2F), 0);
matrices.multiply(new Quaternion(Vec3f.POSITIVE_Z, this.player.getHeadYaw() + 180, true));
matrices.multiply(new Quaternionf(RotationAxis.POSITIVE_Z.rotationDegrees(this.player.getHeadYaw() + 180)));
matrices.translate(-AntiqueAtlasMod.CONFIG.playerIconWidth / 2.0, -AntiqueAtlasMod.CONFIG.playerIconHeight / 2.0, 0);

Textures.PLAYER.drawWithLight(buffer, matrices, 0, 0, AntiqueAtlasMod.CONFIG.playerIconWidth, AntiqueAtlasMod.CONFIG.playerIconHeight, light);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.tag.BiomeTags;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.tag.BiomeTags;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;

import java.util.*;
Expand Down Expand Up @@ -96,7 +96,7 @@ static private Optional<Identifier> guessFittingTextureSet(RegistryKey<Biome> bi
if (MinecraftClient.getInstance().world == null)
return Optional.empty();

RegistryEntry<Biome> biomeTag = MinecraftClient.getInstance().world.getRegistryManager().get(Registry.BIOME_KEY).entryOf(biome);
RegistryEntry<Biome> biomeTag = MinecraftClient.getInstance().world.getRegistryManager().get(RegistryKeys.BIOME).entryOf(biome);

if (biomeIsVoid(biomeTag)) {
return Optional.of(AntiqueAtlasMod.id("end_void"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package hunternif.mc.impl.atlas.client.gui;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import hunternif.mc.impl.atlas.util.ExportImageUtil;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import org.lwjgl.opengl.GL11;

public enum ExportProgressOverlay {
INSTANCE;

@Environment(EnvType.CLIENT)
public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) {
public void draw(DrawContext context, int scaledWidth, int scaledHeight) {
int x = scaledWidth - 40, y = scaledHeight - 20, barWidth = 50, barHeight = 2;

ExportUpdateListener l = ExportUpdateListener.INSTANCE;
Expand All @@ -31,9 +28,9 @@ public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) {
int s = 2;

int headerWidth = font.getWidth(l.header);
font.draw(matrices, l.header, (x) * s - headerWidth / 2F, (y) * s - 14, 0xffffff);
context.drawText(font, l.header, (int) ((x) * s - headerWidth / 2F), (y) * s - 14, 0xffffff, false);
int statusWidth = font.getWidth(l.status);
font.draw(matrices, l.status, (x) * s - statusWidth / 2F, (y) * s, 0xffffff);
context.drawText(font, l.status, (int) ((x) * s - statusWidth / 2F), (y) * s, 0xffffff, false);

y += 7;

Expand All @@ -42,8 +39,6 @@ public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) {
if (l.maxProgress < 0)
p = 0;

RenderSystem.disableTexture();

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vb = tessellator.getBuffer();

Expand All @@ -60,7 +55,5 @@ public void draw(MatrixStack matrices, int scaledWidth, int scaledHeight) {
vb.vertex(x + barWidth * p, y, 0).color(0.5f, 1, 0.5f, 1).next();

tessellator.draw();

RenderSystem.enableTexture();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.mojang.blaze3d.systems.RenderSystem;
import hunternif.mc.impl.atlas.client.Textures;
import hunternif.mc.impl.atlas.client.gui.core.GuiComponentButton;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;
import org.lwjgl.opengl.GL11;

public class GuiArrowButton extends GuiComponentButton {
Expand Down Expand Up @@ -44,7 +44,7 @@ static GuiArrowButton right() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTick) {
public void render(DrawContext context, int mouseX, int mouseY, float partialTick) {
RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

Expand Down Expand Up @@ -81,7 +81,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTi
v = 12;
break;
}
Textures.BTN_ARROWS.draw(matrices, x, y, u, v, WIDTH, HEIGHT);
Textures.BTN_ARROWS.draw(context, x, y, u, v, WIDTH, HEIGHT);

RenderSystem.disableBlend();
}
Expand Down
Loading

0 comments on commit 3e73805

Please sign in to comment.