26.3-rc-3
This commit is contained in:
1 parent
4a97c841b8
commit
7cfb996bd3
16 files changed
+108
-189
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ org.gradle.configuration-cache=false
|
||||
|
||||
# Fabric Properties
|
||||
# check https://fabricmc.net/develop/
|
||||
minecraft_version=26.3-snapshot-9
|
||||
minecraft_version=26.3-rc-3
|
||||
loader_version=0.19.3
|
||||
loom_version=1.17-SNAPSHOT
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package carpet.fakes;
|
||||
|
||||
import net.minecraft.world.level.levelgen.densityfunction.DensityFunction;
|
||||
|
||||
public interface RandomStateVisitorAccessor {
|
||||
DensityFunction.Visitor getVisitor();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.RandomStateVisitorAccessor;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.DensityFunction;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(RandomState.class)
|
||||
public class RandomState_ScarpetMixin implements RandomStateVisitorAccessor {
|
||||
@Unique
|
||||
private DensityFunction.Visitor visitor;
|
||||
|
||||
@ModifyArg(
|
||||
method = "<init>",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/levelgen/NoiseRouter;mapAll(Lnet/minecraft/world/level/levelgen/densityfunction/DensityFunction$Visitor;)Lnet/minecraft/world/level/levelgen/NoiseRouter;"
|
||||
),
|
||||
index = 0
|
||||
)
|
||||
private DensityFunction.Visitor captureVisitor(DensityFunction.Visitor visitor) {
|
||||
this.visitor = visitor;
|
||||
return visitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DensityFunction.Visitor getVisitor() {
|
||||
return this.visitor;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public abstract class ServerChunkCacheMixin
|
||||
|
||||
@Shadow @Final private DistanceManager distanceManager;
|
||||
|
||||
@Redirect(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V", at = @At(
|
||||
@Redirect(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/DistanceManager;getNaturalSpawnChunkCount()I"
|
||||
))
|
||||
@@ -54,7 +54,7 @@ public abstract class ServerChunkCacheMixin
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V", at = @At("RETURN"))
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("RETURN"))
|
||||
private void onFinishSpawnWorldCycle(CallbackInfo ci)
|
||||
{
|
||||
LevelData levelData = this.level.getLevelData(); // levelProperies class
|
||||
|
||||
@@ -19,13 +19,13 @@ public abstract class ServerChunkCache_profilerMixin
|
||||
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V", at = @At("HEAD"))
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("HEAD"))
|
||||
private void startSpawningSection(CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(level, "Spawning", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;J)V", at = @At("RETURN"))
|
||||
@Inject(method = "tickChunks(Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("RETURN"))
|
||||
private void stopSpawningSection(CallbackInfo ci)
|
||||
{
|
||||
if (currentSection != null)
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public abstract class ServerGamePacketListenerImpl_antiCheatDisabledMixin extend
|
||||
return isSingleplayerOwner() || CarpetSettings.antiCheatDisabled;
|
||||
}
|
||||
|
||||
@Redirect(method = "handleMovePlayer", require = 0, // don't crash with immersive portals,
|
||||
@Redirect(method = "handlePlayerPositionChange", require = 0, // don't crash with immersive portals,
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;isChangingDimension()Z"))
|
||||
|
||||
@@ -122,11 +122,11 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "handleMovePlayer", at = @At(
|
||||
@Inject(method = "handlePlayerPositionChange", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;jumpFromGround()V"
|
||||
))
|
||||
private void onJump(ServerboundMovePlayerPacket playerMoveC2SPacket_1, CallbackInfo ci)
|
||||
private void onJump(double requestedX, double requestedY, double requestedZ, float requestedYRot, float requestedXRot, boolean isOnGround, boolean horizontalCollision, CallbackInfo ci)
|
||||
{
|
||||
PLAYER_JUMPS.onPlayerEvent(player);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import carpet.script.value.ValueConversions;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
@@ -58,21 +58,20 @@ import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.util.random.WeightedList;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.level.ServerExplosion;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.Aquifer;
|
||||
import net.minecraft.world.level.levelgen.NoiseRouterData;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.DensityFunction;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.DensityFunctions;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseRouter;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.DensitySamplerSet;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.SamplerContext;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureType;
|
||||
import net.minecraft.world.level.saveddata.WeatherData;
|
||||
import net.minecraft.world.level.storage.TagValueInput;
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -96,7 +95,6 @@ import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiManager;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiRecord;
|
||||
@@ -133,7 +131,6 @@ import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
@@ -1731,104 +1728,68 @@ public class WorldAccess
|
||||
{
|
||||
return ListValue.wrap(cc.registry(Registries.DENSITY_FUNCTION).keySet().stream().map(ValueConversions::of));
|
||||
}
|
||||
RandomState router = level.getChunkSource().randomState();
|
||||
return densityFunctionQueries.length == 1
|
||||
? NumericValue.of(sampleNoise(router, level, densityFunctionQueries[0], pos))
|
||||
: ListValue.wrap(Arrays.stream(densityFunctionQueries).map(s -> NumericValue.of(sampleNoise(router, level, s, pos))));
|
||||
? NumericValue.of(sampleNoise(level, densityFunctionQueries[0], pos))
|
||||
: ListValue.wrap(Arrays.stream(densityFunctionQueries).map(s -> NumericValue.of(sampleNoise(level, s, pos))));
|
||||
});
|
||||
}
|
||||
|
||||
public static double sampleNoise(RandomState router, ServerLevel level, String what, BlockPos pos)
|
||||
|
||||
@Nullable static DensitySamplerSet samplersCache = null;
|
||||
@Nullable static ServerLevel samplerLevel = null;
|
||||
|
||||
public static double sampleNoise(ServerLevel level, String what, BlockPos pos)
|
||||
{
|
||||
DensityFunction densityFunction = switch (what)
|
||||
{
|
||||
case "temperature" -> router.router().temperature();
|
||||
case "vegetation" -> router.router().vegetation();
|
||||
case "continents" -> router.router().continents();
|
||||
case "erosion" -> router.router().erosion();
|
||||
case "depth" -> router.router().depth();
|
||||
case "ridges" -> router.router().ridges();
|
||||
case "preliminary_surface_level" -> router.router().preliminarySurfaceLevel();
|
||||
case "final_density" -> router.router().finalDensity();
|
||||
//case "vein_toggle" -> router. router(). veinToggle();
|
||||
//case "vein_ridged" -> router.router().veinRidged();
|
||||
//case "vein_gap" -> router.router().veinGap();
|
||||
default -> {
|
||||
Aquifer.Config aquifer = router.aquifers().orElse(null);
|
||||
if (aquifer != null) {
|
||||
yield switch (what) {
|
||||
case "barrier_noise" -> aquifer.barrierNoise();
|
||||
case "fluid_level_floodedness_noise" -> aquifer.fluidLevelFloodednessNoise();
|
||||
case "fluid_level_spread_noise" -> aquifer.fluidLevelSpreadNoise();
|
||||
case "lava_noise" -> aquifer.lavaNoise();
|
||||
default -> stupidWorldgenNoiseCacheGetter.apply(Pair.of(level, what));
|
||||
};
|
||||
}
|
||||
yield stupidWorldgenNoiseCacheGetter.apply(Pair.of(level, what));
|
||||
}
|
||||
};
|
||||
return densityFunction.compute(new DensityFunction.SinglePointContext(pos.getX(), pos.getY(), pos.getZ()));
|
||||
if (samplersCache == null || samplerLevel != level) {
|
||||
final ServerChunkCache chunkSource = level.getChunkSource();
|
||||
final RandomState randomState = chunkSource.randomState();
|
||||
final SamplerContext samplerContext = SamplerContext.builder().enableCaches().build();
|
||||
samplersCache = randomState.samplersWithContext(samplerContext);
|
||||
samplerLevel = level;
|
||||
}
|
||||
|
||||
// to be used with future seedable noise
|
||||
public static final Function<Pair<ServerLevel, String>, DensityFunction> stupidWorldgenNoiseCacheGetter = Util.memoize(pair -> {
|
||||
ServerLevel level = pair.getKey();
|
||||
String densityFunctionQuery = pair.getValue();
|
||||
ChunkGenerator generator = level.getChunkSource().getGenerator();
|
||||
|
||||
if (generator instanceof final NoiseBasedChunkGenerator noiseBasedChunkGenerator)
|
||||
ResourceKey<DensityFunction> key = switch (what) {
|
||||
case "temperature" -> NoiseRouterData.OVERWORLD_FUNCTIONS.temperature();
|
||||
case "vegetation" -> NoiseRouterData.OVERWORLD_FUNCTIONS.vegetation();
|
||||
case "continents" -> NoiseRouterData.OVERWORLD_FUNCTIONS.continents();
|
||||
case "erosion" -> NoiseRouterData.OVERWORLD_FUNCTIONS.erosion();
|
||||
case "depth" -> NoiseRouterData.OVERWORLD_FUNCTIONS.depth();
|
||||
case "ridges" -> NoiseRouterData.RIDGES;
|
||||
case "preliminary_height" -> NoiseRouterData.OVERWORLD_FUNCTIONS.preliminarySurfaceLevel();
|
||||
case "final_density" -> NoiseRouterData.OVERWORLD_FUNCTIONS.finalDensity();
|
||||
default -> null;
|
||||
};
|
||||
final DensityFunction df;
|
||||
if (key != null) {
|
||||
df = level.registryAccess().lookupOrThrow(Registries.DENSITY_FUNCTION).get(key).get().value();
|
||||
} else {
|
||||
df = level.registryAccess().lookupOrThrow(Registries.DENSITY_FUNCTION).getValue(InputValidator.identifierOf(what));
|
||||
}
|
||||
if (df == null)
|
||||
{
|
||||
Registry<DensityFunction> densityFunctionRegistry = level.registryAccess().lookupOrThrow(Registries.DENSITY_FUNCTION);
|
||||
NoiseRouter router = noiseBasedChunkGenerator.generatorSettings().value().noiseRouter();
|
||||
DensityFunction densityFunction = switch (densityFunctionQuery)
|
||||
{
|
||||
case "temperature" -> router.temperature();
|
||||
case "vegetation" -> router.vegetation();
|
||||
case "continents" -> router.continents();
|
||||
case "erosion" -> router.erosion();
|
||||
case "depth" -> router.depth();
|
||||
case "ridges" -> router.ridges();
|
||||
case "preliminary_surface_level" -> router.preliminarySurfaceLevel();
|
||||
case "final_density" -> router.finalDensity();
|
||||
//case "vein_toggle" -> router.veinToggle();
|
||||
//case "vein_ridged" -> router.veinRidged();
|
||||
//case "vein_gap" -> router.veinGap();
|
||||
default -> {
|
||||
// last call, maybe its the aquifers
|
||||
DensityFunction dfa;
|
||||
if (level.getChunkSource().getGenerator() instanceof NoiseBasedChunkGenerator noiseBasedChunkGenerator) {
|
||||
Aquifer.Config aquifers = noiseBasedChunkGenerator.generatorSettings().value().aquifers().orElse(null);
|
||||
if (aquifers != null) {
|
||||
yield switch (densityFunctionQuery) {
|
||||
dfa = switch (what) {
|
||||
case "barrier_noise" -> aquifers.barrierNoise();
|
||||
case "fluid_level_floodedness_noise" -> aquifers.fluidLevelFloodednessNoise();
|
||||
case "fluid_level_spread_noise" -> aquifers.fluidLevelSpreadNoise();
|
||||
case "lava_noise" -> aquifers.lavaNoise();
|
||||
default -> {
|
||||
DensityFunction result = densityFunctionRegistry.getValue(InputValidator.identifierOf(densityFunctionQuery));
|
||||
if (result == null)
|
||||
{
|
||||
throw new InternalExpressionException("Density function '" + densityFunctionQuery + "' is not defined in the registies.");
|
||||
}
|
||||
yield result;
|
||||
}
|
||||
default -> null;
|
||||
};
|
||||
if (dfa != null) {
|
||||
return samplersCache.sampleValue(dfa, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
} else if (what.equalsIgnoreCase("barrier_noise") || what.equalsIgnoreCase("fluid_level_floodedness_noise") || what.equalsIgnoreCase("fluid_level_spread_noise") || what.equalsIgnoreCase("lava_noise")) {
|
||||
// querying for aquifers outside of noise based level should not result in an invalid exception, but rather a 0 value, as the aquifers are not present in that world.
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DensityFunction result = densityFunctionRegistry.getValue(InputValidator.identifierOf(densityFunctionQuery));
|
||||
if (result == null)
|
||||
{
|
||||
throw new InternalExpressionException("Density function '" + densityFunctionQuery + "' is not defined in the registies.");
|
||||
throw new InternalExpressionException("Density function '" + what + "' is not defined in the registries.");
|
||||
}
|
||||
yield result;
|
||||
return samplersCache.sampleValue(df, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
};
|
||||
|
||||
RandomState randomState = RandomState.create(
|
||||
level.registryAccess().lookupOrThrow(Registries.NOISE), level.getSeed(), noiseBasedChunkGenerator.generatorSettings().value()
|
||||
);
|
||||
DensityFunction.Visitor visitor = Vanilla.RandomState_getVisitor(randomState);
|
||||
|
||||
return densityFunction.mapAll(visitor);
|
||||
}
|
||||
return DensityFunctions.zero();
|
||||
});
|
||||
}
|
||||
@@ -109,11 +109,6 @@ public class Vanilla
|
||||
return ((TicketsFetcherInterface) ticketManager).getTicketsByPosition();
|
||||
}
|
||||
|
||||
public static DensityFunction.Visitor RandomState_getVisitor(RandomState randomState)
|
||||
{
|
||||
return ((RandomStateVisitorAccessor) (Object) randomState).getVisitor();
|
||||
}
|
||||
|
||||
public static CompoundTag BlockInput_getTag(BlockInput blockInput)
|
||||
{
|
||||
return ((BlockStateArgumentInterface) blockInput).getCMTag();
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.world.attribute.EnvironmentAttribute;
|
||||
import net.minecraft.world.attribute.EnvironmentAttributes;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import org.joml.Vector3fc;
|
||||
|
||||
public class BiomeInfo
|
||||
{
|
||||
@@ -47,7 +48,7 @@ public class BiomeInfo
|
||||
});
|
||||
}};
|
||||
|
||||
private static Value fromEnvironmentalAttribute(ServerLevel w, Biome b, EnvironmentAttribute<Integer> fogColor) {
|
||||
private static Value fromEnvironmentalAttribute(ServerLevel w, Biome b, EnvironmentAttribute<Vector3fc> fogColor) {
|
||||
return ValueConversions.ofRGB(b.getAttributes().applyModifier(fogColor, w.dimensionType().attributes().applyModifier(fogColor, fogColor.defaultValue())));
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.VerticalAnchor;
|
||||
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
||||
import net.minecraft.world.level.levelgen.densityfunction.SamplerContext;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralClawFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralTreeFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CuboidPlacement;
|
||||
@@ -85,8 +86,6 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProc
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import static net.minecraft.world.level.levelgen.feature.TreeFeature.CAN_PLACE_BELOW_TREE_TRUNKS;
|
||||
|
||||
public class FeatureGenerator
|
||||
{
|
||||
@Nullable
|
||||
@@ -269,8 +268,8 @@ public class FeatureGenerator
|
||||
{
|
||||
//Holder<Biome> genBiome = generator.getBiomeSource().getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ()), seed.sampler());
|
||||
if (structure.findValidGenerationPoint(new Structure.GenerationContext(
|
||||
world.registryAccess(), generator, world.uncachedBiomeResolver(),
|
||||
seed, world.getStructureManager(), world.getSeed(), chunkPos, world, structureBiomes::contains
|
||||
world.registryAccess(), generator, generator.getBiomeSource(), seed.createClimateSampler(SamplerContext.EMPTY_UNCACHED),
|
||||
seed, world.getStructureTemplateManager(), world.getSeed(), chunkPos, world, structureBiomes::contains
|
||||
)).isPresent())
|
||||
{
|
||||
return StructureStart.INVALID_START;
|
||||
@@ -279,7 +278,7 @@ public class FeatureGenerator
|
||||
else
|
||||
{
|
||||
StructureStart filledStructure = structure.generate(Holder.direct(structure), world.dimension(),
|
||||
world.registryAccess(), generator, world.uncachedBiomeResolver(), seed, world.getStructureManager(),
|
||||
world.registryAccess(), generator, generator.getBiomeSource(), seed.createClimateSampler(SamplerContext.EMPTY_UNCACHED), seed, world.getStructureTemplateManager(),
|
||||
world.getSeed(), chunkPos, 0, world, structureBiomes::contains);
|
||||
if (filledStructure != null && filledStructure.isValid())
|
||||
{
|
||||
@@ -289,17 +288,17 @@ public class FeatureGenerator
|
||||
return null;
|
||||
}
|
||||
|
||||
private static RuleBasedStateProvider belowTrees = RuleBasedStateProvider.ifTrueThenProvide(CAN_PLACE_BELOW_TREE_TRUNKS, Blocks.DIRT);
|
||||
private static RuleBasedStateProvider belowTrees = RuleBasedStateProvider.ifTrueThenProvide(BlockPredicate.not(BlockPredicate.matchesTag(BlockTags.CANNOT_REPLACE_BELOW_TREE_TRUNK)), Blocks.DIRT);
|
||||
|
||||
private static TreeFeature.Builder createTree(Block block, Block block2, int i, int j, int k, int l)
|
||||
{
|
||||
return new TreeFeature.Builder(BlockStateProvider.simple(block), new StraightTrunkPlacer(i, j, k), BlockStateProvider.simple(block2), new BlobFoliagePlacer(ConstantInt.of(l), ConstantInt.of(0), 3), new TwoLayersFeatureSize(1, 0, 1), belowTrees);
|
||||
return new TreeFeature.Builder(BlockStateProvider.of(block), new StraightTrunkPlacer(i, j, k), BlockStateProvider.of(block2), new BlobFoliagePlacer(ConstantInt.of(l), ConstantInt.of(0), 3), new TwoLayersFeatureSize(1, 0, 1), Holder.direct( belowTrees));
|
||||
}
|
||||
|
||||
// from AquaticFeatures
|
||||
private static Holder<PlacedFeature> wallCoral(final HolderGetter<Block> blocks, final Direction direction) {
|
||||
return PlacementUtils.inlinePlaced(
|
||||
new SimpleBlockFeature(new RotatedBlockProvider(new RandomBlockProvider(blocks.getOrThrow(BlockTags.WALL_CORALS)), Optional.of(direction))),
|
||||
new SimpleBlockFeature(new RotatedBlockProvider(Holder.direct(new RandomBlockProvider(blocks.getOrThrow(BlockTags.WALL_CORALS))), Optional.of(direction))),
|
||||
new RandomChancePlacement(0.2f),
|
||||
OffsetPlacement.of(direction),
|
||||
BlockPredicateFilter.forPredicate(BlockPredicate.matchesBlocks(Blocks.WATER))
|
||||
@@ -308,7 +307,7 @@ public class FeatureGenerator
|
||||
|
||||
public static Feature coral(final HolderGetter<Feature> features, final HolderGetter<Block> blocks, final Block block) {
|
||||
return new OverlayFeature(HolderSet.direct(
|
||||
PlacementUtils.inlinePlaced(new SimpleBlockFeature(BlockStateProvider.simple(block))),
|
||||
PlacementUtils.inlinePlaced(new SimpleBlockFeature(BlockStateProvider.of(block))),
|
||||
PlacementUtils.inlinePlaced(
|
||||
new WeightedRandomSelectorFeature(WeightedList.of(
|
||||
new Weighted<>(PlacementUtils.inlinePlaced(new SimpleBlockFeature(new RandomBlockProvider(blocks.getOrThrow(BlockTags.CORALS)))), 20),
|
||||
@@ -373,7 +372,7 @@ public class FeatureGenerator
|
||||
|
||||
// TODO remove this using what place feature is using
|
||||
put("oak_bees", l -> simpleTree(createTree(Blocks.OAK_LOG, Blocks.OAK_LEAVES, 4, 2, 0, 2).ignoreVines().decorators(List.of(new BeehiveDecorator(1.00F)))));
|
||||
put("fancy_oak_bees", l -> simpleTree(new TreeFeature.Builder(BlockStateProvider.simple(Blocks.OAK_LOG), new FancyTrunkPlacer(3, 11, 0), BlockStateProvider.simple(Blocks.OAK_LEAVES), new FancyFoliagePlacer(ConstantInt.of(2), ConstantInt.of(4), 4), new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4)), belowTrees).ignoreVines().decorators(List.of(new BeehiveDecorator(1.00F)))));
|
||||
put("fancy_oak_bees", l -> simpleTree(new TreeFeature.Builder(BlockStateProvider.of(Blocks.OAK_LOG), new FancyTrunkPlacer(3, 11, 0), BlockStateProvider.of(Blocks.OAK_LEAVES), new FancyFoliagePlacer(ConstantInt.of(2), ConstantInt.of(4), 4), new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4)), Holder.direct(belowTrees)).ignoreVines().decorators(List.of(new BeehiveDecorator(1.00F)))));
|
||||
put("birch_bees", l -> simpleTree(createTree(Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES, 5, 2, 0, 2).ignoreVines().decorators(List.of(new BeehiveDecorator(1.00F)))));
|
||||
|
||||
put("coral_tree", l -> simplePlop(coral(l, 0)));
|
||||
@@ -508,7 +507,7 @@ public class FeatureGenerator
|
||||
checks.set(true);
|
||||
try
|
||||
{
|
||||
StructureStart start = structure.generate(Holder.direct(structure), world.dimension(), world.registryAccess(), generator, world.uncachedBiomeResolver(), world.getChunkSource().randomState(), world.getStructureManager(), world.getSeed(), ChunkPos.containing(pos), 0, world, b -> true);
|
||||
StructureStart start = structure.generate(Holder.direct(structure), world.dimension(), world.registryAccess(), generator, generator.getBiomeSource(), world.getChunkSource().randomState().createClimateSampler(SamplerContext.EMPTY_UNCACHED), world.getChunkSource().randomState(), world.getStructureTemplateManager(), world.getSeed(), ChunkPos.containing(pos), 0, world, b -> true);
|
||||
if (start == StructureStart.INVALID_START)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -81,12 +81,12 @@ public class ShapesRenderer
|
||||
switch (shapeDirection)
|
||||
{
|
||||
case NORTH -> {}
|
||||
case SOUTH -> poseStack.mulPose(Axis.YP.rotationDegrees(180));
|
||||
case EAST -> poseStack.mulPose(Axis.YP.rotationDegrees(270));
|
||||
case WEST -> poseStack.mulPose(Axis.YP.rotationDegrees(90));
|
||||
case UP -> poseStack.mulPose(Axis.XP.rotationDegrees(90));
|
||||
case DOWN -> poseStack.mulPose(Axis.XP.rotationDegrees(-90));
|
||||
case CAMERA -> poseStack.mulPose(camera.rotation());
|
||||
case SOUTH -> poseStack.rotate(Axis.YP.rotationDegrees(180));
|
||||
case EAST -> poseStack.rotate(Axis.YP.rotationDegrees(270));
|
||||
case WEST -> poseStack.rotate(Axis.YP.rotationDegrees(90));
|
||||
case UP -> poseStack.rotate(Axis.XP.rotationDegrees(90));
|
||||
case DOWN -> poseStack.rotate(Axis.XP.rotationDegrees(-90));
|
||||
case CAMERA -> poseStack.rotate(camera.rotation());
|
||||
case PLAYER -> {
|
||||
Vec3 vector = objectPos.subtract(camera.position());
|
||||
double x = vector.x;
|
||||
@@ -99,8 +99,8 @@ public class ShapesRenderer
|
||||
// that should work somehow but it doesn't for some reason
|
||||
//matrices.mulPose(new Quaternion( -rotY, rotX, 0, false));
|
||||
|
||||
poseStack.mulPose(Axis.YP.rotation(rotX));
|
||||
poseStack.mulPose(Axis.XP.rotation(-rotY));
|
||||
poseStack.rotate(Axis.YP.rotation(rotX));
|
||||
poseStack.rotate(Axis.XP.rotation(-rotY));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,21 +373,21 @@ public class ShapesRenderer
|
||||
matrices.translate(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
matrices.mulPose(camera1.rotation().conjugate(new Quaternionf()));
|
||||
matrices.rotate(camera1.rotation().conjugate(new Quaternionf()));
|
||||
|
||||
matrices.translate(v1.x - cx, v1.y - cy, v1.z - cz);
|
||||
rotatePoseStackByShapeDirection(matrices, shape.facing, camera1, isitem ? v1 : v1.add(0.5, 0.5, 0.5));
|
||||
if (shape.tilt != 0.0f)
|
||||
{
|
||||
matrices.mulPose(Axis.ZP.rotationDegrees(-shape.tilt));
|
||||
matrices.rotate(Axis.ZP.rotationDegrees(-shape.tilt));
|
||||
}
|
||||
if (shape.lean != 0.0f)
|
||||
{
|
||||
matrices.mulPose(Axis.XP.rotationDegrees(-shape.lean));
|
||||
matrices.rotate(Axis.XP.rotationDegrees(-shape.lean));
|
||||
}
|
||||
if (shape.turn != 0.0f)
|
||||
{
|
||||
matrices.mulPose(Axis.YP.rotationDegrees(shape.turn));
|
||||
matrices.rotate(Axis.YP.rotationDegrees(shape.turn));
|
||||
}
|
||||
matrices.scale(shape.scaleX, shape.scaleY, shape.scaleZ);
|
||||
|
||||
@@ -399,7 +399,7 @@ public class ShapesRenderer
|
||||
else
|
||||
{
|
||||
// items seems to be flipped by default
|
||||
matrices.mulPose(Axis.YP.rotationDegrees(180));
|
||||
matrices.rotate(Axis.YP.rotationDegrees(180));
|
||||
}
|
||||
|
||||
blockPos = BlockPos.containing(v1);
|
||||
@@ -546,15 +546,15 @@ public class ShapesRenderer
|
||||
//RenderSystem.scalef(shape.size* 0.0025f, -shape.size*0.0025f, shape.size*0.0025f);
|
||||
if (shape.tilt != 0.0f)
|
||||
{
|
||||
matrices.mulPose(Axis.ZP.rotationDegrees(shape.tilt));
|
||||
matrices.rotate(Axis.ZP.rotationDegrees(shape.tilt));
|
||||
}
|
||||
if (shape.lean != 0.0f)
|
||||
{
|
||||
matrices.mulPose(Axis.XP.rotationDegrees(shape.lean));
|
||||
matrices.rotate(Axis.XP.rotationDegrees(shape.lean));
|
||||
}
|
||||
if (shape.turn != 0.0f)
|
||||
{
|
||||
matrices.mulPose(Axis.YP.rotationDegrees(shape.turn));
|
||||
matrices.rotate(Axis.YP.rotationDegrees(shape.turn));
|
||||
}
|
||||
matrices.translate(-10 * shape.indent, -10 * shape.height - 9, (-10 * renderEpsilon) - 10 * shape.raise);
|
||||
//if (visibleThroughWalls) RenderSystem.disableDepthTest();
|
||||
|
||||
@@ -31,8 +31,7 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
private final Vec3 position;
|
||||
private final ServerLevel world;
|
||||
private final PermissionSet level;
|
||||
private final String simpleName;
|
||||
private final Component name;
|
||||
private final CommandSourceStack.NamesProvider namesProvider;
|
||||
private final MinecraftServer server;
|
||||
// skipping silent since snooper is never silent
|
||||
private final Entity entity;
|
||||
@@ -49,15 +48,14 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
public SnoopyCommandSource(CommandSourceStack original, Component[] error, List<Component> chatOutput, OptionalLong[] returnValue)
|
||||
{
|
||||
super(CommandSource.NULL, original.getPosition(), original.getRotation(), original.getLevel(), Vanilla.MinecraftServer_getRunPermissionLevel(original.getServer()),
|
||||
original.getTextName(), original.getDisplayName(), original.getServer(), original.getEntity()
|
||||
original.getServer(), original.getEntity()
|
||||
//,false ,(b, i) -> returnValue[0] = OptionalLong.of(i), EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(original.getServer())
|
||||
);
|
||||
this.output = CommandSource.NULL;
|
||||
this.position = original.getPosition();
|
||||
this.world = original.getLevel();
|
||||
this.level = Vanilla.MinecraftServer_getRunPermissionLevel(original.getServer());
|
||||
this.simpleName = original.getTextName();
|
||||
this.name = original.getDisplayName();
|
||||
this.namesProvider = original.namesProvider;
|
||||
this.server = original.getServer();
|
||||
this.entity = original.getEntity();
|
||||
this.resultConsumer = (b, i) -> returnValue[0] = OptionalLong.of(i);
|
||||
@@ -74,14 +72,13 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
{
|
||||
super(player.commandSource(), player.position(), player.getRotationVector(),
|
||||
player.level() instanceof final ServerLevel serverLevel ? serverLevel : null,
|
||||
player.level().getServer().getProfilePermissions(player.nameAndId()), player.getName().getString(), player.getDisplayName(),
|
||||
player.level().getServer().getProfilePermissions(player.nameAndId()),
|
||||
player.level().getServer(), player);
|
||||
this.output = player.commandSource();
|
||||
this.position = player.position();
|
||||
this.world = player.level() instanceof final ServerLevel serverLevel ? serverLevel : null;
|
||||
this.level = player.level().getServer().getProfilePermissions(player.nameAndId());
|
||||
this.simpleName = player.getName().getString();
|
||||
this.name = player.getDisplayName();
|
||||
this.namesProvider = NamesProvider.FOR_ENTITY;
|
||||
this.server = player.level().getServer();
|
||||
this.entity = player;
|
||||
this.resultConsumer = (b, i) -> result[0] = i;
|
||||
@@ -94,12 +91,12 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
((CommandSourceStackInterface) this).setupPrivates(false, (b, i) -> result[0] = i, EntityAnchorArgument.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(player.level().getServer()));
|
||||
}
|
||||
|
||||
private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, PermissionSet level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, CommandResultCallback consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer,
|
||||
private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, PermissionSet level, CommandSourceStack.NamesProvider namesProvider, MinecraftServer server, @Nullable Entity entity, CommandResultCallback consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer,
|
||||
Component[] error, List<Component> chatOutput
|
||||
)
|
||||
{
|
||||
super(output, pos, rot, world, level,
|
||||
simpleName, name, server, entity
|
||||
server, entity
|
||||
// , false, consumer, entityAnchor, context, chainer
|
||||
);
|
||||
this.output = output;
|
||||
@@ -107,8 +104,7 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
this.rotation = rot;
|
||||
this.world = world;
|
||||
this.level = level;
|
||||
this.simpleName = simpleName;
|
||||
this.name = name;
|
||||
this.namesProvider = namesProvider;
|
||||
this.server = server;
|
||||
this.entity = entity;
|
||||
this.resultConsumer = consumer;
|
||||
@@ -123,25 +119,25 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
@Override
|
||||
public CommandSourceStack withEntity(Entity entity)
|
||||
{
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, entity.getName().getString(), entity.getDisplayName(), server, entity, resultConsumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, NamesProvider.FOR_ENTITY, server, entity, resultConsumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSourceStack withPosition(Vec3 position)
|
||||
{
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, namesProvider, server, entity, resultConsumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSourceStack withRotation(Vec2 rotation)
|
||||
{
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, namesProvider, server, entity, resultConsumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSourceStack withCallback(CommandResultCallback consumer)
|
||||
{
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, consumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, namesProvider, server, entity, consumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,13 +166,13 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
@Override
|
||||
public CommandSourceStack withAnchor(EntityAnchorArgument.Anchor anchor)
|
||||
{
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, anchor, signingContext, taskChainer, error, chatOutput);
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, namesProvider, server, entity, resultConsumer, anchor, signingContext, taskChainer, error, chatOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSourceStack withSigningContext(CommandSigningContext commandSigningContext, TaskChainer taskChainer)
|
||||
{
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, commandSigningContext, taskChainer, error, chatOutput);
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, namesProvider, server, entity, resultConsumer, entityAnchor, commandSigningContext, taskChainer, error, chatOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,7 +180,7 @@ public class SnoopyCommandSource extends CommandSourceStack
|
||||
{
|
||||
double d = DimensionType.getTeleportationScale(this.world.dimensionType(), world.dimensionType());
|
||||
Vec3 position = new Vec3(this.position.x * d, this.position.y, this.position.z * d);
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
return new SnoopyCommandSource(output, position, rotation, world, level, namesProvider, server, entity, resultConsumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ColumnPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.util.ARGB;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -60,6 +61,7 @@ import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.joml.Vector3fc;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public class ValueConversions
|
||||
@@ -140,6 +142,11 @@ public class ValueConversions
|
||||
return new NumericValue(value * 256 + 255);
|
||||
}
|
||||
|
||||
public static Value ofRGB(Vector3fc value)
|
||||
{
|
||||
return new NumericValue(ARGB.colorFromVector3f(value));
|
||||
}
|
||||
|
||||
public static Level dimFromValue(Value dimensionValue, MinecraftServer server)
|
||||
{
|
||||
if (dimensionValue instanceof EntityValue)
|
||||
|
||||
@@ -14,3 +14,4 @@ accessible method net/minecraft/world/level/border/WorldBorder getListeners ()Lj
|
||||
accessible method net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator calculateTargetStrength (Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)I
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour UPDATE_SHAPE_ORDER [Lnet/minecraft/core/Direction;
|
||||
accessible field net/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher blockModelResolver Lnet/minecraft/client/renderer/block/BlockModelResolver;
|
||||
accessible field net/minecraft/commands/CommandSourceStack namesProvider Lnet/minecraft/commands/CommandSourceStack$NamesProvider;
|
||||
@@ -153,7 +153,6 @@
|
||||
"BlockPredicate_scarpetMixin",
|
||||
"TagPredicate_scarpetMixin",
|
||||
"HorseBaseEntity_scarpetMixin",
|
||||
"RandomState_ScarpetMixin",
|
||||
"Biome_scarpetMixin",
|
||||
"PortalProcessor_scarpetMixin",
|
||||
|
||||
|
||||
Reference in new issue
Block a user