Merge branch 'mc1.18/dev' into mc1.19/dev

This commit is contained in:
simibubi 2022-09-06 15:48:31 +02:00
commit e268784f5a
8 changed files with 90 additions and 32 deletions

View file

@ -15,6 +15,7 @@
"minecraft:tripwire",
"minecraft:tripwire_hook",
"minecraft:daylight_detector",
"minecraft:target"
"minecraft:target",
"minecraft:hopper"
]
}

View file

@ -412,7 +412,7 @@ public class AllTags {
AllBlockTags.WRENCH_PICKUP.includeAll(BlockTags.PRESSURE_PLATES);
AllBlockTags.WRENCH_PICKUP.add(Blocks.REDSTONE_WIRE, Blocks.REDSTONE_TORCH, Blocks.REPEATER, Blocks.LEVER,
Blocks.COMPARATOR, Blocks.OBSERVER, Blocks.REDSTONE_WALL_TORCH, Blocks.PISTON, Blocks.STICKY_PISTON,
Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK, Blocks.DAYLIGHT_DETECTOR, Blocks.TARGET);
Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK, Blocks.DAYLIGHT_DETECTOR, Blocks.TARGET, Blocks.HOPPER);
AllBlockTags.ORE_OVERRIDE_STONE.includeAll(BlockTags.STONE_ORE_REPLACEABLES);

View file

@ -9,7 +9,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.IntStream;
import org.apache.commons.lang3.tuple.Pair;
@ -159,13 +158,17 @@ public class RecipeGridHandler {
}
public static boolean isRecipeAllowed(CraftingRecipe recipe, CraftingContainer inventory) {
if (!AllConfigs.SERVER.recipes.allowBiggerFireworksInCrafter.get() && recipe instanceof FireworkRocketRecipe) {
int numItems = IntStream.range(0, inventory.getContainerSize())
.map(i -> inventory.getItem(i).isEmpty() ? 0 : 1)
.sum();
if (numItems > 9)
if (recipe instanceof FireworkRocketRecipe) {
int numItems = 0;
for (int i = 0; i < inventory.getContainerSize(); i++) {
if (!inventory.getItem(i).isEmpty()) {
numItems++;
}
}
if (numItems > AllConfigs.SERVER.recipes.maxFireworkIngredientsInCrafter.get()) {
return false;
}
}
if (AllRecipeTypes.shouldIgnoreInAutomation(recipe))
return false;
return true;

View file

@ -4,6 +4,7 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -183,6 +184,8 @@ public class FluidNetwork {
}
int flowSpeed = transferSpeed;
Map<IFluidHandler, Integer> accumulatedFill = new IdentityHashMap<>();
for (boolean simulate : Iterate.trueAndFalse) {
FluidAction action = simulate ? FluidAction.SIMULATE : FluidAction.EXECUTE;
@ -213,6 +216,7 @@ public class FluidNetwork {
flowSpeed = transfer.getAmount();
List<Pair<BlockFace, LazyOptional<IFluidHandler>>> availableOutputs = new ArrayList<>(targets);
while (!availableOutputs.isEmpty() && transfer.getAmount() > 0) {
int dividedTransfer = transfer.getAmount() / availableOutputs.size();
int remainder = transfer.getAmount() % availableOutputs.size();
@ -235,11 +239,21 @@ public class FluidNetwork {
continue;
}
int simulatedTransfer = toTransfer;
if (simulate)
simulatedTransfer += accumulatedFill.getOrDefault(targetHandler, 0);
FluidStack divided = transfer.copy();
divided.setAmount(toTransfer);
divided.setAmount(simulatedTransfer);
int fill = targetHandler.fill(divided, action);
if (simulate) {
accumulatedFill.put(targetHandler, Integer.valueOf(fill));
fill -= simulatedTransfer - toTransfer;
}
transfer.setAmount(transfer.getAmount() - fill);
if (fill < toTransfer)
if (fill < simulatedTransfer)
iterator.remove();
}

View file

@ -118,9 +118,14 @@ public class Carriage {
return entities.get(dimension);
}
public double travel(Level level, TrackGraph graph, double distance,
Function<TravellingPoint, ITrackSelector> forwardControl,
Function<TravellingPoint, ITrackSelector> backwardControl, int type) {
public double travel(Level level, TrackGraph graph, double distance, TravellingPoint toFollowForward,
TravellingPoint toFollowBackward, int type) {
Function<TravellingPoint, ITrackSelector> forwardControl =
toFollowForward == null ? train.navigation::control : mp -> mp.follow(toFollowForward);
Function<TravellingPoint, ITrackSelector> backwardControl =
toFollowBackward == null ? train.navigation::control : mp -> mp.follow(toFollowBackward);
boolean onTwoBogeys = isOnTwoBogeys();
double stress = train.derailed ? 0 : onTwoBogeys ? bogeySpacing - getAnchorDiff() : 0;
blocked = false;
@ -825,13 +830,38 @@ public class Carriage {
double diffY = positionVec.y - coupledVec.y;
double diffZ = positionVec.z - coupledVec.z;
if (!entity.level.isClientSide())
entity.setServerSidePrevPosition();
entity.setPos(positionAnchor);
entity.prevYaw = entity.yaw;
entity.prevPitch = entity.pitch;
if (!entity.level.isClientSide()) {
Vec3 lookahead = positionAnchor.add(positionAnchor.subtract(entity.position())
.normalize()
.scale(16));
for (Entity e : entity.getPassengers()) {
if (!(e instanceof Player))
continue;
if (e.distanceToSqr(entity) > 32 * 32)
continue;
if (CarriageEntityHandler.isActiveChunk(entity.level, new BlockPos(lookahead)))
break;
train.carriageWaitingForChunks = id;
return;
}
if (entity.getPassengers()
.stream()
.anyMatch(p -> p instanceof Player)
) {
}
if (train.carriageWaitingForChunks == id)
train.carriageWaitingForChunks = -1;
entity.setServerSidePrevPosition();
}
entity.setPos(positionAnchor);
entity.yaw = (float) (Mth.atan2(diffZ, diffX) * 180 / Math.PI) + 180;
entity.pitch = (float) (Math.atan2(diffY, Math.sqrt(diffX * diffX + diffZ * diffZ)) * 180 / Math.PI) * -1;

View file

@ -21,6 +21,7 @@ import com.simibubi.create.content.logistics.trains.entity.TravellingPoint.ITrac
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.network.FriendlyByteBuf;
@ -39,6 +40,7 @@ public class CarriageSyncData {
private TravellingPoint[] pointsToApproach;
private float[] pointDistanceSnapshot;
private float destinationDistanceSnapshot;
private int ticksSince;
public CarriageSyncData() {
wheelLocations = new Vector<>(4);
@ -48,6 +50,7 @@ public class CarriageSyncData {
fallbackPointSnapshot = null;
destinationDistanceSnapshot = 0;
leadingCarriage = false;
ticksSince = 0;
for (int i = 0; i < 4; i++) {
wheelLocations.add(null);
pointsToApproach[i] = new TravellingPoint();
@ -92,6 +95,7 @@ public class CarriageSyncData {
public void read(FriendlyByteBuf buffer) {
leadingCarriage = buffer.readBoolean();
boolean fallback = buffer.readBoolean();
ticksSince = 0;
if (fallback) {
fallbackLocations =
@ -212,9 +216,18 @@ public class CarriageSyncData {
destinationDistanceSnapshot = (float) (distanceToDestination - carriage.train.navigation.distanceToDestination);
}
public void approach(CarriageContraptionEntity entity, Carriage carriage, float partial) {
public void approach(CarriageContraptionEntity entity, Carriage carriage, float partialIn) {
DimensionalCarriageEntity dce = carriage.getDimensional(entity.level);
int updateInterval = entity.getType()
.updateInterval();
if (ticksSince >= updateInterval * 2)
partialIn /= ticksSince - updateInterval * 2 + 1;
partialIn *= ServerSpeedProvider.get();
final float partial = partialIn;
ticksSince++;
if (fallbackLocations != null && fallbackPointSnapshot != null) {
dce.positionAnchor = approachVector(partial, dce.positionAnchor, fallbackLocations.getFirst(),
fallbackPointSnapshot.getFirst());

View file

@ -14,7 +14,6 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import javax.annotation.Nullable;
@ -32,7 +31,6 @@ import com.simibubi.create.content.logistics.trains.TrackGraph;
import com.simibubi.create.content.logistics.trains.TrackNode;
import com.simibubi.create.content.logistics.trains.entity.Carriage.DimensionalCarriageEntity;
import com.simibubi.create.content.logistics.trains.entity.TravellingPoint.IEdgePointListener;
import com.simibubi.create.content.logistics.trains.entity.TravellingPoint.ITrackSelector;
import com.simibubi.create.content.logistics.trains.entity.TravellingPoint.SteerDirection;
import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgeData;
import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgePointType;
@ -82,6 +80,7 @@ public class Train {
public double speed = 0;
public double targetSpeed = 0;
public Double speedBeforeStall = null;
public int carriageWaitingForChunks = -1;
public double throttle = 1;
public boolean honk = false;
@ -279,6 +278,9 @@ public class Train {
boolean stalled = false;
double maxStress = 0;
if (carriageWaitingForChunks != -1)
distance = 0;
for (int i = 0; i < carriageCount; i++) {
Carriage carriage = carriages.get(i);
if (previousCarriage != null) {
@ -366,18 +368,13 @@ public class Train {
: carriages.get(i + 1)
.getLeadingPoint();
Function<TravellingPoint, ITrackSelector> forwardControl =
toFollowForward == null ? navigation::control : mp -> mp.follow(toFollowForward);
Function<TravellingPoint, ITrackSelector> backwardControl =
toFollowBackward == null ? navigation::control : mp -> mp.follow(toFollowBackward);
double totalStress = derailed ? 0 : leadingStress + trailingStress;
boolean first = i == 0;
boolean last = i == carriageCount - 1;
int carriageType = first ? last ? Carriage.BOTH : Carriage.FIRST : last ? Carriage.LAST : Carriage.MIDDLE;
double actualDistance =
carriage.travel(level, graph, distance + totalStress, forwardControl, backwardControl, carriageType);
carriage.travel(level, graph, distance + totalStress, toFollowForward, toFollowBackward, carriageType);
blocked |= carriage.blocked;
boolean onTwoBogeys = carriage.isOnTwoBogeys();

View file

@ -8,8 +8,8 @@ public class CRecipes extends ConfigBase {
public final ConfigBool allowShapedSquareInPress = b(true, "allowShapedSquareInPress", Comments.allowShapedSquareInPress);
public final ConfigBool allowRegularCraftingInCrafter =
b(true, "allowRegularCraftingInCrafter", Comments.allowRegularCraftingInCrafter);
public final ConfigBool allowBiggerFireworksInCrafter =
b(false, "allowBiggerFireworksInCrafter", Comments.allowBiggerFireworksInCrafter);
public final ConfigInt maxFireworkIngredientsInCrafter =
i(9, 1, "maxFireworkIngredientsInCrafter", Comments.maxFireworkIngredientsInCrafter);
public final ConfigBool allowStonecuttingOnSaw = b(true, "allowStonecuttingOnSaw", Comments.allowStonecuttingOnSaw);
public final ConfigBool allowWoodcuttingOnSaw = b(true, "allowWoodcuttingOnSaw", Comments.allowWoodcuttingOnSaw);
public final ConfigBool allowCastingBySpout = b(true, "allowCastingBySpout", Comments.allowCastingBySpout);
@ -34,8 +34,8 @@ public class CRecipes extends ConfigBase {
"Allow any single-ingredient 2x2 or 3x3 crafting recipes to be processed by a Mechanical Press + Basin.";
static String allowRegularCraftingInCrafter =
"Allow any standard crafting recipes to be processed by Mechanical Crafters.";
static String allowBiggerFireworksInCrafter =
"Allow Firework Rockets with more than 9 ingredients to be crafted using Mechanical Crafters.";
static String maxFireworkIngredientsInCrafter =
"The Maximum amount of ingredients that can be used to craft Firework Rockets using Mechanical Crafters.";
static String allowStonecuttingOnSaw =
"Allow any stonecutting recipes to be processed by a Mechanical Saw.";
static String allowWoodcuttingOnSaw =