Skip to content

Commit

Permalink
Restrict Ring of Correction to block breaking
Browse files Browse the repository at this point in the history
Fixes #4317, and also makes things less weird e.g. with scraping copper blocks or tilling soil.
  • Loading branch information
TheRealWormbo committed May 7, 2024
1 parent 4c141cb commit 8e145cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
*/
package vazkii.botania.common.item.equipment.bauble;

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;

import vazkii.botania.api.item.SortableTool;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
import vazkii.botania.mixin.ServerPlayerGameModeAccessor;

public class RingOfCorrectionItem extends BaubleItem {

Expand All @@ -27,13 +28,13 @@ public RingOfCorrectionItem(Properties props) {

@Override
public void onWornTick(ItemStack stack, LivingEntity entity) {
if (entity.level().isClientSide || !(entity instanceof Player player)) {
if (entity.level().isClientSide || !(entity instanceof ServerPlayer player)) {
return;
}

ItemStack currentStack = player.getMainHandItem();
if (currentStack.isEmpty() || !(currentStack.getItem() instanceof SortableTool tool)
|| !player.swinging) {
|| !((ServerPlayerGameModeAccessor) player.gameMode).botania_isDestroyingBlock()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package vazkii.botania.mixin;

import net.minecraft.server.level.ServerPlayerGameMode;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ServerPlayerGameMode.class)
public interface ServerPlayerGameModeAccessor {
@Accessor("isDestroyingBlock")
boolean botania_isDestroyingBlock();
}
1 change: 1 addition & 0 deletions Xplat/src/main/resources/botania_xplat.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"RecipeManagerAccessor",
"RecipeProviderAccessor",
"ServerLevelMixin",
"ServerPlayerGameModeAccessor",
"ServerPlayerMixin",
"SpawnPlacementsMixin",
"StatsAccessor",
Expand Down

0 comments on commit 8e145cd

Please sign in to comment.