This commit is contained in:
gnembon committed 2023-01-18 22:11:19 +01:00
1 parent 2b95a878ad
commit c7d506675e
19 files changed
+107 -43

No files matched your search

@@ -0,0 +1,17 @@
package carpet.mixins;
import carpet.fakes.BiomeInterface;
import net.minecraft.world.level.biome.Biome;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(Biome.class)
public class Biome_scarpetMixin implements BiomeInterface {
@Shadow
private Biome.ClimateSettings climateSettings;
@Override
public Biome.ClimateSettings getClimateSettings() {
return climateSettings;
}
}
@@ -4,20 +4,24 @@ import carpet.CarpetSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.server.commands.CloneCommands;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(CloneCommands.class)
public abstract class CloneCommands_fillUpdatesMixin
{
@ModifyConstant(method = "clone", constant = @Constant(intValue = CarpetSettings.VANILLA_FILL_LIMIT))
private static int fillLimit(int original) {
return CarpetSettings.fillLimit;
@Redirect(method = "clone", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/GameRules;getInt(Lnet/minecraft/world/level/GameRules$Key;)I"
))
private static int redirectCloneGameRuleInt(GameRules instance, GameRules.Key<GameRules.IntegerValue> key)
{
int vanilla = instance.getInt(key);
return Math.max(vanilla, CarpetSettings.fillLimit);
}
@Redirect(method = "clone", at = @At(
@@ -2,16 +2,21 @@ package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.server.commands.FillBiomeCommand;
import net.minecraft.world.level.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(FillBiomeCommand.class)
public class FillBiomeCommandMixin
{
@ModifyConstant(method = "fill", constant = @Constant(intValue = CarpetSettings.VANILLA_FILL_LIMIT))
private static int fillLimit(int original)
@Redirect(method = "fill", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/GameRules;getInt(Lnet/minecraft/world/level/GameRules$Key;)I"
))
private static int redirectCloneGameRuleInt(GameRules instance, GameRules.Key<GameRules.IntegerValue> key)
{
return CarpetSettings.fillLimit;
int vanilla = instance.getInt(key);
return Math.max(vanilla, CarpetSettings.fillLimit);
}
}
@@ -4,20 +4,24 @@ import carpet.CarpetSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.server.commands.FillCommand;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(FillCommand.class)
public abstract class FillCommandMixin
{
@ModifyConstant(method = "fillBlocks", constant = @Constant(intValue = CarpetSettings.VANILLA_FILL_LIMIT))
private static int fillLimit(int original)
@Redirect(method = "fillBlocks", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/GameRules;getInt(Lnet/minecraft/world/level/GameRules$Key;)I"
))
private static int redirectCloneGameRuleInt(GameRules instance, GameRules.Key<GameRules.IntegerValue> key)
{
return CarpetSettings.fillLimit;
int vanilla = instance.getInt(key);
return Math.max(vanilla, CarpetSettings.fillLimit);
}
@Redirect(method = "fillBlocks", at = @At(
@@ -1,9 +1,12 @@
package carpet.mixins;
import carpet.CarpetServer;
import carpet.fakes.ServerGamePacketListenerImplInterface;
import net.minecraft.network.Connection;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -13,13 +16,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static carpet.script.CarpetEventServer.Event.PLAYER_DISCONNECTS;
@Mixin(ServerGamePacketListenerImpl.class)
public class ServerGamePacketListenerImpl_coreMixin {
public class ServerGamePacketListenerImpl_coreMixin implements ServerGamePacketListenerImplInterface {
@Shadow
public ServerPlayer player;
@Shadow @Final private Connection connection;
@Inject(method = "onDisconnect", at = @At("HEAD"))
private void onPlayerDisconnect(Component reason, CallbackInfo ci) {
CarpetServer.onPlayerLoggedOut(this.player);
if (PLAYER_DISCONNECTS.isNeeded()) PLAYER_DISCONNECTS.onPlayerMessage(player, reason.getContents().toString());
}
@Override
public Connection getConnection() {
return connection;
}
}