Skip to content

Fixes Extendo Grips for branch mc1.18/fabric/dev #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.DamageSource;
Expand All @@ -31,6 +32,10 @@
import net.minecraft.world.entity.projectile.ProjectileUtil;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
Expand Down Expand Up @@ -158,23 +163,6 @@ public static void dontMissEntitiesWhenYouHaveHighReachDistance(/*ClickInputEven
}
}

// @SubscribeEvent(priority = EventPriority.LOWEST)
// public static void consumeDurabilityOnBlockBreak(BreakEvent event) {
// findAndDamageExtendoGrip(event.getPlayer());
// }
//
// @SubscribeEvent(priority = EventPriority.LOWEST)
// public static void consumeDurabilityOnPlace(EntityPlaceEvent event) {
// Entity entity = event.getEntity();
// if (entity instanceof Player)
// findAndDamageExtendoGrip((Player) entity);
// }

// @SubscribeEvent(priority = EventPriority.LOWEST)
// public static void consumeDurabilityOnPlace(PlayerInteractEvent event) {
// findAndDamageExtendoGrip(event.getPlayer());
// }

private static void findAndDamageExtendoGrip(Player player) {
if (player == null)
return;
Expand Down Expand Up @@ -289,6 +277,14 @@ public static boolean isHoldingExtendoGrip(Player player) {
return holdingGrip;
}

public static void consumeDurabilityOnBreak(Level level, Player player, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity) {
findAndDamageExtendoGrip(player);
}

public static void consumeDurabilityOnPlace(BlockPlaceContext blockPlaceContext, BlockPos blockPos, BlockState blockState) {
findAndDamageExtendoGrip(blockPlaceContext.getPlayer());
}

// @Override
// @Environment(EnvType.CLIENT)
// public void initializeClient(Consumer<IItemRenderProperties> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,7 @@ public static void register() {
MinecartEvents.WRITE.register(AbstractMinecartExtensions::minecartWrite);
MinecartEvents.REMOVE.register(AbstractMinecartExtensions::minecartRemove);
PlayerBlockBreakEvents.BEFORE.register(SymmetryHandler::onBlockDestroyed);
PlayerBlockBreakEvents.AFTER.register(ExtendoGripItem::consumeDurabilityOnBreak);
BlockEvents.POST_PROCESS_PLACE.register(ExtendoGripItem::consumeDurabilityOnPlace);
}
}