-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
148 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...ithub/tartaricacid/touhoulittlemaid/compat/domesticationinnovation/EnchantmentRefuse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.compat.domesticationinnovation; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
import net.minecraft.world.item.enchantment.EnchantmentHelper; | ||
import net.minecraftforge.event.entity.player.PlayerInteractEvent; | ||
import net.minecraftforge.eventbus.api.EventPriority; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.ModList; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
import java.util.Map; | ||
|
||
@Mod.EventBusSubscriber | ||
public class EnchantmentRefuse { | ||
private static final String DOMESTICATION_INNOVATION = "domesticationinnovation"; | ||
private static final ResourceLocation COLLAR_TAG_ID = new ResourceLocation(DOMESTICATION_INNOVATION, "collar_tag"); | ||
private static final ResourceLocation UNDEAD_CURSE_ENCHANTMENT_ID = new ResourceLocation(DOMESTICATION_INNOVATION, "undead_curse"); | ||
private static final ResourceLocation BLAZING_PROTECTION_ENCHANTMENT_ID = new ResourceLocation(DOMESTICATION_INNOVATION, "blazing_protection"); | ||
|
||
@SubscribeEvent(priority = EventPriority.HIGHEST) | ||
public static void onInteractMaid(PlayerInteractEvent.EntityInteract event) { | ||
if (!ModList.get().isLoaded(DOMESTICATION_INNOVATION)) { | ||
return; | ||
} | ||
if (!(event.getTarget() instanceof EntityMaid maid)) { | ||
return; | ||
} | ||
if (maid.level.isClientSide) { | ||
return; | ||
} | ||
Player player = event.getEntity(); | ||
if (!maid.isOwnedBy(player)) { | ||
return; | ||
} | ||
ItemStack stack = event.getItemStack(); | ||
ResourceLocation itemsKey = ForgeRegistries.ITEMS.getKey(stack.getItem()); | ||
if (!COLLAR_TAG_ID.equals(itemsKey)) { | ||
return; | ||
} | ||
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack); | ||
for (Enchantment enchantment : enchantments.keySet()) { | ||
ResourceLocation enchantmentsKey = ForgeRegistries.ENCHANTMENTS.getKey(enchantment); | ||
if (UNDEAD_CURSE_ENCHANTMENT_ID.equals(enchantmentsKey)) { | ||
event.setCanceled(true); | ||
player.sendSystemMessage(Component.translatable("domesticationinnovation.touhou_little_maid.enchantment.undead_curse")); | ||
return; | ||
} | ||
if (BLAZING_PROTECTION_ENCHANTMENT_ID.equals(enchantmentsKey)) { | ||
event.setCanceled(true); | ||
player.sendSystemMessage(Component.translatable("domesticationinnovation.touhou_little_maid.enchantment.blazing_protection")); | ||
return; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters