More portable blocks
- Fixed latch hotfix still not making it work properly - Cocoa pods can now be harvested by harvesters - Fans, RSCs, basins, stockpile switches, gauges, engines, cranks and other blocks can now be moved in a contraption - Most of creates technical blocks can now be picked up using a wrench - Fixed Stockpile switch not reacting to movement. - Fixed Stockpile switch not reacting to changes to a double container - Chassis range display no longer shows the overlay for non-sticky directions
This commit is contained in:
parent
4cbf424f4d
commit
0bd3a8d880
28 changed files with 167 additions and 69 deletions
|
@ -10,11 +10,13 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraftforge.common.ToolType;
|
import net.minecraftforge.common.ToolType;
|
||||||
|
|
||||||
public class CasingBlock extends Block implements IHaveConnectedTextures {
|
public class CasingBlock extends Block implements IHaveConnectedTextures, IWrenchable {
|
||||||
|
|
||||||
String textureFrom;
|
String textureFrom;
|
||||||
|
|
||||||
|
@ -22,6 +24,11 @@ public class CasingBlock extends Block implements IHaveConnectedTextures {
|
||||||
super(Properties.from(Blocks.ANDESITE));
|
super(Properties.from(Blocks.ANDESITE));
|
||||||
this.textureFrom = textureFrom;
|
this.textureFrom = textureFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ToolType getHarvestTool(BlockState state) {
|
public ToolType getHarvestTool(BlockState state) {
|
||||||
|
|
|
@ -27,6 +27,8 @@ public interface IWrenchable {
|
||||||
KineticTileEntity.switchToBlockState(world, context.getPos(), updateAfterWrenched(rotated, context));
|
KineticTileEntity.switchToBlockState(world, context.getPos(), updateAfterWrenched(rotated, context));
|
||||||
|
|
||||||
TileEntity te = context.getWorld().getTileEntity(context.getPos());
|
TileEntity te = context.getWorld().getTileEntity(context.getPos());
|
||||||
|
if (te != null)
|
||||||
|
te.updateContainingBlockInfo();
|
||||||
if (te instanceof GeneratingKineticTileEntity) {
|
if (te instanceof GeneratingKineticTileEntity) {
|
||||||
((GeneratingKineticTileEntity) te).updateGeneratedRotation();
|
((GeneratingKineticTileEntity) te).updateGeneratedRotation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.PushReaction;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -71,11 +70,6 @@ public abstract class KineticBlock extends Block implements IRotate {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
|
||||||
return PushReaction.BLOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
||||||
|
|
||||||
|
|
|
@ -359,8 +359,12 @@ public abstract class KineticTileEntity extends SmartTileEntity
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileEntity tileEntityIn = world.getTileEntity(pos);
|
TileEntity tileEntityIn = world.getTileEntity(pos);
|
||||||
if (!(tileEntityIn instanceof KineticTileEntity))
|
boolean isKinetic = tileEntityIn instanceof KineticTileEntity;
|
||||||
|
|
||||||
|
if (!isKinetic) {
|
||||||
|
world.setBlockState(pos, state, 3);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
KineticTileEntity tileEntity = (KineticTileEntity) tileEntityIn;
|
KineticTileEntity tileEntity = (KineticTileEntity) tileEntityIn;
|
||||||
if (tileEntity.hasNetwork())
|
if (tileEntity.hasNetwork())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.simibubi.create.modules.contraptions.components.actors;
|
package com.simibubi.create.modules.contraptions.components.actors;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.IPortableBlock;
|
import com.simibubi.create.modules.contraptions.components.contraptions.IPortableBlock;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -8,7 +9,9 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.HorizontalBlock;
|
import net.minecraft.block.HorizontalBlock;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
|
@ -16,11 +19,16 @@ import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.IWorldReader;
|
import net.minecraft.world.IWorldReader;
|
||||||
|
|
||||||
public abstract class AttachedActorBlock extends HorizontalBlock implements IPortableBlock {
|
public abstract class AttachedActorBlock extends HorizontalBlock implements IPortableBlock, IWrenchable {
|
||||||
|
|
||||||
public AttachedActorBlock() {
|
public AttachedActorBlock() {
|
||||||
super(Properties.from(Blocks.IRON_BLOCK));
|
super(Properties.from(Blocks.IRON_BLOCK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.simibubi.create.modules.contraptions.components.contraptions.Movement
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.CocoaBlock;
|
||||||
import net.minecraft.block.CropsBlock;
|
import net.minecraft.block.CropsBlock;
|
||||||
import net.minecraft.block.KelpBlock;
|
import net.minecraft.block.KelpBlock;
|
||||||
import net.minecraft.block.SugarCaneBlock;
|
import net.minecraft.block.SugarCaneBlock;
|
||||||
|
@ -81,7 +82,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (state.getCollisionShape(world, pos).isEmpty()) {
|
if (state.getCollisionShape(world, pos).isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
||||||
for (IProperty<?> property : state.getProperties()) {
|
for (IProperty<?> property : state.getProperties()) {
|
||||||
if (!(property instanceof IntegerProperty))
|
if (!(property instanceof IntegerProperty))
|
||||||
continue;
|
continue;
|
||||||
|
@ -96,14 +97,14 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidOther(World world, BlockPos pos, BlockState state) {
|
private boolean isValidOther(World world, BlockPos pos, BlockState state) {
|
||||||
if (state.getBlock() instanceof CropsBlock)
|
if (state.getBlock() instanceof CropsBlock)
|
||||||
return false;
|
return false;
|
||||||
if (state.getBlock() instanceof SugarCaneBlock)
|
if (state.getBlock() instanceof SugarCaneBlock)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (state.getCollisionShape(world, pos).isEmpty()) {
|
if (state.getCollisionShape(world, pos).isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
||||||
for (IProperty<?> property : state.getProperties()) {
|
for (IProperty<?> property : state.getProperties()) {
|
||||||
if (!(property instanceof IntegerProperty))
|
if (!(property instanceof IntegerProperty))
|
||||||
continue;
|
continue;
|
||||||
|
@ -131,7 +132,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
return Blocks.AIR.getDefaultState();
|
return Blocks.AIR.getDefaultState();
|
||||||
return state.getFluidState().getBlockState();
|
return state.getFluidState().getBlockState();
|
||||||
}
|
}
|
||||||
if (state.getCollisionShape(world, pos).isEmpty()) {
|
if (state.getCollisionShape(world, pos).isEmpty() || state.getBlock() instanceof CocoaBlock) {
|
||||||
for (IProperty<?> property : state.getProperties()) {
|
for (IProperty<?> property : state.getProperties()) {
|
||||||
if (!(property instanceof IntegerProperty))
|
if (!(property instanceof IntegerProperty))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -13,6 +13,9 @@ import com.simibubi.create.modules.contraptions.components.contraptions.piston.M
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState;
|
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.pulley.PulleyBlock;
|
import com.simibubi.create.modules.contraptions.components.contraptions.pulley.PulleyBlock;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.pulley.PulleyTileEntity;
|
import com.simibubi.create.modules.contraptions.components.contraptions.pulley.PulleyTileEntity;
|
||||||
|
import com.simibubi.create.modules.contraptions.components.crank.HandCrankBlock;
|
||||||
|
import com.simibubi.create.modules.contraptions.components.fan.NozzleBlock;
|
||||||
|
import com.simibubi.create.modules.contraptions.components.flywheel.engine.EngineBlock;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.pulley.PulleyBlock.MagnetBlock;
|
import com.simibubi.create.modules.contraptions.components.contraptions.pulley.PulleyBlock.MagnetBlock;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.pulley.PulleyBlock.RopeBlock;
|
import com.simibubi.create.modules.contraptions.components.contraptions.pulley.PulleyBlock.RopeBlock;
|
||||||
import com.simibubi.create.modules.logistics.block.AttachedLogisticalBlock;
|
import com.simibubi.create.modules.logistics.block.AttachedLogisticalBlock;
|
||||||
|
@ -105,6 +108,8 @@ public class BlockMovementTraits {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (state.has(BlockStateProperties.HANGING))
|
if (state.has(BlockStateProperties.HANGING))
|
||||||
return true;
|
return true;
|
||||||
|
if (block instanceof HandCrankBlock)
|
||||||
|
return true;
|
||||||
if (block instanceof LadderBlock)
|
if (block instanceof LadderBlock)
|
||||||
return true;
|
return true;
|
||||||
if (block instanceof ExtractorBlock)
|
if (block instanceof ExtractorBlock)
|
||||||
|
@ -131,8 +136,12 @@ public class BlockMovementTraits {
|
||||||
return true;
|
return true;
|
||||||
if (block instanceof RopeBlock)
|
if (block instanceof RopeBlock)
|
||||||
return true;
|
return true;
|
||||||
|
if (block instanceof NozzleBlock)
|
||||||
|
return true;
|
||||||
if (block instanceof MagnetBlock)
|
if (block instanceof MagnetBlock)
|
||||||
return true;
|
return true;
|
||||||
|
if (block instanceof EngineBlock)
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +187,12 @@ public class BlockMovementTraits {
|
||||||
return direction == Direction.DOWN;
|
return direction == Direction.DOWN;
|
||||||
if (block instanceof AttachedActorBlock)
|
if (block instanceof AttachedActorBlock)
|
||||||
return direction == state.get(HarvesterBlock.HORIZONTAL_FACING).getOpposite();
|
return direction == state.get(HarvesterBlock.HORIZONTAL_FACING).getOpposite();
|
||||||
|
if (block instanceof HandCrankBlock)
|
||||||
|
return direction == state.get(HandCrankBlock.FACING).getOpposite();
|
||||||
|
if (block instanceof NozzleBlock)
|
||||||
|
return direction == state.get(NozzleBlock.FACING).getOpposite();
|
||||||
|
if (block instanceof EngineBlock)
|
||||||
|
return direction == state.get(EngineBlock.HORIZONTAL_FACING).getOpposite();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.modules.contraptions.components.actors.BlockBreakingMovementBehaviour;
|
import com.simibubi.create.modules.contraptions.components.actors.BlockBreakingMovementBehaviour;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.CocoaBlock;
|
||||||
import net.minecraft.block.material.PushReaction;
|
import net.minecraft.block.material.PushReaction;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -272,7 +273,8 @@ public class ContraptionCollider {
|
||||||
if (AllBlocks.PULLEY_MAGNET.typeOf(collidedState) && pos.equals(BlockPos.ZERO)
|
if (AllBlocks.PULLEY_MAGNET.typeOf(collidedState) && pos.equals(BlockPos.ZERO)
|
||||||
&& movementDirection == Direction.UP)
|
&& movementDirection == Direction.UP)
|
||||||
continue;
|
continue;
|
||||||
|
if (collidedState.getBlock() instanceof CocoaBlock)
|
||||||
|
continue;
|
||||||
if (!collidedState.getMaterial().isReplaceable()
|
if (!collidedState.getMaterial().isReplaceable()
|
||||||
&& !collidedState.getCollisionShape(world, colliderPos).isEmpty()) {
|
&& !collidedState.getCollisionShape(world, colliderPos).isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,7 +24,7 @@ public abstract class BearingBlock extends DirectionalKineticBlock {
|
||||||
protected boolean hasStaticPart() {
|
protected boolean hasStaticPart() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Axis getRotationAxis(BlockState state) {
|
public Axis getRotationAxis(BlockState state) {
|
||||||
return state.get(FACING).getAxis();
|
return state.get(FACING).getAxis();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.simibubi.create.modules.contraptions.components.contraptions.chassis;
|
package com.simibubi.create.modules.contraptions.components.contraptions.chassis;
|
||||||
|
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.RotatedPillarBlock;
|
import net.minecraft.block.RotatedPillarBlock;
|
||||||
|
@ -21,7 +22,7 @@ import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.Tags;
|
import net.minecraftforge.common.Tags;
|
||||||
|
|
||||||
public abstract class AbstractChassisBlock extends RotatedPillarBlock {
|
public abstract class AbstractChassisBlock extends RotatedPillarBlock implements IWrenchable {
|
||||||
|
|
||||||
public AbstractChassisBlock(Properties properties) {
|
public AbstractChassisBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
|
|
|
@ -46,8 +46,9 @@ public class ChassisTileEntity extends SmartTileEntity {
|
||||||
te -> ((ChassisTileEntity) te).collectChassisGroup());
|
te -> ((ChassisTileEntity) te).collectChassisGroup());
|
||||||
range.requiresWrench();
|
range.requiresWrench();
|
||||||
range.between(1, max);
|
range.between(1, max);
|
||||||
range.withClientCallback(
|
range
|
||||||
i -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ChassisRangeDisplay.display(this)));
|
.withClientCallback(
|
||||||
|
i -> DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ChassisRangeDisplay.display(this)));
|
||||||
range.value = max / 2;
|
range.value = max / 2;
|
||||||
behaviours.add(range);
|
behaviours.add(range);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +162,7 @@ public class ChassisTileEntity extends SmartTileEntity {
|
||||||
BlockPos current = pos.offset(facing, i);
|
BlockPos current = pos.offset(facing, i);
|
||||||
BlockState currentState = world.getBlockState(current);
|
BlockState currentState = world.getBlockState(current);
|
||||||
|
|
||||||
if (forcedMovement != facing && !visualize && !sticky)
|
if (forcedMovement != facing && !sticky)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Ignore replaceable Blocks and Air-like
|
// Ignore replaceable Blocks and Air-like
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.block.ITE;
|
import com.simibubi.create.foundation.block.ITE;
|
||||||
import com.simibubi.create.foundation.block.RenderUtilityBlock;
|
import com.simibubi.create.foundation.block.RenderUtilityBlock;
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionEntity;
|
import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionEntity;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.mounted.CartAssemblerTileEntity.CartMovementMode;
|
import com.simibubi.create.modules.contraptions.components.contraptions.mounted.CartAssemblerTileEntity.CartMovementMode;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAssemblerTileEntity> {
|
public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAssemblerTileEntity>, IWrenchable {
|
||||||
|
|
||||||
public static IProperty<RailShape> RAIL_SHAPE =
|
public static IProperty<RailShape> RAIL_SHAPE =
|
||||||
EnumProperty.create("shape", RailShape.class, RailShape.EAST_WEST, RailShape.NORTH_SOUTH);
|
EnumProperty.create("shape", RailShape.class, RailShape.EAST_WEST, RailShape.NORTH_SOUTH);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.components.contraptions.piston;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState;
|
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonBlock.PistonState;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -20,7 +21,7 @@ import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class PistonPoleBlock extends ProperDirectionalBlock {
|
public class PistonPoleBlock extends ProperDirectionalBlock implements IWrenchable {
|
||||||
|
|
||||||
public PistonPoleBlock() {
|
public PistonPoleBlock() {
|
||||||
super(Properties.from(Blocks.PISTON_HEAD));
|
super(Properties.from(Blocks.PISTON_HEAD));
|
||||||
|
|
|
@ -3,11 +3,14 @@ package com.simibubi.create.modules.contraptions.components.fan;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -17,7 +20,7 @@ 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;
|
||||||
|
|
||||||
public class NozzleBlock extends ProperDirectionalBlock {
|
public class NozzleBlock extends ProperDirectionalBlock implements IWrenchable {
|
||||||
|
|
||||||
public NozzleBlock() {
|
public NozzleBlock() {
|
||||||
super(Properties.from(AllBlocks.ENCASED_FAN.get()));
|
super(Properties.from(AllBlocks.ENCASED_FAN.get()));
|
||||||
|
@ -28,6 +31,11 @@ public class NozzleBlock extends ProperDirectionalBlock {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return new NozzleTileEntity();
|
return new NozzleTileEntity();
|
||||||
|
|
|
@ -3,14 +3,16 @@ package com.simibubi.create.modules.contraptions.components.flywheel.engine;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.HorizontalBlock;
|
import net.minecraft.block.HorizontalBlock;
|
||||||
import net.minecraft.block.material.PushReaction;
|
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
|
@ -19,7 +21,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
public abstract class EngineBlock extends HorizontalBlock {
|
public abstract class EngineBlock extends HorizontalBlock implements IWrenchable {
|
||||||
|
|
||||||
protected EngineBlock(Properties builder) {
|
protected EngineBlock(Properties builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
|
@ -36,10 +38,10 @@ public abstract class EngineBlock extends HorizontalBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||||
return PushReaction.BLOCK;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,18 @@ import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||||
import com.simibubi.create.foundation.block.ITE;
|
import com.simibubi.create.foundation.block.ITE;
|
||||||
import com.simibubi.create.foundation.item.ItemHelper;
|
import com.simibubi.create.foundation.item.ItemHelper;
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.material.PushReaction;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
@ -26,7 +28,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
public class BasinBlock extends Block implements ITE<BasinTileEntity> {
|
public class BasinBlock extends Block implements ITE<BasinTileEntity>, IWrenchable {
|
||||||
|
|
||||||
public BasinBlock() {
|
public BasinBlock() {
|
||||||
super(Properties.from(Blocks.ANDESITE));
|
super(Properties.from(Blocks.ANDESITE));
|
||||||
|
@ -41,10 +43,10 @@ public class BasinBlock extends Block implements ITE<BasinTileEntity> {
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return new BasinTileEntity();
|
return new BasinTileEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||||
return PushReaction.BLOCK;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.IPortableBlock;
|
import com.simibubi.create.modules.contraptions.components.contraptions.IPortableBlock;
|
||||||
import com.simibubi.create.modules.contraptions.components.contraptions.MovementBehaviour;
|
import com.simibubi.create.modules.contraptions.components.contraptions.MovementBehaviour;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class ContactBlock extends ProperDirectionalBlock implements IPortableBlock {
|
public class ContactBlock extends ProperDirectionalBlock implements IPortableBlock, IWrenchable {
|
||||||
|
|
||||||
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||||
public static MovementBehaviour MOVEMENT = new ContactMovementBehaviour();
|
public static MovementBehaviour MOVEMENT = new ContactMovementBehaviour();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Random;
|
||||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.WrappedWorld;
|
||||||
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock;
|
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock;
|
||||||
import com.simibubi.create.modules.contraptions.base.IRotate;
|
import com.simibubi.create.modules.contraptions.base.IRotate;
|
||||||
|
|
||||||
|
@ -79,13 +80,16 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
|
||||||
Direction nearestLookingDirection = context.getNearestLookingDirection();
|
Direction nearestLookingDirection = context.getNearestLookingDirection();
|
||||||
boolean lookPositive = nearestLookingDirection.getAxisDirection() == AxisDirection.POSITIVE;
|
boolean lookPositive = nearestLookingDirection.getAxisDirection() == AxisDirection.POSITIVE;
|
||||||
if (face.getAxis() == Axis.X) {
|
if (face.getAxis() == Axis.X) {
|
||||||
toPlace = toPlace.with(FACING, lookPositive ? Direction.NORTH : Direction.SOUTH)
|
toPlace = toPlace
|
||||||
|
.with(FACING, lookPositive ? Direction.NORTH : Direction.SOUTH)
|
||||||
.with(AXIS_ALONG_FIRST_COORDINATE, true);
|
.with(AXIS_ALONG_FIRST_COORDINATE, true);
|
||||||
} else if (face.getAxis() == Axis.Y) {
|
} else if (face.getAxis() == Axis.Y) {
|
||||||
toPlace = toPlace.with(FACING, horizontalFacing.getOpposite()).with(AXIS_ALONG_FIRST_COORDINATE,
|
toPlace = toPlace
|
||||||
horizontalFacing.getAxis() == Axis.X);
|
.with(FACING, horizontalFacing.getOpposite())
|
||||||
|
.with(AXIS_ALONG_FIRST_COORDINATE, horizontalFacing.getAxis() == Axis.X);
|
||||||
} else {
|
} else {
|
||||||
toPlace = toPlace.with(FACING, lookPositive ? Direction.WEST : Direction.EAST)
|
toPlace = toPlace
|
||||||
|
.with(FACING, lookPositive ? Direction.WEST : Direction.EAST)
|
||||||
.with(AXIS_ALONG_FIRST_COORDINATE, false);
|
.with(AXIS_ALONG_FIRST_COORDINATE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +123,8 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
|
||||||
if (getRotationAxis(state) == Axis.Y && face != state.get(FACING))
|
if (getRotationAxis(state) == Axis.Y && face != state.get(FACING))
|
||||||
return false;
|
return false;
|
||||||
BlockState blockState = world.getBlockState(pos.offset(face));
|
BlockState blockState = world.getBlockState(pos.offset(face));
|
||||||
if (Block.hasSolidSide(blockState, world, pos, face.getOpposite())
|
if (Block.hasSolidSide(blockState, world, pos, face.getOpposite()) && blockState.getMaterial() != Material.GLASS
|
||||||
&& blockState.getMaterial() != Material.GLASS)
|
&& !(world instanceof WrappedWorld))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -149,11 +153,15 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int i = 0; i < particleCount; i++) {
|
for (int i = 0; i < particleCount; i++) {
|
||||||
Vec3d mul = VecHelper.offsetRandomly(Vec3d.ZERO, rand, .25f)
|
Vec3d mul = VecHelper
|
||||||
.mul(new Vec3d(1, 1, 1).subtract(positiveFaceVec)).normalize().scale(.3f);
|
.offsetRandomly(Vec3d.ZERO, rand, .25f)
|
||||||
|
.mul(new Vec3d(1, 1, 1).subtract(positiveFaceVec))
|
||||||
|
.normalize()
|
||||||
|
.scale(.3f);
|
||||||
Vec3d offset = VecHelper.getCenterOf(pos).add(faceVec.scale(.55)).add(mul);
|
Vec3d offset = VecHelper.getCenterOf(pos).add(faceVec.scale(.55)).add(mul);
|
||||||
worldIn.addParticle(new RedstoneParticleData((float) rgb.x, (float) rgb.y, (float) rgb.z, 1), offset.x,
|
worldIn
|
||||||
offset.y, offset.z, mul.x, mul.y, mul.z);
|
.addParticle(new RedstoneParticleData((float) rgb.x, (float) rgb.y, (float) rgb.z, 1), offset.x,
|
||||||
|
offset.y, offset.z, mul.x, mul.y, mul.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.block.IHaveNoBlockItem;
|
import com.simibubi.create.foundation.block.IHaveNoBlockItem;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
|
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
|
||||||
import com.simibubi.create.modules.logistics.block.transposer.TransposerBlock;
|
import com.simibubi.create.modules.logistics.block.transposer.TransposerBlock;
|
||||||
|
|
||||||
|
@ -13,8 +14,10 @@ import net.minecraft.block.material.PushReaction;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -23,7 +26,7 @@ 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;
|
||||||
|
|
||||||
public abstract class AttachedLogisticalBlock extends HorizontalBlock implements IHaveNoBlockItem {
|
public abstract class AttachedLogisticalBlock extends HorizontalBlock implements IHaveNoBlockItem, IWrenchable {
|
||||||
|
|
||||||
public static final BooleanProperty UPWARD = BooleanProperty.create("upward");
|
public static final BooleanProperty UPWARD = BooleanProperty.create("upward");
|
||||||
|
|
||||||
|
@ -36,6 +39,11 @@ public abstract class AttachedLogisticalBlock extends HorizontalBlock implements
|
||||||
return !isVertical();
|
return !isVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||||
|
return ActionResultType.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract boolean isVertical();
|
protected abstract boolean isVertical();
|
||||||
|
|
||||||
protected abstract BlockState getVerticalDefaultState();
|
protected abstract BlockState getVerticalDefaultState();
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package com.simibubi.create.modules.logistics.block;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.foundation.block.ITE;
|
import com.simibubi.create.foundation.block.ITE;
|
||||||
import com.simibubi.create.foundation.gui.ScreenOpener;
|
import com.simibubi.create.foundation.gui.ScreenOpener;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.HorizontalBlock;
|
import net.minecraft.block.HorizontalBlock;
|
||||||
import net.minecraft.block.material.PushReaction;
|
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
import net.minecraft.item.BlockItemUseContext;
|
||||||
|
@ -26,7 +27,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
|
||||||
public class StockswitchBlock extends HorizontalBlock implements ITE<StockswitchTileEntity> {
|
public class StockswitchBlock extends HorizontalBlock implements ITE<StockswitchTileEntity>, IWrenchable {
|
||||||
|
|
||||||
public static final IntegerProperty INDICATOR = IntegerProperty.create("indicator", 0, 6);
|
public static final IntegerProperty INDICATOR = IntegerProperty.create("indicator", 0, 6);
|
||||||
|
|
||||||
|
@ -88,6 +89,8 @@ public class StockswitchBlock extends HorizontalBlock implements ITE<Stockswitch
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
|
if (player != null && AllItems.WRENCH.typeOf(player.getHeldItem(handIn)))
|
||||||
|
return false;
|
||||||
DistExecutor.runWhenOn(Dist.CLIENT,
|
DistExecutor.runWhenOn(Dist.CLIENT,
|
||||||
() -> () -> withTileEntityDo(worldIn, pos, te -> this.displayScreen(te, player)));
|
() -> () -> withTileEntityDo(worldIn, pos, te -> this.displayScreen(te, player)));
|
||||||
return true;
|
return true;
|
||||||
|
@ -139,11 +142,6 @@ public class StockswitchBlock extends HorizontalBlock implements ITE<Stockswitch
|
||||||
return new StockswitchTileEntity();
|
return new StockswitchTileEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PushReaction getPushReaction(BlockState state) {
|
|
||||||
return PushReaction.BLOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<StockswitchTileEntity> getTileEntityClass() {
|
public Class<StockswitchTileEntity> getTileEntityClass() {
|
||||||
return StockswitchTileEntity.class;
|
return StockswitchTileEntity.class;
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.simibubi.create.modules.logistics.block;
|
package com.simibubi.create.modules.logistics.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.simibubi.create.AllTileEntities;
|
import com.simibubi.create.AllTileEntities;
|
||||||
import com.simibubi.create.foundation.block.SyncedTileEntity;
|
import com.simibubi.create.foundation.behaviour.base.SmartTileEntity;
|
||||||
|
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -15,7 +18,7 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
public class StockswitchTileEntity extends SyncedTileEntity {
|
public class StockswitchTileEntity extends SmartTileEntity {
|
||||||
|
|
||||||
public float onWhenAbove;
|
public float onWhenAbove;
|
||||||
public float offWhenBelow;
|
public float offWhenBelow;
|
||||||
|
@ -34,6 +37,7 @@ public class StockswitchTileEntity extends SyncedTileEntity {
|
||||||
currentLevel = -1;
|
currentLevel = -1;
|
||||||
powered = false;
|
powered = false;
|
||||||
observedInventory = LazyOptional.empty();
|
observedInventory = LazyOptional.empty();
|
||||||
|
setLazyTickRate(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,7 +111,17 @@ public class StockswitchTileEntity extends SyncedTileEntity {
|
||||||
world.notifyNeighbors(pos, getBlockState().getBlock());
|
world.notifyNeighbors(pos, getBlockState().getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void lazyTick() {
|
||||||
|
super.lazyTick();
|
||||||
|
if (world.isRemote)
|
||||||
|
return;
|
||||||
|
findNewInventory();
|
||||||
|
updateCurrentLevel();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean findNewInventory() {
|
private boolean findNewInventory() {
|
||||||
|
observedInventory = LazyOptional.empty();
|
||||||
BlockPos invPos = getPos().offset(getBlockState().get(BlockStateProperties.HORIZONTAL_FACING));
|
BlockPos invPos = getPos().offset(getBlockState().get(BlockStateProperties.HORIZONTAL_FACING));
|
||||||
|
|
||||||
if (!world.isBlockPresent(invPos))
|
if (!world.isBlockPresent(invPos))
|
||||||
|
@ -119,14 +133,19 @@ public class StockswitchTileEntity extends SyncedTileEntity {
|
||||||
TileEntity invTE = world.getTileEntity(invPos);
|
TileEntity invTE = world.getTileEntity(invPos);
|
||||||
if (invTE == null)
|
if (invTE == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
observedInventory = invTE.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
observedInventory = invTE.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
||||||
if (observedInventory.isPresent()) {
|
if (observedInventory.isPresent()) {
|
||||||
updateCurrentLevel();
|
updateCurrentLevel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.simibubi.create.modules.logistics.block.diodes;
|
||||||
|
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
|
|
||||||
|
import net.minecraft.block.RedstoneDiodeBlock;
|
||||||
|
|
||||||
|
public abstract class AbstractDiodeBlock extends RedstoneDiodeBlock implements IWrenchable {
|
||||||
|
|
||||||
|
public AbstractDiodeBlock(Properties builder) {
|
||||||
|
super(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import com.simibubi.create.AllBlocks;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.RedstoneDiodeBlock;
|
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -13,7 +12,7 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
|
|
||||||
public class FlexpeaterBlock extends RedstoneDiodeBlock {
|
public class FlexpeaterBlock extends AbstractDiodeBlock {
|
||||||
|
|
||||||
public static BooleanProperty POWERING = BooleanProperty.create("powering");
|
public static BooleanProperty POWERING = BooleanProperty.create("powering");
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,8 @@ public class LatchBlock extends ToggleLatchBlock {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
return true;
|
return true;
|
||||||
BlockState blockstate = worldIn.getBlockState(blockpos);
|
BlockState blockstate = worldIn.getBlockState(blockpos);
|
||||||
return blockstate.getBlock() == Blocks.REDSTONE_WIRE ? blockstate.get(RedstoneWireBlock.POWER) > 0 : false;
|
if (blockstate.getBlock() == Blocks.REDSTONE_WIRE && blockstate.get(RedstoneWireBlock.POWER) > 0)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Random;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.RedstoneDiodeBlock;
|
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -14,7 +13,7 @@ import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.TickPriority;
|
import net.minecraft.world.TickPriority;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class PulseRepeaterBlock extends RedstoneDiodeBlock {
|
public class PulseRepeaterBlock extends AbstractDiodeBlock {
|
||||||
|
|
||||||
public static BooleanProperty PULSING = BooleanProperty.create("pulsing");
|
public static BooleanProperty PULSING = BooleanProperty.create("pulsing");
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,11 @@ package com.simibubi.create.modules.logistics.block.diodes;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllItems;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.RedstoneDiodeBlock;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
@ -16,10 +17,10 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class ToggleLatchBlock extends RedstoneDiodeBlock {
|
public class ToggleLatchBlock extends AbstractDiodeBlock {
|
||||||
|
|
||||||
public static BooleanProperty POWERING = BooleanProperty.create("powering");
|
public static BooleanProperty POWERING = BooleanProperty.create("powering");
|
||||||
|
|
||||||
public ToggleLatchBlock() {
|
public ToggleLatchBlock() {
|
||||||
super(Properties.from(Blocks.REPEATER));
|
super(Properties.from(Blocks.REPEATER));
|
||||||
setDefaultState(getDefaultState().with(POWERING, false).with(POWERED, false));
|
setDefaultState(getDefaultState().with(POWERING, false).with(POWERED, false));
|
||||||
|
@ -29,17 +30,17 @@ public class ToggleLatchBlock extends RedstoneDiodeBlock {
|
||||||
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
protected void fillStateContainer(Builder<Block, BlockState> builder) {
|
||||||
builder.add(POWERED, POWERING, HORIZONTAL_FACING);
|
builder.add(POWERED, POWERING, HORIZONTAL_FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) {
|
public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) {
|
||||||
return blockState.get(HORIZONTAL_FACING) == side ? this.getActiveSignal(blockAccess, pos, blockState) : 0;
|
return blockState.get(HORIZONTAL_FACING) == side ? this.getActiveSignal(blockAccess, pos, blockState) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getDelay(BlockState state) {
|
protected int getDelay(BlockState state) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
|
@ -47,6 +48,8 @@ public class ToggleLatchBlock extends RedstoneDiodeBlock {
|
||||||
return false;
|
return false;
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
return false;
|
return false;
|
||||||
|
if (AllItems.WRENCH.typeOf(player.getHeldItem(handIn)))
|
||||||
|
return false;
|
||||||
return activated(worldIn, pos, state);
|
return activated(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.modules.logistics.block.inventories;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
|
import com.simibubi.create.modules.contraptions.IWrenchable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -16,7 +17,7 @@ import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class CrateBlock extends ProperDirectionalBlock {
|
public class CrateBlock extends ProperDirectionalBlock implements IWrenchable {
|
||||||
|
|
||||||
public static final BooleanProperty DOUBLE = BooleanProperty.create("double");
|
public static final BooleanProperty DOUBLE = BooleanProperty.create("double");
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.modules.logistics.block.transposer;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.foundation.utility.AllShapes;
|
import com.simibubi.create.foundation.utility.AllShapes;
|
||||||
import com.simibubi.create.modules.contraptions.IWrenchable;
|
|
||||||
import com.simibubi.create.modules.logistics.block.belts.BeltAttachableLogisticalBlock;
|
import com.simibubi.create.modules.logistics.block.belts.BeltAttachableLogisticalBlock;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -23,7 +22,7 @@ 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;
|
||||||
|
|
||||||
public class TransposerBlock extends BeltAttachableLogisticalBlock implements IWrenchable {
|
public class TransposerBlock extends BeltAttachableLogisticalBlock {
|
||||||
|
|
||||||
public static BooleanProperty POWERED = BlockStateProperties.POWERED;
|
public static BooleanProperty POWERED = BlockStateProperties.POWERED;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue