Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
JNNGL committed Jul 21, 2024
1 parent 56cdabe commit 8fe928b
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ https://github.com/JNNGL/VanillaMinimaps/assets/45935949/ea7738c9-bd4a-4388-9d65

https://github.com/JNNGL/VanillaMinimaps/assets/45935949/f64aed82-8193-4c3b-9c8f-be32dc3d6fa0

**Supported server versions: 1.20.4**
**Supported server version: 1.21**

### Features

Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev").version("1.5.11")
id("xyz.jpenilla.run-paper").version("2.2.2")
id("com.github.johnrengelman.shadow").version("7.1.2")
id("io.papermc.paperweight.userdev").version("1.7.1")
id("xyz.jpenilla.run-paper").version("2.3.0")
id("io.github.goooler.shadow").version("8.1.7")
}

setGroup("com.jnngl")
setVersion("1.0.1-SNAPSHOT")
setVersion("1.0.1")

repositories {
mavenCentral()
Expand All @@ -21,10 +21,10 @@ repositories {
}

dependencies {
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.20.4-R0.1-SNAPSHOT")
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21-R0.1-SNAPSHOT")
implementation("net.elytrium:serializer:1.1.1")
implementation("com.jnngl:mapcolor:1.0.1")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
annotationProcessor("org.projectlombok:lombok:1.18.30")
compileOnly("org.projectlombok:lombok:1.18.30")
implementation("com.j256.ormlite:ormlite-jdbc:6.1")
Expand All @@ -39,7 +39,7 @@ shadowJar {
minimize()
}

def targetJavaVersion = 17
def targetJavaVersion = 21
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
setSourceCompatibility(javaVersion)
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.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
import com.jnngl.vanillaminimaps.map.SecondaryMinimapLayer;
import com.jnngl.vanillaminimaps.map.renderer.MinimapLayerRenderer;
import net.minecraft.core.Direction;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.saveddata.maps.MapId;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;

import java.util.LinkedHashMap;
Expand All @@ -54,7 +56,7 @@ public MinimapLayer createMinimapLayer(World world, MinimapLayerRenderer rendere
int mapId = MAP_ID_COUNTER--;

ItemStack item = new ItemStack(Items.FILLED_MAP);
item.getOrCreateTag().putInt("map", mapId);
item.set(DataComponents.MAP_ID, new MapId(mapId));

ItemFrame upperFrame = createLayerFrame(world, item, Direction.DOWN);
ItemFrame lowerFrame = createLayerFrame(world, item, Direction.UP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
import com.jnngl.vanillaminimaps.clientside.EntityHandle;
import com.jnngl.vanillaminimaps.injection.PassengerRewriter;
import com.jnngl.vanillaminimaps.map.MinimapLayer;
import java.util.Set;
import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket;
import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.level.saveddata.maps.MapId;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;

import java.util.Collections;
Expand All @@ -46,13 +49,14 @@ public NMSMinimapPacketSender(VanillaMinimaps plugin) {
@Override
public void updateLayer(Player viewer, MinimapLayer layer, int x, int y, int width, int height, byte[] data) {
MapItemSavedData.MapPatch patch = new MapItemSavedData.MapPatch(x, y, width, height, data);
((CraftPlayer) viewer).getHandle().connection.send(new ClientboundMapItemDataPacket(layer.mapId(), (byte) 0, false, Collections.emptyList(), patch));
((CraftPlayer) viewer).getHandle().connection.send(
new ClientboundMapItemDataPacket(new MapId(layer.mapId()), (byte) 0, false, Collections.emptyList(), patch));
}

private void spawnItemFrame(ServerPlayerConnection connection, ItemFrame itemFrame, double offsetY) {
ServerPlayer player = connection.getPlayer();
itemFrame.setPos(player.getX(), player.getY() + offsetY, player.getZ());
connection.send(itemFrame.getAddEntityPacket());
connection.send(itemFrame.getAddEntityPacket(new ServerEntity(null, itemFrame, 0, false, p -> {}, Set.of())));
var metadata = itemFrame.getEntityData().getNonDefaultValues();
if (metadata != null && !metadata.isEmpty()) {
connection.send(new ClientboundSetEntityDataPacket(itemFrame.getId(), metadata));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@
import net.minecraft.network.protocol.game.*;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ClientInformation;
import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -80,7 +81,7 @@ public NMSSteerableLockedView(Player player) {
viewer.getUUID(), viewer.getGameProfile(),
false, 0, GameType.CREATIVE, null, null)
)));
connection.send(viewer.getAddEntityPacket());
connection.send(viewer.getAddEntityPacket(new ServerEntity(viewer.serverLevel(), viewer, 0, false, p -> {}, Set.of())));
connection.send(new ClientboundRotateHeadPacket(viewer, convertAngle(player.getYaw())));
List<SynchedEntityData.DataValue<?>> metadata = viewer.getEntityData().getNonDefaultValues();
if (metadata != null && !metadata.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.commands.CommandSourceStack;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
import org.bukkit.craftbukkit.CraftServer;

public class NMSCommandDispatcherAccessor {

public static CommandDispatcher<CommandSourceStack> vanillaDispatcher() {
return ((CraftServer) Bukkit.getServer()).getServer().vanillaCommandDispatcher.getDispatcher();
return ((CraftServer) Bukkit.getServer()).getServer().getCommands().getDispatcher();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
if (passengers != null) {
synchronized (passengers) {
FriendlyByteBuf buf = new FriendlyByteBuf(ctx.alloc().ioBuffer());
buf.writeVarInt(0x5D); // Packet ID
buf.writeVarInt(0x5F); // Packet ID
buf.writeVarInt(packet.getVehicle()); // Vehicle ID
buf.writeVarInt(packet.getPassengers().length + passengers.size()); // Passenger count
for (int passenger : packet.getPassengers()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import net.minecraft.world.level.material.MapColor;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_20_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_20_R3.block.data.CraftBlockData;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.block.data.CraftBlockData;

public class FlatWorldMinimapRenderer implements CacheableWorldMinimapRenderer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import net.minecraft.world.level.material.MapColor;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.CraftWorld;

import java.util.concurrent.atomic.AtomicInteger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"uniforms": [
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "IViewRotMat", "type": "matrix3x3", "count": 9, "values": [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
{ "name": "Light0_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] },
{ "name": "Light1_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] },
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/shaders/core/rendertype_entity_cutout.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ uniform sampler2D Sampler2;

uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform mat3 IViewRotMat;
uniform vec2 ScreenSize;
uniform int FogShape;

Expand All @@ -46,7 +45,7 @@ void main() {
vec4 vertex = vec4(Position, 1.0);
vec4 vcolor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color);
gl_Position = ProjMat * ModelViewMat * vertex;
vertexDistance = fog_distance(ModelViewMat, IViewRotMat * Position, FogShape);
vertexDistance = fog_distance(Position, FogShape);
lightMapColor = texelFetch(Sampler2, UV2 / 16, 0);
overlayColor = texelFetch(Sampler1, UV1, 0);
normal = ProjMat * ModelViewMat * vec4(Normal, 0.0);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/shaders/core/rendertype_text.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"uniforms": [
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "IViewRotMat", "type": "matrix3x3", "count": 9, "values": [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
{ "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] },
{ "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] },
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/shaders/core/rendertype_text.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ uniform sampler2D Sampler2;

uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform mat3 IViewRotMat;
uniform vec2 ScreenSize;
uniform int FogShape;

Expand All @@ -36,7 +35,7 @@ void main() {
vec4 vertex = vec4(Position, 1.0);
vec4 vcolor = Color * texelFetch(Sampler2, UV2 / 16, 0);
gl_Position = ProjMat * ModelViewMat * vertex;
vertexDistance = length((ModelViewMat * vertex).xyz);
vertexDistance = length(vertex.xyz);

#moj_import <minimap/vertex_main.glsl>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (texture(Sampler0, uv).xyz == vec3(112. / 255., 108. / 255., 138. / 255.)) {
case 3: { gl_Position = vec4(-1 + 0.70 * vratio, 1 - 0.04 * ratio, 0, 1); uv2 = vec2(1, 1); break; }
}

vec3 local = IViewRotMat * vec3(1, 0, 0);
vec3 local = transpose(mat3(ModelViewMat)) * vec3(1, 0, 0);
float yaw = -atan(local.x, local.z);

float vx = decodeFixedPoint(1, 0);
Expand Down

0 comments on commit 8fe928b

Please sign in to comment.