This commit is contained in:
gnembon committed 2023-04-26 22:58:59 +02:00
1 parent 15b120f729
commit 07033af7dd
44 files changed
+309 -265

No files matched your search

+2 -2
View File
@@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check https://fabricmc.net/develop/ # check https://fabricmc.net/develop/
minecraft_version=23w16a minecraft_version=23w17a
loader_version=0.14.19 loader_version=0.14.19
jsr305_version=3.0.2 jsr305_version=3.0.2
fabric_version=0.78.0+1.20 fabric_version=0.79.1+1.20
# Mod Properties # Mod Properties
mod_version = 1.4.105 mod_version = 1.4.105
+1 -1
View File
@@ -842,7 +842,7 @@ public class CarpetSettings
{ {
for (ServerLevel world : server.getAllLevels()) for (ServerLevel world : server.getAllLevels())
{ {
world.getChunkSource().getLightEngine().setTaskPerBatch(maxBatchSize); //world.getChunkSource().getLightEngine().setTaskPerBatch(maxBatchSize);
} }
} }
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) { @Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
@@ -1,10 +1,12 @@
package carpet.fakes; package carpet.fakes;
import net.minecraft.world.level.lighting.LayerLightEngine; import net.minecraft.world.level.lighting.LightEngine;
public interface LightStorageInterface extends Lighting_scarpetChunkCreationInterface public interface LightStorageInterface extends Lighting_scarpetChunkCreationInterface
{ {
void processRemoveLightData(long pos); void processRemoveLightData(long pos);
void processRelight(LayerLightEngine<?, ?> lightProvider, long pos); void processRelight(LightEngine<?, ?> lightProvider, long pos);
int getLightLevelByLong(long blockPos);
} }
@@ -5,4 +5,6 @@ public interface Lighting_scarpetChunkCreationInterface
void removeLightData(long pos); void removeLightData(long pos);
void relight(long pos); void relight(long pos);
default void clearQueuedSectionBlocksPublicAccess(long sectionPos) {};
} }
@@ -174,12 +174,12 @@ public class EntityPlayerActionPack
List<Entity> entities; List<Entity> entities;
if (onlyRideables) if (onlyRideables)
{ {
entities = player.level.getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D), entities = player.level().getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D),
e -> e instanceof Minecart || e instanceof Boat || e instanceof AbstractHorse); e -> e instanceof Minecart || e instanceof Boat || e instanceof AbstractHorse);
} }
else else
{ {
entities = player.level.getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D)); entities = player.level().getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D));
} }
if (entities.size()==0) if (entities.size()==0)
return this; return this;
@@ -310,11 +310,11 @@ public class EntityPlayerActionPack
case BLOCK: case BLOCK:
{ {
player.resetLastActionTime(); player.resetLastActionTime();
ServerLevel world = player.getLevel(); ServerLevel world = player.serverLevel();
BlockHitResult blockHit = (BlockHitResult) hit; BlockHitResult blockHit = (BlockHitResult) hit;
BlockPos pos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
Direction side = blockHit.getDirection(); Direction side = blockHit.getDirection();
if (pos.getY() < player.getLevel().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos)) if (pos.getY() < player.level().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos))
{ {
InteractionResult result = player.gameMode.useItemOn(player, world, player.getItemInHand(hand), hand, blockHit); InteractionResult result = player.gameMode.useItemOn(player, world, player.getItemInHand(hand), hand, blockHit);
if (result.consumesAction()) if (result.consumesAction())
@@ -349,7 +349,7 @@ public class EntityPlayerActionPack
} }
} }
ItemStack handItem = player.getItemInHand(hand); ItemStack handItem = player.getItemInHand(hand);
if (player.gameMode.useItem(player, player.getLevel(), handItem, hand).consumesAction()) if (player.gameMode.useItem(player, player.level(), handItem, hand).consumesAction())
{ {
ap.itemUseCooldown = 3; ap.itemUseCooldown = 3;
return true; return true;
@@ -392,17 +392,17 @@ public class EntityPlayerActionPack
BlockHitResult blockHit = (BlockHitResult) hit; BlockHitResult blockHit = (BlockHitResult) hit;
BlockPos pos = blockHit.getBlockPos(); BlockPos pos = blockHit.getBlockPos();
Direction side = blockHit.getDirection(); Direction side = blockHit.getDirection();
if (player.blockActionRestricted(player.level, pos, player.gameMode.getGameModeForPlayer())) return false; if (player.blockActionRestricted(player.level(), pos, player.gameMode.getGameModeForPlayer())) return false;
if (ap.currentBlock != null && player.level.getBlockState(ap.currentBlock).isAir()) if (ap.currentBlock != null && player.level().getBlockState(ap.currentBlock).isAir())
{ {
ap.currentBlock = null; ap.currentBlock = null;
return false; return false;
} }
BlockState state = player.level.getBlockState(pos); BlockState state = player.level().getBlockState(pos);
boolean blockBroken = false; boolean blockBroken = false;
if (player.gameMode.getGameModeForPlayer().isCreative()) if (player.gameMode.getGameModeForPlayer().isCreative())
{ {
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1); player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
ap.blockHitDelay = 5; ap.blockHitDelay = 5;
blockBroken = true; blockBroken = true;
} }
@@ -410,15 +410,15 @@ public class EntityPlayerActionPack
{ {
if (ap.currentBlock != null) if (ap.currentBlock != null)
{ {
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1); player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
} }
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1); player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
boolean notAir = !state.isAir(); boolean notAir = !state.isAir();
if (notAir && ap.curBlockDamageMP == 0) if (notAir && ap.curBlockDamageMP == 0)
{ {
state.attack(player.level, pos, player); state.attack(player.level(), pos, player);
} }
if (notAir && state.getDestroyProgress(player, player.level, pos) >= 1) if (notAir && state.getDestroyProgress(player, player.level(), pos) >= 1)
{ {
ap.currentBlock = null; ap.currentBlock = null;
//instamine?? //instamine??
@@ -432,15 +432,15 @@ public class EntityPlayerActionPack
} }
else else
{ {
ap.curBlockDamageMP += state.getDestroyProgress(player, player.level, pos); ap.curBlockDamageMP += state.getDestroyProgress(player, player.level(), pos);
if (ap.curBlockDamageMP >= 1) if (ap.curBlockDamageMP >= 1)
{ {
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1); player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
ap.currentBlock = null; ap.currentBlock = null;
ap.blockHitDelay = 5; ap.blockHitDelay = 5;
blockBroken = true; blockBroken = true;
} }
player.level.destroyBlockProgress(-1, pos, (int) (ap.curBlockDamageMP * 10)); player.level().destroyBlockProgress(-1, pos, (int) (ap.curBlockDamageMP * 10));
} }
player.resetLastActionTime(); player.resetLastActionTime();
@@ -456,8 +456,8 @@ public class EntityPlayerActionPack
{ {
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack(); EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
if (ap.currentBlock == null) return; if (ap.currentBlock == null) return;
player.level.destroyBlockProgress(-1, ap.currentBlock, -1); player.level().destroyBlockProgress(-1, ap.currentBlock, -1);
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getLevel().getMaxBuildHeight(), -1); player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.level().getMaxBuildHeight(), -1);
ap.currentBlock = null; ap.currentBlock = null;
} }
}, },
@@ -468,7 +468,7 @@ public class EntityPlayerActionPack
{ {
if (action.limit == 1) if (action.limit == 1)
{ {
if (player.isOnGround()) player.jumpFromGround(); // onGround if (player.onGround()) player.jumpFromGround(); // onGround
} }
else else
{ {
@@ -21,7 +21,7 @@ import net.minecraft.world.level.levelgen.feature.CoralFeature;
import net.minecraft.world.level.levelgen.feature.CoralMushroomFeature; import net.minecraft.world.level.levelgen.feature.CoralMushroomFeature;
import net.minecraft.world.level.levelgen.feature.CoralTreeFeature; import net.minecraft.world.level.levelgen.feature.CoralTreeFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MapColor;
/** /**
* Deduplicates logic for the different behaviors of the {@code renewableCoral} rule * Deduplicates logic for the different behaviors of the {@code renewableCoral} rule
@@ -56,7 +56,7 @@ public interface FertilizableCoral extends BonemealableBlock {
default -> new CoralMushroomFeature(NoneFeatureConfiguration.CODEC); default -> new CoralMushroomFeature(NoneFeatureConfiguration.CODEC);
}; };
MaterialColor color = blockUnder.getMapColor(worldIn, pos); MapColor color = blockUnder.getMapColor(worldIn, pos);
BlockState properBlock = blockUnder; BlockState properBlock = blockUnder;
HolderSet.Named<Block> coralBlocks = worldIn.registryAccess().registryOrThrow(Registries.BLOCK).getTag(BlockTags.CORAL_BLOCKS).orElseThrow(); HolderSet.Named<Block> coralBlocks = worldIn.registryAccess().registryOrThrow(Registries.BLOCK).getTag(BlockTags.CORAL_BLOCKS).orElseThrow();
for (Holder<Block> block: coralBlocks) for (Holder<Block> block: coralBlocks)
@@ -30,7 +30,8 @@ import net.minecraft.world.level.block.AbstractBannerBlock;
import net.minecraft.world.level.block.BeaconBeamBlock; import net.minecraft.world.level.block.BeaconBeamBlock;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MapColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@@ -100,7 +101,7 @@ public class HopperCounter
{ {
startTick = -1; startTick = -1;
this.color = color; this.color = color;
this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMaterialColor(),"w ") + color.getName(); this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMapColor(),"w ") + color.getName();
} }
/** /**
@@ -229,7 +230,7 @@ public class HopperCounter
*/ */
public static int appropriateColor(int color) public static int appropriateColor(int color)
{ {
if (color == 0) return MaterialColor.SNOW.col; if (color == 0) return MapColor.SNOW.col;
int r = (color >> 16 & 255); int r = (color >> 16 & 255);
int g = (color >> 8 & 255); int g = (color >> 8 & 255);
int b = (color & 255); int b = (color & 255);
@@ -241,7 +242,7 @@ public class HopperCounter
/** /**
* Maps items that don't get a good block to reference for colour, or those that colour is wrong to a number of blocks, so we can get their colours easily with the * Maps items that don't get a good block to reference for colour, or those that colour is wrong to a number of blocks, so we can get their colours easily with the
* {@link Block#defaultMaterialColor()} method as these items have those same colours. * {@link Block#defaultMapColor()} method as these items have those same colours.
*/ */
private static final Map<Item, Block> DEFAULTS = Map.ofEntries( private static final Map<Item, Block> DEFAULTS = Map.ofEntries(
entry(Items.DANDELION, Blocks.YELLOW_WOOL), entry(Items.DANDELION, Blocks.YELLOW_WOOL),
@@ -334,8 +335,8 @@ public class HopperCounter
*/ */
public static TextColor fromItem(Item item, RegistryAccess registryAccess) public static TextColor fromItem(Item item, RegistryAccess registryAccess)
{ {
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMaterialColor().col)); if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMapColor().col));
if (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMaterialColor().col)); if (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMapColor().col));
Block block = null; Block block = null;
final Registry<Item> itemRegistry = registryAccess.registryOrThrow(Registries.ITEM); final Registry<Item> itemRegistry = registryAccess.registryOrThrow(Registries.ITEM);
final Registry<Block> blockRegistry = registryAccess.registryOrThrow(Registries.BLOCK); final Registry<Block> blockRegistry = registryAccess.registryOrThrow(Registries.BLOCK);
@@ -350,9 +351,9 @@ public class HopperCounter
} }
if (block != null) if (block != null)
{ {
if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMaterialColor().col)); if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMapColor().col));
if (block instanceof BeaconBeamBlock) return TextColor.fromRgb(appropriateColor( ((BeaconBeamBlock) block).getColor().getMaterialColor().col)); if (block instanceof BeaconBeamBlock) return TextColor.fromRgb(appropriateColor( ((BeaconBeamBlock) block).getColor().getMapColor().col));
return TextColor.fromRgb(appropriateColor( block.defaultMaterialColor().col)); return TextColor.fromRgb(appropriateColor( block.defaultMapColor().col));
} }
return null; return null;
} }
@@ -12,11 +12,11 @@ public class ParticleDisplay
{ {
public static void drawParticleLine(ServerPlayer player, Vec3 from, Vec3 to, String main, String accent, int count, double spread) public static void drawParticleLine(ServerPlayer player, Vec3 from, Vec3 to, String main, String accent, int count, double spread)
{ {
HolderLookup<ParticleType<?>> lookup = player.getLevel().holderLookup(Registries.PARTICLE_TYPE); HolderLookup<ParticleType<?>> lookup = player.level().holderLookup(Registries.PARTICLE_TYPE);
ParticleOptions accentParticle = ParticleParser.getEffect(accent, lookup); ParticleOptions accentParticle = ParticleParser.getEffect(accent, lookup);
ParticleOptions mainParticle = ParticleParser.getEffect(main, lookup); ParticleOptions mainParticle = ParticleParser.getEffect(main, lookup);
if (accentParticle != null) player.getLevel().sendParticles( if (accentParticle != null) player.serverLevel().sendParticles(
player, player,
accentParticle, accentParticle,
true, true,
@@ -29,9 +29,9 @@ public class ParticleDisplay
Vec3 incvec = to.subtract(from).normalize();// multiply(50/sqrt(lineLengthSq)); Vec3 incvec = to.subtract(from).normalize();// multiply(50/sqrt(lineLengthSq));
for (Vec3 delta = new Vec3(0.0,0.0,0.0); for (Vec3 delta = new Vec3(0.0,0.0,0.0);
delta.lengthSqr() < lineLengthSq; delta.lengthSqr() < lineLengthSq;
delta = delta.add(incvec.scale(player.level.random.nextFloat()))) delta = delta.add(incvec.scale(player.level().random.nextFloat())))
{ {
player.getLevel().sendParticles( player.serverLevel().sendParticles(
player, player,
mainParticle, mainParticle,
true, true,
@@ -89,7 +89,7 @@ public class HUDController
case "overworld" -> Level.OVERWORLD; case "overworld" -> Level.OVERWORLD;
case "nether" -> Level.NETHER; case "nether" -> Level.NETHER;
case "end" -> Level.END; case "end" -> Level.END;
default -> player.level.dimension(); default -> player.level().dimension();
}; };
return new Component[]{SpawnReporter.printMobcapsForDimension(server.getLevel(dim), false).get(0)}; return new Component[]{SpawnReporter.printMobcapsForDimension(server.getLevel(dim), false).get(0)};
}); });
@@ -29,7 +29,7 @@ public abstract class ArmorStand_scarpetMarkerMixin extends LivingEntity
@Inject(method = "readAdditionalSaveData", at = @At("HEAD")) @Inject(method = "readAdditionalSaveData", at = @At("HEAD"))
private void checkScarpetMarkerUnloaded(CallbackInfo ci) private void checkScarpetMarkerUnloaded(CallbackInfo ci)
{ {
if (!level.isClientSide) if (!level().isClientSide)
{ {
if (getTags().contains(Auxiliary.MARKER_STRING)) if (getTags().contains(Auxiliary.MARKER_STRING))
{ {
@@ -12,7 +12,7 @@ import net.minecraft.world.level.chunk.DataLayer;
import net.minecraft.world.level.chunk.LightChunkGetter; import net.minecraft.world.level.chunk.LightChunkGetter;
import net.minecraft.world.level.lighting.BlockLightSectionStorage; import net.minecraft.world.level.lighting.BlockLightSectionStorage;
import net.minecraft.world.level.lighting.BlockLightSectionStorage.BlockDataLayerStorageMap; import net.minecraft.world.level.lighting.BlockLightSectionStorage.BlockDataLayerStorageMap;
import net.minecraft.world.level.lighting.LayerLightEngine; import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.lighting.LayerLightSectionStorage; import net.minecraft.world.level.lighting.LayerLightSectionStorage;
@Mixin(BlockLightSectionStorage.class) @Mixin(BlockLightSectionStorage.class)
@@ -24,7 +24,7 @@ public abstract class BlockLightSectionStorage_scarpetChunkCreationMixin extends
} }
@Override @Override
public void processRelight(final LayerLightEngine<?, ?> lightProvider, final long cPos) public void processRelight(final LightEngine<?, ?> lightProvider, final long cPos)
{ {
final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider; final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider;
@@ -62,4 +62,10 @@ public abstract class BlockLightSectionStorage_scarpetChunkCreationMixin extends
} }
} }
} }
@Override
public int getLightLevelByLong(long blockPos)
{
return getLightValue(blockPos);
}
} }
@@ -31,7 +31,7 @@ public abstract class ExperienceOrb_xpNoCooldownMixin extends Entity
@Inject(method = "playerTouch", at = @At("HEAD")) @Inject(method = "playerTouch", at = @At("HEAD"))
private void addXP(Player player, CallbackInfo ci) { private void addXP(Player player, CallbackInfo ci) {
if (CarpetSettings.xpNoCooldown && !level.isClientSide) { if (CarpetSettings.xpNoCooldown && !level().isClientSide) {
player.takeXpDelay = 0; player.takeXpDelay = 0;
// reducing the count to 1 and leaving vanilla to deal with it // reducing the count to 1 and leaving vanilla to deal with it
while (this.count > 1) { while (this.count > 1) {
@@ -24,11 +24,11 @@ public abstract class Guardian_renewableSpongesMixin extends Monster
@Override @Override
public void thunderHit(ServerLevel serverWorld, LightningBolt lightningEntity) public void thunderHit(ServerLevel serverWorld, LightningBolt lightningEntity)
{ // isRemoved() { // isRemoved()
if (!this.level.isClientSide && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardian)) if (!this.level().isClientSide && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardian))
{ {
ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level); ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level());
elderGuardian.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); elderGuardian.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
elderGuardian.finalizeSpawn(serverWorld ,this.level.getCurrentDifficultyAt(elderGuardian.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData)null, (CompoundTag)null); elderGuardian.finalizeSpawn(serverWorld ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData)null, (CompoundTag)null);
elderGuardian.setNoAi(this.isNoAi()); elderGuardian.setNoAi(this.isNoAi());
if (this.hasCustomName()) if (this.hasCustomName())
@@ -37,7 +37,7 @@ public abstract class Guardian_renewableSpongesMixin extends Monster
elderGuardian.setCustomNameVisible(this.isCustomNameVisible()); elderGuardian.setCustomNameVisible(this.isCustomNameVisible());
} }
this.level.addFreshEntity(elderGuardian); this.level().addFreshEntity(elderGuardian);
this.discard(); // discard remove(); this.discard(); // discard remove();
} }
else else
@@ -13,7 +13,7 @@ import static carpet.CarpetSettings.FungusGrowthMode.*;
@Mixin(HugeFungusFeature.class) @Mixin(HugeFungusFeature.class)
public class HugeFungusFeatureMixin { public class HugeFungusFeatureMixin {
@ModifyArgs(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/feature/HugeFungusFeature;placeStem(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/util/RandomSource;Lnet/minecraft/world/level/levelgen/feature/HugeFungusConfiguration;Lnet/minecraft/core/BlockPos;IZ)V")) @ModifyArgs(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/feature/HugeFungusFeature;placeStem(Lnet/minecraft/world/level/WorldGenLevel;Lnet/minecraft/util/RandomSource;Lnet/minecraft/world/level/levelgen/feature/HugeFungusConfiguration;Lnet/minecraft/core/BlockPos;IZ)V"))
private void mixin(Args args) { private void mixin(Args args) {
boolean natural = !((HugeFungusConfiguration) args.get(2)).planted; boolean natural = !((HugeFungusConfiguration) args.get(2)).planted;
args.set(5, natural && ((boolean) args.get(5)) || args.set(5, natural && ((boolean) args.get(5)) ||
@@ -1,23 +1,25 @@
package carpet.mixins; package carpet.mixins;
import carpet.fakes.LightStorageInterface;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Invoker;
import carpet.fakes.ChunkLightProviderInterface; import carpet.fakes.ChunkLightProviderInterface;
import carpet.fakes.Lighting_scarpetChunkCreationInterface; import carpet.fakes.Lighting_scarpetChunkCreationInterface;
import net.minecraft.world.level.chunk.DataLayer; import net.minecraft.world.level.chunk.DataLayer;
import net.minecraft.world.level.lighting.LayerLightEngine; import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.lighting.LayerLightSectionStorage; import net.minecraft.world.level.lighting.LayerLightSectionStorage;
@Mixin(LayerLightEngine.class) @Mixin(LightEngine.class)
public abstract class LayerLightEngine_scarpetChunkCreationMixin implements Lighting_scarpetChunkCreationInterface, ChunkLightProviderInterface public abstract class LayerLightEngine_scarpetChunkCreationMixin implements Lighting_scarpetChunkCreationInterface, ChunkLightProviderInterface
{ {
@Shadow @Shadow
@Final @Final
protected LayerLightSectionStorage<?> storage; protected LayerLightSectionStorage<?> storage;
@Shadow protected abstract void clearQueuedSectionBlocks(final long l);
@Override @Override
public void removeLightData(final long pos) public void removeLightData(final long pos)
{ {
@@ -31,6 +33,13 @@ public abstract class LayerLightEngine_scarpetChunkCreationMixin implements Ligh
} }
@Override @Override
@Invoker("getLevel") public int callGetCurrentLevelFromSection(DataLayer array, long blockPos) {
public abstract int callGetCurrentLevelFromSection(DataLayer array, long blockPos); return ((LightStorageInterface)storage).getLightLevelByLong(blockPos);
};
@Override
public void clearQueuedSectionBlocksPublicAccess(long sectionPos)
{
clearQueuedSectionBlocks(sectionPos);
}
} }
@@ -1,10 +1,12 @@
package carpet.mixins; package carpet.mixins;
import java.util.Arrays; import java.util.Arrays;
import carpet.fakes.Lighting_scarpetChunkCreationInterface;
import net.minecraft.core.SectionPos; import net.minecraft.core.SectionPos;
import net.minecraft.world.level.chunk.DataLayer; import net.minecraft.world.level.chunk.DataLayer;
import net.minecraft.world.level.lighting.DataLayerStorageMap; import net.minecraft.world.level.lighting.DataLayerStorageMap;
import net.minecraft.world.level.lighting.LayerLightEngine; import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.lighting.LayerLightSectionStorage; import net.minecraft.world.level.lighting.LayerLightSectionStorage;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -25,8 +27,8 @@ public abstract class LayerLightSectionStorage_scarpetChunkCreationMixin impleme
@Shadow @Shadow
protected abstract DataLayer getDataLayer(final long sectionPos, final boolean cached); protected abstract DataLayer getDataLayer(final long sectionPos, final boolean cached);
@Shadow //@Shadow
protected abstract void clearQueuedSectionBlocks(final LayerLightEngine<?, ?> storage, final long blockChunkPos); //protected abstract void clearQueuedSectionBlocks(final LightEngine<?, ?> storage, final long blockChunkPos);
@Shadow @Shadow
@Final @Final
@@ -42,7 +44,7 @@ public abstract class LayerLightSectionStorage_scarpetChunkCreationMixin impleme
@Final @Final
protected Long2ObjectMap<DataLayer> queuedSections; protected Long2ObjectMap<DataLayer> queuedSections;
@Shadow protected abstract void enableLightSources(final long l, final boolean bl); //@Shadow protected abstract void enableLightSources(final long l, final boolean bl);
@Unique @Unique
private final LongSet removedChunks = new LongOpenHashSet(); private final LongSet removedChunks = new LongOpenHashSet();
@@ -63,10 +65,10 @@ public abstract class LayerLightSectionStorage_scarpetChunkCreationMixin impleme
} }
@Inject( @Inject(
method = "markNewInconsistencies(Lnet/minecraft/world/level/lighting/LayerLightEngine;ZZ)V", method = "markNewInconsistencies",
at = @At("HEAD") at = @At("HEAD")
) )
private void processData(final LayerLightEngine<?, ?> lightProvider, final boolean doSkylight, final boolean skipEdgeLightPropagation, final CallbackInfo ci) private void processData(final LightEngine<?, ?> lightProvider, final CallbackInfo ci)
{ {
// Process light removal // Process light removal
@@ -80,7 +82,7 @@ public abstract class LayerLightSectionStorage_scarpetChunkCreationMixin impleme
if (this.storingLightForSection(sectionPos)) if (this.storingLightForSection(sectionPos))
{ {
this.clearQueuedSectionBlocks(lightProvider, sectionPos); ((Lighting_scarpetChunkCreationInterface)lightProvider).clearQueuedSectionBlocksPublicAccess(sectionPos);
if (this.changedSections.add(sectionPos)) if (this.changedSections.add(sectionPos))
this.updatingSectionData.copyDataLayer(sectionPos); this.updatingSectionData.copyDataLayer(sectionPos);
@@ -108,7 +110,7 @@ public abstract class LayerLightSectionStorage_scarpetChunkCreationMixin impleme
} }
@Override @Override
public void processRelight(final LayerLightEngine<?, ?> lightProvider, final long pos) public void processRelight(final LightEngine<?, ?> lightProvider, final long pos)
{ {
} }
} }
@@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import carpet.fakes.Lighting_scarpetChunkCreationInterface; import carpet.fakes.Lighting_scarpetChunkCreationInterface;
import net.minecraft.world.level.lighting.LayerLightEngine; import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.lighting.LevelLightEngine;
@Mixin(LevelLightEngine.class) @Mixin(LevelLightEngine.class)
@@ -13,11 +13,11 @@ public abstract class LevelLightEngine_scarpetChunkCreationMixin implements Ligh
{ {
@Shadow @Shadow
@Final @Final
private LayerLightEngine<?, ?> blockEngine; private LightEngine<?, ?> blockEngine;
@Shadow @Shadow
@Final @Final
private LayerLightEngine<?, ?> skyEngine; private LightEngine<?, ?> skyEngine;
@Override @Override
public void removeLightData(final long pos) public void removeLightData(final long pos)
@@ -22,6 +22,6 @@ public abstract class LivingEntity_cleanLogsMixin extends Entity
@Redirect(method = "die", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;hasCustomName()Z")) @Redirect(method = "die", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;hasCustomName()Z"))
private boolean shouldLogDeaths(LivingEntity livingEntity) private boolean shouldLogDeaths(LivingEntity livingEntity)
{ {
return livingEntity.hasCustomName() && CarpetSettings.cleanLogs && level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); return livingEntity.hasCustomName() && CarpetSettings.cleanLogs && level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
} }
} }
@@ -30,7 +30,7 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity
if (CarpetSettings.creativeFlyDrag != 0.09 && (Object)this instanceof Player) if (CarpetSettings.creativeFlyDrag != 0.09 && (Object)this instanceof Player)
{ {
Player self = (Player)(Object)(this); Player self = (Player)(Object)(this);
if (self.getAbilities().flying && ! onGround ) if (self.getAbilities().flying && ! onGround() )
return (float)(1.0-CarpetSettings.creativeFlyDrag); return (float)(1.0-CarpetSettings.creativeFlyDrag);
} }
return original; return original;
@@ -43,7 +43,7 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity
if (CarpetSettings.creativeFlySpeed != 1.0D && (Object)this instanceof Player) if (CarpetSettings.creativeFlySpeed != 1.0D && (Object)this instanceof Player)
{ {
Player self = (Player)(Object)(this); Player self = (Player)(Object)(this);
if (self.getAbilities().flying && !onGround) if (self.getAbilities().flying && !onGround())
cir.setReturnValue( getFlyingSpeed() * (float)CarpetSettings.creativeFlySpeed); cir.setReturnValue( getFlyingSpeed() * (float)CarpetSettings.creativeFlySpeed);
} }
} }
@@ -37,8 +37,8 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
int maxEntityCramming =-1; int maxEntityCramming =-1;
if (CarpetSettings.maxEntityCollisions > 0) if (CarpetSettings.maxEntityCollisions > 0)
{ {
maxEntityCramming = this.level.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); maxEntityCramming = this.level().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
entities = ((LevelInterface) this.level).getOtherEntitiesLimited( entities = ((LevelInterface) this.level()).getOtherEntitiesLimited(
this, this,
this.getBoundingBox(), this.getBoundingBox(),
EntitySelector.pushableBy(this), EntitySelector.pushableBy(this),
@@ -46,11 +46,11 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
} }
else else
{ {
entities = this.level.getEntities(this, this.getBoundingBox(), EntitySelector.pushableBy(this)); entities = this.level().getEntities(this, this.getBoundingBox(), EntitySelector.pushableBy(this));
} }
if (!entities.isEmpty()) { if (!entities.isEmpty()) {
if (maxEntityCramming < 0) maxEntityCramming = this.level.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); if (maxEntityCramming < 0) maxEntityCramming = this.level().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
if (maxEntityCramming > 0 && entities.size() > maxEntityCramming - 1 && this.random.nextInt(4) == 0) { if (maxEntityCramming > 0 && entities.size() > maxEntityCramming - 1 && this.random.nextInt(4) == 0) {
int candidates = 0; int candidates = 0;
@@ -26,7 +26,7 @@ public abstract class MerchantResultSlot_scarpetEventMixin {
target = "Lnet/minecraft/world/item/trading/Merchant;notifyTrade(Lnet/minecraft/world/item/trading/MerchantOffer;)V") target = "Lnet/minecraft/world/item/trading/Merchant;notifyTrade(Lnet/minecraft/world/item/trading/MerchantOffer;)V")
) )
private void onTrade(Player player, ItemStack stack, CallbackInfo ci) { private void onTrade(Player player, ItemStack stack, CallbackInfo ci) {
if(PLAYER_TRADES.isNeeded() && !player.level.isClientSide()) if(PLAYER_TRADES.isNeeded() && !player.level().isClientSide())
{ {
PLAYER_TRADES.onTrade((ServerPlayer) player, merchant, slots.getActiveOffer()); PLAYER_TRADES.onTrade((ServerPlayer) player, merchant, slots.getActiveOffer());
} }
@@ -51,7 +51,7 @@ public abstract class Player_parrotMixin extends LivingEntity
private void onTickMovement(CallbackInfo ci) private void onTickMovement(CallbackInfo ci)
{ {
boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable; boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable;
if (!this.level.isClientSide && ((parrots_will_drop && this.fallDistance > 0.5F) || this.isInWater() || this.abilities.flying || isSleeping())) if (!this.level().isClientSide && ((parrots_will_drop && this.fallDistance > 0.5F) || this.isInWater() || this.abilities.flying || isSleeping()))
{ {
this.removeEntitiesOnShoulder(); this.removeEntitiesOnShoulder();
} }
@@ -57,7 +57,7 @@ public abstract class Player_scarpetEventsMixin extends LivingEntity
@Inject(method = "touch", at = @At("HEAD")) @Inject(method = "touch", at = @At("HEAD"))
private void onEntityCollision(Entity entity, CallbackInfo ci) private void onEntityCollision(Entity entity, CallbackInfo ci)
{ {
if (PLAYER_COLLIDES_WITH_ENTITY.isNeeded() && !level.isClientSide) if (PLAYER_COLLIDES_WITH_ENTITY.isNeeded() && !level().isClientSide)
{ {
PLAYER_COLLIDES_WITH_ENTITY.onEntityHandAction((ServerPlayer)(Object)this, entity, null); PLAYER_COLLIDES_WITH_ENTITY.onEntityHandAction((ServerPlayer)(Object)this, entity, null);
} }
@@ -66,7 +66,7 @@ public abstract class Player_scarpetEventsMixin extends LivingEntity
@Inject(method = "interactOn", cancellable = true, at = @At("HEAD")) @Inject(method = "interactOn", cancellable = true, at = @At("HEAD"))
private void doInteract(Entity entity, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir) private void doInteract(Entity entity, InteractionHand hand, CallbackInfoReturnable<InteractionResult> cir)
{ {
if (!level.isClientSide && PLAYER_INTERACTS_WITH_ENTITY.isNeeded()) if (!level().isClientSide && PLAYER_INTERACTS_WITH_ENTITY.isNeeded())
{ {
if(PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction((ServerPlayer) (Object)this, entity, hand)) { if(PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction((ServerPlayer) (Object)this, entity, hand)) {
cir.setReturnValue(InteractionResult.PASS); cir.setReturnValue(InteractionResult.PASS);
@@ -78,7 +78,7 @@ public abstract class Player_scarpetEventsMixin extends LivingEntity
@Inject(method = "attack", at = @At("HEAD"), cancellable = true) @Inject(method = "attack", at = @At("HEAD"), cancellable = true)
private void onAttack(Entity target, CallbackInfo ci) private void onAttack(Entity target, CallbackInfo ci)
{ {
if (!level.isClientSide && PLAYER_ATTACKS_ENTITY.isNeeded() && target.isAttackable()) if (!level().isClientSide && PLAYER_ATTACKS_ENTITY.isNeeded() && target.isAttackable())
{ {
if(PLAYER_ATTACKS_ENTITY.onEntityHandAction((ServerPlayer) (Object)this, target, null)) { if(PLAYER_ATTACKS_ENTITY.onEntityHandAction((ServerPlayer) (Object)this, target, null)) {
ci.cancel(); ci.cancel();
@@ -72,11 +72,11 @@ public abstract class PrimedTntMixin extends Entity implements TntEntityInterfac
private void onExplode(CallbackInfo ci) private void onExplode(CallbackInfo ci)
{ {
if (LoggerRegistry.__tnt && logHelper != null) if (LoggerRegistry.__tnt && logHelper != null)
logHelper.onExploded(getX(), getY(), getZ(), this.level.getGameTime()); logHelper.onExploded(getX(), getY(), getZ(), this.level().getGameTime());
if (mergedTNT > 1) if (mergedTNT > 1)
for (int i = 0; i < mergedTNT - 1; i++) for (int i = 0; i < mergedTNT - 1; i++)
this.level.explode(this, this.getX(), this.getY() + (double)(this.getBbHeight() / 16.0F), this.level().explode(this, this.getX(), this.getY() + (double)(this.getBbHeight() / 16.0F),
this.getZ(), this.getZ(),
4.0F, 4.0F,
Level.ExplosionInteraction.TNT); Level.ExplosionInteraction.TNT);
@@ -90,9 +90,9 @@ public abstract class PrimedTntMixin extends Entity implements TntEntityInterfac
// Merge code for combining tnt into a single entity if they happen to exist in the same spot, same fuse, no motion CARPET-XCOM // Merge code for combining tnt into a single entity if they happen to exist in the same spot, same fuse, no motion CARPET-XCOM
if(CarpetSettings.mergeTNT){ if(CarpetSettings.mergeTNT){
Vec3 velocity = getDeltaMovement(); Vec3 velocity = getDeltaMovement();
if(!level.isClientSide && mergeBool && velocity.x == 0 && velocity.y == 0 && velocity.z == 0){ if(!level().isClientSide && mergeBool && velocity.x == 0 && velocity.y == 0 && velocity.z == 0){
mergeBool = false; mergeBool = false;
for(Entity entity : level.getEntities(this, this.getBoundingBox())){ for(Entity entity : level().getEntities(this, this.getBoundingBox())){
if(entity instanceof PrimedTnt && !entity.isRemoved()){ if(entity instanceof PrimedTnt && !entity.isRemoved()){
PrimedTnt entityTNTPrimed = (PrimedTnt)entity; PrimedTnt entityTNTPrimed = (PrimedTnt)entity;
Vec3 tntVelocity = entityTNTPrimed.getDeltaMovement(); Vec3 tntVelocity = entityTNTPrimed.getDeltaMovement();
@@ -113,7 +113,7 @@ public abstract class PrimedTntMixin extends Entity implements TntEntityInterfac
{ {
// Merge code, merge only tnt that have had a chance to move CARPET-XCOM // Merge code, merge only tnt that have had a chance to move CARPET-XCOM
Vec3 velocity = getDeltaMovement(); Vec3 velocity = getDeltaMovement();
if(!level.isClientSide && (velocity.y != 0 || velocity.x != 0 || velocity.z != 0)){ if(!level().isClientSide && (velocity.y != 0 || velocity.x != 0 || velocity.z != 0)){
mergeBool = true; mergeBool = true;
} }
} }
@@ -28,7 +28,7 @@ public class ServerGamePacketListenerImplMixin
// We should force onto the main thread here // We should force onto the main thread here
// ServerNetworkHandler.handleData can possibly mutate data that isn't // ServerNetworkHandler.handleData can possibly mutate data that isn't
// thread safe, and also allows for client commands to be executed // thread safe, and also allows for client commands to be executed
PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListener) this, player.getLevel()); PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListener) this, player.serverLevel());
ServerNetworkHandler.handleData(packet.getData(), player); ServerNetworkHandler.handleData(packet.getData(), player);
ci.cancel(); ci.cancel();
} }
@@ -100,7 +100,7 @@ public abstract class ServerPlayer_scarpetEventMixin extends Player implements S
private void logPreviousCoordinates(ServerLevel serverWorld, CallbackInfoReturnable<Entity> cir) private void logPreviousCoordinates(ServerLevel serverWorld, CallbackInfoReturnable<Entity> cir)
{ {
previousLocation = position(); previousLocation = position();
previousDimension = level.dimension(); //dimension type previousDimension = level().dimension(); //dimension type
} }
@Inject(method = "changeDimension", at = @At("RETURN")) @Inject(method = "changeDimension", at = @At("RETURN"))
@@ -14,7 +14,7 @@ import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.chunk.DataLayer; import net.minecraft.world.level.chunk.DataLayer;
import net.minecraft.world.level.chunk.LightChunkGetter; import net.minecraft.world.level.chunk.LightChunkGetter;
import net.minecraft.world.level.lighting.BlockLightSectionStorage.BlockDataLayerStorageMap; import net.minecraft.world.level.lighting.BlockLightSectionStorage.BlockDataLayerStorageMap;
import net.minecraft.world.level.lighting.LayerLightEngine; import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.lighting.LayerLightSectionStorage; import net.minecraft.world.level.lighting.LayerLightSectionStorage;
import net.minecraft.world.level.lighting.SkyLightSectionStorage; import net.minecraft.world.level.lighting.SkyLightSectionStorage;
@@ -26,7 +26,7 @@ public abstract class SkyLightSectionStorage_scarpetChunkCreationMixin extends L
super(lightType, chunkProvider, lightData); super(lightType, chunkProvider, lightData);
} }
@Shadow /*@Shadow
@Final @Final
private LongSet sectionsToAddSourcesTo; private LongSet sectionsToAddSourcesTo;
@@ -37,10 +37,11 @@ public abstract class SkyLightSectionStorage_scarpetChunkCreationMixin extends L
@Shadow @Shadow
@Final @Final
private LongSet sectionsWithSources; private LongSet sectionsWithSources;
*/
@Shadow protected abstract boolean isAboveData(final long pos); @Shadow protected abstract boolean isAboveData(final long pos);
@Shadow protected abstract boolean lightOnInSection(final long sectionPos); //@Shadow protected abstract boolean lightOnInSection(final long sectionPos);
@Override @Override
public void processRemoveLightData(final long cPos) public void processRemoveLightData(final long cPos)
@@ -48,16 +49,18 @@ public abstract class SkyLightSectionStorage_scarpetChunkCreationMixin extends L
for (int y = -1; y < 17; ++y) for (int y = -1; y < 17; ++y)
{ {
final long sectionPos = SectionPos.asLong(SectionPos.x(cPos), y, SectionPos.z(cPos)); final long sectionPos = SectionPos.asLong(SectionPos.x(cPos), y, SectionPos.z(cPos));
/* do something with this later
this.sectionsToAddSourcesTo.remove(sectionPos); this.sectionsToAddSourcesTo.remove(sectionPos);
this.sectionsToRemoveSourcesFrom.remove(sectionPos); this.sectionsToRemoveSourcesFrom.remove(sectionPos);
this.sectionsWithSources.remove(sectionPos); this.sectionsWithSources.remove(sectionPos);
*/
} }
} }
@Override @Override
public void processRelight(final LayerLightEngine<?, ?> lightProvider, final long cPos) public void processRelight(final LightEngine<?, ?> lightProvider, final long cPos)
{ {
final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider; final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider;
@@ -114,4 +117,10 @@ public abstract class SkyLightSectionStorage_scarpetChunkCreationMixin extends L
} }
} }
} }
@Override
public int getLightLevelByLong(long blockPos)
{
return getLightValue(blockPos);
}
} }
@@ -35,6 +35,8 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends
@Final @Final
private ChunkMap chunkMap; private ChunkMap chunkMap;
//@Shadow public abstract void propagateLightSources(final ChunkPos chunkPos);
@Override @Override
@Invoker("updateChunkStatus") @Invoker("updateChunkStatus")
public abstract void invokeUpdateChunkStatus(ChunkPos pos); public abstract void invokeUpdateChunkStatus(ChunkPos pos);
@@ -46,7 +48,7 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends
chunk.setLightCorrect(false); chunk.setLightCorrect(false);
this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> {
super.enableLightSources(pos, false); super.setLightEnabled(pos, false);
((Lighting_scarpetChunkCreationInterface) this).removeLightData(SectionPos.getZeroNode(SectionPos.asLong(pos.x, 0, pos.z))); ((Lighting_scarpetChunkCreationInterface) this).removeLightData(SectionPos.getZeroNode(SectionPos.asLong(pos.x, 0, pos.z)));
}, },
() -> "Remove light data " + pos () -> "Remove light data " + pos
@@ -58,8 +60,14 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends
{ {
final ChunkPos pos = chunk.getPos(); final ChunkPos pos = chunk.getPos();
this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> { propagateLightSources(pos);
super.enableLightSources(pos, true); /*this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> {
super.setLightEnabled(pos, true);
chunk.findBlockLightSources((lightPos, state) -> {
final int lightEmission = state.getLightEmission();
enqueueIncrease(lightPos.asLong(), LightEngine.QueueEntry.increaseLightFromEmission(lightEmission, isEmptyShape(state)));
});
chunk.getLights().forEach( chunk.getLights().forEach(
blockPos -> super.onBlockEmissionIncrease(blockPos, chunk.getLightEmission(blockPos)) blockPos -> super.onBlockEmissionIncrease(blockPos, chunk.getLightEmission(blockPos))
@@ -68,7 +76,7 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends
((Lighting_scarpetChunkCreationInterface) this).relight(SectionPos.getZeroNode(SectionPos.asLong(pos.x, 0, pos.z))); ((Lighting_scarpetChunkCreationInterface) this).relight(SectionPos.getZeroNode(SectionPos.asLong(pos.x, 0, pos.z)));
}, },
() -> "Relight chunk " + pos () -> "Relight chunk " + pos
)); ));*/
return CompletableFuture.runAsync( return CompletableFuture.runAsync(
Util.name(() -> { Util.name(() -> {
@@ -16,7 +16,11 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(ThreadedLevelLightEngine.class) @Mixin(ThreadedLevelLightEngine.class)
public abstract class ThreadedLevelLightEngine_scarpetMixin extends LevelLightEngine implements ServerLightingProviderInterface public abstract class ThreadedLevelLightEngine_scarpetMixin extends LevelLightEngine implements ServerLightingProviderInterface
{ {
@Shadow public abstract void checkBlock(BlockPos pos); //@Shadow public abstract void checkBlock(BlockPos pos);
//@Shadow public abstract void setLightEnabled(final ChunkPos chunkPos, final boolean bl);
//@Shadow public abstract void propagateLightSources(final ChunkPos chunkPos);
public ThreadedLevelLightEngine_scarpetMixin(LightChunkGetter chunkProvider, boolean hasBlockLight, boolean hasSkyLight) public ThreadedLevelLightEngine_scarpetMixin(LightChunkGetter chunkProvider, boolean hasBlockLight, boolean hasSkyLight)
{ {
@@ -34,18 +38,19 @@ public abstract class ThreadedLevelLightEngine_scarpetMixin extends LevelLightEn
//ChunkPos pos = new ChunkPos(x, z); //ChunkPos pos = new ChunkPos(x, z);
int j; int j;
for(j = -1; j < 17; ++j) { // skip some recomp for(j = -1; j < 17; ++j) { // skip some recomp
super.queueSectionData(LightLayer.BLOCK, SectionPos.of(pos, j), new DataLayer(), false); super.queueSectionData(LightLayer.BLOCK, SectionPos.of(pos, j), new DataLayer());
super.queueSectionData(LightLayer.SKY, SectionPos.of(pos, j), new DataLayer(), false); super.queueSectionData(LightLayer.SKY, SectionPos.of(pos, j), new DataLayer());
} }
for(j = 0; j < 16; ++j) { for(j = 0; j < 16; ++j) {
super.updateSectionStatus(SectionPos.of(pos, j), true); super.updateSectionStatus(SectionPos.of(pos, j), true);
} }
super.enableLightSources(pos, true); setLightEnabled(pos, true);
chunk.getLights().forEach((blockPos) -> { propagateLightSources(pos);
super.onBlockEmissionIncrease(blockPos, chunk.getLightEmission(blockPos)); // chunk.getLights().forEach((blockPos) -> {
}); // super.onBlockEmissionIncrease(blockPos, chunk.getLightEmission(blockPos));
// });
} }
@@ -79,7 +79,7 @@ public abstract class Villager_aiMixin extends AbstractVillager
//boolean work = false; //boolean work = false;
boolean sleep = false; boolean sleep = false;
boolean panic = this.brain.isActive(Activity.PANIC); boolean panic = this.brain.isActive(Activity.PANIC);
long currentTime = this.level.getGameTime(); long currentTime = this.level().getGameTime();
if (optional_11.isPresent()) { if (optional_11.isPresent()) {
sleep = (currentTime - optional_11.get()) < 24000L; sleep = (currentTime - optional_11.get()) < 24000L;
} }
@@ -123,7 +123,7 @@ public abstract class Villager_aiMixin extends AbstractVillager
if (itemStack_1.getItem() == Items.EMERALD) if (itemStack_1.getItem() == Items.EMERALD)
{ {
GlobalPos bedPos = this.brain.getMemory(MemoryModuleType.HOME).orElse(null); GlobalPos bedPos = this.brain.getMemory(MemoryModuleType.HOME).orElse(null);
if (bedPos == null || bedPos.dimension() != level.dimension()) // get Dimension if (bedPos == null || bedPos.dimension() != level().dimension()) // get Dimension
{ {
setUnhappy(); setUnhappy();
((ServerLevel) getCommandSenderWorld()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState()), getX(), getY() + getEyeHeight() + 1, getZ(), 1, 0.1, 0.1, 0.1, 0.0); ((ServerLevel) getCommandSenderWorld()).sendParticles(new BlockParticleOption(ParticleTypes.BLOCK_MARKER, Blocks.BARRIER.defaultBlockState()), getX(), getY() + getEyeHeight() + 1, getZ(), 1, 0.1, 0.1, 0.1, 0.0);
@@ -85,7 +85,7 @@ public class EntityPlayerMPFake extends ServerPlayer
{ {
player.getServer().getPlayerList().remove(player); player.getServer().getPlayerList().remove(player);
player.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login")); player.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"));
ServerLevel worldIn = player.getLevel();//.getWorld(player.dimension); ServerLevel worldIn = player.serverLevel();//.getWorld(player.dimension);
GameProfile gameprofile = player.getGameProfile(); GameProfile gameprofile = player.getGameProfile();
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, true); EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, true);
playerShadow.setChatSession(player.getChatSession()); playerShadow.setChatSession(player.getChatSession());
@@ -99,7 +99,7 @@ public class EntityPlayerMPFake extends ServerPlayer
playerShadow.entityData.set(DATA_PLAYER_MODE_CUSTOMISATION, player.getEntityData().get(DATA_PLAYER_MODE_CUSTOMISATION)); playerShadow.entityData.set(DATA_PLAYER_MODE_CUSTOMISATION, player.getEntityData().get(DATA_PLAYER_MODE_CUSTOMISATION));
server.getPlayerList().broadcastAll(new ClientboundRotateHeadPacket(playerShadow, (byte) (player.yHeadRot * 256 / 360)), playerShadow.level.dimension()); server.getPlayerList().broadcastAll(new ClientboundRotateHeadPacket(playerShadow, (byte) (player.yHeadRot * 256 / 360)), playerShadow.level().dimension());
server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, playerShadow)); server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, playerShadow));
//player.world.getChunkManager().updatePosition(playerShadow); //player.world.getChunkManager().updatePosition(playerShadow);
playerShadow.getAbilities().flying = player.getAbilities().flying; playerShadow.getAbilities().flying = player.getAbilities().flying;
@@ -143,7 +143,7 @@ public class EntityPlayerMPFake extends ServerPlayer
if (this.getServer().getTickCount() % 10 == 0) if (this.getServer().getTickCount() % 10 == 0)
{ {
this.connection.resetPosition(); this.connection.resetPosition();
this.getLevel().getChunkSource().move(this); this.serverLevel().getChunkSource().move(this);
} }
try try
{ {
@@ -591,7 +591,7 @@ public class CarpetEventServer
return handler.call(() -> return handler.call(() ->
Arrays.asList( Arrays.asList(
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.getLevel().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand") StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand")
), player::createCommandSourceStack); ), player::createCommandSourceStack);
} }
@@ -604,7 +604,7 @@ public class CarpetEventServer
return handler.call(() -> return handler.call(() ->
Arrays.asList( Arrays.asList(
new EntityValue(player), new EntityValue(player),
new BlockValue(null, player.getLevel(), blockpos), new BlockValue(null, player.serverLevel(), blockpos),
StringValue.of(facing.getName()) StringValue.of(facing.getName())
), player::createCommandSourceStack); ), player::createCommandSourceStack);
} }
@@ -622,9 +622,9 @@ public class CarpetEventServer
Vec3 vec3d = hitRes.getLocation().subtract(blockpos.getX(), blockpos.getY(), blockpos.getZ()); Vec3 vec3d = hitRes.getLocation().subtract(blockpos.getX(), blockpos.getY(), blockpos.getZ());
return Arrays.asList( return Arrays.asList(
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.getLevel().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"), StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"),
new BlockValue(null, player.getLevel(), blockpos), new BlockValue(null, player.serverLevel(), blockpos),
StringValue.of(enumfacing.getName()), StringValue.of(enumfacing.getName()),
ListValue.of( ListValue.of(
new NumericValue(vec3d.x), new NumericValue(vec3d.x),
@@ -648,7 +648,7 @@ public class CarpetEventServer
return Arrays.asList( return Arrays.asList(
new EntityValue(player), new EntityValue(player),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"), StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"),
new BlockValue(null, player.getLevel(), blockpos), new BlockValue(null, player.serverLevel(), blockpos),
StringValue.of(enumfacing.getName()), StringValue.of(enumfacing.getName()),
ListValue.of( ListValue.of(
new NumericValue(vec3d.x), new NumericValue(vec3d.x),
@@ -667,9 +667,9 @@ public class CarpetEventServer
{ {
return handler.call(() -> Arrays.asList( return handler.call(() -> Arrays.asList(
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.getLevel().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"), StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"),
new BlockValue(null, player.getLevel(), pos) new BlockValue(null, player.serverLevel(), pos)
), player::createCommandSourceStack); ), player::createCommandSourceStack);
} }
}; };
@@ -680,9 +680,9 @@ public class CarpetEventServer
{ {
handler.call(() -> Arrays.asList( handler.call(() -> Arrays.asList(
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.getLevel().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"), StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand"),
new BlockValue(null, player.getLevel(), pos) new BlockValue(null, player.serverLevel(), pos)
), player::createCommandSourceStack); ), player::createCommandSourceStack);
return false; return false;
} }
@@ -693,7 +693,7 @@ public class CarpetEventServer
public boolean onBlockBroken(ServerPlayer player, BlockPos pos, BlockState previousBS) public boolean onBlockBroken(ServerPlayer player, BlockPos pos, BlockState previousBS)
{ {
return handler.call( return handler.call(
() -> Arrays.asList(new EntityValue(player), new BlockValue(previousBS, player.getLevel(), pos)), () -> Arrays.asList(new EntityValue(player), new BlockValue(previousBS, player.serverLevel(), pos)),
player::createCommandSourceStack player::createCommandSourceStack
); );
} }
@@ -713,7 +713,7 @@ public class CarpetEventServer
@Override @Override
public void onTrade(ServerPlayer player, Merchant merchant, MerchantOffer tradeOffer) public void onTrade(ServerPlayer player, Merchant merchant, MerchantOffer tradeOffer)
{ {
RegistryAccess regs = player.getLevel().registryAccess(); RegistryAccess regs = player.level().registryAccess();
handler.call(() -> Arrays.asList( handler.call(() -> Arrays.asList(
new EntityValue(player), new EntityValue(player),
merchant instanceof final AbstractVillager villager ? new EntityValue(villager) : Value.NULL, merchant instanceof final AbstractVillager villager ? new EntityValue(villager) : Value.NULL,
@@ -728,7 +728,7 @@ public class CarpetEventServer
@Override @Override
public boolean onItemAction(ServerPlayer player, InteractionHand enumhand, ItemStack itemstack) public boolean onItemAction(ServerPlayer player, InteractionHand enumhand, ItemStack itemstack)
{ {
handler.call(() -> Arrays.asList(new EntityValue(player), ValueConversions.of(itemstack, player.getLevel().registryAccess())), player::createCommandSourceStack); handler.call(() -> Arrays.asList(new EntityValue(player), ValueConversions.of(itemstack, player.level().registryAccess())), player::createCommandSourceStack);
return false; return false;
} }
}; };
@@ -787,7 +787,7 @@ public class CarpetEventServer
handler.call(() -> handler.call(() ->
Arrays.asList( Arrays.asList(
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.getLevel().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand") StringValue.of(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand")
), player::createCommandSourceStack); ), player::createCommandSourceStack);
return false; return false;
@@ -802,7 +802,7 @@ public class CarpetEventServer
return handler.call(() -> return handler.call(() ->
Arrays.asList( Arrays.asList(
new EntityValue(player), new EntityValue(player),
ValueConversions.of(itemstack, player.getLevel().registryAccess()), ValueConversions.of(itemstack, player.level().registryAccess()),
new StringValue(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand") new StringValue(enumhand == InteractionHand.MAIN_HAND ? "mainhand" : "offhand")
), player::createCommandSourceStack); ), player::createCommandSourceStack);
} }
@@ -999,7 +999,7 @@ public class CarpetEventServer
{ {
return; return;
} }
Registry<StatType<?>> registry = player.getLevel().registryAccess().registryOrThrow(Registries.STAT_TYPE); Registry<StatType<?>> registry = player.level().registryAccess().registryOrThrow(Registries.STAT_TYPE);
handler.call(() -> Arrays.asList( handler.call(() -> Arrays.asList(
new EntityValue(player), new EntityValue(player),
NBTSerializableValue.nameFromRegistryId(registry.getKey(stat.getType())), NBTSerializableValue.nameFromRegistryId(registry.getKey(stat.getType())),
@@ -1105,7 +1105,7 @@ public class CarpetEventServer
{ {
handler.call( handler.call(
() -> Collections.singletonList(new EntityValue(entity)), () -> Collections.singletonList(new EntityValue(entity)),
() -> entity.getServer().createCommandSourceStack().withLevel((ServerLevel) entity.level).withPermission(Vanilla.MinecraftServer_getRunPermissionLevel(entity.getServer())) () -> entity.getServer().createCommandSourceStack().withLevel((ServerLevel) entity.level()).withPermission(Vanilla.MinecraftServer_getRunPermissionLevel(entity.getServer()))
); );
} }
})).collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)); })).collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue));
@@ -1124,7 +1124,7 @@ public class CarpetEventServer
{ {
handler.call( handler.call(
() -> Arrays.asList(new EntityValue(entity), BooleanValue.of(created)), () -> Arrays.asList(new EntityValue(entity), BooleanValue.of(created)),
() -> entity.getServer().createCommandSourceStack().withLevel((ServerLevel) entity.level).withPermission(Vanilla.MinecraftServer_getRunPermissionLevel(entity.getServer())) () -> entity.getServer().createCommandSourceStack().withLevel((ServerLevel) entity.level()).withPermission(Vanilla.MinecraftServer_getRunPermissionLevel(entity.getServer()))
); );
} }
})) }))
@@ -1334,7 +1334,7 @@ public class CarpetEventServer
valArgs.add(EntityValue.of(player)); valArgs.add(EntityValue.of(player));
for (Object o : args) for (Object o : args)
{ {
valArgs.add(ValueConversions.guess(player.getLevel(), o)); valArgs.add(ValueConversions.guess(player.serverLevel(), o));
} }
return valArgs; return valArgs;
}, player::createCommandSourceStack }, player::createCommandSourceStack
@@ -437,7 +437,7 @@ public class Inventories
{ {
// stolen from LookTargetUtil.give((VillagerEntity)owner, droppedStack, (LivingEntity) owner); // stolen from LookTargetUtil.give((VillagerEntity)owner, droppedStack, (LivingEntity) owner);
double dropY = livingEntity.getY() - 0.30000001192092896D + livingEntity.getEyeHeight(); double dropY = livingEntity.getY() - 0.30000001192092896D + livingEntity.getEyeHeight();
item = new ItemEntity(livingEntity.level, livingEntity.getX(), dropY, livingEntity.getZ(), droppedStack); item = new ItemEntity(livingEntity.level(), livingEntity.getX(), dropY, livingEntity.getZ(), droppedStack);
Vec3 vec3d = livingEntity.getViewVector(1.0F).normalize().scale(0.3);// new Vec3d(0, 0.3, 0); Vec3 vec3d = livingEntity.getViewVector(1.0F).normalize().scale(0.3);// new Vec3d(0, 0.3, 0);
item.setDeltaMovement(vec3d); item.setDeltaMovement(vec3d);
item.setDefaultPickUpDelay(); item.setDefaultPickUpDelay();
+64 -64
View File
@@ -1,7 +1,7 @@
package carpet.script.utils; package carpet.script.utils;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MapColor;
import java.util.Map; import java.util.Map;
@@ -89,68 +89,68 @@ public class Colors
entry(SoundType.POLISHED_DEEPSLATE, "polished_deepslate") entry(SoundType.POLISHED_DEEPSLATE, "polished_deepslate")
); );
public static final Map<MaterialColor, String> mapColourName = Map.ofEntries( public static final Map<MapColor, String> mapColourName = Map.ofEntries(
entry(MaterialColor.NONE , "air" ), entry(MapColor.NONE , "air" ),
entry(MaterialColor.GRASS , "grass" ), entry(MapColor.GRASS , "grass" ),
entry(MaterialColor.SAND , "sand" ), entry(MapColor.SAND , "sand" ),
entry(MaterialColor.WOOL , "wool" ), entry(MapColor.WOOL , "wool" ),
entry(MaterialColor.FIRE , "tnt" ), entry(MapColor.FIRE , "tnt" ),
entry(MaterialColor.ICE , "ice" ), entry(MapColor.ICE , "ice" ),
entry(MaterialColor.METAL , "iron" ), entry(MapColor.METAL , "iron" ),
entry(MaterialColor.PLANT , "foliage" ), entry(MapColor.PLANT , "foliage" ),
entry(MaterialColor.SNOW , "snow" ), entry(MapColor.SNOW , "snow" ),
entry(MaterialColor.CLAY , "clay" ), entry(MapColor.CLAY , "clay" ),
entry(MaterialColor.DIRT , "dirt" ), entry(MapColor.DIRT , "dirt" ),
entry(MaterialColor.STONE , "stone" ), entry(MapColor.STONE , "stone" ),
entry(MaterialColor.WATER , "water" ), entry(MapColor.WATER , "water" ),
entry(MaterialColor.WOOD , "wood" ), entry(MapColor.WOOD , "wood" ),
entry(MaterialColor.QUARTZ , "quartz" ), entry(MapColor.QUARTZ , "quartz" ),
entry(MaterialColor.COLOR_ORANGE , "adobe" ), entry(MapColor.COLOR_ORANGE , "adobe" ),
entry(MaterialColor.COLOR_MAGENTA , "magenta" ), entry(MapColor.COLOR_MAGENTA , "magenta" ),
entry(MaterialColor.COLOR_LIGHT_BLUE, "light_blue"), entry(MapColor.COLOR_LIGHT_BLUE, "light_blue"),
entry(MaterialColor.COLOR_YELLOW , "yellow" ), entry(MapColor.COLOR_YELLOW , "yellow" ),
entry(MaterialColor.COLOR_LIGHT_GREEN , "lime" ), entry(MapColor.COLOR_LIGHT_GREEN , "lime" ),
entry(MaterialColor.COLOR_PINK , "pink" ), entry(MapColor.COLOR_PINK , "pink" ),
entry(MaterialColor.COLOR_GRAY , "gray" ), entry(MapColor.COLOR_GRAY , "gray" ),
entry(MaterialColor.COLOR_LIGHT_GRAY, "light_gray"), entry(MapColor.COLOR_LIGHT_GRAY, "light_gray"),
entry(MaterialColor.COLOR_CYAN , "cyan" ), entry(MapColor.COLOR_CYAN , "cyan" ),
entry(MaterialColor.COLOR_PURPLE , "purple" ), entry(MapColor.COLOR_PURPLE , "purple" ),
entry(MaterialColor.COLOR_BLUE , "blue" ), entry(MapColor.COLOR_BLUE , "blue" ),
entry(MaterialColor.COLOR_BROWN , "brown" ), entry(MapColor.COLOR_BROWN , "brown" ),
entry(MaterialColor.COLOR_GREEN , "green" ), entry(MapColor.COLOR_GREEN , "green" ),
entry(MaterialColor.COLOR_RED , "red" ), entry(MapColor.COLOR_RED , "red" ),
entry(MaterialColor.COLOR_BLACK , "black" ), entry(MapColor.COLOR_BLACK , "black" ),
entry(MaterialColor.GOLD , "gold" ), entry(MapColor.GOLD , "gold" ),
entry(MaterialColor.DIAMOND , "diamond" ), entry(MapColor.DIAMOND , "diamond" ),
entry(MaterialColor.LAPIS , "lapis" ), entry(MapColor.LAPIS , "lapis" ),
entry(MaterialColor.EMERALD , "emerald" ), entry(MapColor.EMERALD , "emerald" ),
entry(MaterialColor.PODZOL , "obsidian" ), entry(MapColor.PODZOL , "obsidian" ),
entry(MaterialColor.NETHER , "netherrack"), //TODO fix these entry(MapColor.NETHER , "netherrack"), //TODO fix these
entry(MaterialColor.TERRACOTTA_WHITE , "white_terracotta" ), entry(MapColor.TERRACOTTA_WHITE , "white_terracotta" ),
entry(MaterialColor.TERRACOTTA_ORANGE , "orange_terracotta" ), entry(MapColor.TERRACOTTA_ORANGE , "orange_terracotta" ),
entry(MaterialColor.TERRACOTTA_MAGENTA , "magenta_terracotta" ), entry(MapColor.TERRACOTTA_MAGENTA , "magenta_terracotta" ),
entry(MaterialColor.TERRACOTTA_LIGHT_BLUE, "light_blue_terracotta" ), entry(MapColor.TERRACOTTA_LIGHT_BLUE, "light_blue_terracotta" ),
entry(MaterialColor.TERRACOTTA_YELLOW , "yellow_terracotta" ), entry(MapColor.TERRACOTTA_YELLOW , "yellow_terracotta" ),
entry(MaterialColor.TERRACOTTA_LIGHT_GREEN , "lime_terracotta" ), entry(MapColor.TERRACOTTA_LIGHT_GREEN , "lime_terracotta" ),
entry(MaterialColor.TERRACOTTA_PINK , "pink_terracotta" ), entry(MapColor.TERRACOTTA_PINK , "pink_terracotta" ),
entry(MaterialColor.TERRACOTTA_GRAY , "gray_terracotta" ), entry(MapColor.TERRACOTTA_GRAY , "gray_terracotta" ),
entry(MaterialColor.TERRACOTTA_LIGHT_GRAY, "light_gray_terracotta" ), entry(MapColor.TERRACOTTA_LIGHT_GRAY, "light_gray_terracotta" ),
entry(MaterialColor.TERRACOTTA_CYAN , "cyan_terracotta" ), entry(MapColor.TERRACOTTA_CYAN , "cyan_terracotta" ),
entry(MaterialColor.TERRACOTTA_PURPLE , "purple_terracotta" ), entry(MapColor.TERRACOTTA_PURPLE , "purple_terracotta" ),
entry(MaterialColor.TERRACOTTA_BLUE , "blue_terracotta" ), entry(MapColor.TERRACOTTA_BLUE , "blue_terracotta" ),
entry(MaterialColor.TERRACOTTA_BROWN , "brown_terracotta" ), entry(MapColor.TERRACOTTA_BROWN , "brown_terracotta" ),
entry(MaterialColor.TERRACOTTA_GREEN , "green_terracotta" ), entry(MapColor.TERRACOTTA_GREEN , "green_terracotta" ),
entry(MaterialColor.TERRACOTTA_RED , "red_terracotta" ), entry(MapColor.TERRACOTTA_RED , "red_terracotta" ),
entry(MaterialColor.TERRACOTTA_BLACK , "black_terracotta" ), entry(MapColor.TERRACOTTA_BLACK , "black_terracotta" ),
entry(MaterialColor.CRIMSON_NYLIUM , "crimson_nylium" ), entry(MapColor.CRIMSON_NYLIUM , "crimson_nylium" ),
entry(MaterialColor.CRIMSON_STEM , "crimson_stem" ), entry(MapColor.CRIMSON_STEM , "crimson_stem" ),
entry(MaterialColor.CRIMSON_HYPHAE , "crimson_hyphae" ), entry(MapColor.CRIMSON_HYPHAE , "crimson_hyphae" ),
entry(MaterialColor.WARPED_NYLIUM , "warped_nylium" ), entry(MapColor.WARPED_NYLIUM , "warped_nylium" ),
entry(MaterialColor.WARPED_STEM , "warped_stem" ), entry(MapColor.WARPED_STEM , "warped_stem" ),
entry(MaterialColor.WARPED_HYPHAE , "warped_hyphae" ), entry(MapColor.WARPED_HYPHAE , "warped_hyphae" ),
entry(MaterialColor.WARPED_WART_BLOCK , "warped_wart" ), entry(MapColor.WARPED_WART_BLOCK , "warped_wart" ),
entry(MaterialColor.DEEPSLATE , "deepslate" ), entry(MapColor.DEEPSLATE , "deepslate" ),
entry(MaterialColor.RAW_IRON , "raw_iron" ), entry(MapColor.RAW_IRON , "raw_iron" ),
entry(MaterialColor.GLOW_LICHEN , "glow_lichen" ) entry(MapColor.GLOW_LICHEN , "glow_lichen" )
); );
} }
@@ -12,12 +12,12 @@ public class EntityTools
*/ */
public static void genericJump(Entity e) public static void genericJump(Entity e)
{ {
if (!e.isOnGround() && !e.isInWaterOrBubble() && !e.isInLava()) if (!e.onGround() && !e.isInWaterOrBubble() && !e.isInLava())
{ {
return; return;
} }
float m = e.level.getBlockState(e.blockPosition()).getBlock().getJumpFactor(); float m = e.level().getBlockState(e.blockPosition()).getBlock().getJumpFactor();
float g = e.level.getBlockState(BlockPos.containing(e.getX(), e.getBoundingBox().minY - 0.5000001D, e.getZ())).getBlock().getJumpFactor(); float g = e.level().getBlockState(BlockPos.containing(e.getX(), e.getBoundingBox().minY - 0.5000001D, e.getZ())).getBlock().getJumpFactor();
float jumpVelocityMultiplier = m == 1.0D ? g : m; float jumpVelocityMultiplier = m == 1.0D ? g : m;
float jumpStrength = (0.42F * jumpVelocityMultiplier); float jumpStrength = (0.42F * jumpVelocityMultiplier);
Vec3 vec3d = e.getDeltaMovement(); Vec3 vec3d = e.getDeltaMovement();
@@ -767,15 +767,15 @@ public class ShapeDispatcher
{ {
return; return;
} }
particle = getParticleData("block_marker " + blocks.getKey(Block.byItem(this.item.getItem())), p.level.registryAccess()); particle = getParticleData("block_marker " + blocks.getKey(Block.byItem(this.item.getItem())), p.level().registryAccess());
} }
else else
{ {
particle = getParticleData("block_marker " + blocks.getKey(this.blockState.getBlock()), p.level.registryAccess()); particle = getParticleData("block_marker " + blocks.getKey(this.blockState.getBlock()), p.level().registryAccess());
} }
Vec3 v = relativiseRender(p.level, this.pos, 0); Vec3 v = relativiseRender(p.level(), this.pos, 0);
p.getLevel().sendParticles(p, particle, true, v.x, v.y, v.z, 1, 0.0, 0.0, 0.0, 0.0); p.serverLevel().sendParticles(p, particle, true, v.x, v.y, v.z, 1, 0.0, 0.0, 0.0, 0.0);
}; };
} }
@@ -868,14 +868,14 @@ public class ShapeDispatcher
double density = Math.max(2.0, from.distanceTo(to) / 50 / (a + 0.1)); double density = Math.max(2.0, from.distanceTo(to) / 50 / (a + 0.1));
return p -> return p ->
{ {
if (p.level.dimension() == shapeDimension) if (p.level().dimension() == shapeDimension)
{ {
particleMesh( particleMesh(
Collections.singletonList(p), Collections.singletonList(p),
replacementParticle(p.level.registryAccess()), replacementParticle(p.level().registryAccess()),
density, density,
relativiseRender(p.level, from, 0), relativiseRender(p.level(), from, 0),
relativiseRender(p.level, to, 0) relativiseRender(p.level(), to, 0)
); );
} }
}; };
@@ -966,19 +966,19 @@ public class ShapeDispatcher
Vec3 vecA = vertexList.get(i); Vec3 vecA = vertexList.get(i);
if (relative.get(i)) if (relative.get(i))
{ {
vecA = relativiseRender(p.level, vecA, 0); vecA = relativiseRender(p.level(), vecA, 0);
} }
i++; i++;
Vec3 vecB = vertexList.get(i); Vec3 vecB = vertexList.get(i);
if (relative.get(i)) if (relative.get(i))
{ {
vecB = relativiseRender(p.level, vecB, 0); vecB = relativiseRender(p.level(), vecB, 0);
} }
i++; i++;
Vec3 vecC = vertexList.get(i); Vec3 vecC = vertexList.get(i);
if (relative.get(i)) if (relative.get(i))
{ {
vecC = relativiseRender(p.level, vecC, 0); vecC = relativiseRender(p.level(), vecC, 0);
} }
alterDrawTriangles(vecA, vecB, vecC); alterDrawTriangles(vecA, vecB, vecC);
} }
@@ -987,19 +987,19 @@ public class ShapeDispatcher
Vec3 vec0 = vertexList.get(0); Vec3 vec0 = vertexList.get(0);
if (relative.get(0)) if (relative.get(0))
{ {
vec0 = relativiseRender(p.level, vec0, 0); vec0 = relativiseRender(p.level(), vec0, 0);
} }
Vec3 vec1 = vertexList.get(1); Vec3 vec1 = vertexList.get(1);
if (relative.get(1)) if (relative.get(1))
{ {
vec1 = relativiseRender(p.level, vec1, 0); vec1 = relativiseRender(p.level(), vec1, 0);
} }
for (int i = 2; i < vertexList.size(); i++) for (int i = 2; i < vertexList.size(); i++)
{ {
Vec3 vec = vertexList.get(i); Vec3 vec = vertexList.get(i);
if (relative.get(i)) if (relative.get(i))
{ {
vec = relativiseRender(p.level, vec, 0); vec = relativiseRender(p.level(), vec, 0);
} }
alterDrawTriangles(vec0, vec1, vec); alterDrawTriangles(vec0, vec1, vec);
vec1 = vec; vec1 = vec;
@@ -1009,19 +1009,19 @@ public class ShapeDispatcher
Vec3 vecA = vertexList.get(0); Vec3 vecA = vertexList.get(0);
if (relative.get(0)) if (relative.get(0))
{ {
vecA = relativiseRender(p.level, vecA, 0); vecA = relativiseRender(p.level(), vecA, 0);
} }
Vec3 vecB = vertexList.get(1); Vec3 vecB = vertexList.get(1);
if (relative.get(1)) if (relative.get(1))
{ {
vecB = relativiseRender(p.level, vecB, 0); vecB = relativiseRender(p.level(), vecB, 0);
} }
for (int i = 2; i < vertexList.size(); i++) for (int i = 2; i < vertexList.size(); i++)
{ {
Vec3 vec = vertexList.get(i); Vec3 vec = vertexList.get(i);
if (relative.get(i)) if (relative.get(i))
{ {
vec = relativiseRender(p.level, vec, 0); vec = relativiseRender(p.level(), vec, 0);
} }
alterDrawTriangles(vecA, vecB, vec); alterDrawTriangles(vecA, vecB, vec);
vecA = vecB; vecA = vecB;
@@ -1061,16 +1061,16 @@ public class ShapeDispatcher
public Consumer<ServerPlayer> alternative() public Consumer<ServerPlayer> alternative()
{ {
return p -> { return p -> {
if (p.level.dimension() != this.shapeDimension) if (p.level().dimension() != this.shapeDimension)
{ {
return; return;
} }
if (fa > 0.0f) if (fa > 0.0f)
{ {
ParticleOptions locparticledata = getParticleData(String.format(Locale.ROOT, "dust %.1f %.1f %.1f %.1f", fr, fg, fb, fa), p.level.registryAccess()); ParticleOptions locparticledata = getParticleData(String.format(Locale.ROOT, "dust %.1f %.1f %.1f %.1f", fr, fg, fb, fa), p.level().registryAccess());
for (Vec3 v : getAlterPoint(p)) for (Vec3 v : getAlterPoint(p))
{ {
p.getLevel().sendParticles(p, locparticledata, true, p.serverLevel().sendParticles(p, locparticledata, true,
v.x, v.y, v.z, 1, v.x, v.y, v.z, 1,
0.0, 0.0, 0.0, 0.0); 0.0, 0.0, 0.0, 0.0);
} }
@@ -1205,13 +1205,13 @@ public class ShapeDispatcher
double density = Math.max(2.0, from.distanceTo(to) / 50) / (a + 0.1); double density = Math.max(2.0, from.distanceTo(to) / 50) / (a + 0.1);
return p -> return p ->
{ {
if (p.level.dimension() == shapeDimension) if (p.level().dimension() == shapeDimension)
{ {
drawParticleLine( drawParticleLine(
Collections.singletonList(p), Collections.singletonList(p),
replacementParticle(p.level.registryAccess()), replacementParticle(p.level().registryAccess()),
relativiseRender(p.level, from, 0), relativiseRender(p.level(), from, 0),
relativiseRender(p.level, to, 0), relativiseRender(p.level(), to, 0),
density density
); );
} }
@@ -1279,8 +1279,8 @@ public class ShapeDispatcher
return p -> return p ->
{ {
int partno = Math.min(1000, 20 * subdivisions); int partno = Math.min(1000, 20 * subdivisions);
RandomSource rand = p.level.getRandom(); RandomSource rand = p.level().getRandom();
ServerLevel world = p.getLevel(); ServerLevel world = p.serverLevel();
ParticleOptions particle = replacementParticle(world.registryAccess()); ParticleOptions particle = replacementParticle(world.registryAccess());
Vec3 ccenter = relativiseRender(world, center, 0); Vec3 ccenter = relativiseRender(world, center, 0);
@@ -1376,8 +1376,8 @@ public class ShapeDispatcher
return p -> return p ->
{ {
int partno = (int) Math.min(1000, Math.sqrt(20 * subdivisions * (1 + height))); int partno = (int) Math.min(1000, Math.sqrt(20 * subdivisions * (1 + height)));
RandomSource rand = p.level.getRandom(); RandomSource rand = p.level().getRandom();
ServerLevel world = p.getLevel(); ServerLevel world = p.serverLevel();
ParticleOptions particle = replacementParticle(world.registryAccess()); ParticleOptions particle = replacementParticle(world.registryAccess());
Vec3 ccenter = relativiseRender(world, center, 0); Vec3 ccenter = relativiseRender(world, center, 0);
@@ -2183,7 +2183,7 @@ public class ShapeDispatcher
int parts = 0; int parts = 0;
for (ServerPlayer player : playerList) for (ServerPlayer player : playerList)
{ {
ServerLevel world = player.getLevel(); ServerLevel world = player.serverLevel();
world.sendParticles(player, particle, true, world.sendParticles(player, particle, true,
(towards.x) / 2 + from.x, (towards.y) / 2 + from.y, (towards.z) / 2 + from.z, particles / 3, (towards.x) / 2 + from.x, (towards.y) / 2 + from.y, (towards.z) / 2 + from.z, particles / 3,
towards.x / 6, towards.y / 6, towards.z / 6, 0.0); towards.x / 6, towards.y / 6, towards.z / 6, 0.0);
@@ -2200,7 +2200,7 @@ public class ShapeDispatcher
int dev = 2 * divider; int dev = 2 * divider;
for (ServerPlayer player : playerList) for (ServerPlayer player : playerList)
{ {
ServerLevel world = player.getLevel(); ServerLevel world = player.serverLevel();
world.sendParticles(player, particle, true, world.sendParticles(player, particle, true,
(towards.x) / center + from.x, (towards.y) / center + from.y, (towards.z) / center + from.z, particles / divider, (towards.x) / center + from.x, (towards.y) / center + from.y, (towards.z) / center + from.z, particles / divider,
towards.x / dev, towards.y / dev, towards.z / dev, 0.0); towards.x / dev, towards.y / dev, towards.z / dev, 0.0);
@@ -2224,7 +2224,7 @@ public class ShapeDispatcher
int pcount = 0; int pcount = 0;
if (distance < 100) if (distance < 100)
{ {
RandomSource rand = players.get(0).level.random; RandomSource rand = players.get(0).level().random;
int particles = (int) (distance / density) + 1; int particles = (int) (distance / density) + 1;
Vec3 towards = to.subtract(from); Vec3 towards = to.subtract(from);
for (int i = 0; i < particles; i++) for (int i = 0; i < particles; i++)
@@ -2232,7 +2232,7 @@ public class ShapeDispatcher
Vec3 at = from.add(towards.scale(rand.nextDouble())); Vec3 at = from.add(towards.scale(rand.nextDouble()));
for (ServerPlayer player : players) for (ServerPlayer player : players)
{ {
player.getLevel().sendParticles(player, particle, true, player.serverLevel().sendParticles(player, particle, true,
at.x, at.y, at.z, 1, at.x, at.y, at.z, 1,
0.0, 0.0, 0.0, 0.0); 0.0, 0.0, 0.0, 0.0);
pcount++; pcount++;
@@ -2253,7 +2253,7 @@ public class ShapeDispatcher
{ {
for (ServerPlayer player : players) for (ServerPlayer player : players)
{ {
player.getLevel().sendParticles(player, particle, true, player.serverLevel().sendParticles(player, particle, true,
delta.x + from.x, delta.y + from.y, delta.z + from.z, 1, delta.x + from.x, delta.y + from.y, delta.z + from.z, 1,
0.0, 0.0, 0.0, 0.0); 0.0, 0.0, 0.0, 0.0);
pcount++; pcount++;
@@ -66,16 +66,16 @@ public class SnoopyCommandSource extends CommandSourceStack
public SnoopyCommandSource(ServerPlayer player, Component[] error, List<Component> output) public SnoopyCommandSource(ServerPlayer player, Component[] error, List<Component> output)
{ {
super(player, player.position(), player.getRotationVector(), super(player, player.position(), player.getRotationVector(),
player.level instanceof final ServerLevel serverLevel ? serverLevel : null, player.level() instanceof final ServerLevel serverLevel ? serverLevel : null,
player.server.getProfilePermissions(player.getGameProfile()), player.getName().getString(), player.getDisplayName(), player.server.getProfilePermissions(player.getGameProfile()), player.getName().getString(), player.getDisplayName(),
player.level.getServer(), player); player.level().getServer(), player);
this.output = player; this.output = player;
this.position = player.position(); this.position = player.position();
this.world = player.level instanceof final ServerLevel serverLevel ? serverLevel : null; this.world = player.level() instanceof final ServerLevel serverLevel ? serverLevel : null;
this.level = player.server.getProfilePermissions(player.getGameProfile()); this.level = player.server.getProfilePermissions(player.getGameProfile());
this.simpleName = player.getName().getString(); this.simpleName = player.getName().getString();
this.name = player.getDisplayName(); this.name = player.getDisplayName();
this.server = player.level.getServer(); this.server = player.level().getServer();
this.entity = player; this.entity = player;
this.resultConsumer = (ctx, succ, res) -> { this.resultConsumer = (ctx, succ, res) -> {
}; };
@@ -31,7 +31,7 @@ public class Tracer
Vec3 pos = source.getEyePosition(partialTicks); Vec3 pos = source.getEyePosition(partialTicks);
Vec3 rotation = source.getViewVector(partialTicks); Vec3 rotation = source.getViewVector(partialTicks);
Vec3 reachEnd = pos.add(rotation.x * reach, rotation.y * reach, rotation.z * reach); Vec3 reachEnd = pos.add(rotation.x * reach, rotation.y * reach, rotation.z * reach);
return source.level.clip(new ClipContext(pos, reachEnd, ClipContext.Block.OUTLINE, fluids ? return source.level().clip(new ClipContext(pos, reachEnd, ClipContext.Block.OUTLINE, fluids ?
ClipContext.Fluid.ANY : ClipContext.Fluid.NONE, source)); ClipContext.Fluid.ANY : ClipContext.Fluid.NONE, source));
} }
@@ -45,7 +45,7 @@ public class Tracer
public static EntityHitResult rayTraceEntities(Entity source, Vec3 start, Vec3 end, AABB box, Predicate<Entity> predicate, double maxSqDistance) public static EntityHitResult rayTraceEntities(Entity source, Vec3 start, Vec3 end, AABB box, Predicate<Entity> predicate, double maxSqDistance)
{ {
Level world = source.level; Level world = source.level();
double targetDistance = maxSqDistance; double targetDistance = maxSqDistance;
Entity target = null; Entity target = null;
Vec3 targetHitPos = null; Vec3 targetHitPos = null;
@@ -165,7 +165,7 @@ public class WorldTools
List<ServerPlayer> players = world.getChunkSource().chunkMap.getPlayers(chunkPos, false); List<ServerPlayer> players = world.getChunkSource().chunkMap.getPlayers(chunkPos, false);
if (!players.isEmpty()) if (!players.isEmpty())
{ {
ClientboundLevelChunkWithLightPacket packet = new ClientboundLevelChunkWithLightPacket(worldChunk, world.getLightEngine(), null, null, false); // false seems to update neighbours as well. ClientboundLevelChunkWithLightPacket packet = new ClientboundLevelChunkWithLightPacket(worldChunk, world.getLightEngine(), null, null); // false seems to update neighbours as well.
players.forEach(p -> p.connection.send(packet)); players.forEach(p -> p.connection.send(packet));
} }
} }
@@ -434,12 +434,12 @@ public class EntityValue extends Value
put("motion_x", (e, a) -> new NumericValue(e.getDeltaMovement().x)); put("motion_x", (e, a) -> new NumericValue(e.getDeltaMovement().x));
put("motion_y", (e, a) -> new NumericValue(e.getDeltaMovement().y)); put("motion_y", (e, a) -> new NumericValue(e.getDeltaMovement().y));
put("motion_z", (e, a) -> new NumericValue(e.getDeltaMovement().z)); put("motion_z", (e, a) -> new NumericValue(e.getDeltaMovement().z));
put("on_ground", (e, a) -> BooleanValue.of(e.isOnGround())); put("on_ground", (e, a) -> BooleanValue.of(e.onGround()));
put("name", (e, a) -> new StringValue(e.getName().getString())); put("name", (e, a) -> new StringValue(e.getName().getString()));
put("display_name", (e, a) -> new FormattedTextValue(e.getDisplayName())); put("display_name", (e, a) -> new FormattedTextValue(e.getDisplayName()));
put("command_name", (e, a) -> new StringValue(e.getScoreboardName())); put("command_name", (e, a) -> new StringValue(e.getScoreboardName()));
put("custom_name", (e, a) -> e.hasCustomName() ? new StringValue(e.getCustomName().getString()) : Value.NULL); put("custom_name", (e, a) -> e.hasCustomName() ? new StringValue(e.getCustomName().getString()) : Value.NULL);
put("type", (e, a) -> nameFromRegistryId(e.getLevel().registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getKey(e.getType()))); put("type", (e, a) -> nameFromRegistryId(e.level().registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getKey(e.getType())));
put("is_riding", (e, a) -> BooleanValue.of(e.isPassenger())); put("is_riding", (e, a) -> BooleanValue.of(e.isPassenger()));
put("is_ridden", (e, a) -> BooleanValue.of(e.isVehicle())); put("is_ridden", (e, a) -> BooleanValue.of(e.isVehicle()));
put("passengers", (e, a) -> ListValue.wrap(e.getPassengers().stream().map(EntityValue::new))); put("passengers", (e, a) -> ListValue.wrap(e.getPassengers().stream().map(EntityValue::new)));
@@ -489,7 +489,7 @@ public class EntityValue extends Value
put("immune_to_frost", (e, a) -> BooleanValue.of(!e.canFreeze())); put("immune_to_frost", (e, a) -> BooleanValue.of(!e.canFreeze()));
put("invulnerable", (e, a) -> BooleanValue.of(e.isInvulnerable())); put("invulnerable", (e, a) -> BooleanValue.of(e.isInvulnerable()));
put("dimension", (e, a) -> nameFromRegistryId(e.level.dimension().location())); // getDimId put("dimension", (e, a) -> nameFromRegistryId(e.level().dimension().location())); // getDimId
put("height", (e, a) -> new NumericValue(e.getDimensions(Pose.STANDING).height)); put("height", (e, a) -> new NumericValue(e.getDimensions(Pose.STANDING).height));
put("width", (e, a) -> new NumericValue(e.getDimensions(Pose.STANDING).width)); put("width", (e, a) -> new NumericValue(e.getDimensions(Pose.STANDING).width));
put("eye_height", (e, a) -> new NumericValue(e.getEyeHeight())); put("eye_height", (e, a) -> new NumericValue(e.getEyeHeight()));
@@ -516,7 +516,7 @@ public class EntityValue extends Value
} }
return Value.NULL; return Value.NULL;
}); });
put("home", (e, a) -> e instanceof final Mob mob ? (mob.getRestrictRadius() > 0) ? new BlockValue(null, (ServerLevel) e.getLevel(), mob.getRestrictCenter()) : Value.FALSE : Value.NULL); put("home", (e, a) -> e instanceof final Mob mob ? (mob.getRestrictRadius() > 0) ? new BlockValue(null, (ServerLevel) e.level(), mob.getRestrictCenter()) : Value.FALSE : Value.NULL);
put("spawn_point", (e, a) -> { put("spawn_point", (e, a) -> {
if (e instanceof final ServerPlayer spe) if (e instanceof final ServerPlayer spe)
{ {
@@ -566,7 +566,7 @@ public class EntityValue extends Value
put("brain", (e, a) -> { put("brain", (e, a) -> {
String module = a.getString(); String module = a.getString();
MemoryModuleType<?> moduleType = e.getLevel().registryAccess().registryOrThrow(Registries.MEMORY_MODULE_TYPE).get(InputValidator.identifierOf(module)); MemoryModuleType<?> moduleType = e.level().registryAccess().registryOrThrow(Registries.MEMORY_MODULE_TYPE).get(InputValidator.identifierOf(module));
if (moduleType == MemoryModuleType.DUMMY) if (moduleType == MemoryModuleType.DUMMY)
{ {
return Value.NULL; return Value.NULL;
@@ -704,7 +704,7 @@ public class EntityValue extends Value
{ {
return Value.NULL; return Value.NULL;
} }
return new BlockValue(null, sp.getLevel(), pos); return new BlockValue(null, sp.serverLevel(), pos);
} }
return Value.NULL; return Value.NULL;
}); });
@@ -831,7 +831,7 @@ public class EntityValue extends Value
{ {
return Value.NULL; return Value.NULL;
} }
Registry<Attribute> attributes = e.getLevel().registryAccess().registryOrThrow(Registries.ATTRIBUTE); Registry<Attribute> attributes = e.level().registryAccess().registryOrThrow(Registries.ATTRIBUTE);
if (a == null) if (a == null)
{ {
AttributeMap container = el.getAttributes(); AttributeMap container = el.getAttributes();
@@ -1711,7 +1711,7 @@ public class EntityValue extends Value
}); });
put("item", (e, v) -> { put("item", (e, v) -> {
ItemStack item = ValueConversions.getItemStackFromValue(v, true, e.level.registryAccess()); ItemStack item = ValueConversions.getItemStackFromValue(v, true, e.level().registryAccess());
if (e instanceof final ItemEntity itementity) if (e instanceof final ItemEntity itementity)
{ {
itementity.setItem(item); itementity.setItem(item);
@@ -1745,7 +1745,7 @@ public class EntityValue extends Value
} }
CompoundTag tag = new CompoundTag(); CompoundTag tag = new CompoundTag();
tag.put("Data", getEntity().saveWithoutId(new CompoundTag())); tag.put("Data", getEntity().saveWithoutId(new CompoundTag()));
Registry<EntityType<?>> reg = getEntity().level.registryAccess().registryOrThrow(Registries.ENTITY_TYPE); Registry<EntityType<?>> reg = getEntity().level().registryAccess().registryOrThrow(Registries.ENTITY_TYPE);
tag.put("Name", StringTag.valueOf(reg.getKey(getEntity().getType()).toString())); tag.put("Name", StringTag.valueOf(reg.getKey(getEntity().getType()).toString()));
return tag; return tag;
} }
@@ -265,7 +265,7 @@ public class ScreenValue extends Value
{ {
Map<Value, Value> data = new HashMap<>(); Map<Value, Value> data = new HashMap<>();
data.put(StringValue.of("slot"), NumericValue.of(slotId)); data.put(StringValue.of("slot"), NumericValue.of(slotId));
data.put(StringValue.of("stack"), ValueConversions.of(stack, player.level.registryAccess())); data.put(StringValue.of("stack"), ValueConversions.of(stack, player.level().registryAccess()));
ScreenValue.this.callListener(ScreenValue.this.player, "slot_update", data); ScreenValue.this.callListener(ScreenValue.this.player, "slot_update", data);
} }
@@ -40,7 +40,7 @@ import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructurePiece; import net.minecraft.world.level.levelgen.structure.StructurePiece;
import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.pathfinder.Node; import net.minecraft.world.level.pathfinder.Node;
import net.minecraft.world.level.pathfinder.Path; import net.minecraft.world.level.pathfinder.Path;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
@@ -84,7 +84,7 @@ public class ValueConversions
return of(world.dimension().location()); return of(world.dimension().location());
} }
public static Value of(MaterialColor color) public static Value of(MapColor color)
{ {
return ListValue.of(StringValue.of(Colors.mapColourName.get(color)), ofRGB(color.col)); return ListValue.of(StringValue.of(Colors.mapColourName.get(color)), ofRGB(color.col));
} }
@@ -85,7 +85,7 @@ public class SpawnReporter
return; return;
} }
} }
Pair<ResourceKey<Level>, MobCategory> key = Pair.of(mob.level.dimension(), cat); Pair<ResourceKey<Level>, MobCategory> key = Pair.of(mob.level().dimension(), cat);
long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L); long count = spawn_stats.get(key).getOrDefault(mob.getType(), 0L);
spawn_stats.get(key).put(mob.getType(), count + 1); spawn_stats.get(key).put(mob.getType(), count + 1);
spawned_mobs.get(key).put(Pair.of(mob.getType(), pos)); spawned_mobs.get(key).put(Pair.of(mob.getType(), pos));
+21 -21
View File
@@ -18,7 +18,7 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -32,34 +32,34 @@ import static java.util.Map.entry;
public class WoolTool public class WoolTool
{ {
/** /**
* A map of the {@link MaterialColor} to the {@link DyeColor} which is used in {@link WoolTool#getWoolColorAtPosition} * A map of the {@link net.minecraft.world.level.material.MapColor} to the {@link DyeColor} which is used in {@link WoolTool#getWoolColorAtPosition}
* to get the colour of wool at a position. * to get the colour of wool at a position.
*/ */
private static final Map<MaterialColor,DyeColor> Material2Dye = Arrays.stream(DyeColor.values()) private static final Map<MapColor,DyeColor> Material2Dye = Arrays.stream(DyeColor.values())
.collect(Collectors.toUnmodifiableMap(DyeColor::getMaterialColor, Function.identity())); .collect(Collectors.toUnmodifiableMap(DyeColor::getMapColor, Function.identity()));
/** /**
* A map of all the wool colours to their respective colours in the {@link Messenger#m} format so the name of the counter * A map of all the wool colours to their respective colours in the {@link Messenger#m} format so the name of the counter
* gets printed in colour. * gets printed in colour.
*/ */
public static final Map<MaterialColor,String> Material2DyeName = Map.ofEntries( public static final Map<MapColor,String> Material2DyeName = Map.ofEntries(
entry(MaterialColor.SNOW, "w "), entry(MapColor.SNOW, "w "),
entry(MaterialColor.COLOR_ORANGE, "#F9801D "), entry(MapColor.COLOR_ORANGE, "#F9801D "),
entry(MaterialColor.COLOR_MAGENTA, "m "), entry(MapColor.COLOR_MAGENTA, "m "),
entry(MaterialColor.COLOR_LIGHT_BLUE, "t "), entry(MapColor.COLOR_LIGHT_BLUE, "t "),
entry(MaterialColor.COLOR_YELLOW, "y "), entry(MapColor.COLOR_YELLOW, "y "),
entry(MaterialColor.COLOR_LIGHT_GREEN, "l "), entry(MapColor.COLOR_LIGHT_GREEN, "l "),
entry(MaterialColor.COLOR_PINK, "#FFACCB "), entry(MapColor.COLOR_PINK, "#FFACCB "),
entry(MaterialColor.COLOR_GRAY, "f "), entry(MapColor.COLOR_GRAY, "f "),
entry(MaterialColor.COLOR_LIGHT_GRAY, "g "), entry(MapColor.COLOR_LIGHT_GRAY, "g "),
entry(MaterialColor.COLOR_CYAN, "c "), entry(MapColor.COLOR_CYAN, "c "),
entry(MaterialColor.COLOR_PURPLE, "p "), entry(MapColor.COLOR_PURPLE, "p "),
entry(MaterialColor.COLOR_BLUE, "v "), entry(MapColor.COLOR_BLUE, "v "),
entry(MaterialColor.COLOR_BROWN, "#835432 "), entry(MapColor.COLOR_BROWN, "#835432 "),
entry(MaterialColor.COLOR_GREEN, "e "), entry(MapColor.COLOR_GREEN, "e "),
entry(MaterialColor.COLOR_RED, "r "), entry(MapColor.COLOR_RED, "r "),
entry(MaterialColor.COLOR_BLACK, "k ") entry(MapColor.COLOR_BLACK, "k ")
); );
/** /**