mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-03 22:34:42 +01:00
Prevent damage to Extendo-Grip from Frost Walker
Frost Walker places frosted ice blocks through the EntityPlaceEvent. Currently, the event then damages the Extendo-Grip for every frosted ice block placed by the enchantment, rapidly breaking it. This fix prevents damage to the Extendo-Grip when the block is Frosted Ice and the player's equipment has Frost Walker.
This commit is contained in:
parent
2cf08a1231
commit
00468791dc
1 changed files with 16 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.simibubi.create.content.equipment.extendoGrip;
|
package com.simibubi.create.content.equipment.extendoGrip;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -29,6 +30,9 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantment;
|
||||||
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
|
@ -182,8 +186,18 @@ public class ExtendoGripItem extends Item {
|
||||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||||
public static void consumeDurabilityOnPlace(EntityPlaceEvent event) {
|
public static void consumeDurabilityOnPlace(EntityPlaceEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Player)
|
if (entity instanceof Player player) {
|
||||||
findAndDamageExtendoGrip((Player) entity);
|
if (event.getPlacedBlock().is(Blocks.FROSTED_ICE)) {
|
||||||
|
for (ItemStack armorSlot : player.getArmorSlots()) {
|
||||||
|
for (Enchantment enchantment : armorSlot.getAllEnchantments().keySet()) {
|
||||||
|
if (!enchantment.equals(Enchantments.FROST_WALKER)) {
|
||||||
|
findAndDamageExtendoGrip(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else findAndDamageExtendoGrip(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @SubscribeEvent(priority = EventPriority.LOWEST)
|
// @SubscribeEvent(priority = EventPriority.LOWEST)
|
||||||
|
|
Loading…
Add table
Reference in a new issue