mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
Merge remote-tracking branch 'origin/dev/fabric-mixins' into dev/fabric-mixins
This commit is contained in:
commit
ecba6e0843
@ -342,6 +342,6 @@ ij_json_wrap_long_lines = false
|
||||
indent_size = 2
|
||||
ij_yaml_keep_indents_on_empty_lines = true
|
||||
ij_yaml_keep_line_breaks = true
|
||||
ij_yaml_space_before_colon = true
|
||||
ij_yaml_space_before_colon = false
|
||||
ij_yaml_spaces_within_braces = true
|
||||
ij_yaml_spaces_within_brackets = true
|
||||
|
@ -1,6 +1,6 @@
|
||||
import com.dfsek.terra.getGitHash
|
||||
|
||||
val versionObj = Version("5", "2", "1", true)
|
||||
val versionObj = Version("5", "3", "0", true)
|
||||
|
||||
allprojects {
|
||||
version = versionObj
|
||||
|
@ -89,6 +89,12 @@ public class StructureScript {
|
||||
.registerFunction("ceil", new UnaryNumberFunctionBuilder(number -> FastMath.ceil(number.doubleValue())))
|
||||
.registerFunction("log", new UnaryNumberFunctionBuilder(number -> FastMath.log(number.doubleValue())))
|
||||
.registerFunction("round", new UnaryNumberFunctionBuilder(number -> FastMath.round(number.doubleValue())))
|
||||
.registerFunction("sin", new UnaryNumberFunctionBuilder(number -> FastMath.sin(number.doubleValue())))
|
||||
.registerFunction("cos", new UnaryNumberFunctionBuilder(number -> FastMath.cos(number.doubleValue())))
|
||||
.registerFunction("tan", new UnaryNumberFunctionBuilder(number -> FastMath.tan(number.doubleValue())))
|
||||
.registerFunction("asin", new UnaryNumberFunctionBuilder(number -> FastMath.asin(number.doubleValue())))
|
||||
.registerFunction("acos", new UnaryNumberFunctionBuilder(number -> FastMath.acos(number.doubleValue())))
|
||||
.registerFunction("atan", new UnaryNumberFunctionBuilder(number -> FastMath.atan(number.doubleValue())))
|
||||
.registerFunction("max", new BinaryNumberFunctionBuilder((number, number2) -> FastMath.max(number.doubleValue(), number2.doubleValue())))
|
||||
.registerFunction("min", new BinaryNumberFunctionBuilder((number, number2) -> FastMath.min(number.doubleValue(), number2.doubleValue())));
|
||||
|
||||
|
@ -33,7 +33,7 @@ dependencies {
|
||||
|
||||
configure<LoomGradleExtension> {
|
||||
accessWidener("src/main/resources/terra.accesswidener")
|
||||
refmapName = "terra.refmap.json"
|
||||
refmapName = "terra-refmap.json"
|
||||
}
|
||||
|
||||
val remapped = tasks.register<RemapJarTask>("remapShadedJar") {
|
||||
|
@ -1,16 +1,100 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.block.Axis;
|
||||
import com.dfsek.terra.api.platform.block.BlockFace;
|
||||
import com.dfsek.terra.api.platform.block.data.Bisected;
|
||||
import com.dfsek.terra.api.platform.block.data.Slab;
|
||||
import com.dfsek.terra.api.platform.block.data.Stairs;
|
||||
import com.dfsek.terra.api.platform.block.state.Container;
|
||||
import com.dfsek.terra.api.platform.block.state.MobSpawner;
|
||||
import com.dfsek.terra.api.platform.block.state.Sign;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.data.FabricDirectional;
|
||||
import com.dfsek.terra.fabric.block.data.FabricMultipleFacing;
|
||||
import com.dfsek.terra.fabric.block.data.FabricOrientable;
|
||||
import com.dfsek.terra.fabric.block.data.FabricRotatable;
|
||||
import com.dfsek.terra.fabric.block.data.FabricSlab;
|
||||
import com.dfsek.terra.fabric.block.data.FabricStairs;
|
||||
import com.dfsek.terra.fabric.block.data.FabricWaterlogged;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
import net.minecraft.block.entity.MobSpawnerBlockEntity;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.block.enums.BlockHalf;
|
||||
import net.minecraft.block.enums.SlabType;
|
||||
import net.minecraft.block.enums.StairShape;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class FabricAdapter {
|
||||
public static BlockPos adapt(Vector3 v) {
|
||||
return new BlockPos(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
}
|
||||
|
||||
public static Vector3 adapt(BlockPos pos) {
|
||||
return new Vector3(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
public static FabricBlockData adapt(BlockState state) {
|
||||
if(state.contains(Properties.STAIR_SHAPE)) return new FabricStairs(state);
|
||||
|
||||
if(state.contains(Properties.SLAB_TYPE)) return new FabricSlab(state);
|
||||
|
||||
if(state.contains(Properties.AXIS)) return new FabricOrientable(state, Properties.AXIS);
|
||||
if(state.contains(Properties.HORIZONTAL_AXIS)) return new FabricOrientable(state, Properties.HORIZONTAL_AXIS);
|
||||
|
||||
if(state.contains(Properties.ROTATION)) return new FabricRotatable(state);
|
||||
|
||||
if(state.contains(Properties.FACING)) return new FabricDirectional(state, Properties.FACING);
|
||||
if(state.contains(Properties.HOPPER_FACING)) return new FabricDirectional(state, Properties.HOPPER_FACING);
|
||||
if(state.contains(Properties.HORIZONTAL_FACING)) return new FabricDirectional(state, Properties.HORIZONTAL_FACING);
|
||||
|
||||
if(state.getProperties().containsAll(Arrays.asList(Properties.NORTH, Properties.SOUTH, Properties.EAST, Properties.WEST)))
|
||||
return new FabricMultipleFacing(state);
|
||||
if(state.contains(Properties.WATERLOGGED)) return new FabricWaterlogged(state);
|
||||
return new FabricBlockData(state);
|
||||
}
|
||||
|
||||
public static Direction adapt(BlockFace face) {
|
||||
switch(face) {
|
||||
case NORTH:
|
||||
return Direction.NORTH;
|
||||
case WEST:
|
||||
return Direction.WEST;
|
||||
case SOUTH:
|
||||
return Direction.SOUTH;
|
||||
case EAST:
|
||||
return Direction.EAST;
|
||||
case UP:
|
||||
return Direction.UP;
|
||||
case DOWN:
|
||||
return Direction.DOWN;
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal direction: " + face);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static com.dfsek.terra.api.platform.block.state.BlockState adapt(com.dfsek.terra.api.platform.block.Block block) {
|
||||
WorldAccess worldAccess = (WorldAccess) block.getLocation().getWorld();
|
||||
|
||||
BlockEntity entity = worldAccess.getBlockEntity(adapt(block.getLocation().toVector()));
|
||||
if(entity instanceof SignBlockEntity) {
|
||||
return (Sign) entity;
|
||||
} else if(entity instanceof MobSpawnerBlockEntity) {
|
||||
return (MobSpawner) entity;
|
||||
} else if(entity instanceof LootableContainerBlockEntity) {
|
||||
return (Container) entity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final class FabricEnumAdapter {
|
||||
public static Stairs.Shape adapt(StairShape shape) {
|
||||
switch(shape) {
|
||||
case OUTER_RIGHT:
|
||||
@ -99,25 +183,6 @@ public final class FabricEnumAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public static Direction adapt(BlockFace face) {
|
||||
switch(face) {
|
||||
case SOUTH:
|
||||
return Direction.SOUTH;
|
||||
case NORTH:
|
||||
return Direction.NORTH;
|
||||
case EAST:
|
||||
return Direction.EAST;
|
||||
case WEST:
|
||||
return Direction.WEST;
|
||||
case UP:
|
||||
return Direction.UP;
|
||||
case DOWN:
|
||||
return Direction.DOWN;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
public static SlabType adapt(Slab.Type type) {
|
||||
switch(type) {
|
||||
case DOUBLE:
|
@ -39,10 +39,11 @@ import com.dfsek.terra.config.pack.ConfigPack;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.fabric.handle.FabricItemHandle;
|
||||
import com.dfsek.terra.fabric.handle.FabricWorldHandle;
|
||||
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
|
||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.world.features.PopulatorFeature;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.mixin.access.BiomeEffectsAccessor;
|
||||
import com.dfsek.terra.fabric.mixin.access.GeneratorTypeAccessor;
|
||||
import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.generation.PopulatorFeature;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.profiler.Profiler;
|
||||
import com.dfsek.terra.profiler.ProfilerImpl;
|
||||
import com.dfsek.terra.registry.exception.DuplicateEntryException;
|
||||
@ -259,23 +260,23 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
generationSettings.feature(GenerationStep.Feature.VEGETAL_DECORATION, POPULATOR_CONFIGURED_FEATURE);
|
||||
|
||||
|
||||
BiomeEffectsAccessor accessor = (BiomeEffectsAccessor) vanilla.getEffects();
|
||||
BiomeEffects.Builder effects = new BiomeEffects.Builder()
|
||||
.waterColor(colors.getOrDefault("water", vanilla.getEffects().waterColor))
|
||||
.waterFogColor(colors.getOrDefault("water-fog", vanilla.getEffects().waterFogColor))
|
||||
.fogColor(colors.getOrDefault("fog", vanilla.getEffects().fogColor))
|
||||
.skyColor(colors.getOrDefault("sky", vanilla.getEffects().skyColor))
|
||||
.grassColorModifier(vanilla.getEffects().grassColorModifier);
|
||||
.waterColor(colors.getOrDefault("water", accessor.getWaterColor()))
|
||||
.waterFogColor(colors.getOrDefault("water-fog", accessor.getWaterFogColor()))
|
||||
.fogColor(colors.getOrDefault("fog", accessor.getFogColor()))
|
||||
.skyColor(colors.getOrDefault("sky", accessor.getSkyColor()))
|
||||
.grassColorModifier(accessor.getGrassColorModifier());
|
||||
|
||||
if(colors.containsKey("grass")) {
|
||||
effects.grassColor(colors.get("grass"));
|
||||
} else {
|
||||
vanilla.getEffects().grassColor.ifPresent(effects::grassColor);
|
||||
accessor.getGrassColor().ifPresent(effects::grassColor);
|
||||
}
|
||||
vanilla.getEffects().foliageColor.ifPresent(effects::foliageColor);
|
||||
if(colors.containsKey("foliage")) {
|
||||
effects.foliageColor(colors.get("foliage"));
|
||||
} else {
|
||||
vanilla.getEffects().foliageColor.ifPresent(effects::foliageColor);
|
||||
accessor.getFoliageColor().ifPresent(effects::foliageColor);
|
||||
}
|
||||
|
||||
return new Biome.Builder()
|
||||
@ -328,7 +329,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
};
|
||||
//noinspection ConstantConditions
|
||||
((GeneratorTypeAccessor) generatorType).setTranslationKey(new LiteralText("Terra:" + pack.getTemplate().getID()));
|
||||
GeneratorTypeAccessor.getVALUES().add(generatorType);
|
||||
GeneratorTypeAccessor.getValues().add(generatorType);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.fabric.world.block;
|
||||
package com.dfsek.terra.fabric.block;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
@ -7,7 +7,7 @@ import com.dfsek.terra.api.platform.block.BlockFace;
|
||||
import com.dfsek.terra.api.platform.block.BlockType;
|
||||
import com.dfsek.terra.api.platform.block.state.BlockState;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldAccess;
|
@ -1,11 +1,10 @@
|
||||
package com.dfsek.terra.fabric.world.block;
|
||||
package com.dfsek.terra.fabric.block;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.BlockType;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.mixin.access.StateAccessor;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.state.State;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
@ -41,7 +40,7 @@ public class FabricBlockData implements BlockData {
|
||||
StringBuilder data = new StringBuilder(Registry.BLOCK.getId(delegate.getBlock()).toString());
|
||||
if(!delegate.getEntries().isEmpty()) {
|
||||
data.append('[');
|
||||
data.append(delegate.getEntries().entrySet().stream().map(State.PROPERTY_MAP_PRINTER).collect(Collectors.joining(",")));
|
||||
data.append(delegate.getEntries().entrySet().stream().map(StateAccessor.getPropertyMapPrinter()).collect(Collectors.joining(",")));
|
||||
data.append(']');
|
||||
}
|
||||
return data.toString();
|
@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.data.AnaloguePowerable;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
/**
|
@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockFace;
|
||||
import com.dfsek.terra.api.platform.block.data.Directional;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockFace;
|
||||
import com.dfsek.terra.api.platform.block.data.MultipleFacing;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.Axis;
|
||||
import com.dfsek.terra.api.platform.block.data.Orientable;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.math.Direction;
|
||||
@ -26,11 +27,11 @@ public class FabricOrientable extends FabricBlockData implements Orientable {
|
||||
|
||||
@Override
|
||||
public Axis getAxis() {
|
||||
return FabricEnumAdapter.adapt(getHandle().get(property));
|
||||
return FabricAdapter.adapt(getHandle().get(property));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAxis(Axis axis) {
|
||||
delegate = delegate.with(property, FabricEnumAdapter.adapt(axis));
|
||||
delegate = delegate.with(property, FabricAdapter.adapt(axis));
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockFace;
|
||||
import com.dfsek.terra.api.platform.block.data.Rotatable;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.data.Slab;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
||||
@ -11,11 +12,11 @@ public class FabricSlab extends FabricWaterlogged implements Slab {
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return FabricEnumAdapter.adapt(delegate.get(Properties.SLAB_TYPE));
|
||||
return FabricAdapter.adapt(delegate.get(Properties.SLAB_TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
delegate = delegate.with(Properties.SLAB_TYPE, FabricEnumAdapter.adapt(type));
|
||||
delegate = delegate.with(Properties.SLAB_TYPE, FabricAdapter.adapt(type));
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockFace;
|
||||
import com.dfsek.terra.api.platform.block.data.Stairs;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
||||
@ -12,31 +13,31 @@ public class FabricStairs extends FabricWaterlogged implements Stairs {
|
||||
|
||||
@Override
|
||||
public Shape getShape() {
|
||||
return FabricEnumAdapter.adapt(getHandle().get(Properties.STAIR_SHAPE));
|
||||
return FabricAdapter.adapt(getHandle().get(Properties.STAIR_SHAPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShape(Shape shape) {
|
||||
super.delegate = getHandle().with(Properties.STAIR_SHAPE, FabricEnumAdapter.adapt(shape));
|
||||
super.delegate = getHandle().with(Properties.STAIR_SHAPE, FabricAdapter.adapt(shape));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Half getHalf() {
|
||||
return FabricEnumAdapter.adapt(getHandle().get(Properties.BLOCK_HALF));
|
||||
return FabricAdapter.adapt(getHandle().get(Properties.BLOCK_HALF));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHalf(Half half) {
|
||||
super.delegate = getHandle().with(Properties.BLOCK_HALF, FabricEnumAdapter.adapt(half));
|
||||
super.delegate = getHandle().with(Properties.BLOCK_HALF, FabricAdapter.adapt(half));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFace getFacing() {
|
||||
return FabricEnumAdapter.adapt(getHandle().get(Properties.HORIZONTAL_FACING));
|
||||
return FabricAdapter.adapt(getHandle().get(Properties.HORIZONTAL_FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(BlockFace facing) {
|
||||
super.delegate = getHandle().with(Properties.HORIZONTAL_FACING, FabricEnumAdapter.adapt(facing));
|
||||
super.delegate = getHandle().with(Properties.HORIZONTAL_FACING, FabricAdapter.adapt(facing));
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.fabric.world.block.data;
|
||||
package com.dfsek.terra.fabric.block.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.data.Waterlogged;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.fabric.world.generator;
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkData;
|
||||
@ -7,7 +7,6 @@ import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.config.pack.ConfigPack;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
|
||||
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.fabric.world.features;
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.fabric.world;
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
@ -3,7 +3,6 @@ package com.dfsek.terra.fabric.handle;
|
||||
import com.dfsek.terra.api.platform.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.platform.inventory.Item;
|
||||
import com.dfsek.terra.api.platform.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.argument.ItemStackArgumentType;
|
||||
|
@ -2,8 +2,8 @@ package com.dfsek.terra.fabric.handle;
|
||||
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -1,37 +0,0 @@
|
||||
package com.dfsek.terra.fabric.inventory;
|
||||
|
||||
import com.dfsek.terra.api.platform.inventory.Inventory;
|
||||
import com.dfsek.terra.api.platform.inventory.ItemStack;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import net.minecraft.item.Items;
|
||||
|
||||
public class FabricInventory implements Inventory {
|
||||
private final net.minecraft.inventory.Inventory delegate;
|
||||
|
||||
public FabricInventory(net.minecraft.inventory.Inventory delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.inventory.Inventory getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return delegate.size();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public ItemStack getItem(int slot) {
|
||||
net.minecraft.item.ItemStack itemStack = delegate.getStack(slot);
|
||||
return itemStack.getItem() == Items.AIR ? null : (ItemStack) (Object) itemStack;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void setItem(int slot, ItemStack newStack) {
|
||||
delegate.setStack(slot, (net.minecraft.item.ItemStack) (Object) newStack);
|
||||
}
|
||||
}
|
@ -2,8 +2,8 @@ package com.dfsek.terra.fabric.mixin;
|
||||
|
||||
import com.dfsek.terra.config.pack.ConfigPack;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.generation.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.dfsek.terra.fabric.mixin.access;
|
||||
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(BiomeEffects.class)
|
||||
public interface BiomeEffectsAccessor {
|
||||
@Accessor("fogColor")
|
||||
int getFogColor();
|
||||
|
||||
@Accessor("waterColor")
|
||||
int getWaterColor();
|
||||
|
||||
@Accessor("waterFogColor")
|
||||
int getWaterFogColor();
|
||||
|
||||
@Accessor("skyColor")
|
||||
int getSkyColor();
|
||||
|
||||
@Accessor("foliageColor")
|
||||
Optional<Integer> getFoliageColor();
|
||||
|
||||
@Accessor("grassColor")
|
||||
Optional<Integer> getGrassColor();
|
||||
|
||||
@Accessor("grassColorModifier")
|
||||
BiomeEffects.GrassColorModifier getGrassColorModifier();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.fabric.mixin;
|
||||
package com.dfsek.terra.fabric.mixin.access;
|
||||
|
||||
import net.minecraft.client.world.GeneratorType;
|
||||
import net.minecraft.text.Text;
|
||||
@ -10,12 +10,12 @@ import java.util.List;
|
||||
|
||||
@Mixin(GeneratorType.class)
|
||||
public interface GeneratorTypeAccessor {
|
||||
@Accessor
|
||||
static List<GeneratorType> getVALUES() {
|
||||
@Accessor("VALUES")
|
||||
static List<GeneratorType> getValues() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Mutable
|
||||
@Accessor
|
||||
@Accessor("translationKey")
|
||||
void setTranslationKey(Text translationKey);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.dfsek.terra.fabric.mixin.access;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.MobSpawnerLogic;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(MobSpawnerLogic.class)
|
||||
public interface MobSpawnerLogicAccessor {
|
||||
@Invoker("getEntityId")
|
||||
Identifier callGetEntityId();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.dfsek.terra.fabric.mixin.access;
|
||||
|
||||
import net.minecraft.state.State;
|
||||
import net.minecraft.state.property.Property;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(State.class)
|
||||
public interface StateAccessor {
|
||||
@Accessor("PROPERTY_MAP_PRINTER")
|
||||
static Function<Map.Entry<Property<?>, Comparable<?>>, String> getPropertyMapPrinter() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Biome.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.world.Biome.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.world.Biome.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class BiomeMixin {
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
|
@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(ChunkGenerator.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.world.generator.ChunkGenerator.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.world.generator.ChunkGenerator.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ChunkGeneratorMixin {
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
|
@ -10,8 +10,6 @@ import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -21,12 +19,12 @@ import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(ConfiguredFeature.class)
|
||||
@Implements(@Interface(iface = Tree.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = Tree.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ConfiguredFeatureMixin {
|
||||
@Shadow
|
||||
public abstract boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos);
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@SuppressWarnings({"ConstantConditions", "try"})
|
||||
public boolean terra$plant(Location l, Random r) {
|
||||
String id = BuiltinRegistries.CONFIGURED_FEATURE.getId((ConfiguredFeature<?, ?>) (Object) this).toString();
|
||||
try(ProfileFrame ignore = TerraFabricPlugin.getInstance().getProfiler().profile("fabric_tree:" + id.toLowerCase(Locale.ROOT))) {
|
||||
|
@ -3,8 +3,8 @@ package com.dfsek.terra.fabric.mixin.implementations.block;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.state.BlockState;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.block.FabricBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(BlockEntity.class)
|
||||
@Implements(@Interface(iface = BlockState.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = BlockState.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class BlockEntityMixin {
|
||||
@Shadow
|
||||
protected BlockPos pos;
|
||||
|
@ -2,7 +2,7 @@ package com.dfsek.terra.fabric.mixin.implementations.block;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.BlockType;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(Block.class)
|
||||
@Implements(@Interface(iface = BlockType.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = BlockType.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class BlockMixin {
|
||||
@Shadow
|
||||
private BlockState defaultState;
|
||||
|
@ -2,7 +2,6 @@ package com.dfsek.terra.fabric.mixin.implementations.block.state;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.state.Container;
|
||||
import com.dfsek.terra.api.platform.inventory.Inventory;
|
||||
import com.dfsek.terra.fabric.inventory.FabricInventory;
|
||||
import com.dfsek.terra.fabric.mixin.implementations.block.BlockEntityMixin;
|
||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
@ -10,10 +9,10 @@ import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(LootableContainerBlockEntity.class)
|
||||
@Implements(@Interface(iface = Container.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = Container.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class LootableContainerBlockEntityMixin extends BlockEntityMixin {
|
||||
public Inventory terra$getInventory() {
|
||||
return new FabricInventory(((LootableContainerBlockEntity) (Object) this));
|
||||
return (Inventory) this;
|
||||
}
|
||||
|
||||
public Object terra$getHandle() {
|
||||
|
@ -4,6 +4,7 @@ import com.dfsek.terra.api.platform.block.state.MobSpawner;
|
||||
import com.dfsek.terra.api.platform.block.state.SerialState;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.mixin.access.MobSpawnerLogicAccessor;
|
||||
import net.minecraft.block.entity.MobSpawnerBlockEntity;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.MobSpawnerLogic;
|
||||
@ -14,13 +15,13 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(MobSpawnerBlockEntity.class)
|
||||
@Implements(@Interface(iface = MobSpawner.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = MobSpawner.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class MobSpawnerBlockEntityMixin {
|
||||
@Shadow
|
||||
public abstract MobSpawnerLogic getLogic();
|
||||
|
||||
public EntityType terra$getSpawnedType() {
|
||||
return (EntityType) Registry.ENTITY_TYPE.get(getLogic().getEntityId());
|
||||
return (EntityType) Registry.ENTITY_TYPE.get(((MobSpawnerLogicAccessor) getLogic()).callGetEntityId());
|
||||
}
|
||||
|
||||
public void terra$setSpawnedType(@NotNull EntityType creatureType) {
|
||||
|
@ -12,7 +12,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(SignBlockEntity.class)
|
||||
@Implements(@Interface(iface = Sign.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = Sign.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class SignBlockEntityMixin {
|
||||
@Shadow
|
||||
public abstract void setTextOnRow(int row, Text text);
|
||||
|
@ -4,8 +4,8 @@ import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ChunkRegion.class)
|
||||
@Implements(@Interface(iface = Chunk.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = Chunk.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ChunkRegionMixin {
|
||||
@Final
|
||||
@Shadow
|
||||
|
@ -4,8 +4,8 @@ import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(WorldChunk.class)
|
||||
@Implements(@Interface(iface = Chunk.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = Chunk.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class WorldChunkMixin {
|
||||
@Final
|
||||
@Shadow
|
||||
|
@ -2,7 +2,7 @@ package com.dfsek.terra.fabric.mixin.implementations.chunk.data;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkData;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.ProtoChunk;
|
||||
@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ProtoChunk.class)
|
||||
@Implements(@Interface(iface = ChunkData.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = ChunkData.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ProtoChunkMixin {
|
||||
@Shadow
|
||||
public abstract BlockState getBlockState(BlockPos pos);
|
||||
|
@ -2,7 +2,7 @@ package com.dfsek.terra.fabric.mixin.implementations.entity;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.FabricAdapter;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.Entity.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.Entity.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class EntityMixin {
|
||||
@Shadow
|
||||
public net.minecraft.world.World world;
|
||||
@ -41,7 +41,7 @@ public abstract class EntityMixin {
|
||||
teleport(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
public World terra$getWorld() {
|
||||
return (World) world;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(EntityType.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.EntityType.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.EntityType.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class EntityTypeMixin {
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
|
@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
@Implements(@Interface(iface = Player.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = Player.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class PlayerEntityMixin extends EntityMixin {
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ServerCommandSource.class)
|
||||
@Implements(@Interface(iface = CommandSender.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = CommandSender.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ServerCommandSourceMixin {
|
||||
@Shadow
|
||||
public abstract void sendFeedback(Text message, boolean broadcastToOps);
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.inventory;
|
||||
|
||||
import com.dfsek.terra.api.platform.inventory.Inventory;
|
||||
import com.dfsek.terra.api.platform.inventory.ItemStack;
|
||||
import net.minecraft.block.entity.LockableContainerBlockEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(LockableContainerBlockEntity.class)
|
||||
@Implements(@Interface(iface = Inventory.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public class LockableContainerBlockEntityMixin {
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public int terra$getSize() {
|
||||
return ((LockableContainerBlockEntity) (Object) this).size();
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public ItemStack terra$getItem(int slot) {
|
||||
net.minecraft.item.ItemStack itemStack = ((LockableContainerBlockEntity) (Object) this).getStack(slot);
|
||||
return itemStack.getItem() == Items.AIR ? null : (ItemStack) (Object) itemStack;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void terra$setItem(int slot, ItemStack newStack) {
|
||||
((LockableContainerBlockEntity) (Object) this).setStack(slot, (net.minecraft.item.ItemStack) (Object) newStack);
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(Item.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.Item.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.Item.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ItemMixin {
|
||||
@Shadow
|
||||
public abstract int getMaxDamage();
|
||||
|
@ -3,13 +3,16 @@ package com.dfsek.terra.fabric.mixin.implementations.inventory.item;
|
||||
import com.dfsek.terra.api.platform.inventory.Item;
|
||||
import com.dfsek.terra.api.platform.inventory.item.ItemMeta;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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;
|
||||
|
||||
@Mixin(ItemStack.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.ItemStack.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.ItemStack.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ItemStackMixin {
|
||||
@Shadow
|
||||
public abstract int getCount();
|
||||
@ -24,7 +27,7 @@ public abstract class ItemStackMixin {
|
||||
public abstract boolean isDamageable();
|
||||
|
||||
@Shadow
|
||||
public abstract ItemStack copy();
|
||||
public abstract void setTag(@Nullable CompoundTag tag);
|
||||
|
||||
public int terra$getAmount() {
|
||||
return getCount();
|
||||
@ -34,7 +37,7 @@ public abstract class ItemStackMixin {
|
||||
setCount(i);
|
||||
}
|
||||
|
||||
public Item getType() {
|
||||
public Item terra$getType() {
|
||||
return (Item) getItem();
|
||||
}
|
||||
|
||||
@ -42,11 +45,17 @@ public abstract class ItemStackMixin {
|
||||
return (ItemMeta) this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void terra$setItemMeta(ItemMeta meta) {
|
||||
|
||||
setTag(((ItemStack) (Object) meta).getTag());
|
||||
}
|
||||
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public boolean terra$isDamageable() {
|
||||
return isDamageable();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import java.util.Objects;
|
||||
|
||||
@Mixin(Enchantment.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.item.Enchantment.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.item.Enchantment.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class EnchantmentMixin {
|
||||
@Shadow
|
||||
public abstract boolean isAcceptableItem(net.minecraft.item.ItemStack stack);
|
||||
|
@ -4,16 +4,33 @@ import com.dfsek.terra.api.platform.inventory.item.Damageable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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;
|
||||
|
||||
@Mixin(ItemStack.class)
|
||||
@Implements(@Interface(iface = Damageable.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = Damageable.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ItemStackDamageableMixin {
|
||||
@Shadow
|
||||
public abstract boolean isDamaged();
|
||||
|
||||
@Shadow
|
||||
public abstract int getDamage();
|
||||
|
||||
@Shadow
|
||||
public abstract void setDamage(int damage);
|
||||
|
||||
public boolean terra$hasDamage() {
|
||||
return isDamaged();
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public void terra$setDamage(int damage) {
|
||||
setDamage(damage);
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public int terra$getDamage() {
|
||||
return getDamage();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
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;
|
||||
|
||||
@ -16,7 +17,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(ItemStack.class)
|
||||
@Implements(@Interface(iface = ItemMeta.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = ItemMeta.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ItemStackMetaMixin {
|
||||
@Shadow
|
||||
public abstract boolean hasEnchantments();
|
||||
@ -31,6 +32,7 @@ public abstract class ItemStackMetaMixin {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Intrinsic(displace = true)
|
||||
public Map<Enchantment, Integer> terra$getEnchantments() {
|
||||
if(!hasEnchantments()) return Collections.emptyMap();
|
||||
Map<Enchantment, Integer> map = new HashMap<>();
|
||||
|
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Mixins in this package implement Terra
|
||||
* interfaces in Minecraft classes.
|
||||
*/
|
||||
package com.dfsek.terra.fabric.mixin.implementations;
|
@ -9,28 +9,35 @@ import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
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;
|
||||
|
||||
@Mixin(ChunkRegion.class)
|
||||
@Implements(@Interface(iface = World.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = World.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ChunkRegionMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerWorld world;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private long seed;
|
||||
|
||||
public int terra$getMaxHeight() {
|
||||
return ((ChunkRegion) (Object) this).getDimensionHeight();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ChunkGenerator terra$getGenerator() {
|
||||
return (ChunkGenerator) ((ChunkRegion) (Object) this).toServerWorld().getChunkManager().getChunkGenerator();
|
||||
}
|
||||
@ -43,6 +50,7 @@ public abstract class ChunkRegionMixin {
|
||||
return new FabricBlock(new BlockPos(x, y, z), ((ChunkRegion) (Object) this));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Entity terra$spawnEntity(Location location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ChunkRegion) (Object) this).toServerWorld());
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
@ -50,6 +58,11 @@ public abstract class ChunkRegionMixin {
|
||||
return (Entity) entity;
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public long terra$getSeed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
public int terra$getMinHeight() {
|
||||
return 0;
|
||||
}
|
||||
@ -80,4 +93,17 @@ public abstract class ChunkRegionMixin {
|
||||
public int hashCode() {
|
||||
return world.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden in the same manner as {@link #hashCode()}
|
||||
*
|
||||
* @param other Another object
|
||||
* @return Whether this world is the same as other.
|
||||
* @see #hashCode()
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if(!(other instanceof ServerWorldAccess)) return false;
|
||||
return world.equals(((ServerWorldAccess) other).toServerWorld());
|
||||
}
|
||||
}
|
||||
|
@ -9,17 +9,23 @@ import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
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;
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
@Implements(@Interface(iface = World.class, prefix = "terra$"))
|
||||
@Implements(@Interface(iface = World.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class ServerWorldMixin {
|
||||
@Shadow
|
||||
public abstract long getSeed();
|
||||
|
||||
public int terra$getMaxHeight() {
|
||||
return ((ServerWorld) (Object) this).getDimensionHeight();
|
||||
}
|
||||
@ -43,6 +49,11 @@ public abstract class ServerWorldMixin {
|
||||
return (Entity) entity;
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public long terra$getSeed() {
|
||||
return getSeed();
|
||||
}
|
||||
|
||||
public int terra$getMinHeight() {
|
||||
return 0;
|
||||
}
|
||||
@ -58,4 +69,18 @@ public abstract class ServerWorldMixin {
|
||||
public TerraChunkGenerator terra$getTerraGenerator() {
|
||||
return ((FabricChunkGeneratorWrapper) terra$getGenerator()).getHandle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden in the same manner as {@link ChunkRegionMixin#hashCode()}
|
||||
*
|
||||
* @param other Another object
|
||||
* @return Whether this world is the same as other.
|
||||
* @see ChunkRegionMixin#hashCode()
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if(!(other instanceof ServerWorldAccess)) return false;
|
||||
return (ServerWorldAccess) this == (((ServerWorldAccess) other).toServerWorld());
|
||||
}
|
||||
}
|
||||
|
@ -1,90 +0,0 @@
|
||||
package com.dfsek.terra.fabric.world;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.block.BlockFace;
|
||||
import com.dfsek.terra.api.platform.block.state.Container;
|
||||
import com.dfsek.terra.api.platform.block.state.MobSpawner;
|
||||
import com.dfsek.terra.api.platform.block.state.Sign;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricDirectional;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricMultipleFacing;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricOrientable;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricRotatable;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricSlab;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricStairs;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricWaterlogged;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
import net.minecraft.block.entity.MobSpawnerBlockEntity;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class FabricAdapter {
|
||||
public static BlockPos adapt(Vector3 v) {
|
||||
return new BlockPos(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
}
|
||||
|
||||
public static Vector3 adapt(BlockPos pos) {
|
||||
return new Vector3(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
public static FabricBlockData adapt(BlockState state) {
|
||||
if(state.contains(Properties.STAIR_SHAPE)) return new FabricStairs(state);
|
||||
|
||||
if(state.contains(Properties.SLAB_TYPE)) return new FabricSlab(state);
|
||||
|
||||
if(state.contains(Properties.AXIS)) return new FabricOrientable(state, Properties.AXIS);
|
||||
if(state.contains(Properties.HORIZONTAL_AXIS)) return new FabricOrientable(state, Properties.HORIZONTAL_AXIS);
|
||||
|
||||
if(state.contains(Properties.ROTATION)) return new FabricRotatable(state);
|
||||
|
||||
if(state.contains(Properties.FACING)) return new FabricDirectional(state, Properties.FACING);
|
||||
if(state.contains(Properties.HOPPER_FACING)) return new FabricDirectional(state, Properties.HOPPER_FACING);
|
||||
if(state.contains(Properties.HORIZONTAL_FACING)) return new FabricDirectional(state, Properties.HORIZONTAL_FACING);
|
||||
|
||||
if(state.getProperties().containsAll(Arrays.asList(Properties.NORTH, Properties.SOUTH, Properties.EAST, Properties.WEST)))
|
||||
return new FabricMultipleFacing(state);
|
||||
if(state.contains(Properties.WATERLOGGED)) return new FabricWaterlogged(state);
|
||||
return new FabricBlockData(state);
|
||||
}
|
||||
|
||||
public static Direction adapt(BlockFace face) {
|
||||
switch(face) {
|
||||
case NORTH:
|
||||
return Direction.NORTH;
|
||||
case WEST:
|
||||
return Direction.WEST;
|
||||
case SOUTH:
|
||||
return Direction.SOUTH;
|
||||
case EAST:
|
||||
return Direction.EAST;
|
||||
case UP:
|
||||
return Direction.UP;
|
||||
case DOWN:
|
||||
return Direction.DOWN;
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal direction: " + face);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static com.dfsek.terra.api.platform.block.state.BlockState adapt(com.dfsek.terra.api.platform.block.Block block) {
|
||||
WorldAccess worldAccess = (WorldAccess) block.getLocation().getWorld();
|
||||
|
||||
BlockEntity entity = worldAccess.getBlockEntity(adapt(block.getLocation().toVector()));
|
||||
if(entity instanceof SignBlockEntity) {
|
||||
return (Sign) entity;
|
||||
} else if(entity instanceof MobSpawnerBlockEntity) {
|
||||
return (MobSpawner) entity;
|
||||
} else if(entity instanceof LootableContainerBlockEntity) {
|
||||
return (Container) entity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,19 +1,3 @@
|
||||
accessWidener v1 named
|
||||
|
||||
extendable method net/minecraft/client/world/GeneratorType <init> (Ljava/lang/String;)V
|
||||
|
||||
accessible field net/minecraft/server/world/ServerWorld worldProperties Lnet/minecraft/world/level/ServerWorldProperties;
|
||||
|
||||
accessible method net/minecraft/world/MobSpawnerLogic getEntityId ()Lnet/minecraft/util/Identifier;
|
||||
|
||||
accessible field net/minecraft/state/State PROPERTY_MAP_PRINTER Ljava/util/function/Function;
|
||||
|
||||
|
||||
accessible field net/minecraft/world/biome/BiomeEffects fogColor I
|
||||
accessible field net/minecraft/world/biome/BiomeEffects waterColor I
|
||||
accessible field net/minecraft/world/biome/BiomeEffects waterFogColor I
|
||||
accessible field net/minecraft/world/biome/BiomeEffects skyColor I
|
||||
|
||||
accessible field net/minecraft/world/biome/BiomeEffects foliageColor Ljava/util/Optional;
|
||||
accessible field net/minecraft/world/biome/BiomeEffects grassColor Ljava/util/Optional;
|
||||
accessible field net/minecraft/world/biome/BiomeEffects grassColorModifier Lnet/minecraft/world/biome/BiomeEffects$GrassColorModifier;
|
||||
|
@ -5,6 +5,9 @@
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"GeneratorOptionsMixin",
|
||||
"access.BiomeEffectsAccessor",
|
||||
"access.MobSpawnerLogicAccessor",
|
||||
"access.StateAccessor",
|
||||
"implementations.BiomeMixin",
|
||||
"implementations.ChunkGeneratorMixin",
|
||||
"implementations.ConfiguredFeatureMixin",
|
||||
@ -20,6 +23,7 @@
|
||||
"implementations.entity.EntityTypeMixin",
|
||||
"implementations.entity.PlayerEntityMixin",
|
||||
"implementations.entity.ServerCommandSourceMixin",
|
||||
"implementations.inventory.LockableContainerBlockEntityMixin",
|
||||
"implementations.inventory.item.ItemMixin",
|
||||
"implementations.inventory.item.ItemStackMixin",
|
||||
"implementations.inventory.meta.EnchantmentMixin",
|
||||
@ -29,7 +33,7 @@
|
||||
"implementations.world.ServerWorldMixin"
|
||||
],
|
||||
"client": [
|
||||
"GeneratorTypeAccessor"
|
||||
"access.GeneratorTypeAccessor"
|
||||
],
|
||||
"server": [],
|
||||
"injectors": {
|
||||
|
@ -20,7 +20,7 @@ apply(plugin = "net.minecraftforge.gradle")
|
||||
apply(plugin = "org.spongepowered.mixin")
|
||||
|
||||
configure<org.spongepowered.asm.gradle.plugins.MixinExtension> {
|
||||
add(sourceSets.main.get(), "terra.refmap.json")
|
||||
add(sourceSets.main.get(), "terra-refmap.json")
|
||||
}
|
||||
|
||||
plugins {
|
||||
|
@ -2,7 +2,7 @@
|
||||
"required": true,
|
||||
"package": "com.dfsek.terra.forge.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"refmap": "terra.refmap.json",
|
||||
"refmap": "terra-refmap.json",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user