Skip to content

Commit bc945a7

Browse files
committed
Allow paddling in creative
1 parent 6f039e3 commit bc945a7

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

common/src/main/java/dev/ryanhcode/sable/mixin/punching/MinecraftMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private void tryPaddling(final CallbackInfoReturnable<Boolean> cir) {
4343
if (hitResult.getType() == HitResult.Type.BLOCK) {
4444
final FluidState state = this.level.getFluidState(hitResult.getBlockPos());
4545
if (!state.isEmpty()) {
46-
ClientSubLevelPunchHelper.clientTryPunch(hitResult, this.level);
46+
ClientSubLevelPunchHelper.clientTryPunch(hitResult, this.level, false);
4747
}
4848
}
4949
}

common/src/main/java/dev/ryanhcode/sable/mixin/punching/MultiPlayerGameModeMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private void onBlockBreakStart(final BlockPos blockPos, final Direction directio
2424
assert this.minecraft.player != null;
2525

2626
if (this.minecraft.hitResult instanceof final BlockHitResult blockHitResult) {
27-
ClientSubLevelPunchHelper.clientTryPunch(blockHitResult, this.minecraft.level);
27+
ClientSubLevelPunchHelper.clientTryPunch(blockHitResult, this.minecraft.level, true);
2828
}
2929
}
3030

common/src/main/java/dev/ryanhcode/sable/network/client/ClientSubLevelPunchHelper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dev.ryanhcode.sable.network.client;
22

33
import dev.ryanhcode.sable.Sable;
4-
import dev.ryanhcode.sable.api.SubLevelHelper;
54
import dev.ryanhcode.sable.companion.math.JOMLConversion;
65
import dev.ryanhcode.sable.index.SableAttributes;
76
import dev.ryanhcode.sable.mixinterface.entity.entity_sublevel_collision.EntityMovementExtension;
@@ -16,15 +15,18 @@
1615
import org.joml.Vector3d;
1716

1817
public class ClientSubLevelPunchHelper {
19-
public static void clientTryPunch(final BlockHitResult hitResult, final Level level) {
18+
/**
19+
* @param testCreativeBreaking whether to prevent pushing if a creative player will destroy the block
20+
*/
21+
public static void clientTryPunch(final BlockHitResult hitResult, final Level level, final boolean testCreativeBreaking) {
2022
final Minecraft minecraft = Minecraft.getInstance();
2123
final LocalPlayer player = minecraft.player;
2224
if (player.blockActionRestricted(level, hitResult.getBlockPos(), minecraft.gameMode.getPlayerMode()) ||
2325
player.getCooldowns().isOnCooldown(player.getMainHandItem().getItem())) {
2426
return;
2527
}
2628

27-
if (player.isCreative()) {
29+
if (player.isCreative() && testCreativeBreaking) {
2830
final BlockState blockState = minecraft.level.getBlockState(hitResult.getBlockPos());
2931

3032
if (player.getMainHandItem().getItem().canAttackBlock(blockState, minecraft.level, hitResult.getBlockPos(), player)) {

0 commit comments

Comments
 (0)