Jump to content

Bektor

Forge Modder
  • Posts

    852
  • Joined

  • Last visited

Everything posted by Bektor

  1. Check those lines in the constructor of your block: this.setLightLevel(4.0f/16.0f); this.setLightOpacity(16);
  2. Ok, I fixed those mistakes now. But for some reason it generates now only water... from level 1 to about 63 it generates only water and above only air. Level 0 is one layer of stone. There aren't even any hills etc. For the updated code, pls look at the top of the thread. Edited the main post there.
  3. Ok. double noise = 0; // breakpoint 1 for(int i = 0; i < 16; i++) for(int y = 0; i < 16; y++) noise = generateNewNoise(8, i, y, .5, 1); this.generateTerrain(x, z, primer, noise); // breakpoint 2 When I press F8 in eclipse to execute the code between breakpoint 1 and 2 it just stops... So I can stop then the complete application because it jumps out of the debug stuff (even when I click the button to run to the next breakpoint). So I think the problem is somewhere there in some code which works fine outside of Minecraft.
  4. Hi, I'm currently writing a complete world generator from scratch using OpenSimplexNoise, Minecraft 1.10.2 and Forge 12.18.1.2073 with Mappings snapshot_20160823. Now I ran into a problem: When I click on "Create New World" I can see the loading screen, but after that nothing happens.... It just freezes... Even when I click on the red "X" from the window nothing happens anymore.... and Windows does not show that the window isn't reacting anymore (I can even move the window... just not close it without task manager). The problem now: It does nothing... just stops doing anything in the creating world process... no error or crash-log. Here is the code: [spoiler=WorldType] public class PrimevalWorldType extends WorldType { private static PrimevalChunkManager chunkManager; public static TerrainGenerator terrainGenerator; public PrimevalWorldType(String name) { super(name); } @Override public BiomeProvider getBiomeProvider(World world) { if(world.provider.getDimension() == 0) { if(chunkManager == null) { chunkManager = new PrimevalChunkManager(Biomes.PLAINS); } return chunkManager; } return super.getBiomeProvider(world); } @Override public IChunkGenerator getChunkGenerator(World world, String generatorOptions) { if(world.provider.getDimension() == 0) { if(terrainGenerator == null) { terrainGenerator = new TerrainGenerator(world, world.getSeed()); return terrainGenerator; } } return super.getChunkGenerator(world, generatorOptions); } @Override public float getCloudHeight() { return 256.f; } } [spoiler=ChunkManager] public class PrimevalChunkManager extends BiomeProvider { /** The biome generator object. */ private final Biome biome; public PrimevalChunkManager(Biome biomeIn) { this.biome = biomeIn; } /** * Returns the biome generator */ public Biome getBiome(BlockPos pos) { return this.biome; } /** * Returns an array of biomes for the location input. */ public Biome[] getBiomesForGeneration(Biome[] biomes, int x, int z, int width, int height) { if (biomes == null || biomes.length < width * height) { biomes = new Biome[width * height]; } Arrays.fill(biomes, 0, width * height, this.biome); return biomes; } /** * Gets biomes to use for the blocks and loads the other data like temperature and humidity onto the * WorldChunkManager. */ public Biome[] getBiomes(@Nullable Biome[] oldBiomeList, int x, int z, int width, int depth) { if (oldBiomeList == null || oldBiomeList.length < width * depth) { oldBiomeList = new Biome[width * depth]; } Arrays.fill(oldBiomeList, 0, width * depth, this.biome); return oldBiomeList; } /** * Gets a list of biomes for the specified blocks. */ public Biome[] getBiomes(@Nullable Biome[] listToReuse, int x, int z, int width, int length, boolean cacheFlag) { return this.getBiomes(listToReuse, x, z, width, length); } @Nullable public BlockPos findBiomePosition(int x, int z, int range, List<Biome> biomes, Random random) { return biomes.contains(this.biome) ? new BlockPos(x - range + random.nextInt(range * 2 + 1), 0, z - range + random.nextInt(range * 2 + 1)) : null; } /** * checks given Chunk's Biomes against List of allowed ones */ public boolean areBiomesViable(int x, int z, int radius, List<Biome> allowed) { return allowed.contains(this.biome); } } [spoiler=TerrainGenerator] public class TerrainGenerator implements IChunkGenerator { private Random random; private World world; private OpenSimplexNoise simplex; public TerrainGenerator(World world, long seed) { this.world = world; this.random = new Random(seed); this.simplex = new OpenSimplexNoise(seed); } @Override public Chunk provideChunk(int x, int z) { random.setSeed((long) x * 341873128712l + (long) z * 132897987541l); ChunkPrimer primer = new ChunkPrimer(); double noise = 0; for(int i = 0; i < 16; i++) for(int y = 0; i < 16; y++) noise = generateNewNoise(8, i, y, .5, 1); this.generateTerrain(x, z, primer, noise); // store in the process pile Chunk chunk = new Chunk(this.world, primer, x, z); chunk.generateSkylightMap(); Biome[] abiome = this.world.getBiomeProvider().getBiomes((Biome[])null, x * 16, z * 16, 16, 16); byte[] abyte = chunk.getBiomeArray(); for (int i1 = 0; i1 < abyte.length; ++i1) { abyte[i1] = (byte)Biome.getIdForBiome(abiome[i1]); } chunk.generateSkylightMap(); return chunk; } private double generateNewNoise(int iterations, int x, int z, double persistence, double scale) { double maxAmp = 0; double amp = 1; double freq = scale; double noise = 0; // add successively smaller, higher-frequency terms // each iteration is called an octave, because it is twice the frequency of the iteration before it for(int i = 0; i < iterations; ++i) { // iterations = number of octaves for(int y = 1; y < 230; y++) { noise += simplex.eval(x * freq, y * freq, z * freq) * amp; maxAmp += amp; amp += 1/(2^iterations); //*= persistence; freq *= 2; } } // take the average value of the iterations noise /= maxAmp; // normalize the result //noise = noise * (high - low) / 2 + (high + low) / 2; return noise; } public void generateTerrain(int x, int z, ChunkPrimer primer, double noise) { for(int i = 0; i < 16; i++) { // x-axis for(int y = 0; i < 16; y++) { // z-axis for(int k = 0; k < 256; k++) { // y-axis if(k > noise) { if(k < 63) primer.setBlockState(i, k, y, Blocks.WATER.getDefaultState()); else primer.setBlockState(i, k, y, Blocks.AIR.getDefaultState()); } else primer.setBlockState(i, k, y, Blocks.STONE.getDefaultState()); } } } } @Override public void populate(int x, int z) { // TODO Auto-generated method stub } @Override public boolean generateStructures(Chunk chunkIn, int x, int z) { // TODO Auto-generated method stub return false; } @Override public List<SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { // TODO Auto-generated method stub return null; } @Override public BlockPos getStrongholdGen(World worldIn, String structureName, BlockPos position) { // TODO Auto-generated method stub return null; } @Override public void recreateStructures(Chunk chunkIn, int x, int z) { // TODO Auto-generated method stub } } For anyone who now thinks the generateNewNoise method does not work... it works perfectly. I tested the whole noise generating stuff outside of MC in a small test project and got some nice looking bitmaps out of it. Only when trying to put that whole stuff into the MC "API" it stops working... and I get nothing... I haven't written much extra code yet, because I first want to have it working and see how the world looks and modify it until it looks nice before I want to add biomes and GenLayer stuff and a lot of other stuff, because then it's easier to fix problems and find them and change stuff as it would be when having a dozen of classes and thousands of lines of code..... I hope someone can help me with this complex stuff... And I would like any explanation which is possible, because it took me even some month to get the knowledge to get it working outside of Minecraft (even when I don't know the math in the OpenSimplexNoise algorythm). Thx in advance. Bektor EDIT: Now it generates only water from layer 1 to about 63 and everything above is air and layer 0 is stone. So no hills and just water... Here is the updated code: [spoiler=TerrainGenerator] public class TerrainGenerator implements IChunkGenerator { private Random random; private World world; private OpenSimplexNoise simplex; private double[] noise = new double[256]; public TerrainGenerator(World world, long seed) { this.world = world; this.random = new Random(seed); this.simplex = new OpenSimplexNoise(seed); } @Override public Chunk provideChunk(int x, int z) { random.setSeed((long) x * 341873128712l + (long) z * 132897987541l); ChunkPrimer primer = new ChunkPrimer(); for(int i = 0; i < 16; i++) for(int y = 0; y < 16; y++) { noise[i * 16 + y] = 0.d; noise[i * 16 + y] = generateNewNoise(8, i, y, .5, 1); } this.generateTerrain(x, z, primer, noise); // store in the process pile Chunk chunk = new Chunk(this.world, primer, x, z); chunk.generateSkylightMap(); Biome[] abiome = this.world.getBiomeProvider().getBiomes((Biome[])null, x * 16, z * 16, 16, 16); byte[] abyte = chunk.getBiomeArray(); for (int i1 = 0; i1 < abyte.length; ++i1) { abyte[i1] = (byte)Biome.getIdForBiome(abiome[i1]); } chunk.generateSkylightMap(); return chunk; } private double generateNewNoise(int iterations, int x, int z, double persistence, double scale) { double maxAmp = 0; double amp = 1; double freq = scale; double noise = 0; // add successively smaller, higher-frequency terms // each iteration is called an octave, because it is twice the frequency of the iteration before it for(int i = 0; i < iterations; ++i) { // iterations = number of octaves for(int y = 1; y < 230; y++) { noise += simplex.eval(x * freq, y * freq, z * freq) * amp; maxAmp += amp; amp += 1/(2^iterations); //*= persistence; freq *= 2; } } // take the average value of the iterations noise /= maxAmp; // normalize the result //noise = noise * (high - low) / 2 + (high + low) / 2; return noise; } public void generateTerrain(int x, int z, ChunkPrimer primer, double[] noise) { int height; for(int i = 0; i < 16; i++) { // x-axis for(int y = 0; y < 16; y++) { // z-axis height = (int) noise[y * 16 + i]; for(int k = 0; k < 256; k++) { // y-axis if(k > height) { if(k < 63) primer.setBlockState(i, k, y, Blocks.WATER.getDefaultState()); else primer.setBlockState(i, k, y, Blocks.AIR.getDefaultState()); } else primer.setBlockState(i, k, y, Blocks.STONE.getDefaultState()); } } } } @Override public void populate(int x, int z) { // TODO Auto-generated method stub } @Override public boolean generateStructures(Chunk chunkIn, int x, int z) { // TODO Auto-generated method stub return false; } @Override public List<SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { // TODO Auto-generated method stub return null; } @Override public BlockPos getStrongholdGen(World worldIn, String structureName, BlockPos position) { // TODO Auto-generated method stub return null; } @Override public void recreateStructures(Chunk chunkIn, int x, int z) { // TODO Auto-generated method stub } }
  5. Ah, ok. Didn't know about that one. But isn't there a other option, like a option to set it in one of the files from gradlew itself? Would not require me to setup these variable each time I'm starting the PC because someone thought they have to be resetted every start-up.
  6. Well, but this would not work on most other PCs. It would require admin rights which I don't have on those PCs... on one I even can't open the "Systemsteuerung". And it wasn't shown as I searched. Maybe your keywords were better then mine.
  7. Well, a tutorial found on google told me that: "Select Window -> Preferences and type "Gradle" in filter box." Which basically results in nothing. And if you mean the environment variables from windows where I set the JAVA_HOME stuff, that would not work on the other PCs.
  8. If this is the case you won't be able to develop on those computers either. Well, I can do modding on most of those PCs, but I can't setup gradle there.... (Java settings are the problem there and I don't have access on these machines to change them so that I can install gradle OR the PC is so slow in decompiling and recompiling.... and when then the WLAN in for example school breaks away.....) How do I set the 'GRADLE_USER_HOME' variable?
  9. Hi, I'm wondering how I can get my mod workspace portable, so I can install it on a stick and work on my mod on any PC. Currently I've got there the problem that I have to execute the "setupDecompWorkspace" again and again and that is not on all PC's possible because some do not have the processing power or the incorrect java version etc..... I've got already eclipse installed on my USB stick. I hope someone can help me with this. Thx in advance. Bektor
  10. Thx. That's what I was searching for.
  11. Is there a way to get the exact number of sub-blocks without having to give it the method as a parameter? So before the for-loop runs the method identifies how much sub-blocks need to be registered.
  12. My question is: How can I register the block and all sub-blocks for rendering once instead of having to register every sub-block manual. I've got some blocks with a metadata from 0 to 15 and I don't want to call 16 times the method to register the ItemBlock rendering and to register the Block rendering. I'm searching for a way where I can call one method and this method registers the item block and block rendering for all 16 sub-blocks and this method should even work with just having 14 sub-blocks or 10 sub-blocks etc. and for every block .
  13. Solution: ItemBlock has to be registered to be rendered extra.
  14. Hi, I'm wondering if there is a way to register the inventory and world renderer for a block and all it sub-blocks with just having to call the method which registers the block ONCE. It should also work for all blocks, if they are using normal item blocks or custom ones should not matter and it should not matter which block it is. It's really not the best solution to have to call the render register method for all blocks and all sub-blocks again and again. Thx in advance. Bektor
  15. Ok, but it does still not render correctly in the inventory and in the hand. ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(BlockList.modSand), 0, new ModelResourceLocation(BlockList.modSand.getRegistryName(), "inventory")); And yeah, it's actually a sand block with a grass texture because I've got no other texture yet. EDIT: That's all what the log says. It shows this error two times.
  16. Ok, then I'm wondering why it is not rendering in the inventory (just shows a missing texture plane there, in the world it renders correctly): { "forge_marker": 1, "defaults": { "textures": { "all": "primevalforest:blocks/grass_top" } }, "variants": { "normal": { "model": "cube_all" }, "inventory": { "model": "cube_all" } } } And for these normal blocks: Do I still have to do this: Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), meta, new ModelResourceLocation(block.getRegistryName(), "inventory")); Or can I remove that line of code?
  17. Well, currently I'm only using the standard block model with a different texture for my blocks.
  18. Hi, I'm currently looking into the Forge json file system, (so the ones with "forge_marker": 1) cause I was using always the vanilla system but now I want to use the forge one. So I've got one question: For the Forge json system, do I still need the jsons in models.block and models.item? Thx in advance. Bektor
  19. So there is no way to just have one property field which will be set for each block? Because I don't like the idea of having to have them static, because when I have 32 wood types I need 2 classes and then I would need all the code in methods like updateTick() which can get large again.... and I'm not the fan of C&P code from class A to B. I mean, it was the main idea behind making the class abstract that I don't need to copy over my fast leave decay stuff to all classes because it requires the block metadata, so the property field to work.
  20. Hi, I've got a huge problem when creating my own leaves block with a property enum which stores all types of leaves and woods. It always results into a NullPointerException and I don't know what's wrong. Here the crash: Besides: I'm using Forge 1.9.4 with Java 8. BlockLeaves.java package minecraftplaye.primevalforest.common.blocks; import minecraftplaye.primevalforest.api.types.WoodType; import minecraftplaye.primevalforest.common.blocks.core.BlockBaseLeaves; import net.minecraft.block.properties.PropertyEnum; public class BlockLeaves extends BlockBaseLeaves { public static PropertyEnum<WoodType> META_PROPERTY = PropertyEnum.create("wood", WoodType.class/*, Arrays.copyOfRange(WoodType.values(), 0, 0)*/); public BlockLeaves() { super(META_PROPERTY); } } Block Base Leaves (the lines and methods marked in the crash log and the constructor): public abstract class BlockBaseLeaves extends BlockLeaves implements IShearable { protected final PropertyEnum<WoodType> META_PROP; public BlockBaseLeaves(PropertyEnum<WoodType> META_PROPERTY) { super(); this.META_PROP = META_PROPERTY; this.setLightOpacity(1); this.setTickRandomly(true); this.setTickRandomly(true); this.setSoundType(SoundType.PLANT); this.setCreativeTab(ModCreativeTabs.primevalTab); } The complete stuff is in the order of the crash log: @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {META_PROP}); } public BlockBaseLeaves(PropertyEnum<WoodType> META_PROPERTY) { super(); Here are all methods which have something to do with the meta data: @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {META_PROP}); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(META_PROP, WoodType.getTypeFromID(meta)); } @Override public int getMetaFromState(IBlockState state) { return ((WoodType) state.getValue(META_PROP)).getID(); } @Override public EnumType getWoodType(int meta) { return null; } @Override public int damageDropped(IBlockState state) { return ((WoodType) state.getValue(META_PROP)).getID(); } My WoodType enum is currently filled with just 2 values: public enum WoodType implements IStringSerializable { // ID, name, Modulus of Rupture, Dried Weight Oak(0, "oak", 47.f), TEST(1, "test", 35.f); private final float driedWeight; private WoodType(int ID, String name, float driedWeight) { this.ID = ID; this.name = name; this.driedWeight = driedWeight / 10; } public static WoodType getTypeFromID(int ID) { for(int i = 0; i < WoodType.values().length; i++) { if(WoodType.values()[i].getID() == ID) return WoodType.values()[i]; } return null; } There are also getters for all values of the class. I hope someone can help me with this. Thx in advance. Bektor
  21. Well, I'm not going to learn some stupid old OpenGL 2.1.... why should I? For anything which is not called Minecraft I would have to re-learn nearly everything! And I'm currently learning modern OpenGL (3.3+), even when the book I've got is for OpenGL 4.5. And you can't just learn from such classes when there is nearly no comment or javadoc stuff that easily. And even when there would be it would take a very long time. I even saw code where textures where drawn, but it wasn't 1.9 code and because I've got no idea how to port that code over and because I don't know which coordinates and all of that stuff I have to use for that what I want...... I'm trying to do it know with OpenGL 4.5! Don't care how many people might not have OpenGL 4.5. Seems no other way which makes fun... and isn't frustrating....
  22. The hell you don't. Gui#drawTexturedModalRect If your class extends anything that inherits from Gui then you have drawTexturedModalRect. Well, but my class does NOT inherits from Gui. It's an ENTITY, not an Gui. I'm inheriting from Render.
  23. You can even use drawTexturedModalRect from Gui class. Just make sure you translate/scale/rotate to right position in world. Or draw simple boxes or panes (drawRect), or anything really. Well, I don't have access to the method drawTexturedModalRect from the GUI class. And just copy it into my render class would not work because I don't have access to all variables. And I don't think I would need stuff like textureX, textureY, width and height.
  24. Ok, there is just one problem. The snowball class is using the RenderItem thing to render it, but I've got no item to be rendered, because my Entity is not an item.
×
×
  • Create New...

Important Information

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