Skip to content

Commit

Permalink
Update mod to Minecraft 1.21 (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 authored Jun 19, 2024
1 parent 596934a commit ceb7e0e
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 79 deletions.
6 changes: 3 additions & 3 deletions api/src/main/java/dev/gegy/roles/api/util/TinyRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public <U> DataResult<Pair<T, U>> decode(DynamicOps<U> ops, U input) {
}

private Identifier parseId(String string) {
if (string.indexOf(':') != -1) {
return new Identifier(string);
if (string.indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
return Identifier.of(string);
} else {
return new Identifier(this.defaultNamespace, string);
return Identifier.of(this.defaultNamespace, string);
}
}

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
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.2
loader_version=0.15.11

# Fabric api
fabric_version=0.99.0+1.20.6
fabric_version=0.100.1+1.21

# Mod Properties
mod_version=1.6.10
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/dev/gegy/roles/PlayerRoles.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dev.gegy.roles.api.RoleOwner;
import dev.gegy.roles.api.RoleReader;
import dev.gegy.roles.api.override.RoleOverrideType;
import dev.gegy.roles.command.PlayerRolesEntitySelectorOptions;
import dev.gegy.roles.command.RoleCommand;
import dev.gegy.roles.config.PlayerRolesConfig;
import dev.gegy.roles.override.ChatTypeOverride;
Expand Down Expand Up @@ -121,6 +122,8 @@ public void onInitialize() {
RoleCommand.register(dispatcher);
});

PlayerRolesEntitySelectorOptions.register();

CommandOverride.initialize();

ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> trySendChat(sender));
Expand Down Expand Up @@ -156,6 +159,6 @@ public static boolean canBypassPlayerLimit(MinecraftServer server, UUID playerUu
}

public static Identifier identifier(String path) {
return new Identifier(ID, path);
return Identifier.of(ID, path);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.gegy.roles.command;

import com.mojang.brigadier.exceptions.CommandSyntaxException;

import dev.gegy.roles.PlayerRoles;
import dev.gegy.roles.api.PlayerRolesApi;
import net.fabricmc.fabric.api.command.v2.EntitySelectorOptionRegistry;
import net.minecraft.command.EntitySelectorReader;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public final class PlayerRolesEntitySelectorOptions {
private static final Identifier ID = PlayerRoles.identifier("role");
private static final Text DESCRIPTION = Text.literal("Player Role");

public static void register() {
EntitySelectorOptionRegistry.register(ID, DESCRIPTION, PlayerRolesEntitySelectorOptions::handle, PlayerRolesEntitySelectorOptions::canUse);
}

private static void handle(EntitySelectorReader reader) throws CommandSyntaxException {
boolean isNegated = reader.readNegationCharacter();
String roleName = reader.getReader().readUnquotedString();
reader.addPredicate(entity -> {
var role = PlayerRolesApi.provider().get(roleName);
return (role != null && PlayerRolesApi.lookup().byEntity(entity).has(role)) != isNegated;
});
if (!isNegated) {
reader.setCustomFlag(ID, true);
}
}

private static boolean canUse(EntitySelectorReader reader) {
return !reader.getCustomFlag(ID);
}
}
39 changes: 0 additions & 39 deletions src/main/java/dev/gegy/roles/mixin/EntitySelectorOptionsMixin.java

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/java/dev/gegy/roles/mixin/EntitySelectorReaderMixin.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.dedicated.DedicatedPlayerManager;
import net.minecraft.world.WorldSaveHandler;
import net.minecraft.world.PlayerSaveHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(DedicatedPlayerManager.class)
public class DedicatedPlayerManagerMixin extends PlayerManager {
public DedicatedPlayerManagerMixin(MinecraftServer server, CombinedDynamicRegistries<ServerDynamicRegistryType> registryManager, WorldSaveHandler saveHandler, int maxPlayers) {
public DedicatedPlayerManagerMixin(MinecraftServer server, CombinedDynamicRegistries<ServerDynamicRegistryType> registryManager, PlayerSaveHandler saveHandler, int maxPlayers) {
super(server, registryManager, saveHandler, maxPlayers);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"depends": {
"fabricloader": ">=0.15",
"fabric": ">=0.99",
"minecraft": "1.20.6",
"java": ">=17"
"minecraft": ">=1.21",
"java": ">=21"
}
}
2 changes: 0 additions & 2 deletions src/main/resources/roles.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"mixins": [
"CommandBlockExecutorMixin",
"CommandFunctionMixin",
"EntitySelectorOptionsMixin",
"EntitySelectorReaderMixin",
"PlayerManagerMixin",
"ServerCommandSourceMixin",
"ServerPlayerEntityMixin",
Expand Down

0 comments on commit ceb7e0e

Please sign in to comment.