-
Posts
62 -
Joined
-
Last visited
Everything posted by Keheck
-
And if I want to also have a breath mechanic, so that oxygenized air becomes my deoxygenized one whenever something happens?
-
At first I wanted to solve it with a TileEntity, but that would probably make Minecraft shit itself from vast amount of TileEntities in each chunk, so I'm thinking about some kind of "binary" blockstate that just says "here be oxygen" or "here be no oxygen", and depending on wheter you're in oxygenized air you either stay alive or slowly suffocate (like drowning in water). I can try to adjust for realism later, but just as a proof of concept
-
I already know how I override other vanilla blocks (same registry name as the block to replace and then register the block on my mod's turn). But it doesn't work the same way for the air block, since it is a default value for the block registry, which can't be overridden once registered. Why do I want to do that? Because I want to build a mod that adds a Oxygen mechanic to the air block. Is there some other workaround that is friendly for intermediate modders?
-
I am currently experimenting with capabilities and don't know if getting my capability this way: // PARTY_CAP is my Capability<T> object. player.getCapability(PartyProvider.PARTY_CAP).orElse(PartyProvider.PARTY_CAP.getDefaultInstance()); is correct, or if it's not intended to be get that way.
-
1.14.4 What does the discriminator byte do in PacketBuffers?
Keheck replied to Keheck's topic in Modder Support
When would it be better to use that instead of a SimpleChannel? Like, what are some example cases you could name? -
1.14.4 What does the discriminator byte do in PacketBuffers?
Keheck replied to Keheck's topic in Modder Support
So if I understood correctly, the first byte of a packet payload is always(?) the id of the message in the specific channel. It is to correctly identify the message that the payload needs to be decoded into, since there is no (more efficient) way to store the message type itself into the payload, correct? -
1.14.4 What does the discriminator byte do in PacketBuffers?
Keheck posted a topic in Modder Support
I am currently setting up some networking to synchronize data between Clients and Servers, and I've been running into a problem where I got an invalid discriminator byte on my channel. I've fixed that by "shifting" the data written to the PacketBuffer in my encoding method by one byte. To know what exactly what I'm talking about, you can take a look at this and that class, they contain the important stuff (Mod's main class and the Message class, respectively). The packet is sent off here . (An Item class' onItemRightClick method) Or you can open the spoiler: It seems like the discriminator is somehow tied to the id of the Message registered on the channel but I would like some confirmation/correction on that theory. What is the discriminator actually used for? -
I am currently trying to make my mod server compatible, and Forge conveniently sets up with a "runServer" and "runClient" configuration. However, it seems like I'm not able to join the server created by "runServer" with the client from "runClient". I'm assuming it's because the "runClient" client is not a valid Minecraft account, since using my normal one works just fine. It would be nice if it was possible to let the "runClient" client join the server, since I only have one valid Minecraft account atm. Does that work somehow? Edit: The type of error I get is Failed to log in: Invalid session (Try restarting your game and the launcher). Neither restarting the game nor the IDE (just to be sure) helped. When looking at the Console output of the server I get the following message: [Server thread/INFO] [minecraft/ServerLoginNetHandler]: com.mojang.authlib.GameProfile@4c3f1902[id=<null>,name=Dev,properties={},legacy=false] (/127.0.0.1:52506) lost connection: Disconnected, while joining via my legal Account gives me [User Authenticator #1/INFO] [minecraft/ServerLoginNetHandler]: UUID of player Keheck is 65831990-3d68-4646-95c9-2b75429faf43
-
I was looking for uses of that distribution side, but no class uses that annotation together with this distribution side... (aside from net.minecraftforge.fml.common.Mod.EventBusSubscriber) The javadoc in net.minecraftforge.api.distmarker.Dist class says the following: But that didn't help clarify on what should only be processed on the Dedicated Server side, and does that distribution side also exist on singleplayer worlds? I know that Dist.CLIENT is used for stuff like rendering, but when is it appropriate to use Dist.DEDICATED_SERVER?
-
I want for my mod to have a gui that can display blocks in a way that it looks like a platform like the one in the image below (the actual appearance may vary though). For that I wrap the blocks to render into an ItemStack and have the ItemRenderer render that stack. Now it seems that Minecraft switches into an orthographic view when rendering GUIs, which makes sense of course, but I'd rather like to have a "correct" perspective onto the gui. Is there a way I can render my GUI not orthographic?
-
First of, in analogy to how the registration of Entities are handled, I have two classes: the class io.github.keheck.mobfighters.registry.entries.FighterEntry, which is the equivalent of the EntityEntry class: it is a "pattern" class for individual instanced of a Fighter. Then there is the io.github.keheck.mobfighters.fight.fighters.Fighter class, which is the equivalent of Entity class: It is created via a method inside FighterEntry. The constructor of FighterEntry looks like this: public FighterEntry(IFighterFactory factory, EntityType<? extends LivingEntity> entityType) { this.factory = factory; this.entityType = entityType; //also, read your fighter-data here. } IFighterFactory: This is a functional interface. It is used to create an instance of a new fighter whenever it is needed. EntityType<...>: This is used so that when a fight is currently going, my mod has information on what the fighter should look like (I want to do a 3D rendered GUI, but that can wait). Why restrict it to instances of LivingEntity? Because only living entities can do stuff, and it made the most sense to me... As for the registry name of the FighterEntry class: I annotated the setRegistryName(ResourceLocation) with @Deprecated, because the getRegistryName method returns the registry name of it's EntityEntry (see constructor). Now to what I am trying to say: I have, in my FighterEntry class, three other fields: two arrays of io.github.keheck.mobfighters.fight.moves.Move instances and one of io.github.keheck.mobfighters.fight.traits.Trait instances. In the constructor (of the FighterEntry class) I want to read a .json file at a specific location, using the registry name of the entityType field. That way, when a FighterEntry gets added to the registry, it automatically retrieves it's information on what moves it can learn and perform. Why do I want to do it that way? two reasons: I want the arrays to be as immutable from the outside as possible. The first step to do that is to make them private (which they are). The second is to make them not change inside any method of the FighterEntry class. By their nature Moves are very numerous, and Fighters can learn a big number of them (at least, that's what I'm trying to achieve). I don't want modders to waste their time by adding instances of each and every Move they want to add to thier own fighter. Besides that, the code could get *really* long if they add a number of Fighters. If you want to read the code in it's entierety, here's the github repo.
-
I want to read the data of a FighterEntry while it's being initialized (so during a registry event, in it's constructor), so I can encapsulate the data with no way (except with reflection maybe) to change that data from the outside. I now realize that I don't really need a list of mod domains, since I can just read it's registry name and get the path from there (although maybe I could use the knowledge of getting that list in another I might make) Is there a way to override this property? I only want to use the data/asset system because of this:
-
Yea yea I already know that, the problem is though that I want to read the data during the mod's setup. Unless I can still use the ReloadListener system?
-
I want to get a list of mod domains so I can read asset data from them. Perferably during mod setup. I explained in this post why exactly I want to load asset data.
-
Is there a way to recieve a list of mod domains from Forge during mod setup?
-
I'm afraid this won't work for me... I want the data for the Fighter during mod setup, specifically during the registraion of the Fighters. Here's how I invisioned it (this will all happen inside a registry handler for the Fighter Registry with lowest event priority, so it is (likely) the last one to get called): Get a list of all the registered fighters. Loop the following for every entry (and account for errors): Get the registry name of the entry Is the domain empty or does it equal "minecraft"? Yes: Look into "./data/mobfighters/" ("mobfighters" is the modid of my mod) No: Look into "./data/<domain>"/ Search in the data directory for "./fighter/<path>" Read the .json Pass the read data onto the entry. Does the way I want to do it even make sense, or is it safe to do that? If you want to look at my code, I have a repo here. (The important classes are io.github.keheck.mobfighters.registry.entries.FighterEntry and io.github.keheck.mobfighters.registry.Registry)
-
Is there a way to load files in the ./assets/ and ./data/ directory of any mod, including your own? I'd imagine it to work with resource locations, but skimming over the usages of net.minecraft.util.ResourceLocation and net.minecraftforge.registries.ForgeRegistryEntry#getRegistryName didn't help me much. If you're wondering why I want to load files: I'm working on a Pokemon-style mod, except it uses mobs from Minecraft and other mods, and I want other mods to be able to add thier own mobs (or "Fighters" as I call them) to my mod that you can then capture and fight with. And since adding such a Fighter would also mean adding moves it can learn, i want other modders to be able to write it in a .json file where they just list the registry names of the moves and my mod picks out the correct moves, so the actual code of the mod stays rather short and isn't littered with chained methods of adding moves. Edit: I want to load the asset data during mod setup.
-
In the minecraft class the doc-comment for net.minecraft.client.Minecraft#displayGuiScreen(Screen) reads: Problem is, there is no method in that class named "addScheduledClass" in my Forge version, and there is also no method that would take a Runnable/Thread object (which I imagine the method to do).
-
[1.14.4] Entity in ServerWorld but not in ClientWorld
Keheck replied to Keheck's topic in Modder Support
Yes, that was it! Thank you, now I can go and run into new problems as I move on -
[1.14.4] Entity in ServerWorld but not in ClientWorld
Keheck replied to Keheck's topic in Modder Support
What? -
[1.14.4] Entity in ServerWorld but not in ClientWorld
Keheck replied to Keheck's topic in Modder Support
Note: Idk why the hidden contents are so long... -
I have this problem where (as far as I could deduct from debugging) a entity from my mod gets summoned into the server world, but the client world didn't recieve that entity. The symptom of that problem is that the entity can't get rendered . My entity is a simple descendant (class name: io.github.keheck.mobfighters.entity.MobBall) of the net.minecraft.entity.ProjectileItemEntity class that only implements the onImpact(net.minecraft.util.math.RayTraceResult) method like this: @Override @SuppressWarnings("NullableProblems") protected void onImpact(RayTraceResult result) { if(!world.isRemote()) this.remove(); } The other methods overriden are the remove() method, which only loggs the death and then removes the entity as normal, and two methods that return an Item and ItemStack respectively, so not really, if at all, connected to my problem. I did some more digging while writing this, and it seems like the root of the problem lies in the method "net.minecraft.client.network.play.ClientPlayNetHandler#handleSpawnObject(net.minecraft.network.play.server.SSpawnObjectPacket)" Here it is: As one might notice, this method compares the EntityType in the recieved packet with every vanilla EntityType, and if it finds a match, an Entity instance is created by using a constructor of the according class. But since the EntityType of my mob is not equal to any of the listed EntityTypes in that method, it gets assigned to null and because of that doesn't get added to the ClientWorld (see bottom of the method). This is how I register my entity and the renderer, respectively: If you want to explore my project yourself, I have a repository on github (it needs to be setup though, see README.md). The latest log can be found here. The question that arises now: How can I [make Minecraft] add the entity to the ClientWorld instance as well? (if the problem is that simple to solve...)
-
While I was working on my mod my IDE complained that "All entities must have a constructor that takes one net.minecraft.world.World constructor" //A constructor like this: public Entity(net.minecraft.world.World world) { //do stuff } I was wondering why, especially because the mod builds and the entity registers just fine without this constructor. I dug around in my code inspection settings and it turns out that it belongs to the MCP inspection group. Using a breakpoint to find it's usage didn't help since at no point during mod setup and testing (testing as in summoning the entity via the /summon command; the entity is a throwable and would use another constructor when thrown anyway). When is this constructor used, if at all, and is that constructor important?