Merge remote-tracking branch 'origin/0.2' into 0.2

This commit is contained in:
Zelophed 2020-01-28 20:38:00 +01:00
commit 04a5281319
28 changed files with 812 additions and 90 deletions

View file

@ -26,10 +26,12 @@ import com.simibubi.create.modules.contraptions.components.contraptions.piston.M
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonHeadBlock;
import com.simibubi.create.modules.contraptions.components.contraptions.piston.PistonPoleBlock;
import com.simibubi.create.modules.contraptions.components.crafter.MechanicalCrafterBlock;
import com.simibubi.create.modules.contraptions.components.crank.HandCrankBlock;
import com.simibubi.create.modules.contraptions.components.crusher.CrushingWheelBlock;
import com.simibubi.create.modules.contraptions.components.crusher.CrushingWheelControllerBlock;
import com.simibubi.create.modules.contraptions.components.deployer.DeployerBlock;
import com.simibubi.create.modules.contraptions.components.fan.EncasedFanBlock;
import com.simibubi.create.modules.contraptions.components.fan.NozzleBlock;
import com.simibubi.create.modules.contraptions.components.mixer.MechanicalMixerBlock;
import com.simibubi.create.modules.contraptions.components.motor.MotorBlock;
import com.simibubi.create.modules.contraptions.components.press.MechanicalPressBlock;
@ -120,8 +122,11 @@ public enum AllBlocks {
WATER_WHEEL(new WaterWheelBlock()),
ENCASED_FAN(new EncasedFanBlock()),
ENCASED_FAN_INNER(new RenderUtilityDirectionalBlock()),
NOZZLE(new NozzleBlock()),
TURNTABLE(new TurntableBlock()),
SHAFT_HALF(new ShaftHalfBlock()),
HAND_CRANK(new HandCrankBlock()),
HAND_CRANK_HANDLE(new RenderUtilityDirectionalBlock()),
CRUSHING_WHEEL(new CrushingWheelBlock()),
CRUSHING_WHEEL_CONTROLLER(new CrushingWheelControllerBlock()),

View file

@ -16,12 +16,15 @@ import com.simibubi.create.modules.contraptions.components.contraptions.piston.M
import com.simibubi.create.modules.contraptions.components.contraptions.piston.MechanicalPistonTileEntityRenderer;
import com.simibubi.create.modules.contraptions.components.crafter.MechanicalCrafterTileEntity;
import com.simibubi.create.modules.contraptions.components.crafter.MechanicalCrafterTileEntityRenderer;
import com.simibubi.create.modules.contraptions.components.crank.HandCrankTileEntity;
import com.simibubi.create.modules.contraptions.components.crank.HandCrankTileEntityRenderer;
import com.simibubi.create.modules.contraptions.components.crusher.CrushingWheelControllerTileEntity;
import com.simibubi.create.modules.contraptions.components.crusher.CrushingWheelTileEntity;
import com.simibubi.create.modules.contraptions.components.deployer.DeployerTileEntity;
import com.simibubi.create.modules.contraptions.components.deployer.DeployerTileEntityRenderer;
import com.simibubi.create.modules.contraptions.components.fan.EncasedFanTileEntity;
import com.simibubi.create.modules.contraptions.components.fan.EncasedFanTileEntityRenderer;
import com.simibubi.create.modules.contraptions.components.fan.NozzleTileEntity;
import com.simibubi.create.modules.contraptions.components.mixer.MechanicalMixerTileEntity;
import com.simibubi.create.modules.contraptions.components.mixer.MechanicalMixerTileEntityRenderer;
import com.simibubi.create.modules.contraptions.components.motor.MotorTileEntity;
@ -91,8 +94,10 @@ public enum AllTileEntities {
TURNTABLE(TurntableTileEntity::new, AllBlocks.TURNTABLE),
ENCASED_SHAFT(EncasedShaftTileEntity::new, AllBlocks.ENCASED_SHAFT, AllBlocks.ENCASED_BELT),
ENCASED_FAN(EncasedFanTileEntity::new, AllBlocks.ENCASED_FAN),
NOZZLE(NozzleTileEntity::new, AllBlocks.NOZZLE),
CLUTCH(ClutchTileEntity::new, AllBlocks.CLUTCH),
GEARSHIFT(GearshiftTileEntity::new, AllBlocks.GEARSHIFT),
HAND_CRANK(HandCrankTileEntity::new, AllBlocks.HAND_CRANK),
BELT(BeltTileEntity::new, AllBlocks.BELT),
BELT_TUNNEL(BeltTunnelTileEntity::new, AllBlocks.BELT_TUNNEL),
MECHANICAL_PISTON(MechanicalPistonTileEntity::new, AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON),
@ -179,6 +184,7 @@ public enum AllTileEntities {
bind(ClutchTileEntity.class, new SplitShaftTileEntityRenderer());
bind(BeltTileEntity.class, new BeltTileEntityRenderer());
bind(WaterWheelTileEntity.class, new KineticTileEntityRenderer());
bind(HandCrankTileEntity.class, new HandCrankTileEntityRenderer());
bind(MechanicalPistonTileEntity.class, new MechanicalPistonTileEntityRenderer());
bind(MechanicalBearingTileEntity.class, new MechanicalBearingTileEntityRenderer());

View file

@ -61,7 +61,7 @@ public class CreateConfig {
// Contraptions
public IntValue maxBeltLength, crushingDamage, maxMotorSpeed, maxRotationSpeed;
public IntValue fanMaxPushDistance, fanMaxPullDistance, fanBlockCheckRate, fanRotationArgmax, generatingFanSpeed,
public IntValue fanPushDistance, fanPullDistance, fanBlockCheckRate, fanRotationArgmax, generatingFanSpeed,
inWorldProcessingTime;
public IntValue maxChassisForTranslation, maxChassisForRotation, maxChassisRange, maxPistonPoles;
@ -206,13 +206,13 @@ public class CreateConfig {
.comment("", "Game ticks between Fans checking for anything blocking their air flow.")
.translation(basePath + name).defineInRange(name, 30, 10, Integer.MAX_VALUE);
name = "fanMaxPushDistance";
fanMaxPushDistance = builder.comment("", "Maximum distance in blocks Fans can push entities.")
.translation(basePath + name).defineInRange(name, 20, 1, Integer.MAX_VALUE);
name = "fanPushDistance";
fanPushDistance = builder.comment("", "Maximum distance in blocks Fans can push entities.")
.translation(basePath + name).defineInRange(name, 20, 5, Integer.MAX_VALUE);
name = "fanMaxPullDistance";
fanMaxPullDistance = builder.comment("", "Maximum distance in blocks from where Fans can pull entities.")
.translation(basePath + name).defineInRange(name, 10, 1, Integer.MAX_VALUE);
name = "fanPullDistance";
fanPullDistance = builder.comment("", "Maximum distance in blocks from where Fans can pull entities.")
.translation(basePath + name).defineInRange(name, 20, 5, Integer.MAX_VALUE);
name = "fanRotationArgmax";
fanRotationArgmax = builder.comment("", "Rotation speed at which the maximum stats of fans are reached.")
@ -438,6 +438,7 @@ public class CreateConfig {
case MOTOR:
return 1024;
case ENCASED_FAN:
case HAND_CRANK:
return 64;
case WATER_WHEEL:
return 32;
@ -485,6 +486,7 @@ public class CreateConfig {
case SHAFT:
case SPEED_GAUGE:
case STRESS_GAUGE:
case HAND_CRANK:
default:
return 1;
}

View file

@ -70,7 +70,17 @@ public class AllShapes {
makeCuboidShape(0, 14, 6, 16, 18, 1)),
GAUGE_SHAPE_UP = VoxelShapes.or(
makeCuboidShape(1, 0, 0, 15, 2, 16),//plate
makeCuboidShape(2, 2, 1, 14, 14, 15))//log
makeCuboidShape(2, 2, 1, 14, 14, 15)),//log
NOZZLE_SHAPE_UP = VoxelShapes.or(
makeCuboidShape(2, 0, 2, 14, 14, 14),
VoxelShapes.combine(
makeCuboidShape(1, 13, 1, 15, 15, 15),
makeCuboidShape(3, 13, 3, 13, 15, 13),
IBooleanFunction.ONLY_FIRST)),
CRANK_SHAPE_UP = VoxelShapes.or(
makeCuboidShape(5, 0, 5, 11, 6, 11),
makeCuboidShape(1, 3, 1, 15, 8, 15)
)
;
@ -105,6 +115,8 @@ public class AllShapes {
public static final VoxelShaper
LOGISTICAL_CASING_MIDDLE = VoxelShaper.forDirectional(LOGISTICAL_CASING_MIDDLE_SHAPE, Direction.UP),
LOGISTICAL_CASING_CAP = VoxelShaper.forDirectional(LOGISTICAL_CASING_CAP_SHAPE, Direction.UP),
NOZZLE = VoxelShaper.forDirectional(NOZZLE_SHAPE_UP, Direction.UP),
CRANK = VoxelShaper.forDirectional(CRANK_SHAPE_UP, Direction.UP),
CART_ASSEMBLER = VoxelShaper.forHorizontalAxis(CART_ASSEMBLER_SHAPE, Direction.SOUTH),
MECHANICAL_PISTON_HEAD = VoxelShaper.forDirectional(MECHANICAL_PISTON_HEAD_SHAPE_UP, Direction.UP),
MECHANICAL_PISTON = SHORT_CASING_12_VOXEL,

View file

@ -44,7 +44,10 @@ public abstract class DirectionalKineticBlock extends KineticBlock {
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(FACING, context.getFace());
Direction preferred = getPreferredFacing(context);
if (preferred == null || context.isPlacerSneaking())
return getDefaultState().with(FACING, context.getNearestLookingDirection().getOpposite());
return getDefaultState().with(FACING, preferred.getOpposite());
}
@Override

View file

@ -0,0 +1,64 @@
package com.simibubi.create.modules.contraptions.components.crank;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.DirectionalKineticBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.tileentity.TileEntity;
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.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public class HandCrankBlock extends DirectionalKineticBlock implements IWithTileEntity<HandCrankTileEntity> {
public HandCrankBlock() {
super(Properties.from(AllBlocks.COGWHEEL.get()));
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.CRANK.get(state.get(FACING));
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
BlockRayTraceResult hit) {
boolean handEmpty = player.getHeldItem(handIn).isEmpty();
if (!handEmpty && player.isSneaking())
return false;
withTileEntityDo(worldIn, pos, te -> te.turn(player.isSneaking()));
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new HandCrankTileEntity();
}
@Override
protected boolean hasStaticPart() {
return false;
}
@Override
public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) {
return face == state.get(FACING).getOpposite();
}
@Override
public Axis getRotationAxis(BlockState state) {
return state.get(FACING).getAxis();
}
}

View file

@ -0,0 +1,50 @@
package com.simibubi.create.modules.contraptions.components.crank;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.modules.contraptions.base.GeneratingKineticTileEntity;
public class HandCrankTileEntity extends GeneratingKineticTileEntity {
public int inUse;
public boolean backwards;
public float independentAngle;
public float chasingVelocity;
public HandCrankTileEntity() {
super(AllTileEntities.HAND_CRANK.type);
}
public void turn(boolean back) {
boolean update = false;
if (getGeneratedSpeed() == 0 || back != backwards)
update = true;
inUse = 10;
this.backwards = back;
if (update && !world.isRemote)
updateGeneratedRotation();
}
@Override
public float getGeneratedSpeed() {
return inUse == 0 ? 0 : backwards ? -128 : 128;
}
@Override
public void tick() {
super.tick();
float actualSpeed = getSpeed();
chasingVelocity += (actualSpeed - chasingVelocity) * .25f;
independentAngle += chasingVelocity;
if (inUse > 0) {
inUse--;
if (inUse == 0 && !world.isRemote)
updateGeneratedRotation();
}
}
}

View file

@ -0,0 +1,35 @@
package com.simibubi.create.modules.contraptions.components.crank;
import static net.minecraft.state.properties.BlockStateProperties.FACING;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.base.KineticTileEntityRenderer;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.util.Direction;
public class HandCrankTileEntityRenderer extends KineticTileEntityRenderer {
@Override
public void renderTileEntityFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
int destroyStage, BufferBuilder buffer) {
super.renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, buffer);
BlockState state = te.getBlockState();
if (!AllBlocks.HAND_CRANK.typeOf(state))
return;
Direction facing = state.get(FACING);
SuperByteBuffer handle = CreateClient.bufferCache
.renderGenericBlockModel(AllBlocks.HAND_CRANK_HANDLE.getDefault().with(FACING, facing));
HandCrankTileEntity crank = (HandCrankTileEntity) te;
kineticRotationTransform(handle, te, facing.getAxis(),
(crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, getWorld());
handle.translate(x, y, z).renderInto(buffer);
}
}

View file

@ -71,8 +71,8 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
public float getMaxDistance() {
float speed = Math.abs(this.getSpeed());
float distanceFactor = Math.min(speed / parameters.fanRotationArgmax.get(), 1);
float pushDistance = MathHelper.lerp(distanceFactor, 3, parameters.fanMaxPushDistance.get());
float pullDistance = MathHelper.lerp(distanceFactor, 1.5f, parameters.fanMaxPullDistance.get());
float pushDistance = MathHelper.lerp(distanceFactor, 3, parameters.fanPushDistance.get());
float pullDistance = MathHelper.lerp(distanceFactor, 3f, parameters.fanPullDistance.get());
return this.getSpeed() > 0 ? pushDistance : pullDistance;
}
@ -119,79 +119,4 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
airCurrent.tick();
}
// public void processEntity(Entity entity) {
// if (InWorldProcessing.isFrozen())
// return;
//
// if (entity instanceof ItemEntity) {
// if (world.rand.nextInt(4) == 0) {
// Type processingType = getProcessingType();
// if (processingType == Type.BLASTING)
// world.addParticle(ParticleTypes.LARGE_SMOKE, entity.posX, entity.posY + .25f, entity.posZ, 0,
// 1 / 16f, 0);
// if (processingType == Type.SMOKING)
// world.addParticle(ParticleTypes.CLOUD, entity.posX, entity.posY + .25f, entity.posZ, 0, 1 / 16f, 0);
// if (processingType == Type.SPLASHING)
// world.addParticle(ParticleTypes.BUBBLE_POP, entity.posX + (world.rand.nextFloat() - .5f) * .5f,
// entity.posY + .25f, entity.posZ + (world.rand.nextFloat() - .5f) * .5f, 0, 1 / 16f, 0);
// }
//
// if (world.isRemote)
// return;
//
// if (canProcess((ItemEntity) entity))
// InWorldProcessing.applyProcessing((ItemEntity) entity, getProcessingType());
//
// } else {
// if (getProcessingType() == Type.SMOKING) {
// entity.setFire(2);
// entity.attackEntityFrom(damageSourceFire, 4);
// }
// if (getProcessingType() == Type.BLASTING) {
// entity.setFire(10);
// entity.attackEntityFrom(damageSourceLava, 8);
// }
// if (getProcessingType() == Type.SPLASHING) {
// if (entity.isBurning()) {
// entity.extinguish();
// world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_GENERIC_EXTINGUISH_FIRE,
// SoundCategory.NEUTRAL, 0.7F,
// 1.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.4F);
// }
// }
// }
// }
//
// protected boolean canProcess() {
// return getProcessingType() != null;
// }
//
// protected boolean canProcess(ItemEntity entity) {
// return canProcess() && InWorldProcessing.canProcess(entity, getProcessingType());
// }
//
// protected void moveEntity(Entity entity, boolean push) {
// if ((entity instanceof ItemEntity) && AllBlocks.BELT.typeOf(world.getBlockState(entity.getPosition()))
// && getAirFlowDirection() != Direction.UP) {
// return;
// }
//
// Vec3d center = VecHelper.getCenterOf(pos);
// Vec3i flow = getAirFlowDirection().getDirectionVec();
//
// float sneakModifier = entity.isSneaking() ? 4096f : 512f;
// float acceleration = (float) (getSpeed() * 1 / sneakModifier
// / (entity.getPositionVec().distanceTo(center) / (push ? pushDistance : pullDistance)));
// Vec3d previousMotion = entity.getMotion();
// float maxAcceleration = 5;
//
// double xIn = MathHelper.clamp(flow.getX() * acceleration - previousMotion.x, -maxAcceleration, maxAcceleration);
// double yIn = MathHelper.clamp(flow.getY() * acceleration - previousMotion.y, -maxAcceleration, maxAcceleration);
// double zIn = MathHelper.clamp(flow.getZ() * acceleration - previousMotion.z, -maxAcceleration, maxAcceleration);
//
// entity.setMotion(
// previousMotion.add(new Vec3d(xIn, yIn, zIn).mul(flow.getX(), flow.getY(), flow.getZ()).scale(1 / 8f)));
// entity.fallDistance = 0;
// }
}

View file

@ -0,0 +1,72 @@
package com.simibubi.create.modules.contraptions.components.fan;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
public class NozzleBlock extends ProperDirectionalBlock {
public NozzleBlock() {
super(Properties.from(AllBlocks.ENCASED_FAN.get()));
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new NozzleTileEntity();
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(FACING, context.getFace());
}
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT_MIPPED;
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.NOZZLE.get(state.get(FACING));
}
@Override
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos,
boolean isMoving) {
if (worldIn.isRemote)
return;
if (fromPos.equals(pos.offset(state.get(FACING).getOpposite())))
if (!isValidPosition(state, worldIn, pos)) {
worldIn.destroyBlock(pos, true);
return;
}
}
@Override
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
Direction towardsFan = state.get(FACING).getOpposite();
BlockState fanState = worldIn.getBlockState(pos.offset(towardsFan));
return AllBlocks.ENCASED_FAN.typeOf(fanState)
&& fanState.get(EncasedFanBlock.FACING) == towardsFan.getOpposite();
}
}

View file

@ -0,0 +1,171 @@
package com.simibubi.create.modules.contraptions.components.fan;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.behaviour.base.SmartTileEntity;
import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceContext.BlockMode;
import net.minecraft.util.math.RayTraceContext.FluidMode;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Explosion.Mode;
public class NozzleTileEntity extends SmartTileEntity {
private List<Entity> pushingEntities = new ArrayList<>();
private float range;
private boolean pushing;
private BlockPos fanPos;
public NozzleTileEntity() {
super(AllTileEntities.NOZZLE.type);
setLazyTickRate(5);
}
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
}
@Override
public CompoundNBT writeToClient(CompoundNBT compound) {
compound.putFloat("Range", range);
compound.putBoolean("Pushing", pushing);
return super.writeToClient(compound);
}
@Override
public void readClientUpdate(CompoundNBT tag) {
range = tag.getFloat("Range");
pushing = tag.getBoolean("Pushing");
super.readClientUpdate(tag);
}
@Override
public void initialize() {
super.initialize();
fanPos = pos.offset(getBlockState().get(NozzleBlock.FACING).getOpposite());
lazyTick();
}
@Override
public void tick() {
super.tick();
float range = calcRange();
if (this.range != range)
setRange(range);
Vec3d center = VecHelper.getCenterOf(pos);
if (world.isRemote && range != 0) {
if (world.rand.nextInt(MathHelper.clamp((CreateConfig.parameters.fanPushDistance.get() - (int) range), 1, 10)) == 0) {
Vec3d start = VecHelper.offsetRandomly(center, world.rand, pushing ? 1 : range / 2);
Vec3d motion = center.subtract(start).normalize().scale(MathHelper.clamp(range * (pushing ? .025f : 1f), 0, .5f) * (pushing ? -1 : 1));
world.addParticle(ParticleTypes.POOF, start.x, start.y, start.z, motion.x, motion.y, motion.z);
}
}
for (Iterator<Entity> iterator = pushingEntities.iterator(); iterator.hasNext();) {
Entity entity = iterator.next();
Vec3d diff = entity.getPositionVec().subtract(center);
if (!(entity instanceof PlayerEntity) && world.isRemote)
continue;
double distance = diff.length();
if (distance > range || entity.isSneaking()
|| (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative())) {
iterator.remove();
continue;
}
if (!pushing && distance < 1.5f)
continue;
float factor = (entity instanceof ItemEntity) ? 1 / 128f : 1 / 32f;
Vec3d pushVec = diff.normalize().scale((range - distance) * (pushing ? 1 : -1));
entity.setMotion(entity.getMotion().add(pushVec.scale(factor)));
entity.fallDistance = 0;
entity.velocityChanged = true;
}
}
public void setRange(float range) {
this.range = range;
if (range == 0)
pushingEntities.clear();
sendData();
}
private float calcRange() {
TileEntity te = world.getTileEntity(fanPos);
if (!(te instanceof EncasedFanTileEntity))
return 0;
EncasedFanTileEntity fan = (EncasedFanTileEntity) te;
if (fan.isGenerator)
return 0;
if (fan.airCurrent == null)
return 0;
if (fan.getSpeed() == 0)
return 0;
pushing = fan.getSpeed() > 0;
return fan.getMaxDistance();
}
@Override
public void lazyTick() {
super.lazyTick();
if (range == 0)
return;
Vec3d center = VecHelper.getCenterOf(pos);
AxisAlignedBB bb = new AxisAlignedBB(center, center).grow(range / 2f);
for (Entity entity : world.getEntitiesWithinAABB(Entity.class, bb)) {
Vec3d diff = entity.getPositionVec().subtract(center);
double distance = diff.length();
if (distance > range || entity.isSneaking()
|| (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative())) {
continue;
}
boolean canSee = canSee(entity);
if (!canSee) {
pushingEntities.remove(entity);
continue;
}
if (!pushingEntities.contains(entity))
pushingEntities.add(entity);
}
if (!pushing && pushingEntities.size() > 512 && !world.isRemote)
world.createExplosion(null, center.x, center.y, center.z, 6, Mode.BREAK);
}
private boolean canSee(Entity entity) {
RayTraceContext context = new RayTraceContext(entity.getPositionVec(), VecHelper.getCenterOf(pos),
BlockMode.COLLIDER, FluidMode.NONE, entity);
return pos.equals(world.rayTraceBlocks(context).getPos());
}
}

View file

@ -65,7 +65,7 @@ public class AirFlowParticleData implements IParticleData, ICustomParticle<AirFl
@Override
public String getParameters() {
return String.format(Locale.ROOT, "%s %d %d %d", AllParticles.ROTATION_INDICATOR.parameter(), posX, posY, posZ);
return String.format(Locale.ROOT, "%s %d %d %d", AllParticles.AIR_FLOW.parameter(), posX, posY, posZ);
}
@Override

View file

@ -0,0 +1,16 @@
{
"forge_marker": 1,
"defaults": {
"model": "create:block/hand_crank/block"
},
"variants": {
"facing": {
"north": { "y": 0 },
"south": { "y": 180 },
"west": { "y": 270 },
"up": { "x": 270 },
"down": { "x": 90 },
"east": { "y": 90 }
}
}
}

View file

@ -0,0 +1,16 @@
{
"forge_marker": 1,
"defaults": {
"model": "create:block/hand_crank/handle"
},
"variants": {
"facing": {
"north": { "y": 0 },
"south": { "y": 180 },
"west": { "y": 270 },
"up": { "x": 270 },
"down": { "x": 90 },
"east": { "y": 90 }
}
}
}

View file

@ -0,0 +1,16 @@
{
"forge_marker": 1,
"defaults": {
"model": "create:block/nozzle/block"
},
"variants": {
"facing": {
"north": { "y": 0 },
"south": { "y": 180 },
"west": { "y": 270 },
"up": { "x": 270 },
"down": { "x": 90 },
"east": { "y": 90 }
}
}
}

View file

@ -88,6 +88,8 @@
"block.create.encased_belt": "Encased Belt",
"block.create.encased_shaft": "Encased Shaft",
"block.create.encased_fan": "Encased Fan",
"block.create.nozzle": "Nozzle",
"block.create.hand_crank": "Hand Crank",
"block.create.motor": "Motor",
"block.create.belt": "Mechanical Belt",
"block.create.crushing_wheel": "Crushing Wheel",

View file

@ -0,0 +1,32 @@
{
"credit": "Made with Blockbench",
"parent": "block/block",
"textures": {
"0": "create:block/axis",
"1": "create:block/axis_top",
"2": "create:block/andesite_casing_short",
"3": "block/spruce_log",
"particle": "create:block/axis"
},
"elements": [
{
"name": "Axis",
"from": [6, 6, 11],
"to": [10, 10, 16],
"shade": false,
"faces": {
"east": {"uv": [6, 0, 10, 5], "rotation": 270, "texture": "#0"},
"south": {"uv": [6, 6, 10, 10], "texture": "#1"},
"west": {"uv": [6, 0, 10, 5], "rotation": 90, "texture": "#0"},
"up": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
"down": {"uv": [6, 0, 10, 5], "texture": "#0"}
}
}
],
"groups": [
{
"name": "shaft_half",
"origin": [8, 8, 8],
"children": [0]
}, 1, 2, 3, 4]
}

View file

@ -0,0 +1,73 @@
{
"credit": "Made with Blockbench",
"parent": "block/block",
"textures": {
"0": "create:block/axis",
"1": "create:block/axis_top",
"2": "create:block/andesite_casing_short",
"3": "block/spruce_log",
"particle": "create:block/axis"
},
"elements": [
{
"name": "Connector",
"from": [5, 5, 11],
"to": [11, 11, 14],
"faces": {
"north": {"uv": [0, 0, 6, 6], "texture": "#3"},
"east": {"uv": [0, 0, 3, 6], "texture": "#3"},
"south": {"uv": [0, 0, 6, 6], "texture": "#3"},
"west": {"uv": [0, 0, 3, 6], "texture": "#3"},
"up": {"uv": [0, 0, 6, 3], "texture": "#3"},
"down": {"uv": [0, 0, 6, 3], "texture": "#3"}
}
},
{
"name": "Arm",
"from": [-2, 6, 10],
"to": [14, 10, 13],
"faces": {
"north": {"uv": [0, 6, 16, 10], "texture": "#2"},
"east": {"uv": [0, 0, 4, 3], "rotation": 90, "texture": "#2"},
"south": {"uv": [0, 6, 16, 10], "texture": "#2"},
"west": {"uv": [0, 0, 4, 3], "rotation": 90, "texture": "#2"},
"up": {"uv": [0, 6, 16, 9], "texture": "#2"},
"down": {"uv": [0, 6, 16, 9], "texture": "#2"}
}
},
{
"name": "Connector",
"from": [0, 7, 9],
"to": [2, 9, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [9, 8, 9]},
"faces": {
"north": {"uv": [0, 0, 2, 2], "texture": "#2"},
"east": {"uv": [0, 0, 1, 2], "texture": "#2"},
"south": {"uv": [0, 0, 2, 2], "texture": "#2"},
"west": {"uv": [0, 0, 1, 2], "texture": "#2"},
"up": {"uv": [0, 0, 2, 1], "texture": "#2"},
"down": {"uv": [0, 0, 2, 1], "texture": "#2"}
}
},
{
"name": "Grip",
"from": [-0.5, 6.5, 3],
"to": [2.5, 9.5, 9],
"rotation": {"angle": 45, "axis": "z", "origin": [1, 8, 9]},
"faces": {
"north": {"uv": [6, 11, 9, 14], "rotation": 90, "texture": "#0"},
"east": {"uv": [7, 1, 10, 7], "rotation": 90, "texture": "#0"},
"south": {"uv": [7, 5, 10, 8], "texture": "#0"},
"west": {"uv": [7, 1, 10, 7], "rotation": 90, "texture": "#0"},
"up": {"uv": [7, 1, 10, 7], "texture": "#0"},
"down": {"uv": [7, 1, 10, 7], "texture": "#0"}
}
}
],
"groups": [
{
"name": "shaft_half",
"origin": [8, 8, 8],
"children": [0]
}, 1, 2, 3, 4]
}

View file

@ -0,0 +1,123 @@
{
"credit": "Made with Blockbench",
"parent": "block/block",
"textures": {
"0": "create:block/axis",
"1": "create:block/axis_top",
"2": "create:block/andesite_casing_short",
"3": "block/spruce_log",
"particle": "create:block/axis"
},
"elements": [
{
"name": "Axis",
"from": [6, 6, 11],
"to": [10, 10, 16],
"shade": false,
"faces": {
"east": {"uv": [6, 0, 10, 5], "rotation": 270, "texture": "#0"},
"south": {"uv": [6, 6, 10, 10], "texture": "#1"},
"west": {"uv": [6, 0, 10, 5], "rotation": 90, "texture": "#0"},
"up": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
"down": {"uv": [6, 0, 10, 5], "texture": "#0"}
}
},
{
"name": "Connector",
"from": [5, 5, 11],
"to": [11, 11, 14],
"faces": {
"north": {"uv": [0, 0, 6, 6], "texture": "#3"},
"east": {"uv": [0, 0, 3, 6], "texture": "#3"},
"south": {"uv": [0, 0, 6, 6], "texture": "#3"},
"west": {"uv": [0, 0, 3, 6], "texture": "#3"},
"up": {"uv": [0, 0, 6, 3], "texture": "#3"},
"down": {"uv": [0, 0, 6, 3], "texture": "#3"}
}
},
{
"name": "Arm",
"from": [-2, 6, 10],
"to": [14, 10, 13],
"faces": {
"north": {"uv": [0, 6, 16, 10], "texture": "#2"},
"east": {"uv": [0, 0, 4, 3], "rotation": 90, "texture": "#2"},
"south": {"uv": [0, 6, 16, 10], "texture": "#2"},
"west": {"uv": [0, 0, 4, 3], "rotation": 90, "texture": "#2"},
"up": {"uv": [0, 6, 16, 9], "texture": "#2"},
"down": {"uv": [0, 6, 16, 9], "texture": "#2"}
}
},
{
"name": "Connector",
"from": [0, 7, 9],
"to": [2, 9, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [9, 8, 9]},
"faces": {
"north": {"uv": [0, 0, 2, 2], "texture": "#2"},
"east": {"uv": [0, 0, 1, 2], "texture": "#2"},
"south": {"uv": [0, 0, 2, 2], "texture": "#2"},
"west": {"uv": [0, 0, 1, 2], "texture": "#2"},
"up": {"uv": [0, 0, 2, 1], "texture": "#2"},
"down": {"uv": [0, 0, 2, 1], "texture": "#2"}
}
},
{
"name": "Grip",
"from": [-0.5, 6.5, 3],
"to": [2.5, 9.5, 9],
"rotation": {"angle": 45, "axis": "z", "origin": [1, 8, 9]},
"faces": {
"north": {"uv": [6, 11, 9, 14], "rotation": 90, "texture": "#0"},
"east": {"uv": [7, 1, 10, 7], "rotation": 90, "texture": "#0"},
"south": {"uv": [7, 5, 10, 8], "texture": "#0"},
"west": {"uv": [7, 1, 10, 7], "rotation": 90, "texture": "#0"},
"up": {"uv": [7, 1, 10, 7], "texture": "#0"},
"down": {"uv": [7, 1, 10, 7], "texture": "#0"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 180, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 180, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 1, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"translation": [-0.5, -1.25, 0],
"scale": [0.75, 0.75, 0.75]
},
"head": {
"rotation": [90, 0, 0],
"translation": [0, 14.5, 0]
},
"fixed": {
"translation": [0, 0, -3.5],
"scale": [0.5, 0.5, 0.5]
}
},
"groups": [
{
"name": "shaft_half",
"origin": [8, 8, 8],
"children": [0]
}, 1, 2, 3, 4]
}

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/hand_crank/item"
}

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/nozzle/item"
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "create:hand_crank"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "create:nozzle"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,29 @@
{
"type": "crafting_shaped",
"pattern": [
" L ",
"PPP",
" A"
],
"key": {
"L": {
"tag": "minecraft:logs"
},
"P": {
"tag": "minecraft:planks"
},
"A": {
"item": "create:andesite_alloy"
}
},
"result": {
"item": "create:hand_crank",
"count": 1
},
"conditions": [
{
"type": "create:module",
"module": "contraptions"
}
]
}

View file

@ -0,0 +1,26 @@
{
"type": "crafting_shaped",
"pattern": [
" A ",
" W ",
"AAA"
],
"key": {
"A": {
"item": "create:andesite_alloy"
},
"W": {
"tag": "minecraft:wool"
}
},
"result": {
"item": "create:nozzle",
"count": 1
},
"conditions": [
{
"type": "create:module",
"module": "contraptions"
}
]
}