mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-09 03:23:09 +01:00
Conditional moving saw operation
- Saws are inactive while moving backwards - Vertical moving saws can now damage entities
This commit is contained in:
parent
a28b6bbdc3
commit
5342beacaf
2 changed files with 25 additions and 3 deletions
|
@ -27,7 +27,8 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour {
|
|||
|
||||
@Override
|
||||
public boolean isActive(MovementContext context) {
|
||||
return SawBlock.isHorizontal(context.state);
|
||||
return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.get(SawBlock.FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +36,15 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour {
|
|||
return new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()).scale(.65f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitNewPosition(MovementContext context, BlockPos pos) {
|
||||
super.visitNewPosition(context, pos);
|
||||
if(!SawBlock.isHorizontal(context.state) && context.data.contains("BreakingPos")) {
|
||||
context.data.remove("BreakingPos");
|
||||
context.stall = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreak(World world, BlockPos breakingPos, BlockState state) {
|
||||
return super.canBreak(world, breakingPos, state) && SawTileEntity.isSawable(state);
|
||||
|
|
|
@ -139,10 +139,22 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
|||
SuperByteBuffer superBuffer;
|
||||
Direction facing = state.get(SawBlock.FACING);
|
||||
|
||||
boolean horizontal = SawBlock.isHorizontal(state);
|
||||
boolean backwards = VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite());
|
||||
boolean moving = context.getAnimationSpeed() != 0;
|
||||
boolean shouldAnimate = (context.contraption.stalled && horizontal)
|
||||
|| (!context.contraption.stalled && !backwards && moving);
|
||||
|
||||
if(SawBlock.isHorizontal(state)) {
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state);
|
||||
if(shouldAnimate)
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state);
|
||||
else
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE.renderOn(state);
|
||||
} else {
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state);
|
||||
if(shouldAnimate)
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE.renderOn(state);
|
||||
else
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state);
|
||||
}
|
||||
|
||||
for (MatrixStack m : matrixStacks) {
|
||||
|
|
Loading…
Reference in a new issue