Reformated
This commit is contained in:
parent
079b51e3f6
commit
852e5a6abc
385 changed files with 6924 additions and 5656 deletions
|
@ -1,5 +1,7 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -16,7 +18,6 @@ import net.minecraft.world.level.block.state.properties.Property;
|
|||
import net.minecraft.world.level.material.LavaFluid;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.betterx.bclib.api.v2.tag.CommonBlockTags;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
@ -197,10 +198,12 @@ public class BlocksHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static Optional<BlockPos> findSurfaceBelow(LevelAccessor level,
|
||||
BlockPos startPos,
|
||||
int minY,
|
||||
Predicate<BlockState> surface) {
|
||||
public static Optional<BlockPos> findSurfaceBelow(
|
||||
LevelAccessor level,
|
||||
BlockPos startPos,
|
||||
int minY,
|
||||
Predicate<BlockState> surface
|
||||
) {
|
||||
final MutableBlockPos POS = new MutableBlockPos(startPos.getX(), startPos.getY(), startPos.getZ());
|
||||
for (int y = startPos.getY(); y >= minY; y--) {
|
||||
POS.setY(y);
|
||||
|
@ -209,11 +212,13 @@ public class BlocksHelper {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
public static boolean findSurface(LevelAccessor level,
|
||||
MutableBlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> surface) {
|
||||
public static boolean findSurface(
|
||||
LevelAccessor level,
|
||||
MutableBlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> surface
|
||||
) {
|
||||
for (int len = 0; len < length; len++) {
|
||||
if (surface.test(level.getBlockState(startPos))) return true;
|
||||
startPos.move(dir, 1);
|
||||
|
@ -221,11 +226,13 @@ public class BlocksHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean findOnSurroundingSurface(LevelAccessor level,
|
||||
MutableBlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> surface) {
|
||||
public static boolean findOnSurroundingSurface(
|
||||
LevelAccessor level,
|
||||
MutableBlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> surface
|
||||
) {
|
||||
for (int len = 0; len < length; len++) {
|
||||
if (surface.test(level.getBlockState(startPos))) {
|
||||
if (len == 0) { //we started inside of the surface
|
||||
|
@ -246,11 +253,13 @@ public class BlocksHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean findSurroundingSurface(LevelAccessor level,
|
||||
MutableBlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> surface) {
|
||||
public static boolean findSurroundingSurface(
|
||||
LevelAccessor level,
|
||||
MutableBlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> surface
|
||||
) {
|
||||
BlockState beforeState = null;
|
||||
BlockState nowState;
|
||||
for (int len = 0; len < length; len++) {
|
||||
|
@ -279,11 +288,13 @@ public class BlocksHelper {
|
|||
}
|
||||
|
||||
|
||||
public static boolean isFreeSpace(LevelAccessor level,
|
||||
BlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> freeSurface) {
|
||||
public static boolean isFreeSpace(
|
||||
LevelAccessor level,
|
||||
BlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> freeSurface
|
||||
) {
|
||||
MutableBlockPos POS = startPos.mutable();
|
||||
for (int len = 0; len < length; len++) {
|
||||
if (!freeSurface.test(level.getBlockState(POS))) {
|
||||
|
@ -294,11 +305,13 @@ public class BlocksHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static int blockCount(LevelAccessor level,
|
||||
BlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> freeSurface) {
|
||||
public static int blockCount(
|
||||
LevelAccessor level,
|
||||
BlockPos startPos,
|
||||
Direction dir,
|
||||
int length,
|
||||
Predicate<BlockState> freeSurface
|
||||
) {
|
||||
MutableBlockPos POS = startPos.mutable();
|
||||
for (int len = 0; len < length; len++) {
|
||||
if (!freeSurface.test(level.getBlockState(POS))) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -13,8 +16,6 @@ import net.fabricmc.api.Environment;
|
|||
import net.fabricmc.fabric.impl.client.indigo.renderer.helper.ColorHelper;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
|
@ -7,7 +9,6 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
|
@ -12,7 +14,6 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.interfaces.LootPoolAccessor;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -13,18 +16,17 @@ import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
|
|||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.interfaces.LootPoolAccessor;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class LootUtil {
|
||||
public static Optional<List<ItemStack>> getDrops(BlockBehaviour block,
|
||||
BlockState state,
|
||||
LootContext.Builder builder) {
|
||||
public static Optional<List<ItemStack>> getDrops(
|
||||
BlockBehaviour block,
|
||||
BlockState state,
|
||||
LootContext.Builder builder
|
||||
) {
|
||||
ResourceLocation tableID = block.getLootTable();
|
||||
if (tableID == BuiltInLootTables.EMPTY) {
|
||||
return Optional.empty();
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class MHelper {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.fabricmc.loader.api.*;
|
||||
import net.fabricmc.loader.api.metadata.*;
|
||||
|
||||
|
@ -7,7 +9,6 @@ import com.google.gson.JsonElement;
|
|||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -52,8 +53,10 @@ public class ModUtil {
|
|||
}
|
||||
|
||||
private static ModMetadata readJSON(InputStream is, String sourceFile) throws IOException {
|
||||
try (com.google.gson.stream.JsonReader reader = new JsonReader(new InputStreamReader(is,
|
||||
StandardCharsets.UTF_8))) {
|
||||
try (com.google.gson.stream.JsonReader reader = new JsonReader(new InputStreamReader(
|
||||
is,
|
||||
StandardCharsets.UTF_8
|
||||
))) {
|
||||
JsonObject data = JsonParser.parseReader(reader)
|
||||
.getAsJsonObject();
|
||||
Version ver;
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.bclib.sdf.SDF;
|
||||
import org.betterx.bclib.sdf.operator.SDFUnion;
|
||||
import org.betterx.bclib.sdf.primitive.SDFLine;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -8,10 +13,6 @@ import net.minecraft.world.level.WorldGenLevel;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.math.Vector3f;
|
||||
import org.betterx.bclib.sdf.SDF;
|
||||
import org.betterx.bclib.sdf.operator.SDFUnion;
|
||||
import org.betterx.bclib.sdf.primitive.SDFLine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -78,10 +79,12 @@ public class SplineHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static SDF buildSDF(List<Vector3f> spline,
|
||||
float radius1,
|
||||
float radius2,
|
||||
Function<BlockPos, BlockState> placerFunction) {
|
||||
public static SDF buildSDF(
|
||||
List<Vector3f> spline,
|
||||
float radius1,
|
||||
float radius2,
|
||||
Function<BlockPos, BlockState> placerFunction
|
||||
) {
|
||||
int count = spline.size();
|
||||
float max = count - 2;
|
||||
SDF result = null;
|
||||
|
@ -99,9 +102,11 @@ public class SplineHelper {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static SDF buildSDF(List<Vector3f> spline,
|
||||
Function<Float, Float> radiusFunction,
|
||||
Function<BlockPos, BlockState> placerFunction) {
|
||||
public static SDF buildSDF(
|
||||
List<Vector3f> spline,
|
||||
Function<Float, Float> radiusFunction,
|
||||
Function<BlockPos, BlockState> placerFunction
|
||||
) {
|
||||
int count = spline.size();
|
||||
float max = count - 2;
|
||||
SDF result = null;
|
||||
|
@ -119,11 +124,13 @@ public class SplineHelper {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static boolean fillSpline(List<Vector3f> spline,
|
||||
WorldGenLevel world,
|
||||
BlockState state,
|
||||
BlockPos pos,
|
||||
Function<BlockState, Boolean> replace) {
|
||||
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++) {
|
||||
Vector3f endPos = spline.get(i);
|
||||
|
@ -136,11 +143,13 @@ public class SplineHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void fillSplineForce(List<Vector3f> spline,
|
||||
WorldGenLevel 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);
|
||||
|
@ -149,12 +158,14 @@ public class SplineHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean fillLine(Vector3f start,
|
||||
Vector3f end,
|
||||
WorldGenLevel 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.x() - start.x();
|
||||
float dy = end.y() - start.y();
|
||||
float dz = end.z() - start.z();
|
||||
|
@ -202,12 +213,14 @@ public class SplineHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void fillLineForce(Vector3f start,
|
||||
Vector3f end,
|
||||
WorldGenLevel 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.x() - start.x();
|
||||
float dy = end.y() - start.y();
|
||||
float dz = end.z() - start.z();
|
||||
|
@ -250,11 +263,13 @@ public class SplineHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean canGenerate(List<Vector3f> spline,
|
||||
float scale,
|
||||
BlockPos start,
|
||||
WorldGenLevel world,
|
||||
Function<BlockState, Boolean> canReplace) {
|
||||
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();
|
||||
|
@ -285,10 +300,12 @@ public class SplineHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean canGenerate(List<Vector3f> spline,
|
||||
BlockPos start,
|
||||
WorldGenLevel world,
|
||||
Function<BlockState, Boolean> canReplace) {
|
||||
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();
|
||||
|
|
|
@ -78,26 +78,30 @@ public class StructureHelper {
|
|||
mirror,
|
||||
rotation,
|
||||
BlockPos.ZERO
|
||||
);
|
||||
);
|
||||
return pos.offset(-offset.x * 0.5, 0, -offset.z * 0.5);
|
||||
}
|
||||
|
||||
public static void placeCenteredBottom(WorldGenLevel world,
|
||||
BlockPos pos,
|
||||
StructureTemplate structure,
|
||||
Rotation rotation,
|
||||
Mirror mirror,
|
||||
RandomSource random) {
|
||||
public static void placeCenteredBottom(
|
||||
WorldGenLevel world,
|
||||
BlockPos pos,
|
||||
StructureTemplate structure,
|
||||
Rotation rotation,
|
||||
Mirror mirror,
|
||||
RandomSource random
|
||||
) {
|
||||
placeCenteredBottom(world, pos, structure, rotation, mirror, makeBox(pos), random);
|
||||
}
|
||||
|
||||
public static void placeCenteredBottom(WorldGenLevel world,
|
||||
BlockPos pos,
|
||||
StructureTemplate structure,
|
||||
Rotation rotation,
|
||||
Mirror mirror,
|
||||
BoundingBox bounds,
|
||||
RandomSource random) {
|
||||
public static void placeCenteredBottom(
|
||||
WorldGenLevel world,
|
||||
BlockPos pos,
|
||||
StructureTemplate structure,
|
||||
Rotation rotation,
|
||||
Mirror mirror,
|
||||
BoundingBox bounds,
|
||||
RandomSource random
|
||||
) {
|
||||
BlockPos offset = offsetPos(pos, structure, rotation, mirror);
|
||||
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation)
|
||||
.setMirror(mirror)
|
||||
|
@ -113,10 +117,12 @@ public class StructureHelper {
|
|||
return BoundingBox.fromCorners(new Vec3i(sx, 0, sz), new Vec3i(ex, 255, ez));
|
||||
}
|
||||
|
||||
public static BoundingBox getStructureBounds(BlockPos pos,
|
||||
StructureTemplate structure,
|
||||
Rotation rotation,
|
||||
Mirror mirror) {
|
||||
public static BoundingBox getStructureBounds(
|
||||
BlockPos pos,
|
||||
StructureTemplate structure,
|
||||
Rotation rotation,
|
||||
Mirror mirror
|
||||
) {
|
||||
Vec3i max = structure.getSize();
|
||||
Vec3 min = StructureTemplate.transform(Vec3.atCenterOf(structure.getSize()), mirror, rotation, BlockPos.ZERO);
|
||||
max = max.offset(-min.x, -min.y, -min.z);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue