2024/11/23

搞了一个TOP检测关闭GUI
This commit is contained in:
叁玖领域 2024-11-23 16:16:19 +08:00
parent eedf4b64cf
commit f81569bde3
14 changed files with 172 additions and 28 deletions

View File

@ -114,8 +114,7 @@ dependencies {
// compile against the JEI API but do not include it at runtime
compileOnly("mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}")
// at runtime, use the full JEI jar for NeoForge
runtimeOnly("mezz.jei:jei-${mc_version}-neoforge:${jei_version}")
// compileOnly("mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}")
// compileOnly("mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}")
// Example optional mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"

View File

@ -1,2 +1,2 @@
// 1.21 2024-11-16T17:00:44.8646839 Languages: en_us for mod: leashedplayer
2d1cc1306605f16bca4d02aeeec79c571a6dc04b assets/leashedplayer/lang/en_us.json
// 1.21 2024-11-23T14:23:28.9623441 Languages: en_us for mod: leashedplayer
ac6deeef9e460393df3b854a8d898d1a863deb45 assets/leashedplayer/lang/en_us.json

View File

@ -1,2 +1,2 @@
// 1.21 2024-11-16T21:56:30.3223474 Languages: zh_cn for mod: leashedplayer
4ee98b29b6ba49637275aeeeb939f179e121b60a assets/leashedplayer/lang/zh_cn.json
// 1.21 2024-11-23T14:23:28.9623441 Languages: zh_cn for mod: leashedplayer
c019c3538ff7dc5a74283f3045cae496b67d7a33 assets/leashedplayer/lang/zh_cn.json

View File

@ -1,2 +1,2 @@
// 1.21 2024-11-16T21:56:30.3223474 Languages: zh_tw for mod: leashedplayer
6fc9463fd8d30efe4e30a2c3584623d458c320a0 assets/leashedplayer/lang/zh_tw.json
// 1.21 2024-11-23T14:23:28.9623441 Languages: zh_tw for mod: leashedplayer
c464f0cfad108f12fddf0229aaabd0750d3b1eee assets/leashedplayer/lang/zh_tw.json

View File

@ -32,6 +32,8 @@
"gamerule.LP.DefaultTalkArea.description": "When the global setting is non-negative, it limits the chat range for all players. If a player's configured chat range is smaller than this value, this rule applies. Otherwise, the player's custom value is used.",
"gamerule.LP.KeepLeashNotDropTime": "Keep leash alive Time",
"gamerule.LP.KeepLeashNotDropTime.description": "The time of Keep new leash which has far distance alive (Tick)",
"gamerule.LP.OpenTOPNeededModeWhenScreenIsNotNull": "Open TOP NEEDED Mode When Screen isn't null",
"gamerule.LP.OpenTOPNeededModeWhenScreenIsNotNull.description": "The One Probe will automatic to be in the Needed Mode when Gui Screen is not NULL",
"gamerule.LP.TeleportWithLeashedPlayers": "Teleport leashed player with player holder",
"gamerule.LP.TeleportWithLeashedPlayers.description": "Holder will teleport with their leashed players ",
"item.leash_rope_arrow.desc.1": "§7This arrow will carry the owner along with its flight:",

View File

@ -32,6 +32,8 @@
"gamerule.LP.DefaultTalkArea.description": "全局区域设置为非负数时,则限制全体玩家的聊天区域。若玩家设置的聊天区域小于该值则采用该规则,反之则采用玩家自定义值",
"gamerule.LP.KeepLeashNotDropTime": "保持拴绳不掉落的时间",
"gamerule.LP.KeepLeashNotDropTime.description": "当距离过远时,保持新建拴绳不掉落的时间 (刻)",
"gamerule.LP.OpenTOPNeededModeWhenScreenIsNotNull": "当屏幕不为空时自动打开探测器的Needed模式",
"gamerule.LP.OpenTOPNeededModeWhenScreenIsNotNull.description": "当屏幕不为空时自动打开探测器的Needed模式",
"gamerule.LP.TeleportWithLeashedPlayers": "被拴玩家随玩家持有者传送",
"gamerule.LP.TeleportWithLeashedPlayers.description": "传送时将被拴玩家与持有者一起传送",
"item.leash_rope_arrow.desc.1": "§7该箭将会携带拥有者随其飞行",

View File

@ -32,6 +32,8 @@
"gamerule.LP.DefaultTalkArea.description": "儅全局區域為非負時,則限制全服玩家聊天區域。若玩家自定義值小於該規則則采用,反之則用玩家自定義值",
"gamerule.LP.KeepLeashNotDropTime": "保持其不掉落的時間",
"gamerule.LP.KeepLeashNotDropTime.description": "儅距離過遠時,保持其不掉落的時間(刻)",
"gamerule.LP.OpenTOPNeededModeWhenScreenIsNotNull": "避免糠測器糠屏幕",
"gamerule.LP.OpenTOPNeededModeWhenScreenIsNotNull.description": "避免糠測器糠屏幕",
"gamerule.LP.TeleportWithLeashedPlayers": "被拴玩家随玩家持有者傳送",
"gamerule.LP.TeleportWithLeashedPlayers.description": "將被拴玩家將隨持有者一起傳送",
"item.leash_rope_arrow.desc.1": "§7該箭將會攜帶擁有者隨其飛行",

View File

@ -5,18 +5,22 @@ import com.r3944realms.leashedplayer.client.renders.entities.KidPlayerRenderer;
import com.r3944realms.leashedplayer.client.renders.entities.LeashRopeArrowRenderer;
import com.r3944realms.leashedplayer.client.renders.entities.SpectralLeashRopeArrowRenderer;
import com.r3944realms.leashedplayer.content.entities.ModEntityRegister;
import com.r3944realms.leashedplayer.content.gamerules.GameruleRegistry;
import com.r3944realms.leashedplayer.content.gamerules.Server.OpenTOPNeededModeWhenScreenIsNotNull;
import com.r3944realms.leashedplayer.content.items.ModItemRegister;
import com.r3944realms.leashedplayer.content.items.type.ILeashRopeArrow;
import com.r3944realms.leashedplayer.utils.Logger;
import mcjty.theoneprobe.config.Config;
import net.minecraft.client.renderer.entity.EntityRenderer;
import mcjty.theoneprobe.gui.GuiNote;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen;
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.client.resources.PlayerSkin;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FastColor;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.component.ChargedProjectiles;
@ -25,28 +29,46 @@ import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.ClientTickEvent;
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
import net.neoforged.neoforge.client.event.ScreenEvent;
import java.util.Objects;
import java.util.Stack;
public abstract class ClientEventHandler {
@EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.GAME, modid = LeashedPlayer.MOD_ID)
public static class Game extends ClientEventHandler {
private static int oldSelect;
private static boolean configSaved = false;
private static final boolean IS_TOP_LOADED = ModList.get().isLoaded("theoneprobe");
private static int OldSelect = 0;
@SubscribeEvent
public static void onScreenOpen(ScreenEvent.Opening event) {
if (IS_TOP_LOADED) {
OldSelect = Config.needsProbe.get();
Config.setProbeNeeded(Config.PROBE_NEEDED);
}
}
@SubscribeEvent
public static void onScreenClose(ScreenEvent.Closing event) {
if (IS_TOP_LOADED) {
Config.setProbeNeeded(OldSelect);
public static void onClientTick(ClientTickEvent.Pre event) {
Minecraft mc = Minecraft.getInstance();
if (mc.level == null) return;
if (GameruleRegistry.getGameruleBoolValue(mc.level, OpenTOPNeededModeWhenScreenIsNotNull.ID)){
Screen currentScreen = mc.screen;
if (IS_TOP_LOADED) {
if (currentScreen != null) {
if (currentScreen instanceof GuiNote) {
configSaved = false;
oldSelect = Config.needsProbe.get();
} else {
if (!configSaved) {
oldSelect = Config.needsProbe.get();
Config.setProbeNeeded(Config.PROBE_NEEDED);
configSaved = true;
} else {
Config.setProbeNeeded(Config.PROBE_NEEDED);
}
}
} else {
Config.setProbeNeeded(oldSelect);
configSaved = false;
}
}
}
}
}

View File

@ -0,0 +1,27 @@
package com.r3944realms.leashedplayer.api;
import com.r3944realms.leashedplayer.LeashedPlayer;
import com.r3944realms.leashedplayer.apiContent.item.repcipe.JEIRecipeTypes;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.recipe.vanilla.IVanillaRecipeFactory;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
@JeiPlugin
public class JEIPlugin implements IModPlugin {
private static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(LeashedPlayer.MOD_ID, "jei_plugin");
@Override
public @NotNull ResourceLocation getPluginUid() {
return UID;
}
@Override
public void registerRecipes(@NotNull IRecipeRegistration registration) {
}
}

View File

@ -0,0 +1,13 @@
package com.r3944realms.leashedplayer.apiContent.item.repcipe;
import com.r3944realms.leashedplayer.LeashedPlayer;
import com.r3944realms.leashedplayer.content.items.repcipe.TippedLeashRopeArrowRecipe;
import mezz.jei.api.recipe.RecipeType;
public class JEIRecipeTypes {
public static final RecipeType<TippedLeashRopeArrowRecipe.TippedLeashRopeArrowARecipe> TIPPED_LEASH_ROPE_ARROW_A =
RecipeType.create(LeashedPlayer.MOD_ID, "tipped_leash_rope_arrow_a", TippedLeashRopeArrowRecipe.TippedLeashRopeArrowARecipe.class);
public static final RecipeType<TippedLeashRopeArrowRecipe.TippedLeashRopeArrowBRecipe> TIPPED_LEASH_ROPE_ARROW_B =
RecipeType.create(LeashedPlayer.MOD_ID, "tipped_leash_rope_arrow_b", TippedLeashRopeArrowRecipe.TippedLeashRopeArrowBRecipe.class);
}

View File

@ -0,0 +1,38 @@
package com.r3944realms.leashedplayer.apiContent.item.repcipe;
import mezz.jei.api.constants.ModIds;
import mezz.jei.api.helpers.IJeiHelpers;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.crafting.*;
import net.neoforged.neoforge.common.CommonHooks;
import java.util.List;
import java.util.Optional;
import static net.minecraft.world.item.Items.*;
public class TippedLeashRopeArrowRecipeMaker {
public static List<RecipeHolder<CraftingRecipe>> createRecipes(IJeiHelpers jeiHelpers) {
String group = "jei.tipped.arrow";
ItemStack arrowStack = new ItemStack(Items.ARROW);
Ingredient arrowIngredient = Ingredient.of(arrowStack);
HolderLookup.RegistryLookup<Potion> potionRegistry = CommonHooks.resolveLookup(Registries.POTION);
return null;
}
private TippedLeashRopeArrowRecipeMaker() {
}
}

View File

@ -0,0 +1,25 @@
package com.r3944realms.leashedplayer.content.gamerules.Server;
import com.r3944realms.leashedplayer.LeashedPlayer;
import com.r3944realms.leashedplayer.content.gamerules.Gamerules;
import com.r3944realms.leashedplayer.utils.Util;
import net.minecraft.world.level.GameRules;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import static com.r3944realms.leashedplayer.content.gamerules.Gamerules.GAMERULE_REGISTRY;
@EventBusSubscriber(modid = LeashedPlayer.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
public class OpenTOPNeededModeWhenScreenIsNotNull {
public static final boolean DEFAULT_VALUE = true;
public static final String ID = Util.getGameruleName(OpenTOPNeededModeWhenScreenIsNotNull.class);
public static final String DESCRIPTION_KEY = Gamerules.getDescriptionKey(OpenTOPNeededModeWhenScreenIsNotNull.class);
public static final String NAME_KEY = Gamerules.getNameKey(OpenTOPNeededModeWhenScreenIsNotNull.class);
public static final GameRules.Category CATEGORY = GameRules.Category.MISC;
@SubscribeEvent
public static void onCommonSetup(final FMLCommonSetupEvent event) {
GAMERULE_REGISTRY.registerGamerule(ID, CATEGORY, DEFAULT_VALUE, (i, j)->{});
}
}

View File

@ -11,6 +11,7 @@ import net.minecraft.world.item.crafting.CustomRecipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class TippedLeashRopeArrowRecipe {
public static class TippedLeashRopeArrowARecipe extends CustomRecipe {
@ -66,6 +67,13 @@ public abstract class TippedLeashRopeArrowRecipe {
public @NotNull RecipeSerializer<?> getSerializer() {
return ModRecipeRegister.TIPPED_LEASH_ROPE_ARROW_A_RECIPE.get();
}
@Override
public @NotNull ItemStack getResultItem(@Nullable HolderLookup.Provider pRegistries) {
return new ItemStack(ModItemRegister.TIPPED_LEASH_ROPE_ARROW.get());
}
public @NotNull ItemStack getResultItem() {
return getResultItem(null);
}
}
public static class TippedLeashRopeArrowBRecipe extends CustomRecipe {
@ -115,5 +123,13 @@ public abstract class TippedLeashRopeArrowRecipe {
public @NotNull RecipeSerializer<?> getSerializer() {
return ModRecipeRegister.TIPPED_LEASH_ROPE_ARROW_B_RECIPE.get();
}
@Override
public @NotNull ItemStack getResultItem(@Nullable HolderLookup.Provider pRegistries) {
return new ItemStack(ModItemRegister.TIPPED_LEASH_ROPE_ARROW.get());
}
public @NotNull ItemStack getResultItem() {
return getResultItem(null);
}
}
}

View File

@ -6,10 +6,7 @@ import com.r3944realms.leashedplayer.content.commands.MotionCommand;
import com.r3944realms.leashedplayer.content.effects.ModEffectRegister;
import com.r3944realms.leashedplayer.content.effects.ModPotionRegister;
import com.r3944realms.leashedplayer.content.entities.ModEntityRegister;
import com.r3944realms.leashedplayer.content.gamerules.Server.CreateLeashFenceKnotEntityIfAbsent;
import com.r3944realms.leashedplayer.content.gamerules.Server.DefaultTalkArea;
import com.r3944realms.leashedplayer.content.gamerules.Server.KeepLeashNotDropTime;
import com.r3944realms.leashedplayer.content.gamerules.Server.TeleportWithLeashedPlayers;
import com.r3944realms.leashedplayer.content.gamerules.Server.*;
import com.r3944realms.leashedplayer.content.items.ModCreativeTab;
import com.r3944realms.leashedplayer.content.items.ModItemRegister;
import com.r3944realms.leashedplayer.content.items.type.LeadBreakerItem;
@ -94,6 +91,7 @@ public enum ModLangKeyValue {
TELEPORT_WITH_LEASHED_PLAYERS(TeleportWithLeashedPlayers.NAME_KEY, ModPartEnum.NAME, "Teleport leashed player with player holder", "被拴玩家随玩家持有者传送", "被拴玩家随玩家持有者傳送" ,false),
CREATE_LEASH_FENCE_KNOT_ENTITY_IF_ABSENT(CreateLeashFenceKnotEntityIfAbsent.NAME_KEY, ModPartEnum.NAME, "Create Leash Fence Knot Entity if absent", "如果缺失则创建拴绳结", "如果缺失則創建拴繩結", false),
KEEP_LEASH_NOT_DROP_TIME(KeepLeashNotDropTime.NAME_KEY, ModPartEnum.NAME, "Keep leash alive Time", "保持拴绳不掉落的时间", "保持其不掉落的時間", false),
OTOPNMWSINN_MAME(OpenTOPNeededModeWhenScreenIsNotNull.NAME_KEY, ModPartEnum.NAME, "Open TOP NEEDED Mode When Screen isn't null", "当屏幕不为空时自动打开探测器的Needed模式", "避免糠測器糠屏幕", false),
// DISABLE_MOVE_CHECK(DisablePlayerMoveCheck.NAME_KEY, ModPartEnum.NAME, "Disable Player Move Check", "禁止检查玩家移动", "禁止檢查玩家移動", false),
//GAME_RULE_DESCRIPTION
@ -101,7 +99,7 @@ public enum ModLangKeyValue {
CREATE_LEASH_FENCE_KNOT_ENTITY_IF_ABSENT_DESCRIPTION(CreateLeashFenceKnotEntityIfAbsent.DESCRIPTION_KEY, ModPartEnum.DESCRIPTION, "Create LeashKnot Entity if it's absent on fence", "如果在栅栏处缺失拴绳结,则创建它", "如果在柵欄処缺失拴繩結,則創建它", false),
KEEP_LEASH_NOT_DROP_TIME_DESCRIPTION(KeepLeashNotDropTime.DESCRIPTION_KEY, ModPartEnum.DESCRIPTION,"The time of Keep new leash which has far distance alive (Tick)", "当距离过远时,保持新建拴绳不掉落的时间 (刻)", "儅距離過遠時,保持其不掉落的時間(刻)", false),
// DISABLE_MOVE_CHECK_DESCRIPTION(DisablePlayerMoveCheck.DESCRIPTION_KEY, ModPartEnum.DESCRIPTION, "Disable the player's movement Check And Correct it.", "禁止检查玩家移动并且纠正它","禁止檢查玩家移動並糾正他它", false),
OTOPNMWSINN_DESCRIPTION(OpenTOPNeededModeWhenScreenIsNotNull.DESCRIPTION_KEY, ModPartEnum.DESCRIPTION, "The One Probe will automatic to be in the Needed Mode when Gui Screen is not NULL", "当屏幕不为空时自动打开探测器的Needed模式", "避免糠測器糠屏幕", false),
DEFAULT_AREA_TALK_DESCRIPTION(DefaultTalkArea.DESCRIPTION_KEY, ModPartEnum.DESCRIPTION, "When the global setting is non-negative, it limits the chat range for all players. If a player's configured chat range is smaller than this value, this rule applies. Otherwise, the player's custom value is used.", "全局区域设置为非负数时,则限制全体玩家的聊天区域。若玩家设置的聊天区域小于该值则采用该规则,反之则采用玩家自定义值", "儅全局區域為非負時,則限制全服玩家聊天區域。若玩家自定義值小於該規則則采用,反之則用玩家自定義值","阖局初置非负数,则限一顾之日下,若立聊城小在直则用其常,若用玩义直上跻之地", false),
//ADV_NAME
LEASH_START(ModAdvancementKey.LEASH_START.getNameKey(), ModPartEnum.NAME, "The Power of Traction", "牵引之力", "牽引之力", false),