Jump to content

SanAndreaP

Forge Modder
  • Posts

    1689
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by SanAndreaP

  1. There is another method with additional parameters: setBlock(x, y, z, block, meta, flag) you can use 0 as meta as there're no subtypes of the air block flag determines how the method should behave: 1 - cause block update 2 - changes get sent to client 4 - prevents re-rendering The methods w/o the flag parameter always use 3 as a flag (which means 1 | 2 or "cause block update" and "changes get sent to client") Try to use 2 as the flag, like: setBlock(x, y, z, Blocks.air, 0, 2) and see if it still crashes or use the DecorateBiomeEvent.Post event to delete all blocks, since I've seen it's related to the BiomeDecorator or the Decorate event and check if it should decorate (it shouldn't if the chunk is "empty"). For the latter: set the result to DENY if it shouldn't generate at all (also don't check for the EventType here)
  2. Minimap on your HUD -> Zan's Minimap (now called VoxelMap): http://www.planetminecraft.com/mod/zans-minimap/
  3. Assuming maxXP is a float/double. If it isn't, you do an integer division and thus only return 0 until currentXP (which can be an integer) reaches maxXP.
  4. Replace super.doRender with super.doRenderLiving in your renderHunch method. Also I suggest you add @Override above the methods you intend to override for debugging purposes.
  5. Define a new List where you store/cache all possible items: private List<Item> filteredItems = null; In your onItemUse method, do this: - If the list is uninitialized, initialize it and fill the array with all items: if( filteredItems == null ) { filteredItems = new ArrayList<Item>(); Iterators.addAll(filteredItems, Iterators.filter(Iterators.forArray(Item.itemsList), Predicates.notNull())); } The last statement in the block is basically, it filters the itemsList array by throwing out any null value which are in there (basically all unassigned/free items) and adds them to your filteredItems list. - After that, get a random element from your filteredItems list and make a new ItemStack out of that element: ItemStack stack = null; if( items.size() > 0 ) { stack = new ItemStack(items.get(par2EntityPlayer.getRNG().nextInt(items.size())), 1); } The only problem I see is that some items have multiple metadata values as subtypes (dyes and potions are the most prominent example) and you'll get only the first item subtype
  6. Block initializations / registrations (as well as items) go into the preInit (FMLPreInitializationEvent)
  7. firstly I suggest you clean up your code, I mean seriously? world.setBlock(i + 22, j + 0, k + 12, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 13, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 14, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 15, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 16, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 17, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 18, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 19, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 20, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 21, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 22, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 23, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 24, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 25, Block.cobblestone.blockID); world.setBlock(i + 22, j + 0, k + 26, Block.cobblestone.blockID); You can use loops for this stuff, makes the code a lot more readable and debugging won't be a PITA.
  8. So it seems the events fixed my problem, awesome! Also I actually found the "true-last" event fired during population: PopulateChunkEvent.Post, but note that this is fired in the EVENT_BUS and not in the TERRAIN_GEN_BUS! I don't know if it's still the case in 1.7, though. So here's my modified code: WorldGenerator (it's now completely event-driven, IMO it's better than the IWorldProvider): https://github.com/SanAndreasP/EnderStuffPlus/blob/code-cleanup/java/sanandreasp/mods/EnderStuffPlus/world/EnderStuffWorldGenerator.java And this is the Common Proxy, where I basically register the generator: https://github.com/SanAndreasP/EnderStuffPlus/blob/code-cleanup/java/sanandreasp/mods/EnderStuffPlus/registry/CommonProxy.java#L42-L44 Thanks again, coolAlias for the tip!
  9. I've never noticed an event like this existed... It is actually a better solution, since dungeons themselves get also generated "at population". I will tinker with it and observe the results, Thanks!
  10. I have a really hard time trying to fix this. I basically generate a structure in the world with a custom IWorldGenerator. Sometimes it happens when the structure is generated, it gets cut off at chunk borders. I tried to force-load the chunks the structure is being built into, but this doesn't work either. I will be grateful for any hint / advice for solving this. Here's a screenshot of how the structure gets cut off: http://puu.sh/7UX4K.jpg Here's the IWorldGenerator class: https://github.com/SanAndreasP/EnderStuffPlus/blob/code-cleanup/java/sanandreasp/mods/EnderStuffPlus/world/EnderStuffWorldGenerator.java And here's the actual class where the structure gen is happening: https://github.com/SanAndreasP/EnderStuffPlus/blob/code-cleanup/java/sanandreasp/mods/EnderStuffPlus/world/WorldGenEndLeak.java
  11. Remove super.registerBlockIcons(p_149651_1_); as you don't need it (since you register your own icons anyway) and it actually causes said error. Then see if you still get the texture error.
  12. 1. post all of your crash, it's only a part of your stacktrace what you've posted and we can't use it. 2. You register your recipes before you register your blocks, which could cause troubles. I usually register the blocks / items in the preInit (FMLPreInitializationEvent) and register my recipes during init (FMLInitializationEvent)
  13. allocate more memory to Minecraft with arguments -Xms and -Xmx (for example use -Xmx2048M -Xmx2048M to allocate 2GB of memory) EDIT: use no equal signs! Mistake from my side.
  14. You need to use packets. There are tutorials on how to utilize packets in Forge all over the internet.
  15. There's nothing I can do to fix this. It's an issue with the Minecraft code itself:
  16. java.lang.OutOfMemoryError Allocate more memory to Minecraft.
  17. The args changed even before there... There was a reason I didn't give him the addCreatureType method, though I probably should have said why. So again, use private static final Class<?>[][] PARAM_TYPES = new Class[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}}; public static final EnumCreatureType MY_CREATURE_TYPE = EnumHelper.addEnum(PARAM_TYPES, EnumCreatureType.class, "creatureTypeName", BaseEntityClass.class, 40, Material.air, false, true); instead of public static final EnumCreatureType MY_CREATURE_TYPE = EnumHelper.addCreatureType(...) since Forge doesn't provide the additional boolean parameter (even in 1.6) and thus will crash. The parameters for the addEnum are as following: par3 - "creatureTypeName" The name of the new enum within the EnumCreatureType class (you CANNOT use this to reference to the new enum directly! That's why the return value of the addEnum method is saved!) par4 - BaseEntityClass.class The class which should be used as a reference (your mobs shall then use the same class or a childclass of it) par5 - 40 Determines how much entites should be spawning at maximum par6 - Material.air The Material the entities should be spawning in, Material.water and Material.air are used in vanilla par7 - false Determines if it's a peaceful creature (e.g. any animal like cows, chickens etc.) par8 - true Determines if it's an ambient creature (e.g. bats) an animal (e.g. see above) In your case, it would be: private static final Class<?>[][] PARAM_TYPES = new Class[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}}; public static final EnumCreatureType E_NEOLA = EnumHelper.addEnum(PARAM_TYPES, EnumCreatureType.class, "neola", WhateverYourCreatureClassIs.class, 40, Material.air, true, true); Change those parameters to fit your purpose! To reference it in the addSpawn method use the E_NEOLA variable EntityRegistry.addSpawn(EntityNeola.class, 100, 8, 10, E_NEOLA, BiomeGenBase.forest); Some notes from me: I encourage that any static final variable is spelled uppercase with underscores separating the words, like MY_FINAL_VAR to distinguish them from normal variables I encourage that any other variable is spelled camelCase, like myNormalVar
  18. Please just don't blindly copy-paste code... You really want to name your Creature Type "ambientWaterFish"? I highly doubt you have a class named EntityWaterMob Also you can rename the EnumCreatureType variable to something more fitting than "ambientWater" Again, I've explained the parameters previously, here's a short version: *variableName* = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, *nameOfEnumValue*, *baseClassOfCreatures*, *maxNumberOfCreaturesSpawning*, *MaterialInWhichCreaturesShouldSpawnIn*, *isPeaceful*, *isAnimal*); Also you must import net.minecraftforge.common.EnumHelper
  19. The EnumHelper is located at net.minecraftforge.common Can you show me your full class file where you put the variables?
  20. Hmm...well, I modified some code earlier (I didn't update cause I didn't realize it was that important). They're all extending EntityAnimal, and set to EnumCreatureType.creature right now... Those really spawn rarely. Either increase your spawn rates (idk, but I've seen that someone had to increase it to insane numbers like 1000 or so) or register a new EnumCreatureType. The latter is shown here: private static final Class<?>[][] paramTypes = new Class[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}}; public static final EnumCreatureType ambientWater = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "ambientWaterFish", EntityWaterMob.class, 40, Material.water, false, true); "ambientWaterFish" is the name of the new enum within the EnumCreatureType class EntityWaterMob.class is the class which should be used as a reference (your mobs shall then use the same class or a childclass of it) 40 determines how much entites should be spawning at maximum Material.water the Material the entities should be spawning in, Material.water and Material.air are used in vanilla false determines if it's a peaceful creature (e.g. any animal like cows, chickens etc.) true determines if it's an ambient creature (e.g. bats) an animal (e.g. see above)
  21. Wait, so this doesn't work in 1.7.2 anymore? WorldType.NORMAL.addNewBiome(biome); AFAIK, the spawnable biomes list is just an indicator for the player spawn algorithm to determine the spawning biome. EDIT: I must apologize, the right field isn't NORMAL but DEFAULT: WorldType.DEFAULT.addNewBiome(biome); For large biomes, you must also add WorldType.LARGE_BIOMES.addNewBiome(biome);
  22. You use EnumCreatureType.ambient in your addSpawn method. Thus your entity must extend the EntityAmbientCreature class in order for it to spawn. Look at the EnumCreatureType enum to see what values it has and which classes you need to implement / extend in your entity class.
  23. Those are good wrapper methods, but I don't think it's advisable to use update frequencies of 1 for your entities. Mobs, for example, typically use 3, while arrows use 20 and throwables use 10 (in vanilla). Using different values than those may cause strange problems or lag - I've noticed it most with arrows - your mileage may vary, and I'm sure you have good reasons for using 1 since you seem to know quite well what you're doing. This spreadsheet put together by lockNload147 sums up the vanilla entity tracking values. I never worried about this too much, it worked and I was happy. It's older code anyway and will be refractored once I get to it (I'm currently in the process of completely refractoring the mod), and will use those recommented values. Thanks for the sheet
  24. No need for a coremod here, just use an event: LivingDropsEvent PS: wrong forum
  25. You need to use registerModEntity instead of registerGlobalEntity If you want a spawn egg, use registerGlobalEntity with those additional parameters before the registerModEntity. Here I made wrapper methods for the entity registration: https://github.com/SanAndreasP/EnderStuffPlus/blob/master/java/sanandreasp/mods/EnderStuffPlus/registry/CommonProxy.java Those additional parameters are the foreground / background colors. You can (and should) use hexadecimal values, e.g.: 0xFF0000 - red 0x00FF00 - green 0x0000FF - blue each digit after 0x can range from 0 to F (0 to 15) An example for my wrapper methods: https://github.com/SanAndreasP/EnderStuffPlus/blob/master/java/sanandreasp/mods/EnderStuffPlus/registry/ESPModRegistry.java#L450-L464
×
×
  • Create New...

Important Information

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