-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff1d79c
commit 1c44323
Showing
8 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/main/java/com/github/tartaricacid/touhoulittlemaid/event/CopyEntityIdEvent.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,44 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.event; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.init.InitItems; | ||
import net.minecraft.Util; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.network.chat.TranslatableComponent; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
import net.minecraftforge.event.entity.player.PlayerInteractEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.loading.FMLEnvironment; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
@Mod.EventBusSubscriber(modid = TouhouLittleMaid.MOD_ID) | ||
public final class CopyEntityIdEvent { | ||
@SubscribeEvent | ||
public static void copyEntityId(PlayerInteractEvent.EntityInteract event) { | ||
Player player = event.getPlayer(); | ||
InteractionHand hand = event.getHand(); | ||
Entity target = event.getTarget(); | ||
if (player.getItemInHand(hand).is(InitItems.ENTITY_ID_COPY.get())) { | ||
if (player.level.isClientSide && FMLEnvironment.dist == Dist.CLIENT) { | ||
copyEntityId(player, target); | ||
} | ||
event.setCanceled(true); | ||
} | ||
} | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
private static void copyEntityId(Player player, Entity target) { | ||
ResourceLocation key = ForgeRegistries.ENTITIES.getKey(target.getType()); | ||
if (key == null) { | ||
return; | ||
} | ||
Minecraft.getInstance().keyboardHandler.setClipboard(key.toString()); | ||
player.sendMessage(new TranslatableComponent("message.touhou_little_maid.entity_id_copy.copy", key.toString()), Util.NIL_UUID); | ||
} | ||
} |
Empty file removed
0
src/main/java/com/github/tartaricacid/touhoulittlemaid/init/InitCreativeTabs.java
Empty file.
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/github/tartaricacid/touhoulittlemaid/item/ItemEntityIdCopy.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,25 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.item; | ||
|
||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.TranslatableComponent; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
import static com.github.tartaricacid.touhoulittlemaid.item.MaidGroup.MAIN_TAB; | ||
|
||
public class ItemEntityIdCopy extends Item { | ||
public ItemEntityIdCopy() { | ||
super(new Item.Properties().stacksTo(1).tab(MAIN_TAB)); | ||
} | ||
|
||
@Override | ||
public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> components, TooltipFlag pIsAdvanced) { | ||
components.add(new TranslatableComponent("tooltips.touhou_little_maid.entity_id_copy.desc").withStyle(ChatFormatting.GRAY)); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/touhou_little_maid/models/item/entity_id_copy.json
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,6 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "touhou_little_maid:item/entity_id_copy" | ||
} | ||
} |
Binary file added
BIN
+302 Bytes
src/main/resources/assets/touhou_little_maid/textures/item/entity_id_copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.