Reformat Code

This commit is contained in:
Zoë Gidiere
2025-10-05 21:55:16 -06:00
parent 2b09ed8fd9
commit 8d153998fa
17 changed files with 93 additions and 122 deletions

View File

@@ -3,13 +3,13 @@ package com.dfsek.terra.addons.biome.pipeline.image.config.converter.mapping;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import java.util.Map;
import com.dfsek.terra.addons.biome.pipeline.api.biome.PipelineBiome;
import com.dfsek.terra.addons.image.config.ColorLoader.ColorString;
import com.dfsek.terra.addons.image.converter.mapping.ColorMapping;
import com.dfsek.terra.addons.image.util.MapUtil;
import java.util.Map;
public class DefinedPipelineBiomeColorMappingTemplate implements ObjectTemplate<ColorMapping<PipelineBiome>> {

View File

@@ -4,6 +4,13 @@ import com.dfsek.terra.api.block.BlockData;
public interface BlockStateExtended extends BlockState {
/**
* Gets the BlockData.
*
* @return BlockData of this BlockStateExtended
*/
BlockData getData();
/**
* Sets the BlockData.
*
@@ -11,14 +18,7 @@ public interface BlockStateExtended extends BlockState {
*
* @return New BlockStateExtended with the given BlockData
*/
BlockStateExtended setData(BlockData data);
/**
* Gets the BlockData.
*
* @return BlockData of this BlockStateExtended
*/
BlockData getData();
BlockStateExtended setData(BlockData data);
/**
* Gets the BlockState.
@@ -28,5 +28,5 @@ public interface BlockStateExtended extends BlockState {
BlockState getState();
@Override
default boolean isExtended() {return true;}
default boolean isExtended() { return true; }
}

View File

@@ -7,14 +7,14 @@
package com.dfsek.terra.api.structure.configured;
import org.jetbrains.annotations.ApiStatus.Experimental;
import com.dfsek.terra.api.registry.key.StringIdentifiable;
import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.structure.StructureSpawn;
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.util.range.Range;
import org.jetbrains.annotations.ApiStatus.Experimental;
@Experimental
public interface ConfiguredStructure extends StringIdentifiable {

View File

@@ -30,7 +30,7 @@ dependencies {
geyserMappings("GeyserMC.mappings", "biomes", Versions.Allay.mappings, ext = "json")
geyserMappings("GeyserMC.mappings-generator", "new_generator_blocks", Versions.Allay.mappingsGenerator, ext = "json")
mcmeta("misode.mcmeta", "blocks/data", Versions.Allay.mcmeta, ext ="json")
mcmeta("misode.mcmeta", "blocks/data", Versions.Allay.mcmeta, ext = "json")
}
tasks.processResources {

View File

@@ -102,7 +102,8 @@ public final class Mapping {
return false;
}
Map<String, BiomeMapping> mappings = from(stream, new TypeToken<>() {});
Map<String, BiomeMapping> mappings = from(stream, new TypeToken<>() {
});
mappings.forEach((javaId, mapping) -> JE_BIOME_ID_TO_BE.put(javaId, mapping.bedrockId()));
} catch(IOException e) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("Failed to load biomes mapping", e);
@@ -118,7 +119,8 @@ public final class Mapping {
return false;
}
Map<String, ItemMapping> mappings = from(stream, new TypeToken<>() {});
Map<String, ItemMapping> mappings = from(stream, new TypeToken<>() {
});
mappings.forEach((javaId, mapping) -> {
ItemType<?> itemType = ItemTypeGetter
.name(mapping.bedrockId())
@@ -140,7 +142,8 @@ public final class Mapping {
return false;
}
Map<String, List<BlockMapping>> root = from(stream, new TypeToken<>() {});
Map<String, List<BlockMapping>> root = from(stream, new TypeToken<>() {
});
List<BlockMapping> mappings = root.get("mappings");
mappings.forEach(mapping -> {
JeBlockState jeState = createJeBlockState(mapping.javaState());
@@ -163,7 +166,8 @@ public final class Mapping {
return false;
}
Map<String, List<Map<String, ?>>> data = from(stream, new TypeToken<>() {});
Map<String, List<Map<String, ?>>> data = from(stream, new TypeToken<>() {
});
for(var entry : data.entrySet()) {
JE_BLOCK_DEFAULT_PROPERTIES.put(
"minecraft:" + entry.getKey(),
@@ -249,6 +253,7 @@ public final class Mapping {
}
}
// see https://stackoverflow.com/questions/59655279/is-there-an-easy-way-to-make-gson-skip-a-field-if-theres-an-error-deserializing
public static class IgnoreFailureTypeAdapterFactory implements TypeAdapterFactory {
@Override

View File

@@ -3,12 +3,11 @@ package com.dfsek.terra.bukkit.nms.v1_21_9.config;
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import com.dfsek.terra.api.util.range.Range;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import com.dfsek.terra.api.util.range.Range;
public class SpawnEntryConfig implements ObjectTemplate<SpawnEntryConfig> {
@Value("type")

View File

@@ -2,6 +2,8 @@ package com.dfsek.terra.minestom.addon;
import ca.solostudios.strata.Versions;
import ca.solostudios.strata.version.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
@@ -10,9 +12,6 @@ import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.minestom.TerraMinestomPlatform;
import com.dfsek.terra.minestom.config.VanillaBiomeProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MinestomAddon implements BaseAddon {
private static final Version VERSION = Versions.getVersion(1, 0, 0);

View File

@@ -17,17 +17,10 @@
package com.dfsek.terra.mod.generation;
import com.dfsek.seismic.math.coord.CoordFunctions;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.mojang.serialization.MapCodec;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
@@ -55,6 +48,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
@@ -141,10 +135,11 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
for(int y = world.getMaxHeight(); y >= world.getMinHeight(); y--) {
double noise = structureWeightSampler.sample(new UnblendedNoisePos(x + xi, y, z + zi));
if(noise > threshold) {
com.dfsek.terra.api.block.state.BlockState data = delegate.getPalette(x + xi, y, z + zi, world, biomeProvider).get(depth, x + xi, y, z + zi, world.getSeed());
com.dfsek.terra.api.block.state.BlockState data = delegate.getPalette(x + xi, y, z + zi, world, biomeProvider).get(
depth, x + xi, y, z + zi, world.getSeed());
BlockPos blockPos = new BlockPos(x, y, z);
boolean isExtended = data.isExtended() && data.getClass().equals(BlockStateArgument.class);
if (isExtended) {
if(isExtended) {
BlockStateExtended blockStateExtended = (BlockStateExtended) data;
net.minecraft.block.BlockState blockState = (net.minecraft.block.BlockState) blockStateExtended.getState();
@@ -200,7 +195,8 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
int min = height.getBottomY();
for(int y = height.getTopYInclusive() - 1; y >= min; y--) {
com.dfsek.terra.api.block.state.BlockState terraBlockState = delegate.getBlock(properties, x, y, z, biomeProvider);
BlockState blockState = (BlockState) (terraBlockState.isExtended() ? ((BlockStateExtended) terraBlockState).getState() : terraBlockState);
BlockState blockState =
(BlockState) (terraBlockState.isExtended() ? ((BlockStateExtended) terraBlockState).getState() : terraBlockState);
if(heightmap
.getBlockPredicate()
.test(blockState)) return y + 1;
@@ -215,7 +211,8 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
BiomeProvider biomeProvider = pack.getBiomeProvider();
for(int y = height.getTopYInclusive() - 1; y >= height.getBottomY(); y--) {
com.dfsek.terra.api.block.state.BlockState terraBlockState = delegate.getBlock(properties, x, y, z, biomeProvider);
BlockState blockState = (BlockState) (terraBlockState.isExtended() ? ((BlockStateExtended) terraBlockState).getState() : terraBlockState);
BlockState blockState =
(BlockState) (terraBlockState.isExtended() ? ((BlockStateExtended) terraBlockState).getState() : terraBlockState);
array[y - height.getBottomY()] = blockState;
}
return new VerticalBlockSample(height.getBottomY(), array);

View File

@@ -17,8 +17,6 @@
package com.dfsek.terra.mod.handle;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.Blocks;
@@ -35,6 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.entity.EntityType;
import com.dfsek.terra.api.handle.WorldHandle;
@@ -51,10 +50,10 @@ public class MinecraftWorldHandle implements WorldHandle {
try {
BlockResult blockResult = BlockArgumentParser.block(Registries.BLOCK, data, true);
BlockState blockState;
if (blockResult.nbt() != null) {
if(blockResult.nbt() != null) {
net.minecraft.block.BlockState state = blockResult.blockState();
NbtCompound nbtCompound = blockResult.nbt();
if (state.hasBlockEntity()) {
if(state.hasBlockEntity()) {
BlockEntity blockEntity = ((BlockEntityProvider) state.getBlock()).createBlockEntity(new BlockPos(0, 0, 0), state);
nbtCompound.putInt("x", 0);

View File

@@ -1,20 +1,9 @@
package com.dfsek.terra.mod.mixin.implementations.terra.block.state;
import com.dfsek.terra.api.block.BlockData;
import com.dfsek.terra.api.block.BlockType;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.block.state.properties.Property;
import com.dfsek.terra.mod.mixin.access.StateAccessor;
import net.minecraft.block.AbstractBlock.AbstractBlockState;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.pattern.CachedBlockPosition;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.Registries;
import net.minecraft.state.State;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Implements;
@@ -25,24 +14,28 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import com.dfsek.terra.api.block.BlockData;
import com.dfsek.terra.api.block.BlockType;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.block.state.properties.Property;
@Mixin(BlockStateArgument.class)
@Implements(@Interface(iface = BlockStateExtended.class, prefix = "terra$"))
public abstract class BlockStateArgumentMixin implements Predicate<CachedBlockPosition> {
@Shadow
@Nullable
@Final
private NbtCompound data;
@Shadow
public abstract BlockState getBlockState();
@Shadow
public abstract Set<net.minecraft.state.property.Property<?>> getProperties();
@Shadow
@Nullable
@Final
private NbtCompound data;
public boolean terra$matches(com.dfsek.terra.api.block.state.BlockState other) {
return ((com.dfsek.terra.api.block.state.BlockState) getBlockState()).matches(other);
}
@@ -80,7 +73,8 @@ public abstract class BlockStateArgumentMixin implements Predicate<CachedBlockPo
@SuppressWarnings({ "ConstantValue", "DataFlowIssue", "EqualsBetweenInconvertibleTypes" })
@Intrinsic
public BlockStateExtended terra$setData(BlockData data) {
return (BlockStateExtended) new BlockStateArgument(getBlockState(), getProperties(), data.getClass().equals(NbtCompound.class) ? ((NbtCompound) ((Object) data)) : null);
return (BlockStateExtended) new BlockStateArgument(getBlockState(), getProperties(),
data.getClass().equals(NbtCompound.class) ? ((NbtCompound) ((Object) data)) : null);
}
@SuppressWarnings("DataFlowIssue")

View File

@@ -18,26 +18,17 @@
package com.dfsek.terra.mod.mixin.implementations.terra.chunk;
import com.dfsek.seismic.math.coord.CoordFunctions;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.render.DimensionEffects.End;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.fluid.Fluid;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.WorldProperties;
import net.minecraft.world.biome.source.BiomeAccess;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.feature.EndGatewayFeature;
import net.minecraft.world.tick.MultiTickScheduler;
import net.minecraft.world.tick.OrderedTick;
import org.jetbrains.annotations.NotNull;
@@ -49,6 +40,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.world.chunk.Chunk;
@@ -82,18 +74,19 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess {
public void terraChunk$setBlock(int x, int y, int z, @NotNull BlockState data, boolean physics) {
ChunkPos pos = centerPos.getPos();
BlockPos blockPos = new BlockPos(CoordFunctions.chunkAndRelativeToAbsolute(pos.x, x), y, CoordFunctions.chunkAndRelativeToAbsolute(pos.z, z));
BlockPos blockPos = new BlockPos(CoordFunctions.chunkAndRelativeToAbsolute(pos.x, x), y,
CoordFunctions.chunkAndRelativeToAbsolute(pos.z, z));
boolean isExtended = data.isExtended() && data.getClass().equals(BlockStateArgument.class);
if (isExtended) {
if(isExtended) {
BlockStateArgument arg = ((BlockStateArgument) data);
net.minecraft.block.BlockState state = arg.getBlockState();
setBlockState(blockPos, state, 0, 512);
net.minecraft.world.chunk.Chunk chunk = getChunk(blockPos);
BlockEntity blockEntity;
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended)data).getData());
if ("DUMMY".equals(nbt.getString("id", ""))) {
if (state.hasBlockEntity()) {
blockEntity = ((BlockEntityProvider)state.getBlock()).createBlockEntity(blockPos, state);
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended) data).getData());
if("DUMMY".equals(nbt.getString("id", ""))) {
if(state.hasBlockEntity()) {
blockEntity = ((BlockEntityProvider) state.getBlock()).createBlockEntity(blockPos, state);
} else {
blockEntity = null;
}
@@ -101,7 +94,7 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess {
blockEntity = BlockEntity.createFromNbt(blockPos, state, nbt, this.world.getRegistryManager());
}
if (blockEntity != null) {
if(blockEntity != null) {
blockEntity.setWorld(this.world);
chunk.setBlockEntity(blockEntity);
}
@@ -110,7 +103,8 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess {
}
if(physics) {
net.minecraft.block.BlockState state = isExtended ? ((BlockStateArgument) data).getBlockState() : ((net.minecraft.block.BlockState) data);
net.minecraft.block.BlockState state =
isExtended ? ((BlockStateArgument) data).getBlockState() : ((net.minecraft.block.BlockState) data);
if(state.isLiquid()) {
fluidTickScheduler.scheduleTick(OrderedTick.create(state.getFluidState().getFluid(), blockPos));
} else {

View File

@@ -17,15 +17,11 @@
package com.dfsek.terra.mod.mixin.implementations.terra.chunk;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.command.SetBlockCommand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.gen.feature.EndGatewayFeature;
import net.minecraft.world.tick.OrderedTick;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -37,6 +33,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.world.ServerWorld;
import com.dfsek.terra.api.world.chunk.Chunk;
@@ -62,17 +59,18 @@ public abstract class WorldChunkMixin {
public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) {
BlockPos blockPos = new BlockPos(x, y, z);
boolean isExtended = data.isExtended() && data.getClass().equals(BlockStateArgument.class);
if (isExtended) {
if(isExtended) {
BlockStateArgument arg = ((BlockStateArgument) data);
net.minecraft.block.BlockState state = arg.getBlockState();
setBlockState(blockPos, state, 0);
loadBlockEntity(blockPos, ((NbtCompound) (Object) ((BlockStateExtended)data).getData()));
loadBlockEntity(blockPos, ((NbtCompound) (Object) ((BlockStateExtended) data).getData()));
} else {
setBlockState(blockPos, (net.minecraft.block.BlockState) data, 0);
}
if(physics) {
net.minecraft.block.BlockState state = isExtended ? ((BlockStateArgument) data).getBlockState() : ((net.minecraft.block.BlockState) data);
net.minecraft.block.BlockState state =
isExtended ? ((BlockStateArgument) data).getBlockState() : ((net.minecraft.block.BlockState) data);
if(state.isLiquid()) {
world.getFluidTickScheduler().scheduleTick(OrderedTick.create(state.getFluidState().getFluid(), blockPos));
} else {

View File

@@ -17,8 +17,6 @@
package com.dfsek.terra.mod.mixin.implementations.terra.chunk.data;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
@@ -36,6 +34,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
@@ -56,7 +55,7 @@ public abstract class ProtoChunkMixin extends Chunk {
public void terra$setBlock(int x, int y, int z, @NotNull BlockState data) {
BlockPos blockPos = new BlockPos(x, y, z);
boolean isExtended = data.isExtended() && data.getClass().equals(BlockStateArgument.class);
if (isExtended) {
if(isExtended) {
BlockStateExtended blockStateExtended = (BlockStateExtended) data;
net.minecraft.block.BlockState blockState = (net.minecraft.block.BlockState) blockStateExtended.getState();

View File

@@ -1,10 +1,5 @@
package com.dfsek.terra.mod.mixin.implementations.terra.nbt;
import com.dfsek.terra.api.block.BlockData;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import net.minecraft.block.pattern.CachedBlockPosition;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import org.spongepowered.asm.mixin.Implements;
@@ -12,7 +7,7 @@ import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Intrinsic;
import org.spongepowered.asm.mixin.Mixin;
import java.util.function.Predicate;
import com.dfsek.terra.api.block.BlockData;
@Mixin(NbtCompound.class)

View File

@@ -17,11 +17,8 @@
package com.dfsek.terra.mod.mixin.implementations.terra.world;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.FluidBlock;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.entity.SpawnReason;
import net.minecraft.fluid.Fluid;
@@ -30,7 +27,6 @@ import net.minecraft.util.collection.BoundedRegionArray;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkGenerationStep;
import net.minecraft.world.tick.MultiTickScheduler;
@@ -47,6 +43,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.dfsek.terra.api.block.entity.BlockEntity;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.entity.Entity;
import com.dfsek.terra.api.entity.EntityType;
@@ -55,7 +52,6 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
import com.dfsek.terra.mod.generation.MinecraftChunkGeneratorWrapper;
import com.dfsek.terra.mod.mixin.invoke.FluidBlockInvoker;
import com.dfsek.terra.mod.util.MinecraftUtil;
@@ -99,16 +95,16 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess {
BlockPos blockPos = new BlockPos(x, y, z);
int flags = physics ? 3 : 1042;
boolean isExtended = data.isExtended() && data.getClass().equals(BlockStateArgument.class);
if (isExtended) {
if(isExtended) {
BlockStateArgument arg = ((BlockStateArgument) data);
net.minecraft.block.BlockState state = arg.getBlockState();
setBlockState(blockPos, state, flags);
net.minecraft.world.chunk.Chunk chunk = getChunk(blockPos);
net.minecraft.block.entity.BlockEntity blockEntity;
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended)data).getData());
if ("DUMMY".equals(nbt.getString("id", ""))) {
if (state.hasBlockEntity()) {
blockEntity = ((BlockEntityProvider)state.getBlock()).createBlockEntity(blockPos, state);
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended) data).getData());
if("DUMMY".equals(nbt.getString("id", ""))) {
if(state.hasBlockEntity()) {
blockEntity = ((BlockEntityProvider) state.getBlock()).createBlockEntity(blockPos, state);
} else {
blockEntity = null;
}
@@ -116,7 +112,7 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess {
blockEntity = net.minecraft.block.entity.BlockEntity.createFromNbt(blockPos, state, nbt, getRegistryManager());
}
if (blockEntity != null) {
if(blockEntity != null) {
blockEntity.setWorld(world);
chunk.setBlockEntity(blockEntity);
}
@@ -125,7 +121,8 @@ public abstract class ChunkRegionMixin implements StructureWorldAccess {
}
if(physics) {
net.minecraft.block.BlockState state = isExtended ? ((BlockStateArgument) data).getBlockState() : ((net.minecraft.block.BlockState) data);
net.minecraft.block.BlockState state =
isExtended ? ((BlockStateArgument) data).getBlockState() : ((net.minecraft.block.BlockState) data);
if(state.isLiquid()) {
getFluidTickScheduler().scheduleTick(OrderedTick.create(state.getFluidState().getFluid(), blockPos));
} else {

View File

@@ -17,12 +17,8 @@
package com.dfsek.terra.mod.mixin.implementations.terra.world;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.mod.mixin.invoke.FluidBlockInvoker;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.FluidBlock;
import net.minecraft.command.argument.BlockStateArgument;
import net.minecraft.entity.SpawnReason;
import net.minecraft.fluid.Fluid;
@@ -31,22 +27,20 @@ import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.tick.MultiTickScheduler;
import net.minecraft.world.tick.OrderedTick;
import net.minecraft.world.tick.WorldTickScheduler;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Intrinsic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.dfsek.terra.api.block.entity.BlockEntity;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.BlockStateExtended;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.entity.Entity;
import com.dfsek.terra.api.entity.EntityType;
@@ -58,8 +52,6 @@ import com.dfsek.terra.mod.generation.MinecraftChunkGeneratorWrapper;
import com.dfsek.terra.mod.generation.TerraBiomeSource;
import com.dfsek.terra.mod.util.MinecraftUtil;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(net.minecraft.server.world.ServerWorld.class)
@Implements(@Interface(iface = ServerWorld.class, prefix = "terra$"))
@@ -88,16 +80,16 @@ public abstract class ServerWorldMixin extends World {
BlockPos blockPos = new BlockPos(x, y, z);
int flags = physics ? 3 : 1042;
boolean isExtended = data.isExtended() && data.getClass().equals(BlockStateArgument.class);
if (isExtended) {
if(isExtended) {
BlockStateArgument arg = ((BlockStateArgument) data);
net.minecraft.block.BlockState state = arg.getBlockState();
setBlockState(blockPos, state, flags);
net.minecraft.world.chunk.Chunk chunk = getChunk(blockPos);
net.minecraft.block.entity.BlockEntity blockEntity;
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended)data).getData());
if ("DUMMY".equals(nbt.getString("id", ""))) {
if (state.hasBlockEntity()) {
blockEntity = ((BlockEntityProvider)state.getBlock()).createBlockEntity(blockPos, state);
NbtCompound nbt = ((NbtCompound) (Object) ((BlockStateExtended) data).getData());
if("DUMMY".equals(nbt.getString("id", ""))) {
if(state.hasBlockEntity()) {
blockEntity = ((BlockEntityProvider) state.getBlock()).createBlockEntity(blockPos, state);
} else {
blockEntity = null;
}
@@ -105,7 +97,7 @@ public abstract class ServerWorldMixin extends World {
blockEntity = net.minecraft.block.entity.BlockEntity.createFromNbt(blockPos, state, nbt, getRegistryManager());
}
if (blockEntity != null) {
if(blockEntity != null) {
blockEntity.setWorld(this);
chunk.setBlockEntity(blockEntity);
}
@@ -114,7 +106,8 @@ public abstract class ServerWorldMixin extends World {
}
if(physics) {
net.minecraft.block.BlockState state = isExtended ? ((BlockStateArgument) data).getBlockState() : ((net.minecraft.block.BlockState) data);
net.minecraft.block.BlockState state =
isExtended ? ((BlockStateArgument) data).getBlockState() : ((net.minecraft.block.BlockState) data);
if(state.isLiquid()) {
getFluidTickScheduler().scheduleTick(OrderedTick.create(state.getFluidState().getFluid(), blockPos));
} else {

View File

@@ -40,7 +40,8 @@ public class PresetUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(PresetUtil.class);
private static final List<Pair<Identifier, Boolean>> PRESETS = new ArrayList<>();
public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack, ModPlatform platform, boolean extended, boolean packInMetapack) {
public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack, ModPlatform platform, boolean extended,
boolean packInMetapack) {
Registry<DimensionType> dimensionTypeRegistry = platform.dimensionTypeRegistry();
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = platform.chunkGeneratorSettingsRegistry();
Registry<MultiNoiseBiomeSourceParameterList> multiNoiseBiomeSourceParameterLists =
@@ -55,7 +56,8 @@ public class PresetUtil {
HashMap<RegistryKey<DimensionOptions>, DimensionOptions> dimensionMap = new HashMap<>();
insertCustom(platform, "minecraft:overworld", pack, dimensionTypeRegistry, chunkGeneratorSettingsRegistry, dimensionMap, packInMetapack);
insertCustom(platform, "minecraft:overworld", pack, dimensionTypeRegistry, chunkGeneratorSettingsRegistry, dimensionMap,
packInMetapack);
insertDefaults(dimensionTypeRegistry, chunkGeneratorSettingsRegistry, multiNoiseBiomeSourceParameterLists, platform.biomeRegistry(),
dimensionMap);
@@ -111,7 +113,7 @@ public class PresetUtil {
Identifier dimensionTypeID = Identifier.of("terra", pack.getID().toLowerCase(Locale.ROOT));
DimensionType dimensionType;
if (!packInMetapack) {
if(!packInMetapack) {
dimensionType = DimensionUtil.createDimension(vanillaWorldProperties, defaultDimension, platform);
RegistryKey<DimensionType> dimensionTypeRegistryKey = MinecraftUtil.registerDimensionTypeKey(
dimensionTypeID);