Merge fixes.
This commit is contained in:
@@ -46,8 +46,10 @@ import appeng.core.config.DoubleOption;
|
|||||||
import appeng.core.config.EnumOption;
|
import appeng.core.config.EnumOption;
|
||||||
import appeng.core.config.IntegerOption;
|
import appeng.core.config.IntegerOption;
|
||||||
import appeng.core.config.StringListOption;
|
import appeng.core.config.StringListOption;
|
||||||
|
import appeng.core.config.StringOption;
|
||||||
import appeng.core.settings.TickRates;
|
import appeng.core.settings.TickRates;
|
||||||
import appeng.util.EnumCycler;
|
import appeng.util.EnumCycler;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@@ -406,7 +408,7 @@ public final class AEConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getImprovedFluidMultiplier() {
|
public float getImprovedFluidMultiplier() {
|
||||||
return commonConfig.improvedFluidMultiplier.get().floatValue();
|
return (float) commonConfig.improvedFluidMultiplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setters keep visibility as low as possible.
|
// Setters keep visibility as low as possible.
|
||||||
@@ -625,7 +627,7 @@ public final class AEConfig {
|
|||||||
|
|
||||||
improvedFluidTag = inWorldPurification.addString("improvedFluidTag", "", "A fluid tag that identifies fluids that improve crystal purification speed. Does not affect purification with water/lava.");
|
improvedFluidTag = inWorldPurification.addString("improvedFluidTag", "", "A fluid tag that identifies fluids that improve crystal purification speed. Does not affect purification with water/lava.");
|
||||||
improvedFluidMultiplier = inWorldPurification
|
improvedFluidMultiplier = inWorldPurification
|
||||||
.addDouble("improvedFluidMultiplier", 2.0, 1.0, 10.0, "The speed multiplier to use when the crystals are submerged in the improved fluid.")
|
.addDouble("improvedFluidMultiplier", 2.0, 1.0, 10.0, "The speed multiplier to use when the crystals are submerged in the improved fluid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,14 @@ public class ConfigSection {
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StringOption addString(String id, String defaultValue) {
|
||||||
|
return addString(id, defaultValue, comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringOption addString(String id, String defaultValue, String comment) {
|
||||||
|
return addOption(new StringOption(this, id, comment, defaultValue));
|
||||||
|
}
|
||||||
|
|
||||||
public IntegerOption addInt(String id, int defaultValue) {
|
public IntegerOption addInt(String id, int defaultValue) {
|
||||||
return addInt(id, defaultValue, comment);
|
return addInt(id, defaultValue, comment);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package appeng.core.config;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
|
||||||
|
public class StringOption extends BaseOption {
|
||||||
|
|
||||||
|
private final String defaultValue;
|
||||||
|
private String currentValue;
|
||||||
|
|
||||||
|
public StringOption(ConfigSection parent, String id, String comment, String defaultValue) {
|
||||||
|
super(parent, id, comment);
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.currentValue = this.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get() {
|
||||||
|
return currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(String value) {
|
||||||
|
Preconditions.checkNotNull(value);
|
||||||
|
if (value.equals(currentValue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentValue = value;
|
||||||
|
parent.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JsonElement write() {
|
||||||
|
return new JsonPrimitive(currentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void read(JsonElement element) {
|
||||||
|
if (!element.isJsonPrimitive()) {
|
||||||
|
throw new ConfigValidationException(this, "Expected a JSON primitive: " + element);
|
||||||
|
}
|
||||||
|
JsonPrimitive primitive = element.getAsJsonPrimitive();
|
||||||
|
if (!primitive.isString()) {
|
||||||
|
throw new ConfigValidationException(this, "Expected a JSON string, but found: " + primitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentValue = primitive.getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDifferentFromDefault() {
|
||||||
|
return !currentValue.equals(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDefaultAsString() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCurrentValueAsString() {
|
||||||
|
return currentValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,14 +19,14 @@
|
|||||||
package appeng.entity;
|
package appeng.entity;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Material;
|
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import appeng.api.features.AEFeature;
|
import appeng.api.features.AEFeature;
|
||||||
@@ -37,7 +37,6 @@ import appeng.core.AEConfig;
|
|||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
import appeng.items.misc.CrystalSeedItem;
|
import appeng.items.misc.CrystalSeedItem;
|
||||||
import appeng.mixins.ItemEntityAccessor;
|
import appeng.mixins.ItemEntityAccessor;
|
||||||
import appeng.util.Platform;
|
|
||||||
|
|
||||||
public class GrowingCrystalEntity extends AEBaseItemEntity {
|
public class GrowingCrystalEntity extends AEBaseItemEntity {
|
||||||
|
|
||||||
@@ -46,7 +45,8 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
|||||||
// Growth tick progress per tick by number of adjacent accelerators
|
// Growth tick progress per tick by number of adjacent accelerators
|
||||||
// Expressed as 1/1000th of a growth tick, applied to progress_1000
|
// Expressed as 1/1000th of a growth tick, applied to progress_1000
|
||||||
// each time this entity ticks.
|
// each time this entity ticks.
|
||||||
private static final int[] GROWTH_TICK_PROGRESS = { 1, // no accelerators
|
private static final int[] GROWTH_TICK_PROGRESS = { //
|
||||||
|
1, // no accelerators
|
||||||
40, // 1 accelerator
|
40, // 1 accelerator
|
||||||
92, // 2 accelerators
|
92, // 2 accelerators
|
||||||
159, // 3 accelerators
|
159, // 3 accelerators
|
||||||
@@ -94,9 +94,9 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int x = MathHelper.floor(this.getPosX());
|
final int x = MathHelper.floor(this.getX());
|
||||||
final int y = MathHelper.floor((this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D);
|
final int y = MathHelper.floor((this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D);
|
||||||
final int z = MathHelper.floor(this.getPosZ());
|
final int z = MathHelper.floor(this.getZ());
|
||||||
|
|
||||||
BlockPos pos = new BlockPos(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
final BlockState state = this.world.getBlockState(pos);
|
final BlockState state = this.world.getBlockState(pos);
|
||||||
@@ -111,7 +111,7 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
|||||||
|
|
||||||
final int progressPerTick = (int) Math.max(1, this.getSpeed(pos) * multiplier);
|
final int progressPerTick = (int) Math.max(1, this.getSpeed(pos) * multiplier);
|
||||||
|
|
||||||
if (world.isRemote()) {
|
if (world.isClient()) {
|
||||||
// On the client, we reuse the growth-tick-progress
|
// On the client, we reuse the growth-tick-progress
|
||||||
// as a tick-counter for particle effects
|
// as a tick-counter for particle effects
|
||||||
int len = getTicksBetweenParticleEffects(progressPerTick);
|
int len = getTicksBetweenParticleEffects(progressPerTick);
|
||||||
@@ -183,7 +183,7 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
|||||||
|
|
||||||
BlockPos.Mutable testPos = new BlockPos.Mutable();
|
BlockPos.Mutable testPos = new BlockPos.Mutable();
|
||||||
for (Direction direction : Direction.values()) {
|
for (Direction direction : Direction.values()) {
|
||||||
if (this.isPoweredAccelerator(testPos.func_239622_a_(pos, direction))) {
|
if (this.isPoweredAccelerator(testPos.set(pos, direction))) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,13 +205,13 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
|||||||
// automation based around dropping seeds between 5 CGAs, then catchiung
|
// automation based around dropping seeds between 5 CGAs, then catchiung
|
||||||
// them on their way up.
|
// them on their way up.
|
||||||
if (item.getItem() instanceof CrystalSeedItem) {
|
if (item.getItem() instanceof CrystalSeedItem) {
|
||||||
Vector3d v = this.getMotion();
|
Vec3d v = this.getVelocity();
|
||||||
|
|
||||||
// Apply a much smaller acceleration to make them slowly sink
|
// Apply a much smaller acceleration to make them slowly sink
|
||||||
double yAccel = this.hasNoGravity() ? 0 : -0.002;
|
double yAccel = this.hasNoGravity() ? 0 : -0.002;
|
||||||
|
|
||||||
// Apply the x/z slow-down, and the y acceleration
|
// Apply the x/z slow-down, and the y acceleration
|
||||||
this.setMotion(v.x * 0.99, v.y + yAccel, v.z * 0.99);
|
this.setVelocity(v.x * 0.99, v.y + yAccel, v.z * 0.99);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class FluidImportBusPart extends SharedFluidBusPart {
|
|||||||
// skip
|
// skip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return TickRateModulation.SLEEP;
|
return TickRateModulation.SLEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,36 +18,39 @@
|
|||||||
|
|
||||||
package appeng.items.misc;
|
package appeng.items.misc;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.block.Material;
|
|
||||||
import net.minecraft.client.item.TooltipContext;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.ItemEntity;
|
|
||||||
import net.minecraft.item.ItemConvertible;
|
|
||||||
import net.minecraft.item.ItemGroup;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.server.world.ServerWorld;
|
|
||||||
import net.minecraft.text.LiteralText;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import appeng.api.implementations.items.IGrowableCrystal;
|
import appeng.api.implementations.items.IGrowableCrystal;
|
||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.localization.ButtonToolTips;
|
import appeng.core.localization.ButtonToolTips;
|
||||||
import appeng.entity.GrowingCrystalEntity;
|
import appeng.entity.GrowingCrystalEntity;
|
||||||
import appeng.hooks.AECustomEntityItem;
|
import appeng.hooks.AECustomEntityItem;
|
||||||
import appeng.items.AEBaseItem;
|
import appeng.items.AEBaseItem;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.fabricmc.fabric.api.tag.TagRegistry;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.item.TooltipContext;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
import net.minecraft.fluid.Fluid;
|
||||||
|
import net.minecraft.fluid.FluidState;
|
||||||
|
import net.minecraft.item.ItemConvertible;
|
||||||
|
import net.minecraft.item.ItemGroup;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.tag.FluidTags;
|
||||||
|
import net.minecraft.tag.Tag;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This item reprents one of the seeds used to grow various forms of quartz by
|
* This item reprents one of the seeds used to grow various forms of quartz by
|
||||||
@@ -70,9 +73,15 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal, AEC
|
|||||||
*/
|
*/
|
||||||
private final ItemConvertible grownItem;
|
private final ItemConvertible grownItem;
|
||||||
|
|
||||||
|
private final Tag<Fluid> improvedFluidTag;
|
||||||
|
|
||||||
public CrystalSeedItem(Settings properties, ItemConvertible grownItem) {
|
public CrystalSeedItem(Settings properties, ItemConvertible grownItem) {
|
||||||
super(properties);
|
super(properties);
|
||||||
this.grownItem = Preconditions.checkNotNull(grownItem);
|
this.grownItem = Preconditions.checkNotNull(grownItem);
|
||||||
|
|
||||||
|
String improvedFluidTagName = AEConfig.instance().getImprovedFluidTag();
|
||||||
|
this.improvedFluidTag = improvedFluidTagName != null ?
|
||||||
|
TagRegistry.fluid(new Identifier(improvedFluidTagName)) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -101,20 +110,17 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal, AEC
|
|||||||
public float getMultiplier(BlockState state, @Nullable World world, @Nullable BlockPos pos) {
|
public float getMultiplier(BlockState state, @Nullable World world, @Nullable BlockPos pos) {
|
||||||
|
|
||||||
// Check for the improved fluid tag and return the improved multiplier
|
// Check for the improved fluid tag and return the improved multiplier
|
||||||
String improvedFluidTagName = AEConfig.instance().getImprovedFluidTag();
|
FluidState fluidState = state.getFluidState();
|
||||||
if (improvedFluidTagName != null) {
|
if (improvedFluidTag != null && fluidState.isIn(improvedFluidTag)) {
|
||||||
ITag<Fluid> tag = FluidTags.getCollection().get(new ResourceLocation(improvedFluidTagName));
|
|
||||||
if (tag != null && state.getFluidState().isTagged(tag)) {
|
|
||||||
return AEConfig.instance().getImprovedFluidMultiplier();
|
return AEConfig.instance().getImprovedFluidMultiplier();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Check for the normal supported fluid
|
// Check for the normal supported fluid
|
||||||
if (world != null && world.func_234923_W_() == World.field_234919_h_) {
|
if (world != null && world.getRegistryKey() == World.NETHER) {
|
||||||
// In the nether, use Lava as the "normal" fluid
|
// In the nether, use Lava as the "normal" fluid
|
||||||
return state.getFluidState().isTagged(FluidTags.LAVA) ? 1 : 0;
|
return fluidState.isIn(FluidTags.LAVA) ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
return state.getFluidState().isTagged(FluidTags.WATER) ? 1 : 0;
|
return fluidState.isIn(FluidTags.WATER) ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class QuantumCluster implements ILocatable, IAECluster {
|
|||||||
// In future versions, we might actually want to delay the entire registration
|
// In future versions, we might actually want to delay the entire registration
|
||||||
// until the center
|
// until the center
|
||||||
// tile begins ticking normally.
|
// tile begins ticking normally.
|
||||||
if (theWorld.isBlockLoaded(qc.center.getPos())) {
|
if (theWorld.isChunkLoaded(qc.center.getPos())) {
|
||||||
final World cur = theWorld.getServer().getWorld(theWorld.getRegistryKey());
|
final World cur = theWorld.getServer().getWorld(theWorld.getRegistryKey());
|
||||||
|
|
||||||
final BlockEntity te = theWorld.getBlockEntity(qc.center.getPos());
|
final BlockEntity te = theWorld.getBlockEntity(qc.center.getPos());
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package appeng.mixins.tags;
|
package appeng.mixins.tags;
|
||||||
|
|
||||||
|
import net.minecraft.tag.RequiredTagList;
|
||||||
|
import net.minecraft.tag.TagGroup;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||||
|
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
@@ -15,4 +18,9 @@ public interface FluidTagsAccessor {
|
|||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Accessor("REQUIRED_TAGS")
|
||||||
|
static RequiredTagList<Fluid> getRequiredTags() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,21 +18,20 @@
|
|||||||
|
|
||||||
package appeng.parts;
|
package appeng.parts;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import net.minecraft.util.function.BooleanBiFunction;
|
||||||
|
import net.minecraft.util.math.Box;
|
||||||
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import java.util.List;
|
||||||
import net.minecraft.util.math.shapes.IBooleanFunction;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* While creation of a {@link VoxelShape} with
|
* While creation of a {@link net.minecraft.util.shape.VoxelShape} with
|
||||||
* {@link VoxelShapes#create(AxisAlignedBB)} is fast enough, combining voxel
|
* {@link net.minecraft.util.shape.VoxelShapes#cuboid(Box)} is fast enough, combining voxel
|
||||||
* shapes with {@link VoxelShapes#or(VoxelShape, VoxelShape)} or any other
|
* shapes with {@link net.minecraft.util.shape.VoxelShapes#union(VoxelShape, VoxelShape)} or any other
|
||||||
* combination method, as well as {@link VoxelShape#simplify()} are <b>extremely
|
* combination method, as well as {@link VoxelShape#simplify()} are <b>extremely
|
||||||
* slow</b>. For example: Creating a VoxelShape for a list of 5 bounding boxes
|
* slow</b>. For example: Creating a VoxelShape for a list of 5 bounding boxes
|
||||||
* 10,000 times takes about 1.7 seconds.
|
* 10,000 times takes about 1.7 seconds.
|
||||||
@@ -48,11 +47,11 @@ final class VoxelShapeCache {
|
|||||||
// are iterated over in a fixed order, meaning the order of bounding boxes
|
// are iterated over in a fixed order, meaning the order of bounding boxes
|
||||||
// should
|
// should
|
||||||
// be the same for a same set of parts.
|
// be the same for a same set of parts.
|
||||||
private static final LoadingCache<List<AxisAlignedBB>, VoxelShape> CACHE = CacheBuilder.newBuilder()//
|
private static final LoadingCache<List<Box>, VoxelShape> CACHE = CacheBuilder.newBuilder()//
|
||||||
.maximumSize(10000L)//
|
.maximumSize(10000L)//
|
||||||
.build(new CacheLoader<List<AxisAlignedBB>, VoxelShape>() {
|
.build(new CacheLoader<List<Box>, VoxelShape>() {
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape load(List<AxisAlignedBB> key) {
|
public VoxelShape load(List<Box> key) {
|
||||||
return create(key);
|
return create(key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -60,20 +59,20 @@ final class VoxelShapeCache {
|
|||||||
private VoxelShapeCache() {
|
private VoxelShapeCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VoxelShape get(List<AxisAlignedBB> boxes) {
|
public static VoxelShape get(List<Box> boxes) {
|
||||||
return CACHE.getUnchecked(boxes);
|
return CACHE.getUnchecked(boxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static VoxelShape create(List<AxisAlignedBB> boxes) {
|
private static VoxelShape create(List<Box> boxes) {
|
||||||
if (boxes.isEmpty()) {
|
if (boxes.isEmpty()) {
|
||||||
return VoxelShapes.empty();
|
return VoxelShapes.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
VoxelShape shape = VoxelShapes.create(boxes.get(i));
|
VoxelShape shape = VoxelShapes.cuboid(boxes.get(i));
|
||||||
for (; i < boxes.size(); i++) {
|
for (; i < boxes.size(); i++) {
|
||||||
AxisAlignedBB box = boxes.get(i);
|
Box box = boxes.get(i);
|
||||||
shape = VoxelShapes.combine(shape, VoxelShapes.create(box), IBooleanFunction.OR);
|
shape = VoxelShapes.combine(shape, VoxelShapes.cuboid(box), BooleanBiFunction.OR);
|
||||||
}
|
}
|
||||||
return shape.simplify();
|
return shape.simplify();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user