fixes for 22w11a
This commit is contained in:
1 parent
3e419d1557
commit
302a7b4817
39 files changed
+410
-305
No files matched your search
@@ -3,7 +3,8 @@ package carpet.mixins;
|
||||
import carpet.utils.SpawnOverrides;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.level.StructureManager;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -12,7 +13,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
@@ -30,9 +30,9 @@ public abstract class ChunkGenerator_customMobSpawnsMixin
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/Map$Entry;getKey()Ljava/lang/Object;"
|
||||
), cancellable = true)
|
||||
private void checkCMSpawns(Holder<Biome> holder, StructureFeatureManager structureFeatureManager, MobCategory mobCategory, BlockPos blockPos,
|
||||
CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir,
|
||||
Map<ConfiguredStructureFeature<?, ?>, LongSet> map, Iterator<?> var6, Map.Entry<ConfiguredStructureFeature<?, ?>, LongSet> entry)
|
||||
private void checkCMSpawns(Holder<Biome> holder, StructureManager structureFeatureManager, MobCategory mobCategory, BlockPos blockPos,
|
||||
CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir,
|
||||
Map<Structure, LongSet> map, Iterator<?> var6, Map.Entry<Structure, LongSet> entry)
|
||||
{
|
||||
WeightedRandomList<MobSpawnSettings.SpawnerData> res = SpawnOverrides.test(structureFeatureManager, entry.getValue(), mobCategory, entry.getKey(), blockPos);
|
||||
if (res != null)
|
||||
|
||||
@@ -2,8 +2,10 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ChunkGeneratorInterface;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.StructurePlacement;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -14,18 +16,18 @@ import java.util.List;
|
||||
public abstract class ChunkGenerator_scarpetMixin implements ChunkGeneratorInterface
|
||||
{
|
||||
|
||||
@Shadow protected abstract List<StructurePlacement> getPlacementsForFeature(Holder<ConfiguredStructureFeature<?, ?>> holder);
|
||||
@Shadow public abstract void ensureStructuresGenerated(RandomState randomState);
|
||||
|
||||
@Shadow public abstract void ensureStructuresGenerated();
|
||||
@Shadow protected abstract List<StructurePlacement> getPlacementsForStructure(Holder<Structure> holder, RandomState randomState);
|
||||
|
||||
@Override
|
||||
public void initStrongholds()
|
||||
public void initStrongholds(final ServerLevel level)
|
||||
{
|
||||
ensureStructuresGenerated();
|
||||
ensureStructuresGenerated(level.getChunkSource().randomState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StructurePlacement> getPlacementsForFeatureCM(ConfiguredStructureFeature<?, ?> structure) {
|
||||
return getPlacementsForFeature(Holder.direct(structure));
|
||||
public List<StructurePlacement> getPlacementsForFeatureCM(final ServerLevel level, Structure structure) {
|
||||
return getPlacementsForStructure(Holder.direct(structure), level.getChunkSource().randomState());
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package carpet.mixins;
|
||||
import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import org.slf4j.Logger;
|
||||
@@ -25,9 +26,8 @@ public abstract class Commands_customCommandsMixin
|
||||
private CommandDispatcher<CommandSourceStack> dispatcher;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void onRegister(Commands.CommandSelection arg, CallbackInfo ci) {
|
||||
CarpetServer.registerCarpetCommands(this.dispatcher);
|
||||
CarpetServer.registerCarpetCommands(this.dispatcher, arg);
|
||||
private void onRegister(Commands.CommandSelection commandSelection, CommandBuildContext commandBuildContext, CallbackInfo ci) {
|
||||
CarpetServer.registerCarpetCommands(this.dispatcher, commandSelection, commandBuildContext);
|
||||
}
|
||||
|
||||
@Inject(method = "performCommand", at = @At("HEAD"))
|
||||
|
||||
@@ -46,7 +46,8 @@ public class NaturalSpawnerMixin
|
||||
|
||||
@Shadow @Final private static MobCategory[] SPAWNING_CATEGORIES;
|
||||
|
||||
@Redirect(method = "isValidSpawnPostitionForType(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkGenerator;Lnet/minecraft/world/level/biome/MobSpawnSettings$SpawnerData;Lnet/minecraft/core/BlockPos$MutableBlockPos;D)Z", at = @At(
|
||||
@Redirect(method = "isValidSpawnPostitionForType",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerLevel;noCollision(Lnet/minecraft/world/phys/AABB;)Z"
|
||||
))
|
||||
|
||||
@@ -2,6 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.BlockSaplingHelper;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -10,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import java.util.Random;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SaplingBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -23,7 +23,7 @@ public abstract class SaplingBlock_desertShrubsMixin
|
||||
cancellable = true)
|
||||
private void onGenerate(ServerLevel serverWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci)
|
||||
{
|
||||
if(CarpetSettings.desertShrubs && Biome.getBiomeCategory(serverWorld_1.getBiome(blockPos_1)) == Biome.BiomeCategory.DESERT && !BlockSaplingHelper.hasWater(serverWorld_1, blockPos_1))
|
||||
if(CarpetSettings.desertShrubs && serverWorld_1.getBiome(blockPos_1).is(BiomeTags.HAS_DESERT_PYRAMID) && !BlockSaplingHelper.hasWater(serverWorld_1, blockPos_1))
|
||||
{
|
||||
serverWorld_1.setBlock(blockPos_1, Blocks.DEAD_BUSH.defaultBlockState(), 3);
|
||||
ci.cancel();
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ public class ServerGamePacketListenerImpl_interactionUpdatesMixin
|
||||
}
|
||||
@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",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayerGameMode;handleBlockBreakAction(Lnet/minecraft/core/BlockPos;Lnet/minecraft/network/protocol/game/ServerboundPlayerActionPacket$Action;Lnet/minecraft/core/Direction;II)V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void beforeBlockBroken(ServerboundPlayerActionPacket packet, CallbackInfo ci)
|
||||
@@ -69,7 +69,7 @@ public class ServerGamePacketListenerImpl_interactionUpdatesMixin
|
||||
|
||||
@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",
|
||||
target ="Lnet/minecraft/server/level/ServerPlayerGameMode;handleBlockBreakAction(Lnet/minecraft/core/BlockPos;Lnet/minecraft/network/protocol/game/ServerboundPlayerActionPacket$Action;Lnet/minecraft/core/Direction;II)V",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void afterBlockBroken(ServerboundPlayerActionPacket packet, CallbackInfo ci)
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
|
||||
|
||||
@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",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayerGameMode;handleBlockBreakAction(Lnet/minecraft/core/BlockPos;Lnet/minecraft/network/protocol/game/ServerboundPlayerActionPacket$Action;Lnet/minecraft/core/Direction;II)V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void onClicked(ServerboundPlayerActionPacket packet, CallbackInfo ci)
|
||||
|
||||
@@ -14,58 +14,19 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(value = ServerPlayerGameMode.class, priority = 69420) // not that important for carpet
|
||||
public class ServerPlayerGameMode_antiCheatMixin
|
||||
{
|
||||
// this is how it should be done
|
||||
/*
|
||||
@ModifyConstant(method = "processBlockBreakingAction", require = 0,
|
||||
constant = @Constant(doubleValue = 36D))
|
||||
private double addDistance(double original) {
|
||||
if (CarpetSettings.antiCheatDisabled)
|
||||
return 1024D; // blocks 32 distance
|
||||
return original;
|
||||
}
|
||||
*/
|
||||
|
||||
// that shoudn't've been a constant at the first place
|
||||
// resolves problems with mobs using reach entity attributes.
|
||||
|
||||
@Redirect(method = "handleBlockBreakAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;getX()D"
|
||||
))
|
||||
private double getXX(ServerPlayer player,
|
||||
BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight)
|
||||
{
|
||||
if (CarpetSettings.antiCheatDisabled &&
|
||||
player.position().add(0, 1.5, 0).distanceToSqr(Vec3.atCenterOf(pos)) < 1024
|
||||
) return pos.getX()+0.5;
|
||||
return player.getX();
|
||||
}
|
||||
|
||||
@Redirect(method = "handleBlockBreakAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;getY()D"
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;getEyePosition()Lnet/minecraft/world/phys/Vec3;"
|
||||
))
|
||||
private double getYY(ServerPlayer player,
|
||||
BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight)
|
||||
private Vec3 getEyePos(ServerPlayer instance,
|
||||
final BlockPos pos, final ServerboundPlayerActionPacket.Action action, final Direction direction, final int maxBuildHeight, final int sequence)
|
||||
{
|
||||
if (CarpetSettings.antiCheatDisabled &&
|
||||
player.position().add(0, 1.5, 0).distanceToSqr(Vec3.atCenterOf(pos)) < 1024
|
||||
) return pos.getY()-1.0;
|
||||
return player.getY();
|
||||
instance.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) < 1024
|
||||
) return Vec3.atCenterOf(pos);
|
||||
return instance.getEyePosition();
|
||||
}
|
||||
|
||||
@Redirect(method = "handleBlockBreakAction", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;getZ()D"
|
||||
))
|
||||
private double getZZ(ServerPlayer player,
|
||||
BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight)
|
||||
{
|
||||
if (CarpetSettings.antiCheatDisabled &&
|
||||
player.position().add(0, 1.5, 0).distanceToSqr(Vec3.atCenterOf(pos)) < 1024
|
||||
) return pos.getZ()+0.5;
|
||||
return player.getZ();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user