Jump to content

TheGreyGhost

Members
  • Posts

    3280
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by TheGreyGhost

  1. Hi Yes there is. The code from EntityLivingBase: protected void damageEntity(DamageSource par1DamageSource, float par2) { if (!this.isEntityInvulnerable()) { par2 = ForgeHooks.onLivingHurt(this, par1DamageSource, par2); if (par2 <= 0) return; par2 = this.applyArmorCalculations(par1DamageSource, par2); par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); float f1 = par2; par2 = Math.max(par2 - this.getAbsorbtion(), 0.0F); this.func_110149_m(this.getAbsorbtion() - (f1 - par2)); if (par2 != 0.0F) { float f2 = this.getHealth(); this.setEntityHealth(f2 - par2); this.func_110142_aN().func_94547_a(par1DamageSource, f2, par2); this.func_110149_m(this.getAbsorbtion() - par2); } } } If you use the Forge LivingHurtEvent (http://www.minecraftforum.net/topic/1419836-forge-4x-events-howto/), you can move the damage calculations into your own class and not perform the armour and potiondamagecalculations. -TGG
  2. Hi These links might help... http://www.minecraftforge.net/forum/index.php?topic=11963.0 Also http://www.minecraftforge.net/forum/index.php/topic,13355.msg69061.html#msg69061 (Apparently - when you're using Eclipse (which I'm not) you should put it into the SOURCE folder, wherever that is :-).) -TGG
  3. Hi No worries mate, we've all got to start somewhere and the documentation is a bit patchy to say the least :-) Put it in your GenericItem and GenericBlock as is, you'll need to replace "generic:picturename" with the name of your mod ("generic" in this case I think) and the name of the file you're using for the texture. If you're just starting out, this sample code might be helpful http://greyminecraftcoder.blogspot.com.au/2013/09/sample-code-for-rendering-items.html and especially https://github.com/TheGreyGhost/ItemRendering/blob/master/src/TestItemRendering/items/ItemSmileyFace.java https://github.com/TheGreyGhost/ItemRendering/blob/master/src/TestItemRendering/TestItemRenderingMod.java For now ignore all the bits that aren't ItemSmileyFace, they use more advanced rendering methods that you probably don't need yet... -TGG
  4. Ha, well-spotted dude! http://greyminecraftcoder.blogspot.com.au/2013/10/the-most-important-minecraft-classes_9.html -TGG
  5. Hi It looks like it should work. Do you know if onEntityCollidedWithBlock is being called or not? (i.e. using breakpoint or System.out.println -?) -TGG
  6. Hi You need to set the texture name for the blocks and the item. eg @Override public void registerIcons(IconRegister iconRegister) { itemIcon = iconRegister.registerIcon("generic:picturename"); } -TGG
  7. Hi It looks like it's trying to find code4240/alien/world/ChunkProviderDarwin but can't for some reason. Just a random guess as to why: either your path structure is wrong, or there is an upper case / lower case mismatch. Windows ignores upper/lower case in its file & folder names, but zip files don't, so what works fine in windows folders (i.e. from Eclipse) might not be found inside a zip. -TGG
  8. Hi Just a random guess: either your path structure is wrong, or there is an upper case / lower case mismatch. Windows ignores upper/lower case in its file & folder names, but zip files don't, so what works fine in windows folders (i.e. from Eclipse) might not be found inside a zip. -TGG
  9. Hi Vanilla uses this a lot in Minecraft.runTick() http://greyminecraftcoder.blogspot.com.au/2013/10/user-input.html this.currentScreen == null -TGG If you need more flexibility with intercepting the keybinding, this might also be of interest: https://gist.github.com/TheGreyGhost/7033821
  10. Hi Yes there is. Vanilla uses it a lot in Minecraft.runTick() http://greyminecraftcoder.blogspot.com.au/2013/10/user-input.html this.currentScreen == null -TGG
  11. Hi Packet132TileEntityData http://greyminecraftcoder.blogspot.com.au/2013/10/server-packets-changes-to-world-blocks.html -TGG
  12. Hi Your TileEntitySpecialRenderer is throwing an exception for some reason. I suggest adding a breakpoint in your renderTileEntityAt, or alternatively at the try statement in TileEntityRenderer. public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) { TileEntitySpecialRenderer tileentityspecialrenderer = this.getSpecialRendererForEntity(par1TileEntity); if (tileentityspecialrenderer != null) { try { tileentityspecialrenderer.renderTileEntityAt(par1TileEntity, par2, par4, par6, par8); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering Tile Entity"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Tile Entity Details"); par1TileEntity.func_85027_a(crashreportcategory); throw new ReportedException(crashreport); } } } Step through it until you see it throw, with any luck the cause will be obvious. -TGG
  13. Hi You mean - like harvesting wood gives the corresponding type of wood? Block.damageDropped(int metadata) overridden for BlockWood: public int damageDropped(int metaData) { return metaData; } -TGG
  14. Hi I don't understand your question, perhaps you could explain in more detail - what you want to see - what you are actually seeing -TGG
  15. Hi I'd suggest: (1) search for entities nearby. Discard any which are not nearby. (2) For each nearby entity, check whether its bounding box is intersected by the line of fire of the arrow (i.e. the bounding box has four vertical edges: if they are all to the left of your line of fire, or all to the right, then the arrow will miss. Otherwise it may hit. (3) optional: ray trace from the target entity to your mob, to see if there are any blocks in the way which would shield the entity from the arrow. I probably wouldn't bother with the ray trace myself, I suspect that in most cases it wouldn't actually make any difference and it's likely to be rather expensive to compute. Figuring out "left or right" requires a bit of vector math, not too hard if you've studied math, but let us know if you need a pointer in the right direction. Alternatively - you could just make your mob immune to its own arrows. Would be an awful lot easier. -TGG
  16. Hi That's odd I don't understand why this code System.out.println("getNorthBlock (" + (x-1) + "," + y + "," + z +"):" +world.getBlockId(x-1, y, z)); give this output 2013-11-03 10:07:11 [iNFO] [sTDOUT] getNorthBlock (113, 64, 436 and why System.out.println("getCableConnectings (" + x1 + "," + y1 + "," + z1 + "):" + direction); isn't printing anything. North of (114, 64, 436) is (114, 64, 435) not (113, 64, 436) The point of the logging was to see what the blockID is. But to be honest I think it would be time well-spent to tear up your ConnectingId class and rewrite it without the static variables. It might help make the cause of the bug clearer. -TGG
  17. Hi yeah it's a bit cryptic. Let's see if I can't adapt a bit of code I've used before... public class MyEventHandler { @ForgeSubscribe public void addMyCreature(WorldEvent.PotentialSpawns event) { World world = event.world; int xposition = event.x; int yposition = event.y; int zposition = event.z; EnumCreatureType creatureType = event.type; List<SpawnListEntry> listOfSpawnableCreatures = event.list; final int SPAWNWEIGHT = 5; // the higher the number, the more likely this creature will spawn final int MINIMUMNUMBERTOSPAWN = 1; final int MAXIMUMNUMBERTOSPAWN = 4; switch (creatureType) { case monster: { SpawnListEntry myNewCreatureSpawn = new SpawnListEntry(MyCreature.class, SPAWNWEIGHT, MINIMUMNUMBERTOSPAWN, MAXIMUMNUMBERTOSPAWN); listOfSpawnableCreatures.add(myNewCreatureSpawn); break; } case creature: case waterCreature: case ambient: default: } } } In my mod's base class @EventHandler public void load(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new MyEventHandler()); } I haven't actually run that code, but it should be pretty close to what you need. -TGG
  18. Hi Keen, that's what I thought you meant. You can get them to spawn naturally using the Forge event WorldEvent.PotentialSpawns Have you used Forge events before? A bit of an introduction here - http://www.minecraftforum.net/topic/1419836-131-forge-4x-events-howto/ -TGG -TGG
  19. Hi It worked because the LanguageRegistry uses the Block's unlocalized_name field to identify the Block. This is set by the this.setUnlocalizedName() in the Block's constructor. LanguageRegistry:: public void addNameForObject(Object objectToName, String lang, String name) { String objectName; if (objectToName instanceof Item) { objectName=((Item)objectToName).getUnlocalizedName(); } else if (objectToName instanceof Block) { objectName=((Block)objectToName).getUnlocalizedName(); } else if (objectToName instanceof ItemStack) { objectName=((ItemStack)objectToName).getItem().getUnlocalizedName((ItemStack)objectToName); } else { throw new IllegalArgumentException(String.format("Illegal object for naming %s",objectToName)); } objectName+=".name"; addStringLocalization(objectName, lang, name); i.e. objectName=((Block)objectToName).getUnlocalizedName(); // .... addStringLocalization(objectName, lang, name); So - if you don't set the unlocalizedname inside the Block, all three of your blocks have the same default unlocalizedname. So each time you add a new name eg LanguageRegistry.addName(jackolantern, BlockIds.JACKOLANTERN_NAME); it just overwrites the same spot in the LanguageRegistry. -TGG
  20. Hi Do you mean - they don't spawn randomly? Have a look in WorldServer.spawnRandomCreature - public SpawnListEntry spawnRandomCreature(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) { List list = this.getChunkProvider().getPossibleCreatures(par1EnumCreatureType, par2, par3, par4); list = ForgeEventFactory.getPotentialSpawns(this, par1EnumCreatureType, par2, par3, par4, list); return list != null && !list.isEmpty() ? (SpawnListEntry)WeightedRandom.getRandomItem(this.rand, list) : null; } It does a call to ForgeEventFactory.getPotentialSpawns (WorldEvent.PotentialSpawns) which I think will let you add your own creatures to the list of creatures provided by the vanilla code. -TGG
  21. Hi I had a quick look into getNBTTagCompound, which calls updateTagCompound, and it looks to me like it creates it a new one each time and fills it with values stored in WorldInfo. So you can add a key but it just gets thrown away at the end of your PlayerTick. Why do you want to store something in WorldInfo? Depending on what you want to do, .getAdditionalProperty and .setAdditionalProperty might be what you're looking for? -TGG
  22. Hi no worries dude :-) If it makes you feel any better I once wrestled with nearly exactly the same error for half a day before finally figuring it out... -TGG
  23. Hi Although the Minecraft.clickMouse(button) says "left and right buttons", exactly the same code is called for keyboard keys which have been mapped to the attack or use actions. In fact, if the right mouse button is clicked, it is converted to a "keyboard press" as the very first thing. For "eating" an item (or blocking a sword or similar) you might be interested in PlayerControllerMP.sendUseItem and Item.useItemRightClick For right clicks on blocks ForgeEventFactory.onPlayerInteract(RIGHT_CLICK_BLOCK) or Item.onItemFirstUse or Item.tryPlaceItemIntoWorld For right clicks on air ForgeEventFactory.onPlayerInteract(RIGHT_CLICK_AIR) You can see all these options and how they are called from Minecraft.clickMouse. -TGG
  24. Hi I'd suggest overriding the Block.getIcon(metadata,side) to return a different coloured icon depending on your biome. It will probably be a lot simpler. The grass colour modifier is embedded pretty deep in the vanilla code and I don't think it would be easy to selectively apply it to the top only. http://greyminecraftcoder.blogspot.com.au/2013/07/rendering-standard-blocks-cubes.html -TGG
  25. Hi Just guessing here - try FRAG instead of EnumToolMaterial.FRAG @EventHandler public void preInit(FMLPreInitializationEvent event) { EnumToolMaterial FRAG = EnumHelper.addToolMaterial("FRAG", 3, 59, 8.0F, 3.0F, 10); fragSword = new ItemFragSword(8003, FRAG) .setCreativeTab(CreativeTabs.tabCombat).setTextureName("mymod:fragsword").setUnlocalizedName("fragSword"); } -TGG
×
×
  • Create New...

Important Information

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