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.IntegerOption;
|
||||
import appeng.core.config.StringListOption;
|
||||
import appeng.core.config.StringOption;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.util.EnumCycler;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -406,7 +408,7 @@ public final class AEConfig {
|
||||
}
|
||||
|
||||
public float getImprovedFluidMultiplier() {
|
||||
return commonConfig.improvedFluidMultiplier.get().floatValue();
|
||||
return (float) commonConfig.improvedFluidMultiplier.get();
|
||||
}
|
||||
|
||||
// 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.");
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
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 appeng.api.features.AEFeature;
|
||||
@@ -37,7 +37,6 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.items.misc.CrystalSeedItem;
|
||||
import appeng.mixins.ItemEntityAccessor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GrowingCrystalEntity extends AEBaseItemEntity {
|
||||
|
||||
@@ -46,7 +45,8 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
||||
// Growth tick progress per tick by number of adjacent accelerators
|
||||
// Expressed as 1/1000th of a growth tick, applied to progress_1000
|
||||
// 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
|
||||
92, // 2 accelerators
|
||||
159, // 3 accelerators
|
||||
@@ -94,9 +94,9 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
||||
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 z = MathHelper.floor(this.getPosZ());
|
||||
final int z = MathHelper.floor(this.getZ());
|
||||
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
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);
|
||||
|
||||
if (world.isRemote()) {
|
||||
if (world.isClient()) {
|
||||
// On the client, we reuse the growth-tick-progress
|
||||
// as a tick-counter for particle effects
|
||||
int len = getTicksBetweenParticleEffects(progressPerTick);
|
||||
@@ -183,7 +183,7 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
||||
|
||||
BlockPos.Mutable testPos = new BlockPos.Mutable();
|
||||
for (Direction direction : Direction.values()) {
|
||||
if (this.isPoweredAccelerator(testPos.func_239622_a_(pos, direction))) {
|
||||
if (this.isPoweredAccelerator(testPos.set(pos, direction))) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -205,13 +205,13 @@ public class GrowingCrystalEntity extends AEBaseItemEntity {
|
||||
// automation based around dropping seeds between 5 CGAs, then catchiung
|
||||
// them on their way up.
|
||||
if (item.getItem() instanceof CrystalSeedItem) {
|
||||
Vector3d v = this.getMotion();
|
||||
Vec3d v = this.getVelocity();
|
||||
|
||||
// Apply a much smaller acceleration to make them slowly sink
|
||||
double yAccel = this.hasNoGravity() ? 0 : -0.002;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -141,10 +141,10 @@ public class FluidImportBusPart extends SharedFluidBusPart {
|
||||
|
||||
return TickRateModulation.IDLE;
|
||||
} catch (GridAccessException e) {
|
||||
// skip
|
||||
}
|
||||
// skip
|
||||
}
|
||||
}
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,36 +18,39 @@
|
||||
|
||||
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.core.AEConfig;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.entity.GrowingCrystalEntity;
|
||||
import appeng.hooks.AECustomEntityItem;
|
||||
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
|
||||
@@ -70,9 +73,15 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal, AEC
|
||||
*/
|
||||
private final ItemConvertible grownItem;
|
||||
|
||||
private final Tag<Fluid> improvedFluidTag;
|
||||
|
||||
public CrystalSeedItem(Settings properties, ItemConvertible grownItem) {
|
||||
super(properties);
|
||||
this.grownItem = Preconditions.checkNotNull(grownItem);
|
||||
|
||||
String improvedFluidTagName = AEConfig.instance().getImprovedFluidTag();
|
||||
this.improvedFluidTag = improvedFluidTagName != null ?
|
||||
TagRegistry.fluid(new Identifier(improvedFluidTagName)) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -101,20 +110,17 @@ public class CrystalSeedItem extends AEBaseItem implements IGrowableCrystal, AEC
|
||||
public float getMultiplier(BlockState state, @Nullable World world, @Nullable BlockPos pos) {
|
||||
|
||||
// Check for the improved fluid tag and return the improved multiplier
|
||||
String improvedFluidTagName = AEConfig.instance().getImprovedFluidTag();
|
||||
if (improvedFluidTagName != null) {
|
||||
ITag<Fluid> tag = FluidTags.getCollection().get(new ResourceLocation(improvedFluidTagName));
|
||||
if (tag != null && state.getFluidState().isTagged(tag)) {
|
||||
return AEConfig.instance().getImprovedFluidMultiplier();
|
||||
}
|
||||
FluidState fluidState = state.getFluidState();
|
||||
if (improvedFluidTag != null && fluidState.isIn(improvedFluidTag)) {
|
||||
return AEConfig.instance().getImprovedFluidMultiplier();
|
||||
}
|
||||
|
||||
// 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
|
||||
return state.getFluidState().isTagged(FluidTags.LAVA) ? 1 : 0;
|
||||
return fluidState.isIn(FluidTags.LAVA) ? 1 : 0;
|
||||
} 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
|
||||
// until the center
|
||||
// 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 BlockEntity te = theWorld.getBlockEntity(qc.center.getPos());
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
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.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.fluid.Fluid;
|
||||
@@ -15,4 +18,9 @@ public interface FluidTagsAccessor {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Accessor("REQUIRED_TAGS")
|
||||
static RequiredTagList<Fluid> getRequiredTags() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,21 +18,20 @@
|
||||
|
||||
package appeng.parts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
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 net.minecraft.util.math.shapes.IBooleanFunction;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* While creation of a {@link VoxelShape} with
|
||||
* {@link VoxelShapes#create(AxisAlignedBB)} is fast enough, combining voxel
|
||||
* shapes with {@link VoxelShapes#or(VoxelShape, VoxelShape)} or any other
|
||||
* While creation of a {@link net.minecraft.util.shape.VoxelShape} with
|
||||
* {@link net.minecraft.util.shape.VoxelShapes#cuboid(Box)} is fast enough, combining voxel
|
||||
* 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
|
||||
* slow</b>. For example: Creating a VoxelShape for a list of 5 bounding boxes
|
||||
* 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
|
||||
// should
|
||||
// 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)//
|
||||
.build(new CacheLoader<List<AxisAlignedBB>, VoxelShape>() {
|
||||
.build(new CacheLoader<List<Box>, VoxelShape>() {
|
||||
@Override
|
||||
public VoxelShape load(List<AxisAlignedBB> key) {
|
||||
public VoxelShape load(List<Box> key) {
|
||||
return create(key);
|
||||
}
|
||||
});
|
||||
@@ -60,20 +59,20 @@ final class VoxelShapeCache {
|
||||
private VoxelShapeCache() {
|
||||
}
|
||||
|
||||
public static VoxelShape get(List<AxisAlignedBB> boxes) {
|
||||
public static VoxelShape get(List<Box> boxes) {
|
||||
return CACHE.getUnchecked(boxes);
|
||||
}
|
||||
|
||||
private static VoxelShape create(List<AxisAlignedBB> boxes) {
|
||||
private static VoxelShape create(List<Box> boxes) {
|
||||
if (boxes.isEmpty()) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
VoxelShape shape = VoxelShapes.create(boxes.get(i));
|
||||
VoxelShape shape = VoxelShapes.cuboid(boxes.get(i));
|
||||
for (; i < boxes.size(); i++) {
|
||||
AxisAlignedBB box = boxes.get(i);
|
||||
shape = VoxelShapes.combine(shape, VoxelShapes.create(box), IBooleanFunction.OR);
|
||||
Box box = boxes.get(i);
|
||||
shape = VoxelShapes.combine(shape, VoxelShapes.cuboid(box), BooleanBiFunction.OR);
|
||||
}
|
||||
return shape.simplify();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user