Skip to content

Commit

Permalink
Update Forge/NeoForge to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
pop4959 committed Jun 17, 2024
1 parent 80d0c75 commit be9f7b8
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 20 deletions.
4 changes: 2 additions & 2 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repositories {
}

dependencies {
minecraft(group = "com.mojang", name = "minecraft", version = "1.20.6")
minecraft(group = "com.mojang", name = "minecraft", version = "1.21")
mappings(loom.officialMojangMappings())
forge(group = "net.minecraftforge", name = "forge", version = "1.20.6-50.0.30")
forge(group = "net.minecraftforge", name = "forge", version = "1.21-51.0.8")
modImplementation(group = "org.popcraft", name = "chunky-forge", version = "${project.property("target")}")
compileOnly(group = "us.dynmap", name = "DynmapCoreAPI", version = "${project.property("target_dynmap")}")
compileOnly(group = "com.github.BlueMap-Minecraft", name = "BlueMapAPI", version = "${project.property("target_bluemap")}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
@Mod(ChunkyBorderForge.MOD_ID)
public class ChunkyBorderForge {
public static final String MOD_ID = "chunkyborder";
private static final ResourceLocation PLAY_BORDER_PACKET_ID = new ResourceLocation("chunky", "border");
private static final ResourceLocation PLAY_BORDER_PACKET_ID = ResourceLocation.fromNamespaceAndPath("chunky", "border");
public static final Channel<CustomPacketPayload> PLAY_BORDER_CHANNEL = ChannelBuilder.named(PLAY_BORDER_PACKET_ID)
.optional()
.payloadChannel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.MeshData;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.Util;
Expand Down Expand Up @@ -48,7 +49,6 @@ private void renderWorldBorder(final Camera camera, final CallbackInfo ci) {
if (borderShape == null) {
return;
}
final BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
final double renderDistanceBlocks = this.minecraft.options.getEffectiveRenderDistance() * 16D;
final double posX = camera.getPosition().x;
final double posZ = camera.getPosition().z;
Expand Down Expand Up @@ -97,7 +97,7 @@ private void renderWorldBorder(final Camera camera, final CallbackInfo ci) {
RenderSystem.disableCull();
final float offset = (Util.getMillis() % 3000L) / 3000.0F;
float textureVertical = (float) (height - Mth.frac(camera.getPosition().y));
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
final BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
final float textureSize = 0.5F;
if (borderShape instanceof final PolygonBorderShape polygon) {
final double[] pointsX = polygon.getPointsX();
Expand Down Expand Up @@ -197,7 +197,10 @@ private void renderWorldBorder(final Camera camera, final CallbackInfo ci) {
b += angle;
}
}
BufferUploader.drawWithShader(bufferBuilder.end());
final MeshData meshdata = bufferBuilder.build();
if (meshdata != null) {
BufferUploader.drawWithShader(meshdata);
}
RenderSystem.enableCull();
RenderSystem.polygonOffset(0.0F, 0.0F);
RenderSystem.disablePolygonOffset();
Expand All @@ -223,6 +226,6 @@ private void addWall(final BufferBuilder bufferBuilder, final double height, fin
}

private void addVertex(final BufferBuilder bufferBuilder, final double height, final double x1, final double z1, final double x2, final double z2, final float u, final float v) {
bufferBuilder.vertex(x2 - x1, height, z2 - z1).uv(u, v).endVertex();
bufferBuilder.addVertex((float) (x2 - x1), (float) height, (float) (z2 - z1)).setUv(u, v);
}
}
4 changes: 2 additions & 2 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ description="${description}"
[[dependencies.chunkyborder]]
modId="forge"
mandatory=true
versionRange="[50,)"
versionRange="[51,)"
ordering="NONE"
side="BOTH"
[[dependencies.chunkyborder]]
modId="minecraft"
mandatory=true
versionRange="[1.20.5,1.21)"
versionRange="[1.21,1.22)"
ordering="NONE"
side="BOTH"
[[dependencies.chunkyborder]]
Expand Down
4 changes: 2 additions & 2 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ repositories {
}

dependencies {
minecraft(group = "com.mojang", name = "minecraft", version = "1.20.5")
minecraft(group = "com.mojang", name = "minecraft", version = "1.21")
mappings(loom.officialMojangMappings())
neoForge(group = "net.neoforged", name = "neoforge", version = "20.5.5-beta")
neoForge(group = "net.neoforged", name = "neoforge", version = "21.0.14-beta")
modImplementation(group = "org.popcraft", name = "chunky-neoforge", version = "${project.property("target")}")
compileOnly(group = "us.dynmap", name = "DynmapCoreAPI", version = "${project.property("target_dynmap")}")
compileOnly(group = "com.github.BlueMap-Minecraft", name = "BlueMapAPI", version = "${project.property("target_bluemap")}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
import org.joml.Vector3f;
import org.popcraft.chunky.Chunky;
Expand Down Expand Up @@ -115,7 +115,7 @@ public void onServerStopping(final ServerStoppingEvent event) {
}

@SubscribeEvent
public void onServerTick(final TickEvent.ServerTickEvent event) {
public void onServerTick(final ServerTickEvent.Post event) {
if (!initialized) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.MeshData;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.Util;
Expand Down Expand Up @@ -48,7 +49,6 @@ private void renderWorldBorder(final Camera camera, final CallbackInfo ci) {
if (borderShape == null) {
return;
}
final BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
final double renderDistanceBlocks = this.minecraft.options.getEffectiveRenderDistance() * 16D;
final double posX = camera.getPosition().x;
final double posZ = camera.getPosition().z;
Expand Down Expand Up @@ -97,7 +97,7 @@ private void renderWorldBorder(final Camera camera, final CallbackInfo ci) {
RenderSystem.disableCull();
final float offset = (Util.getMillis() % 3000L) / 3000.0F;
float textureVertical = (float) (height - Mth.frac(camera.getPosition().y));
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
final BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
final float textureSize = 0.5F;
if (borderShape instanceof final PolygonBorderShape polygon) {
final double[] pointsX = polygon.getPointsX();
Expand Down Expand Up @@ -197,7 +197,10 @@ private void renderWorldBorder(final Camera camera, final CallbackInfo ci) {
b += angle;
}
}
BufferUploader.drawWithShader(bufferBuilder.end());
final MeshData meshdata = bufferBuilder.build();
if (meshdata != null) {
BufferUploader.drawWithShader(meshdata);
}
RenderSystem.enableCull();
RenderSystem.polygonOffset(0.0F, 0.0F);
RenderSystem.disablePolygonOffset();
Expand All @@ -223,6 +226,6 @@ private void addWall(final BufferBuilder bufferBuilder, final double height, fin
}

private void addVertex(final BufferBuilder bufferBuilder, final double height, final double x1, final double z1, final double x2, final double z2, final float u, final float v) {
bufferBuilder.vertex(x2 - x1, height, z2 - z1).uv(u, v).endVertex();
bufferBuilder.addVertex((float) (x2 - x1), (float) height, (float) (z2 - z1)).setUv(u, v);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import io.netty.buffer.ByteBuf;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
import org.popcraft.chunky.platform.World;
import org.popcraft.chunky.shape.Shape;
import org.popcraft.chunkyborder.util.ClientBorder;
import org.popcraft.chunkyborder.util.PluginMessage;

public class BorderPayload implements CustomPacketPayload {
public static final CustomPacketPayload.Type<BorderPayload> ID = CustomPacketPayload.createType("chunky:border");
public static final CustomPacketPayload.Type<BorderPayload> ID = new CustomPacketPayload.Type<>(ResourceLocation.parse("chunky:border"));
private World world;
private Shape shape;
private ClientBorder border;
Expand Down
4 changes: 2 additions & 2 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ description="${description}"
[[dependencies.chunkyborder]]
modId="neoforge"
mandatory=true
versionRange="[20.5-beta,)"
versionRange="[21.0-beta,)"
ordering="NONE"
side="BOTH"
[[dependencies.chunkyborder]]
modId="minecraft"
mandatory=true
versionRange="[1.20.5,1.21)"
versionRange="[1.21,1.22)"
ordering="NONE"
side="BOTH"
[[dependencies.chunkyborder]]
Expand Down

0 comments on commit be9f7b8

Please sign in to comment.