mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 08:27:03 +01:00
Cart Assembler - behaviors, railtype update and texture fixes
This commit is contained in:
parent
282d9d6801
commit
3417ceb4fb
10 changed files with 192 additions and 115 deletions
|
@ -326,7 +326,7 @@ c77b46d8b459e5c7cc495393546f3fcca8a1fa1d assets\create\blockstates\weathered_lim
|
|||
7f39521b211441f5c3e06d60c5978cebe16cacfb assets\create\blockstates\zinc_block.json
|
||||
b7181bcd8182b2f17088e5aa881f374c9c65470c assets\create\blockstates\zinc_ore.json
|
||||
6bf74a9e1f74b41f53399c1f817942b01a010bf0 assets\create\lang\en_ud.json
|
||||
587b2f5b13ba67674d5eec135e5f767e9255d20d assets\create\lang\en_us.json
|
||||
fd0932555a5afde9c3c5f990f78de545814cc4ab assets\create\lang\en_us.json
|
||||
846200eb548d3bfa2e77b41039de159b4b6cfb45 assets\create\models\block\acacia_window.json
|
||||
1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets\create\models\block\acacia_window_pane_noside.json
|
||||
1763ea2c9b981d187f5031ba608f3d5d3be3986a assets\create\models\block\acacia_window_pane_noside_alt.json
|
||||
|
@ -925,7 +925,7 @@ f5a18f4279c2e845a5967b1c2f9e807c2bb77afb assets\create\models\item\brass_casing.
|
|||
1786bdffa2ab5a07c88d2797db3d7b54461323c4 assets\create\models\item\brass_ingot.json
|
||||
a37be4a0ec9bf6c381527403c57ced4f81abd67c assets\create\models\item\brass_nugget.json
|
||||
14ea6ee4db6e7e76446e331a70b6b6bec31e8eb7 assets\create\models\item\brass_sheet.json
|
||||
7fcb2a4d0bbe434f269b5bcaffebe410913297be assets\create\models\item\cart_assembler.json
|
||||
b362b940fe9074f0a9b8d53d8a12b41f18c2c292 assets\create\models\item\cart_assembler.json
|
||||
99d64b76b3baa84c3bd4b96ccd3376ca12425950 assets\create\models\item\chiseled_dark_scoria.json
|
||||
83d3571eacde52568786802b268f24c6578c1e5d assets\create\models\item\chiseled_dolomite.json
|
||||
afd697168c9786eb80e54eccdc6a23afa6c7fb0e assets\create\models\item\chiseled_gabbro.json
|
||||
|
|
|
@ -485,6 +485,7 @@
|
|||
|
||||
"create.block.deployer.damage_source_name": "a rogue Deployer",
|
||||
"create.block.cart_assembler.invalid": "Can not place a Cart Assembler on this rail type",
|
||||
"create.block.cart_assembler.invalid_update": "Invalid rail to update this Cart Assembler",
|
||||
|
||||
"create.recipe.crushing": "Crushing",
|
||||
"create.recipe.milling": "Milling",
|
||||
|
@ -1114,11 +1115,15 @@
|
|||
"block.create.sequenced_gearshift.tooltip.behaviour2": "Opens the _configuration_ _interface._",
|
||||
|
||||
"block.create.cart_assembler.tooltip": "CART ASSEMBLER",
|
||||
"block.create.cart_assembler.tooltip.summary": "Mounts a connected Structure onto a _passing_ _Minecart_.",
|
||||
"block.create.cart_assembler.tooltip.condition1": "When Powered by Redstone",
|
||||
"block.create.cart_assembler.tooltip.behaviour1": "_Assembles_ a connected Structure onto a _Minecart_ and _sends_ the Minecart on its way.",
|
||||
"block.create.cart_assembler.tooltip.condition2": "Otherwise",
|
||||
"block.create.cart_assembler.tooltip.behaviour2": "_Disassembles_ mounted Structures of _passing_ _carts_, places them back into the world and _stops_ the cart.",
|
||||
"block.create.cart_assembler.tooltip.summary": "When _placed_ _on_ a _Rail_, adopts functionality and _assembles/disassebles_ _structures_ on passing _carts_.",
|
||||
"block.create.cart_assembler.tooltip.condition1": "When placed above Rail",
|
||||
"block.create.cart_assembler.tooltip.behaviour1": "_Assembles_ onto passing _carts_ _when_ _powered_, _disassembles_ them _otherwise_.",
|
||||
"block.create.cart_assembler.tooltip.condition2": "When placed above Powered Rail",
|
||||
"block.create.cart_assembler.tooltip.behaviour2": "_Assembles_ and _accelerates_ _carts_ _when_ _powered_, _disassembles_ and _holds_ them _otherwise_.",
|
||||
"block.create.cart_assembler.tooltip.condition3": "When placed above Detector Rail",
|
||||
"block.create.cart_assembler.tooltip.behaviour3": "_Assembles_ unassembled _carts_, _disassembles_ assembled _carts_.",
|
||||
"block.create.cart_assembler.tooltip.condition4": "When placed above Activator Rail",
|
||||
"block.create.cart_assembler.tooltip.behaviour4": "_Disassembles_ _carts_ when _powered_.",
|
||||
|
||||
"block.create.rope_pulley.tooltip": "ROPE PULLEY",
|
||||
"block.create.rope_pulley.tooltip.summary": "Moves attached _blocks_ and _structures_ _vertically_. Use _Chassis_ or _Slime_ _Blocks_ to move more than a single block.",
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"parent": "create:block/cart_assembler/block"
|
||||
"parent": "create:block/cart_assembler/block_none"
|
||||
}
|
|
@ -454,7 +454,7 @@ public class AllBlocks {
|
|||
.tag(BlockTags.RAILS)
|
||||
.item(CartAssemblerBlockItem::new)
|
||||
.model((c, p) -> p.blockItem(() -> c.getEntry()
|
||||
.getBlock(), "/block"))
|
||||
.getBlock(), "/block_none"))
|
||||
.build()
|
||||
.register();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.mo
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
|
@ -14,6 +15,7 @@ import com.simibubi.create.content.schematics.ISpecialBlockItemRequirement;
|
|||
import com.simibubi.create.content.schematics.ItemRequirement;
|
||||
import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.AbstractRailBlock;
|
||||
|
@ -44,11 +46,14 @@ import net.minecraft.tileentity.TileEntity;
|
|||
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.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
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.text.StringTextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -80,6 +85,36 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
.with(BlockStateProperties.HORIZONTAL_AXIS, axis);
|
||||
}
|
||||
|
||||
private static Item getRailItem(BlockState state) {
|
||||
switch (state.get(RAIL_TYPE)) {
|
||||
case RAIL_NORMAL:
|
||||
return Items.RAIL;
|
||||
case RAIL_DETECTOR:
|
||||
return Items.DETECTOR_RAIL;
|
||||
case RAIL_POWERED:
|
||||
return Items.POWERED_RAIL;
|
||||
case RAIL_ACTIVATOR:
|
||||
return Items.ACTIVATOR_RAIL;
|
||||
default:
|
||||
return Items.AIR;
|
||||
}
|
||||
}
|
||||
|
||||
public static BlockState getRailBlock(BlockState assembler) {
|
||||
switch (assembler.get(RAIL_TYPE)) {
|
||||
case RAIL_NORMAL:
|
||||
return Blocks.RAIL.getDefaultState().with(RailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
case RAIL_DETECTOR:
|
||||
return Blocks.DETECTOR_RAIL.getDefaultState().with(DetectorRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
case RAIL_POWERED:
|
||||
return Blocks.POWERED_RAIL.getDefaultState().with(PoweredRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
case RAIL_ACTIVATOR:
|
||||
return Blocks.ACTIVATOR_RAIL.getDefaultState().with(PoweredRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
default:
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||
builder.add(RAIL_SHAPE, POWERED, RAIL_TYPE);
|
||||
|
@ -97,32 +132,92 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canMakeSlopes(BlockState state, IBlockReader world, BlockPos pos) {
|
||||
public boolean canMakeSlopes(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
public void onMinecartPass(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, AbstractMinecartEntity cart) {
|
||||
if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity))
|
||||
return;
|
||||
|
||||
withTileEntityDo(world, pos, te -> {
|
||||
if (te.isMinecartUpdateValid()) {
|
||||
switch (state.get(RAIL_TYPE)) {
|
||||
case RAIL_POWERED:
|
||||
if (state.get(POWERED)) {
|
||||
assemble(world, pos, cart);
|
||||
Direction facing = cart.getAdjustedHorizontalFacing();
|
||||
cart.setMotion(facing.getXOffset(), facing.getYOffset(), facing.getZOffset());
|
||||
float speed = getRailMaxSpeed(state, world, pos, cart);
|
||||
cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed, facing.getZOffset() * speed);
|
||||
} else {
|
||||
disassemble(world, pos, cart);
|
||||
Vec3d diff = VecHelper.getCenterOf(pos)
|
||||
.subtract(cart.getPositionVec());
|
||||
cart.setMotion(diff.x / 16f, 0, diff.z / 16f);
|
||||
}
|
||||
break;
|
||||
case RAIL_NORMAL:
|
||||
if (state.get(POWERED)) {
|
||||
assemble(world, pos, cart);
|
||||
} else {
|
||||
disassemble(world, pos, cart);
|
||||
}
|
||||
break;
|
||||
case RAIL_ACTIVATOR:
|
||||
if (state.get(POWERED)) {
|
||||
disassemble(world, pos, cart);
|
||||
}
|
||||
break;
|
||||
case RAIL_DETECTOR:
|
||||
if (cart.getPassengers().isEmpty()) {
|
||||
assemble(world, pos, cart);
|
||||
Direction facing = cart.getAdjustedHorizontalFacing();
|
||||
float speed = getRailMaxSpeed(state, world, pos, cart);
|
||||
cart.setMotion(facing.getXOffset() * speed, facing.getYOffset() * speed, facing.getZOffset() * speed);
|
||||
} else {
|
||||
disassemble(world, pos, cart);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
te.resetTicksSinceMinecartUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ActionResultType onUse(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos,
|
||||
PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult blockRayTraceResult) {
|
||||
|
||||
ItemStack itemStack = player.getHeldItem(hand);
|
||||
if (itemStack.getItem() != getRailItem(state)) {
|
||||
|
||||
if (itemStack.getItem() == Items.RAIL) {
|
||||
System.out.println("normal rail");
|
||||
world.setBlockState(pos, state.with(RAIL_TYPE, RAIL_NORMAL));
|
||||
} else if (itemStack.getItem() == Items.POWERED_RAIL) {
|
||||
world.setBlockState(pos, state.with(RAIL_TYPE, RAIL_POWERED));
|
||||
} else if (itemStack.getItem() == Items.ACTIVATOR_RAIL) {
|
||||
world.setBlockState(pos, state.with(RAIL_TYPE, RAIL_ACTIVATOR));
|
||||
} else if (itemStack.getItem() == Items.DETECTOR_RAIL) {
|
||||
world.setBlockState(pos, state.with(RAIL_TYPE, RAIL_DETECTOR));
|
||||
} else {
|
||||
player.sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid_update")), true);
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
if (!player.isCreative()) {
|
||||
itemStack.setCount(itemStack.getCount() - 1);
|
||||
player.inventory.placeItemBackInInventory(world, new ItemStack(getRailItem(state)));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
protected void assemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
if (!cart.getPassengers()
|
||||
.isEmpty())
|
||||
|
@ -169,7 +264,7 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
|
||||
public void neighborChanged(@Nonnull BlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull Block blockIn, @Nonnull BlockPos fromPos,
|
||||
boolean isMoving) {
|
||||
super.neighborChanged(state, worldIn, pos, blockIn, fromPos, isMoving);
|
||||
|
||||
|
@ -183,18 +278,21 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IProperty<RailShape> getShapeProperty() {
|
||||
return RAIL_SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
@Nonnull
|
||||
public VoxelShape getShape(BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos, @Nonnull ISelectionContext context) {
|
||||
return AllShapes.CART_ASSEMBLER
|
||||
.get(state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Direction.Axis.Z : Direction.Axis.X);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
|
||||
@Nonnull
|
||||
public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos,
|
||||
ISelectionContext context) {
|
||||
if (context.getEntity() instanceof AbstractMinecartEntity)
|
||||
return VoxelShapes.empty();
|
||||
|
@ -202,12 +300,13 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
}
|
||||
|
||||
@Override
|
||||
public PushReaction getPushReaction(BlockState state) {
|
||||
@Nonnull
|
||||
public PushReaction getPushReaction(@Nonnull BlockState state) {
|
||||
return PushReaction.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
public boolean isNormalCube(@Nonnull BlockState state, @Nonnull IBlockReader worldIn, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -217,49 +316,45 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos) {
|
||||
public boolean isValidPosition(@Nonnull BlockState state, @Nonnull IWorldReader world, @Nonnull BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<ItemStack> getDrops(BlockState state, net.minecraft.world.storage.loot.LootContext.Builder builder) {
|
||||
@Nonnull
|
||||
public List<ItemStack> getDrops(@Nonnull BlockState state, @Nonnull net.minecraft.world.storage.loot.LootContext.Builder builder) {
|
||||
List<ItemStack> drops = super.getDrops(state, builder);
|
||||
drops.addAll(getRailBlock(state).getDrops(builder));
|
||||
return drops;
|
||||
}
|
||||
|
||||
|
||||
private static Item getRailItem(BlockState state) {
|
||||
switch (state.get(RAIL_TYPE)) {
|
||||
case RAIL_NORMAL:
|
||||
return Items.RAIL;
|
||||
case RAIL_DETECTOR:
|
||||
return Items.DETECTOR_RAIL;
|
||||
case RAIL_POWERED:
|
||||
return Items.POWERED_RAIL;
|
||||
case RAIL_ACTIVATOR:
|
||||
return Items.ACTIVATOR_RAIL;
|
||||
default:
|
||||
return Items.AIR;
|
||||
}
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state) {
|
||||
return new ItemRequirement(ItemUseType.CONSUME, getRailItem(state));
|
||||
}
|
||||
|
||||
public static BlockState getRailBlock(BlockState assembler) {
|
||||
switch (assembler.get(RAIL_TYPE)) {
|
||||
case RAIL_NORMAL:
|
||||
return Blocks.RAIL.getDefaultState().with(RailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
case RAIL_DETECTOR:
|
||||
return Blocks.DETECTOR_RAIL.getDefaultState().with(DetectorRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
case RAIL_POWERED:
|
||||
return Blocks.POWERED_RAIL.getDefaultState().with(PoweredRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
case RAIL_ACTIVATOR:
|
||||
return Blocks.ACTIVATOR_RAIL.getDefaultState().with(PoweredRailBlock.SHAPE, assembler.get(RAIL_SHAPE));
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<ItemStack> getDropedAssembler(BlockState p_220077_0_, ServerWorld p_220077_1_, BlockPos p_220077_2_, @Nullable TileEntity p_220077_3_, @Nullable Entity p_220077_4_, ItemStack p_220077_5_) {
|
||||
return super.getDrops(p_220077_0_, (new LootContext.Builder(p_220077_1_)).withRandom(p_220077_1_.rand).withParameter(LootParameters.POSITION, p_220077_2_).withParameter(LootParameters.TOOL, p_220077_5_).withNullableParameter(LootParameters.THIS_ENTITY, p_220077_4_).withNullableParameter(LootParameters.BLOCK_ENTITY, p_220077_3_));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) {
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (world instanceof ServerWorld) {
|
||||
if (player != null && !player.isCreative())
|
||||
getDropedAssembler(state, (ServerWorld) world, pos, world.getTileEntity(pos), player, context.getItem())
|
||||
.forEach(itemStack -> {
|
||||
player.inventory.placeItemBackInInventory(world, itemStack);
|
||||
});
|
||||
state.spawnAdditionalDrops(world, pos, ItemStack.EMPTY);
|
||||
world.setBlockState(pos, getRailBlock(state));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
public static class MinecartAnchorBlock extends Block {
|
||||
|
||||
|
@ -274,37 +369,10 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
|||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState p_220053_1_, IBlockReader p_220053_2_, BlockPos p_220053_3_,
|
||||
ISelectionContext p_220053_4_) {
|
||||
@Nonnull
|
||||
public VoxelShape getShape(@Nonnull BlockState p_220053_1_, @Nonnull IBlockReader p_220053_2_, @Nonnull BlockPos p_220053_3_,
|
||||
@Nonnull ISelectionContext p_220053_4_) {
|
||||
return VoxelShapes.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRequirement getRequiredItems(BlockState state) {
|
||||
return new ItemRequirement(ItemUseType.CONSUME, getRailItem(state));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<ItemStack> getDropedAssembler(BlockState p_220077_0_, ServerWorld p_220077_1_, BlockPos p_220077_2_, @Nullable TileEntity p_220077_3_, @Nullable Entity p_220077_4_, ItemStack p_220077_5_) {
|
||||
return super.getDrops(p_220077_0_, (new LootContext.Builder(p_220077_1_)).withRandom(p_220077_1_.rand).withParameter(LootParameters.POSITION, p_220077_2_).withParameter(LootParameters.TOOL, p_220077_5_).withNullableParameter(LootParameters.THIS_ENTITY, p_220077_4_).withNullableParameter(LootParameters.BLOCK_ENTITY, p_220077_3_));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onSneakWrenched(BlockState state, ItemUseContext context) {
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (world instanceof ServerWorld) {
|
||||
if (!player.isCreative())
|
||||
getDropedAssembler(state, (ServerWorld) world, pos, world.getTileEntity(pos), player, context.getItem())
|
||||
.forEach(itemStack -> {
|
||||
player.inventory.placeItemBackInInventory(world, itemStack);
|
||||
});
|
||||
state.spawnAdditionalDrops(world, pos, ItemStack.EMPTY);
|
||||
world.setBlockState(pos, getRailBlock(state));
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.mo
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.state.properties.RailShape;
|
||||
|
@ -11,6 +12,8 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CartAssemblerBlockItem extends BlockItem {
|
||||
|
||||
public CartAssemblerBlockItem(Block block, Properties properties) {
|
||||
|
@ -18,12 +21,14 @@ public class CartAssemblerBlockItem extends BlockItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ActionResultType onItemUse(ItemUseContext context) {
|
||||
BlockPos pos = context.getPos();
|
||||
World world = context.getWorld();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof AbstractRailBlock) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (block instanceof AbstractRailBlock && player != null) {
|
||||
RailShape shape = state.get(((AbstractRailBlock) block).getShapeProperty());
|
||||
if (shape == RailShape.EAST_WEST || shape == RailShape.NORTH_SOUTH) {
|
||||
BlockState defaultState = AllBlocks.CART_ASSEMBLER.getDefaultState().with(CartAssemblerBlock.RAIL_SHAPE, shape);
|
||||
|
@ -39,21 +44,15 @@ public class CartAssemblerBlockItem extends BlockItem {
|
|||
} else if (block.getClass() == DetectorRailBlock.class) {
|
||||
world.setBlockState(pos, defaultState.with(CartAssemblerBlock.RAIL_TYPE, CartAssemblerBlock.RAIL_DETECTOR));
|
||||
} else {
|
||||
showWarning(context);
|
||||
player.sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid")), true);
|
||||
return super.onItemUse(context);
|
||||
}
|
||||
if (!context.getPlayer().isCreative())
|
||||
if (!player.isCreative())
|
||||
context.getItem().setCount(context.getItem().getCount() - 1);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
showWarning(context);
|
||||
player.sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid")), true);
|
||||
}
|
||||
|
||||
|
||||
return super.onItemUse(context);
|
||||
}
|
||||
|
||||
private void showWarning(ItemUseContext context) {
|
||||
context.getPlayer().sendStatusMessage(new StringTextComponent(Lang.translate("block.cart_assembler.invalid")), true);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
"death.attack.create.cuckoo_clock_explosion": "%1$s was blown up by tampered cuckoo clock",
|
||||
"create.block.deployer.damage_source_name": "a rogue Deployer",
|
||||
"create.block.cart_assembler.invalid": "Can not place a Cart Assembler on this rail type",
|
||||
"create.block.cart_assembler.invalid_update": "Invalid rail to update this Cart Assembler",
|
||||
|
||||
"create.recipe.crushing": "Crushing",
|
||||
"create.recipe.milling": "Milling",
|
||||
|
|
|
@ -288,11 +288,15 @@
|
|||
"block.create.sequenced_gearshift.tooltip.behaviour2": "Opens the _configuration_ _interface._",
|
||||
|
||||
"block.create.cart_assembler.tooltip": "CART ASSEMBLER",
|
||||
"block.create.cart_assembler.tooltip.summary": "Mounts a connected Structure onto a _passing_ _Minecart_.",
|
||||
"block.create.cart_assembler.tooltip.condition1": "When Powered by Redstone",
|
||||
"block.create.cart_assembler.tooltip.behaviour1": "_Assembles_ a connected Structure onto a _Minecart_ and _sends_ the Minecart on its way.",
|
||||
"block.create.cart_assembler.tooltip.condition2": "Otherwise",
|
||||
"block.create.cart_assembler.tooltip.behaviour2": "_Disassembles_ mounted Structures of _passing_ _carts_, places them back into the world and _stops_ the cart.",
|
||||
"block.create.cart_assembler.tooltip.summary": "When _placed_ _on_ a _Rail_, adopts functionality and _assembles/disassebles_ _structures_ on passing _carts_.",
|
||||
"block.create.cart_assembler.tooltip.condition1": "When placed above Rail",
|
||||
"block.create.cart_assembler.tooltip.behaviour1": "_Assembles_ onto passing _carts_ _when_ _powered_, _disassembles_ them _otherwise_.",
|
||||
"block.create.cart_assembler.tooltip.condition2": "When placed above Powered Rail",
|
||||
"block.create.cart_assembler.tooltip.behaviour2": "_Assembles_ and _accelerates_ _carts_ _when_ _powered_, _disassembles_ and _holds_ them _otherwise_.",
|
||||
"block.create.cart_assembler.tooltip.condition3": "When placed above Detector Rail",
|
||||
"block.create.cart_assembler.tooltip.behaviour3": "_Assembles_ unassembled _carts_, _disassembles_ assembled _carts_.",
|
||||
"block.create.cart_assembler.tooltip.condition4": "When placed above Activator Rail",
|
||||
"block.create.cart_assembler.tooltip.behaviour4": "_Disassembles_ _carts_ when _powered_.",
|
||||
|
||||
"block.create.rope_pulley.tooltip": "ROPE PULLEY",
|
||||
"block.create.rope_pulley.tooltip.summary": "Moves attached _blocks_ and _structures_ _vertically_. Use _Chassis_ or _Slime_ _Blocks_ to move more than a single block.",
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
"parent": "create:block/cart_assembler/block",
|
||||
"textures": {
|
||||
"clutch_off": "create:block/clutch_on",
|
||||
"rail": "block/activator_rail"
|
||||
"rail": "block/activator_rail_on"
|
||||
}
|
||||
}
|
|
@ -2,6 +2,6 @@
|
|||
"parent": "create:block/cart_assembler/block",
|
||||
"textures": {
|
||||
"clutch_off": "create:block/clutch_on",
|
||||
"rail": "block/detector_rail"
|
||||
"rail": "block/detector_rail_on"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue