Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to 1.21 #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
matrix:
# Use these Java versions
java: [
17 # Latest version
21 # Latest version
]
# and run on both Linux and Windows
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
Expand All @@ -33,8 +33,8 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from LTS java on one OS
uses: actions/upload-artifact@v2
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from LTS java on one OS
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.gradle/loom-cache
Expand All @@ -20,11 +20,11 @@ jobs:
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
libs/

# gradle

.gradle/
Expand Down
33 changes: 15 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
}
Expand Down Expand Up @@ -38,20 +38,17 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modImplementation "maven.modrinth:anshar:0.0.15"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:5.4.0"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-block:5.4.0"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-level:5.4.0"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:5.4.0"
modImplementation "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:20.4.2"

modImplementation include('eu.pb4:polymer-virtual-entity:0.7.6+1.20.4')
modImplementation include("xyz.nucleoid:server-translations-api:2.2.0+1.20.3-rc1")

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
//modImplementation "maven.modrinth:anshar:0.0.15"
modImplementation files("libs/anshar-0.0.15.jar")
modImplementation "org.ladysnake.cardinal-components-api:cardinal-components-base:6.1.0"
modImplementation "org.ladysnake.cardinal-components-api:cardinal-components-block:6.1.0"
modImplementation "org.ladysnake.cardinal-components-api:cardinal-components-level:6.1.0"
modImplementation "org.ladysnake.cardinal-components-api:cardinal-components-entity:6.1.0"
modImplementation "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:21.0.5"

modImplementation include("eu.pb4:polymer-core:0.9.6+1.21")
modImplementation include("eu.pb4:polymer-virtual-entity:0.9.6+1.21")
modImplementation include("xyz.nucleoid:server-translations-api:2.3.1+1.21-pre2")
}

processResources {
Expand All @@ -63,7 +60,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
Expand All @@ -72,8 +69,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

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

jar {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.6
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.16.0

# Mod Properties
mod_version=0.0.15.1
maven_group=eu.pb4.ansharpatch
archives_base_name=anshar-polymer-patch

# Dependencies
fabric_version=0.96.1+1.20.4
fabric_version=0.100.7+1.21
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/eu/pb4/ansharpatch/AnsharPolymerPatch.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package eu.pb4.ansharpatch;

import com.lgmrszd.anshar.ModComponentTypes;
import eu.pb4.polymer.core.api.other.PolymerComponent;
import net.fabricmc.api.ModInitializer;

import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.resource.ResourceType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -12,6 +11,7 @@ public class AnsharPolymerPatch implements ModInitializer {

@Override
public void onInitialize() {
PolymerComponent.registerDataComponent(ModComponentTypes.BEACON_POS);
/*PolymerResourcePackUtils.addModAssets("anshar");
PolymerResourcePackUtils.getInstance().creationEvent.register(x -> {
x.addWriteConverter((path, bytes) -> path.startsWith("/assets/anshar/sounds/tunes") ? null : bytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.lgmrszd.anshar.beacon.BeaconComponent;
import com.lgmrszd.anshar.beacon.EndCrystalComponent;
import com.lgmrszd.anshar.transport.PlayerTransportComponent;
import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent;
import net.minecraft.server.network.ServerPlayerEntity;
import org.ladysnake.cca.api.v3.component.sync.AutoSyncedComponent;
import org.spongepowered.asm.mixin.Mixin;

@Mixin({BeaconComponent.class, EndCrystalComponent.class, PlayerTransportComponent.class})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@

@Mixin(EntityStatusS2CPacket.class)
public interface EntityStatusS2CPacketAccessor {
@Accessor
int getId();

@Mutable
@Accessor
void setId(int id);

@Accessor
byte getStatus();
void setEntityId(int id);

@Mutable
@Accessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.resource.FileResourcePackProvider;
import net.minecraft.resource.ResourcePackSource;
import net.minecraft.resource.ResourceType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.lgmrszd.anshar.ModRegistration;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -15,8 +16,8 @@ private static Object dontRegister(Registry<?> registry, Identifier id, Object e
return entry;
}

@Redirect(method = "registerAll", at = @At(value = "INVOKE", target = "Lnet/fabricmc/fabric/api/networking/v1/ServerPlayNetworking;registerGlobalReceiver(Lnet/minecraft/util/Identifier;Lnet/fabricmc/fabric/api/networking/v1/ServerPlayNetworking$PlayChannelHandler;)Z"))
private static boolean networkingBad(Identifier channelName, ServerPlayNetworking.PlayChannelHandler channelHandler) {
@Redirect(method = "registerAll", at = @At(value = "INVOKE", target = "Lnet/fabricmc/fabric/api/networking/v1/ServerPlayNetworking;registerGlobalReceiver(Lnet/minecraft/network/packet/CustomPayload$Id;Lnet/fabricmc/fabric/api/networking/v1/ServerPlayNetworking$PlayPayloadHandler;)Z"))
private static boolean networkingBad(CustomPayload.Id<?> type, ServerPlayNetworking.PlayPayloadHandler<?> handler) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
import eu.pb4.polymer.virtualentity.api.elements.ItemDisplayElement;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.FireworksComponent;
import net.minecraft.entity.EntityStatuses;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.decoration.Brightness;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FireworkRocketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.*;
import net.minecraft.particle.DustParticleEffect;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.Registries;
import net.minecraft.server.network.ServerPlayNetworkHandler;
Expand All @@ -37,7 +37,6 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.GameMode;
import net.minecraft.world.explosion.Explosion;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix3f;
import org.joml.Vector3f;
Expand Down Expand Up @@ -267,7 +266,7 @@ public float getJumpPercentage() {
return (float) this.gateTicks / 230.0F;
}

@Redirect(method = "moveToCurrentTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;teleport(DDD)V"))
@Redirect(method = "moveToCurrentTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;requestTeleport(DDD)V"))
private void replaceTeleport(PlayerEntity instance, double x, double y, double z) {
instance.setPos(x, y, z);
}
Expand All @@ -278,19 +277,19 @@ private void replaceTeleport(PlayerEntity instance, double x, double y, double z
*/
@Overwrite
public void sendExplosionPacketS2C(boolean skipOurselves, BlockPos pos, int color) {
var list = new ArrayList<Packet<ClientPlayPacketListener>>();
var list = new ArrayList<Packet<? super ClientPlayPacketListener>>();
var id = VirtualEntityUtils.requestEntityId();
list.add(new EntitySpawnS2CPacket(id, UUID.randomUUID(),
pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0, EntityType.FIREWORK_ROCKET, 0, Vec3d.ZERO, 0));

{
var stack = new ItemStack(Items.FIREWORK_ROCKET);
stack.getOrCreateNbt().put(FireworkRocketItem.FIREWORKS_KEY, TransportEffects.makeTransportFirework(color));
stack.set(DataComponentTypes.FIREWORKS, new FireworksComponent(0, TransportEffects.makeTransportFirework(color)));
list.add(new EntityTrackerUpdateS2CPacket(id, List.of(DataTracker.SerializedEntry.of(FireworkRocketEntityAccessor.getITEM(), stack))));
}
{
var x = PolymerCommonUtils.createUnsafe(EntityStatusS2CPacket.class);
((EntityStatusS2CPacketAccessor) x).setId(id);
((EntityStatusS2CPacketAccessor) x).setEntityId(id);
((EntityStatusS2CPacketAccessor) x).setStatus(EntityStatuses.EXPLODE_FIREWORK_CLIENT);
list.add(x);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

@Mixin(ResourcePackManager.class)
Expand All @@ -20,7 +19,7 @@ public abstract class ResourcePackManagerMixin {
@Shadow
@Final
@Mutable
public Set<ResourcePackProvider> providers;
private Set<ResourcePackProvider> providers;

@Inject(method = "<init>", at = @At("RETURN"))
public void injectCustom(ResourcePackProvider[] resourcePackProviders, CallbackInfo info) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package eu.pb4.ansharpatch.mixin;

import com.lgmrszd.anshar.transport.PlayerTransportComponent;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down
Loading