TheRPGAdventurer Posted July 2, 2017 Posted July 2, 2017 I have made a nether dragon and it is immune to fire lava magma blocks, But I want it to have a regeneration effect when it is on lava. Quote
IceMetalPunk Posted July 2, 2017 Posted July 2, 2017 (edited) Rather than making the entity immune to fire, I would hook into the LivingEvent.LivingHurtEvent. This way you can cancel all fire damage for your entity like you want, but you can also apply potion effects if the DamageSource is fire damage. For instance: @SubscribeEvent public void handleFirePotion(LivingEvent.LivingHurtEvent event) { if (event.getSource().isFireDamage() && event.getEntityLiving() instanceof EntityNetherDragon) { event.getEntityLiving().addPotionEffect(new PotionEffect(...)); event.setCanceled(true); } } Fill in the PotionEffect's constructor as needed, of course. Edited July 2, 2017 by IceMetalPunk Gave example Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 2, 2017 Author Posted July 2, 2017 On 7/2/2017 at 5:15 AM, IceMetalPunk said: Rather than making the entity immune to fire, I would hook into the LivingEvent.LivingHurtEvent. This way you can cancel all fire damage for your entity like you want, but you can also apply potion effects if the DamageSource is fire damage. For instance: @SubscribeEvent public void handleFirePotion(LivingEvent.LivingHurtEvent event) { if (event.getSource().isFireDamage() && event.getEntityLiving() instanceof EntityNetherDragon) { event.getEntityLiving().addPotionEffect(new PotionEffect(...)); event.setCanceled(true); } } Fill in the PotionEffect's constructor as needed, of course. Expand Where do I put these btw, is it in the nether dragon class or in the main mod class? Quote
IceMetalPunk Posted July 2, 2017 Posted July 2, 2017 Neither. Look up how to create and use event handlers with Forge; they'll come in very useful for you in the future 1 Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 2, 2017 Author Posted July 2, 2017 On 7/2/2017 at 5:45 AM, IceMetalPunk said: Neither. Look up how to create and use event handlers with Forge; they'll come in very useful for you in the future Expand Question, how do skeletons handle it's spawning, cause wither skeletons and ordinary skeletons are spawned in different Dimensions. Does Minecraft have a main class also? Quote
IceMetalPunk Posted July 2, 2017 Posted July 2, 2017 On 7/2/2017 at 5:50 AM, TheRPGAdventurer said: Question, how do skeletons handle it's spawning, cause wither skeletons and ordinary skeletons are spawned in different Dimensions. Does Minecraft have a main class also? Expand Yes, but that's not where you should be looking for spawning data. For spawning of custom entities, you should be using the Forge method EntityRegistry.addSpawn(entityClass, weightedProb, min, max, typeOfCreature, biomes). So for instance, to add your NetherDragon to the Nether, spawning in groups of 1 to 3 often, keeping in mind the Nether's biome is called HELL, you'd do something like this: EntityRegistry.addSpawn(EntityNetherDragon.class, 1.0f, 1, 3, EnumCreatureType.MONSTER, Biomes.HELL); Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 2, 2017 Author Posted July 2, 2017 On 7/2/2017 at 6:12 AM, IceMetalPunk said: Yes, but that's not where you should be looking for spawning data. For spawning of custom entities, you should be using the Forge method EntityRegistry.addSpawn(entityClass, weightedProb, min, max, typeOfCreature, biomes). So for instance, to add your NetherDragon to the Nether, spawning in groups of 1 to 3 often, keeping in mind the Nether's biome is called HELL, you'd do something like this: EntityRegistry.addSpawn(EntityNetherDragon.class, 1.0f, 1, 3, EnumCreatureType.MONSTER, Biomes.HELL); Expand Ok here's my problem, My dragon has a main class called EntityTameableDragon, and it is separated into 6 different breeds Sapphire,Jade,Amethyst,END(ender dragon) the nether dragon is one of them, and each breed has it's own class, and all the breeds has an enum called EnumDragonBreed.class, much like the skeleton, The problem is when I use the code below, it just spawns it with the default breed called END which is the ender dragon, what I want to achieve is to spawn the "gem" type dragons in the overworld extreme hills and spawn the nether dragon in the nether and the end can only be obtained by killing the ender dragon(vanilla) and hatching the dragon egg. this mod is not really mine, it's from dragon mounts mod and I'm trying to revive it. EntityRegistry.addSpawn(EntityTameableDragon.class, 1.0f, 1, 3, EnumCreatureType.MONSTER, Biomes.HELL); Quote
IceMetalPunk Posted July 2, 2017 Posted July 2, 2017 (edited) On 7/2/2017 at 6:23 AM, TheRPGAdventurer said: Ok here's my problem, My dragon has a main class called EntityTameableDragon, and it is separated into 6 different breeds Sapphire,Jade,Amethyst,END(ender dragon) the nether dragon is one of them, and each breed has it's own class, and all the breeds has an enum called EnumDragonBreed.class, much like the skeleton, The problem is when I use the code below, it just spawns it with the default breed called END which is the ender dragon, what I want to achieve is to spawn the "gem" type dragons in the overworld extreme hills and spawn the nether dragon in the nether and the end can only be obtained by killing the ender dragon(vanilla) and hatching the dragon egg. this mod is not really mine, it's from dragon mounts mod and I'm trying to revive it. EntityRegistry.addSpawn(EntityTameableDragon.class, 1.0f, 1, 3, EnumCreatureType.MONSTER, Biomes.HELL); Expand The EntityLiving class contains a method called onInitialSpawn which is called the first time an entity spawns and never again for that instance of the entity. You can override that to check the biome the entity is currently in and set the data accordingly. Edited July 2, 2017 by IceMetalPunk 1 Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 2, 2017 Author Posted July 2, 2017 On 7/2/2017 at 6:27 AM, IceMetalPunk said: The EntityLiving class contains a method called onInitialSpawn which is called the first time an entity spawns and never again for that instance of the entity. You can use that to check the biome the entity is currently in and set the data accordingly. Expand So you mean like the onInitialSpawn will set what breeds to use and then forge will now use it instead of using the default breed? Quote
IceMetalPunk Posted July 2, 2017 Posted July 2, 2017 No... onInitialSpawn is just a method that will be called on your entity whenever it spawns in the world. It's up to you to put the code in that method to check the biome, set the breed data, and do whatever else you need your entity to do whenever it spawns. Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 2, 2017 Author Posted July 2, 2017 (edited) On 7/2/2017 at 6:31 AM, IceMetalPunk said: No... onInitialSpawn is just a method that will be called on your entity whenever it spawns in the world. It's up to you to put the code in that method to check the biome, set the breed data, and do whatever else you need your entity to do whenever it spawns. Expand Do I still have to use the GameRegistry Forge Method? Edited July 2, 2017 by TheRPGAdventurer Wrong Grammar Quote
IceMetalPunk Posted July 2, 2017 Posted July 2, 2017 Which method of GameRegsitry, and for what? It seems perhaps there are basic concepts of both Java and Forge that you aren't quite familiar with. I'd suggest starting smaller, with some more basic mods and watching/reading tutorials on how to make a basic mod first. Once you're comfortable with that, then move on to larger projects like trying to update an existing dragon-taming mod. Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 2, 2017 Author Posted July 2, 2017 On 7/2/2017 at 6:35 AM, IceMetalPunk said: Which method of GameRegsitry, and for what? It seems perhaps there are basic concepts of both Java and Forge that you aren't quite familiar with. I'd suggest starting smaller, with some more basic mods and watching/reading tutorials on how to make a basic mod first. Once you're comfortable with that, then move on to larger projects like trying to update an existing dragon-taming mod. Expand also I found a bug in the original mod when he sets his biomes for which his egg will change breeds the mob will also spawn. Quote
TheRPGAdventurer Posted July 2, 2017 Author Posted July 2, 2017 On 7/2/2017 at 6:48 AM, TheRPGAdventurer said: also I found a bug in the original mod when he sets his biomes for which his egg will change breeds the mob will also spawn. Expand On 7/2/2017 at 6:35 AM, IceMetalPunk said: Which method of GameRegsitry, and for what? It seems perhaps there are basic concepts of both Java and Forge that you aren't quite familiar with. I'd suggest starting smaller, with some more basic mods and watching/reading tutorials on how to make a basic mod first. Once you're comfortable with that, then move on to larger projects like trying to update an existing dragon-taming mod. Expand Ok it worked but the problem is I can only set it on two breeds but how do I do it? https://pastebin.com/FXfuWZvE Quote
TheRPGAdventurer Posted July 2, 2017 Author Posted July 2, 2017 On 7/2/2017 at 6:27 AM, IceMetalPunk said: The EntityLiving class contains a method called onInitialSpawn which is called the first time an entity spawns and never again for that instance of the entity. You can override that to check the biome the entity is currently in and set the data accordingly. Expand also what does weightProbability do? Quote
IceMetalPunk Posted July 3, 2017 Posted July 3, 2017 You can set it to as many breeds as you want. Remember that you can use "else if" statements in Java. weightedProb determines the chance that this particular mob will spawn instead of a different mob that can spawn in the same biome. So for instance, if your dragon could spawn, or a skeleton could spawn, giving your dragon a higher weightedProb makes it more likely the game will spawn your dragon instead of a skeleton. Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 3, 2017 Author Posted July 3, 2017 On 7/3/2017 at 3:19 AM, IceMetalPunk said: You can set it to as many breeds as you want. Remember that you can use "else if" statements in Java. weightedProb determines the chance that this particular mob will spawn instead of a different mob that can spawn in the same biome. So for instance, if your dragon could spawn, or a skeleton could spawn, giving your dragon a higher weightedProb makes it more likely the game will spawn your dragon instead of a skeleton. Expand Now I found my mistake, I only used else without if. Quote
TheRPGAdventurer Posted July 3, 2017 Author Posted July 3, 2017 On 7/3/2017 at 3:19 AM, IceMetalPunk said: You can set it to as many breeds as you want. Remember that you can use "else if" statements in Java. weightedProb determines the chance that this particular mob will spawn instead of a different mob that can spawn in the same biome. So for instance, if your dragon could spawn, or a skeleton could spawn, giving your dragon a higher weightedProb makes it more likely the game will spawn your dragon instead of a skeleton. Expand I just copy pasted this from the skeleton, if (biome instanceof BiomeHills && this.worldObj.canSeeSky(new BlockPos(this)) && this.rand.nextInt(6) != 0) {this.setBreedType(EnumDragonBreed.RUBY); what does && this.rand.nextInt(6) != 0 do. Quote
IceMetalPunk Posted July 3, 2017 Posted July 3, 2017 (edited) On 7/3/2017 at 3:31 AM, TheRPGAdventurer said: I just copy pasted this from the skeleton, if (biome instanceof BiomeHills && this.worldObj.canSeeSky(new BlockPos(this)) && this.rand.nextInt(6) != 0) {this.setBreedType(EnumDragonBreed.RUBY); what does && this.rand.nextInt(6) != 0 do. Expand && means "and". this.rand is a random number generator, which all Entities have. nextInt(int X) is a method of Java's random number generators that generates a random integer from 0 to X-1. != means "not equal to". So this uses the entity's random number generator to pick a random integer from 0 to 5 and check that it's not 0. Which means it creates a 5/6 chance of the condition being true, and a 1/6 chance of it being false. In other words, in this case, 5/6 of the dragons in the hills will be Ruby type, while 1/6 will not. Edited July 3, 2017 by IceMetalPunk 1 Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 3, 2017 Author Posted July 3, 2017 On 7/3/2017 at 3:35 AM, IceMetalPunk said: && means "and". this.rand is a random number generator, which all Entities have. nextInt(int X) is a method of Java's random number generators that generates a random integer from 0 to X-1. != means "not equal to". So this uses the entity's random number generator to pick a random integer from 0 to 5 and check that it's not 0. Which means it creates a 5/6 chance of the condition being true, and a 1/6 chance of it being false. In other words, in this case, 5/6 of the dragons in the hills will be Ruby type, while 1/6 will not. Expand what if I put != 5 here is the enumDragonBreed class https://pastebin.com/gvrSag9r Quote
IceMetalPunk Posted July 3, 2017 Posted July 3, 2017 On 7/3/2017 at 4:29 AM, TheRPGAdventurer said: what if I put != 5 here is the enumDragonBreed class https://pastebin.com/gvrSag9r Expand It'd be the same thing. Picking a random integer between 0 and 5 gives you a 1/6 chance of picking any particular one of those numbers; if you're checking that it hasn't picked just one of them, the value you choose to compare against doesn't matter, it will still be the same 1/6 chance of being false. Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 3, 2017 Author Posted July 3, 2017 (edited) On 7/3/2017 at 4:31 AM, IceMetalPunk said: It'd be the same thing. Picking a random integer between 0 and 5 gives you a 1/6 chance of picking any particular one of those numbers; if you're checking that it hasn't picked just one of them, the value you choose to compare against doesn't matter, it will still be the same 1/6 chance of being false. Expand the reason I try to put != 5 because it still spawns with the default breed called END. here is the OnInitialSpawn Method, https://pastebin.com/LAipzhK6 Edited July 3, 2017 by TheRPGAdventurer forgot something Quote
IceMetalPunk Posted July 3, 2017 Posted July 3, 2017 On 7/3/2017 at 4:38 AM, TheRPGAdventurer said: the reason I try to put != 5 because it still spawns with the default breed called END. Expand That entire line is all evaluated before deciding whether it should use the Ruby type. if (biome instanceof BiomeHills && this.worldObj.canSeeSky(new BlockPos(this)) && this.rand.nextInt(6) != 0) Which means if it spawns outside the hills biome, if there are any blocks above it when it spawns (so it can't see the sky directly), or if there happens to be a 1/6 chance on the random number result.... if any of those things are true, it won't use the Ruby type. So you might want to check all those conditions with some console output (using, for instance, the System.out.println() method) to see which is failing. Quote Whatever Minecraft needs, it is most likely not yet another tool tier.
TheRPGAdventurer Posted July 3, 2017 Author Posted July 3, 2017 On 7/3/2017 at 4:42 AM, IceMetalPunk said: That entire line is all evaluated before deciding whether it should use the Ruby type. if (biome instanceof BiomeHills && this.worldObj.canSeeSky(new BlockPos(this)) && this.rand.nextInt(6) != 0) Which means if it spawns outside the hills biome, if there are any blocks above it when it spawns (so it can't see the sky directly), or if there happens to be a 1/6 chance on the random number result.... if any of those things are true, it won't use the Ruby type. So you might want to check all those conditions with some console output (using, for instance, the System.out.println() method) to see which is failing. Expand Dude side note, it does spawn but the problem is it spawns every breed in the overworld except nether and ruby, my problem is that END still spawns aside with others and I can't see any rubies. Quote
TheRPGAdventurer Posted July 3, 2017 Author Posted July 3, 2017 On 7/3/2017 at 4:42 AM, IceMetalPunk said: That entire line is all evaluated before deciding whether it should use the Ruby type. if (biome instanceof BiomeHills && this.worldObj.canSeeSky(new BlockPos(this)) && this.rand.nextInt(6) != 0) Which means if it spawns outside the hills biome, if there are any blocks above it when it spawns (so it can't see the sky directly), or if there happens to be a 1/6 chance on the random number result.... if any of those things are true, it won't use the Ruby type. So you might want to check all those conditions with some console output (using, for instance, the System.out.println() method) to see which is failing. Expand If i put == 0 will it include 0? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.