mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-13 21:41:34 +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
|
@Override
|
||||||
public boolean isActive(MovementContext context) {
|
public boolean isActive(MovementContext context) {
|
||||||
return SawBlock.isHorizontal(context.state);
|
return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.get(SawBlock.FACING)
|
||||||
|
.getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,6 +36,15 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
return new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()).scale(.65f);
|
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
|
@Override
|
||||||
public boolean canBreak(World world, BlockPos breakingPos, BlockState state) {
|
public boolean canBreak(World world, BlockPos breakingPos, BlockState state) {
|
||||||
return super.canBreak(world, breakingPos, state) && SawTileEntity.isSawable(state);
|
return super.canBreak(world, breakingPos, state) && SawTileEntity.isSawable(state);
|
||||||
|
|
|
@ -139,9 +139,21 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||||
SuperByteBuffer superBuffer;
|
SuperByteBuffer superBuffer;
|
||||||
Direction facing = state.get(SawBlock.FACING);
|
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)) {
|
if(SawBlock.isHorizontal(state)) {
|
||||||
|
if(shouldAnimate)
|
||||||
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state);
|
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state);
|
||||||
|
else
|
||||||
|
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE.renderOn(state);
|
||||||
} else {
|
} else {
|
||||||
|
if(shouldAnimate)
|
||||||
|
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE.renderOn(state);
|
||||||
|
else
|
||||||
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state);
|
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue