diff --git a/README.md b/README.md
index 20d62523a..a7fc50bd6 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
Create
-
-
+
+
@@ -19,7 +19,6 @@ Check out the wiki and in-game Tool-tips for further info on how to use these fe
[](https://www.patreon.com/simibubi "Support Us")
- Support for Minecraft 1.12: Not planned
-- Support for Minecraft 1.16: Porting efforts are making good progress.
- Support for Fabric: Not planned
Find out more about Create on our Project Page
diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache
index 21ba221e9..ecb704331 100644
--- a/src/generated/resources/.cache/cache
+++ b/src/generated/resources/.cache/cache
@@ -39,7 +39,7 @@ b8dd6e505943e06706d0718ece620ab3cf943650 assets/create/blockstates/brass_casing.
11ebdd9bd0815833e62ec1bea03a4cdd86ce00f3 assets/create/blockstates/brown_sail.json
e81608346d43406ee72cae0f78b8bcfb37ba2d75 assets/create/blockstates/brown_seat.json
322289524c058fac66bbe76b4924c3b0c0c33b84 assets/create/blockstates/brown_valve_handle.json
-26f3b6a8f8249e4e622ab200057d75e228762817 assets/create/blockstates/cart_assembler.json
+1ef072f86d95fd84638bbb6c298603eb311d1e53 assets/create/blockstates/cart_assembler.json
7299cea212d879d6d5611bd139b24768b9af236f assets/create/blockstates/chiseled_dark_scoria.json
0f01f813388d3e6907c1cfd992e4b21c914e267e assets/create/blockstates/chiseled_dolomite.json
324488e0c228f38f2597b2f76849e962bc1a7d90 assets/create/blockstates/chiseled_gabbro.json
@@ -337,7 +337,7 @@ e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets/create/blockstates/powered_toggl
d06cd9a1101b18d306a786320aab12018b1325d6 assets/create/blockstates/purple_sail.json
92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json
61035f8afe75ff7bbd291da5d8690bcbebe679eb assets/create/blockstates/purple_valve_handle.json
-ab2a1bf8f37f1c64d00538867f4c3a97195bd3c4 assets/create/blockstates/radial_chassis.json
+6fa36883e76e9e403bb429c8f86b8c0d3bba0cff assets/create/blockstates/radial_chassis.json
45877c4d90a7185c2f304edbd67379d800920439 assets/create/blockstates/red_sail.json
da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json
722fc77bbf387af8a4016e42cbf9501d2b968881 assets/create/blockstates/red_valve_handle.json
@@ -1226,7 +1226,7 @@ c1da21be9f1af4f7a2ef4ec9cd92195d65ada316 assets/create/models/item/clockwork_bea
0a2a0f0aafeab0088172f77afd40c1fa2cc1f2b8 assets/create/models/item/clutch.json
dcb09deae110077bcddf090996b51cc66e9a7de3 assets/create/models/item/cogwheel.json
7717e3b21cff39f497f07687c70c1fa40eaa756d assets/create/models/item/content_observer.json
-e903818e22c6286af8e09dc01551335174a83fe0 assets/create/models/item/controller_rail.json
+9dbd63c9e1b09a663fd4b83d76e3ab5967086167 assets/create/models/item/controller_rail.json
965a90a882d85dba93b30af9bce7ecf8e68ce747 assets/create/models/item/copper_block.json
759bcb5fe7dfdd628716f9b4ff19a5ab00393381 assets/create/models/item/copper_casing.json
c2a320162daa2d24cef969d1d14a0cbd55eb574f assets/create/models/item/copper_ingot.json
diff --git a/src/generated/resources/assets/create/blockstates/cart_assembler.json b/src/generated/resources/assets/create/blockstates/cart_assembler.json
index ec6f465b9..0349a4837 100644
--- a/src/generated/resources/assets/create/blockstates/cart_assembler.json
+++ b/src/generated/resources/assets/create/blockstates/cart_assembler.json
@@ -24,36 +24,66 @@
"powered=true,rail_type=activator_rail,shape=north_south": {
"model": "create:block/cart_assembler/block_activator_rail_powered"
},
+ "powered=false,rail_type=controller_rail,shape=north_south": {
+ "model": "create:block/cart_assembler/block_controller_rail"
+ },
+ "powered=true,rail_type=controller_rail,shape=north_south": {
+ "model": "create:block/cart_assembler/block_controller_rail_powered"
+ },
+ "powered=false,rail_type=controller_rail_backwards,shape=north_south": {
+ "model": "create:block/cart_assembler/block_controller_rail",
+ "y": 180
+ },
+ "powered=true,rail_type=controller_rail_backwards,shape=north_south": {
+ "model": "create:block/cart_assembler/block_controller_rail_powered",
+ "y": 180
+ },
"powered=false,rail_type=regular,shape=east_west": {
"model": "create:block/cart_assembler/block_regular",
- "y": 90
+ "y": 270
},
"powered=true,rail_type=regular,shape=east_west": {
"model": "create:block/cart_assembler/block_regular_powered",
- "y": 90
+ "y": 270
},
"powered=false,rail_type=powered_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_rail",
- "y": 90
+ "y": 270
},
"powered=true,rail_type=powered_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_rail_powered",
- "y": 90
+ "y": 270
},
"powered=false,rail_type=detector_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_detector_rail",
- "y": 90
+ "y": 270
},
"powered=true,rail_type=detector_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_detector_rail_powered",
- "y": 90
+ "y": 270
},
"powered=false,rail_type=activator_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_activator_rail",
- "y": 90
+ "y": 270
},
"powered=true,rail_type=activator_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_activator_rail_powered",
+ "y": 270
+ },
+ "powered=false,rail_type=controller_rail,shape=east_west": {
+ "model": "create:block/cart_assembler/block_controller_rail",
+ "y": 270
+ },
+ "powered=true,rail_type=controller_rail,shape=east_west": {
+ "model": "create:block/cart_assembler/block_controller_rail_powered",
+ "y": 270
+ },
+ "powered=false,rail_type=controller_rail_backwards,shape=east_west": {
+ "model": "create:block/cart_assembler/block_controller_rail",
+ "y": 90
+ },
+ "powered=true,rail_type=controller_rail_backwards,shape=east_west": {
+ "model": "create:block/cart_assembler/block_controller_rail_powered",
"y": 90
}
}
diff --git a/src/generated/resources/assets/create/models/item/controller_rail.json b/src/generated/resources/assets/create/models/item/controller_rail.json
index 3e4d4be29..5bd031d95 100644
--- a/src/generated/resources/assets/create/models/item/controller_rail.json
+++ b/src/generated/resources/assets/create/models/item/controller_rail.json
@@ -1,6 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
- "layer0": "create:block/controller_rail_item"
+ "layer0": "create:block/controller_rail"
}
}
\ No newline at end of file
diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java
index 46b019a8a..5012cee13 100644
--- a/src/main/java/com/simibubi/create/AllBlocks.java
+++ b/src/main/java/com/simibubi/create/AllBlocks.java
@@ -761,7 +761,7 @@ public class AllBlocks {
.onRegister(CreateRegistrate.blockColors(() -> AllColorHandlers::getRedstonePower))
.tag(BlockTags.RAILS)
.item()
- .model((c, p) -> p.generated(c, Create.asResource("block/" + c.getName() + "_item")))
+ .model((c, p) -> p.generated(c, Create.asResource("block/" + c.getName())))
.build()
.register();
diff --git a/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java
index d252b40f3..9bc30ce82 100644
--- a/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java
+++ b/src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java
@@ -77,6 +77,8 @@ public class SpoutCategory extends CreateRecipeCategory {
ItemStack container = fhi.getContainer();
if (container.isItemEqual(copy))
return;
+ if (container.isEmpty())
+ return;
Ingredient bucket = Ingredient.fromStacks(stack);
ResourceLocation itemName = stack.getItem()
diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java
index bce6c6e1d..e75d55a55 100644
--- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java
+++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java
@@ -172,7 +172,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
return;
}
- if (runningTicks == CYCLE / 2) {
+ if (runningTicks == CYCLE / 2 && getSpeed() != 0) {
if (inWorld())
applyPressingInWorld();
if (onBasin())
diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java
index 6e434eacf..3692bd43f 100644
--- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java
+++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java
@@ -64,6 +64,7 @@ import net.minecraft.block.SlimeBlock;
import net.minecraft.entity.Entity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
+import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.NBTUtil;
@@ -86,6 +87,7 @@ import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.IFluidHandler;
+import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.templates.FluidTank;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@@ -608,12 +610,12 @@ public abstract class Contraption {
int index = 0;
for (MountedStorage mountedStorage : storage.values())
handlers[index++] = mountedStorage.getItemHandler();
-
+
IFluidHandler[] fluidHandlers = new IFluidHandler[fluidStorage.size()];
index = 0;
for (MountedFluidStorage mountedStorage : fluidStorage.values())
fluidHandlers[index++] = mountedStorage.getFluidHandler();
-
+
inventory = new CombinedInvWrapper(handlers);
fluidInventory = new CombinedTankWrapper(fluidHandlers);
@@ -824,6 +826,11 @@ public abstract class Contraption {
}
}
+ for (int i = 0; i < inventory.getSlots(); i++)
+ inventory.setStackInSlot(i, ItemStack.EMPTY);
+ for (int i = 0; i < fluidInventory.getTanks(); i++)
+ fluidInventory.drain(fluidInventory.getFluidInTank(i), FluidAction.EXECUTE);
+
for (Pair pair : superglue) {
BlockPos targetPos = transform.apply(pair.getKey());
Direction targetFacing = transform.transformFacing(pair.getValue());
diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssembleRailType.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssembleRailType.java
index a05de16ab..ce5b76e7d 100644
--- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssembleRailType.java
+++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssembleRailType.java
@@ -1,27 +1,54 @@
package com.simibubi.create.content.contraptions.components.structureMovement.mounted;
+import com.simibubi.create.AllBlocks;
+import com.simibubi.create.content.contraptions.components.tracks.ControllerRailBlock;
import com.simibubi.create.foundation.utility.Lang;
+import com.tterrag.registrate.util.entry.BlockEntry;
import net.minecraft.block.Block;
+import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.IStringSerializable;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
public enum CartAssembleRailType implements IStringSerializable {
REGULAR(Blocks.RAIL),
POWERED_RAIL(Blocks.POWERED_RAIL),
DETECTOR_RAIL(Blocks.DETECTOR_RAIL),
ACTIVATOR_RAIL(Blocks.ACTIVATOR_RAIL),
+ CONTROLLER_RAIL(AllBlocks.CONTROLLER_RAIL, blockState -> AllBlocks.CONTROLLER_RAIL.has(blockState)
+ && blockState.has(ControllerRailBlock.BACKWARDS) && !blockState.get(ControllerRailBlock.BACKWARDS)),
+ CONTROLLER_RAIL_BACKWARDS(AllBlocks.CONTROLLER_RAIL, blockState -> AllBlocks.CONTROLLER_RAIL.has(blockState)
+ && blockState.has(ControllerRailBlock.BACKWARDS) && blockState.get(ControllerRailBlock.BACKWARDS))
;
- public Block railBlock;
- public Item railItem;
+ private final Supplier railBlockSupplier;
+ private final Supplier- railItemSupplier;
+ public final Predicate matches;
- private CartAssembleRailType(Block block) {
- this.railBlock = block;
- this.railItem = block.asItem();
+ CartAssembleRailType(Block block) {
+ this.railBlockSupplier = () -> block;
+ this.railItemSupplier = block::asItem;
+ this.matches = blockState -> blockState.getBlock() == getBlock();
+ }
+
+ CartAssembleRailType(BlockEntry> block, Predicate matches) {
+ this.railBlockSupplier = block::get;
+ this.railItemSupplier = () -> block.get().asItem();
+ this.matches = matches;
+ }
+
+ public Block getBlock() {
+ return railBlockSupplier.get();
+ }
+
+ public Item getItem() {
+ return railItemSupplier.get();
}
@Override
diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java
index 8868fc7a4..20c79a460 100644
--- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java
+++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlock.java
@@ -16,6 +16,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.mou
import com.simibubi.create.content.contraptions.components.structureMovement.train.CouplingHandler;
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.content.contraptions.components.tracks.ControllerRailBlock;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement;
@@ -51,6 +52,7 @@ import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Hand;
+import net.minecraft.util.Rotation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
@@ -60,6 +62,7 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.math.vector.Vector3d;
+import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
@@ -88,13 +91,17 @@ public class CartAssemblerBlock extends AbstractRailBlock
}
private static Item getRailItem(BlockState state) {
- return state.get(RAIL_TYPE).railItem;
+ return state.get(RAIL_TYPE).getItem();
}
public static BlockState getRailBlock(BlockState state) {
- AbstractRailBlock railBlock = (AbstractRailBlock) state.get(RAIL_TYPE).railBlock;
- return railBlock.getDefaultState()
+ AbstractRailBlock railBlock = (AbstractRailBlock) state.get(RAIL_TYPE).getBlock();
+ BlockState railState = railBlock.getDefaultState()
.with(railBlock.getShapeProperty(), state.get(RAIL_SHAPE));
+ if (railState.contains(ControllerRailBlock.BACKWARDS)) {
+ railState = railState.with(ControllerRailBlock.BACKWARDS, state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS);
+ }
+ return railState;
}
@Override
@@ -188,6 +195,11 @@ public class CartAssemblerBlock extends AbstractRailBlock
float speed = getRailMaxSpeed(state, world, pos, cart);
cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed, facing.getZOffset() * speed);
}
+ if (action == CartAssemblerAction.ASSEMBLE_ACCELERATE_DIRECTIONAL) {
+ Vector3i accelerationVector = ControllerRailBlock.getAccelerationVector(AllBlocks.CONTROLLER_RAIL.getDefaultState().with(ControllerRailBlock.SHAPE, state.get(RAIL_SHAPE)).with(ControllerRailBlock.BACKWARDS, state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS));
+ float speed = getRailMaxSpeed(state, world, pos, cart);
+ cart.setMotion(Vector3d.of(accelerationVector).scale(speed));
+ }
if (action == CartAssemblerAction.DISASSEMBLE_BRAKE) {
Vector3d diff = VecHelper.getCenterOf(pos)
.subtract(cart.getPositionVec());
@@ -198,10 +210,10 @@ public class CartAssemblerBlock extends AbstractRailBlock
}
public enum CartAssemblerAction {
- ASSEMBLE, DISASSEMBLE, ASSEMBLE_ACCELERATE, DISASSEMBLE_BRAKE, PASS;
+ ASSEMBLE, DISASSEMBLE, ASSEMBLE_ACCELERATE, DISASSEMBLE_BRAKE, ASSEMBLE_ACCELERATE_DIRECTIONAL, PASS;
public boolean shouldAssemble() {
- return this == ASSEMBLE || this == ASSEMBLE_ACCELERATE;
+ return this == ASSEMBLE || this == ASSEMBLE_ACCELERATE || this == ASSEMBLE_ACCELERATE_DIRECTIONAL;
}
public boolean shouldDisassemble() {
@@ -226,6 +238,9 @@ public class CartAssemblerBlock extends AbstractRailBlock
return cart.getPassengers()
.isEmpty() ? CartAssemblerAction.ASSEMBLE_ACCELERATE : CartAssemblerAction.DISASSEMBLE;
+ if (type == CartAssembleRailType.CONTROLLER_RAIL || type == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS)
+ return powered ? CartAssemblerAction.ASSEMBLE_ACCELERATE_DIRECTIONAL : CartAssemblerAction.DISASSEMBLE_BRAKE;
+
return CartAssemblerAction.PASS;
}
@@ -245,7 +260,7 @@ public class CartAssemblerBlock extends AbstractRailBlock
CartAssembleRailType newType = null;
for (CartAssembleRailType type : CartAssembleRailType.values())
- if (heldItem == type.railItem)
+ if (heldItem == type.getItem())
newType = type;
if (newType == null)
return ActionResultType.PASS;
@@ -499,4 +514,22 @@ public class CartAssemblerBlock extends AbstractRailBlock
return VoxelShapes.empty();
}
}
+
+ @Override
+ public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
+ World world = context.getWorld();
+ if (world.isRemote)
+ return ActionResultType.SUCCESS;
+ BlockPos pos = context.getPos();
+ BlockState newState = state.with(RAIL_SHAPE, state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH);
+ if (state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL || state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS) {
+ newState = newState.with(RAIL_TYPE, AllBlocks.CONTROLLER_RAIL.get().rotate(AllBlocks.CONTROLLER_RAIL.getDefaultState()
+ .with(ControllerRailBlock.SHAPE, state.get(RAIL_SHAPE)).with(ControllerRailBlock.BACKWARDS,
+ state.get(RAIL_TYPE) == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS), Rotation.CLOCKWISE_90)
+ .get(ControllerRailBlock.BACKWARDS) ? CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS : CartAssembleRailType.CONTROLLER_RAIL);
+ }
+ context.getWorld().setBlockState(pos, newState, 3);
+ world.notifyNeighborsOfStateChange(pos.down(), this);
+ return ActionResultType.SUCCESS;
+ }
}
diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java
index 1ee299c5b..78c25232b 100644
--- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java
+++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java
@@ -56,7 +56,7 @@ public class CartAssemblerBlockItem extends BlockItem {
.with(CartAssemblerBlock.RAIL_SHAPE, shape);
CartAssembleRailType newType = null;
for (CartAssembleRailType type : CartAssembleRailType.values())
- if (block == type.railBlock)
+ if (type.matches.test(state))
newType = type;
if (newType == null)
return false;
diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java
index be2703b7d..95d44b209 100644
--- a/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java
+++ b/src/main/java/com/simibubi/create/content/contraptions/components/tracks/ControllerRailBlock.java
@@ -55,7 +55,7 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl
.with(SHAPE, NORTH_SOUTH));
}
- private static Vector3i getAccelerationVector(BlockState state) {
+ public static Vector3i getAccelerationVector(BlockState state) {
Direction pointingTo = getPointingTowards(state);
return (isStateBackwards(state) ? pointingTo.getOpposite() : pointingTo).getDirectionVec();
}
diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java
index cd96a9655..8a5f98693 100644
--- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java
+++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java
@@ -158,6 +158,7 @@ public class BasinBlock extends Block implements ITE, IWrenchab
withTileEntityDo(worldIn, pos, te -> {
ItemHelper.dropContents(worldIn, pos, te.inputInventory);
ItemHelper.dropContents(worldIn, pos, te.outputInventory);
+ te.spoutputBuffer.forEach(is -> Block.spawnAsEntity(worldIn, pos, is));
});
worldIn.removeTileEntity(pos);
}
diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java
index 30c28ccb8..de10e77c9 100644
--- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java
+++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntity.java
@@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.processing;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Random;
@@ -34,6 +35,7 @@ import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
+import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -83,6 +85,7 @@ public class BasinTileEntity extends SmartTileEntity {
List disabledSpoutputs;
Direction preferredSpoutput;
+ protected List spoutputBuffer;
public static final int OUTPUT_ANIMATION_TIME = 10;
List> visualizedOutputItems;
@@ -107,6 +110,7 @@ public class BasinTileEntity extends SmartTileEntity {
visualizedOutputFluids = Collections.synchronizedList(new ArrayList<>());
disabledSpoutputs = new ArrayList<>();
preferredSpoutput = null;
+ spoutputBuffer = new ArrayList<>();
}
@Override
@@ -144,6 +148,7 @@ public class BasinTileEntity extends SmartTileEntity {
disabledSpoutputs.clear();
ListNBT disabledList = compound.getList("DisabledSpoutput", NBT.TAG_STRING);
disabledList.forEach(d -> disabledSpoutputs.add(Direction.valueOf(((StringNBT) d).getString())));
+ spoutputBuffer = NBTHelper.readItemList(compound.getList("Overflow", NBT.TAG_COMPOUND));
if (!clientPacket)
return;
@@ -166,6 +171,7 @@ public class BasinTileEntity extends SmartTileEntity {
ListNBT disabledList = new ListNBT();
disabledSpoutputs.forEach(d -> disabledList.add(StringNBT.of(d.name())));
compound.put("DisabledSpoutput", disabledList);
+ compound.put("Overflow", NBTHelper.writeItemList(spoutputBuffer));
if (!clientPacket)
return;
@@ -270,6 +276,10 @@ public class BasinTileEntity extends SmartTileEntity {
ingredientRotationSpeed.tickChaser();
ingredientRotation.setValue(ingredientRotation.getValue() + ingredientRotationSpeed.getValue());
}
+
+ if (!spoutputBuffer.isEmpty() && !world.isRemote)
+ tryClearingSpoutputOverflow();
+
if (!contentsChanged)
return;
contentsChanged = false;
@@ -288,6 +298,46 @@ public class BasinTileEntity extends SmartTileEntity {
}
}
+ private void tryClearingSpoutputOverflow() {
+ BlockState blockState = getBlockState();
+ if (!(blockState.getBlock() instanceof BasinBlock))
+ return;
+ Direction direction = blockState.get(BasinBlock.FACING);
+ TileEntity te = world.getTileEntity(pos.down()
+ .offset(direction));
+ IItemHandler targetInv = te == null ? null
+ : te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite())
+ .orElse(null);
+ boolean update = false;
+
+ for (Iterator iterator = spoutputBuffer.iterator(); iterator.hasNext();) {
+ ItemStack itemStack = iterator.next();
+
+ if (direction == Direction.DOWN) {
+ Block.spawnAsEntity(world, pos, itemStack);
+ iterator.remove();
+ update = true;
+ continue;
+ }
+
+ if (targetInv == null)
+ return;
+ if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack, true)
+ .isEmpty())
+ continue;
+
+ update = true;
+ ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false);
+ iterator.remove();
+ visualizedOutputItems.add(IntAttached.withZero(itemStack));
+ }
+
+ if (update) {
+ notifyChangeOfContents();
+ sendData();
+ }
+ }
+
public float getTotalFluidUnits(float partialTicks) {
int renderedFluids = 0;
float totalUnits = 0;
@@ -371,6 +421,8 @@ public class BasinTileEntity extends SmartTileEntity {
} else {
// Output basin, try moving items to it
+ if (!spoutputBuffer.isEmpty())
+ return false;
TileEntity te = world.getTileEntity(pos.down()
.offset(direction));
if (te == null)
@@ -383,12 +435,14 @@ public class BasinTileEntity extends SmartTileEntity {
if (targetInv == null && !outputItems.isEmpty())
return false;
- for (ItemStack itemStack : outputItems)
- if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), simulate)
- .isEmpty())
- return false;
- else if (!simulate)
- visualizedOutputItems.add(IntAttached.withZero(itemStack));
+ for (ItemStack itemStack : outputItems) {
+ if (simulate) {
+ if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), simulate)
+ .isEmpty())
+ return false;
+ } else
+ spoutputBuffer.add(itemStack.copy());
+ }
if (outputFluids.isEmpty())
return true;
diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java
index 9a8d76134..b0df8a1bc 100644
--- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java
+++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BrassTunnelTileEntity.java
@@ -205,7 +205,10 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
indexStart = 0;
ItemStack toDistribute = null;
+ int leftovers = 0;
+
for (boolean simulate : Iterate.trueAndFalse) {
+ leftovers = 0;
int index = indexStart;
int stackSize = stackToDistribute.getCount();
int splitStackSize = stackSize / amountTargets;
@@ -226,12 +229,13 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
ItemStack toOutput = ItemHandlerHelper.copyStackWithSize(toDistribute, count);
ItemStack remainder = insertIntoTunnel(tunnel, side, toOutput, simulate);
- if (remainder == null || !remainder.isEmpty()) {
+ if (remainder == null || remainder.getCount() == count) {
if (force)
return;
continue;
}
+ leftovers += remainder.getCount();
toDistribute.shrink(count);
if (toDistribute.isEmpty())
break;
@@ -241,7 +245,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
}
}
- stackToDistribute = toDistribute.copy();
+ stackToDistribute = ItemHandlerHelper.copyStackWithSize(stackToDistribute, toDistribute.getCount() + leftovers);
previousOutputIndex++;
previousOutputIndex %= amountTargets;
notifyUpdate();
diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java
index 7aafc14d4..750df89b1 100644
--- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java
+++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java
@@ -9,6 +9,7 @@ import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
+import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
@@ -39,6 +40,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
private Map blocks;
private Map tileEntities;
+ private List renderedTileEntities;
private List entities;
private MutableBoundingBox bounds;
public BlockPos anchor;
@@ -55,6 +57,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
this.bounds = new MutableBoundingBox();
this.anchor = anchor;
this.entities = new ArrayList<>();
+ this.renderedTileEntities = new ArrayList<>();
}
public Set getAllPositions() {
@@ -90,12 +93,17 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
BlockState blockState = getBlockState(pos);
if (blockState.hasTileEntity()) {
- TileEntity tileEntity = blockState.createTileEntity(this);
- if (tileEntity != null) {
- tileEntity.setLocation(this, pos);
- tileEntities.put(pos, tileEntity);
+ try {
+ TileEntity tileEntity = blockState.createTileEntity(this);
+ if (tileEntity != null) {
+ tileEntity.setLocation(this, pos);
+ tileEntities.put(pos, tileEntity);
+ renderedTileEntities.add(tileEntity);
+ }
+ return tileEntity;
+ } catch (Exception e) {
+ Create.logger.debug("Could not create TE of block " + blockState + ": " + e);
}
- return tileEntity;
}
return null;
}
@@ -192,8 +200,8 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
return bounds;
}
- public Iterable getTileEntities() {
- return tileEntities.values();
+ public Iterable getRenderedTileEntities() {
+ return renderedTileEntities;
}
@Override
diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java
index 7b7a2f8ec..95bc3f84d 100644
--- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java
+++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java
@@ -126,9 +126,8 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen