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
@@ -9,7 +9,6 @@ import carpet.settings.Rule;
|
||||
import carpet.utils.Translations;
|
||||
import carpet.utils.CommandHelper;
|
||||
import carpet.utils.Messenger;
|
||||
import carpet.utils.SpawnChunks;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
@@ -770,37 +769,6 @@ public class CarpetSettings
|
||||
)
|
||||
public static int simulationDistance = 0;
|
||||
|
||||
public static class ChangeSpawnChunksValidator extends Validator<Integer> {
|
||||
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
|
||||
if (source == null) return newValue;
|
||||
if (newValue < 0 || newValue > 32)
|
||||
{
|
||||
Messenger.m(source, "r spawn chunk size has to be between 0 and 32");
|
||||
return null;
|
||||
}
|
||||
if (currentRule.value().intValue() == newValue.intValue())
|
||||
{
|
||||
//must been some startup thing
|
||||
return newValue;
|
||||
}
|
||||
ServerLevel currentOverworld = source.getServer().overworld();
|
||||
if (currentOverworld != null)
|
||||
{
|
||||
SpawnChunks.changeSpawnSize(currentOverworld, newValue);
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
@Rule(
|
||||
desc = "Changes size of spawn chunks",
|
||||
extra = {"Defines new radius", "setting it to 0 - disables spawn chunks"},
|
||||
category = CREATIVE,
|
||||
strict = false,
|
||||
options = {"0", "11"},
|
||||
validate = ChangeSpawnChunksValidator.class
|
||||
)
|
||||
public static int spawnChunksSize = MinecraftServer.START_CHUNK_RADIUS;
|
||||
|
||||
public enum RenewableCoralMode {
|
||||
FALSE,
|
||||
EXPANDED,
|
||||
|
||||
@@ -131,7 +131,7 @@ public class BlockRotator
|
||||
}
|
||||
else if (block instanceof SlabBlock)
|
||||
{
|
||||
if (((SlabBlock) block).useShapeForLightOcclusion(state))
|
||||
if (state.getValue(SlabBlock.TYPE) != SlabType.DOUBLE)
|
||||
{
|
||||
newState = state.setValue(SlabBlock.TYPE, state.getValue(SlabBlock.TYPE) == SlabType.TOP ? SlabType.BOTTOM : SlabType.TOP);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package carpet.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CarpetTaintedList<E> extends ArrayList<E>
|
||||
{
|
||||
public CarpetTaintedList(final List<E> list)
|
||||
{
|
||||
super(list);
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public class OptimizedExplosion
|
||||
// explosionSound incremented till disabling the explosion particles and sound
|
||||
if (explosionSound < 100 || explosionSound % 100 == 0)
|
||||
{
|
||||
world.playSound(null, posX, posY, posZ, SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 4.0F,
|
||||
world.playSound(null, posX, posY, posZ, SoundEvents.GENERIC_EXPLODE.value(), SoundSource.BLOCKS, 4.0F,
|
||||
(1.0F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F);
|
||||
|
||||
if (spawnParticles)
|
||||
|
||||
@@ -676,7 +676,7 @@ public class RedstoneWireTurbo
|
||||
// call BlockStateBase#neighborChanged directly. This change mostly
|
||||
// restores old behavior, at the cost of bypassing the
|
||||
// max-chained-neighbor-updates server property.
|
||||
worldIn.getBlockState(upd.self).neighborChanged(worldIn, upd.self, wire, upd.parent, false);
|
||||
worldIn.getBlockState(upd.self).handleNeighborChanged(worldIn, upd.self, wire, upd.parent, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
@@ -16,21 +17,23 @@ public class CarpetClient
|
||||
{
|
||||
public record CarpetPayload(CompoundTag data) implements CustomPacketPayload
|
||||
{
|
||||
public static final StreamCodec<FriendlyByteBuf, CarpetPayload> STREAM_CODEC = CustomPacketPayload.codec(CarpetPayload::write, CarpetPayload::new);
|
||||
|
||||
public static final Type<CarpetPayload> TYPE = new CustomPacketPayload.Type<>(CARPET_CHANNEL);
|
||||
|
||||
public CarpetPayload(FriendlyByteBuf input)
|
||||
{
|
||||
this(input.readNbt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf output)
|
||||
{
|
||||
output.writeNbt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id()
|
||||
@Override public Type<CarpetPayload> type()
|
||||
{
|
||||
return CARPET_CHANNEL;
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
}
|
||||
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, current, ClientInformation.createDefault(), false);
|
||||
instance.fixStartingPosition = () -> instance.moveTo(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance, new CommonListenerCookie(current, 0, instance.clientInformation()));
|
||||
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance, new CommonListenerCookie(current, 0, instance.clientInformation(), false));
|
||||
instance.teleportTo(worldIn, pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
|
||||
instance.setHealth(20.0F);
|
||||
instance.unsetRemoved();
|
||||
@@ -101,7 +101,7 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
GameProfile gameprofile = player.getGameProfile();
|
||||
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, player.clientInformation(), true);
|
||||
playerShadow.setChatSession(player.getChatSession());
|
||||
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), playerShadow, new CommonListenerCookie(gameprofile, 0, player.clientInformation()));
|
||||
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), playerShadow, new CommonListenerCookie(gameprofile, 0, player.clientInformation(), true));
|
||||
|
||||
playerShadow.setHealth(player.getHealth());
|
||||
playerShadow.connection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||
|
||||
@@ -4,6 +4,7 @@ import carpet.fakes.ClientConnectionInterface;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.PacketListener;
|
||||
import net.minecraft.network.ProtocolInfo;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
|
||||
public class FakeClientConnection extends Connection
|
||||
@@ -27,7 +28,12 @@ public class FakeClientConnection extends Connection
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(PacketListener packetListener)
|
||||
public void setListenerForServerboundHandshake(PacketListener packetListener)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends PacketListener> void setupInboundProtocol(ProtocolInfo<T> protocolInfo, T packetListener)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ import net.minecraft.world.level.levelgen.NoiseRouter;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureType;
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -898,7 +899,7 @@ public class WorldAccess
|
||||
}
|
||||
world.levelEvent(null, 2001, where, Block.getId(state));
|
||||
|
||||
boolean toolBroke = false;
|
||||
final MutableBoolean toolBroke = new MutableBoolean(false);
|
||||
boolean dropLoot = true;
|
||||
if (playerBreak)
|
||||
{
|
||||
@@ -914,7 +915,8 @@ public class WorldAccess
|
||||
{
|
||||
damageAmount = 2;
|
||||
}
|
||||
toolBroke = damageAmount > 0 && tool.hurt(damageAmount, world.getRandom(), null);
|
||||
final int finalDamageAmount = damageAmount;
|
||||
tool.hurtAndBreak(damageAmount, world.getRandom(), null, () -> { if (finalDamageAmount > 0) toolBroke.setTrue(); } );
|
||||
if (!isUsingEffectiveTool)
|
||||
{
|
||||
dropLoot = false;
|
||||
@@ -931,7 +933,7 @@ public class WorldAccess
|
||||
{
|
||||
if (how > 0)
|
||||
{
|
||||
tool.enchant(Enchantments.BLOCK_FORTUNE, (int) how);
|
||||
tool.enchant(Enchantments.FORTUNE, (int) how);
|
||||
}
|
||||
if (DUMMY_ENTITY == null)
|
||||
{
|
||||
@@ -944,7 +946,7 @@ public class WorldAccess
|
||||
{
|
||||
return Value.TRUE;
|
||||
}
|
||||
if (toolBroke)
|
||||
if (toolBroke.booleanValue())
|
||||
{
|
||||
return Value.NULL;
|
||||
}
|
||||
|
||||
@@ -59,10 +59,7 @@ public class SystemInfo
|
||||
return StringValue.of(tlf);
|
||||
});
|
||||
put("world_dimensions", c -> ListValue.wrap(c.server().levelKeys().stream().map(k -> ValueConversions.of(k.location()))));
|
||||
put("world_spawn_point", c -> {
|
||||
LevelData prop = c.server().overworld().getLevelData();
|
||||
return ListValue.of(NumericValue.of(prop.getXSpawn()), NumericValue.of(prop.getYSpawn()), NumericValue.of(prop.getZSpawn()));
|
||||
});
|
||||
put("world_spawn_point", c -> ValueConversions.of(c.server().overworld().getLevelData().getSpawnPos()));
|
||||
|
||||
put("world_bottom", c -> new NumericValue(c.level().getMinBuildHeight()));
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.EntityTypeTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -46,7 +47,6 @@ import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.MobType;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.RelativeMovement;
|
||||
@@ -359,20 +359,26 @@ public class EntityValue extends Value
|
||||
|
||||
// combat groups
|
||||
|
||||
put("arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() == MobType.ARTHROPOD && e.isAlive()), allTypes.stream().filter(arthropods::contains)));
|
||||
put("!arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() != MobType.ARTHROPOD && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et))));
|
||||
put("arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(arthropods::contains)));
|
||||
put("!arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et))));
|
||||
|
||||
put("undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() == MobType.UNDEAD && e.isAlive()), allTypes.stream().filter(undeads::contains)));
|
||||
put("!undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() != MobType.UNDEAD && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et))));
|
||||
put("undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(undeads::contains)));
|
||||
put("!undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et))));
|
||||
|
||||
put("aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() == MobType.WATER && e.isAlive()), allTypes.stream().filter(aquatique::contains)));
|
||||
put("!aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() != MobType.WATER && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et))));
|
||||
put("aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(aquatique::contains)));
|
||||
put("!aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et))));
|
||||
|
||||
put("illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() == MobType.ILLAGER && e.isAlive()), allTypes.stream().filter(illagers::contains)));
|
||||
put("!illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() != MobType.ILLAGER && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et))));
|
||||
put("illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(illagers::contains)));
|
||||
put("!illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et))));
|
||||
|
||||
put("regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() == MobType.UNDEFINED && e.isAlive()), allTypes.stream().filter(regular::contains)));
|
||||
put("!regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() != MobType.UNDEFINED && e.isAlive()), allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et))));
|
||||
put("regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> {
|
||||
EntityType<?> type = e.getType();
|
||||
return !illagers.contains(type) && !arthropods.contains(type) && !undeads.contains(type) && !aquatique.contains(type) && living.contains(type) && e.isAlive();
|
||||
}, allTypes.stream().filter(regular::contains)));
|
||||
put("!regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> {
|
||||
EntityType<?> type = e.getType();
|
||||
return (illagers.contains(type) || arthropods.contains(type) || undeads.contains(type) || aquatique.contains(type)) && e.isAlive();
|
||||
}, allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et))));
|
||||
|
||||
for (ResourceLocation typeId : BuiltInRegistries.ENTITY_TYPE.keySet())
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BlockInfo
|
||||
lst.add(Messenger.s("====================================="));
|
||||
lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):", blocks.getKey(block),metastring, blocks.getId(block), metastring )));
|
||||
lst.add(Messenger.s(String.format(" - Map colour: %s", Colors.mapColourName.get(state.getMapColor(world, pos)))));
|
||||
lst.add(Messenger.s(String.format(" - Sound type: %s", Colors.soundName.get(block.getSoundType(state)))));
|
||||
lst.add(Messenger.s(String.format(" - Sound type: %s", Colors.soundName.get(state.getSoundType()))));
|
||||
lst.add(Messenger.s(""));
|
||||
lst.add(Messenger.s(String.format(" - Full block: %s", state.isCollisionShapeFullBlock(world, pos)))); // isFullCube() )));
|
||||
lst.add(Messenger.s(String.format(" - Normal cube: %s", state.isRedstoneConductor(world, pos)))); //isNormalCube()))); isSimpleFullBlock
|
||||
@@ -61,7 +61,7 @@ public class BlockInfo
|
||||
lst.add(Messenger.s(String.format(" - Can burn: %s", state.ignitedByLava())));
|
||||
lst.add(Messenger.s(String.format(" - Hardness: %.2f", state.getDestroySpeed(world, pos))));
|
||||
lst.add(Messenger.s(String.format(" - Blast resistance: %.2f", block.getExplosionResistance())));
|
||||
lst.add(Messenger.s(String.format(" - Ticks randomly: %s", block.isRandomlyTicking(state))));
|
||||
lst.add(Messenger.s(String.format(" - Ticks randomly: %s", state.isRandomlyTicking())));
|
||||
lst.add(Messenger.s(""));
|
||||
lst.add(Messenger.s(String.format(" - Can provide power: %s", state.isSignalSource())));
|
||||
lst.add(Messenger.s(String.format(" - Strong power level: %d", world.getDirectSignalTo(pos))));
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package carpet.utils;
|
||||
|
||||
import carpet.fakes.ChunkTicketManagerInterface;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.DistanceManager;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
|
||||
public class SpawnChunks
|
||||
{
|
||||
public static void changeSpawnSize(ServerLevel overworld, int size)
|
||||
{
|
||||
ChunkPos centerChunk = new ChunkPos(new BlockPos(
|
||||
overworld.getLevelData().getXSpawn(),
|
||||
overworld.getLevelData().getYSpawn(),
|
||||
overworld.getLevelData().getZSpawn()
|
||||
));
|
||||
DistanceManager ticketManager = overworld.getChunkSource().chunkMap.getDistanceManager();
|
||||
((ChunkTicketManagerInterface)ticketManager).changeSpawnChunks(centerChunk, size);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user