Skip to content

Commit

Permalink
Port to 1.18.2, 1.19.3, 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lntricate1 committed May 29, 2023
1 parent 2f41504 commit ba3fe54
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ preprocess {
// mc117.link(mc116, null)

mc117.link(mc118, null)
mc118.link(mc1193, null)
mc118.link(mc1193, file('versions/mapping-1.18.2-1.19.3.txt'))
mc1193.link(mc1194, null)
// mc119.link(mcSnapshot, null)
}
Expand Down
5 changes: 3 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ def versions = Arrays.asList(
// "1.15.2",
// "1.16.5",
"1.17.1",
// "1.18.2",
// "1.19.x",
"1.18.2",
"1.19.3",
"1.19.4",
// "snapshot",
)
for (String version : versions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

public interface IChunkMap
{
public boolean noPlayersCloseWithInteraction(ChunkPos chunkPos, Interaction interaction);
public boolean anyPlayerCloseWithInteraction(ChunkPos chunkPos, Interaction interaction);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ public class ChunkMapMixin implements IChunkMap
@Shadow @Final private PlayerMap playerMap;

@Override
public boolean noPlayersCloseWithInteraction(ChunkPos chunkPos, Interaction interaction)
public boolean anyPlayerCloseWithInteraction(ChunkPos chunkPos, Interaction interaction)
{
return playerMap.getPlayers(chunkPos.toLong()).noneMatch(player -> ((IServerPlayer)player).getInteraction(interaction) && euclideanDistanceSquared(chunkPos, player) < 16384.0);
//#if MC >= 11800
//$$ for(ServerPlayer player : playerMap.getPlayers(chunkPos.toLong()))
//$$ if(((IServerPlayer)player).getInteraction(interaction) && euclideanDistanceSquared(chunkPos, player) < 16384.0)
//$$ return true;
//$$ return false;
//#else
return playerMap.getPlayers(chunkPos.toLong()).anyMatch(player ->
((IServerPlayer)player).getInteraction(interaction) && euclideanDistanceSquared(chunkPos, player) < 16384.0);
//#endif
}

@Inject(method = "skipPlayer", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.WrapWithCondition;

import me.lntricate.intricarpet.interactions.Interaction;
Expand All @@ -21,24 +19,22 @@ public class ServerChunkCacheMixin
{
@Shadow private ChunkMap chunkMap;

@Unique private boolean check;
private static final String targetMethod =
//#if MC >= 11800
//$$ "tickChunks";
//#else
"method_20801";
//#endif

@ModifyExpressionValue(method = "method_20801", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ChunkMap;noPlayersCloseForSpawning(Lnet/minecraft/world/level/ChunkPos;)Z"))
private boolean noPlayersCloseForSpawning(boolean original)
{
check = original;
return false;
}

@WrapWithCondition(method = "method_20801", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/NaturalSpawner;spawnForChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/NaturalSpawner$SpawnState;ZZZ)V"))
@WrapWithCondition(method = targetMethod, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/NaturalSpawner;spawnForChunk(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/NaturalSpawner$SpawnState;ZZZ)V"))
private boolean shouldSpawnMobs(ServerLevel a, LevelChunk levelChunk, SpawnState b, boolean c, boolean d, boolean e)
{
return !(check || ((IChunkMap)chunkMap).noPlayersCloseWithInteraction(levelChunk.getPos(), Interaction.MOBSPAWNING));
return ((IChunkMap)chunkMap).anyPlayerCloseWithInteraction(levelChunk.getPos(), Interaction.MOBSPAWNING);
}

@WrapWithCondition(method = "method_20801", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V"))
@WrapWithCondition(method = targetMethod, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;tickChunk(Lnet/minecraft/world/level/chunk/LevelChunk;I)V"))
private boolean shouldRandomTick(ServerLevel instance, LevelChunk levelChunk, int i)
{
return !(check || ((IChunkMap)chunkMap).noPlayersCloseWithInteraction(levelChunk.getPos(), Interaction.RANDOMTICKS));
return ((IChunkMap)chunkMap).anyPlayerCloseWithInteraction(levelChunk.getPos(), Interaction.RANDOMTICKS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,21 @@ private void afterInteractItem(ServerboundUseItemPacket packet, CallbackInfo ci)
CarpetSettings.impendingFillSkipUpdates.set(false);
}

@Inject(method = "handlePlayerAction", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayerGameMode;handleBlockBreakAction(Lnet/minecraft/core/BlockPos;Lnet/minecraft/network/protocol/game/ServerboundPlayerActionPacket$Action;Lnet/minecraft/core/Direction;I)V"))
private static final String handleBlockBreakAction =
//#if MC >= 11900
//$$ "Lnet/minecraft/server/level/ServerPlayerGameMode;handleBlockBreakAction(Lnet/minecraft/core/BlockPos;Lnet/minecraft/network/protocol/game/ServerboundPlayerActionPacket$Action;Lnet/minecraft/core/Direction;II)V";
//#else
"Lnet/minecraft/server/level/ServerPlayerGameMode;handleBlockBreakAction(Lnet/minecraft/core/BlockPos;Lnet/minecraft/network/protocol/game/ServerboundPlayerActionPacket$Action;Lnet/minecraft/core/Direction;I)V";
//#endif

@Inject(method = "handlePlayerAction", at = @At(value = "INVOKE", target = handleBlockBreakAction))
private void beforeBreakBlock(ServerboundPlayerActionPacket packet, CallbackInfo ci)
{
if(!((IServerPlayer)player).getInteraction(Interaction.UPDATES))
CarpetSettings.impendingFillSkipUpdates.set(true);
}

@Inject(method = "handlePlayerAction", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayerGameMode;handleBlockBreakAction(Lnet/minecraft/core/BlockPos;Lnet/minecraft/network/protocol/game/ServerboundPlayerActionPacket$Action;Lnet/minecraft/core/Direction;I)V", shift = Shift.AFTER))
@Inject(method = "handlePlayerAction", at = @At(value = "INVOKE", target = handleBlockBreakAction, shift = Shift.AFTER))
private void afterBreakBlock(ServerboundPlayerActionPacket packet, CallbackInfo ci)
{
CarpetSettings.impendingFillSkipUpdates.set(false);
Expand Down
4 changes: 3 additions & 1 deletion versions/1.18.2/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
yarn_mappings=1.18.2+build.4

# Fabric Mod Metadata
minecraft_dependency = 1.18.x
minecraft_dependency=1.18.x
carpet_dependency=>=1.4.69

# Build Information
# The target mc versions for the mod during mod publishing, separated with \n
game_versions=1.18.2

# Dependencies
# fabric_api_version=0.59.1+1.18.2
carpet_version=1.18.2-1.4.69+v220331
15 changes: 15 additions & 0 deletions versions/1.19.3/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fabric Properties
# check these on https://fabricmc.net/versions.html?&version=1.18.2
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5

# Fabric Mod Metadata
minecraft_dependency=1.19.3
carpet_dependency=>=1.4.96

# Build Information
# The target mc versions for the mod during mod publishing, separated with \n
game_versions=1.19.3

# Dependencies
carpet_version=1.19.3-1.4.96+v230201
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Fabric Properties
# check these on https://fabricmc.net/versions.html?&version=1.19.4
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
yarn_mappings=1.19.4+build.2

# Fabric Mod Metadata
minecraft_dependency = 1.19.x
minecraft_dependency=1.19.4
carpet_dependency=>=1.4.100

# Build Information
# The target mc versions for the mod during mod publishing, separated with \n
game_versions=1.19.4

# Dependencies
# fabric_api_version=0.75.3+1.19.4
carpet_version=1.19.4-1.4.100+v230314
1 change: 1 addition & 0 deletions versions/mapping-1.18.2-1.19.3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
net.minecraft.network.chat.BaseComponent net.minecraft.network.chat.Component

0 comments on commit ba3fe54

Please sign in to comment.