removed spawn chunks size rule. Hack for network stuff - may stay. 24w03a
This commit is contained in:
1 parent
4aec8114c9
commit
d524df5a0b
25 files changed
+116
-194
No files matched your search
@@ -1,31 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.network.ClientNetworkHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ClientboundCustomPayloadPacket.class)
|
||||
public class ClientboundCustomPayloadPacket_customPacketMixin
|
||||
{
|
||||
@Inject(method = "readPayload", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/protocol/common/ClientboundCustomPayloadPacket;readUnknownPayload(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/network/protocol/common/custom/DiscardedPayload;"),
|
||||
cancellable = true)
|
||||
private static void onOnCustomPayloadR(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf, CallbackInfoReturnable<CustomPacketPayload> cir)
|
||||
{
|
||||
if (resourceLocation.equals(CarpetClient.CARPET_CHANNEL))
|
||||
{
|
||||
cir.setReturnValue(new CarpetClient.CarpetPayload(friendlyByteBuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.CarpetTaintedList;
|
||||
import carpet.network.CarpetClient;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(CustomPacketPayload.class)
|
||||
public interface CustomPacketPayload_networkStuffMixin
|
||||
{
|
||||
@Inject(method = "codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;)Lnet/minecraft/network/codec/StreamCodec;", at = @At("HEAD"), cancellable = true)
|
||||
private static <B extends FriendlyByteBuf> void onCodec(final CustomPacketPayload.FallbackProvider<B> fallbackProvider, final List<CustomPacketPayload.TypeAndCodec<? super B, ?>> list, final CallbackInfoReturnable<StreamCodec<B, CustomPacketPayload>> cir)
|
||||
{
|
||||
// this is stupid hack to make sure carpet payloads are always registered
|
||||
// that might collide with other mods that do the same thing
|
||||
// so we may need to adjust this in the future
|
||||
if (!(list instanceof CarpetTaintedList))
|
||||
{
|
||||
List<CustomPacketPayload.TypeAndCodec<? super B, ?>> extendedList = new CarpetTaintedList<>(list);
|
||||
extendedList.add(new CustomPacketPayload.TypeAndCodec<>(CarpetClient.CarpetPayload.TYPE, CarpetClient.CarpetPayload.STREAM_CODEC));
|
||||
cir.setReturnValue(CustomPacketPayload.codec(fallbackProvider, extendedList));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import carpet.CarpetSettings;
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.logging.logHelpers.ExplosionLogHelper;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.monster.breeze.Breeze;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -81,9 +81,9 @@ public abstract class Explosion_optimizedTntMixin
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/sounds/SoundEvent;)V",
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)V",
|
||||
at = @At(value = "RETURN"))
|
||||
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particleOptions, ParticleOptions particleOptions2, SoundEvent soundEvent, CallbackInfo ci)
|
||||
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder soundEvent, CallbackInfo ci)
|
||||
{
|
||||
if (LoggerRegistry.__explosions && ! world.isClientSide)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -45,9 +45,9 @@ public abstract class Explosion_scarpetEventMixin
|
||||
|
||||
private List<Entity> affectedEntities;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/sounds/SoundEvent;)V",
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/particles/ParticleOptions;Lnet/minecraft/core/Holder;)V",
|
||||
at = @At(value = "RETURN"))
|
||||
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particleOptions, ParticleOptions particleOptions2, SoundEvent soundEvent, CallbackInfo ci)
|
||||
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder soundEvent, CallbackInfo ci)
|
||||
{
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClientSide())
|
||||
{
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import carpet.utils.SpawnChunks;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -61,11 +58,4 @@ public abstract class MinecraftServer_coreMixin
|
||||
|
||||
@Shadow
|
||||
public abstract ServerLevel overworld();
|
||||
|
||||
@Inject(method = "prepareLevels", at = @At("RETURN"))
|
||||
private void afterSpawnCreated(ChunkProgressListener worldGenerationProgressListener, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.spawnChunksSize != 11)
|
||||
SpawnChunks.changeSpawnSize(overworld(), CarpetSettings.spawnChunksSize);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class PickaxeItem_missingToolsMixin extends DiggerItem
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
if (CarpetSettings.missingTools && state.getBlock().getSoundType(state) == SoundType.GLASS)
|
||||
if (CarpetSettings.missingTools && state.getSoundType() == SoundType.GLASS)
|
||||
{
|
||||
return speed;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
|
||||
}
|
||||
|
||||
@Inject(method = "explode", at = @At("HEAD"))
|
||||
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionDamageCalculator explosionBehavior, double d, double e, double f, float g, boolean bl, ExplosionInteraction explosionInteraction, ParticleOptions particleOptions, ParticleOptions particleOptions2, SoundEvent soundEvent, CallbackInfoReturnable<Explosion> cir)
|
||||
private void handleExplosion(/*@Nullable*/ Entity entity, /*@Nullable*/ DamageSource damageSource, /*@Nullable*/ ExplosionDamageCalculator explosionBehavior, double d, double e, double f, float g, boolean bl, ExplosionInteraction explosionInteraction, ParticleOptions particleOptions, ParticleOptions particleOptions2, Holder<SoundEvent> soundEvent, CallbackInfoReturnable<Explosion> cir)
|
||||
{
|
||||
if (EXPLOSION.isNeeded()) {
|
||||
Explosion.BlockInteraction var10000 = switch (explosionInteraction) {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(ServerLevel.class)
|
||||
public class ServerLevel_spawnChunksMixin
|
||||
{
|
||||
@ModifyConstant(method = "setDefaultSpawnPos", constant = @Constant(intValue = 11), expect = 2)
|
||||
private int pushLimit(int original)
|
||||
{
|
||||
return CarpetSettings.spawnChunksSize;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,43 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = ServerPlayer.class)
|
||||
public abstract class ServerPlayerGameMode_antiCheatMixin extends Player
|
||||
@Mixin(value = Player.class)
|
||||
public abstract class ServerPlayerGameMode_antiCheatMixin extends LivingEntity
|
||||
{
|
||||
public ServerPlayerGameMode_antiCheatMixin(final Level level, final BlockPos blockPos, final float f, final GameProfile gameProfile)
|
||||
@Shadow public abstract double entityInteractionRange();
|
||||
|
||||
@Shadow public abstract double blockInteractionRange();
|
||||
|
||||
protected ServerPlayerGameMode_antiCheatMixin(final EntityType<? extends LivingEntity> entityType, final Level level)
|
||||
{
|
||||
super(level, blockPos, f, gameProfile);
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
@Inject(method = "canInteractWithBlock", at = @At("HEAD"), cancellable = true)
|
||||
private void canInteractLongRangeBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir)
|
||||
private void canInteractLongRangeBlock(BlockPos pos, double d, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
double maxRange = blockInteractionRange() + 1.0;
|
||||
double maxRange = blockInteractionRange() + d;
|
||||
maxRange = maxRange * maxRange;
|
||||
if (CarpetSettings.antiCheatDisabled && maxRange < 1024 && getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) < 1024) cir.setReturnValue(true);
|
||||
}
|
||||
|
||||
@Inject(method = "canInteractWithEntity", at = @At("HEAD"), cancellable = true)
|
||||
private void canInteractLongRangeEntity(AABB aabb, CallbackInfoReturnable<Boolean> cir)
|
||||
@Inject(method = "canInteractWithEntity(Lnet/minecraft/world/phys/AABB;D)Z", at = @At("HEAD"), cancellable = true)
|
||||
private void canInteractLongRangeEntity(AABB aabb, double d, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
double maxRange = entityInteractionRange() + 1.0;
|
||||
double maxRange = entityInteractionRange() + d;
|
||||
maxRange = maxRange * maxRange;
|
||||
if (CarpetSettings.antiCheatDisabled && maxRange < 1024 && aabb.distanceToSqr(getEyePosition()) < 1024) cir.setReturnValue(true);
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.network.CarpetClient;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ServerboundCustomPayloadPacket.class)
|
||||
public class ServerboundCustomPayloadPacket_mixin
|
||||
{
|
||||
@Inject(method = "readPayload", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/protocol/common/ServerboundCustomPayloadPacket;readUnknownPayload(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/network/protocol/common/custom/DiscardedPayload;"
|
||||
), cancellable = true)
|
||||
private static void onOnCustomPayload(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf, CallbackInfoReturnable<CustomPacketPayload> cir)
|
||||
{
|
||||
if (CarpetClient.CARPET_CHANNEL.equals(resourceLocation))
|
||||
{
|
||||
cir.setReturnValue(new CarpetClient.CarpetPayload(friendlyByteBuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user