Jump to content

robustus

Members
  • Posts

    151
  • Joined

  • Last visited

Everything posted by robustus

  1. I got the jump potion enabled through reflection, but can you explain the thing about the fields? For those interested, I added this code to my main mod file in FMLInitialization Item.itemsList[item.potion.itemID] = null; try { potion = (ItemPotion)(new NewItemPotion(117)).setIconCoord(13, .setItemName("potion"); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } Then in the NewItemPotion public class NewItemPotion extends ItemPotion { public NewItemPotion(int par1) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { super(par1); this.setMaxStackSize(1); this.setHasSubtypes(true); this.setMaxDamage(0); this.setCreativeTab(CreativeTabs.tabBrewing); Class PHelper = PotionHelper.class; Field f = PHelper.getDeclaredField("potionRequirements"); f.setAccessible(true); HashMap myPotionRequirements = (HashMap) f.get(null); myPotionRequirements.put(Integer.valueOf(Potion.jump.getId()), "0 & 1 & !2 & 3 & 0+6"); } } What do I have to worry about when the code is obfuscated?
  2. Ok I understand now the code with the bit operators for potions. Without reflection, I assume there is no other way to assign the Jump potion effect to one of the unused bit id's?
  3. Ive been racking my brain trying to figure out adding new potions myself. Im not a very experienced coder, so if someone could help me understand the code for this that would be great. From what I see this is the general code here: potionRequirements.put(Integer.valueOf(Potion.regeneration.getId()), "0 & !1 & !2 & !3 & 0+6"); sugarEffect = "-0+1-2-3&4-4+13"; Just not exactly sure what any of this is actually saying I'm looking to add a custom item that uses the Potion.jump effect. Also not sure how exactly to utilize reflection, where would that reflection code be placed, and could someone explain how that code actually works? Much appreciated.
  4. /** * Changes the block ID to that of an updating fluid. */ private void setNotStationary(World par1World, int par2, int par3, int par4) { int var5 = par1World.getBlockMetadata(par2, par3, par4); par1World.editingBlocks = true; par1World.setBlockAndMetadata(par2, par3, par4, this.blockID - 1, var5); par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4); par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID - 1, this.tickRate()); par1World.editingBlocks = false; } This is the code here in the stationary block and you can see it subtracts one from the stationary for the flowing
  5. liquid flowing block ID has to be 1 less than the still block.
  6. You need to use the Forge Event Hook FillBucketEvent and insert your code there
  7. I'm not an expert coder but I spent hours on this and I still haven't been able to get the custom sand to act like the regular sand even when I've copied it exactly and just changed the texture. The sand would disappear during most of the fall. I know the custom render was working because of tweaks to the file would change some variances of it, but the exact same code. Why the need to add a custom render and entity all to accomplish a custom falling block. Especially when you've looked around for help on the issue and EVERYONE seems to have a problem accomplishing this. It would be the slightest bit of change to the code would go miles.
  8. I'll take a look I just got in after being away all weekend. Im not sure why signs would be generated, what happens when you change your block your looking to place there with like gold ore just as a test.
  9. theres a forge hook in the replacebiomeblocks event someone posted sample of how to use it in another thread
  10. easiest way is to declare a new worldtype in post init you can also override default, when you declare the worldtype you link to a custom worldtype.class where you can specify a custom ChunkProviderGenerate which is the file you want to look at for most generation @PostInit public void postinitConfig(FMLPostInitializationEvent fmlpostinitializationevent) { WorldType DEFAULT = new WorldTypeCustom(0, "Default"); } then have WorldTypeCustom extend WorldType and add this @Override public IChunkProvider getChunkGenerator(World world, String generatorOptions) { return (this == FLAT ? new ChunkProviderFlat(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions) : new ChunkProviderCustom(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled())); } Copy the vanilla ChunkProviderGenerate into new classs ChunkProviderCustom and start tweaking
  11. Currently the only thing preventing easy creation of these blocks is the protected variable that loads minecrafts default texture file. The render for falling sand uses the proper sprite index but you need to add your own entity and render all just to get it to use a custom texture file and I have spent probably way too much time than its worth trying to get that to work with no avail. Adding a hook in the RenderFallingSand to be able to change the texture would be huge!!! Thanks.
  12. World Type is like Default, Large Biomes, Flat. You can add one or overwrite one. I havent dug deep into dimensions but you dont need to create a new world type to add your own dimension and use a custom chunk generator for the dimension, but if you want to use a custom chunk provider for the overworld you probably have to go the worldtype route.
  13. If you are using my exact code you need to specify the biome ID you want the code to work for, or you can take out the if biomeID check, then it will do it for all the biomes. If you want paste your code here Ill take a look at it. The way I got a custom chunk provider to work was I created a World type that overrides the default world type, or you can create a completely new world type, then you would create a new class like WorldTypeVoid and that is where you would specify the custom chunkprovider
  14. You need to create a new world type or overwrite the default and in the new WorldType.class you create you can specify a custom ChunkProviderGenerate - look at the default version that is where the generation is done.
  15. I moved the code out of the For loop, essentially taking 2 closing brackets above the code and taking away 2 after the code
  16. I think you have to push the code two brackets down. try this public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase) { byte var5 = 63; double var6 = 0.03125D; this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D); for (int var8 = 0; var8 < 16; ++var8) { for (int var9 = 0; var9 < 16; ++var9) { BiomeGenBase var10 = par4ArrayOfBiomeGenBase[var9 + var8 * 16]; float var11 = var10.getFloatTemperature(); int var12 = (int)(this.stoneNoise[var8 + var9 * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D); int var13 = -1; byte var14 = var10.topBlock; byte var15 = var10.fillerBlock; for (int var16 = 127; var16 >= 0; --var16) { int var17 = (var9 * 16 + var8) * 128 + var16; if (var16 <= 0 + this.rand.nextInt(5)) { par3ArrayOfByte[var17] = (byte)Block.bedrock.blockID; } else { byte var18 = par3ArrayOfByte[var17]; if (var18 == 0) { var13 = -1; } else if (var18 != Block.stone.blockID) { if (var13 == -1) { if (var12 == 0) { var14 = 0; var15 = (byte)Block.stone.blockID; } else if (var16 >= var5 - 4 && var16 <= var5 + 1) { var14 = var10.topBlock; var15 = var10.fillerBlock; } if (var16 < var5 && var14 == 0) { if (var11 < 0.15F) { var14 = (byte)Block.ice.blockID; } else { var14 = (byte)Block.waterStill.blockID; } } var13 = var12; if (var16 >= var5 - 1) { par3ArrayOfByte[var17] = var14; } else { par3ArrayOfByte[var17] = var15; } } else if (var13 > 0) { --var13; par3ArrayOfByte[var17] = var15; if (var13 == 0 && var15 == Block.sand.blockID) { var13 = this.rand.nextInt(4); var15 = (byte)Block.sandStone.blockID; } } } } byte var38 = par3ArrayOfByte[var17]; int var99 = var10.biomeID; if (var99 == 28){ //if height is greater than 60 and blocks are stone, replace with custom block if (var16 > 60 && var38 == Block.stone.blockID) { par3ArrayOfByte[var17] = (byte)TVMain.amStone.blockID; } } } } } }
  17. this code allowed me to replace all stone blocks in specific biome above a certain height. byte var38 = par3ArrayOfByte[var17]; int var99 = var10.biomeID; if (var99 == 28){ //if height is greater than 60 and blocks are stone, replace with custom block if (var16 > 60 && var38 == Block.stone.blockID) { par3ArrayOfByte[var17] = (byte)mod.customblock.blockID; } }
  18. The blocks you insert here need to be under the block ID 256 I believe for the byte storage which is being used.
  19. OK I figured out how to add custom biomes to the world type and also to have a custom world type overwrite the default so you can use custom chunk providers or chunk managers on the Default world type. Basically you need to call the new world type in a PostInit FMLPostInitialization event. If you want to overwrite Default, name it DEFAULT and number it 0 @PostInit public void postinitConfig(FMLPostInitializationEvent fmlpostinitializationevent) { WorldType DEFAULT = new WorldTypeCustom(0, "Default"); }
  20. Ive been unsuccessful trying to call the replace biome block forge event, but i have been able to create a new world type that uses a custom chunk provider, the only problem now Im running into is the custom biomes in my main mod file are not loading automatically into the custom world type, and when I try to add them via various code I am just getting the game hanging when creating a new world, anyone have any info on how to add custom biomes to custom world types?
  21. Hi all, I am somewhat of a novice at java and have been modding for a few months building up to more and more complicated things. I've been looking into the code to try and find the spot where I would be able to change the stone and blocks below the filler block and have found a Forge hook that I'm not sure how to use. I've found this portion of code in ChunkProviderGenerate /** * Replaces the stone that was placed in with blocks that match the biome */ public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase) { ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, par1, par2, par3ArrayOfByte, par4ArrayOfBiomeGenBase); MinecraftForge.EVENT_BUS.post(event); if (event.getResult() == Result.DENY) return; byte var5 = 63; double var6 = 0.03125D; this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D); for (int var8 = 0; var8 < 16; ++var8) { for (int var9 = 0; var9 < 16; ++var9) { BiomeGenBase var10 = par4ArrayOfBiomeGenBase[var9 + var8 * 16]; float var11 = var10.getFloatTemperature(); int var12 = (int)(this.stoneNoise[var8 + var9 * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D); int var13 = -1; byte var14 = var10.topBlock; byte var15 = var10.fillerBlock; for (int var16 = 127; var16 >= 0; --var16) { int var17 = (var9 * 16 + var8) * 128 + var16; if (var16 <= 0 + this.rand.nextInt(5)) { par3ArrayOfByte[var17] = (byte)Block.bedrock.blockID; } else { byte var18 = par3ArrayOfByte[var17]; if (var18 == 0) { var13 = -1; } else if (var18 == Block.stone.blockID) { if (var13 == -1) { if (var12 <= 0) { var14 = 0; var15 = (byte)Block.stone.blockID; } else if (var16 >= var5 - 4 && var16 <= var5 + 1) { var14 = var10.topBlock; var15 = var10.fillerBlock; } if (var16 < var5 && var14 == 0) { if (var11 < 0.15F) { var14 = (byte)Block.ice.blockID; } else { var14 = (byte)Block.waterStill.blockID; } } var13 = var12; if (var16 >= var5 - 1) { par3ArrayOfByte[var17] = var14; } else { par3ArrayOfByte[var17] = var15; } } else if (var13 > 0) { --var13; par3ArrayOfByte[var17] = var15; if (var13 == 0 && var15 == Block.sand.blockID) { var13 = this.rand.nextInt(4); var15 = (byte)Block.sandStone.blockID; } } } } } } } } So to me it looks like the code has a forge event where you can disable to the original replaceblocks code here and insert your own, so I found this code in the ChunkProviderEvent * This event is fired when a chunks blocks are replaced by a biomes top and * filler blocks. * * You can set the result to DENY to prevent the default replacement. */ @HasResult public static class ReplaceBiomeBlocks extends ChunkProviderEvent { public final int chunkX; public final int chunkZ; public final byte[] blockArray; public final BiomeGenBase[] biomeArray; public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int chunkX, int chunkZ, byte[] blockArray, BiomeGenBase[] biomeArray) { super(chunkProvider); this.chunkX = chunkX; this.chunkZ = chunkZ; this.blockArray = blockArray; this.biomeArray = biomeArray; } } Could anyone explain how I insert a hook that calls my own replaceblocksevent I am kinda at a loss for where to start? Any help would be greatly appreciated.
  22. Thanks for the help. It is definitely way too tedious for such a small aesthetic thing for me at this stage, perhaps I'll revisit when I run out of things to mod
  23. I figured that, but I can't find the code that makes that happen, anyone know where to look? Its not in BlockGrass.java
  24. Hi, I've had no problem creating a "grass" block, the only thing I haven't been able to find is how the vanilla grass block works in respect to the coloring of the grass. Grass is unique that only the side texture top portion is colored, and the grass color is not applied to the dirt texture underneath. I've copied the vanilla grass block code but when the grass is colored, it tints the side dirt texture as well, which is the kink im trying to iron out here. Right now I've just set the side texture to the top grass block, but I'd love to be able to have the side of my grass blocks have the dirt underneath like the Vanilla one. Anyone have a clue about this? Just to clarify I am not asking how to get a different texture to appear on the side of the block, merely just how the grass manages to only color the top portion of the block and not the dirt section of that texture
×
×
  • Create New...

Important Information

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