Everything posted by jabelar
-
[1.7.10] Placing seed problems
You might be interested in my tutorial on custom crops: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-creating-custom.html
-
Much mob spawning!
Unfortunately, the collision boxes in Minecraft have x and z dimensions need to be equal. I think this helps the code do path finding but can pose a problem if you've created a complex entity. I suggest you just make it similar to how a cow or something has collision box -- won't cover whole entity, and won't perfectly size, but will be what Minecraft players already expect. If you really needed to do a fancier collision box, then you basically have to create additional, invisible entities associated with your bear and if those get hit then damage the bear entity. It is a bit tricky to program, but possible if you need it. Overall, you normally have to compromise -- make the collision box a bit bigger than the entity width and bit smaller than entity length and you'll have most of the entity covered.
-
Much mob spawning!
I'm not sure if you attached the picture you meant to attach -- does that picture have a bunch of bears in it? Anyway, I think the problem is that you add the spawns for all your bear types each time you register an individual bear. For example, you call createEntity() for EntityUrsoMarrom but in the createEntity() code you add spawns for UrsoPreto, etc. I think you should remove the add spawn code to a separate method and only call it once after you've registered all the entities.
-
[1.7.10]How to check actual entity type with Check Spawn event
Whew -- so I'm not crazy. Yeah, I suspect that the generation of the animals is done somewhere else, where they forgot to fire check spawn or something. Thanks for confirming!
-
[1.7.10]How to check actual entity type with Check Spawn event
The Check Spawn is still driving me crazy though. I can detect things like Zombies fine. If I have this code: String name = event.entityLiving.getClass().getSimpleName(); if (name.equals("EntityCow")) { System.out.println("Check spawn event for "+event.entityLiving.getClass().getSimpleName()); } if (event.entityLiving instanceof EntityCow) { System.out.println("EntityCow spawning"); } if (name.equals("EntityZombie")) { System.out.println("Check spawn event for "+event.entityLiving.getClass().getSimpleName()); } if (event.entityLiving instanceof EntityZombie) { System.out.println("EntityZombie spawning"); } Then I get following console output (which happily reports zombies, but doesn't show any cows): But the game has lots of cows in it! Oh well... not sure what is wrong.
-
[1.7.10]How to check actual entity type with Check Spawn event
Okay, I don't know what went wrong for me then. Maybe a typo or something. Using EntityJoinedWorldEvent seems to mostly work for me, with the exception that I get the visual glitch I mentioned where if I use spawn egg the entity briefly appears before being killed (I'm trying to prevent the spawn).
-
[1.7.10]How to check actual entity type with Check Spawn event
Draco, I can get EnititySheep detected with EntityConstructing just fine. The problem is that the position is always 0, 0, 0 in that event. I'll try EntityJoinWorldEvent. Note another thing I didn't like about the join event is that I want to prevent some of the entities from spawning, which is easy with setting check spawn to Result.DENY. With EntityJoinWorldEvent, I think I have to set dead which will I think last time I tried it showed a visible blip where the entity is visible for a tick before disappearing. Ultimately I'd like to prevent the spawn altogether. But can one of you try the CheckSpawn event to see if you see what I'm seeing?
-
[1.7.10]How to check actual entity type with Check Spawn event
I know I can get the position of the entity, except during the constructing position is always 0.0D, 0.0D, 0.0D. If you look at the Entity constructor it explicitly sets the position to that just before posting the event. So that doesn't work. EntityJoinWorldEvent only seems to fire occasionally. I think maybe it fires once per entity type? It certainly doesn't fire for every sheep. Back to the casting question -- I thought it should be preserved. However, I found a weird thing -- checking for EntityLiving, EntityLivingBase, EntityCreature all test true. However testing for EntityAnimal, or EntitySheep, etc. I just cant get a hit. I'm pretty sure that there are entity sheep spawning because I see them and I'm recreating the world each time. Do this test if you have time. Put code like this in: if (event.entityLiving instanceof EntityCreature) { System.out.println("EntityCreature spawning"); } if (event.entityLiving instanceof EntityAnimal) { System.out.println("EntityAnimal spawning"); } if (event.entityLiving instanceof EntitySheep) { System.out.println("EntitySheep spawning"); } When I do I get a ton of "EntityCreature spawning messages", but nothing else. I wondered if there were just lots of non-animal creatures spawning but if I comment out that test then nothing prints out. Do you see the same?
-
[1.7.10]How to check actual entity type with Check Spawn event
I'm thinking that what I'll have to do is use EntityConstructing but in the even handler just check for entity type and if I find it then will put it in a public list of recently spawned entities. Then in the ServerTick event I'll go through those entities and do my handling there once they have a non-zero position. I'm pretty sure I can get that to work, but it is a lot messier than it should be.
-
[1.7.10]How to check actual entity type with Check Spawn event
I should mention that I also had trouble with EntityConstructing event because that occurs before the position of the entity is set (posX is 0.0D, etc.) and I also need to know the position of the entity as well as its type. So CheckSpawn gives location (the event actually passes x, y, z) but casts to EntityLiving and the EntityConstructing event gives the entity type without casting, but there is no position information! So I need help figuring out a way to know the position of certain type of vanilla entity when it spawns? Anyone have an idea of an event or scheme for doing that?
-
How to update gui screen
The gui screen class should have both an updateScreen() and a drawScreen() method that are called every tick. So if the information you want to display is in public fields on the client side then you can just check them and do what you want in response.
-
[1.7.10]How to check actual entity type with Check Spawn event
I want to do something when specific entity types spawn. But if I check for instanceof on the event.entityLiving field, it always fails (e.g. checking for instanceof EntitySheep). However, checking for instanceof EntityLiving checks as true. So I guess the event.entityLiving is cast as an EntityLiving and the actual type (EntitySheep or whatever) is lost. And in fact I see that if I trace back the call hierarchy for the post to the event bus, the parameter passed is indeed cast to EntityLiving. I think that is a shame and not sure it is really necessary -- I'm pretty sure Java would have allowed them to pass EntitySheep in since they inherit from EntityLiving... Anyway, this greatly weakens the usefulness of the CheckSpawn event since all you know is that some EntityLiving has spawned but have no way to check what exactly it was. Does anyone have an idea on how I can acheive what I want -- detecting when certain entities spawn? Is there another event, like maybe a chunk event where I can scan for entities that have appeared along with a new chunk or something? I suppose another way to solve it would be to remember the location of the spawn and then search for the entity in a bounding box around that point a few ticks later. But that seems kinda kludgy... Am I wrong in thinking that the entity passed to the CheckSpawn would be more useful if it is not cast to EntityLiving? Should I put in a bug report for this?
-
[solved][1.7.10] LivingFallEvent get not catched
The fall event works well for me. Are you sure you actually registered the handling class to the bus? Post your code for registering the handler.
-
[1.7.10] Spawning Particles
TGG, I understand the concern over the running of Minecraft.getMinecraft() on server side. I think it is odd too. Some, vanilla code seems to do that when calling the Effect Renderer (from an mc that is found with Minecraft.getMinecraft(). And it doesn't crash and it works fine for me, which surprised me. However, to be safe I switched it to remove the negation and it still works. So yeah, probably better to do is that way. NJay, can you post your onUpdate() method code as well as the actual error messages?
-
[1.7.10] Spawning Particles
I do it for one of my custom entities like this, in the onUpdate() event (or some other event that happens every tick): if (!worldObj.isRemote && rand.nextFloat()<0.1F) { double var4 = rand.nextGaussian() * 0.02D; double var6 = rand.nextGaussian() * 0.02D; double var8 = rand.nextGaussian() * 0.02D; EntityFX particleMysterious = new EntityParticleFXMysterious(worldObj, posX + rand.nextFloat() * width * 2.0F - width, posY + 0.5D + rand.nextFloat() * height, posZ + rand.nextFloat() * width * 2.0F - width, var4, var6, var8); Minecraft.getMinecraft().effectRenderer.addEffect(particleMysterious); } In this case, EntityParticleFXMysterious is a class I made that extends EntityParticleFX but you can also use the standard particles if you want.
-
[Solved][1.7.10]Why is this check for armor always returning true?
Yeah well, I've never understood the aversion to it though. I find code much more readable if it is spaced out generally (I'll even put whitespace in my code). I'm a touch typist so it takes me no extra time to go to next line. In the old days, vertical screen resolution was low so it was important to compress the vertical space, and I know some people have problem with understanding code that goes more than one screen, but I find that space helps me more. Anyway, this is one argument that has been around since dawn of languages like C and I can't find any compelling argument for either way. Anyway, back to the thread topic: the error is of course that there is semicolon after the if expression thereby terminating it and letting code execution fall through to next block always. This happened because I cut and past from another line where I had previously been assigning it to a boolean.
-
[Solved][1.7.10]Why is this check for armor always returning true?
Doh, I figured it out. There is actually a typo in the code. You want me to tell you what it is, or do you want the satisfaction of finding it yourself? It is kinda a silly mistake but also the type of thing that could be dangerous if you miss it...
-
[Solved][1.7.10]Why is this check for armor always returning true?
Hmm, I went back to my original code (from github, so is same as I started with exactly) but it seems to be working now for some reason! If I have nothing in boot slot then there is no console output, if I put vanilla boots in slot there is no console output, and if I put in my boots it has console output. So, yeah, working... Maybe I overlooked something when testing originally. I'll do a bit more testing before I consider it solved.
-
[Solved][1.7.10]Why is this check for armor always returning true?
I added the additional check while debugging. Initially I simply had if (thePlayer.getCurrentArmor(0) != null && thePlayer.getCurrentArmor(0) == MagicBeans.bootsOfSafeFalling); And to prove that my armor is not actually equipped, here is screenshot during testing just now: http://s13.postimg.org/8r6wpp8tz/Capture4.png Regarding the creative mode, yeah the way I'm testing the fall event is to go to creative and then fly up kinda high then switch game mode to 0 which causes me to drop. My full method for the fall event is: @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(LivingFallEvent event) { if (!event.entityLiving.worldObj.isRemote && event.entityLiving instanceof EntityPlayer) { EntityPlayer thePlayer = (EntityPlayer) event.entityLiving; if (thePlayer.getCurrentArmor(0) != null && thePlayer.getCurrentArmor(0).getItem() == MagicBeans.bootsOfSafeFalling); { // DEBUG System.out.println("LivingFallEvent handled due to having safe falling armor equipped"); event.distance = 0.0F ; } } }
-
[Solved][1.7.10]Why is this check for armor always returning true?
Yeah, I actually started with using == as i just replied to diesieben07. This is in LivingFallEvent so thePlayer is from the event parameter.
-
[Solved][1.7.10]Why is this check for armor always returning true?
unlocalized names was the last thing I tried. I first tried to equate the items with: if (thePlayer.getCurrentArmor(0) != null && thePlayer.getCurrentArmor(0).getItem() != null && thePlayer.getCurrentArmor(0).getItem() == MagicBeans.bootsOfSafeFalling); And also using .equals if (thePlayer.getCurrentArmor(0) != null && thePlayer.getCurrentArmor(0).getItem() != null && thePlayer.getCurrentArmor(0).getItem().equals(MagicBeans.bootsOfSafeFalling)); I guess I can try instanceof but I have several similar items using same class so not really cleanest way.
-
[Solved][1.7.10]Why is this check for armor always returning true?
Okay, I simply want to check if certain armor is being worn, but for some reason this statement is returning true even with nothing equipped at all. I'm not sure why the null check doesn't return false in the first place, and even more confused why it considers the unlocalized name matched. I know there is nothing equipped because I check but also am doing fresh world where I don't even have the armor anywhere in my inventory (equipped or not). if (thePlayer.getCurrentArmor(0) != null && thePlayer.getCurrentArmor(0).getUnlocalizedName().equals(MagicBeans.bootsOfSafeFalling.getUnlocalizedName())); { // DEBUG System.out.println(MagicBeans.bootsOfSafeFalling.getUnlocalizedName()+" equipped."); } The console prints out: item.boots_of_safe_falling equipped. Maybe I'm just going cross-eyed from 3 days straight programming, but shouldn't the the null check return false if nothing is equipped? And how could the string equals return true with nothing in the armor slot? Another weird thing is that if I change the println to thePlayer.getCurrentArmor(0).getUnlocalizedName()+" equipped." I get a null pointer exception on that line. But that seems strange because the expression in the if expression evaluated without an exception. Note I've tried many other variations on this check. I've tried checking if the item itself was equals (using both == and .equals() method). I tried comparing methods from items and itemstacks. Help!
-
[SOLVE[1.7.10]Some but not all assets in JAR don't work, but all work in Eclipse
Thanks, I didn't know that! By the way, for anyone who might find this thread later -- my second issue with the mod logo not working in JAR versus Eclipse had to do with the path I put the logo file in. It should be put at same level as the mcmod.info itself (i.e. directly in resources folder, not in underlying assets folder).
-
[SOLVE[1.7.10]Some but not all assets in JAR don't work, but all work in Eclipse
Yep, that was the problem. Thanks! I think I might have figured that out myself except that for some reason it works in Eclipse with the wrong name. Does anyone have an explanation for that? Why would en_us.lang work in Eclipse but only en_US.lang work in both Eclipse and JAR?
-
[SOLVE[1.7.10]Some but not all assets in JAR don't work, but all work in Eclipse
I must be missing something simple, but I've been stumped for couple days on this. Basically, when I run in Eclipse all assets work including custom block textures, custom entity textures, custom sounds, the mod logo, and the lang file (hovering over my custom items in creative tab show translated name). When I export the JAR using gradlew build instruction, the JAR contains all the assets organized in the way I expect (and seems same as other people's mod JARs I've inspected). However, when running Minecraft with this mod the lang file doesn't work (hovering over my custom items in creative tab show "item.bootsofsafefalling.name" and such). Also the mod logo file no longer shows in the mod options screen. But all my other textures and sounds are working fine! It seems that the lang file path is less tolerant to the difference between the Eclipse and JAR environment or something, whereas block textures seem to be able to find them. Anyway, here's some relevant info. Eclipse package structure: http://s30.postimg.org/6i4lzamwh/Capture1.png Resulting JAR top level structure: http://s12.postimg.org/uu39q2lbx/Capture2.png Resulting JAR en_lang location: http://s11.postimg.org/4js0ipl9v/Capture3.png Here is my build.gradle file contents: buildscript { repositories { mavenCentral() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' } } apply plugin: 'forge' version = "1.7.10-1.0.0" group= "com.blogspot.jabelarminecraft.magicbeans" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "magicbeans" minecraft { version = "1.7.10-10.13.2.1277" runDir = "../run/assets" } dependencies { // you may put jars on which you depend on in ./libs // or you may define them like so.. //compile "some.group:artifact:version:classifier" //compile "some.group:artifact:version" // real examples //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env // for more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' // replace version and mcversion expand 'version':project.version, 'mcversion':project.minecraft.version } // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } } Here is en_us.lang file contents from Eclipse: tile.magicbeanstalk.name=Magic Bean Stalk tile.magicbeansvine.name=Magic Bean Vine tile.magicbeanscloud.name=Cloud item.magicbeans.name=Magic Beans item.bootsofsafefalling.name=Boots of Safe Falling entity.magicbeans.Giant.name=Giant In the JAR the en_us.lang file seems to have same contents: tile.magicbeanstalk.name=Magic Bean Stalk tile.magicbeansvine.name=Magic Bean Vine tile.magicbeanscloud.name=Cloud item.magicbeans.name=Magic Beans item.bootsofsafefalling.name=Boots of Safe Falling entity.magicbeans.Giant.name=Giant Maybe it is something about the way I specify the unlocalized names for the items. One of the problematic items is instantiated in my main mod class like this: public final static ItemArmor bootsOfSafeFalling = (ItemArmor) new ItemArmor(ItemArmor.ArmorMaterial.CLOTH, 1, 3).setUnlocalizedName("bootsofsafefalling").setTextureName("minecraft:chainmail_boots"); And registered in my common proxy class like this: GameRegistry.registerItem(MagicBeans.bootsOfSafeFalling, "bootsOfSafeFalling"); What am I doing wrong? It's driving me crazy! Again, generally after exporting the JAR assets are working except for lang and mod logo, yet those files are in the JAR exactly where I expect them to be with same contents as Eclipse environment!
IPS spam blocked by CleanTalk.