Everything posted by Choonster
-
[1.12 to 1.14] Make custom mobs spawn only at night (custom biome)
It looks like spawning conditions are handled by EntitySpawnPlacementRegistry in 1.14. You need to call EntitySpawnPlacementRegistry.register with your EntityType and a predicate that determines the conditions under which it can spawn. Zombies and other hostile mobs use MonsterEntity::func_223325_c for the predicate, this checks the difficulty and the light level.
-
[1.12.2] Only first fluid registered renders properly
I don't know exactly what your issue is, but I can point you to my 1.12.2 fluid code where I have several fluids with their own textures: initialisation and registration, model registration, blockstates file.
-
[1.14.4] IForgeItem#initCapabilities called before Capabilities are registered
It turns out that the constructor of the @Mod class is too early to call CapabilityManager#registerCapability as it uses the CapabilityManager#callbacks map, but this is only initialised between RegistryEvent.NewRegistry and RegistryEvent.Register being fired. Due to this, I kept the capability registration in FMLCommonSetupEvent and just added null protection to the IForgeItem#initCapabilities implementations. This fixed the crash. You can see the changes I made in this commit.
-
[1.14.4] IForgeItem#initCapabilities called before Capabilities are registered
Lex responded to the issue on GitHub and basically said to register the capabilities earlier and add null protection to the IForgeItem#createProvider implementation:
-
[1.14.4] get config in IConditionSerializer
ForgeConfigSpec implements UnmodifiableConfig, have you tried calling UnmodifiableConfig#getOrElse on your ForgeConfigSpec instance? Note that if you've followed Forge's example and made your ForgeConfigSpec fields private, you'll need to create a public method in your config class that calls UnmodifiableConfig#get(String) on the appropriate ForgeConfigSpec instance.
-
[1.14.4] IForgeItem#initCapabilities called before Capabilities are registered
I decided to report this on GitHub.
-
[1.14.4] PlayerInteractEvent.RightClickBlock event not firing
This is a known issue.
-
[1.14.4] IForgeItem#initCapabilities called before Capabilities are registered
Minecraft Version: 1.14.4 Forge Version: 28.0.19 Code: https://github.com/Choonster-Minecraft-Mods/TestMod3/tree/ba1306dd180514cc7dd135b21262f8eb72cdd305 Log: https://gist.github.com/Choonster/2ee4d06856ca409f85b89728e9ddd47e After updating to 1.14.4 and attempting to run the client (the first time since updating to 1.14), I encountered a crash due to LastUseTimeModelItem#initCapabilities being called when LastUseTimeCapability.LAST_USE_TIME_CAPABILITY was still null. It appears that an ItemStack of this Item is being created in Minecraft#populateSearchTreeManager, which is called towards the end of Minecraft#init. ClientModLoader.begin is called earlier in Minecraft#init to start loading mods, but this doesn't actually fire FMLCommonSetupEvent (the event that Capabilities are registered in) directly; instead it registers a resource reload listener that fires the event (and the other setup events). The initial reload that calls this listener doesn't happen until the very end of Minecraft#init (after Minecraft#populateSearchTreeManager). It feels counter-intuitive that IForgeItem#initCapabilities can be called before Capabilities have actually been registered, but is this a bug or is it intended behaviour?
-
Using custom biomes for advancements requiring a 'location' trigger
You need to use the registry name of the Biome, not the numeric ID or the display name. This will be whatever you name you've specified in the setRegistryName call for the Biome.
-
[1.14.4] Adding villager trades
It looks like the possible trades for each level of each profession are stored in VillagerTrades.field_221239_a (may have a deobfuscated name in newer mappings). The trades for each level are stored in an array, so you can probably create a new array with the both existing trades and your new trades and then replace the existing array in the profession's Int2ObjectMap.
-
[1.14.2] Forge tag errors
This was fixed by this pull request for 1.14.3. Update to the latest 1.14.3 version of Forge.
-
[1.12.2] Getting and setting the direction of any block with a PropertyDirection
I suggest looking at how Block#rotateBlock finds the property to change and doing something similar.
-
1.12.2 how to add multiple recipes for 1 item?
Recipes don't have to have the same name as their output item, you can call your recipes whatever you want.
-
how to play a sound when right clicking in 1.12
All of the sound-playing methods in the documentation are methods of the class mentioned in the header. e.g. The first three are methods of World, which means you need to call them on an instance of World.
-
[1.13.2] [Solved] Config Array with Range?
You could probably use ForgeConfigSpec.Builder#define(String, T, Predicate<Object>) with a Predicate that checks if every integer in the array is within the appropriate range. The only downside I can see is that Forge will correct single number properties outside the defined range to the minimum or maximum of the range; but if any number in your array is outside the defined range, Forge will correct the entire property to the default array value.
-
[1.14.3] Reusing data values within recipes
Metadata doesn't exist in 1.13+. To copy damage (or any other value) from an ingredient to the output, you'll need a custom recipe type that overrides IRecipe#getCraftingResult. You can see an example of this here, with a JSON recipe that uses it here.
-
1.13.2 Custom record Sound is null.
I ended up initialising my SoundEvents in a method called from RegistryEvent.Register<Item> and storing them in a temporary Map until they're registered in RegistryEvent.Register<SoundEvent>. You can see this here.
-
[1.13] Config getting reset due to it being set to a different value than default?
The parameters of that overload of defineInRange are (path, defaultValue, min, max). You're passing 1.0 as the default value and -3.0 as both the minimum and maximum values.
-
Creating a json recipe for spawn eggs.
1.13 flattened spawn eggs into a separate item for each entity type instead of being a single item with the entity type in the NBT. See the wiki for the new item registry names.
-
[1.13.2] Compilation error mismatch between IDEA and javac
In TestMod3, I have a series of packets for updating item capability data in Containers. Because they all operate in similar ways, they all extend a generic base class and their static encode/decode/handle methods all call corresponding generic static methods in the base class. I've run into a strange issue with the decode methods where IDEA can infer the type arguments and doesn't want me to explicitly specify them, but the compiler can't infer the type arguments and generates a compilation error. You can see an example of a decode method without explicit type arguments here, which generates this compilation error: TestMod3_1.13.2\src\main\java\choonster\testmod3\network\capability\fluidhandler\MessageBulkUpdateContainerFluidTanks.java:49: error: incompatible types: cannot infer type-variable(s) HANDLER,DATA,MESSAGE return MessageBulkUpdateContainerCapability.decode( ^ (argument mismatch; cannot infer functional interface descriptor for MessageFactory<HANDLER,FluidTankInfo,MESSAGE>) where HANDLER,DATA,MESSAGE are type-variables: HANDLER extends Object declared in method <HANDLER,DATA,MESSAGE>decode(PacketBuffer,CapabilityDataDecoder<DATA>,MessageFactory<HANDLER,DATA,MESSAGE>) DATA extends Object declared in method <HANDLER,DATA,MESSAGE>decode(PacketBuffer,CapabilityDataDecoder<DATA>,MessageFactory<HANDLER,DATA,MESSAGE>) MESSAGE extends MessageBulkUpdateContainerCapability<HANDLER,DATA> declared in method <HANDLER,DATA,MESSAGE>decode(PacketBuffer,CapabilityDataDecoder<DATA>,MessageFactory<HANDLER,DATA,MESSAGE>) However, adding the explicit type arguments (like this) causes IDEA to recommend removing them, as shown in this screenshot: Does anyone know what would cause this mismatch, or if there's a way to avoid the explicit type arguments here?
-
[1.13.2] EntityEntry missing?
They've been replaced by the Vanilla EntityType class and its builder.
-
[1.13.2] Custom EnumCreatureType
The implementation of the create method is generated at runtime for enums that implement IExtensibleEnum. See the doc comment on IExtensibleEnum for more information.
-
[1.13.2] Best Way to send message to all players?
If you mean a network message (SimpleNetworkWrapper/SimpleChannel), use PacketDistributor.ALL and PacketDistributor#noArg to get the PacketTarget argument for SimpleChannel#send. PacketDistributor.ALL sends the packet to all players on the server.
-
[1.13.2] Item capabilities - LazyOptional?
I have a system to sync ItemStack capabilities here and here, the packet classes can be found here. You can see the implementation for IPigSpawner (IPigSpawnerFinite) here and the corresponding packets here.
-
[1.13.2] Item capabilities - LazyOptional?
Generally you should use LazyOptional#ifPresent to run a function (usually a lambda expression) if the value is present. The function receives the interface instance as an argument. If you need the interface instance itself, you can use LazyOptional#orElse or LazyOptional#orElseGet.
IPS spam blocked by CleanTalk.