Skip to content

Commit 5b89a95

Browse files
committed
Port to 1.21.9-1.21.10
1 parent e171a55 commit 5b89a95

File tree

12 files changed

+39
-59
lines changed

12 files changed

+39
-59
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import com.github.spotbugs.snom.SpotBugsTask
22

33
plugins {
4-
id 'fabric-loom' version '1.10-SNAPSHOT'
4+
id 'fabric-loom' version '1.11-SNAPSHOT'
55
id 'maven-publish'
66
id 'io.freefair.lombok' version '8.6'
77
id 'com.github.spotbugs-base' version '6.0.14'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
33
# Fabric Properties
44
# check these on https://fabricmc.net/versions.html
55
minecraft_version=[VERSIONED]
6-
fabric_loader=0.16.13
6+
fabric_loader=0.17.0
77
yarn_mappings=[VERSIONED]
88
fabric_api=[VERSIONED]
99
midnightlib_version =[VERSIONED]

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ pluginManagement {
99
}
1010

1111
plugins {
12-
id "dev.kikugie.stonecutter" version "0.7.6"
12+
id "dev.kikugie.stonecutter" version "0.7.10"
1313
}
1414

1515
stonecutter {
1616
create(rootProject) {
17-
versions "1.21.1", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8"
17+
versions "1.21.1", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10"
1818
vcsVersion = "1.21.1"
1919
}
2020
}

src/main/java/com/github/vini2003/linkart/mixin/AbstractMinecartEntityMixin.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,13 @@ private Vec3d modifiedMovement(Vec3d movement) {
113113

114114
@Inject(at = @At("HEAD"), method = "tick")
115115
private void linkart$tick(CallbackInfo ci) {
116-
if (getWorld().isClient()) return;
116+
World world = /*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/;
117+
if (world.isClient()) return;
117118
AbstractMinecartEntity cast = (AbstractMinecartEntity) (Object) this;
118119
if (linkart$getFollowing() == null) return;
119120

120-
Vec3d pos = getPos();
121-
Vec3d pos2 = linkart$getFollowing().getPos();
121+
Vec3d pos = /*? if >=1.21.9 {*//*getEntityPos()*//*?} else {*/getPos()/*?}*/;
122+
Vec3d pos2 = linkart$getFollowing()./*? if >=1.21.9 {*//*getEntityPos()*//*?} else {*/getPos()/*?}*/;
122123
double dist = Math.max(Math.abs(pos.distanceTo(pos2)) - LinkartConfiguration.distance, 0);
123124
Vec3d vec3d = pos.relativize(pos2);
124125
vec3d = vec3d.multiply(LinkartConfiguration.velocityMultiplier);
@@ -153,10 +154,10 @@ private Vec3d modifiedMovement(Vec3d movement) {
153154

154155
if (LinkartConfiguration.chunkloading) {
155156
if (linkart$getFollower() != null && !CartUtils.approximatelyZero(this.getVelocity().length())) {
156-
((ServerWorld) this.getWorld()).getChunkManager().addTicket(ChunkTicketType.PORTAL, this.getChunkPos(), LinkartConfiguration.chunkloadingRadius/*? if <1.21.5 {*/, this.getBlockPos()/*?}*/);
157-
LoadingCarts.getOrCreate((ServerWorld) getWorld()).addCart(cast);
157+
((ServerWorld) world).getChunkManager().addTicket(ChunkTicketType.PORTAL, this.getChunkPos(), LinkartConfiguration.chunkloadingRadius/*? if <1.21.5 {*/, this.getBlockPos()/*?}*/);
158+
LoadingCarts.getOrCreate((ServerWorld) world).addCart(cast);
158159
} else {
159-
LoadingCarts.getOrCreate((ServerWorld) getWorld()).removeCart(cast);
160+
LoadingCarts.getOrCreate((ServerWorld) world).removeCart(cast);
160161
}
161162
}
162163
}
@@ -208,7 +209,7 @@ void onPushAway(Entity entity, CallbackInfo ci) {
208209
@Override
209210
public AbstractMinecartEntity linkart$getFollowing() {
210211
if (linkart$following == null && linkart$followingUUID != null) {
211-
linkart$following = (AbstractMinecartEntity) ((ServerWorld) this.getWorld()).getEntity(linkart$followingUUID);
212+
linkart$following = (AbstractMinecartEntity) ((ServerWorld) this./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/).getEntity(linkart$followingUUID);
212213
}
213214
return linkart$following;
214215
}
@@ -222,7 +223,7 @@ void onPushAway(Entity entity, CallbackInfo ci) {
222223
@Override
223224
public AbstractMinecartEntity linkart$getFollower() {
224225
if (linkart$follower == null && linkart$followerUUID != null) {
225-
linkart$follower = (AbstractMinecartEntity) ((ServerWorld) this.getWorld()).getEntity(linkart$followerUUID);
226+
linkart$follower = (AbstractMinecartEntity) ((ServerWorld) this./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/).getEntity(linkart$followerUUID);
226227
}
227228
return linkart$follower;
228229
}

src/main/java/com/github/vini2003/linkart/mixin/EntityMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public abstract class EntityMixin {
2020

2121
@Inject(at = @At("HEAD"), method = "remove")
2222
void linkart$removeLink(CallbackInfo callbackInformation, @Local(argsOnly = true) Entity.RemovalReason reason) {
23-
if ((Entity) (Object) this instanceof AbstractMinecartEntity minecart && !minecart.getWorld().isClient() && reason.shouldDestroy()) {
23+
if ((Entity) (Object) this instanceof AbstractMinecartEntity minecart && !minecart./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/.isClient() && reason.shouldDestroy()) {
2424
CartUtils.unlinkFromParent(minecart);
2525
CartUtils.unlinkFromParent(minecart.linkart$getFollower());
2626
}
@@ -29,10 +29,10 @@ public abstract class EntityMixin {
2929
@Inject(at = @At("HEAD"), method = "adjustMovementForCollisions(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;", cancellable = true)
3030
void linkart$onRecalculateVelocity(Vec3d movement, CallbackInfoReturnable<Vec3d> cir) {
3131
if ((Object) this instanceof AbstractMinecartEntity minecart) {
32-
List<Entity> collisions = minecart.getWorld().getOtherEntities((Entity) (Object) this, minecart.getBoundingBox().stretch(movement));
32+
List<Entity> collisions = minecart./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/.getOtherEntities((Entity) (Object) this, minecart.getBoundingBox().stretch(movement));
3333

3434
for (Entity entity : collisions) {
35-
if (!CollisionUtils.shouldCollide(minecart, entity) && minecart.getWorld().getBlockState(minecart.getBlockPos()).getBlock() instanceof AbstractRailBlock) {
35+
if (!CollisionUtils.shouldCollide(minecart, entity) && minecart./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/.getBlockState(minecart.getBlockPos()).getBlock() instanceof AbstractRailBlock) {
3636
cir.setReturnValue(movement);
3737
return;
3838
}

src/main/java/com/github/vini2003/linkart/mixin/PlayerEntityMixin.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected PlayerEntityMixin(EntityType<? extends LivingEntity> entityType, World
3131
@Inject(at = @At("HEAD"), method = "interact", cancellable = true)
3232
void onInteract(Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
3333
if (entity instanceof AbstractMinecartEntity minecart) {
34-
if (getWorld().isClient()) return;
34+
if (/*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/.isClient()) return;
3535

3636
PlayerEntity player = (PlayerEntity) (Object) this;
3737
ItemStack stack = player.getStackInHand(hand);
@@ -59,10 +59,13 @@ void onInteract(Entity entity, Hand hand, CallbackInfoReturnable<ActionResult> c
5959
}
6060

6161
@Unique private void finishOperation(CallbackInfoReturnable<ActionResult> cir, AbstractMinecartEntity minecart, ActionResult result) {
62+
ServerWorld world = (ServerWorld) minecart./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/;
63+
if (world.isClient()) return;
64+
6265
if (result.isAccepted()) {
63-
((ServerWorld) minecart.getWorld()).spawnParticles(ParticleTypes.HAPPY_VILLAGER, minecart.getX(), minecart.getY() + 0.2, minecart.getZ(), 10, 0.5, 0.5, 0.5, 0.5);
66+
world.spawnParticles(ParticleTypes.HAPPY_VILLAGER, minecart.getX(), minecart.getY() + 0.2, minecart.getZ(), 10, 0.5, 0.5, 0.5, 0.5);
6467
} else {
65-
((ServerWorld) minecart.getWorld()).spawnParticles(ParticleTypes.ANGRY_VILLAGER, minecart.getX(), minecart.getY() + 0.2, minecart.getZ(), 10, 0.5, 0.5, 0.5, 0.5);
68+
world.spawnParticles(ParticleTypes.ANGRY_VILLAGER, minecart.getX(), minecart.getY() + 0.2, minecart.getZ(), 10, 0.5, 0.5, 0.5, 0.5);
6669
}
6770
cir.setReturnValue(result);
6871
}

src/main/java/com/github/vini2003/linkart/utility/CartUtils.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
import net.minecraft.particle.ItemStackParticleEffect;
66
import net.minecraft.particle.ParticleTypes;
77
import net.minecraft.server.world.ServerWorld;
8+
import net.minecraft.world.World;
89

910
public class CartUtils {
1011

1112
public static void spawnChainParticles(AbstractMinecartEntity entity) {
12-
if (!entity.getWorld().isClient()) {
13-
((ServerWorld) entity.getWorld()).spawnParticles(new ItemStackParticleEffect(ParticleTypes.ITEM, entity.linkart$getLinkItem()), entity.getX(), entity.getY() + 0.3, entity.getZ(), 15, 0.2, 0.2, 0.2, 0.2);
13+
World world = entity./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/;
14+
if (!world.isClient()) {
15+
((ServerWorld) world).spawnParticles(new ItemStackParticleEffect(ParticleTypes.ITEM, entity.linkart$getLinkItem()), entity.getX(), entity.getY() + 0.3, entity.getZ(), 15, 0.2, 0.2, 0.2, 0.2);
1416
}
1517
}
1618

@@ -29,10 +31,12 @@ public static void unlinkFromParent(AbstractMinecartEntity entity) {
2931
entity.setVelocity(0, 0, 0);
3032

3133
if (!entity.linkart$getLinkItem().isEmpty()) {
32-
//? if =1.21.1
34+
//? if >=1.21.9 {
35+
/*entity.dropStack((ServerWorld) entity.getEntityWorld(), entity.linkart$getLinkItem());
36+
*///?} elif >=1.21.4 {
37+
/*entity.dropStack((ServerWorld) entity.getWorld(), entity.linkart$getLinkItem());
38+
*///?} elif =1.21.1
3339
entity.dropStack(entity.linkart$getLinkItem());
34-
//? if >=1.21.4
35-
/*entity.dropStack((ServerWorld) entity.getWorld(), entity.linkart$getLinkItem());*/
3640
spawnChainParticles(entity);
3741
}
3842

src/main/java/com/github/vini2003/linkart/utility/LinkartCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class LinkartCommand {
1111

12-
private static final Supplier<Text> RELOADED = () -> TextUtil.literal("reloaded linkart config");
12+
private static final Supplier<Text> RELOADED = () -> Text.literal("reloaded linkart config");
1313

1414
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
1515
dispatcher.register(CommandManager.literal("linkart")

src/main/java/com/github/vini2003/linkart/utility/TextUtil.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)