use of com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity in project FrostedHeart by TeamMoegMC.
the class MixinGantryContraptionEntity method checkPinionShaft.
@Inject(at = @At("HEAD"), method = "checkPinionShaft", remap = false)
protected void checkPinionShaft(CallbackInfo cbi) {
Direction facing = ((GantryContraption) contraption).getFacing();
Vector3d currentPosition = getAnchorVec().add(.5, .5, .5);
BlockPos gantryShaftPos = new BlockPos(currentPosition).offset(facing.getOpposite());
TileEntity te = world.getTileEntity(gantryShaftPos);
if (te instanceof IGantryShaft) {
GantryShaftTileEntity gte = (GantryShaftTileEntity) te;
((IGantryShaft) gte).setEntity(this);
gte.networkDirty = true;
return;
}
}
use of com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity in project Create by Creators-of-Create.
the class GantryCarriageTileEntity method shouldAssemble.
private boolean shouldAssemble() {
BlockState blockState = getBlockState();
if (!(blockState.getBlock() instanceof GantryCarriageBlock))
return false;
Direction facing = blockState.getValue(GantryCarriageBlock.FACING).getOpposite();
BlockState shaftState = level.getBlockState(worldPosition.relative(facing));
if (!(shaftState.getBlock() instanceof GantryShaftBlock))
return false;
if (shaftState.getValue(GantryShaftBlock.POWERED))
return false;
BlockEntity te = level.getBlockEntity(worldPosition.relative(facing));
return te instanceof GantryShaftTileEntity && ((GantryShaftTileEntity) te).canAssembleOn();
}
use of com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity in project Create by Creators-of-Create.
the class GantryCarriageTileEntity method tryAssemble.
private void tryAssemble() {
BlockState blockState = getBlockState();
if (!(blockState.getBlock() instanceof GantryCarriageBlock))
return;
Direction direction = blockState.getValue(GantryCarriageBlock.FACING);
GantryContraption contraption = new GantryContraption(direction);
BlockEntity shaftTe = level.getBlockEntity(worldPosition.relative(direction.getOpposite()));
if (!(shaftTe instanceof GantryShaftTileEntity))
return;
BlockState shaftState = shaftTe.getBlockState();
if (!AllBlocks.GANTRY_SHAFT.has(shaftState))
return;
float pinionMovementSpeed = ((GantryShaftTileEntity) shaftTe).getPinionMovementSpeed();
Direction shaftOrientation = shaftState.getValue(GantryShaftBlock.FACING);
Direction movementDirection = shaftOrientation;
if (pinionMovementSpeed < 0)
movementDirection = movementDirection.getOpposite();
try {
lastException = null;
if (!contraption.assemble(level, worldPosition))
return;
sendData();
} catch (AssemblyException e) {
lastException = e;
sendData();
return;
}
if (ContraptionCollider.isCollidingWithWorld(level, contraption, worldPosition.relative(movementDirection), movementDirection))
return;
contraption.removeBlocksFromWorld(level, BlockPos.ZERO);
GantryContraptionEntity movedContraption = GantryContraptionEntity.create(level, contraption, shaftOrientation);
BlockPos anchor = worldPosition;
movedContraption.setPos(anchor.getX(), anchor.getY(), anchor.getZ());
AllSoundEvents.CONTRAPTION_ASSEMBLE.playOnServer(level, worldPosition);
level.addFreshEntity(movedContraption);
}
use of com.simibubi.create.content.contraptions.relays.advanced.GantryShaftTileEntity in project Create by Creators-of-Create.
the class GantryContraptionEntity method checkPinionShaft.
protected void checkPinionShaft() {
Vec3 movementVec;
Direction facing = ((GantryContraption) contraption).getFacing();
Vec3 currentPosition = getAnchorVec().add(.5, .5, .5);
BlockPos gantryShaftPos = new BlockPos(currentPosition).relative(facing.getOpposite());
BlockEntity te = level.getBlockEntity(gantryShaftPos);
if (!(te instanceof GantryShaftTileEntity) || !AllBlocks.GANTRY_SHAFT.has(te.getBlockState())) {
if (!level.isClientSide) {
setContraptionMotion(Vec3.ZERO);
disassemble();
}
return;
}
BlockState blockState = te.getBlockState();
Direction direction = blockState.getValue(GantryShaftBlock.FACING);
GantryShaftTileEntity gantryShaftTileEntity = (GantryShaftTileEntity) te;
float pinionMovementSpeed = gantryShaftTileEntity.getPinionMovementSpeed();
movementVec = Vec3.atLowerCornerOf(direction.getNormal()).scale(pinionMovementSpeed);
if (blockState.getValue(GantryShaftBlock.POWERED) || pinionMovementSpeed == 0) {
setContraptionMotion(Vec3.ZERO);
if (!level.isClientSide)
disassemble();
return;
}
Vec3 nextPosition = currentPosition.add(movementVec);
double currentCoord = direction.getAxis().choose(currentPosition.x, currentPosition.y, currentPosition.z);
double nextCoord = direction.getAxis().choose(nextPosition.x, nextPosition.y, nextPosition.z);
if ((Mth.floor(currentCoord) + .5f < nextCoord != (pinionMovementSpeed * direction.getAxisDirection().getStep() < 0)))
if (!gantryShaftTileEntity.canAssembleOn()) {
setContraptionMotion(Vec3.ZERO);
if (!level.isClientSide)
disassemble();
return;
}
if (level.isClientSide)
return;
axisMotion = pinionMovementSpeed;
setContraptionMotion(movementVec);
}
Aggregations