Scanning the Far Lands for Rails

- Fixed basins not continuing their processing when items are extracted by funnel #1416
- Basins now accept full stacks for items thrown into the top manually
- Fixed Smart Chutes not dropping filter items
- Fixed Smart Chutes not updating attached diagonal chutes properly when removed
- Fixed Server-side crash when coupling two minecarts from a glitched self-colliding pile
This commit is contained in:
simibubi 2021-04-15 14:43:34 +02:00
parent 2fc26f1112
commit f9d48386ca
10 changed files with 57 additions and 15 deletions

View file

@ -101,6 +101,8 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
if (!tag.getBoolean("Deployed"))
return;
SchematicWorld schematicWorld = SchematicInstances.get(world, filter);
if (schematicWorld == null)
return;
if (!schematicWorld.getBounds()
.isVecInside(pos.subtract(schematicWorld.anchor)))
return;

View file

@ -93,7 +93,10 @@ public class CouplingPhysics {
public static void softCollisionStep(World world, Couple<AbstractMinecartEntity> carts, double couplingLength) {
Couple<Float> maxSpeed = carts.map(AbstractMinecartEntity::getMaxCartSpeedOnRail);
Couple<Boolean> canAddmotion = carts.map(MinecartSim2020::canAddMotion);
// Assuming Minecarts will never move faster than 1 block/tick
Couple<Vector3d> motions = carts.map(Entity::getMotion);
motions.replaceWithParams(VecHelper::clamp, Couple.create(1f, 1f));
Couple<Vector3d> nextPositions = carts.map(MinecartSim2020::predictNextPositionOf);
Couple<RailShape> shapes = carts.mapWithContext((cart, current) -> {

View file

@ -8,6 +8,7 @@ import com.google.common.collect.Maps;
import com.mojang.datafixers.util.Pair;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.BlockState;
@ -47,7 +48,7 @@ public class MinecartSim2020 {
public static Vector3d predictNextPositionOf(AbstractMinecartEntity cart) {
Vector3d position = cart.getPositionVec();
Vector3d motion = cart.getMotion();
Vector3d motion = VecHelper.clamp(cart.getMotion(), 1f);
return position.add(motion);
}

View file

@ -131,8 +131,13 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
return;
ItemEntity itemEntity = (ItemEntity) entityIn;
withTileEntityDo(worldIn, entityIn.getBlockPos(), te -> {
// Tossed items bypass the quarter-stack limit
te.inputInventory.withMaxStackSize(64);
ItemStack insertItem = ItemHandlerHelper.insertItem(te.inputInventory, itemEntity.getItem()
.copy(), false);
te.inputInventory.withMaxStackSize(16);
if (insertItem.isEmpty()) {
itemEntity.remove();
if (!itemEntity.world.isRemote)

View file

@ -7,8 +7,11 @@ import net.minecraftforge.items.ItemHandlerHelper;
public class BasinInventory extends SmartInventory {
private BasinTileEntity te;
public BasinInventory(int slots, BasinTileEntity te) {
super(slots, te, 16, true);
this.te = te;
}
@Override
@ -19,5 +22,13 @@ public class BasinInventory extends SmartInventory {
return stack;
return super.insertItem(slot, stack, simulate);
}
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
ItemStack extractItem = super.extractItem(slot, amount, simulate);
if (!simulate && !extractItem.isEmpty())
te.notifyChangeOfContents();
return extractItem;
}
}

View file

@ -96,7 +96,8 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
super(type);
inputInventory = new BasinInventory(9, this);
inputInventory.whenContentsChanged($ -> contentsChanged = true);
outputInventory = new BasinInventory(9, this).forbidInsertion();
outputInventory = new BasinInventory(9, this).forbidInsertion()
.withMaxStackSize(64);
areFluidsMoving = false;
itemCapability = LazyOptional.of(() -> new CombinedInvWrapper(inputInventory, outputInventory));
contentsChanged = true;

View file

@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.Iterate;
@ -49,7 +50,7 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
public static boolean isOpenChute(BlockState state) {
return isChute(state) && ((AbstractChuteBlock) state.getBlock()).isOpen(state);
}
public static boolean isTransparentChute(BlockState state) {
return isChute(state) && ((AbstractChuteBlock) state.getBlock()).isTransparent(state);
}
@ -66,7 +67,7 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
public boolean isOpen(BlockState state) {
return true;
}
public boolean isTransparent(BlockState state) {
return false;
}
@ -128,6 +129,7 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState p_196243_4_, boolean p_196243_5_) {
boolean differentBlock = state.getBlock() != p_196243_4_.getBlock();
if (state.hasTileEntity() && (differentBlock || !p_196243_4_.hasTileEntity())) {
TileEntityBehaviour.destroy(world, pos, FilteringBehaviour.TYPE);
withTileEntityDo(world, pos, c -> c.onRemoved(state));
world.removeTileEntity(pos);
}
@ -140,7 +142,10 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
BlockPos toUpdate = pos.up()
.offset(direction);
BlockState stateToUpdate = world.getBlockState(toUpdate);
BlockState updated = updateChuteState(stateToUpdate, world.getBlockState(toUpdate.up()), world, toUpdate);
if (!isChute(stateToUpdate))
continue;
BlockState updated = ((AbstractChuteBlock) stateToUpdate.getBlock()).updateChuteState(stateToUpdate,
world.getBlockState(toUpdate.up()), world, toUpdate);
if (stateToUpdate != updated && !world.isRemote)
world.setBlockState(toUpdate, updated);
}
@ -157,9 +162,11 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
@Override
public void neighborChanged(BlockState p_220069_1_, World world, BlockPos pos, Block p_220069_4_,
BlockPos neighbourPos, boolean p_220069_6_) {
if (pos.down().equals(neighbourPos))
if (pos.down()
.equals(neighbourPos))
withTileEntityDo(world, pos, ChuteTileEntity::blockBelowChanged);
else if (pos.up().equals(neighbourPos))
else if (pos.up()
.equals(neighbourPos))
withTileEntityDo(world, pos, chute -> chute.capAbove = LazyOptional.empty());
}
@ -171,13 +178,13 @@ public abstract class AbstractChuteBlock extends Block implements IWrenchable, I
BlockHelper.addReducedDestroyEffects(state, world, pos, manager);
return true;
}
@Override
public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_,
ISelectionContext p_220053_4_) {
return ChuteShapes.getShape(p_220053_1_);
}
@Override
public VoxelShape getCollisionShape(BlockState p_220071_1_, IBlockReader p_220071_2_, BlockPos p_220071_3_,
ISelectionContext p_220071_4_) {

View file

@ -3,6 +3,8 @@ package com.simibubi.create.content.logistics.block.chute;
import java.util.Random;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;

View file

@ -35,12 +35,14 @@ public class SchematicInstances {
public static SchematicWorld get(World world, ItemStack schematic) {
Cache<Integer, SchematicWorld> map = loadedSchematics.get(world);
int hash = getHash(schematic);
try {
return map.get(hash, () -> loadWorld(world, schematic));
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
SchematicWorld ifPresent = map.getIfPresent(hash);
if (ifPresent != null)
return ifPresent;
SchematicWorld loadWorld = loadWorld(world, schematic);
if (loadWorld == null)
return null;
map.put(hash, loadWorld);
return loadWorld;
}
private static SchematicWorld loadWorld(World wrapped, ItemStack schematic) {

View file

@ -18,6 +18,7 @@ public class SmartInventory extends RecipeWrapper
protected boolean extractionAllowed;
protected boolean insertionAllowed;
protected boolean stackNonStackables;
protected SyncedStackHandler wrapped;
protected int stackSize;
public SmartInventory(int slots, SyncedTileEntity te) {
@ -30,6 +31,13 @@ public class SmartInventory extends RecipeWrapper
insertionAllowed = true;
extractionAllowed = true;
this.stackSize = stackSize;
wrapped = (SyncedStackHandler) inv;
}
public SmartInventory withMaxStackSize(int maxStackSize) {
stackSize = maxStackSize;
wrapped.stackSize = maxStackSize;
return this;
}
public SmartInventory whenContentsChanged(Consumer<Integer> updateCallback) {