Jump to content

Aarilight

Members
  • Posts

    86
  • Joined

  • Last visited

Everything posted by Aarilight

  1. BiomeDictionary.Type.byName is private, BiomeDictionary.Type.getType has a side effect of creating a new Type if it doesn't already exist. My goal is to iterate through the registered types, because I'm serializing/deserializing which to use by name. Is there another way for me to do this? Should I cheat and use reflection? It shouldn't matter to this post, but here's an example of what I'm deserializing (the serializer already works, and deserializing works except for the biome type list): { "block": "souls:fossil_frozen", "replace": "minecraft:dirt", "biome_types": ["frozen"], "chances": 300, "size": { "min": 3.0, "max": 7.0 }, "height": { "min": 0.0, "max": 255.0 } }
  2. Is upgrading your version not an option? I'm on 14.22.0.2462, that's the version I wrote my snippet in.
  3. You put the code from a test into your code? He posted that test to demonstrate how BlockPlaceEvent works. This code won't do anything for you as is. In the handler which started this entire problem, did you try using RightClickBlock instead of PlaceEvent? I went ahead and just tested in game, and yes, PlaceEvent only seems to occur on the server. RightClickBlock can be cancelled based on the ItemStack in your hand, though. Here is working code that only cancels Podzol: @SubscribeEvent public static void onBlockPlace(RightClickBlock event) { ItemStack block = event.getEntityPlayer().getHeldItemMainhand(); if (ItemStack.areItemStacksEqual(block, new ItemStack(Blocks.DIRT, block.getCount(), 2))) { event.setCanceled(true); } } To cancel based on a list of blocked blocks, the easiest way would be to store them as ItemStacks, since that supports holding both the block type and the metadata, and just loop through the list in this event handler. To check equality, make sure the count of the stack you're checking is the same as the held stack count. WILDCARD_VALUE does not work for count. If one of them matches, cancel the event.
  4. You don't need that, you already know your handler is only being called on the server, so it will only reach the top half anyway. Honestly the @SideOnly question was my only idea of what could be wrong, it prevents stuff from being called altogether by removing them from the code on the other side. If you're not using it then it's not your problem. I have no other ideas, so you'll have to wait until someone more knowledgeable responds. Sorry >.>
  5. Your handler is only running on the server, not the client, you can tell because the block was never placed, your client just thought it was. To solve this we might need more context than this. Are you using any @SideOnlys?
  6. I've overridden hasComparatorInputOverride and getComparatorInputOverride, and it seems to work fine--whenever I update the comparator (such as placing a block next to it) it gives the correct signal. However, the tile entity changes its signal strength over time, and I need this to reflect on the comparator. I tried sending a block update, but it didn't do anything. My current code for triggering block updates is as follows: IBlockState blockState = world.getBlockState(pos); world.notifyBlockUpdate(pos, blockState, blockState, 7); world.notifyNeighborsOfStateChange(pos, blockType, true); I had originally thought that triggering a block update would update all adjacent tiles, but I realised that I was probably wrong, and so I tried updateObservingBlocks. That didn't work either, then I stumbled upon notifyNeighborsOfStateChange. It works for adjacent comparators, but not comparators that get the signal through a solid block. Do I have to run this notifyNeighborsOfStateChange on all adjacent blocks to get the comparator to update, or am I missing a convenience method that does all this for me? EDIT: Wow, I feel dumb. World#updateComparatorOutputLevel does exactly what I need. Maybe this thread will help someone at some point at least >.>
  7. I didn't neglect to register the item on purpose >.> It was just a bug--I have two different superclasses for Blocks and BlockPanes and I had forgotten to register the BlockPanes on my Register<Block> event. ....When I get a chance I think I'll make an interface for these so that having separate superclasses isn't an issue I have to worry about anymore.
  8. I figured out the reason this was crashing, my recipe output item was never registered. The json recipe system warned about it on parsing. I guess it's kinda pointless to add in checks for that since it's heavily encouraged to use json recipes now. (not related, but grats on 10k draco!)
  9. I'm only using a simple recipe for testing, the recipes I'm actually using code for are much more complicated, things I don't expect I'll be able to do with the json format. I'll take a look when I get to converting the recipes to json, I just haven't gotten that far yet because of misc other conversion bugs. I guess it's about time I use an IDE that supports debugging java...... it'll probably help me solve issues like this way easier >.> (I use VSCode for web-dev, just didn't want to spend the time configuring IDEA again--lost all my settings on a crash last time) Anyway, thanks for the help. I'll keep forging ahead.
  10. Ah yea I should have simplified it for this post. The reason I was doing it like that is a mixture of old code and trying to figure out exactly what the problem is. You said my items are invalid, what's invalid about them? If I don't register this recipe the items seem to work fine, including in shapeless recipes.
  11. @SubscribeEvent public static void registerRecipes(RegistryEvent.Register<IRecipe> event) { Souls.logger.info("register recipes"); ItemStack recipeOutput = new ItemStack(ModObjects.ENDERSTEEL_BARS.getItemBlock(), 16); GameRegistry.addShapedRecipe(new ResourceLocation(Souls.MODID, "endersteel_bars.recipe"), null, recipeOutput, new String[] { "EEE", "EEE" }, 'E', ModObjects.ENDERSTEEL.getItem()); } This code doesn't crash when it's called, but it completely freezes the game on loading a world. Here's the log: [16:21:10] [Server thread/FATAL] [FML]: Fatal errors were detected during the transition from AVAILABLE to SERVER_ABOUT_TO_START. Loading cannot continue [16:21:10] [Server thread/FATAL] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:------- |:--------- |:------------------ |:-------------------------------- |:--------- | | UCHIJAA | minecraft | 1.12.1 | minecraft.jar | None | | UCHIJAA | mcp | 9.19 | minecraft.jar | None | | UCHIJAA | FML | 8.0.99.99 | forgeSrc-1.12.1-14.22.0.2462.jar | None | | UCHIJAE | forge | 14.22.0.2462 | forgeSrc-1.12.1-14.22.0.2462.jar | None | | UCHIJAA | souls | 1.12.1-5.1-87ac678 | Souls-1.12.1-5.1-87ac678.jar | None | [16:21:10] [Server thread/FATAL] [FML]: The following problems were captured during this phase [16:21:10] [Server thread/ERROR] [FML]: Caught exception from forge (java.lang.NullPointerException) [16:21:10] [Server thread/ERROR] [FML]: A fatal exception occurred during the server about to start event net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Minecraft Forge (forge) Caused by: java.lang.NullPointerException at net.minecraft.client.util.SearchTree.lambda$index$0(SearchTree.java:91) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at java.util.ArrayList.forEach(ArrayList.java:1249) ~[?:1.8.0_131-1-redhat] at net.minecraft.client.util.SearchTree.index(SearchTree.java:89) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraft.client.util.SearchTree.add(SearchTree.java:78) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at java.util.ArrayList.forEach(ArrayList.java:1249) ~[?:1.8.0_131-1-redhat] at net.minecraft.client.Minecraft.populateSearchTreeManager(Minecraft.java:648) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraftforge.fml.client.FMLClientHandler.reloadSearchTrees(FMLClientHandler.java:1107) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraftforge.fml.common.FMLCommonHandler.reloadSearchTrees(FMLCommonHandler.java:771) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraftforge.common.ForgeModContainer.mappingChanged(ForgeModContainer.java:535) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131-1-redhat] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131-1-redhat] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131-1-redhat] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131-1-redhat] at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?] at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?] at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?] at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:253) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:231) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraftforge.fml.common.Loader.fireRemapEvent(Loader.java:962) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraftforge.registries.GameData.freezeData(GameData.java:233) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:790) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:343) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraft.client.Minecraft.init(Minecraft.java:576) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraft.client.Minecraft.run(Minecraft.java:416) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at net.minecraft.client.main.Main.main(Main.java:118) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131-1-redhat] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131-1-redhat] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131-1-redhat] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131-1-redhat] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) ~[launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131-1-redhat] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131-1-redhat] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131-1-redhat] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131-1-redhat] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) ~[GradleStartCommon.class:?] at GradleStart.main(GradleStart.java:26) ~[GradleStart.class:?] [16:21:10] [Server thread/INFO]: Stopping server [16:21:10] [Server thread/INFO]: Saving players [16:21:10] [Server thread/INFO]: Saving worlds [16:21:10] [Server thread/INFO] [FML]: Applying holder lookups [16:21:10] [Server thread/INFO] [FML]: Holder lookups applied [16:21:10] [Server thread/INFO] [FML]: The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED. Errors may have been discarded. [16:21:10] [Server thread/INFO] [FML]: The state engine was in incorrect state ERRORED and forced into state AVAILABLE. Errors may have been discarded. This freeze happens regardless of whether I register the recipe with GameRegistry.addShapedRecipe orForgeRegistries.RECIPES.register(new ShapedOreRecipe) What am I doing wrong?
  12. Not sure if I misunderstood your answer for 5), but by replacing the minecraft:bone_meal_from_bone recipe, my new, replaced recipe unlocked when I had bones in my inventory (via original advancement). So the only real issue with replacing recipes is that it logs warnings about them having the minecraft: prefix even though it's intentional. Besides this warning everything works as I intended. I would need a new advancement to unlock it if the recipe was changing, but the recipe is the same, it's just the output that's different now. I guess I should have mentioned that.
  13. Ah well, thanks anyway. I added in a info log beforehand that says it's intentional. Do you have any advice on my other questions, by any chance? It's ok if you don't =)
  14. Fixed the last issue, I had assumed that Attempted to set registry name with existing registry name meant I couldn't set two items to the same registry name, but it actually means that the item already has a registry name, and it can't be changed. I don't have an answer for my other four questions yet tho. I updated the initial post marking this last question as solved. However, setting the registryName to replace a vanilla registryName causes this warning: Dangerous alternative prefix `minecraft` for name `bone_meal_from_bone`, expected `souls` invalid registry invocation/invalid name? Is there a way to suppress this warning?
  15. I have five questions: From what I've gathered, unlocking recipes (to add them to the recipe book) occurs from advancements that trigger when you have the items. Can I use them to unlock recipes that I've added via registering in the code? Are all recipes by default locked? If I'm adding all of the recipes from ForgeRegistries.RECIPES.register, and therefore have a reference to the recipes and their ResourceLocation, is there a way I unlock all of them by default? To get a recipe to appear in a specific tab of the recipe book, I read that you have to have them in the matching creative tab. Since my items all appear in a custom creative tab, does that mean they will only show in the compass (search/all) tab? I plan to convert most of my recipes to JSON, but there are a few complicated recipes that take any number of certain items and set NBT data on the resulting items. What's the best practice on recipes like this? Do they even work with the recipe book? [Solved] How can I replace vanilla recipes? In another topic, this was posted: But doing what it says, when setRegistryName is called, I get an error java.lang.IllegalStateException: Attempted to set registry name with existing registry name! New: minecraft:bone_meal_from_bone What am I doing wrong here?
  16. I'm back in modding! Unfortunately, like usual I want to use the latest version. I'm in the process of converting my mod's code from 1.10.2 to 1.12.1. In my old code I used the name of entities to get their colours in the EntityList.ENTITY_EGGS list. Simple example of one of the things I was doing: EntityList.ENTITY_EGGS.get(entityName) Now, the list seems to have been changed to be a ResourceLocation map, so to get a key in it, I assume I need the ResourceLocation of the entity. Is there a way for me to get it? I assume I can't just construct a new ResourceLocation because it would be a different instance of ResourceLocation.
  17. My custom mob spawner (now rewritten to not extend vanilla mob spawners in any way) is spawning mobs. However, the data I set to the mobs (via ForgeData), when they're spawned via the server, is not synced with the client. Here's the log I'm generating when mobs spawn: [02:09:43] [Server thread/INFO] [STDOUT]: [com.kallgirl.souls.common.block.Summoner.SummonerLogic:updateSpawner:139]: set entity data [02:09:43] [Server thread/INFO] [STDOUT]: [com.kallgirl.souls.common.NoMobSpawning:onMobJoinWorld:27]: successful spawn: Pig [02:09:43] [Client thread/INFO] [STDOUT]: [com.kallgirl.souls.common.NoMobSpawning:onMobJoinWorld:30]: mob had no data: Pig How can I ensure that the custom data I set on the entity, when spawning it, is also set on the client entity that is spawned? By printing the stack trace I was able to find where the entity enters the client, but it seems like the code (NetHandlerPlayClient:961) doesn't have support for forge's ForgeData. Is this a bug, an oversight, or am I doing something wrong/missing a step?
  18. But then I can reference it like Summoner.TileEntity! Idk, I guess I'm just not used to Java naming conventions. I'd assume you'd recommend something more like TileEntitySummoner? I think I understand with the static vs instance inner class. Because the class's hidden constructor requires an instance of Summoner, registering the mapping for it does nothing, because it can't be constructed anyway? Or am I misunderstanding why it's important to make it static?
  19. My question from earlier wasn't specific enough to get attention, so here's a bit of an update. I've found out that the mobs are spawned separately server/client side, and the client one, I think, updates from the server. The problem from before is that the custom data I was setting on mobs I spawned, to allow them to pass through my no-mob-spawning catcher, isn't being passed onto the client. These are the lines where I set the custom data to the entity. The server spawns the entity correctly, but the client doesn't have that data set when it spawns it. How can I ensure that the custom data I set on the entity, when spawning it, is also set on the client entity that is spawned? By printing the stack trace I was able to find where the entity enters the client, but it seems like the code (NetHandlerPlayClient:961) doesn't have support for forge's ForgeData. Is this a bug, an oversight, or am I doing something wrong?
  20. There were too many complex things I needed to do with mob spawners to be able to use the vanilla versions anymore. I've implemented wrapper classes for BlockMobSpawner, TileEntityMobSpawner, and MobSpawnerBaseLogic. It seems to work the same, except I'm having a few issues that I can't seem to figure out how to solve. Current issues: 1. The mobs spawned are INVISIBLE. Yet they still persist after reloading. I don't even understand how something like this can even happen. 2. Spawners created with my mod work until you reload the world, and then they render the wrong entity and sometimes also spawn the wrong entity. I guess both the old and new spawning methods are being called, somehow? I can't figure out how, tho. 3. They have no name and no mod listing (checked via WAILA), even tho I'm pretty sure I'm running the same code I run to add my other blocks to the mod. Is it because it's a BlockContainer? Do I have to do something special for it? Here's the github for my mod, if you're willing to help me debug. The responsible files should be /src/main/java/com/kallgirl/souls/common/block/Summoner/* If you want to actually build & test it, you can make my mod's spawners by giving yourself a soulbook souls:soulbook, a bone chunk souls:boneChunk, right clicking with the bone chunk (should give you essence of a vanilla overworld mob). In a crafting window, combine your soulbook and that essence (if you're in creative mode, use pick block to duplicate a whole stack of it). If you're in a crafting table it's easier, you need 16 essence to fill the soulbook. Once the soulbook is filled, place a souls:emptySummoner in the world, and then right click on it with the soulbook you filled. It should create a mob spawner with the mob type you filled the soulbook with. If you decide to help, thanks so much. I've been banging my head into a wall for the past day trying to figure this one out haha
  21. So what I'm thinking now is cancel all PotentialSpawns, then cancel any EntityJoinWorldEvents which are EntityLivings that don't have NBT data saying that they were spawned by my mob spawners. Unfortunately, I don't think there's a way for me to set custom NBT data on an entity with a vanilla mob spawner, so I'll have to make a wrapper class for my mob spawners now as well. Oh well. I figured it'd happen eventually. =P If I find time I'll file a request for those events, but altho they'll make things easier for me I'm not really sure they're worth the effort. I'm the first person trying to prevent spawns in generated structures, as far as I can tell by googling. Thanks a bunch for your very informative post, btw!
  22. Except entities spawned by mob spawners, my goal is to prevent all entity spawning. Hostile mobs, passive mobs, mobs spawned w/ structure generation, etc. I've already seen the EntityJoinWorldEvent, and it seems mostly useless for the complexity of what I need to do. Using the following code, I was able to disable most spawns (I think?): for (BiomeDictionary.Type type : BiomeDictionary.Type.values()) { Biome[] biomes = BiomeDictionary.getBiomesForType(type); for (Biome biome : biomes) { for (EnumCreatureType creatureType : EnumCreatureType.values()) { List<Biome.SpawnListEntry> spawnableList = biome.getSpawnableList(creatureType); spawnableList.clear(); } } } It doesn't seem to catch everything, however. And since it doesn't prevent structure generation spawns, I need to find a workaround for that as well. Any ideas/suggestions?
  23. Do you have a /build folder? My resources are put there on build You'd be looking for /build/resources/main/assets/neurocameramod/textures/blocks/test.png
  24. HarvestDropsEvent doesn't seem to have support for adding/removing XP drops. Is there a way I can remove the XP drops from breaking a mob spawner?
  25. In case anyone is ever trying to change the drops of a mob spawner based on the type it is, in the future, and found this old post, and got sad, there is a way! You must subscribe to both BreakEvent and HarvestDropsEvent. In BreakEvent, when it's a Blocks.MOB_SPAWNER, set a static field to the TileEntityMobSpawner. In the HarvestDropsEvent, when the same condition is met, use the TileEntityMobSpawner you saved.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.