-
Posts
36 -
Joined
Everything posted by Caffeinated Pinkie
-
Is there a proper or correct way to check if a mod is running in a Forge development environment versus if it's running in an actual Minecraft client?
-
Item DeferredRegister Issue
Caffeinated Pinkie replied to Caffeinated Pinkie's topic in Modder Support
Oh jeez, that was a stupid mistake. I should not have been writing late t night. Thank you. -
Item DeferredRegister Issue
Caffeinated Pinkie replied to Caffeinated Pinkie's topic in Modder Support
Alright. But that still doesn't help because none of the methods I tried work. -
Item DeferredRegister Issue
Caffeinated Pinkie replied to Caffeinated Pinkie's topic in Modder Support
Well, when I iterate through the BLOCKS entries, it shows two RegistryObjects in it. After running the command to create items as I did, there are two RegistryObjects in the items entries. They all have the correct names as well. It seems functionally identical to defining them as so: public Circuitry() { DeferredRegister<Item> items = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); items.register("in_node", () -> new BlockItem(IN_NODE.get(), new Properties().group(ItemGroup.REDSTONE))); items.register("out_node", () -> new BlockItem(OUT_NODE.get(), new Properties().group(ItemGroup.REDSTONE))); IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(BLOCKS); bus.register(items); } and even doing this statically like so: public class Circuitry { private static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID); private static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); public static final RegistryObject<Block> IN_NODE = BLOCKS.register("in_node", InNodeBlock::new), OUT_NODE = BLOCKS.register("out_node", OutNodeBlock::new); static { ITEMS.register("in_node", () -> new BlockItem(IN_NODE.get(), new Properties().group(ItemGroup.REDSTONE))); ITEMS.register("out_node", () -> new BlockItem(OUT_NODE.get(), new Properties().group(ItemGroup.REDSTONE))); } public Circuitry() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(BLOCKS); bus.register(ITEMS); } } Even writing it identical to how the documentation does it doesn't help: public class Circuitry { private static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID); private static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); public static final RegistryObject<Block> IN_NODE_BLOCK = BLOCKS.register("in_node", InNodeBlock::new), OUT_NODE_BLOCK = BLOCKS.register("out_node", OutNodeBlock::new); public static final RegistryObject<Item> IN_NODE_ITEM = ITEMS.register("in_node", () -> new BlockItem(IN_NODE_BLOCK.get(), new Properties().group(ItemGroup.REDSTONE))), OUT_NODE_ITEM = ITEMS.register("out_node", () -> new BlockItem(OUT_NODE_BLOCK.get(), new Properties().group(ItemGroup.REDSTONE))); public Circuitry() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(BLOCKS); bus.register(ITEMS); } } -
Here is most of my mod class: public class Circuitry { public static final String MODID = "circuitry"; private static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID); public static final RegistryObject<Block> IN_NODE = BLOCKS.register("in_node", InNodeBlock::new), OUT_NODE = BLOCKS.register("out_node", OutNodeBlock::new); public Circuitry() { DeferredRegister<Item> items = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); BLOCKS.getEntries().forEach(block -> items.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Properties().group(ItemGroup.REDSTONE)))); IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.register(BLOCKS); bus.register(items); } } I have the Item DeferredRegister and RegistryObjects in the constructor rather than statically declaring it because I never need to retrieve the Item objects anywhere else in my code. However, upon loading a world, I am unable to find any of the added Blocks in the Redstone tab of the creative menu. The following commands don't work either: /give Dev circuitry:in_node /give Dev circuitry:out_node Declaring the Item DeferredRegister and RegistryObjects statically doesn't seem to fix the problem either. Printing the Item DeferredRegistry shows two entries with the correct names. No error messages are thrown and I can't determine why this is occurring.
-
Is there a preferred way to access a private class from Minecraft classes? I can use the regular Java Reflection to access it, but I don't believe that will work after it is obfuscated. For example, how can I access net.minecraft.client.gui.screen.FlatPresetsScreen.LayerItem given that it is not a public class?
-
I need the Apache HttpClient Mime Apache to create multipart forms. However, nothing I try seems to allow me to load the mod with this library. Even copying the source files into the mod source doesn't work; I keep getting NoClassDefFoundErrors. Is it even possible to, from a Maven dependency (org.apache.httpcomponents:httpmime:jar:4.3.2), create a fat jar, shade the library, or in any way embed it? The documentation for ForgeGradle is not in date anymore regarding this topic and the guides in the Grade Docs don't work for Forge.
-
In order to use multipart HTTP forms, I've had to import Apache HttpClient Mime. I've tried including it in my built jar like so: configurations { compile.extendsFrom(buildWith) } dependencies { minecraft 'net.minecraftforge:forge:1.15.2-31.2.0' buildWith 'org.apache.httpcomponents:httpmime:+' } jar.from { configurations.buildWith.collect { it.isDirectory() ? it : zipTree(it) } } This does add the files to the mod jar, but I still get errors when I try to use the library in game. It cannot find the class files that are being referenced. What am I missing here? How can I include external libraries in the mod or with the game?
-
Well, is there a way to get the cross-sections of the VoxelShape? Or, at the very least, some documentation on how VoxelShapes work?
-
I'm wondering what the most efficient way to calculate the volume of a block is. That is, if I have a BlockState in a World at a BlockPos, how can I most easily or efficiently calculate the volume? Do I have to just take the integral of the cross-sections of the VoxelShape? If that is the case, how do I get the cross-sections?
-
Actually, that's definitely cleaner than overriding FireBlock. I already catch the lightning when it is added, so that shouldn't be hard. Thanks.
-
Well, the problem is that I'm trying to prevent all lightning from spawning fire, including vanilla lightning.
-
So, for a mod that I am making, I've been trying to find the simplest and cleanest way to prevent fire from spawning where lightning bolts strike. I have a few solutions already that work, the simplest of which is that I register a custom FireBlock over the vanilla one. It has a boolean in it that is set to true when EntityConstructing is called with lightning and false when it enters the world. While this value is true, fire cannot be spawned. The reason why this is difficult is that the constructor for LightningBoltEntity actually spawns fire before it even enters the world. Basically, I can intercept the lightning object when it calls the Entity constructor at the start of its constructor and after it is finished constructing, by which it is already too late. Do any of you have suggestions for a better method of doing this? I'm concerned about compatibility issues that may arise from overriding FireBlock.
-
I'm currently looking for a way to remove the vanilla system of clearing lines of chat from memory when a certain amount are present. Basically, I'd like all chat messages to persist indefinitely for a given instance of the game. It's a little hard to decipher how vanilla does this as the source code for the chat GUI classes don't seem to currently be available. Edit: Actually, the NewChatGui class has its source code visible, so it shouldn't be too hard. My apologies for not searching harder first.
-
What exactly is the danger of doing the following: public static final Block MOD_BLOCK = new ModBlock(); @SubscribeEvent public static void onRegisterBlocks(Register<Block> event) { MOD_BLOCK.setRegistryName("mod_block"); event.getRegistry().register(MOD_BLOCK); } instead of: public static Block MOD_BLOCK; @SubscribeEvent public static void onRegisterBlocks(Register<Block> event) { MOD_BLOCK = new ModBlock(); MOD_BLOCK.setRegistryName("mod_block"); event.getRegistry().register(MOD_BLOCK); } The Forge documentation is somewhat unclear on this topic, mainly just implying that it causes issues when introducing DeferredRegisters.
-
I need to store a single number with a specific Block type. The number should be modifiable by the user, which I already have a method for, and persist between games. Each Block in the world should have the number independent from the other ones. I should be able to easily retrieve the number frequently. Lastly, I need to be able to iterate over all instances of the Block in the world. That part doesn't need to be included with the numbers, but it would be convenient. With that information, would it preferable to create an entire TileEntity for this Block type just for this single number, or would it be better to use the WorldSavedData system to store and retrieve it? I want to also consider compatibility with other mods that allow for copying of Blocks, like WorldEdit and MCEdit, as in the copied Blocks should have a number associated with them and should be part of the data structure that I can iterate over. Thank you.
-
What is the proper/most efficient way to time things in game? In a regular program, I would probably use Executors#newSingleThreadScheduledExecutor(), but is that a good idea in Forge? In the mod I'm working on, I want something to occur after a command is executed, every X seconds with X seconds of warning. Should I subscribe to WorldTickEvent or ServerTickEvent? Or should I use MinecraftServer#registerTickable(Runnable)?
-
Localization with Server Only Mods
Caffeinated Pinkie replied to Caffeinated Pinkie's topic in Modder Support
For example, PlayerList#sendMessage(ITextComponent). If you use a TranslationTextComponent, so that the message is lazily translated by clients, the message is also sent back to the server with this line: this.server.sendMessage(component); The server doesn't translate the message before displaying it in the server console in a dedicated server. In general, the dedicated server doesn't seem to be able to eagerly translate mod language keys even in English. -
Localization with Server Only Mods
Caffeinated Pinkie replied to Caffeinated Pinkie's topic in Modder Support
I'm sorry if this is already answered somewhere, but the wall I've hit at this point is that the dedicated server does not seem to be able to translate the keys. When I send a TranslationTextComponent to the MinecraftServer with the translation key or directly translate it in place using LanguageMap and then send it in a StringTextComponent to the MinecraftServer or players, it still just displays the translation key. The dedicated client is able to translate the key, however, if sent a TranslationTextComponent. Also, for the ChannelRegistrationChangeEvent, what is the proper way to register my mod so that it actually fires. Do I only have to register it on the client or the server too? I can't seem to find any documentation or guides on this topic. As a rule of thumb, should modders generally try to translate for modded clients without their particular mod? Or is it common practice to just use TextComponentHelper and leave it at that? -
Localization with Server Only Mods
Caffeinated Pinkie replied to Caffeinated Pinkie's topic in Modder Support
Alright, is there a way to check whether the client has a particular mod? TextComponentHelper works if the client is vanilla, but not if the client is modded and does not have the mod. -
Localization with Server Only Mods
Caffeinated Pinkie replied to Caffeinated Pinkie's topic in Modder Support
Alright. Is there a method to check if clients have the localization and send just a StringTextComponent instead? Never mind, the documentation describes this pretty well. Thank you for the help. -
I've just found an issue with Forge localization that I'm not sure is intentional or not. Basically, I have mod that is only required on the server-side, but has some commands and messages that are sent to players. Using TranslationTextComponents, the messages are translated to the appropriate locale if the client has the mod installed. However, if the client does not have the mod, the messages are untranslated and just the translation key is sent. For example, "commands.ahe.explosions.stopped" is sent instead of "Explosions stopped." This issue is also present in the server console, but I figured that's fine if the client translates it properly. Am I missing something or is there just no proper way to use localization to clients that don't have the proper mods?
-
Is it possible to have a Map in the current configuration system? I'm having issues doing so.
-
Common Config Doesn't Load
Caffeinated Pinkie replied to Caffeinated Pinkie's topic in Modder Support
Alright, that works. I was registering it in a static FMLCommonSetupEvent method that was registered with @EventBusSubscriber and @SubscribeEvent.