Continue migration

This commit is contained in:
Aleksey 2021-04-12 16:34:13 +03:00
parent 47ed597358
commit 33dbfbe633
263 changed files with 1450 additions and 1486 deletions

View file

@ -172,7 +172,7 @@ public class BlocksHelper {
state = world.getBlockState(POS);
if (state.getBlock() instanceof FurBlock) {
doubleCheck.add(POS.toImmutable());
doubleCheck.add(POS.immutable());
}
// Liquids
else if (!state.getFluidState().isEmpty()) {
@ -237,7 +237,7 @@ public class BlocksHelper {
if (state.is(Blocks.CHORUS_PLANT)) {
Set<BlockPos> ends = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet();
ends.add(POS.toImmutable());
ends.add(POS.immutable());
for (int i = 0; i < 64 && !ends.isEmpty(); i++) {
ends.forEach((pos) -> {
@ -276,7 +276,7 @@ public class BlocksHelper {
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
int ray = downRayRep(world, POS.toImmutable(), 64);
int ray = downRayRep(world, POS.immutable(), 64);
if (ray > 32) {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.defaultBlockState());
if (world.getRandom().nextBoolean()) {

View file

@ -10,7 +10,7 @@ import com.google.common.collect.Maps;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.impl.client.indigo.renderer.helper.ColorHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Minecraft;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
@ -193,7 +193,7 @@ public class ColorUtil {
public static int extractColor(Item item) {
ResourceLocation id = Registry.ITEM.getId(item);
if (id.equals(Registry.ITEM.getDefaultId()))
if (id.equals(Registry.ITEM.getDefaultKey()))
return -1;
if (colorPalette.containsKey(id)) {
return colorPalette.get(id);
@ -227,7 +227,7 @@ public class ColorUtil {
}
public static NativeImage loadImage(ResourceLocation image, int w, int h) {
MinecraftClient minecraft = MinecraftClient.getInstance();
Minecraft minecraft = Minecraft.getInstance();
ResourceManager resourceManager = minecraft.getResourceManager();
if (resourceManager.containsResource(image)) {
try (Resource resource = resourceManager.getResource(image)) {

View file

@ -9,9 +9,9 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import net.minecraft.core.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import ru.betterend.mixin.common.GenerationSettingsAccessor;
import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndStructures;

View file

@ -2,7 +2,7 @@ package ru.betterend.util;
import java.util.Random;
import net.minecraft.client.util.math.Vector3f;
import com.mojang.math.Vector3f;
import net.minecraft.util.math.Vec3d;
public class MHelper {
@ -15,7 +15,7 @@ public class MHelper {
public static int color(int r, int g, int b) {
return ALPHA | (r << 16) | (g << 8) | b;
}
public static int color(String hex) {
int r = Integer.parseInt(hex.substring(0, 2), 16);
int g = Integer.parseInt(hex.substring(2, 4), 16);
@ -26,7 +26,7 @@ public class MHelper {
public static int randRange(int min, int max, Random random) {
return min + random.nextInt(max - min + 1);
}
public static double randRange(double min, double max, Random random) {
return min + random.nextDouble() * (max - min);
}
@ -68,81 +68,81 @@ public class MHelper {
public static int min(int a, int b) {
return a < b ? a : b;
}
public static int min(int a, int b, int c) {
return min(a, min(b, c));
}
public static int max(int a, int b) {
return a > b ? a : b;
}
public static float min(float a, float b) {
return a < b ? a : b;
}
public static float max(float a, float b) {
return a > b ? a : b;
}
public static float max(float a, float b, float c) {
return max(a, max(b, c));
}
public static int max(int a, int b, int c) {
return max(a, max(b, c));
}
public static boolean isEven(int num) {
return (num & 1) == 0;
}
public static float lengthSqr(float x, float y, float z) {
return x * x + y * y + z * z;
}
public static double lengthSqr(double x, double y, double z) {
return x * x + y * y + z * z;
}
public static float length(float x, float y, float z) {
return (float) Math.sqrt(lengthSqr(x, y, z));
}
public static double length(double x, double y, double z) {
return Math.sqrt(lengthSqr(x, y, z));
}
public static float lengthSqr(float x, float y) {
return x * x + y * y;
}
public static double lengthSqr(double x, double y) {
return x * x + y * y;
}
public static float length(float x, float y) {
return (float) Math.sqrt(lengthSqr(x, y));
}
public static double length(double x, double y) {
return Math.sqrt(lengthSqr(x, y));
}
public static float dot(float x1, float y1, float z1, float x2, float y2, float z2) {
return x1 * x2 + y1 * y2 + z1 * z2;
}
public static float dot(float x1, float y1, float x2, float y2) {
return x1 * x2 + y1 * y2;
}
public static int getRandom(int x, int z) {
int h = x * 374761393 + z * 668265263;
h = (h ^ (h >> 13)) * 1274126177;
return h ^ (h >> 16);
}
public static int getSeed(int seed, int x, int y) {
int h = seed + x * 374761393 + y * 668265263;
h = (h ^ (h >> 13)) * 1274126177;
@ -154,7 +154,7 @@ public class MHelper {
h = (h ^ (h >> 13)) * 1274126177;
return h ^ (h >> 16);
}
public static <T> void shuffle(T[] array, Random random) {
for (int i = 0; i < array.length; i++) {
int i2 = random.nextInt(array.length);
@ -167,15 +167,15 @@ public class MHelper {
public static int pow2(int i) {
return i * i;
}
public static float pow2(float f) {
return f * f;
}
public static double pow2(double d) {
return d * d;
}
public static int fromHSBtoRGB(float hue, float saturation, float brightness) {
int red = 0;
int green = 0;
@ -189,35 +189,35 @@ public class MHelper {
float var9 = brightness * (1.0F - saturation * var7);
float var10 = brightness * (1.0F - saturation * (1.0F - var7));
switch ((int) var6) {
case 0 :
red = (int) (brightness * 255.0F + 0.5F);
green = (int) (var10 * 255.0F + 0.5F);
blue = (int) (var8 * 255.0F + 0.5F);
break;
case 1 :
red = (int) (var9 * 255.0F + 0.5F);
green = (int) (brightness * 255.0F + 0.5F);
blue = (int) (var8 * 255.0F + 0.5F);
break;
case 2 :
red = (int) (var8 * 255.0F + 0.5F);
green = (int) (brightness * 255.0F + 0.5F);
blue = (int) (var10 * 255.0F + 0.5F);
break;
case 3 :
red = (int) (var8 * 255.0F + 0.5F);
green = (int) (var9 * 255.0F + 0.5F);
blue = (int) (brightness * 255.0F + 0.5F);
break;
case 4 :
red = (int) (var10 * 255.0F + 0.5F);
green = (int) (var8 * 255.0F + 0.5F);
blue = (int) (brightness * 255.0F + 0.5F);
break;
case 5 :
red = (int) (brightness * 255.0F + 0.5F);
green = (int) (var8 * 255.0F + 0.5F);
blue = (int) (var9 * 255.0F + 0.5F);
case 0:
red = (int) (brightness * 255.0F + 0.5F);
green = (int) (var10 * 255.0F + 0.5F);
blue = (int) (var8 * 255.0F + 0.5F);
break;
case 1:
red = (int) (var9 * 255.0F + 0.5F);
green = (int) (brightness * 255.0F + 0.5F);
blue = (int) (var8 * 255.0F + 0.5F);
break;
case 2:
red = (int) (var8 * 255.0F + 0.5F);
green = (int) (brightness * 255.0F + 0.5F);
blue = (int) (var10 * 255.0F + 0.5F);
break;
case 3:
red = (int) (var8 * 255.0F + 0.5F);
green = (int) (var9 * 255.0F + 0.5F);
blue = (int) (brightness * 255.0F + 0.5F);
break;
case 4:
red = (int) (var10 * 255.0F + 0.5F);
green = (int) (var8 * 255.0F + 0.5F);
blue = (int) (brightness * 255.0F + 0.5F);
break;
case 5:
red = (int) (brightness * 255.0F + 0.5F);
green = (int) (var8 * 255.0F + 0.5F);
blue = (int) (var9 * 255.0F + 0.5F);
}
}
@ -241,8 +241,7 @@ public class MHelper {
float hue;
if (saturation == 0.0F) {
hue = 0.0F;
}
else {
} else {
float var9 = (float) (max - r) / (float) (max - min);
float var10 = (float) (max - g) / (float) (max - min);
float var11 = (float) (max - b) / (float) (max - min);
@ -263,10 +262,10 @@ public class MHelper {
values[0] = hue;
values[1] = saturation;
values[2] = brightness;
return values;
}
public static Vec3d fromRGBtoHSBV(int r, int g, int b) {
int max = max(r, g, b);
int min = min(r, g, b);
@ -282,8 +281,7 @@ public class MHelper {
float hue;
if (saturation == 0.0F) {
hue = 0.0F;
}
else {
} else {
float var9 = (float) (max - r) / (float) (max - min);
float var10 = (float) (max - g) / (float) (max - min);
float var11 = (float) (max - b) / (float) (max - min);
@ -300,45 +298,44 @@ public class MHelper {
++hue;
}
}
return new Vec3d(hue, saturation, brightness);
}
public static final float radiansToDegrees(float value) {
return value * RAD_TO_DEG;
}
public static final float degreesToRadians(float value) {
return value / RAD_TO_DEG;
}
public static Vector3f cross(Vector3f vec1, Vector3f vec2)
{
public static Vector3f cross(Vector3f vec1, Vector3f vec2) {
float cx = vec1.getY() * vec2.getZ() - vec1.getZ() * vec2.getY();
float cy = vec1.getZ() * vec2.getX() - vec1.getX() * vec2.getZ();
float cz = vec1.getX() * vec2.getY() - vec1.getY() * vec2.getX();
return new Vector3f(cx, cy, cz);
}
public static Vector3f normalize(Vector3f vec) {
float length = lengthSqr(vec.getX(), vec.getY(), vec.getZ());
float length = lengthSqr(vec.x(), vec.y(), vec.z());
if (length > 0) {
length = (float) Math.sqrt(length);
float x = vec.getX() / length;
float y = vec.getY() / length;
float z = vec.getZ() / length;
float x = vec.x() / length;
float y = vec.y() / length;
float z = vec.z() / length;
vec.set(x, y, z);
}
return vec;
}
public static float angle(Vector3f vec1, Vector3f vec2) {
float dot = vec1.getX() * vec2.getX() + vec1.getY() * vec2.getY() + vec1.getZ() * vec2.getZ();
float length1 = lengthSqr(vec1.getX(), vec1.getY(), vec1.getZ());
float length2 = lengthSqr(vec2.getX(), vec2.getY(), vec2.getZ());
return (float) Math.acos(dot / Math.sqrt(length1 * length2));
}
public static Vector3f randomHorizontal(Random random) {
float angleY = MHelper.randRange(0, MHelper.PI2, random);
float vx = (float) Math.sin(angleY);

View file

@ -1,20 +1,20 @@
package ru.betterend.util;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.item.ItemConvertible;
import net.minecraft.world.level.ItemLike;
import net.minecraft.core.Registry;
public class RecipeHelper {
public static boolean exists(ItemConvertible item) {
public static boolean exists(ItemLike item) {
if (item instanceof Block) {
return Registry.BLOCK.getKey((Block) item) != Registry.BLOCK.getDefaultId();
return Registry.BLOCK.getKey((Block) item) != Registry.BLOCK.getDefaultKey();
} else {
return Registry.ITEM.getId(item.asItem()) != Registry.ITEM.getDefaultId();
return Registry.ITEM.getId(item.asItem()) != Registry.ITEM.getDefaultKey();
}
}
public static boolean exists(ItemConvertible... items) {
for (ItemConvertible item : items) {
public static boolean exists(ItemLike... items) {
for (ItemLike item : items) {
if (!exists(item)) {
return false;
}

View file

@ -8,11 +8,11 @@ import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.util.math.Vector3f;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.util.sdf.SDF;
import ru.betterend.util.sdf.operator.SDFUnion;
import ru.betterend.util.sdf.primitive.SDFLine;
@ -114,7 +114,7 @@ public class SplineHelper {
return result;
}
public static boolean fillSpline(List<Vector3f> spline, StructureWorldAccess world, BlockState state, BlockPos pos,
public static boolean fillSpline(List<Vector3f> spline, WorldGenLevel world, BlockState state, BlockPos pos,
Function<BlockState, Boolean> replace) {
Vector3f startPos = spline.get(0);
for (int i = 1; i < spline.size(); i++) {
@ -128,8 +128,8 @@ public class SplineHelper {
return true;
}
public static void fillSplineForce(List<Vector3f> spline, StructureWorldAccess world, BlockState state,
BlockPos pos, Function<BlockState, Boolean> replace) {
public static void fillSplineForce(List<Vector3f> spline, WorldGenLevel world, BlockState state, BlockPos pos,
Function<BlockState, Boolean> replace) {
Vector3f startPos = spline.get(0);
for (int i = 1; i < spline.size(); i++) {
Vector3f endPos = spline.get(i);
@ -138,8 +138,8 @@ public class SplineHelper {
}
}
public static boolean fillLine(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state,
BlockPos pos, Function<BlockState, Boolean> replace) {
public static boolean fillLine(Vector3f start, Vector3f end, WorldGenLevel world, BlockState state, BlockPos pos,
Function<BlockState, Boolean> replace) {
float dx = end.getX() - start.getX();
float dy = end.getY() - start.getY();
float dz = end.getZ() - start.getZ();
@ -187,8 +187,8 @@ public class SplineHelper {
}
}
public static void fillLineForce(Vector3f start, Vector3f end, StructureWorldAccess world, BlockState state,
BlockPos pos, Function<BlockState, Boolean> replace) {
public static void fillLineForce(Vector3f start, Vector3f end, WorldGenLevel world, BlockState state, BlockPos pos,
Function<BlockState, Boolean> replace) {
float dx = end.getX() - start.getX();
float dy = end.getY() - start.getY();
float dz = end.getZ() - start.getZ();
@ -231,19 +231,19 @@ public class SplineHelper {
}
}
public static boolean canGenerate(List<Vector3f> spline, float scale, BlockPos start, StructureWorldAccess world,
public static boolean canGenerate(List<Vector3f> spline, float scale, BlockPos start, WorldGenLevel world,
Function<BlockState, Boolean> canReplace) {
int count = spline.size();
Vector3f vec = spline.get(0);
MutableBlockPos mut = new MutableBlockPos();
float x1 = start.getX() + vec.getX() * scale;
float y1 = start.getY() + vec.getY() * scale;
float z1 = start.getZ() + vec.getZ() * scale;
float x1 = start.getX() + vec.x() * scale;
float y1 = start.getY() + vec.y() * scale;
float z1 = start.getZ() + vec.z() * scale;
for (int i = 1; i < count; i++) {
vec = spline.get(i);
float x2 = start.getX() + vec.getX() * scale;
float y2 = start.getY() + vec.getY() * scale;
float z2 = start.getZ() + vec.getZ() * scale;
float x2 = start.getX() + vec.x() * scale;
float y2 = start.getY() + vec.y() * scale;
float z2 = start.getZ() + vec.z() * scale;
for (float py = y1; py < y2; py += 3) {
if (py - start.getY() < 10)
@ -264,19 +264,19 @@ public class SplineHelper {
return true;
}
public static boolean canGenerate(List<Vector3f> spline, BlockPos start, StructureWorldAccess world,
public static boolean canGenerate(List<Vector3f> spline, BlockPos start, WorldGenLevel world,
Function<BlockState, Boolean> canReplace) {
int count = spline.size();
Vector3f vec = spline.get(0);
MutableBlockPos mut = new MutableBlockPos();
float x1 = start.getX() + vec.getX();
float y1 = start.getY() + vec.getY();
float z1 = start.getZ() + vec.getZ();
float x1 = start.getX() + vec.x();
float y1 = start.getY() + vec.y();
float z1 = start.getZ() + vec.z();
for (int i = 1; i < count; i++) {
vec = spline.get(i);
float x2 = start.getX() + vec.getX();
float y2 = start.getY() + vec.getY();
float z2 = start.getZ() + vec.getZ();
float x2 = start.getX() + vec.x();
float y2 = start.getY() + vec.y();
float z2 = start.getZ() + vec.z();
for (float py = y1; py < y2; py += 3) {
if (py - start.getY() < 10)

View file

@ -26,7 +26,7 @@ import net.minecraft.util.math.BlockBox;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.level.WorldGenLevel;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -88,13 +88,13 @@ public class StructureHelper {
return pos.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
}
public static void placeCenteredBottom(StructureWorldAccess world, BlockPos pos, Structure structure,
Rotation rotation, BlockMirror mirror, Random random) {
public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, Structure structure, Rotation rotation,
BlockMirror mirror, Random random) {
placeCenteredBottom(world, pos, structure, rotation, mirror, makeBox(pos), random);
}
public static void placeCenteredBottom(StructureWorldAccess world, BlockPos pos, Structure structure,
Rotation rotation, BlockMirror mirror, BlockBox bounds, Random random) {
public static void placeCenteredBottom(WorldGenLevel world, BlockPos pos, Structure structure, Rotation rotation,
BlockMirror mirror, BlockBox bounds, Random random) {
BlockPos offset = offsetPos(pos, structure, rotation, mirror);
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror)
.setBoundingBox(bounds);
@ -129,7 +129,7 @@ public class StructureHelper {
return BlockBox.create(x1, y1, z1, x2, y2, z2);
}
public static void erode(StructureWorldAccess world, BlockBox bounds, int iterations, Random random) {
public static void erode(WorldGenLevel world, BlockBox bounds, int iterations, Random random) {
MutableBlockPos mut = new MutableBlockPos();
boolean canDestruct = true;
for (int i = 0; i < iterations; i++) {
@ -227,7 +227,7 @@ public class StructureHelper {
}
}
public static void erodeIntense(StructureWorldAccess world, BlockBox bounds, Random random) {
public static void erodeIntense(WorldGenLevel world, BlockBox bounds, Random random) {
MutableBlockPos mut = new MutableBlockPos();
MutableBlockPos mut2 = new MutableBlockPos();
int minY = bounds.minY - 10;
@ -264,7 +264,7 @@ public class StructureHelper {
drop(world, bounds);
}
private static boolean isTerrainNear(StructureWorldAccess world, BlockPos pos) {
private static boolean isTerrainNear(WorldGenLevel world, BlockPos pos) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (world.getBlockState(pos.relative(dir)).isIn(EndTags.GEN_TERRAIN)) {
return true;
@ -273,7 +273,7 @@ public class StructureHelper {
return false;
}
private static void drop(StructureWorldAccess world, BlockBox bounds) {
private static void drop(WorldGenLevel world, BlockBox bounds) {
MutableBlockPos mut = new MutableBlockPos();
Set<BlockPos> blocks = Sets.newHashSet();
@ -288,7 +288,7 @@ public class StructureHelper {
mut.setY(y);
BlockState state = world.getBlockState(mut);
if (!ignore(state) && isTerrainNear(world, mut)) {
edge.add(mut.toImmutable());
edge.add(mut.immutable());
}
}
}
@ -307,7 +307,7 @@ public class StructureHelper {
if (bounds.contains(mut)) {
state = world.getBlockState(mut);
if (!ignore(state) && !blocks.contains(mut)) {
add.add(mut.toImmutable());
add.add(mut.immutable());
}
}
}
@ -359,13 +359,13 @@ public class StructureHelper {
}
}
public static void cover(StructureWorldAccess world, BlockBox bounds, Random random) {
public static void cover(WorldGenLevel world, BlockBox bounds, Random random) {
MutableBlockPos mut = new MutableBlockPos();
for (int x = bounds.minX; x <= bounds.maxX; x++) {
mut.setX(x);
for (int z = bounds.minZ; z <= bounds.maxZ; z++) {
mut.setZ(z);
BlockState top = world.getBiome(mut).getGenerationSettings().getSurfaceConfig().getTopMaterial();
BlockState top = world.getBiome(mut).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
for (int y = bounds.maxY; y >= bounds.minY; y--) {
mut.setY(y);
BlockState state = world.getBlockState(mut);

View file

@ -6,9 +6,9 @@ import java.util.Set;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemConvertible;
import net.minecraft.tags.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
@ -17,53 +17,45 @@ public class TagHelper {
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_BLOCK = Maps.newHashMap();
private static final Map<ResourceLocation, Set<ResourceLocation>> TAGS_ITEM = Maps.newHashMap();
public static void addTag(Tag.Identified<Block> tag, Block... blocks) {
ResourceLocation tagID = tag.getId();
Set<ResourceLocation> set = TAGS_BLOCK.get(tagID);
if (set == null) {
set = Sets.newHashSet();
TAGS_BLOCK.put(tagID, set);
}
public static void addTag(Tag.Named<Block> tag, Block... blocks) {
ResourceLocation tagID = tag.getName();
Set<ResourceLocation> set = TAGS_BLOCK.computeIfAbsent(tagID, k -> Sets.newHashSet());
for (Block block : blocks) {
ResourceLocation id = Registry.BLOCK.getKey(block);
if (id != Registry.BLOCK.getDefaultId()) {
if (id != Registry.BLOCK.getDefaultKey()) {
set.add(id);
}
}
}
public static void addTag(Tag.Identified<Item> tag, ItemConvertible... items) {
ResourceLocation tagID = tag.getId();
Set<ResourceLocation> set = TAGS_ITEM.get(tagID);
if (set == null) {
set = Sets.newHashSet();
TAGS_ITEM.put(tagID, set);
}
for (ItemConvertible item : items) {
ResourceLocation id = Registry.ITEM.getId(item.asItem());
if (id != Registry.ITEM.getDefaultId()) {
public static void addTag(Tag.Named<Item> tag, ItemLike... items) {
ResourceLocation tagID = tag.getName();
Set<ResourceLocation> set = TAGS_ITEM.computeIfAbsent(tagID, k -> Sets.newHashSet());
for (ItemLike item : items) {
ResourceLocation id = Registry.ITEM.getKey(item.asItem());
if (id != Registry.ITEM.getDefaultKey()) {
set.add(id);
}
}
}
@SafeVarargs
public static void addTags(ItemConvertible item, Tag.Identified<Item>... tags) {
for (Tag.Identified<Item> tag : tags) {
public static void addTags(ItemLike item, Tag.Named<Item>... tags) {
for (Tag.Named<Item> tag : tags) {
addTag(tag, item);
}
}
@SafeVarargs
public static void addTags(Block block, Tag.Identified<Block>... tags) {
for (Tag.Identified<Block> tag : tags) {
public static void addTags(Block block, Tag.Named<Block>... tags) {
for (Tag.Named<Block> tag : tags) {
addTag(tag, block);
}
}
public static Tag.Builder apply(Tag.Builder builder, Set<ResourceLocation> ids) {
ids.forEach((value) -> {
builder.add(value, "Better End Code");
ids.forEach(value -> {
builder.addTag(value, "Better End Code");
});
return builder;
}
@ -80,7 +72,7 @@ public class TagHelper {
if (tagsMap.containsKey(id)) {
apply(tagsMap.get(id), ids);
} else {
tagsMap.put(id, apply(Tag.Builder.create(), ids));
tagsMap.put(id, apply(Tag.Builder.tag(), ids));
}
});
}

View file

@ -11,12 +11,12 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.core.Direction;
import net.minecraft.world.ServerWorldAccess;
import ru.betterend.util.BlocksHelper;
import ru.betterend.world.structures.StructureWorld;
@ -40,7 +40,7 @@ public abstract class SDF {
return this;
}
public void fillRecursive(ServerWorldAccess world, BlockPos start) {
public void fillRecursive(ServerLevelAccessor world, BlockPos start) {
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
Set<BlockPos> blocks = Sets.newHashSet();
@ -55,13 +55,13 @@ public abstract class SDF {
for (BlockPos center : ends) {
for (Direction dir : Direction.values()) {
bPos.set(center).move(dir);
BlockPos wpos = bPos.add(start);
BlockPos wpos = bPos.offset(start);
if (!blocks.contains(bPos) && canReplace.apply(world.getBlockState(wpos))) {
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
BlockState state = getBlockState(wpos);
PosInfo.create(mapWorld, addInfo, wpos).setState(state);
add.add(bPos.toImmutable());
add.add(bPos.immutable());
}
}
}
@ -103,7 +103,7 @@ public abstract class SDF {
}
}
public void fillArea(ServerWorldAccess world, BlockPos center, Box box) {
public void fillArea(ServerLevelAccessor world, BlockPos center, Box box) {
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
@ -117,7 +117,7 @@ public abstract class SDF {
if (canReplace.apply(world.getBlockState(mut))) {
BlockPos fpos = mut.subtract(center);
if (this.getDistance(fpos.getX(), fpos.getY(), fpos.getZ()) < 0) {
PosInfo.create(mapWorld, addInfo, mut.toImmutable()).setState(getBlockState(mut));
PosInfo.create(mapWorld, addInfo, mut.immutable()).setState(getBlockState(mut));
}
}
}
@ -152,7 +152,7 @@ public abstract class SDF {
}
}
public void fillRecursiveIgnore(ServerWorldAccess world, BlockPos start, Function<BlockState, Boolean> ignore) {
public void fillRecursiveIgnore(ServerLevelAccessor world, BlockPos start, Function<BlockState, Boolean> ignore) {
Map<BlockPos, PosInfo> mapWorld = Maps.newHashMap();
Map<BlockPos, PosInfo> addInfo = Maps.newHashMap();
Set<BlockPos> blocks = Sets.newHashSet();
@ -167,13 +167,13 @@ public abstract class SDF {
for (BlockPos center : ends) {
for (Direction dir : Direction.values()) {
bPos.set(center).move(dir);
BlockPos wpos = bPos.add(start);
BlockPos wpos = bPos.offset(start);
BlockState state = world.getBlockState(wpos);
boolean ign = ignore.apply(state);
if (!blocks.contains(bPos) && (ign || canReplace.apply(state))) {
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
PosInfo.create(mapWorld, addInfo, wpos).setState(ign ? state : getBlockState(bPos));
add.add(bPos.toImmutable());
add.add(bPos.immutable());
}
}
}
@ -230,13 +230,13 @@ public abstract class SDF {
for (BlockPos center : ends) {
for (Direction dir : Direction.values()) {
bPos.set(center).move(dir);
BlockPos wpos = bPos.add(start);
BlockPos wpos = bPos.offset(start);
if (!blocks.contains(bPos)) {
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
BlockState state = getBlockState(wpos);
PosInfo.create(mapWorld, addInfo, wpos).setState(state);
add.add(bPos.toImmutable());
add.add(bPos.immutable());
}
}
}
@ -274,7 +274,7 @@ public abstract class SDF {
});
}
public Set<BlockPos> getPositions(ServerWorldAccess world, BlockPos start) {
public Set<BlockPos> getPositions(ServerLevelAccessor world, BlockPos start) {
Set<BlockPos> blocks = Sets.newHashSet();
Set<BlockPos> ends = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet();
@ -287,17 +287,17 @@ public abstract class SDF {
for (BlockPos center : ends) {
for (Direction dir : Direction.values()) {
bPos.set(center).move(dir);
BlockPos wpos = bPos.add(start);
BlockPos wpos = bPos.offset(start);
BlockState state = world.getBlockState(wpos);
if (!blocks.contains(wpos) && canReplace.apply(state)) {
if (this.getDistance(bPos.getX(), bPos.getY(), bPos.getZ()) < 0) {
add.add(bPos.toImmutable());
add.add(bPos.immutable());
}
}
}
}
ends.forEach((end) -> blocks.add(end.add(start)));
ends.forEach((end) -> blocks.add(end.offset(start)));
ends.clear();
ends.addAll(add);
add.clear();

View file

@ -2,17 +2,17 @@ package ru.betterend.util.sdf.operator;
import java.util.function.Consumer;
import net.minecraft.client.util.math.Vector3f;
import com.mojang.math.Vector3f;
public class SDFCoordModify extends SDFUnary {
private static final Vector3f POS = new Vector3f();
private Consumer<Vector3f> function;
public SDFCoordModify setFunction(Consumer<Vector3f> function) {
this.function = function;
return this;
}
@Override
public float getDistance(float x, float y, float z) {
POS.set(x, y, z);

View file

@ -2,17 +2,17 @@ package ru.betterend.util.sdf.operator;
import java.util.function.Function;
import net.minecraft.client.util.math.Vector3f;
import com.mojang.math.Vector3f;
public class SDFDisplacement extends SDFUnary {
private static final Vector3f POS = new Vector3f();
private Function<Vector3f, Float> displace;
public SDFDisplacement setFunction(Function<Vector3f, Float> displace) {
this.displace = displace;
return this;
}
@Override
public float getDistance(float x, float y, float z) {
POS.set(x, y, z);

View file

@ -1,17 +1,17 @@
package ru.betterend.util.sdf.operator;
import net.minecraft.client.util.math.Vector3f;
import com.mojang.math.Vector3f;
import net.minecraft.util.math.Quaternion;
public class SDFRotation extends SDFUnary {
private static final Vector3f POS = new Vector3f();
private Quaternion rotation;
public SDFRotation setRotation(Vector3f axis, float rotationAngle) {
rotation = new Quaternion(axis, rotationAngle, false);
return this;
}
@Override
public float getDistance(float x, float y, float z) {
POS.set(x, y, z);