Merge branch 'mc1.15/dev' into mc1.16/dev

This commit is contained in:
simibubi 2020-12-22 13:31:14 +01:00
commit c3c834bd2b
23 changed files with 232 additions and 50 deletions

View File

@ -1,7 +1,7 @@
<p align="center"><img src="https://i.imgur.com/35JmqWB.gif" alt="Logo" width="100"></p> <p align="center"><img src="https://i.imgur.com/35JmqWB.gif" alt="Logo" width="100"></p>
<h1 align="center">Create<br> <h1 align="center">Create<br>
<a href="https://www.patreon.com/simibubi"><img src="https://img.shields.io/badge/Supporters-50+-ff5733" alt="Patreon"></a> <a href="https://www.patreon.com/simibubi"><img src="https://img.shields.io/badge/Supporters-60-ff5733" alt="Patreon"></a>
<a href="https://www.curseforge.com/minecraft/mc-mods/create/files"><img src="https://img.shields.io/badge/Available%20for-MC%201.14,%201.15-c70039" alt="Supported Versions"></a> <a href="https://www.curseforge.com/minecraft/mc-mods/create/files"><img src="https://img.shields.io/badge/Available%20for-MC%201.14,%201.15,%201.16-c70039" alt="Supported Versions"></a>
<a href="https://github.com/Creators-of-Create/Create/blob/master/LICENSE"><img src="https://img.shields.io/github/license/Creators-of-Create/Create?style=flat&color=900c3f" alt="License"></a> <a href="https://github.com/Creators-of-Create/Create/blob/master/LICENSE"><img src="https://img.shields.io/github/license/Creators-of-Create/Create?style=flat&color=900c3f" alt="License"></a>
<a href="https://discord.gg/hmaD7Se"><img src="https://img.shields.io/discord/620934202875183104?color=844685&label=Feedback%20%26%20Help&style=flat" alt="Discord"></a> <a href="https://discord.gg/hmaD7Se"><img src="https://img.shields.io/discord/620934202875183104?color=844685&label=Feedback%20%26%20Help&style=flat" alt="Discord"></a>
<a href="https://www.curseforge.com/minecraft/mc-mods/create"><img src="http://cf.way2muchnoise.eu/short_create.svg" alt="Curseforge Downloads"></a><br><br> <a href="https://www.curseforge.com/minecraft/mc-mods/create"><img src="http://cf.way2muchnoise.eu/short_create.svg" alt="Curseforge Downloads"></a><br><br>
@ -19,7 +19,6 @@ Check out the wiki and in-game Tool-tips for further info on how to use these fe
[<img src="https://i.imgur.com/xj8o2xC.jpg" width="210">](https://www.patreon.com/simibubi "Support Us") [<img src="https://i.imgur.com/xj8o2xC.jpg" width="210">](https://www.patreon.com/simibubi "Support Us")
- Support for Minecraft 1.12: Not planned - Support for Minecraft 1.12: Not planned
- Support for Minecraft 1.16: Porting efforts are making good progress.
- Support for Fabric: Not planned - Support for Fabric: Not planned
<hr> <hr>
<h4 align="center">Find out more about Create on our <a href="https://www.curseforge.com/minecraft/mc-mods/create">Project Page</a></h4> <h4 align="center">Find out more about Create on our <a href="https://www.curseforge.com/minecraft/mc-mods/create">Project Page</a></h4>

View File

@ -39,7 +39,7 @@ b8dd6e505943e06706d0718ece620ab3cf943650 assets/create/blockstates/brass_casing.
11ebdd9bd0815833e62ec1bea03a4cdd86ce00f3 assets/create/blockstates/brown_sail.json 11ebdd9bd0815833e62ec1bea03a4cdd86ce00f3 assets/create/blockstates/brown_sail.json
e81608346d43406ee72cae0f78b8bcfb37ba2d75 assets/create/blockstates/brown_seat.json e81608346d43406ee72cae0f78b8bcfb37ba2d75 assets/create/blockstates/brown_seat.json
322289524c058fac66bbe76b4924c3b0c0c33b84 assets/create/blockstates/brown_valve_handle.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 7299cea212d879d6d5611bd139b24768b9af236f assets/create/blockstates/chiseled_dark_scoria.json
0f01f813388d3e6907c1cfd992e4b21c914e267e assets/create/blockstates/chiseled_dolomite.json 0f01f813388d3e6907c1cfd992e4b21c914e267e assets/create/blockstates/chiseled_dolomite.json
324488e0c228f38f2597b2f76849e962bc1a7d90 assets/create/blockstates/chiseled_gabbro.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 d06cd9a1101b18d306a786320aab12018b1325d6 assets/create/blockstates/purple_sail.json
92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json 92957119abd5fbcca36a113b2a80255fd70fc303 assets/create/blockstates/purple_seat.json
61035f8afe75ff7bbd291da5d8690bcbebe679eb assets/create/blockstates/purple_valve_handle.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 45877c4d90a7185c2f304edbd67379d800920439 assets/create/blockstates/red_sail.json
da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json da1b08387af7afa0855ee8d040f620c01f20660a assets/create/blockstates/red_seat.json
722fc77bbf387af8a4016e42cbf9501d2b968881 assets/create/blockstates/red_valve_handle.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 0a2a0f0aafeab0088172f77afd40c1fa2cc1f2b8 assets/create/models/item/clutch.json
dcb09deae110077bcddf090996b51cc66e9a7de3 assets/create/models/item/cogwheel.json dcb09deae110077bcddf090996b51cc66e9a7de3 assets/create/models/item/cogwheel.json
7717e3b21cff39f497f07687c70c1fa40eaa756d assets/create/models/item/content_observer.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 965a90a882d85dba93b30af9bce7ecf8e68ce747 assets/create/models/item/copper_block.json
759bcb5fe7dfdd628716f9b4ff19a5ab00393381 assets/create/models/item/copper_casing.json 759bcb5fe7dfdd628716f9b4ff19a5ab00393381 assets/create/models/item/copper_casing.json
c2a320162daa2d24cef969d1d14a0cbd55eb574f assets/create/models/item/copper_ingot.json c2a320162daa2d24cef969d1d14a0cbd55eb574f assets/create/models/item/copper_ingot.json

View File

@ -24,36 +24,66 @@
"powered=true,rail_type=activator_rail,shape=north_south": { "powered=true,rail_type=activator_rail,shape=north_south": {
"model": "create:block/cart_assembler/block_activator_rail_powered" "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": { "powered=false,rail_type=regular,shape=east_west": {
"model": "create:block/cart_assembler/block_regular", "model": "create:block/cart_assembler/block_regular",
"y": 90 "y": 270
}, },
"powered=true,rail_type=regular,shape=east_west": { "powered=true,rail_type=regular,shape=east_west": {
"model": "create:block/cart_assembler/block_regular_powered", "model": "create:block/cart_assembler/block_regular_powered",
"y": 90 "y": 270
}, },
"powered=false,rail_type=powered_rail,shape=east_west": { "powered=false,rail_type=powered_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_rail", "model": "create:block/cart_assembler/block_powered_rail",
"y": 90 "y": 270
}, },
"powered=true,rail_type=powered_rail,shape=east_west": { "powered=true,rail_type=powered_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_powered_rail_powered", "model": "create:block/cart_assembler/block_powered_rail_powered",
"y": 90 "y": 270
}, },
"powered=false,rail_type=detector_rail,shape=east_west": { "powered=false,rail_type=detector_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_detector_rail", "model": "create:block/cart_assembler/block_detector_rail",
"y": 90 "y": 270
}, },
"powered=true,rail_type=detector_rail,shape=east_west": { "powered=true,rail_type=detector_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_detector_rail_powered", "model": "create:block/cart_assembler/block_detector_rail_powered",
"y": 90 "y": 270
}, },
"powered=false,rail_type=activator_rail,shape=east_west": { "powered=false,rail_type=activator_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_activator_rail", "model": "create:block/cart_assembler/block_activator_rail",
"y": 90 "y": 270
}, },
"powered=true,rail_type=activator_rail,shape=east_west": { "powered=true,rail_type=activator_rail,shape=east_west": {
"model": "create:block/cart_assembler/block_activator_rail_powered", "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 "y": 90
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"parent": "minecraft:item/generated", "parent": "minecraft:item/generated",
"textures": { "textures": {
"layer0": "create:block/controller_rail_item" "layer0": "create:block/controller_rail"
} }
} }

View File

@ -761,7 +761,7 @@ public class AllBlocks {
.onRegister(CreateRegistrate.blockColors(() -> AllColorHandlers::getRedstonePower)) .onRegister(CreateRegistrate.blockColors(() -> AllColorHandlers::getRedstonePower))
.tag(BlockTags.RAILS) .tag(BlockTags.RAILS)
.item() .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() .build()
.register(); .register();

View File

@ -77,6 +77,8 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
ItemStack container = fhi.getContainer(); ItemStack container = fhi.getContainer();
if (container.isItemEqual(copy)) if (container.isItemEqual(copy))
return; return;
if (container.isEmpty())
return;
Ingredient bucket = Ingredient.fromStacks(stack); Ingredient bucket = Ingredient.fromStacks(stack);
ResourceLocation itemName = stack.getItem() ResourceLocation itemName = stack.getItem()

View File

@ -172,7 +172,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
return; return;
} }
if (runningTicks == CYCLE / 2) { if (runningTicks == CYCLE / 2 && getSpeed() != 0) {
if (inWorld()) if (inWorld())
applyPressingInWorld(); applyPressingInWorld();
if (onBasin()) if (onBasin())

View File

@ -64,6 +64,7 @@ import net.minecraft.block.SlimeBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.NBTUtil; 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.FluidStack;
import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
import net.minecraftforge.fluids.capability.templates.FluidTank; import net.minecraftforge.fluids.capability.templates.FluidTank;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper; import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@ -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<BlockPos, Direction> pair : superglue) { for (Pair<BlockPos, Direction> pair : superglue) {
BlockPos targetPos = transform.apply(pair.getKey()); BlockPos targetPos = transform.apply(pair.getKey());
Direction targetFacing = transform.transformFacing(pair.getValue()); Direction targetFacing = transform.transformFacing(pair.getValue());

View File

@ -1,27 +1,54 @@
package com.simibubi.create.content.contraptions.components.structureMovement.mounted; 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.simibubi.create.foundation.utility.Lang;
import com.tterrag.registrate.util.entry.BlockEntry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import java.util.function.Predicate;
import java.util.function.Supplier;
public enum CartAssembleRailType implements IStringSerializable { public enum CartAssembleRailType implements IStringSerializable {
REGULAR(Blocks.RAIL), REGULAR(Blocks.RAIL),
POWERED_RAIL(Blocks.POWERED_RAIL), POWERED_RAIL(Blocks.POWERED_RAIL),
DETECTOR_RAIL(Blocks.DETECTOR_RAIL), DETECTOR_RAIL(Blocks.DETECTOR_RAIL),
ACTIVATOR_RAIL(Blocks.ACTIVATOR_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; private final Supplier<Block> railBlockSupplier;
public Item railItem; private final Supplier<Item> railItemSupplier;
public final Predicate<BlockState> matches;
private CartAssembleRailType(Block block) { CartAssembleRailType(Block block) {
this.railBlock = block; this.railBlockSupplier = () -> block;
this.railItem = block.asItem(); this.railItemSupplier = block::asItem;
this.matches = blockState -> blockState.getBlock() == getBlock();
}
CartAssembleRailType(BlockEntry<?> block, Predicate<BlockState> 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 @Override

View File

@ -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.CouplingHandler;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; 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.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.contraptions.wrench.IWrenchable;
import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement; import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
import com.simibubi.create.content.schematics.ItemRequirement; 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;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents; import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos; 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.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -88,13 +91,17 @@ public class CartAssemblerBlock extends AbstractRailBlock
} }
private static Item getRailItem(BlockState state) { private static Item getRailItem(BlockState state) {
return state.get(RAIL_TYPE).railItem; return state.get(RAIL_TYPE).getItem();
} }
public static BlockState getRailBlock(BlockState state) { public static BlockState getRailBlock(BlockState state) {
AbstractRailBlock railBlock = (AbstractRailBlock) state.get(RAIL_TYPE).railBlock; AbstractRailBlock railBlock = (AbstractRailBlock) state.get(RAIL_TYPE).getBlock();
return railBlock.getDefaultState() BlockState railState = railBlock.getDefaultState()
.with(railBlock.getShapeProperty(), state.get(RAIL_SHAPE)); .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 @Override
@ -188,6 +195,11 @@ public class CartAssemblerBlock extends AbstractRailBlock
float speed = getRailMaxSpeed(state, world, pos, cart); float speed = getRailMaxSpeed(state, world, pos, cart);
cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed, facing.getZOffset() * speed); 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) { if (action == CartAssemblerAction.DISASSEMBLE_BRAKE) {
Vector3d diff = VecHelper.getCenterOf(pos) Vector3d diff = VecHelper.getCenterOf(pos)
.subtract(cart.getPositionVec()); .subtract(cart.getPositionVec());
@ -198,10 +210,10 @@ public class CartAssemblerBlock extends AbstractRailBlock
} }
public enum CartAssemblerAction { public enum CartAssemblerAction {
ASSEMBLE, DISASSEMBLE, ASSEMBLE_ACCELERATE, DISASSEMBLE_BRAKE, PASS; ASSEMBLE, DISASSEMBLE, ASSEMBLE_ACCELERATE, DISASSEMBLE_BRAKE, ASSEMBLE_ACCELERATE_DIRECTIONAL, PASS;
public boolean shouldAssemble() { public boolean shouldAssemble() {
return this == ASSEMBLE || this == ASSEMBLE_ACCELERATE; return this == ASSEMBLE || this == ASSEMBLE_ACCELERATE || this == ASSEMBLE_ACCELERATE_DIRECTIONAL;
} }
public boolean shouldDisassemble() { public boolean shouldDisassemble() {
@ -226,6 +238,9 @@ public class CartAssemblerBlock extends AbstractRailBlock
return cart.getPassengers() return cart.getPassengers()
.isEmpty() ? CartAssemblerAction.ASSEMBLE_ACCELERATE : CartAssemblerAction.DISASSEMBLE; .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; return CartAssemblerAction.PASS;
} }
@ -245,7 +260,7 @@ public class CartAssemblerBlock extends AbstractRailBlock
CartAssembleRailType newType = null; CartAssembleRailType newType = null;
for (CartAssembleRailType type : CartAssembleRailType.values()) for (CartAssembleRailType type : CartAssembleRailType.values())
if (heldItem == type.railItem) if (heldItem == type.getItem())
newType = type; newType = type;
if (newType == null) if (newType == null)
return ActionResultType.PASS; return ActionResultType.PASS;
@ -499,4 +514,22 @@ public class CartAssemblerBlock extends AbstractRailBlock
return VoxelShapes.empty(); 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;
}
} }

View File

@ -56,7 +56,7 @@ public class CartAssemblerBlockItem extends BlockItem {
.with(CartAssemblerBlock.RAIL_SHAPE, shape); .with(CartAssemblerBlock.RAIL_SHAPE, shape);
CartAssembleRailType newType = null; CartAssembleRailType newType = null;
for (CartAssembleRailType type : CartAssembleRailType.values()) for (CartAssembleRailType type : CartAssembleRailType.values())
if (block == type.railBlock) if (type.matches.test(state))
newType = type; newType = type;
if (newType == null) if (newType == null)
return false; return false;

View File

@ -55,7 +55,7 @@ public class ControllerRailBlock extends AbstractRailBlock implements IWrenchabl
.with(SHAPE, NORTH_SOUTH)); .with(SHAPE, NORTH_SOUTH));
} }
private static Vector3i getAccelerationVector(BlockState state) { public static Vector3i getAccelerationVector(BlockState state) {
Direction pointingTo = getPointingTowards(state); Direction pointingTo = getPointingTowards(state);
return (isStateBackwards(state) ? pointingTo.getOpposite() : pointingTo).getDirectionVec(); return (isStateBackwards(state) ? pointingTo.getOpposite() : pointingTo).getDirectionVec();
} }

View File

@ -158,6 +158,7 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchab
withTileEntityDo(worldIn, pos, te -> { withTileEntityDo(worldIn, pos, te -> {
ItemHelper.dropContents(worldIn, pos, te.inputInventory); ItemHelper.dropContents(worldIn, pos, te.inputInventory);
ItemHelper.dropContents(worldIn, pos, te.outputInventory); ItemHelper.dropContents(worldIn, pos, te.outputInventory);
te.spoutputBuffer.forEach(is -> Block.spawnAsEntity(worldIn, pos, is));
}); });
worldIn.removeTileEntity(pos); worldIn.removeTileEntity(pos);
} }

View File

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.processing;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Random; 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.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -83,6 +85,7 @@ public class BasinTileEntity extends SmartTileEntity {
List<Direction> disabledSpoutputs; List<Direction> disabledSpoutputs;
Direction preferredSpoutput; Direction preferredSpoutput;
protected List<ItemStack> spoutputBuffer;
public static final int OUTPUT_ANIMATION_TIME = 10; public static final int OUTPUT_ANIMATION_TIME = 10;
List<IntAttached<ItemStack>> visualizedOutputItems; List<IntAttached<ItemStack>> visualizedOutputItems;
@ -107,6 +110,7 @@ public class BasinTileEntity extends SmartTileEntity {
visualizedOutputFluids = Collections.synchronizedList(new ArrayList<>()); visualizedOutputFluids = Collections.synchronizedList(new ArrayList<>());
disabledSpoutputs = new ArrayList<>(); disabledSpoutputs = new ArrayList<>();
preferredSpoutput = null; preferredSpoutput = null;
spoutputBuffer = new ArrayList<>();
} }
@Override @Override
@ -144,6 +148,7 @@ public class BasinTileEntity extends SmartTileEntity {
disabledSpoutputs.clear(); disabledSpoutputs.clear();
ListNBT disabledList = compound.getList("DisabledSpoutput", NBT.TAG_STRING); ListNBT disabledList = compound.getList("DisabledSpoutput", NBT.TAG_STRING);
disabledList.forEach(d -> disabledSpoutputs.add(Direction.valueOf(((StringNBT) d).getString()))); disabledList.forEach(d -> disabledSpoutputs.add(Direction.valueOf(((StringNBT) d).getString())));
spoutputBuffer = NBTHelper.readItemList(compound.getList("Overflow", NBT.TAG_COMPOUND));
if (!clientPacket) if (!clientPacket)
return; return;
@ -166,6 +171,7 @@ public class BasinTileEntity extends SmartTileEntity {
ListNBT disabledList = new ListNBT(); ListNBT disabledList = new ListNBT();
disabledSpoutputs.forEach(d -> disabledList.add(StringNBT.of(d.name()))); disabledSpoutputs.forEach(d -> disabledList.add(StringNBT.of(d.name())));
compound.put("DisabledSpoutput", disabledList); compound.put("DisabledSpoutput", disabledList);
compound.put("Overflow", NBTHelper.writeItemList(spoutputBuffer));
if (!clientPacket) if (!clientPacket)
return; return;
@ -270,6 +276,10 @@ public class BasinTileEntity extends SmartTileEntity {
ingredientRotationSpeed.tickChaser(); ingredientRotationSpeed.tickChaser();
ingredientRotation.setValue(ingredientRotation.getValue() + ingredientRotationSpeed.getValue()); ingredientRotation.setValue(ingredientRotation.getValue() + ingredientRotationSpeed.getValue());
} }
if (!spoutputBuffer.isEmpty() && !world.isRemote)
tryClearingSpoutputOverflow();
if (!contentsChanged) if (!contentsChanged)
return; return;
contentsChanged = false; 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<ItemStack> 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) { public float getTotalFluidUnits(float partialTicks) {
int renderedFluids = 0; int renderedFluids = 0;
float totalUnits = 0; float totalUnits = 0;
@ -371,6 +421,8 @@ public class BasinTileEntity extends SmartTileEntity {
} else { } else {
// Output basin, try moving items to it // Output basin, try moving items to it
if (!spoutputBuffer.isEmpty())
return false;
TileEntity te = world.getTileEntity(pos.down() TileEntity te = world.getTileEntity(pos.down()
.offset(direction)); .offset(direction));
if (te == null) if (te == null)
@ -383,12 +435,14 @@ public class BasinTileEntity extends SmartTileEntity {
if (targetInv == null && !outputItems.isEmpty()) if (targetInv == null && !outputItems.isEmpty())
return false; return false;
for (ItemStack itemStack : outputItems) for (ItemStack itemStack : outputItems) {
if (simulate) {
if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), simulate) if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), simulate)
.isEmpty()) .isEmpty())
return false; return false;
else if (!simulate) } else
visualizedOutputItems.add(IntAttached.withZero(itemStack)); spoutputBuffer.add(itemStack.copy());
}
if (outputFluids.isEmpty()) if (outputFluids.isEmpty())
return true; return true;

View File

@ -205,7 +205,10 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
indexStart = 0; indexStart = 0;
ItemStack toDistribute = null; ItemStack toDistribute = null;
int leftovers = 0;
for (boolean simulate : Iterate.trueAndFalse) { for (boolean simulate : Iterate.trueAndFalse) {
leftovers = 0;
int index = indexStart; int index = indexStart;
int stackSize = stackToDistribute.getCount(); int stackSize = stackToDistribute.getCount();
int splitStackSize = stackSize / amountTargets; int splitStackSize = stackSize / amountTargets;
@ -226,12 +229,13 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
ItemStack toOutput = ItemHandlerHelper.copyStackWithSize(toDistribute, count); ItemStack toOutput = ItemHandlerHelper.copyStackWithSize(toDistribute, count);
ItemStack remainder = insertIntoTunnel(tunnel, side, toOutput, simulate); ItemStack remainder = insertIntoTunnel(tunnel, side, toOutput, simulate);
if (remainder == null || !remainder.isEmpty()) { if (remainder == null || remainder.getCount() == count) {
if (force) if (force)
return; return;
continue; continue;
} }
leftovers += remainder.getCount();
toDistribute.shrink(count); toDistribute.shrink(count);
if (toDistribute.isEmpty()) if (toDistribute.isEmpty())
break; break;
@ -241,7 +245,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity {
} }
} }
stackToDistribute = toDistribute.copy(); stackToDistribute = ItemHandlerHelper.copyStackWithSize(stackToDistribute, toDistribute.getCount() + leftovers);
previousOutputIndex++; previousOutputIndex++;
previousOutputIndex %= amountTargets; previousOutputIndex %= amountTargets;
notifyUpdate(); notifyUpdate();

View File

@ -9,6 +9,7 @@ import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
@ -39,6 +40,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
private Map<BlockPos, BlockState> blocks; private Map<BlockPos, BlockState> blocks;
private Map<BlockPos, TileEntity> tileEntities; private Map<BlockPos, TileEntity> tileEntities;
private List<TileEntity> renderedTileEntities;
private List<Entity> entities; private List<Entity> entities;
private MutableBoundingBox bounds; private MutableBoundingBox bounds;
public BlockPos anchor; public BlockPos anchor;
@ -55,6 +57,7 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
this.bounds = new MutableBoundingBox(); this.bounds = new MutableBoundingBox();
this.anchor = anchor; this.anchor = anchor;
this.entities = new ArrayList<>(); this.entities = new ArrayList<>();
this.renderedTileEntities = new ArrayList<>();
} }
public Set<BlockPos> getAllPositions() { public Set<BlockPos> getAllPositions() {
@ -90,12 +93,17 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
BlockState blockState = getBlockState(pos); BlockState blockState = getBlockState(pos);
if (blockState.hasTileEntity()) { if (blockState.hasTileEntity()) {
try {
TileEntity tileEntity = blockState.createTileEntity(this); TileEntity tileEntity = blockState.createTileEntity(this);
if (tileEntity != null) { if (tileEntity != null) {
tileEntity.setLocation(this, pos); tileEntity.setLocation(this, pos);
tileEntities.put(pos, tileEntity); tileEntities.put(pos, tileEntity);
renderedTileEntities.add(tileEntity);
} }
return tileEntity; return tileEntity;
} catch (Exception e) {
Create.logger.debug("Could not create TE of block " + blockState + ": " + e);
}
} }
return null; return null;
} }
@ -192,8 +200,8 @@ public class SchematicWorld extends WrappedWorld implements IServerWorld {
return bounds; return bounds;
} }
public Iterable<TileEntity> getTileEntities() { public Iterable<TileEntity> getRenderedTileEntities() {
return tileEntities.values(); return renderedTileEntities;
} }
@Override @Override

View File

@ -126,9 +126,8 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen<SchematicT
* MathHelper.lerp(partialTicks, lastChasingProgress, chasingProgress)); * MathHelper.lerp(partialTicks, lastChasingProgress, chasingProgress));
int height = SCHEMATIC_TABLE_PROGRESS.height; int height = SCHEMATIC_TABLE_PROGRESS.height;
RenderSystem.disableLighting(); RenderSystem.disableLighting();
drawTexture(matrixStack, mainLeft + 70, mainTop + 58, SCHEMATIC_TABLE_PROGRESS.startX, drawTexture(matrixStack, mainLeft + 70, mainTop + 57, SCHEMATIC_TABLE_PROGRESS.startX,
SCHEMATIC_TABLE_PROGRESS.startY, width, height); SCHEMATIC_TABLE_PROGRESS.startY, width, height);
} }
@Override @Override

View File

@ -77,7 +77,7 @@ public class SchematicRenderer {
SuperByteBuffer superByteBuffer = bufferCache.get(layer); SuperByteBuffer superByteBuffer = bufferCache.get(layer);
superByteBuffer.renderInto(ms, buffer.getBuffer(layer)); superByteBuffer.renderInto(ms, buffer.getBuffer(layer));
} }
TileEntityRenderHelper.renderTileEntities(schematic, schematic.getTileEntities(), ms, new MatrixStack(), TileEntityRenderHelper.renderTileEntities(schematic, schematic.getRenderedTileEntities(), ms, new MatrixStack(),
buffer); buffer);
} }

View File

@ -209,12 +209,17 @@ public class BlockStateGen {
CartAssembleRailType type = state.get(CartAssemblerBlock.RAIL_TYPE); CartAssembleRailType type = state.get(CartAssemblerBlock.RAIL_TYPE);
Boolean powered = state.get(CartAssemblerBlock.POWERED); Boolean powered = state.get(CartAssemblerBlock.POWERED);
RailShape shape = state.get(CartAssemblerBlock.RAIL_SHAPE); RailShape shape = state.get(CartAssemblerBlock.RAIL_SHAPE);
int yRotation = shape == RailShape.EAST_WEST ? 270 : 0;
if (type == CartAssembleRailType.CONTROLLER_RAIL_BACKWARDS) {
yRotation += 180;
type = CartAssembleRailType.CONTROLLER_RAIL;
}
return ConfiguredModel.builder() return ConfiguredModel.builder()
.modelFile(p.models() .modelFile(p.models()
.getExistingFile(p .getExistingFile(p
.modLoc("block/" + c.getName() + "/block_" + type.getString() + (powered ? "_powered" : "")))) .modLoc("block/" + c.getName() + "/block_" + type.getString() + (powered ? "_powered" : ""))))
.rotationY(shape == RailShape.EAST_WEST ? 90 : 0) .rotationY(yRotation % 360)
.build(); .build();
}); });
} }

View File

@ -0,0 +1,6 @@
{
"parent": "create:block/cart_assembler/block",
"textures": {
"rail": "create:block/controller_rail"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "create:block/cart_assembler/block",
"textures": {
"clutch_off": "create:block/clutch_on",
"rail": "create:block/controller_rail_powered"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B