Posted February 12, 20232 yr I want to check is the block that the player see is a specific modded block and I don't find answers, can you help me ? This is the code : @Mod.EventBusSubscriber public class CookerCraftingModdedRestrictionsProcedure { @SubscribeEvent public static void onPlayerTick(TickEvent.PlayerTickEvent event) { if (event.phase == TickEvent.Phase.END) { execute(event, event.player.level, event.player); } } public static void execute(LevelAccessor world, Entity entity) { execute(null, world, entity); } private static void execute(@Nullable Event event, LevelAccessor world, Entity entity) { if (entity == null) return; if ((world.getBlockState(new BlockPos( entity.level.clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX(), entity.level.clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY(), entity.level.clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()))) .getBlock().getRegistryName().equals(new ResourceLocation("minecraft", "diamond_ore"))) { if (entity instanceof Player _player) _player.closeContainer(); } } } I know it don't work but I don't find anything better. The imports aren't here but the error is not that. I want to prevent players from opening the inventory of a specific modded block (here it is vanilla and it is the diamond block but it will be modified) Hope you can help me.
February 12, 20232 yr If you don't want the player to open a modded block's inventory, then don't attach a gui to it. Also, this looks like MCreator. If I am correct in this, ask them for help. I'm not good at modding, but at least I can read a crash report (well enough). That's something, right?
February 13, 20232 yr Author Yes your right for MCreator but I want to prevent a player to open an inventory of an other mod and we can't do that with MCreator so it generate the code but I modify it.
February 14, 20232 yr On 2/13/2023 at 3:19 PM, Sikino said: Yes your right for MCreator but I want to prevent a player to open an inventory of an other mod and we can't do that with MCreator so it generate the code but I modify it. Ignore old me, this was when I didn't know MCreator code was actually decent. Please, I beg for you to learn how to code in Java instead of using MCreator, because MCreator generates unpolished code and you can't do advanced and cool things while also keeping it's code polished, instead it will be infested with bugs, and your mod will have double or triple the file size. Instead of MCreator, use a Java Ide (IntelliJ or Eclipse recommended), if you don't know Java, then search for tutorials online, there are lots of tutorials on Java, also, read the Forge Wiki before asking the simplest questions here. Alternatively, you can also learn how to mod with Fabric instead, you can read it's wiki here. Edited July 26, 20232 yr by EveryBlu I now know MCreator code is now a lot better.
February 15, 20232 yr Author On 2/14/2023 at 5:55 AM, EveryBlu said: Please, I beg for you to learn how to code in Java instead of using MCreator. I know Java but I'm not the only one in this project and the others don't know and just want to make little mods without spending hours of development. I think that nobody will answer so thanks to all of you and goodbye.
February 15, 20232 yr hola this code reads all the loaded blocks in the game and stores it to a hash map public static Map<String, BlockState> blocklist = new HashMap<String, BlockState>();// list whit all blocks for (Entry<ResourceKey<Block>, Block> ResourceKey : ForgeRegistries.BLOCKS.getEntries()) { actualBlock = ResourceKey.getValue(); nnn = fix_blkfullname(actualBlock.getName().getString()); blocklist.put(nnn, actualBlock.defaultBlockState()); if (nnn.contains("slab")) { // slablist.put(nnn, ""); } count++; } // ########## ########## ########## ########## ########## ########## // public static String fix_blkfullname(String blkfullname) { if (blkfullname.contains(".")) { String[] split1 = blkfullname.split("\\."); // "\\." if (split1.length > 1) { blkfullname = split1[split1.length - 1].replaceAll("_", " "); } } return blkfullname.toLowerCase(); }
February 17, 20232 yr On 2/15/2023 at 6:17 PM, Sikino said: I know Java but I'm not the only one in this project and the others don't know and just want to make little mods without spending hours of development. If they are just too lazy, or if they usually don't have a lot of free time, then why don't they just insert their own Java code into the MCreator project? Edited February 17, 20232 yr by EveryBlu Fix grammar.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.