Skip to content

Commit

Permalink
Update to 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 10, 2023
1 parent 56764f5 commit 910aaf9
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 99 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.1.+'
id 'fabric-loom' version '1.4.+'
id 'maven-publish'
}

Expand All @@ -24,7 +24,7 @@ dependencies {

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation 'xyz.nucleoid:plasmid:0.5.102-SNAPSHOT+1.20.2'
modImplementation 'xyz.nucleoid:plasmid:0.5.102-SNAPSHOT+1.20.4'

//modCompileOnly "com.viaversion:viaversion-api:4.7.0-SNAPSHOT"
modCompileOnly "dev.gegy:player-roles-api:1.6.5"
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.22
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.1

# Dependencies
fabric_version=0.89.3+1.20.2
fabric_version=0.91.1+1.20.4

# Mod Properties
mod_version=1.3.1
mod_version=1.3.2
maven_group=xyz.nucleoid
archives_base_name=nucleoid-extras
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.util.Formatting;
import net.minecraft.util.dynamic.Codecs;
import org.jetbrains.annotations.Nullable;
import xyz.nucleoid.plasmid.util.PlasmidCodecs;

import java.util.*;
import java.util.stream.Collectors;
Expand All @@ -23,7 +24,7 @@ public final class ChatFilterConfig {
instance.group(
Codec.STRING.listOf().optionalFieldOf("illegal_words", ImmutableList.of()).forGetter(c -> new ArrayList<>(c.illegalWords)),
Codec.STRING.listOf().optionalFieldOf("contains_illegal_text", ImmutableList.of()).forGetter(c -> c.containsIllegalText),
Codecs.TEXT.optionalFieldOf("feedback_message").forGetter(c -> Optional.ofNullable(c.feedbackMessage)),
PlasmidCodecs.TEXT.optionalFieldOf("feedback_message").forGetter(c -> Optional.ofNullable(c.feedbackMessage)),
Registries.SOUND_EVENT.createEntryCodec().optionalFieldOf("feedback_sound").forGetter(c -> Optional.ofNullable(c.feedbackSound))
).apply(instance, ChatFilterConfig::new)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import xyz.nucleoid.plasmid.game.portal.GamePortalDisplay;
import xyz.nucleoid.plasmid.game.portal.menu.InvalidMenuEntry;
import xyz.nucleoid.plasmid.game.portal.menu.MenuEntry;
import xyz.nucleoid.plasmid.util.IdentityHashStrategy;

import java.util.ArrayList;
import java.util.Comparator;
Expand Down Expand Up @@ -77,7 +78,7 @@ public ItemStack getIcon() {
@Override
public int getPlayerCount() {
int count = 0;
var list = new ObjectOpenCustomHashSet<GameSpace>(Util.identityHashStrategy());
var list = new ObjectOpenCustomHashSet<GameSpace>(IdentityHashStrategy.INSTANCE);
provideGameSpaces(list::add);
for (var entry : list) {
count += Math.max(0, entry.getPlayers().size());
Expand Down Expand Up @@ -140,7 +141,7 @@ private void fill(ServerPlayerEntity player, SimpleGui gui, boolean viewOpen) {
}

private void fillOpen(ServerPlayerEntity player, SimpleGui gui, MutableInt page) {
var gamesTemp = new ObjectOpenCustomHashSet<GameSpace>(Util.identityHashStrategy());
var gamesTemp = new ObjectOpenCustomHashSet<GameSpace>(IdentityHashStrategy.INSTANCE);
this.provideGameSpaces(gamesTemp::add);
var games = new ArrayList<>(gamesTemp);
games.sort(Comparator.comparingInt(space -> -space.getPlayers().size()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import com.mojang.serialization.MapCodec;
import eu.pb4.polymer.core.api.block.PolymerBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
Expand Down Expand Up @@ -38,6 +39,11 @@ public ContributorStatueBlock(Settings settings) {
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
}

@Override
protected MapCodec<? extends BlockWithEntity> getCodec() {
return null;
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient() && player.isCreativeLevelTwoOp()) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/xyz/nucleoid/extras/lobby/block/SnakeBlock.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xyz.nucleoid.extras.lobby.block;

import com.mojang.serialization.MapCodec;
import eu.pb4.polymer.core.api.block.PolymerBlock;
import net.minecraft.block.*;
import net.minecraft.item.ItemPlacementContext;
Expand Down Expand Up @@ -104,4 +105,9 @@ protected void appendProperties(Builder<Block, BlockState> builder) {
builder.add(FACING);
builder.add(ACTIVE);
}

@Override
protected MapCodec<? extends FacingBlock> getCodec() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class TransientDoorBlock extends DoorBlock implements PolymerBlock {
private final Block polymerBlock;

public TransientDoorBlock(Block block) {
super(AbstractBlock.Settings.copy(block), block instanceof DoorBlock door ? door.getBlockSetType() : BlockSetType.OAK);
super(block instanceof DoorBlock door ? door.getBlockSetType() : BlockSetType.OAK, AbstractBlock.Settings.copy(block));
this.polymerBlock = block;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ public GameProfile createGameProfile(MinecraftServer server) {
}

public void loadGameProfileProperties(MinecraftServer server, GameProfile profile, Consumer<GameProfile> callback) {
SkullBlockEntityAccessor.callFetchProfileWithTextures(profile).thenAccept(optional -> {
/*SkullBlockEntityAccessor.callFetchProfileWithTextures(profile).thenAccept(optional -> {
optional.ifPresent(fullProfile -> {
server.getUserCache().add(fullProfile);
callback.accept(fullProfile);
});
});
});*/
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,43 @@

import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
import net.minecraft.predicate.entity.LootContextPredicate;
import net.minecraft.registry.Registries;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import xyz.nucleoid.extras.lobby.block.tater.CubicPotatoBlock;
import xyz.nucleoid.extras.lobby.block.tater.TinyPotatoBlock;

import java.util.Optional;

public class TaterCollectedCriterion extends AbstractCriterion<TaterCollectedCriterion.Conditions> {
@Override
protected TaterCollectedCriterion.Conditions conditionsFromJson(JsonObject obj, Optional<LootContextPredicate> playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
Identifier tater = obj.has("tater") ? new Identifier(obj.get("tater").getAsString()) : null;
if(tater != null && !Registries.BLOCK.containsId(tater)) {
throw new JsonSyntaxException("No tater exists with ID "+tater+"!");
}
Integer count = obj.has("count") ? obj.get("count").getAsString().equals("all") ? CubicPotatoBlock.TATERS.size() : obj.get("count").getAsInt() : null;
return new Conditions(playerPredicate, tater, count);
}

public void trigger(ServerPlayerEntity player, Identifier tater, int count) {
this.trigger(player, conditions -> conditions.matches(tater, count));
}

public static class Conditions extends AbstractCriterionConditions {
private final Identifier tater;
@Override
public Codec<Conditions> getConditionsCodec() {
return Conditions.CODEC;
}

@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public static class Conditions implements AbstractCriterion.Conditions {
public static final Codec<Conditions> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Identifier.CODEC.fieldOf("tater").forGetter(Conditions::getTater),
Codec.INT.optionalFieldOf("count").forGetter(i -> i.optionalCount)
).apply(instance, Conditions::new));

private final Identifier tater;
private final Integer count;
private final Optional<Integer> optionalCount;

public Conditions(Optional<LootContextPredicate> playerPredicate, Identifier tater, Integer count) {
super(playerPredicate);
public Conditions(Identifier tater, Optional<Integer> count) {
this.tater = tater;
this.count = count;
this.count = count.orElse(TinyPotatoBlock.TATERS.size());
this.optionalCount = count;
}

public Identifier getTater() {
Expand All @@ -51,5 +54,10 @@ public boolean matches(Identifier tater, int count) {
boolean countMatches = getCount() == null || getCount() <= count;
return taterMatches && countMatches;
}
}

@Override
public Optional<LootContextPredicate> player() {
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
import net.minecraft.predicate.entity.LootContextPredicate;
import net.minecraft.registry.Registries;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -18,25 +19,12 @@
public class WearTaterCriterion extends AbstractCriterion<WearTaterCriterion.Conditions> {
public static final Calendar CALENDAR = Calendar.getInstance();

@Override
protected WearTaterCriterion.Conditions conditionsFromJson(JsonObject obj, Optional<LootContextPredicate> playerPredicate, AdvancementEntityPredicateDeserializer predicateDeserializer) {
Identifier tater = obj.has("tater") ? new Identifier(obj.get("tater").getAsString()) : null;
if(tater != null && !Registries.BLOCK.containsId(tater)) {
throw new JsonSyntaxException("No tater exists with ID "+tater+"!");
}
Integer dayOfWeek = obj.has("day_of_week") ? dayOfWeekToInt(obj.get("day_of_week").getAsString()) : null;
if(dayOfWeek != null && (dayOfWeek > 7 || dayOfWeek < 1)) {
throw new JsonSyntaxException("Invalid day of week specified!");
}
return new Conditions(playerPredicate, tater, dayOfWeek);
}

public void trigger(ServerPlayerEntity player, Identifier tater) {
CALENDAR.setTime(new Date());
this.trigger(player, conditions -> conditions.matches(tater, CALENDAR.get(Calendar.DAY_OF_WEEK)));
}

public int dayOfWeekToInt(String day) {
public static int dayOfWeekToInt(String day) {
return switch (day.toLowerCase(Locale.ROOT)) {
case "monday" -> Calendar.MONDAY;
case "tuesday" -> Calendar.TUESDAY;
Expand All @@ -49,28 +37,40 @@ public int dayOfWeekToInt(String day) {
};
}

public static class Conditions extends AbstractCriterionConditions {
private final Identifier tater;
private final Integer dayOfWeek;
public static String dayOfWeekToString(int day) {
return switch (day) {
case Calendar.MONDAY -> "monday";
case Calendar.TUESDAY -> "tuesday";
case Calendar.WEDNESDAY -> "wednesday";
case Calendar.THURSDAY -> "thursday";
case Calendar.FRIDAY -> "friday";
case Calendar.SATURDAY -> "saturday";
case Calendar.SUNDAY -> "sunday";
default -> Integer.toString(day);
};
}

public Conditions(Optional<LootContextPredicate> playerPredicate, Identifier tater, Integer dayOfWeek) {
super(playerPredicate);
this.tater = tater;
this.dayOfWeek = dayOfWeek;
}
@Override
public Codec<Conditions> getConditionsCodec() {
return Conditions.CODEC;
}

public Identifier getTater() {
return tater;
}
public record Conditions(Identifier tater, int dayOfWeek) implements AbstractCriterion.Conditions {
public static final Codec<Conditions> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Identifier.CODEC.fieldOf("tater").forGetter(Conditions::tater),
Codec.STRING.xmap(WearTaterCriterion::dayOfWeekToInt, WearTaterCriterion::dayOfWeekToString)
.fieldOf("day_of_week").forGetter(Conditions::dayOfWeek)
).apply(instance, Conditions::new));

public Integer getDayOfWeek() {
return dayOfWeek;
}
public boolean matches(Identifier tater, int dayOfWeek) {
boolean taterMatches = tater() == null || tater().equals(tater);
boolean dayOfWeekMatches = dayOfWeek() == dayOfWeek;
return taterMatches && dayOfWeekMatches;
}

public boolean matches(Identifier tater, int dayOfWeek) {
boolean taterMatches = getTater() == null || getTater().equals(tater);
boolean dayOfWeekMatches = getDayOfWeek() == null || getDayOfWeek() == dayOfWeek;
return taterMatches && dayOfWeekMatches;
}
}
@Override
public Optional<LootContextPredicate> player() {
return Optional.empty();
}
}
}
25 changes: 25 additions & 0 deletions src/main/java/xyz/nucleoid/extras/mixin/TextCodecMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package xyz.nucleoid.extras.mixin;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.mojang.serialization.Codec;
import net.minecraft.text.Text;
import net.minecraft.text.TextCodecs;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import xyz.nucleoid.extras.placeholder.GameTextContent;
import xyz.nucleoid.packettweaker.PacketContext;

import java.util.function.Function;

@Mixin(TextCodecs.class)
public class TextCodecMixin {
@ModifyReturnValue(method = "createCodec", at = @At("RETURN"))
private static Codec<Text> addCustomTextType(Codec<Text> original) {
return original.xmap(Function.identity(), text -> {
if (text.getContent() instanceof GameTextContent gameTextContent) {
return gameTextContent.toVanilla(PacketContext.get().getPlayer(), text);
}
return text;
});
}
}
22 changes: 0 additions & 22 deletions src/main/java/xyz/nucleoid/extras/mixin/TextSerializerMixin.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@

@Mixin(SkullBlockEntity.class)
public class SkullBlockEntityAccessor {
@Invoker
public static CompletableFuture<Optional<GameProfile>> callFetchProfileWithTextures(GameProfile profile) {
throw new AssertionError();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public class ServerScoreboardMixin {
@Final
private MinecraftServer server;

@Inject(method = "addPlayerToTeam", at = @At(value = "INVOKE", target = "Lnet/minecraft/scoreboard/ServerScoreboard;runUpdateListeners()V", shift = At.Shift.AFTER))
@Inject(method = "addScoreHolderToTeam", at = @At(value = "INVOKE", target = "Lnet/minecraft/scoreboard/ServerScoreboard;runUpdateListeners()V", shift = At.Shift.AFTER))
private void extras$updatePlayerAfterJoining(String playerName, Team team, CallbackInfoReturnable<Boolean> cir) {
var player = this.server.getPlayerManager().getPlayer(playerName);
if (player != null) {
PlayerListHelper.updatePlayer(player);
}
}

@Inject(method = "removePlayerFromTeam", at = @At("TAIL"))
@Inject(method = "removeScoreHolderFromTeam", at = @At("TAIL"))
private void extras$updatePlayerAfterLeaving(String playerName, Team team, CallbackInfo ci) {
var player = this.server.getPlayerManager().getPlayer(playerName);
if (player != null) {
Expand Down
Loading

0 comments on commit 910aaf9

Please sign in to comment.