Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
senseiwells committed Jun 21, 2024
1 parent 87bf93c commit d11403e
Show file tree
Hide file tree
Showing 24 changed files with 219 additions and 295 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jar {
publishMods {
file = remapJar.archiveFile
changelog = """
- Updated to 1.20.6
- Updated to 1.21
"""
type = STABLE
modLoaders.add("fabric")
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ systemProp.org.gradle.internal.http.socketTimeout=180000
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G
# Fabric Properties
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.2
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
# Mod Properties
mod_version=1.5.1
mod_version=1.5.2
maven_group=essential-client
# Dependencies
carpet_version=1.4.141
fabric_version=0.99.0+1.20.6
modmenu_version=10.0.0-beta.1
carpet_version=1.4.147
fabric_version=0.100.3+1.21
modmenu_version=11.0.0
arucas_version=d4a71bde0640e678a75795a156d9d38aad4c6f30
bytebuddy_version=1.14.11
minecraft_dependency=1.20.x
minecraft_dependency=1.21.x
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -152,6 +153,5 @@ public static void addMinecraftAPI(ArucasAPI.Builder builder) {
builder.addConversion(ItemStackArgument.class, (s, i) -> EssentialUtils.throwAsUnchecked(() -> i.create(ItemStackDef.class, new ScriptItemStack(s.createStack(1, false)))));
builder.addConversion(BlockStateArgument.class, (b, i) -> i.create(BlockDef.class, new ScriptBlockState(b.getBlockState(), null)));
builder.addConversion(Identifier.class, (id, i) -> i.create(StringDef.class, id.toString()));
builder.addConversion(Enchantment.class, (e, i) -> i.convertValue(Registries.ENCHANTMENT.getId(e)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.DisconnectionInfo;
import net.minecraft.network.packet.c2s.play.PickFromInventoryC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.network.packet.c2s.play.SpectatorTeleportC2SPacket;
Expand Down Expand Up @@ -938,7 +939,7 @@ private Void clickRecipe2(Arguments arguments) {
private Void logout(Arguments arguments) {
String reason = arguments.skip().nextPrimitive(StringDef.class);
ClientScriptUtils.ensureMainThread("logout", arguments.getInterpreter(), () -> {
EssentialUtils.getNetworkHandler().onDisconnected(Text.literal(reason));
EssentialUtils.getNetworkHandler().onDisconnected(new DisconnectionInfo(Text.literal(reason)));
});
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.network.DisconnectionInfo;
import net.minecraft.util.math.Vec3d;

public class AFKRules {
Expand Down Expand Up @@ -37,7 +38,7 @@ public class AFKRules {
wasAfk = true;
}
if (logout >= 200 && ticks == logout) {
playerEntity.networkHandler.onDisconnected(Texts.AFK);
playerEntity.networkHandler.onDisconnected(new DisconnectionInfo(Texts.AFK));
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public static Identifier getCurrentCape() {
}

private static Identifier id(String name) {
return new Identifier("essentialclient", "textures/capes/" + name + ".png");
return Identifier.of("essentialclient", "textures/capes/" + name + ".png");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
import net.minecraft.world.GameRules;

import java.util.function.BiFunction;
Expand Down Expand Up @@ -146,7 +147,7 @@ private void refreshScreen() {
}

private static class GameRuleHelloPayload extends HelloPayload {
public static final Id<GameRuleHelloPayload> ID = CustomPayload.id("essential:game_rule_hello");
public static final Id<GameRuleHelloPayload> ID = new CustomPayload.Id<>(Identifier.of("essential:game_rule_hello"));
public static final PacketCodec<PacketByteBuf, GameRuleHelloPayload> CODEC = PacketCodec.of(
HelloPayload::write,
GameRuleHelloPayload::new
Expand All @@ -167,7 +168,7 @@ public Id<? extends CustomPayload> getId() {
}

private record SetGameRulePayload(String name, String value) implements CustomPayload {
public static final Id<SetGameRulePayload> ID = CustomPayload.id("essential:set_game_rule");
public static final Id<SetGameRulePayload> ID = new CustomPayload.Id<>(Identifier.of("essential:set_game_rule"));
public static final PacketCodec<PacketByteBuf, SetGameRulePayload> CODEC = PacketCodec.of(
(payload, buf) -> buf.writeString(payload.name).writeString(payload.value),
(buf) -> new SetGameRulePayload(buf.readString(), buf.readString())
Expand All @@ -180,7 +181,7 @@ public Id<? extends CustomPayload> getId() {
}

private record GameRulesChangedPayload(NbtCompound compound) implements CustomPayload {
public static final Id<GameRulesChangedPayload> ID = CustomPayload.id("essential:game_rules_changed");
public static final Id<GameRulesChangedPayload> ID = new CustomPayload.Id<>(Identifier.of("essential:game_rules_changed"));
public static final PacketCodec<PacketByteBuf, GameRulesChangedPayload> CODEC = PacketCodec.of(
(payload, buf) -> buf.writeNbt(payload.compound),
(buf) -> new GameRulesChangedPayload(buf.readNbt())
Expand All @@ -193,7 +194,7 @@ public Id<? extends CustomPayload> getId() {
}

private record GameRulePermissionsPayload(boolean canUpdateGamerules) implements CustomPayload {
public static final Id<GameRulePermissionsPayload> ID = CustomPayload.id("essential:game_rule_permissions");
public static final Id<GameRulePermissionsPayload> ID = new CustomPayload.Id<>(Identifier.of("essential:game_rule_permissions"));
public static final PacketCodec<PacketByteBuf, GameRulePermissionsPayload> CODEC = PacketCodec.of(
(payload, buf) -> buf.writeBoolean(payload.canUpdateGamerules),
(buf) -> new GameRulePermissionsPayload(buf.readBoolean())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public class HighlightLiquids implements SimpleSynchronousResourceReloadListener
private static final int DEFAULT_WATER_COLOUR;

static {
LAVA_FLOWING_SPRITE_ID = new Identifier("essentialclient", "block/lava_flow");
LAVA_STILL_SPRITE_ID = new Identifier("essentialclient", "block/lava_still");
WATER_FLOWING_SPRITE_ID = new Identifier("essentialclient", "block/water_flow");
WATER_STILL_SPRITE_ID = new Identifier("essentialclient", "block/water_still");
LAVA_FLOWING_SPRITE_ID = Identifier.of("essentialclient", "block/lava_flow");
LAVA_STILL_SPRITE_ID = Identifier.of("essentialclient", "block/lava_still");
WATER_FLOWING_SPRITE_ID = Identifier.of("essentialclient", "block/water_flow");
WATER_STILL_SPRITE_ID = Identifier.of("essentialclient", "block/water_still");

DEFAULT_WATER_COLOUR = 0x3F76E4;
}
Expand Down Expand Up @@ -115,6 +115,6 @@ public int getFluidColor(@Nullable BlockRenderView view, @Nullable BlockPos pos,

@Override
public Identifier getFabricId() {
return new Identifier("lava_reload_listener");
return Identifier.of("lava_reload_listener");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;

Expand Down Expand Up @@ -128,7 +129,7 @@ protected HelloPayload createHelloPayload(String brand, int version) {
}

private static class ChunkDebugHelloPayload extends HelloPayload {
public static final Id<ChunkDebugHelloPayload> ID = CustomPayload.id("chunk_debug:hello");
public static final Id<ChunkDebugHelloPayload> ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:hello"));
public static final PacketCodec<PacketByteBuf, ChunkDebugHelloPayload> CODEC = PacketCodec.of(
ChunkDebugHelloPayload::write,
ChunkDebugHelloPayload::new
Expand All @@ -152,7 +153,7 @@ private record BatchedChunkInfoPayload(
RegistryKey<World> world,
List<ChunkInfo> infos
) implements CustomPayload {
public static final Id<BatchedChunkInfoPayload> ID = CustomPayload.id("chunk_debug:batched_chunk_info");
public static final Id<BatchedChunkInfoPayload> ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:batched_chunk_info"));
public static final PacketCodec<PacketByteBuf, BatchedChunkInfoPayload> CODEC = PacketCodec.of(
BatchedChunkInfoPayload::write,
BatchedChunkInfoPayload::read
Expand Down Expand Up @@ -207,7 +208,7 @@ public static BatchedChunkInfoPayload read(PacketByteBuf buf) {
}

private record StopChunkInfoPayload() implements CustomPayload {
public static final Id<StopChunkInfoPayload> ID = CustomPayload.id("chunk_debug:stop");
public static final Id<StopChunkInfoPayload> ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:stop"));
public static final PacketCodec<PacketByteBuf, StopChunkInfoPayload> CODEC = PacketCodec.unit(new StopChunkInfoPayload());

@Override
Expand All @@ -217,7 +218,7 @@ public Id<? extends CustomPayload> getId() {
}

private record SetChunkDimensionPayload(RegistryKey<World> dimension) implements CustomPayload {
public static final Id<SetChunkDimensionPayload> ID = CustomPayload.id("chunk_debug:set_dimension");
public static final Id<SetChunkDimensionPayload> ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:set_dimension"));
public static final PacketCodec<PacketByteBuf, SetChunkDimensionPayload> CODEC = PacketCodec.of(
SetChunkDimensionPayload::write,
SetChunkDimensionPayload::new
Expand All @@ -238,7 +239,7 @@ public Id<? extends CustomPayload> getId() {
}

private record ReloadChunkDebugPayload() implements CustomPayload {
public static final Id<ReloadChunkDebugPayload> ID = CustomPayload.id("chunk_debug:reload");
public static final Id<ReloadChunkDebugPayload> ID = new CustomPayload.Id<>(Identifier.of("chunk_debug:reload"));
public static final PacketCodec<PacketByteBuf, ReloadChunkDebugPayload> CODEC = PacketCodec.unit(new ReloadChunkDebugPayload());

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
ChunkGrid.instance.render(0, HEADER_HEIGHT, this.width, this.height - HEADER_HEIGHT - FOOTER_HEIGHT, false);

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
this.drawHeaderAndFooterGradient(tessellator, bufferBuilder);
this.drawHeaderAndFooterTexture(tessellator, bufferBuilder);
this.drawHeaderAndFooterGradient(tessellator);
this.drawHeaderAndFooterTexture(tessellator);
super.render(context, mouseX, mouseY, delta);

if (ChunkGrid.instance.isPanning()) {
Expand Down Expand Up @@ -148,49 +147,45 @@ public void renderBackground(DrawContext context, int mouseX, int mouseY, float

}

private void drawHeaderAndFooterGradient(Tessellator tessellator, BufferBuilder bufferBuilder) {
private void drawHeaderAndFooterGradient(Tessellator tessellator) {
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

RenderHelper.startQuads(bufferBuilder, VertexFormats.POSITION_COLOR);
BufferBuilder bufferBuilder = RenderHelper.startQuads(tessellator, VertexFormats.POSITION_COLOR);

// Header gradient
bufferBuilder.vertex(0, HEADER_HEIGHT, 0).color(0, 0, 0, 255).next();
bufferBuilder.vertex(0, HEADER_HEIGHT + 4, 0).color(0, 0, 0, 0).next();
bufferBuilder.vertex(this.width, HEADER_HEIGHT + 4, 0).color(0, 0, 0, 0).next();
bufferBuilder.vertex(this.width, HEADER_HEIGHT, 0).color(0, 0, 0, 255).next();
bufferBuilder.vertex(0, HEADER_HEIGHT, 0).color(0, 0, 0, 255);
bufferBuilder.vertex(0, HEADER_HEIGHT + 4, 0).color(0, 0, 0, 0);
bufferBuilder.vertex(this.width, HEADER_HEIGHT + 4, 0).color(0, 0, 0, 0);
bufferBuilder.vertex(this.width, HEADER_HEIGHT, 0).color(0, 0, 0, 255);

// Footer gradient
bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT - 4, 0).color(0, 0, 0, 0).next();
bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT, 0).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT, 0).color(0, 0, 0, 255).next();
bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT - 4, 0).color(0, 0, 0, 0).next();

tessellator.draw();
bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT - 4, 0).color(0, 0, 0, 0);
bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT, 0).color(0, 0, 0, 255);
bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT, 0).color(0, 0, 0, 255);
bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT - 4, 0).color(0, 0, 0, 0);
}

private void drawHeaderAndFooterTexture(Tessellator tessellator, BufferBuilder bufferBuilder) {
private void drawHeaderAndFooterTexture(Tessellator tessellator) {
RenderHelper.setPositionTextureColourShader();
// RenderHelper.bindTexture(OPTIONS_BACKGROUND_TEXTURE);

RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend();

RenderHelper.startQuads(bufferBuilder, VertexFormats.POSITION_TEXTURE_COLOR);
BufferBuilder bufferBuilder = RenderHelper.startQuads(tessellator, VertexFormats.POSITION_TEXTURE_COLOR);

// Header
bufferBuilder.vertex(0, 0, 0).texture(0, 0).color(64, 64, 64, 255).next();
bufferBuilder.vertex(0, HEADER_HEIGHT, 0).texture(0, HEADER_HEIGHT / 32f).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.width, HEADER_HEIGHT, 0).texture(this.width / 32f, HEADER_HEIGHT / 32f).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.width, 0, 0).texture(this.width / 32f, 0).color(64, 64, 64, 255).next();
bufferBuilder.vertex(0, 0, 0).texture(0, 0).color(64, 64, 64, 255);
bufferBuilder.vertex(0, HEADER_HEIGHT, 0).texture(0, HEADER_HEIGHT / 32f).color(64, 64, 64, 255);
bufferBuilder.vertex(this.width, HEADER_HEIGHT, 0).texture(this.width / 32f, HEADER_HEIGHT / 32f).color(64, 64, 64, 255);
bufferBuilder.vertex(this.width, 0, 0).texture(this.width / 32f, 0).color(64, 64, 64, 255);

// Footer
bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT, 0).texture(0, (this.height - FOOTER_HEIGHT) / 32f).color(64, 64, 64, 255).next();
bufferBuilder.vertex(0, this.height, 0).texture(0, this.height / 32f).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.width, this.height, 0).texture(this.width / 32f, this.height / 32f).color(64, 64, 64, 255).next();
bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT, 0).texture(this.width / 32f, (this.height - FOOTER_HEIGHT) / 32f).color(64, 64, 64, 255).next();

tessellator.draw();
bufferBuilder.vertex(0, this.height - FOOTER_HEIGHT, 0).texture(0, (this.height - FOOTER_HEIGHT) / 32f).color(64, 64, 64, 255);
bufferBuilder.vertex(0, this.height, 0).texture(0, this.height / 32f).color(64, 64, 64, 255);
bufferBuilder.vertex(this.width, this.height, 0).texture(this.width / 32f, this.height / 32f).color(64, 64, 64, 255);
bufferBuilder.vertex(this.width, this.height - FOOTER_HEIGHT, 0).texture(this.width / 32f, (this.height - FOOTER_HEIGHT) / 32f).color(64, 64, 64, 255);
}

@Override
Expand Down
Loading

0 comments on commit d11403e

Please sign in to comment.