Skip to content

Commit

Permalink
Update to 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox authored and Gegy committed Jun 22, 2024
1 parent 494efa5 commit e7e2ab7
Show file tree
Hide file tree
Showing 31 changed files with 203 additions and 230 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Read mod version from Gradle
id: read_version
Expand All @@ -32,7 +32,7 @@ jobs:
property: 'mod_version'

- name: Generate build number
uses: kNoAPP/gh-action-buildnum@95ff0793ae82a79441ec674ed370adf14134559e
uses: kNoAPP/gh-action-buildnum@7952ffa54bc2c37e2c33bbb3d7226473274cce3e
id: 'minor_version'
with:
workflow_name: 'minor_version'
Expand All @@ -41,7 +41,7 @@ jobs:
skip_bump: true

- name: Generate build number
uses: kNoAPP/gh-action-buildnum@95ff0793ae82a79441ec674ed370adf14134559e
uses: kNoAPP/gh-action-buildnum@7952ffa54bc2c37e2c33bbb3d7226473274cce3e
id: 'build_number'
with:
workflow_name: 'build_number'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

- name: Read mod version from Gradle
id: read_version
Expand All @@ -35,7 +35,7 @@ jobs:
property: 'mod_version'

- name: Generate build number
uses: kNoAPP/gh-action-buildnum@95ff0793ae82a79441ec674ed370adf14134559e
uses: kNoAPP/gh-action-buildnum@7952ffa54bc2c37e2c33bbb3d7226473274cce3e
id: 'minor_version'
with:
workflow_name: 'minor_version'
Expand All @@ -58,7 +58,7 @@ jobs:
MODRINTH: ${{ secrets.MODRINTH_KEY }}
CHANGELOG: ${{ github.event.release.body }}
- name: Bump build number
uses: kNoAPP/gh-action-buildnum@95ff0793ae82a79441ec674ed370adf14134559e
uses: kNoAPP/gh-action-buildnum@7952ffa54bc2c37e2c33bbb3d7226473274cce3e
id: 'justbump'
with:
workflow_name: 'minor_version'
Expand Down
39 changes: 19 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'fabric-loom' version '1.4.+'
id 'fabric-loom' version '1.6.+'
id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
group = project.maven_group
Expand Down Expand Up @@ -84,30 +84,29 @@ dependencies {

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

modApi include('xyz.nucleoid:server-translations-api:2.2.0+1.20.3-rc1')
modApi include('xyz.nucleoid:packet-tweaker:0.5.0+1.20.2-rc1')
modApi include('xyz.nucleoid:fantasy:0.5.0+1.20.4')
modApi include('xyz.nucleoid:server-translations-api:2.3.0+1.20.5-rc2')
modApi include('xyz.nucleoid:packet-tweaker:0.5.1+1.20.6')
modApi include('xyz.nucleoid:fantasy:0.6.0+1.20.6')
modApi include('xyz.nucleoid:more-codecs:0.3.3+1.20.2')
modApi include('xyz.nucleoid:stimuli:0.4.10+1.20.4')
modApi include('xyz.nucleoid:stimuli:0.4.11+1.20.6')
modApi include('xyz.nucleoid:map-templates:0.1.9+1.20.4')
modApi include('xyz.nucleoid:substrate:0.2.2+1.20.1')
modApi 'eu.pb4:polymer-core:0.7.5+1.20.4'
modApi 'eu.pb4:polymer-resource-pack:0.7.5+1.20.4'
modApi 'eu.pb4:polymer-blocks:0.7.5+1.20.4'
modApi 'eu.pb4:polymer-virtual-entity:0.7.5+1.20.4'
modApi include('eu.pb4:hologram-api:0.2.5+1.20.2')
modApi include('eu.pb4:sgui:1.4.1+1.20.4')
modApi include('eu.pb4:sidebar-api:0.3.0+1.20.3')
modApi include("eu.pb4:placeholder-api:2.3.0+1.20.3")
modApi include("eu.pb4:map-canvas-api:0.2.2+1.19.4")
modApi include("eu.pb4:player-data-api:0.4.0+1.20.3")
modApi include("eu.pb4:predicate-api:0.3.0+1.20.2")
modApi 'eu.pb4:polymer-core:0.8.2+1.20.6'
modApi 'eu.pb4:polymer-resource-pack:0.8.2+1.20.6'
modApi 'eu.pb4:polymer-blocks:0.8.2+1.20.6'
modApi 'eu.pb4:polymer-virtual-entity:0.8.2+1.20.6'
modApi include('eu.pb4:sgui:1.5.1+1.20.5')
modApi include('eu.pb4:sidebar-api:0.4.0+1.20.5')
modApi include("eu.pb4:placeholder-api:2.4.0-pre.1+1.20.5")
modApi include("eu.pb4:map-canvas-api:0.3.0+1.20.6")
modApi include("eu.pb4:player-data-api:0.5.0+1.20.5")
modApi include("eu.pb4:predicate-api:0.4.0+1.20.5")

modImplementation include("me.lucko:fabric-permissions-api:0.2-SNAPSHOT")

modCompileOnly('xyz.nucleoid:disguiselib-fabric:1.3.2')
modCompileOnly('maven.modrinth:afkdisplay:1.1.0')
modCompileOnly('eu.pb4:polymer-autohost:0.7.4+1.20.4')
modCompileOnly('eu.pb4:polymer-autohost:0.8.2+1.20.6')
modCompileOnly("dev.emi:trinkets:3.7.1")

testmodImplementation sourceSets.main.output
Expand All @@ -123,7 +122,7 @@ processResources {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
it.options.release = 21
}

java {
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=-Xmx2G

# Fabric Properties
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.1
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10

#Fabric api
fabric_version=0.89.2+1.20.2
fabric_version=0.99.0+1.20.6

# Mod Properties
mod_version=0.6
Expand Down
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-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 1 addition & 2 deletions src/main/java/xyz/nucleoid/plasmid/command/GameCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.command.argument.NbtCompoundArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtOps;
import net.minecraft.registry.RegistryOps;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down Expand Up @@ -143,7 +142,7 @@ private static int openAnonymousGame(CommandContext<ServerCommandSource> context
protected static int openAnonymousGame(CommandContext<ServerCommandSource> context, boolean test) throws CommandSyntaxException {
try {
var configNbt = NbtCompoundArgumentType.getNbtCompound(context, "game_config_nbt");
var result = GameConfig.DIRECT_CODEC.parse(RegistryOps.of(NbtOps.INSTANCE, context.getSource().getRegistryManager()), configNbt);
var result = GameConfig.DIRECT_CODEC.parse(context.getSource().getRegistryManager().getOps(NbtOps.INSTANCE), configNbt);
if (result.error().isPresent()) {
throw MALFORMED_CONFIG.create(result.error().get());
}
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/xyz/nucleoid/plasmid/command/ui/GameJoinUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ public class GameJoinUi extends SimpleGui {
private static final GuiElementInterface EMPTY = new GuiElementBuilder(Items.GRAY_STAINED_GLASS_PANE).setName(Text.empty()).build();

private static final int NAVBAR_POS = 81;
private final ServerPlayerEntity player;
private int tick;
private int page = 0;
private int pageSize;

public GameJoinUi(ServerPlayerEntity player) {
super(ScreenHandlerType.GENERIC_9X6, player, true);
this.player = player;
this.setTitle(Text.translatable("text.plasmid.ui.game_join.title"));
this.updateUi();
}
Expand Down Expand Up @@ -93,9 +95,10 @@ private void updateUi() {
);
int pageValue = this.page + 1;

this.setSlot(NAVBAR_POS + 3, Guis.getNumericBanner(pageValue / 100));
this.setSlot(NAVBAR_POS + 4, Guis.getNumericBanner(pageValue / 10));
this.setSlot(NAVBAR_POS + 5, Guis.getNumericBanner(pageValue));
var registries = this.player.getRegistryManager().createRegistryLookup();
this.setSlot(NAVBAR_POS + 3, Guis.getNumericBanner(registries, pageValue / 100));
this.setSlot(NAVBAR_POS + 4, Guis.getNumericBanner(registries, pageValue / 10));
this.setSlot(NAVBAR_POS + 5, Guis.getNumericBanner(registries, pageValue));

this.setSlot(NAVBAR_POS + 6, new GuiElementBuilder(hasNext ? Items.LIME_STAINED_GLASS_PANE : Items.BLACK_STAINED_GLASS_PANE)
.setName(Text.translatable("spectatorMenu.next_page").formatted(hasNext ? Formatting.GOLD : Formatting.DARK_GRAY))
Expand All @@ -114,7 +117,7 @@ private void changePage(int change) {

private GuiElementBuilder createIconFor(GameSpace gameSpace) {
var sourceConfig = gameSpace.getMetadata().sourceConfig();
var element = GuiElementBuilder.from(sourceConfig.value().icon().copy()).hideFlags()
var element = GuiElementBuilder.from(sourceConfig.value().icon().copy()).hideDefaultTooltip()
.setName(GameConfig.name(sourceConfig).copy());

for (var line : sourceConfig.value().description()) {
Expand All @@ -133,7 +136,7 @@ private GuiElementBuilder createIconFor(GameSpace gameSpace) {
Text.literal(gameSpace.getPlayers().size() + "").formatted(Formatting.YELLOW)).formatted(Formatting.GOLD))
);

element.hideFlags();
element.hideDefaultTooltip();
element.setCallback((a, b, c, d) -> tryJoinGame(this.getPlayer(), gameSpace));

return element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void addTo(GameActivity activity) {
}

private void sendTo(ServerPlayerEntity player) {
player.networkHandler.sendPacket(new ResourcePackSendS2CPacket(this.uuid, this.url, this.hash, this.required, this.prompt));
player.networkHandler.sendPacket(new ResourcePackSendS2CPacket(this.uuid, this.url, this.hash, this.required, Optional.ofNullable(this.prompt)));
}

private void unload(ServerPlayerEntity player) {
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/xyz/nucleoid/plasmid/game/common/OldCombat.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package xyz.nucleoid.plasmid.game.common;

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.AttributeModifierSlot;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.item.*;
import net.minecraft.registry.entry.RegistryEntry;

import java.util.UUID;

Expand All @@ -14,8 +16,8 @@
* This works by modifying the damage and attack speed attributes to match their 1.8 levels.
*/
public final class OldCombat {
private static final EntityAttribute DAMAGE_ATTRIBUTE = EntityAttributes.GENERIC_ATTACK_DAMAGE;
private static final EntityAttribute SPEED_ATTRIBUTE = EntityAttributes.GENERIC_ATTACK_SPEED;
private static final RegistryEntry<EntityAttribute> DAMAGE_ATTRIBUTE = EntityAttributes.GENERIC_ATTACK_DAMAGE;
private static final RegistryEntry<EntityAttribute> SPEED_ATTRIBUTE = EntityAttributes.GENERIC_ATTACK_SPEED;

private static final UUID DAMAGE_ID = Item.ATTACK_DAMAGE_MODIFIER_ID;
private static final UUID SPEED_ID = Item.ATTACK_SPEED_MODIFIER_ID;
Expand All @@ -28,36 +30,37 @@ public final class OldCombat {

public static ItemStack applyTo(ItemStack stack) {
var item = stack.getItem();
if (!(item instanceof ToolItem)) {
if (!(item instanceof ToolItem toolItem)) {
return stack;
}

var material = ((ToolItem) item).getMaterial();
var material = toolItem.getMaterial();

var defaultModifiers = item.getAttributeModifiers(EquipmentSlot.MAINHAND);
var defaultModifiers = item.getAttributeModifiers();

if (defaultModifiers.containsKey(SPEED_ATTRIBUTE)) {
{
EntityAttributeModifier modifier = createSpeedModifier();
stack.addAttributeModifier(SPEED_ATTRIBUTE, modifier, EquipmentSlot.MAINHAND);
defaultModifiers = defaultModifiers.with(SPEED_ATTRIBUTE, modifier, AttributeModifierSlot.MAINHAND);
}

if (defaultModifiers.containsKey(DAMAGE_ATTRIBUTE)) {
{
float attackDamage = material.getAttackDamage();
int baseDamage = getBaseDamage(stack);

EntityAttributeModifier modifier = createDamageModifier(attackDamage + baseDamage);
stack.addAttributeModifier(DAMAGE_ATTRIBUTE, modifier, EquipmentSlot.MAINHAND);
defaultModifiers = defaultModifiers.with(DAMAGE_ATTRIBUTE, modifier, AttributeModifierSlot.MAINHAND);
}

stack.set(DataComponentTypes.ATTRIBUTE_MODIFIERS, defaultModifiers);
return stack;
}

private static EntityAttributeModifier createSpeedModifier() {
return new EntityAttributeModifier(SPEED_ID, "Weapon modifier", 10000.0F, EntityAttributeModifier.Operation.ADDITION);
return new EntityAttributeModifier(SPEED_ID, "Weapon modifier", 10000.0F, EntityAttributeModifier.Operation.ADD_VALUE);
}

private static EntityAttributeModifier createDamageModifier(double damage) {
return new EntityAttributeModifier(DAMAGE_ID, "Weapon modifier", damage, EntityAttributeModifier.Operation.ADDITION);
return new EntityAttributeModifier(DAMAGE_ID, "Weapon modifier", damage, EntityAttributeModifier.Operation.ADD_VALUE);
}

private static int getBaseDamage(ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.item.FireworkRocketItem;
import net.minecraft.component.type.FireworkExplosionComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.scoreboard.AbstractTeam;
import net.minecraft.scoreboard.Team;
Expand Down Expand Up @@ -71,7 +71,7 @@ public static Builder builder(GameTeamConfig config) {
return new Builder(config);
}

public ItemStack createFirework(int flight, FireworkRocketItem.Type type) {
public ItemStack createFirework(int flight, FireworkExplosionComponent.Type type) {
var color = this.fireworkColor().getRgb();
return ItemStackBuilder.firework(color, flight, type).build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package xyz.nucleoid.plasmid.game.common.team;

import com.mojang.serialization.Codec;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import it.unimi.dsi.fastutil.objects.Reference2IntMaps;
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down Expand Up @@ -81,9 +84,9 @@ private void onAddPlayer(ServerPlayerEntity player) {
.formatted(Formatting.BOLD, config.chatFormatting());

var stack = new ItemStack(ColoredBlocks.wool(config.blockDyeColor()));
stack.setCustomName(name);
stack.set(DataComponentTypes.ITEM_NAME, name);

stack.getOrCreateNbt().putString(TEAM_KEY, team.key().id());
stack.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT.with(Codec.STRING.fieldOf(TEAM_KEY), team.key().id()).getOrThrow());

player.getInventory().setStack(index++, stack);
}
Expand All @@ -93,8 +96,8 @@ private TypedActionResult<ItemStack> onUseItem(ServerPlayerEntity player, Hand h
var stack = player.getStackInHand(hand);

if (stack.isIn(ItemTags.WOOL)) {
var tag = stack.getOrCreateNbt();
var key = new GameTeamKey(tag.getString(TEAM_KEY));
var key = new GameTeamKey(stack.getOrDefault(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT)
.get(Codec.STRING.fieldOf(TEAM_KEY)).getOrThrow());

var team = this.teams.byKey(key);
if (team != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public <T> Optional<T> get(Codec<T> codec, Identifier key) {
public boolean isEmpty() {
return this.values.isEmpty();
}

@Override
public String toString() {
return this.values.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ default void playSound(SoundEvent sound) {
@Override
default void playSound(SoundEvent sound, SoundCategory category, float volume, float pitch) {
for (var player : this) {
player.playSound(sound, category, volume, pitch);
player.playSoundToPlayer(sound, category, volume, pitch);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void teleport(ServerPlayerEntity player, Function<ServerPlayerEntity, Se
var worldProperties = world.getLevelProperties();

var spawnInfo = new CommonPlayerSpawnInfo(
world.getDimensionKey(), world.getRegistryKey(),
world.getDimensionEntry(), world.getRegistryKey(),
BiomeAccess.hashSeed(world.getSeed()),
player.interactionManager.getGameMode(), player.interactionManager.getPreviousGameMode(),
world.isDebugWorld(), world.isFlat(), player.getLastDeathPos(), player.getPortalCooldown()
Expand Down Expand Up @@ -130,7 +130,7 @@ private void teleport(ServerPlayerEntity player, Function<ServerPlayerEntity, Se
((ScreenHandlerAccess) player.playerScreenHandler).plasmid$resetTrackedState();

for (var effect : player.getStatusEffects()) {
networkHandler.sendPacket(new EntityStatusEffectS2CPacket(player.getId(), effect));
networkHandler.sendPacket(new EntityStatusEffectS2CPacket(player.getId(), effect, true));
}
}
}
Loading

0 comments on commit e7e2ab7

Please sign in to comment.