mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
1.19 fabric compiles now
This commit is contained in:
@@ -29,7 +29,6 @@ import net.minecraft.MinecraftVersion;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biome.Category;
|
||||
import net.minecraft.world.biome.Biome.Precipitation;
|
||||
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -39,6 +38,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.dfsek.terra.AbstractPlatform;
|
||||
import com.dfsek.terra.addon.EphemeralAddon;
|
||||
@@ -68,6 +68,10 @@ public class PlatformImpl extends AbstractPlatform {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public MinecraftServer getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean reload() {
|
||||
getTerraConfig().load(this);
|
||||
@@ -157,9 +161,10 @@ public class PlatformImpl extends AbstractPlatform {
|
||||
throw new LoadException("Invalid identifier: " + o, depthTracker);
|
||||
return identifier;
|
||||
})
|
||||
.registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.byName((String) o))
|
||||
.registerLoader(Category.class, (type, o, loader, depthTracker) -> Category.byName((String) o))
|
||||
.registerLoader(GrassColorModifier.class, (type, o, loader, depthTracker) -> GrassColorModifier.byName((String) o));
|
||||
.registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.valueOf(((String) o).toUpperCase(
|
||||
Locale.ROOT)))
|
||||
.registerLoader(GrassColorModifier.class, (type, o, loader, depthTracker) -> GrassColorModifier.valueOf(((String) o).toUpperCase(
|
||||
Locale.ROOT)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.dfsek.terra.fabric.config;
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import net.minecraft.world.biome.Biome.Category;
|
||||
import net.minecraft.world.biome.Biome.Precipitation;
|
||||
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
|
||||
|
||||
@@ -43,10 +42,6 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
@Default
|
||||
private Precipitation precipitation = null;
|
||||
|
||||
@Value("climate.category")
|
||||
@Default
|
||||
private Category category = null;
|
||||
|
||||
public Integer getFogColor() {
|
||||
return fogColor;
|
||||
}
|
||||
@@ -71,10 +66,6 @@ public class VanillaBiomeProperties implements ConfigTemplate, Properties {
|
||||
return skyColor;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public Precipitation getPrecipitation() {
|
||||
return precipitation;
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@ import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.StructureWeightType;
|
||||
import net.minecraft.world.gen.StructureTerrainAdaptation;
|
||||
import net.minecraft.world.gen.StructureWeightSampler;
|
||||
import net.minecraft.world.gen.StructureWeightSampler.class_7301;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
@@ -30,14 +31,13 @@ public class BeardGenerator {
|
||||
for(int i = 0; i < 24; ++i) {
|
||||
for(int j = 0; j < 24; ++j) {
|
||||
for(int k = 0; k < 24; ++k) {
|
||||
array[i * 24 * 24 + j * 24 + k] = (float) calculateStructureWeight(j - 12, k - 12, i - 12);
|
||||
array[i * 24 * 24 + j * 24 + k] = (float)calculateStructureWeight(j - 12, k - 12, i - 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
private final ObjectList<StructurePiece> pieces;
|
||||
private final ObjectList<JigsawJunction> junctions;
|
||||
private final ObjectListIterator<StructurePiece> pieceIterator;
|
||||
|
||||
private final ObjectListIterator<StructureWeightSampler.class_7301> pieceIterator;
|
||||
private final ObjectListIterator<JigsawJunction> junctionIterator;
|
||||
private final Chunk chunk;
|
||||
private final int minY;
|
||||
@@ -51,36 +51,50 @@ public class BeardGenerator {
|
||||
ChunkPos chunkPos = chunk.getPos();
|
||||
int i = chunkPos.getStartX();
|
||||
int j = chunkPos.getStartZ();
|
||||
this.junctions = new ObjectArrayList<>(32);
|
||||
this.pieces = new ObjectArrayList<>(10);
|
||||
ObjectList<JigsawJunction> junctions = new ObjectArrayList<>(32);
|
||||
ObjectList<class_7301> pieces = new ObjectArrayList<>(10);
|
||||
int minY = chunk.getBottomY();
|
||||
int maxY = chunk.getTopY();
|
||||
for(StructureStart start : structureAccessor.method_41035(ChunkSectionPos.from(chunk),
|
||||
configuredStructureFeature -> configuredStructureFeature.field_37144)) {
|
||||
for(StructurePiece structurePiece : start.getChildren()) {
|
||||
if(!structurePiece.intersectsChunk(chunkPos, 12)) continue;
|
||||
if(structurePiece instanceof PoolStructurePiece poolStructurePiece) {
|
||||
Projection projection = poolStructurePiece.getPoolElement().getProjection();
|
||||
if(projection == Projection.RIGID) {
|
||||
this.pieces.add(poolStructurePiece);
|
||||
for(StructureStart structureStart : structureAccessor.method_41035(chunkPos,
|
||||
structureType -> structureType.getTerrainAdaptation() !=
|
||||
StructureTerrainAdaptation.NONE)) {
|
||||
StructureTerrainAdaptation structureTerrainAdaptation = structureStart.getFeature().getTerrainAdaptation();
|
||||
|
||||
for(StructurePiece structurePiece : structureStart.getChildren()) {
|
||||
if(structurePiece.intersectsChunk(chunkPos, 12)) {
|
||||
if(structurePiece instanceof PoolStructurePiece poolStructurePiece) {
|
||||
Projection projection = poolStructurePiece.getPoolElement().getProjection();
|
||||
if(projection == Projection.RIGID) {
|
||||
pieces.add(
|
||||
new class_7301(
|
||||
poolStructurePiece.getBoundingBox(), structureTerrainAdaptation,
|
||||
poolStructurePiece.getGroundLevelDelta()
|
||||
)
|
||||
);
|
||||
maxY = Math.max(maxY, poolStructurePiece.getCenter().getY());
|
||||
minY = Math.min(minY, poolStructurePiece.getCenter().getY());
|
||||
}
|
||||
|
||||
for(JigsawJunction jigsawJunction : poolStructurePiece.getJunctions()) {
|
||||
int k = jigsawJunction.getSourceX();
|
||||
int l = jigsawJunction.getSourceZ();
|
||||
if(k > i - 12 && l > j - 12 && k < i + 15 + 12 && l < j + 15 + 12) {
|
||||
junctions.add(jigsawJunction);
|
||||
maxY = Math.max(maxY, jigsawJunction.getSourceGroundY());
|
||||
minY = Math.min(minY, jigsawJunction.getSourceGroundY());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pieces.add(new class_7301(structurePiece.getBoundingBox(), structureTerrainAdaptation, 0));
|
||||
maxY = Math.max(maxY, structurePiece.getCenter().getY());
|
||||
minY = Math.min(minY, structurePiece.getCenter().getY());
|
||||
}
|
||||
for(JigsawJunction jigsawJunction : poolStructurePiece.getJunctions()) {
|
||||
int k = jigsawJunction.getSourceX();
|
||||
int l = jigsawJunction.getSourceZ();
|
||||
if(k <= i - 12 || l <= j - 12 || k >= i + 15 + 12 || l >= j + 15 + 12) continue;
|
||||
maxY = Math.max(maxY, jigsawJunction.getSourceGroundY());
|
||||
minY = Math.min(minY, jigsawJunction.getSourceGroundY());
|
||||
this.junctions.add(jigsawJunction);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
maxY = Math.max(maxY, structurePiece.getCenter().getY());
|
||||
minY = Math.min(minY, structurePiece.getCenter().getY());
|
||||
this.pieces.add(structurePiece);
|
||||
}
|
||||
|
||||
}
|
||||
this.pieceIterator = this.pieces.iterator();
|
||||
this.junctionIterator = this.junctions.iterator();
|
||||
this.pieceIterator = pieces.iterator();
|
||||
this.junctionIterator = junctions.iterator();
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
}
|
||||
@@ -93,20 +107,22 @@ public class BeardGenerator {
|
||||
/**
|
||||
* Gets the structure weight from the array from the given position, or 0 if the position is out of bounds.
|
||||
*/
|
||||
private static double getStructureWeight(int x, int y, int z) {
|
||||
int xOffset = x + 12;
|
||||
int yOffset = y + 12;
|
||||
int zOffset = z + 12;
|
||||
if(xOffset < 0 || xOffset >= 24) {
|
||||
private static double getStructureWeight(int x, int y, int z, int i) {
|
||||
int j = x + 12;
|
||||
int k = y + 12;
|
||||
int l = z + 12;
|
||||
if (isInRange(j) && isInRange(k) && isInRange(l)) {
|
||||
double d = (double)i + 0.5;
|
||||
double e = MathHelper.squaredMagnitude((double)x, d, (double)z);
|
||||
double f = -d * MathHelper.fastInverseSqrt(e / 2.0) / 2.0;
|
||||
return f * (double)STRUCTURE_WEIGHT_TABLE[l * 24 * 24 + j * 24 + k];
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
if(yOffset < 0 || yOffset >= 24) {
|
||||
return 0.0;
|
||||
}
|
||||
if(zOffset < 0 || zOffset >= 24) {
|
||||
return 0.0;
|
||||
}
|
||||
return STRUCTURE_WEIGHT_TABLE[zOffset * 24 * 24 + xOffset * 24 + yOffset];
|
||||
}
|
||||
|
||||
private static boolean isInRange(int i) {
|
||||
return i >= 0 && i < 24;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,34 +161,40 @@ public class BeardGenerator {
|
||||
}
|
||||
|
||||
public double calculateNoise(int x, int y, int z) {
|
||||
double noise = 0.0;
|
||||
double d;
|
||||
double var10001;
|
||||
for(d = 0.0; this.pieceIterator.hasNext(); d += var10001) {
|
||||
StructureWeightSampler.class_7301 lv = this.pieceIterator.next();
|
||||
BlockBox blockBox = lv.box();
|
||||
int l = lv.groundLevelDelta();
|
||||
int m = Math.max(0, Math.max(blockBox.getMinX() - x, x - blockBox.getMaxX()));
|
||||
int n = Math.max(0, Math.max(blockBox.getMinZ() - z, z - blockBox.getMaxZ()));
|
||||
int o = blockBox.getMinY() + l;
|
||||
int p = y - o;
|
||||
|
||||
while(this.pieceIterator.hasNext()) {
|
||||
StructurePiece structurePiece = this.pieceIterator.next();
|
||||
BlockBox blockBox = structurePiece.getBoundingBox();
|
||||
int structureX = Math.max(0, Math.max(blockBox.getMinX() - x, x - blockBox.getMaxX()));
|
||||
int structureY = y - (blockBox.getMinY() + (structurePiece instanceof PoolStructurePiece
|
||||
? ((PoolStructurePiece) structurePiece).getGroundLevelDelta()
|
||||
: 0));
|
||||
int structureZ = Math.max(0, Math.max(blockBox.getMinZ() - z, z - blockBox.getMaxZ()));
|
||||
StructureWeightType structureWeightType = structurePiece.getWeightType();
|
||||
if(structureWeightType == StructureWeightType.BURY) {
|
||||
noise += getMagnitudeWeight(structureX, structureY, structureZ);
|
||||
continue;
|
||||
}
|
||||
if(structureWeightType != StructureWeightType.BEARD) continue;
|
||||
|
||||
noise += getStructureWeight(structureX, structureY, structureZ) * 0.8;
|
||||
int q = switch(lv.terrainAdjustment()) {
|
||||
case NONE -> 0;
|
||||
case BURY, BEARD_THIN -> p;
|
||||
case BEARD_BOX -> Math.max(0, Math.max(o - y, y - blockBox.getMaxY()));
|
||||
};
|
||||
var10001 = switch(lv.terrainAdjustment()) {
|
||||
case NONE -> 0.0;
|
||||
case BURY -> getMagnitudeWeight(m, q, n);
|
||||
case BEARD_THIN, BEARD_BOX -> getStructureWeight(m, q, n, p) * 0.8;
|
||||
};
|
||||
}
|
||||
this.pieceIterator.back(this.pieces.size());
|
||||
|
||||
this.pieceIterator.back(Integer.MAX_VALUE);
|
||||
|
||||
while(this.junctionIterator.hasNext()) {
|
||||
JigsawJunction structurePiece = this.junctionIterator.next();
|
||||
int structureX = x - structurePiece.getSourceX();
|
||||
int structureY = y - structurePiece.getSourceGroundY();
|
||||
int structureZ = z - structurePiece.getSourceZ();
|
||||
noise += getStructureWeight(structureX, structureY, structureZ) * 0.4;
|
||||
JigsawJunction jigsawJunction = this.junctionIterator.next();
|
||||
int r = x - jigsawJunction.getSourceX();
|
||||
int l = y - jigsawJunction.getSourceGroundY();
|
||||
int m = z - jigsawJunction.getSourceZ();
|
||||
d += getStructureWeight(r, l, m, l) * 0.4;
|
||||
}
|
||||
this.junctionIterator.back(this.junctions.size());
|
||||
return noise;
|
||||
|
||||
this.junctionIterator.back(Integer.MAX_VALUE);
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,11 +58,6 @@ public class TerraBiomeSource extends BiomeSource {
|
||||
return Codecs.TERRA_BIOME_SOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeSource withSeed(long seed) {
|
||||
return new TerraBiomeSource(this.biomeRegistry, seed, pack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryEntry<net.minecraft.world.biome.Biome> getBiome(int biomeX, int biomeY, int biomeZ, MultiNoiseSampler noiseSampler) {
|
||||
return biomeRegistry
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is part of Terra.
|
||||
*
|
||||
* Terra is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Terra is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.world.GeneratorType;
|
||||
import net.minecraft.structure.StructureSet;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class TerraGeneratorType extends GeneratorType {
|
||||
private final ConfigPack pack;
|
||||
|
||||
public TerraGeneratorType(ConfigPack pack) {
|
||||
super("terra." + pack.getID());
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChunkGenerator getChunkGenerator(DynamicRegistryManager manager, long seed) {
|
||||
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = manager.get(Registry.CHUNK_GENERATOR_SETTINGS_KEY);
|
||||
RegistryEntry<ChunkGeneratorSettings>
|
||||
settingsSupplier = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.OVERWORLD).orElseThrow();
|
||||
Registry<StructureSet> noiseRegistry = manager.get(Registry.STRUCTURE_SET_KEY);
|
||||
return new FabricChunkGeneratorWrapper(noiseRegistry, new TerraBiomeSource(manager.get(Registry.BIOME_KEY), seed, pack), seed, pack,
|
||||
settingsSupplier);
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,11 @@
|
||||
|
||||
package com.dfsek.terra.fabric.handle;
|
||||
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.command.argument.ItemStackArgumentType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
@@ -36,7 +39,7 @@ public class FabricItemHandle implements ItemHandle {
|
||||
@Override
|
||||
public Item createItem(String data) {
|
||||
try {
|
||||
return (Item) new ItemStackArgumentType().parse(new StringReader(data)).getItem();
|
||||
return (Item) new ItemStackArgumentType(new CommandRegistryAccess(FabricEntryPoint.getPlatform().getServer().getRegistryManager())).parse(new StringReader(data)).getItem();
|
||||
} catch(CommandSyntaxException e) {
|
||||
throw new IllegalArgumentException("Invalid item data \"" + data + "\"", e);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package com.dfsek.terra.fabric.handle;
|
||||
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -36,9 +38,8 @@ public class FabricWorldHandle implements WorldHandle {
|
||||
|
||||
@Override
|
||||
public @NotNull BlockState createBlockState(@NotNull String data) {
|
||||
BlockArgumentParser parser = new BlockArgumentParser(new StringReader(data), true);
|
||||
try {
|
||||
net.minecraft.block.BlockState state = parser.parse(true).getBlockState();
|
||||
net.minecraft.block.BlockState state = BlockArgumentParser.block(FabricEntryPoint.getPlatform().getServer().getRegistryManager().get(Registry.BLOCK_KEY), data, true).blockState();
|
||||
if(state == null) throw new IllegalArgumentException("Invalid data: " + data);
|
||||
return (BlockState) state;
|
||||
} catch(CommandSyntaxException e) {
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* This file is part of Terra.
|
||||
*
|
||||
* Terra is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Terra is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.access;
|
||||
|
||||
import net.minecraft.client.world.GeneratorType;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mixin(GeneratorType.class)
|
||||
public interface GeneratorTypeAccessor {
|
||||
@Accessor("VALUES")
|
||||
static List<GeneratorType> getValues() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Mutable
|
||||
@Accessor("displayName")
|
||||
void setDisplayName(Text translationKey);
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.block.entity;
|
||||
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -42,19 +41,19 @@ public abstract class SignBlockEntityMixin {
|
||||
public abstract void setTextOnRow(int row, Text text);
|
||||
|
||||
public void terra$setLine(int index, @NotNull String line) throws IndexOutOfBoundsException {
|
||||
setTextOnRow(index, new LiteralText(line));
|
||||
setTextOnRow(index, Text.literal(line));
|
||||
}
|
||||
|
||||
public @NotNull String[] terra$getLines() {
|
||||
String[] lines = new String[texts.length];
|
||||
for(int i = 0; i < texts.length; i++) {
|
||||
lines[i] = texts[i].asString();
|
||||
lines[i] = texts[i].getString();
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
public @NotNull String terra$getLine(int index) throws IndexOutOfBoundsException {
|
||||
return texts[index].asString();
|
||||
return texts[index].getString();
|
||||
}
|
||||
|
||||
public void terra$applyState(String state) {
|
||||
|
||||
@@ -44,9 +44,6 @@ public abstract class EntityMixin {
|
||||
@Shadow
|
||||
public abstract void teleport(double destX, double destY, double destZ);
|
||||
|
||||
@Shadow
|
||||
public abstract void sendSystemMessage(Text message, UUID senderUuid);
|
||||
|
||||
public Vector3 terra$position() {
|
||||
return FabricAdapter.adapt(blockPos);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.dfsek.terra.fabric.mixin.implementations.entity;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
@@ -49,7 +48,7 @@ public abstract class ServerCommandSourceMixin {
|
||||
public abstract net.minecraft.entity.@Nullable Entity getEntity();
|
||||
|
||||
public void terra$sendMessage(String message) {
|
||||
sendFeedback(new LiteralText(message), true);
|
||||
sendFeedback(Text.literal(message), true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.resource.ResourcePackManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.SaveLoader;
|
||||
import net.minecraft.server.WorldGenerationProgressListenerFactory;
|
||||
import net.minecraft.util.ApiServices;
|
||||
import net.minecraft.util.UserCache;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -23,13 +24,11 @@ import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
public class MinecraftServerMixin {
|
||||
@Inject(method = "<init>(Ljava/lang/Thread;Lnet/minecraft/world/level/storage/LevelStorage$Session;" +
|
||||
"Lnet/minecraft/resource/ResourcePackManager;Lnet/minecraft/server/SaveLoader;Ljava/net/Proxy;" +
|
||||
"Lcom/mojang/datafixers/DataFixer;Lcom/mojang/authlib/minecraft/MinecraftSessionService;" +
|
||||
"Lcom/mojang/authlib/GameProfileRepository;Lnet/minecraft/util/UserCache;" +
|
||||
"Lcom/mojang/datafixers/DataFixer;Lnet/minecraft/util/ApiServices;" +
|
||||
"Lnet/minecraft/server/WorldGenerationProgressListenerFactory;)V",
|
||||
at = @At("RETURN"))
|
||||
private void injectConstructor(Thread serverThread, LevelStorage.Session session, ResourcePackManager dataPackManager,
|
||||
SaveLoader saveLoader, Proxy proxy, DataFixer dataFixer, MinecraftSessionService sessionService,
|
||||
GameProfileRepository gameProfileRepo, UserCache userCache,
|
||||
SaveLoader saveLoader, Proxy proxy, DataFixer dataFixer, ApiServices apiServices,
|
||||
WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory, CallbackInfo ci) {
|
||||
FabricEntryPoint.getPlatform().setServer((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@@ -17,11 +17,8 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle.client;
|
||||
|
||||
import com.dfsek.terra.fabric.util.BiomeUtil;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.RunArgs;
|
||||
import net.minecraft.client.world.GeneratorType;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -29,8 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.generation.TerraGeneratorType;
|
||||
import com.dfsek.terra.fabric.mixin.access.GeneratorTypeAccessor;
|
||||
import com.dfsek.terra.fabric.util.BiomeUtil;
|
||||
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
@@ -43,12 +39,6 @@ public class MinecraftClientMixin {
|
||||
shift = At.Shift.BEFORE))
|
||||
public void injectConstructor(RunArgs args, CallbackInfo callbackInfo) {
|
||||
FabricEntryPoint.getPlatform().getEventManager().callEvent(new PlatformInitializationEvent());
|
||||
FabricEntryPoint.getPlatform().getConfigRegistry().forEach(pack -> {
|
||||
final GeneratorType generatorType = new TerraGeneratorType(pack);
|
||||
//noinspection ConstantConditions
|
||||
((GeneratorTypeAccessor) generatorType).setDisplayName(new LiteralText("Terra:" + pack.getID()));
|
||||
GeneratorTypeAccessor.getValues().add(1, generatorType);
|
||||
});
|
||||
BiomeUtil.registerBiomes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* This file is part of Terra.
|
||||
*
|
||||
* Terra is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Terra is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle.server;
|
||||
|
||||
import net.minecraft.server.dedicated.ServerPropertiesHandler;
|
||||
import net.minecraft.structure.StructureSet;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.dimension.DimensionOptions;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.GeneratorOptions;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.PlatformImpl;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
||||
|
||||
|
||||
@Mixin(GeneratorOptions.class)
|
||||
public abstract class GeneratorOptionsMixin {
|
||||
@Inject(method = "fromProperties(Lnet/minecraft/util/registry/DynamicRegistryManager;" +
|
||||
"Lnet/minecraft/server/dedicated/ServerPropertiesHandler$WorldGenProperties;)" +
|
||||
"Lnet/minecraft/world/gen/GeneratorOptions;",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private static void fromProperties(DynamicRegistryManager manager,
|
||||
ServerPropertiesHandler.WorldGenProperties properties,
|
||||
CallbackInfoReturnable<GeneratorOptions> cir) {
|
||||
if(properties.levelType() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformImpl main = FabricEntryPoint.getPlatform();
|
||||
|
||||
String levelType = properties.levelType();
|
||||
|
||||
if(levelType.toLowerCase(Locale.ROOT).startsWith("terra")) {
|
||||
String seedProperty = properties.levelSeed();
|
||||
long seed = new Random().nextLong();
|
||||
if(seedProperty != null) {
|
||||
try {
|
||||
long m = Long.parseLong(seedProperty);
|
||||
if(m != 0L) {
|
||||
seed = m;
|
||||
}
|
||||
} catch(NumberFormatException exception) {
|
||||
seed = seedProperty.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
boolean generateStructures = properties.generateStructures();
|
||||
Registry<DimensionType> dimensionTypes = manager.get(Registry.DIMENSION_TYPE_KEY);
|
||||
Registry<Biome> biomeRegistry = manager.get(Registry.BIOME_KEY);
|
||||
Registry<DimensionOptions> dimensionOptions = DimensionType.createDefaultDimensionOptions(manager, seed, false);
|
||||
|
||||
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = manager.get(Registry.CHUNK_GENERATOR_SETTINGS_KEY);
|
||||
RegistryEntry<ChunkGeneratorSettings>
|
||||
settingsSupplier = chunkGeneratorSettingsRegistry.getEntry(ChunkGeneratorSettings.OVERWORLD).orElseThrow();
|
||||
Registry<StructureSet> noiseRegistry = manager.get(Registry.STRUCTURE_SET_KEY);
|
||||
|
||||
String pack = levelType.substring(levelType.indexOf(":") + 1);
|
||||
|
||||
CheckedRegistry<ConfigPack> configRegistry = main.getConfigRegistry();
|
||||
ConfigPack config = configRegistry
|
||||
.getByID(pack)
|
||||
.or(() -> configRegistry.getByID(pack.toUpperCase(Locale.ROOT)))
|
||||
.orElseThrow(() -> new IllegalArgumentException("No such pack " + pack));
|
||||
|
||||
cir.setReturnValue(
|
||||
new GeneratorOptions(seed,
|
||||
generateStructures,
|
||||
false,
|
||||
GeneratorOptions
|
||||
.getRegistryWithReplacedOverworldGenerator(
|
||||
dimensionTypes,
|
||||
dimensionOptions,
|
||||
new FabricChunkGeneratorWrapper(noiseRegistry,
|
||||
new TerraBiomeSource(biomeRegistry, seed, config),
|
||||
seed,
|
||||
config,
|
||||
settingsSupplier))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,12 +137,9 @@ public final class BiomeUtil {
|
||||
effects.foliageColor(vanillaBiomeProperties.getFoliageColor());
|
||||
}
|
||||
|
||||
|
||||
builder.precipitation(Objects.requireNonNullElse(vanillaBiomeProperties.getPrecipitation(), vanilla.getPrecipitation()))
|
||||
.category(Objects.requireNonNullElse(vanillaBiomeProperties.getCategory(), vanilla.getCategory()));
|
||||
builder.precipitation(Objects.requireNonNullElse(vanillaBiomeProperties.getPrecipitation(), vanilla.getPrecipitation()));
|
||||
|
||||
} else {
|
||||
|
||||
effects.waterColor(vanilla.getWaterColor())
|
||||
.waterFogColor(vanilla.getWaterFogColor())
|
||||
.fogColor(vanilla.getFogColor())
|
||||
@@ -150,11 +147,9 @@ public final class BiomeUtil {
|
||||
vanilla.getEffects().getFoliageColor().ifPresent(effects::foliageColor);
|
||||
vanilla.getEffects().getGrassColor().ifPresent(effects::grassColor);
|
||||
|
||||
builder.precipitation(vanilla.getPrecipitation())
|
||||
.category(vanilla.getCategory());
|
||||
builder.precipitation(vanilla.getPrecipitation());
|
||||
}
|
||||
|
||||
|
||||
|
||||
return builder
|
||||
.temperature(vanilla.getTemperature())
|
||||
.downfall(vanilla.getDownfall())
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.2",
|
||||
"java": ">=17",
|
||||
"minecraft": "1.18.x"
|
||||
"minecraft": "1.19.x"
|
||||
},
|
||||
"accessWidener": "terra.accesswidener"
|
||||
}
|
||||
@@ -1,5 +1 @@
|
||||
accessWidener v1 named
|
||||
|
||||
extendable method net/minecraft/client/world/GeneratorType <init> (Ljava/lang/String;)V
|
||||
|
||||
accessible method net/minecraft/world/biome/Biome getCategory ()Lnet/minecraft/world/biome/Biome$Category;
|
||||
|
||||
@@ -37,11 +37,9 @@
|
||||
"lifecycle.RegistryMixin"
|
||||
],
|
||||
"client": [
|
||||
"access.GeneratorTypeAccessor",
|
||||
"lifecycle.client.MinecraftClientMixin"
|
||||
],
|
||||
"server": [
|
||||
"lifecycle.server.GeneratorOptionsMixin",
|
||||
"lifecycle.server.ServerMainMixin"
|
||||
],
|
||||
"injectors": {
|
||||
|
||||
Reference in New Issue
Block a user