mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 21:40:08 +00:00
clean up adapter
This commit is contained in:
1 parent
111eb6b593
commit
546431bbef
4 files changed
+61
-190
No files matched your search
+3
-3
@@ -64,7 +64,7 @@ import com.dfsek.terra.api.world.info.WorldProperties;
|
|||||||
import com.dfsek.terra.forge.config.PreLoadCompatibilityOptions;
|
import com.dfsek.terra.forge.config.PreLoadCompatibilityOptions;
|
||||||
import com.dfsek.terra.forge.data.Codecs;
|
import com.dfsek.terra.forge.data.Codecs;
|
||||||
import com.dfsek.terra.forge.mixin.access.StructureAccessorAccessor;
|
import com.dfsek.terra.forge.mixin.access.StructureAccessorAccessor;
|
||||||
import com.dfsek.terra.forge.util.FabricAdapter;
|
import com.dfsek.terra.forge.util.ForgeAdapter;
|
||||||
|
|
||||||
|
|
||||||
public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.ChunkGenerator implements GeneratorWrapper {
|
public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.ChunkGenerator implements GeneratorWrapper {
|
||||||
@@ -185,7 +185,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight(int x, int z, Type heightmap, HeightLimitView height, NoiseConfig noiseConfig) {
|
public int getHeight(int x, int z, Type heightmap, HeightLimitView height, NoiseConfig noiseConfig) {
|
||||||
WorldProperties properties = FabricAdapter.adapt(height, noiseConfig.getLegacyWorldSeed());
|
WorldProperties properties = ForgeAdapter.adapt(height, noiseConfig.getLegacyWorldSeed());
|
||||||
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||||
int min = height.getBottomY();
|
int min = height.getBottomY();
|
||||||
for(int y = height.getTopY() - 1; y >= min; y--) {
|
for(int y = height.getTopY() - 1; y >= min; y--) {
|
||||||
@@ -199,7 +199,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
@Override
|
@Override
|
||||||
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView height, NoiseConfig noiseConfig) {
|
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView height, NoiseConfig noiseConfig) {
|
||||||
BlockState[] array = new BlockState[height.getHeight()];
|
BlockState[] array = new BlockState[height.getHeight()];
|
||||||
WorldProperties properties = FabricAdapter.adapt(height, noiseConfig.getLegacyWorldSeed());
|
WorldProperties properties = ForgeAdapter.adapt(height, noiseConfig.getLegacyWorldSeed());
|
||||||
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||||
for(int y = height.getTopY() - 1; y >= height.getBottomY(); y--) {
|
for(int y = height.getTopY() - 1; y >= height.getBottomY(); y--) {
|
||||||
array[y - height.getBottomY()] = (BlockState) delegate.getBlock(properties, x, y, z, biomeProvider);
|
array[y - height.getBottomY()] = (BlockState) delegate.getBlock(properties, x, y, z, biomeProvider);
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.forge.mixin.implementations.terra.entity;
|
package com.dfsek.terra.forge.mixin.implementations.terra.entity;
|
||||||
|
|
||||||
import com.dfsek.terra.forge.util.FabricAdapter;
|
import com.dfsek.terra.forge.util.ForgeAdapter;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import org.spongepowered.asm.mixin.Implements;
|
import org.spongepowered.asm.mixin.Implements;
|
||||||
@@ -42,7 +42,7 @@ public abstract class EntityMixin {
|
|||||||
public abstract void teleport(double destX, double destY, double destZ);
|
public abstract void teleport(double destX, double destY, double destZ);
|
||||||
|
|
||||||
public Vector3 terra$position() {
|
public Vector3 terra$position() {
|
||||||
return FabricAdapter.adapt(blockPos);
|
return ForgeAdapter.adapt(blockPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void terra$position(Vector3 location) {
|
public void terra$position(Vector3 location) {
|
||||||
|
|||||||
@@ -1,185 +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.forge.util;
|
|
||||||
|
|
||||||
import net.minecraft.block.enums.BlockHalf;
|
|
||||||
import net.minecraft.block.enums.WallShape;
|
|
||||||
import net.minecraft.block.enums.WireConnection;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import net.minecraft.world.HeightLimitView;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.state.properties.enums.Axis;
|
|
||||||
import com.dfsek.terra.api.block.state.properties.enums.Half;
|
|
||||||
import com.dfsek.terra.api.block.state.properties.enums.RailShape;
|
|
||||||
import com.dfsek.terra.api.block.state.properties.enums.RedstoneConnection;
|
|
||||||
import com.dfsek.terra.api.block.state.properties.enums.WallHeight;
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
|
||||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
|
||||||
|
|
||||||
|
|
||||||
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 Vector3.of(pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Direction adapt(com.dfsek.terra.api.block.state.properties.enums.Direction direction) {
|
|
||||||
return switch(direction) {
|
|
||||||
case SOUTH -> Direction.SOUTH;
|
|
||||||
case NORTH -> Direction.NORTH;
|
|
||||||
case WEST -> Direction.WEST;
|
|
||||||
case EAST -> Direction.EAST;
|
|
||||||
case UP -> Direction.UP;
|
|
||||||
case DOWN -> Direction.DOWN;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WorldProperties adapt(HeightLimitView height, long seed) {
|
|
||||||
return new WorldProperties() {
|
|
||||||
@Override
|
|
||||||
public long getSeed() {
|
|
||||||
return seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxHeight() {
|
|
||||||
return height.getTopY();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMinHeight() {
|
|
||||||
return height.getBottomY();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getHandle() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static com.dfsek.terra.api.block.state.properties.enums.Direction adapt(Direction direction) {
|
|
||||||
return switch(direction) {
|
|
||||||
case SOUTH -> com.dfsek.terra.api.block.state.properties.enums.Direction.SOUTH;
|
|
||||||
case NORTH -> com.dfsek.terra.api.block.state.properties.enums.Direction.NORTH;
|
|
||||||
case WEST -> com.dfsek.terra.api.block.state.properties.enums.Direction.WEST;
|
|
||||||
case EAST -> com.dfsek.terra.api.block.state.properties.enums.Direction.EAST;
|
|
||||||
case UP -> com.dfsek.terra.api.block.state.properties.enums.Direction.UP;
|
|
||||||
case DOWN -> com.dfsek.terra.api.block.state.properties.enums.Direction.DOWN;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WallHeight adapt(WallShape shape) {
|
|
||||||
return switch(shape) {
|
|
||||||
case LOW -> WallHeight.LOW;
|
|
||||||
case NONE -> WallHeight.NONE;
|
|
||||||
case TALL -> WallHeight.TALL;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WallShape adapt(WallHeight shape) {
|
|
||||||
return switch(shape) {
|
|
||||||
case LOW -> WallShape.LOW;
|
|
||||||
case NONE -> WallShape.NONE;
|
|
||||||
case TALL -> WallShape.TALL;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RedstoneConnection adapt(WireConnection connection) {
|
|
||||||
return switch(connection) {
|
|
||||||
case NONE -> RedstoneConnection.NONE;
|
|
||||||
case UP -> RedstoneConnection.UP;
|
|
||||||
case SIDE -> RedstoneConnection.SIDE;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WireConnection adapt(RedstoneConnection connection) {
|
|
||||||
return switch(connection) {
|
|
||||||
case NONE -> WireConnection.NONE;
|
|
||||||
case UP -> WireConnection.UP;
|
|
||||||
case SIDE -> WireConnection.SIDE;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Half adapt(BlockHalf half) {
|
|
||||||
return switch(half) {
|
|
||||||
case BOTTOM -> Half.BOTTOM;
|
|
||||||
case TOP -> Half.TOP;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BlockHalf adapt(Half half) {
|
|
||||||
return switch(half) {
|
|
||||||
case TOP -> BlockHalf.TOP;
|
|
||||||
case BOTTOM -> BlockHalf.BOTTOM;
|
|
||||||
default -> throw new IllegalStateException();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RailShape adapt(net.minecraft.block.enums.RailShape railShape) {
|
|
||||||
return switch(railShape) {
|
|
||||||
case EAST_WEST -> RailShape.EAST_WEST;
|
|
||||||
case NORTH_EAST -> RailShape.NORTH_EAST;
|
|
||||||
case NORTH_WEST -> RailShape.NORTH_WEST;
|
|
||||||
case SOUTH_EAST -> RailShape.SOUTH_EAST;
|
|
||||||
case SOUTH_WEST -> RailShape.SOUTH_WEST;
|
|
||||||
case NORTH_SOUTH -> RailShape.NORTH_SOUTH;
|
|
||||||
case ASCENDING_EAST -> RailShape.ASCENDING_EAST;
|
|
||||||
case ASCENDING_NORTH -> RailShape.ASCENDING_NORTH;
|
|
||||||
case ASCENDING_SOUTH -> RailShape.ASCENDING_SOUTH;
|
|
||||||
case ASCENDING_WEST -> RailShape.ASCENDING_WEST;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static net.minecraft.block.enums.RailShape adapt(RailShape railShape) {
|
|
||||||
return switch(railShape) {
|
|
||||||
case EAST_WEST -> net.minecraft.block.enums.RailShape.EAST_WEST;
|
|
||||||
case NORTH_EAST -> net.minecraft.block.enums.RailShape.NORTH_EAST;
|
|
||||||
case NORTH_WEST -> net.minecraft.block.enums.RailShape.NORTH_WEST;
|
|
||||||
case SOUTH_EAST -> net.minecraft.block.enums.RailShape.SOUTH_EAST;
|
|
||||||
case SOUTH_WEST -> net.minecraft.block.enums.RailShape.SOUTH_WEST;
|
|
||||||
case NORTH_SOUTH -> net.minecraft.block.enums.RailShape.NORTH_SOUTH;
|
|
||||||
case ASCENDING_EAST -> net.minecraft.block.enums.RailShape.ASCENDING_EAST;
|
|
||||||
case ASCENDING_NORTH -> net.minecraft.block.enums.RailShape.ASCENDING_NORTH;
|
|
||||||
case ASCENDING_SOUTH -> net.minecraft.block.enums.RailShape.ASCENDING_SOUTH;
|
|
||||||
case ASCENDING_WEST -> net.minecraft.block.enums.RailShape.ASCENDING_WEST;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Axis adapt(Direction.Axis axis) {
|
|
||||||
return switch(axis) {
|
|
||||||
case X -> Axis.X;
|
|
||||||
case Y -> Axis.Y;
|
|
||||||
case Z -> Axis.Z;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Direction.Axis adapt(Axis axis) {
|
|
||||||
return switch(axis) {
|
|
||||||
case Z -> Direction.Axis.Z;
|
|
||||||
case Y -> Direction.Axis.Y;
|
|
||||||
case X -> Direction.Axis.X;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.forge.util;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.HeightLimitView;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.util.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||||
|
|
||||||
|
|
||||||
|
public final class ForgeAdapter {
|
||||||
|
|
||||||
|
public static Vector3 adapt(BlockPos pos) {
|
||||||
|
return Vector3.of(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WorldProperties adapt(HeightLimitView height, long seed) {
|
||||||
|
return new WorldProperties() {
|
||||||
|
@Override
|
||||||
|
public long getSeed() {
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHeight() {
|
||||||
|
return height.getTopY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinHeight() {
|
||||||
|
return height.getBottomY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getHandle() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user