Jump to content

TLHPoE

Members
  • Posts

    638
  • Joined

  • Last visited

Everything posted by TLHPoE

  1. Hello, I have a double (ranges from 0 to 1) that represents my alpha channel, and then I use the GL11#glColor4d method to change the alpha channel. Afterwards, my text is drawn. The problem is the translucency of the text drawn never changes. The first time it gets drawn it should be barely visible, but instead it looks like it has no alpha channel. Code: Minecraft mc = MCUtil.getMC(); ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); int y = (sr.getScaledHeight() / 4) - (CHAR_HEIGHT * (text.size() - 1)), x = sr.getScaledWidth() / 2; GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glAlphaFunc(GL11.GL_GREATER, 0.002F); GL11.glColor4d(1D, 1D, 1D, alpha); for(String s : text) { RenderUtil.drawString(s, x - (getTextWidth(s) / 2), y, 0xFFFFFF); y += CHAR_HEIGHT; } GL11.glPopMatrix(); Edit: I switched to using bit operations to attach an alpha to the hex colors. int hexAlpha = (int) (255 * alpha) << 24, c1 = 0xFFFF00, c2 = 0x000000; c1 += hexAlpha; c2 += hexAlpha;
  2. Hello, Is there any way to prevent a biome from spawning? Specifically the river biome? This is what I currently have: BiomeManager.coolBiomes.clear(); BiomeManager.desertBiomes.clear(); BiomeManager.icyBiomes.clear(); BiomeManager.oceanBiomes.clear(); BiomeManager.strongHoldBiomes.clear(); BiomeManager.warmBiomes.clear(); BiomeManager.removeSpawnBiome(BiomeGenBase.river); I'm using a custom chunk manager, chunk provider, gen layer, and provider using a custom world type to override the first 3 and using reflection to replace the 4th.
  3. Hi, I just picked up a mod that I started about a year ago and updated it to 1.7.10. Everything is working as it's suppose to, except for one thing. All the biomes are wrong. In my mod, I'm aiming for a sort of pseudo-limited world, where there's only so much of each biome to explore. When you go too far out, the only thing you'll see is ocean. The order is (from spawn outwards): -My custom forest -Vanilla forest -Desert -Taiga hills -Ocean -Deep ocean But in reality, the order is: -Mushroom island -Ice plains and cold taiga -A combination of forest, roofed forest, plains, extreme hills, swamp land, and birch forest (wtf) -Mushroom island (again?) -Ocean -Deep ocean Also, this is what the supposed "ocean" and "deep ocean" biomes look like: I haven't really grasped what happens during world generation, but my guess is that my biome is incompatible somehow and the combinations are due to the temperature functions trying to add in all the biomes that are compatible with each other. What I've tried is to override the getModdedBiomeGenerators method in my WorldChunkManager and just return the original array, but that didn't change anything. Finally, here's my code: WorldTypeT: package terrarium.world; import net.minecraft.world.World; import net.minecraft.world.WorldType; import net.minecraft.world.biome.WorldChunkManager; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.layer.GenLayer; public class WorldTypeT extends WorldType { public int size; public WorldTypeT(int size) { super("SIZE" + size); this.size = size; } } WorldProviderT: package terrarium.world; import net.minecraft.world.WorldProvider; import net.minecraft.world.chunk.IChunkProvider; public class WorldProviderT extends WorldProvider { @Override protected void registerWorldChunkManager() { this.worldChunkMgr = new WorldChunkManagerT(this.getSeed(), (WorldTypeT) this.terrainType); } @Override public IChunkProvider createChunkGenerator() { return new ChunkProviderT(this.worldObj, this.getSeed()); } @Override public String getDimensionName() { return "Overworld"; } } WorldChunkManagerT: package terrarium.world; import java.util.ArrayList; import java.util.Arrays; import net.minecraft.world.WorldType; import net.minecraft.world.biome.BiomeCache; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.WorldChunkManager; import net.minecraft.world.gen.layer.GenLayer; import terrarium.util.Util; import terrarium.world.biome.Biomes; public class WorldChunkManagerT extends WorldChunkManager { public WorldChunkManagerT(long seed, WorldTypeT worldType) { super(seed, worldType); GenLayer pre = (GenLayer) Util.getFieldValue("genBiomes", WorldChunkManager.class, this); pre = GenLayerBiomeT.getLayer(seed, pre, worldType); Util.replaceField("genBiomes", WorldChunkManager.class, pre, this); Util.replaceField("biomeIndexLayer", WorldChunkManager.class, pre, this); System.err.println("YOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"); allowedBiomes = new ArrayList<BiomeGenBase>(Arrays.asList(Biomes.forest, BiomeGenBase.desert)); Util.replaceField("biomeCache", WorldChunkManager.class, new BiomeCache(this), this); } @Override public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original) { return original; } } ChunkProviderT: package terrarium.world; import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.util.IProgressUpdate; import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkPosition; import net.minecraft.world.SpawnerAnimals; import net.minecraft.world.World; import net.minecraft.world.WorldType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.MapGenBase; import net.minecraft.world.gen.MapGenCaves; import net.minecraft.world.gen.NoiseGenerator; import net.minecraft.world.gen.NoiseGeneratorOctaves; import net.minecraft.world.gen.NoiseGeneratorPerlin; import net.minecraft.world.gen.feature.WorldGenDungeons; import net.minecraft.world.gen.feature.WorldGenLakes; import net.minecraft.world.gen.structure.MapGenStronghold; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.ChunkProviderEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; import cpw.mods.fml.common.eventhandler.Event.Result; public class ChunkProviderT implements IChunkProvider { private Random r; private NoiseGeneratorOctaves noiseGen1; private NoiseGeneratorOctaves noiseGen2; private NoiseGeneratorOctaves noiseGen3; private NoiseGeneratorPerlin perlinGen; public NoiseGeneratorOctaves terrainGen1; public NoiseGeneratorOctaves terrainGen2; public NoiseGeneratorOctaves mobSpawnerNoise; private World world; private WorldType worldType; private final double[] noiseField; private final float[] parabolicField; private double[] stoneNoise = new double[256]; private MapGenBase caveGenerator = new MapGenCaves(); private MapGenStronghold strongholdGenerator = new MapGenStronghold(); private BiomeGenBase[] biomesForGeneration; double[] noiseField1; double[] noiseField2; double[] noiseField3; double[] terrainNoiseField2; { caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE); strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD); } public ChunkProviderT(World world, long seed) { this.world = world; worldType = world.getWorldInfo().getTerrainType(); r = new Random(seed); noiseGen1 = new NoiseGeneratorOctaves(r, 16); noiseGen2 = new NoiseGeneratorOctaves(r, 16); noiseGen3 = new NoiseGeneratorOctaves(r, ; perlinGen = new NoiseGeneratorPerlin(r, 4); terrainGen1 = new NoiseGeneratorOctaves(r, 10); terrainGen2 = new NoiseGeneratorOctaves(r, 16); mobSpawnerNoise = new NoiseGeneratorOctaves(r, ; noiseField = new double[825]; parabolicField = new float[25]; for(int j = -2; j <= 2; ++j) { for(int k = -2; k <= 2; ++k) { float f = 10.0F / MathHelper.sqrt_float((float) (j * j + k * k) + 0.2F); parabolicField[j + 2 + (k + 2) * 5] = f; } } NoiseGenerator[] noiseGens = { noiseGen1, noiseGen2, noiseGen3, perlinGen, terrainGen1, terrainGen2, mobSpawnerNoise }; noiseGens = TerrainGen.getModdedNoiseGenerators(world, r, noiseGens); noiseGen1 = (NoiseGeneratorOctaves) noiseGens[0]; noiseGen2 = (NoiseGeneratorOctaves) noiseGens[1]; noiseGen3 = (NoiseGeneratorOctaves) noiseGens[2]; perlinGen = (NoiseGeneratorPerlin) noiseGens[3]; terrainGen1 = (NoiseGeneratorOctaves) noiseGens[4]; terrainGen2 = (NoiseGeneratorOctaves) noiseGens[5]; mobSpawnerNoise = (NoiseGeneratorOctaves) noiseGens[6]; } public void fillBlockArray(int p_147424_1_, int p_147424_2_, Block[] p_147424_3_) { byte b0 = 63; biomesForGeneration = world.getWorldChunkManager().getBiomesForGeneration(biomesForGeneration, p_147424_1_ * 4 - 2, p_147424_2_ * 4 - 2, 10, 10); func_147423_a(p_147424_1_ * 4, 0, p_147424_2_ * 4); for(int k = 0; k < 4; ++k) { int l = k * 5; int i1 = (k + 1) * 5; for(int j1 = 0; j1 < 4; ++j1) { int k1 = (l + j1) * 33; int l1 = (l + j1 + 1) * 33; int i2 = (i1 + j1) * 33; int j2 = (i1 + j1 + 1) * 33; for(int k2 = 0; k2 < 32; ++k2) { double d0 = 0.125D; double d1 = noiseField[k1 + k2]; double d2 = noiseField[l1 + k2]; double d3 = noiseField[i2 + k2]; double d4 = noiseField[j2 + k2]; double d5 = (noiseField[k1 + k2 + 1] - d1) * d0; double d6 = (noiseField[l1 + k2 + 1] - d2) * d0; double d7 = (noiseField[i2 + k2 + 1] - d3) * d0; double d8 = (noiseField[j2 + k2 + 1] - d4) * d0; for(int l2 = 0; l2 < 8; ++l2) { double d9 = 0.25D; double d10 = d1; double d11 = d2; double d12 = (d3 - d1) * d9; double d13 = (d4 - d2) * d9; for(int i3 = 0; i3 < 4; ++i3) { int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2; short short1 = 256; j3 -= short1; double d14 = 0.25D; double d16 = (d11 - d10) * d14; double d15 = d10 - d16; for(int k3 = 0; k3 < 4; ++k3) { if((d15 += d16) > 0.0D) { p_147424_3_[j3 += short1] = Blocks.stone; } else if(k2 * 8 + l2 < b0) { p_147424_3_[j3 += short1] = Blocks.water; } else { p_147424_3_[j3 += short1] = null; } } d10 += d12; d11 += d13; } d1 += d5; d2 += d6; d3 += d7; d4 += d8; } } } } } public void replaceBlocksForBiome(int p_147422_1_, int p_147422_2_, Block[] p_147422_3_, byte[] p_147422_4_, BiomeGenBase[] p_147422_5_) { ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147422_1_, p_147422_2_, p_147422_3_, p_147422_4_, p_147422_5_, world); MinecraftForge.EVENT_BUS.post(event); if(event.getResult() == Result.DENY) { return; } double d0 = 0.03125D; stoneNoise = perlinGen.func_151599_a(stoneNoise, (double) (p_147422_1_ * 16), (double) (p_147422_2_ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); for(int k = 0; k < 16; ++k) { for(int l = 0; l < 16; ++l) { BiomeGenBase biomegenbase = p_147422_5_[l + k * 16]; biomegenbase.genTerrainBlocks(world, r, p_147422_3_, p_147422_4_, p_147422_1_ * 16 + k, p_147422_2_ * 16 + l, stoneNoise[l + k * 16]); } } } public Chunk loadChunk(int p_73158_1_, int p_73158_2_) { return provideChunk(p_73158_1_, p_73158_2_); } public Chunk provideChunk(int p_73154_1_, int p_73154_2_) { r.setSeed((long) p_73154_1_ * 341873128712L + (long) p_73154_2_ * 132897987541L); Block[] ablock = new Block[65536]; byte[] abyte = new byte[65536]; fillBlockArray(p_73154_1_, p_73154_2_, ablock); biomesForGeneration = world.getWorldChunkManager().loadBlockGeneratorData(biomesForGeneration, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16); replaceBlocksForBiome(p_73154_1_, p_73154_2_, ablock, abyte, biomesForGeneration); caveGenerator.func_151539_a(this, world, p_73154_1_, p_73154_2_, ablock); strongholdGenerator.func_151539_a(this, world, p_73154_1_, p_73154_2_, ablock); Chunk chunk = new Chunk(world, ablock, abyte, p_73154_1_, p_73154_2_); byte[] abyte1 = chunk.getBiomeArray(); for(int k = 0; k < abyte1.length; ++k) { abyte1[k] = (byte) biomesForGeneration[k].biomeID; } chunk.generateSkylightMap(); return chunk; } private void func_147423_a(int p_147423_1_, int p_147423_2_, int p_147423_3_) { double d0 = 684.412D; double d1 = 684.412D; double d2 = 512.0D; double d3 = 512.0D; terrainNoiseField2 = terrainGen2.generateNoiseOctaves(terrainNoiseField2, p_147423_1_, p_147423_3_, 5, 5, 200.0D, 200.0D, 0.5D); noiseField1 = noiseGen1.generateNoiseOctaves(noiseField1, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); noiseField2 = noiseGen2.generateNoiseOctaves(noiseField2, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); noiseField3 = noiseGen3.generateNoiseOctaves(noiseField3, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); boolean flag1 = false; boolean flag = false; int l = 0; int i1 = 0; double d4 = 8.5D; for(int j1 = 0; j1 < 5; ++j1) { for(int k1 = 0; k1 < 5; ++k1) { float f = 0.0F; float f1 = 0.0F; float f2 = 0.0F; byte b0 = 2; BiomeGenBase biomegenbase = biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; for(int l1 = -b0; l1 <= b0; ++l1) { for(int i2 = -b0; i2 <= b0; ++i2) { BiomeGenBase biomegenbase1 = biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; float f3 = biomegenbase1.rootHeight; float f4 = biomegenbase1.heightVariation; if(worldType == WorldType.AMPLIFIED && f3 > 0.0F) { f3 = 1.0F + f3 * 2.0F; f4 = 1.0F + f4 * 4.0F; } float f5 = parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F); if(biomegenbase1.rootHeight > biomegenbase.rootHeight) { f5 /= 2.0F; } f += f4 * f5; f1 += f3 * f5; f2 += f5; } } f /= f2; f1 /= f2; f = f * 0.9F + 0.1F; f1 = (f1 * 4.0F - 1.0F) / 8.0F; double d12 = terrainNoiseField2[i1] / 8000.0D; if(d12 < 0.0D) { d12 = -d12 * 0.3D; } d12 = d12 * 3.0D - 2.0D; if(d12 < 0.0D) { d12 /= 2.0D; if(d12 < -1.0D) { d12 = -1.0D; } d12 /= 1.4D; d12 /= 2.0D; } else { if(d12 > 1.0D) { d12 = 1.0D; } d12 /= 8.0D; } ++i1; double d13 = (double) f1; double d14 = (double) f; d13 += d12 * 0.2D; d13 = d13 * 8.5D / 8.0D; double d5 = 8.5D + d13 * 4.0D; for(int j2 = 0; j2 < 33; ++j2) { double d6 = ((double) j2 - d5) * 12.0D * 128.0D / 256.0D / d14; if(d6 < 0.0D) { d6 *= 4.0D; } double d7 = noiseField1[l] / 512.0D; double d8 = noiseField2[l] / 512.0D; double d9 = (noiseField3[l] / 10.0D + 1.0D) / 2.0D; double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6; if(j2 > 29) { double d11 = (double) ((float) (j2 - 29) / 3.0F); d10 = d10 * (1.0D - d11) + -10.0D * d11; } noiseField[l] = d10; ++l; } } } } public boolean chunkExists(int p_73149_1_, int p_73149_2_) { return true; } public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) { BlockFalling.fallInstantly = true; int k = p_73153_2_ * 16; int l = p_73153_3_ * 16; BiomeGenBase biomegenbase = world.getBiomeGenForCoords(k + 16, l + 16); r.setSeed(world.getSeed()); long i1 = r.nextLong() / 2L * 2L + 1L; long j1 = r.nextLong() / 2L * 2L + 1L; r.setSeed((long) p_73153_2_ * i1 + (long) p_73153_3_ * j1 ^ world.getSeed()); boolean flag = false; MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, world, r, p_73153_2_, p_73153_3_, flag)); strongholdGenerator.generateStructuresInChunk(world, r, p_73153_2_, p_73153_3_); int k1; int l1; int i2; biomegenbase.decorate(world, r, k, l); if(TerrainGen.populate(p_73153_1_, world, r, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS)) { SpawnerAnimals.performWorldGenSpawning(world, biomegenbase, k + 8, l + 8, 16, 16, r); } k += 8; l += 8; boolean doGen = TerrainGen.populate(p_73153_1_, world, r, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE); for(k1 = 0; doGen && k1 < 16; ++k1) { for(l1 = 0; l1 < 16; ++l1) { i2 = world.getPrecipitationHeight(k + k1, l + l1); if(world.isBlockFreezable(k1 + k, i2 - 1, l1 + l)) { world.setBlock(k1 + k, i2 - 1, l1 + l, Blocks.ice, 0, 2); } if(world.func_147478_e(k1 + k, i2, l1 + l, true)) { world.setBlock(k1 + k, i2, l1 + l, Blocks.snow_layer, 0, 2); } } } MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, world, r, p_73153_2_, p_73153_3_, flag)); BlockFalling.fallInstantly = false; } public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_) { return true; } public void saveExtraData() { } public boolean unloadQueuedChunks() { return false; } public boolean canSave() { return true; } public String makeString() { return "RandomLevelSource"; } public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, int p_73155_4_) { return world.getBiomeGenForCoords(p_73155_2_, p_73155_4_).getSpawnableList(p_73155_1_); } public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) { return "Stronghold".equals(p_147416_2_) && strongholdGenerator != null ? strongholdGenerator.func_151545_a(p_147416_1_, p_147416_3_, p_147416_4_, p_147416_5_) : null; } public int getLoadedChunkCount() { return 0; } public void recreateStructures(int p_82695_1_, int p_82695_2_) { strongholdGenerator.func_151539_a(this, world, p_82695_1_, p_82695_2_, (Block[]) null); } } GenLayerBiomeT: package terrarium.world; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.GenLayerBiome; import net.minecraft.world.gen.layer.GenLayerBiomeEdge; import net.minecraft.world.gen.layer.GenLayerZoom; import net.minecraft.world.gen.layer.IntCache; import terrarium.util.MathUtil; import terrarium.world.biome.Biomes; public class GenLayerBiomeT extends GenLayerBiome { public int size; public GenLayerBiomeT(long seed, GenLayer parent, WorldTypeT worldType) { super(seed, parent, worldType); this.size = worldType.size; } @Override public int[] getInts(int chunkX, int chunkZ, int par3, int par4) { int[] current = IntCache.getIntCache(par3 * par4); int realX; int realZ; double distance; for(int z = 0; z < par4; z++) { for(int x = 0; x < par3; x++) { realX = x + chunkX; realZ = z + chunkZ; this.initChunkSeed((long) realX, (long) realZ); distance = MathUtil.getDistance2D(0, 0, realX, realZ); if(distance > 24 * size) { current[x + z * par3] = BiomeGenBase.deepOcean.biomeID; } else if(distance > 12 * size) { current[x + z * par3] = BiomeGenBase.ocean.biomeID; } else if(distance > 9 * size) { current[x + z * par3] = BiomeGenBase.taigaHills.biomeID; } else if(distance > 6 * size) { current[x + z * par3] = BiomeGenBase.desert.biomeID; } else if(distance > 3 * size) { current[x + z * par3] = BiomeGenBase.forest.biomeID; } else { current[x + z * par3] = Biomes.forest.biomeID; } } } return current; } public static GenLayer getLayer(long seed, GenLayer parentLayer, WorldTypeT type) { GenLayer ret = new GenLayerBiome(200L, new GenLayerBiomeT(seed, parentLayer, type), type); ret = GenLayerZoom.magnify(1000L, ret, 2); ret = new GenLayerBiomeEdge(1000L, ret); return ret; } } BiomeGenForestT: package terrarium.world.biome; import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import terrarium.util.WorldUtil; import terrarium.world.gen.WorldGenForestTree; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BiomeGenForestT extends BiomeGenBase { public BiomeGenForestT() { super(48); this.setHeight(new BiomeGenBase.Height(BiomeGenMod.DEFAULT_ROOT_HEIGHT, 0.2F)); this.setColor(0x1CD85E); this.setTemperatureRainfall(0.7F, 0.8F); this.setBiomeName("Forest"); this.theBiomeDecorator.treesPerChunk = 4; this.theBiomeDecorator.grassPerChunk = 2; } @Override @SideOnly(Side.CLIENT) public int getBiomeGrassColor(int x, int y, int z) { return 0x1CD85E; } @Override @SideOnly(Side.CLIENT) public int getBiomeFoliageColor(int x, int y, int z) { return 0x69DD3E; } @Override public void decorate(World world, Random random, int x, int z) { for(int i = 0; i < this.theBiomeDecorator.treesPerChunk; i++) { WorldGenForestTree.generate(world, random, x + random.nextInt(16), WorldUtil.getTopBlock(world, x, z), z + random.nextInt(16)); } } } WorldCreation (this is where I initialize all the world stuff): package terrarium.world.biome; import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import terrarium.util.WorldUtil; import terrarium.world.gen.WorldGenForestTree; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BiomeGenForestT extends BiomeGenBase { public BiomeGenForestT() { super(48); this.setHeight(new BiomeGenBase.Height(BiomeGenMod.DEFAULT_ROOT_HEIGHT, 0.2F)); this.setColor(0x1CD85E); this.setTemperatureRainfall(0.7F, 0.8F); this.setBiomeName("Forest"); this.theBiomeDecorator.treesPerChunk = 4; this.theBiomeDecorator.grassPerChunk = 2; } @Override @SideOnly(Side.CLIENT) public int getBiomeGrassColor(int x, int y, int z) { return 0x1CD85E; } @Override @SideOnly(Side.CLIENT) public int getBiomeFoliageColor(int x, int y, int z) { return 0x69DD3E; } @Override public void decorate(World world, Random random, int x, int z) { for(int i = 0; i < this.theBiomeDecorator.treesPerChunk; i++) { WorldGenForestTree.generate(world, random, x + random.nextInt(16), WorldUtil.getTopBlock(world, x, z), z + random.nextInt(16)); } } TL;DR: biome no worky, pls help Thanks
  4. I just now updated to the latest version of 1.7.10, and this no longer works due to blackboard#get returning an Object: ReferenceT.DEOBFUSCATED = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); Is there a new method of doing this?
  5. Forge/FML wasn't able to find your client proxy. Can you show us a picture/diagram of your package explorer please? It should look something like this:
  6. Hello, I'm having a little trouble with alpha blending on one of my GUIs. I'm rendering an opaque background first, rendering other opaque stuff, and then the translucent foreground. The problem is, the fade/gradient from the foreground is intrusive and can be easily seen. Here's a picture of it: Here's what I want to happen: Finally, here's the code: @Override protected void drawGuiContainerBackgroundLayer(float p1, int p2, int p3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; this.mc.getTextureManager().bindTexture(RES_BG); this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); this.mc.getTextureManager().bindTexture(RES); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); GL11.glDisable(GL11.GL_BLEND); }
  7. Hello, I'm trying to render a model I imported/exported from Techne, but the model does not appear anywhere near the player. I added in prints to see if it was rendering, it was. KnifeRenderer: package csgocases.render; import org.lwjgl.opengl.GL11; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.model.ModelBase; import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; public class KnifeRenderer implements IItemRenderer { public final ModelBase model; public KnifeRenderer(ModelBase model) { super(); this.model = model; } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return type == ItemRenderType.EQUIPPED; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return false; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { if(type == ItemRenderType.EQUIPPED) { EntityClientPlayerMP entity = (EntityClientPlayerMP) data[1]; GL11.glPushMatrix(); GL11.glTranslatef(0, 4, 0); model.render(entity, 0, 0, 0, 0, 0, 0); GL11.glPopMatrix(); } } } ModelBayonet: package csgocases.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelBayonet extends ModelBase { ModelRenderer handle; ModelRenderer bottomHandle; ModelRenderer guard1; ModelRenderer guard3; ModelRenderer guard2; ModelRenderer guard4; ModelRenderer guard5; ModelRenderer blade1; ModelRenderer blade2; ModelRenderer blade3; ModelRenderer blade4; ModelRenderer blade5; ModelRenderer blade7; ModelRenderer blade8; public ModelBayonet() { textureWidth = 128; textureHeight = 64; handle = new ModelRenderer(this, 0, 0); handle.addBox(0F, 0F, 0F, 12, 32, 6); handle.setRotationPoint(-6F, -9F, -3F); handle.setTextureSize(128, 64); handle.mirror = true; setRotation(handle, 0F, 0F, 0F); bottomHandle = new ModelRenderer(this, 36, 0); bottomHandle.addBox(0F, 0F, 0F, 14, 1, ; bottomHandle.setRotationPoint(-7F, 23F, -4F); bottomHandle.setTextureSize(128, 64); bottomHandle.mirror = true; setRotation(bottomHandle, 0F, 0F, 0F); guard1 = new ModelRenderer(this, 36, 9); guard1.addBox(0F, 0F, 0F, 13, 1, ; guard1.setRotationPoint(-6F, -10F, -4F); guard1.setTextureSize(128, 64); guard1.mirror = true; setRotation(guard1, 0F, 0F, 0F); guard3 = new ModelRenderer(this, 80, 0); guard3.addBox(0F, 0F, 0F, 1, 1, 6); guard3.setRotationPoint(7F, -10F, -3F); guard3.setTextureSize(128, 64); guard3.mirror = true; setRotation(guard3, 0F, 0F, 0F); guard2 = new ModelRenderer(this, 94, 0); guard2.addBox(0F, 0F, 0F, 7, 1, 1); guard2.setRotationPoint(-13F, -10F, -4F); guard2.setTextureSize(128, 64); guard2.mirror = true; setRotation(guard2, 0F, 0F, 0F); guard4 = new ModelRenderer(this, 94, 0); guard4.addBox(0F, 0F, 0F, 7, 1, 1); guard4.setRotationPoint(-13F, -10F, 3F); guard4.setTextureSize(128, 64); guard4.mirror = true; setRotation(guard4, 0F, 0F, 0F); guard5 = new ModelRenderer(this, 94, 0); guard5.addBox(0F, 0F, 0F, 6, 1, 1); guard5.setRotationPoint(-12F, -10F, -3F); guard5.setTextureSize(128, 64); guard5.mirror = true; setRotation(guard5, 0F, -1.570796F, 0F); blade1 = new ModelRenderer(this, 36, 18); blade1.addBox(0F, 0F, 0F, 9, 32, 2); blade1.setRotationPoint(-5.5F, -42F, -1F); blade1.setTextureSize(128, 64); blade1.mirror = true; setRotation(blade1, 0F, 0F, 0F); blade2 = new ModelRenderer(this, 58, 18); blade2.addBox(0F, 0F, 0F, 3, 32, 1); blade2.setRotationPoint(3.5F, -42F, -0.5F); blade2.setTextureSize(128, 64); blade2.mirror = true; setRotation(blade2, 0F, 0F, 0F); blade3 = new ModelRenderer(this, 0, 38); blade3.addBox(0F, 0F, 0F, 4, 19, 2); blade3.setRotationPoint(-3.85F, -60.9F, -1F); blade3.setTextureSize(128, 64); blade3.mirror = true; setRotation(blade3, 0F, 0F, 0.0872665F); blade4 = new ModelRenderer(this, 66, 18); blade4.addBox(0F, 0F, 0F, 3, 18, 1); blade4.setRotationPoint(3.366667F, -59.7F, 0.5F); blade4.setTextureSize(128, 64); blade4.mirror = true; setRotation(blade4, 0F, 3.141593F, 0.1745329F); blade5 = new ModelRenderer(this, 66, 37); blade5.addBox(0F, 0F, 0F, 2, 19, 2); blade5.setRotationPoint(-1.8F, -60F, -1F); blade5.setTextureSize(128, 64); blade5.mirror = true; setRotation(blade5, 0F, 0F, -0.1745329F); blade7 = new ModelRenderer(this, 58, 51); blade7.addBox(0F, 0F, 0F, 3, 6, 1); blade7.setRotationPoint(-1.5F, -62.8F, 0.5F); blade7.setTextureSize(128, 64); blade7.mirror = true; setRotation(blade7, 3.141593F, 0F, 2.190781F); blade8 = new ModelRenderer(this, 12, 38); blade8.addBox(0F, 0F, 0F, 3, 3, 2); blade8.setRotationPoint(-3.85F, -60.9F, 1F); blade8.setTextureSize(128, 64); blade8.mirror = true; setRotation(blade8, 3.141593F, 0F, 0.896934F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); handle.render(f5); bottomHandle.render(f5); guard1.render(f5); guard3.render(f5); guard2.render(f5); guard4.render(f5); guard5.render(f5); blade1.render(f5); blade2.render(f5); blade3.render(f5); blade4.render(f5); blade5.render(f5); blade7.render(f5); blade8.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } } ClientProxyCS: package csgocases; import net.minecraftforge.client.MinecraftForgeClient; import tlhpoeCore.TLHPoE; import csgocases.model.ModelBayonet; import csgocases.render.KnifeRenderer; public class ClientProxyCS extends ServerProxyCS { @Override public void initClient() { TLHPoE.registerUpdateDetector(ReferenceCS.ID, ReferenceCS.NAME, ReferenceCS.VERSION, "0B6mhkrh-GwwwcFRXTGFiTlpqN1U"); MinecraftForgeClient.registerItemRenderer(ServerProxyCS.bayonet, new KnifeRenderer(new ModelBayonet())); } } ServerProxyCS: package csgocases; import net.minecraft.item.Item; import cpw.mods.fml.common.registry.GameRegistry; import csgocases.item.ItemKnife; public class ServerProxyCS { public static Item bayonet = new ItemKnife("bayonet"); public void initServer() { register(bayonet); } public void initClient() { } private static void register(Item item) { GameRegistry.registerItem(item, item.getUnlocalizedName()); } } ItemKnife: package csgocases.item; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import tf2crates.ReferenceTC; import tf2crates.ServerProxyTC; import tf2crates.entity.EntityDamageSourceBackstab; import tlhpoeCore.network.MessagePlaySound; import csgocases.ReferenceCS; public class ItemKnife extends ItemSword { public static double backstabDifficulty = 0.75D; public ItemKnife(String name) { super(ToolMaterial.EMERALD); this.setUnlocalizedName(name); this.setTextureName(ReferenceCS.ID + ":" + name); } @Override public boolean hitEntity(ItemStack itemStack, EntityLivingBase prey, EntityLivingBase attacker) { itemStack.damageItem(1, attacker); float pYaw = prey.rotationYawHead % 360F; pYaw = pYaw < 0 ? 360 + pYaw : prey.rotationYawHead; float aYaw = attacker.rotationYawHead < 0 ? 360 + attacker.rotationYawHead : attacker.rotationYawHead; float newRot = pYaw - aYaw; if(newRot < (90 * backstabDifficulty) && newRot > (-90 * backstabDifficulty)) { if(!attacker.worldObj.isRemote) { new MessagePlaySound(ReferenceTC.ID + ":tf2crates.crit").sendTo((EntityPlayerMP) attacker); } if(itemStack.getItem() == ServerProxyTC.conniversKunai) { attacker.heal(prey.getMaxHealth()); } prey.attackEntityFrom(EntityDamageSourceBackstab.causeBackstabDamage(attacker), prey.getMaxHealth() * 600); } return false; } }
  8. Another question: Is there a way to know in the code?
  9. Is there anyway to tell if my mod is being run while deobfuscated? (I think deobfuscated is the right word, like in Eclipse) I'm currently using a boolean stored in my reference class, but it's become tedious to set it to false and then obfuscate/compile and then set it back to true.
  10. I think he's trying to do it for blocks I would take a look at the BlockGrass file, seeing as how the actual "grassy" part of the texture is layered onto a dirt texture and then color-changed depending on its biome.
  11. Hello, I think there's a glitch with using the itemstack-sensitive version of the Item#getIconIndex method. What I'm attempting is using a different texture when a certain tag is true in the itemstack's NBT. Picture: As you can see, the icon in the hotbar changed but not the actual 3D item. Additionally, the item in 3rd person mod has the same texture still too. Code: package tf2crates.item; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import tf2crates.ReferenceTC; import tf2crates.ServerProxyTC; import tf2crates.crate.RandomLoot; import tf2crates.entity.DamageSourceBackstab; import tlhpoeCore.network.MessagePlaySound; import tlhpoeCore.util.MiscUtil; public class ItemKnife extends ItemSword { public static double backstabDifficulty = 0.75D; public IIcon goldTexture; public ItemKnife(String name) { super(ServerProxyTC.MOD_WEAPON); this.setUnlocalizedName(name); this.setTextureName(ReferenceTC.ID + ":weapon/" + name); RandomLoot.WEAPONS.add(this); } public ItemKnife(String name, float dmg) { this(name); MiscUtil.replaceField("field_150934_a", ItemSword.class, dmg, this); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister register) { super.registerIcons(register); this.goldTexture = register.registerIcon(ReferenceTC.ID + ":weapon/gold/" + this.getUnlocalizedName().substring(5)); } @Override @SideOnly(Side.CLIENT) public IIcon getIconIndex(ItemStack itemStack) { NBTTagCompound nbt = itemStack.getTagCompound(); if(nbt != null && nbt.getBoolean("Golden")) { return this.goldTexture; } return super.getIconIndex(itemStack); } @Override public boolean hitEntity(ItemStack itemStack, EntityLivingBase prey, EntityLivingBase attacker) { itemStack.damageItem(1, attacker); float pYaw = prey.rotationYawHead % 360F; pYaw = pYaw < 0 ? 360 + pYaw : prey.rotationYawHead; float aYaw = attacker.rotationYawHead < 0 ? 360 + attacker.rotationYawHead : attacker.rotationYawHead; float newRot = pYaw - aYaw; if(newRot < (90 * backstabDifficulty) && newRot > (-90 * backstabDifficulty)) { if(!attacker.worldObj.isRemote) { new MessagePlaySound(ReferenceTC.ID + ":tf2crates.crit").sendTo((EntityPlayerMP) attacker); } attacker.heal(prey.getMaxHealth()); prey.attackEntityFrom(DamageSourceBackstab.BACKSTAB, prey.getMaxHealth() * 600); } return false; } }
  12. Ok, simple problem I think. The ${version} tag (I don't know the technical term) in the mcmod.info file does not display properly in the mod list interface. I used the example mod with some tweaked things. Here's what it looks like: mcmod.info: [ { "modid": "ortus", "name": "Ortus", "description": "A content-heavy mod designed to add more chances for adventuring.", "version": "${version}", "mcversion": "${mcversion}", "url": "", "updateUrl": "", "authorList": ["TLHPoE"], "credits": "The creators of Forge and FML", "logoFile": "", "screenshots": [], "dependencies": [] } ] Main mod class: package ortus; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @Mod(modid = Ortus.ID, version = Ortus.VERSION) public class Ortus { public static final String ID = "ortus"; public static final String VERSION = "1.0"; @EventHandler public void preInit(FMLPreInitializationEvent event) { } @EventHandler public void init(FMLInitializationEvent event) { } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
  13. Is there a special way in Minecraft to render billboard quads? Like rendering a player tag but instead of text it's a ResourceLocation?
  14. Hello, I'm currently maintaining my own wiki on Orain and I want to use the Minecraft Wiki's Crafting Table Template. The problem I'm having is that although Orain runs on MediaWiki, it does not have the Scribunto extension by default as far as I know. This is problematic since the crafting table template uses Scribunto. So is there anyway to install my own extensions on Orain? Or a work around to not use Scribunto at all? EDIT: So uh, it turns out Orain actually does have Scribunto. Oops
  15. That's weird... I tried it with the print and it worked. Thanks anyways TGG!
  16. Hello, I'm trying to make it so whenever the player is eating my food they go into third person mode, and when they're done, they're put into first person mode. Putting them in third person mode works, but not putting them in first person. Here's how I'm putting the player into first person mode: if(world.isRemote) { MCUtil.getMC().gameSettings.thirdPersonView = 0; } I tried placing the code into the onUpdate method and it worked, but I need it in the onFoodEaten or onEaten method. ItemSandvich: package tf2crates.item; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import tf2crates.ReferenceTC; import tf2crates.crate.RandomLoot; import tlhpoeCore.util.MCUtil; public class ItemSandvich extends ItemFood { public ItemSandvich() { super(20, 0.32F, true); this.setUnlocalizedName("sandvich"); this.setTextureName(ReferenceTC.ID + ":sandvich"); this.setMaxStackSize(1); this.setMaxDamage(6001); this.setAlwaysEdible(); RandomLoot.WEAPONS.add(this); } @Override public int getMaxItemUseDuration(ItemStack itemStack) { return 64; } @Override protected void onFoodEaten(ItemStack itemStack, World world, EntityPlayer player) { if(!world.isRemote) { player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 2)); player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 600, 2)); player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 600, 1)); player.heal(player.getMaxHealth()); itemStack.setItemDamage(6000); } else { MCUtil.getMC().gameSettings.thirdPersonView = 0; //No work } } @Override public ItemStack onEaten(ItemStack itemStack, World world, EntityPlayer player) { player.getFoodStats().func_151686_a(this, itemStack); if(world.isRemote) { MCUtil.getMC().gameSettings.thirdPersonView = 0; //No work again } world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); this.onFoodEaten(itemStack, world, player); return itemStack; } @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if(itemStack.getItemDamage() == 0) { player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack)); } return itemStack; } @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int f, boolean f2) { int dmg = itemStack.getItemDamage(); if(dmg > 0) { itemStack.setItemDamage(dmg - 1); } if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; if(player.isEating()) { ItemStack held = player.getHeldItem(); if(held != null && held.getItem() == this) { if(world.isRemote) { MCUtil.getMC().gameSettings.thirdPersonView = 1; } player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1, 5)); } } } } }
  17. Hello, is there anyway to change the max durability of a helmet in an item stack? As in making the helmet unbreakable or last twice as long. Enchantments are not a valid option for me, and I've already tried setting the item stack's damage to Integer#MIN_VALUE.
  18. That fixed it, thanks. I have no clue why I overrided that method and just returned super's implementation.
  19. Nothing package tooldles.item; import java.util.List; import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.Block.SoundType; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.world.World; import tooldles.ReferenceOT; import com.google.common.collect.Sets; public class ItemScythe extends ItemTool { private static final Set MINABLE_BLOCKS = Sets.newHashSet(new Block[] { Blocks.tallgrass, Blocks.deadbush, Blocks.leaves, Blocks.leaves2, Blocks.vine, Blocks.red_flower, Blocks.yellow_flower, Blocks.double_plant, Blocks.web }); public ItemScythe(ToolMaterial material, String name) { super(3F, material, MINABLE_BLOCKS); this.setUnlocalizedName(name); this.setTextureName(ReferenceOT.ID + ":" + name); } @Override public boolean func_150897_b(Block block) { return block == Blocks.tallgrass || block == Blocks.deadbush || block == Blocks.leaves || block == Blocks.leaves2 || block == Blocks.vine || block == Blocks.red_flower || block == Blocks.yellow_flower || block == Blocks.double_plant || block == Blocks.web; } @Override public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { return super.onBlockDestroyed(itemStack, world, block, x, y, z, entity); } @Override public boolean onBlockStartBreak(ItemStack itemStack, int x, int y, int z, EntityPlayer player) { World world = player.worldObj; Block block = world.getBlock(x, y, z); if(this.canHarvestBlock(block, itemStack)) { SoundType sound = block.stepSound; world.playSoundAtEntity(player, sound.getBreakSound(), sound.volume, 0.8F); itemStack.damageItem(1, player); breakBlock(world, itemStack, x - 1, y, z, player); breakBlock(world, itemStack, x + 1, y, z, player); breakBlock(world, itemStack, x - 1, y + 1, z, player); breakBlock(world, itemStack, x + 1, y + 1, z, player); breakBlock(world, itemStack, x - 1, y - 1, z, player); breakBlock(world, itemStack, x + 1, y - 1, z, player); breakBlock(world, itemStack, x, y, z - 1, player); breakBlock(world, itemStack, x, y, z + 1, player); breakBlock(world, itemStack, x, y + 1, z - 1, player); breakBlock(world, itemStack, x, y + 1, z + 1, player); breakBlock(world, itemStack, x, y - 1, z - 1, player); breakBlock(world, itemStack, x, y - 1, z + 1, player); breakBlock(world, itemStack, x + 1, y, z + 1, player); breakBlock(world, itemStack, x - 1, y, z - 1, player); breakBlock(world, itemStack, x + 1, y + 1, z + 1, player); breakBlock(world, itemStack, x - 1, y + 1, z - 1, player); breakBlock(world, itemStack, x + 1, y - 1, z + 1, player); breakBlock(world, itemStack, x - 1, y - 1, z - 1, player); breakBlock(world, itemStack, x + 1, y, z - 1, player); breakBlock(world, itemStack, x - 1, y, z + 1, player); breakBlock(world, itemStack, x + 1, y + 1, z - 1, player); breakBlock(world, itemStack, x - 1, y + 1, z + 1, player); breakBlock(world, itemStack, x + 1, y - 1, z - 1, player); breakBlock(world, itemStack, x - 1, y - 1, z + 1, player); breakBlock(world, itemStack, x, y + 1, z, player); breakBlock(world, itemStack, x, y - 1, z, player); return true; } return false; } private void breakBlock(World world, ItemStack itemStack, int x, int y, int z, EntityLivingBase entity) { Block block = world.getBlock(x, y, z); if(!world.isRemote && this.canHarvestBlock(block, itemStack)) { List<ItemStack> loot = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 2 + EnchantmentHelper.getFortuneModifier(entity)); for(ItemStack lootItem : loot) { EntityItem lootEntity = new EntityItem(world, x, y, z, lootItem); world.spawnEntityInWorld(lootEntity); } world.setBlock(x, y, z, Blocks.air); } } }
  20. Hello, I have a tool that destroys a 3x3x3 area. The problem is that the blocks that are set to air are replaced with phantom blocks. Phantom blocks are blocks that look like they're just air, but whenever walked into, teleports the player backwards. ItemScythe: package tooldles.item; import java.util.List; import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.Block.SoundType; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.world.World; import tooldles.ReferenceOT; import com.google.common.collect.Sets; public class ItemScythe extends ItemTool { private static final Set MINABLE_BLOCKS = Sets.newHashSet(new Block[] { Blocks.tallgrass, Blocks.deadbush, Blocks.leaves, Blocks.leaves2, Blocks.vine, Blocks.red_flower, Blocks.yellow_flower, Blocks.double_plant, Blocks.web }); public ItemScythe(ToolMaterial material, String name) { super(3F, material, MINABLE_BLOCKS); this.setUnlocalizedName(name); this.setTextureName(ReferenceOT.ID + ":" + name); } @Override public boolean func_150897_b(Block block) { return block == Blocks.tallgrass || block == Blocks.deadbush || block == Blocks.leaves || block == Blocks.leaves2 || block == Blocks.vine || block == Blocks.red_flower || block == Blocks.yellow_flower || block == Blocks.double_plant || block == Blocks.web; } @Override public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { return super.onBlockDestroyed(itemStack, world, block, x, y, z, entity); } @Override public boolean onBlockStartBreak(ItemStack itemStack, int x, int y, int z, EntityPlayer player) { World world = player.worldObj; Block block = world.getBlock(x, y, z); if(this.canHarvestBlock(block, itemStack)) { SoundType sound = block.stepSound; world.playSoundAtEntity(player, sound.getBreakSound(), sound.volume, 0.8F); itemStack.damageItem(1, player); breakBlock(world, itemStack, x - 1, y, z, player); breakBlock(world, itemStack, x + 1, y, z, player); breakBlock(world, itemStack, x - 1, y + 1, z, player); breakBlock(world, itemStack, x + 1, y + 1, z, player); breakBlock(world, itemStack, x - 1, y - 1, z, player); breakBlock(world, itemStack, x + 1, y - 1, z, player); breakBlock(world, itemStack, x, y, z - 1, player); breakBlock(world, itemStack, x, y, z + 1, player); breakBlock(world, itemStack, x, y + 1, z - 1, player); breakBlock(world, itemStack, x, y + 1, z + 1, player); breakBlock(world, itemStack, x, y - 1, z - 1, player); breakBlock(world, itemStack, x, y - 1, z + 1, player); breakBlock(world, itemStack, x + 1, y, z + 1, player); breakBlock(world, itemStack, x - 1, y, z - 1, player); breakBlock(world, itemStack, x + 1, y + 1, z + 1, player); breakBlock(world, itemStack, x - 1, y + 1, z - 1, player); breakBlock(world, itemStack, x + 1, y - 1, z + 1, player); breakBlock(world, itemStack, x - 1, y - 1, z - 1, player); breakBlock(world, itemStack, x + 1, y, z - 1, player); breakBlock(world, itemStack, x - 1, y, z + 1, player); breakBlock(world, itemStack, x + 1, y + 1, z - 1, player); breakBlock(world, itemStack, x - 1, y + 1, z + 1, player); breakBlock(world, itemStack, x + 1, y - 1, z - 1, player); breakBlock(world, itemStack, x - 1, y - 1, z + 1, player); breakBlock(world, itemStack, x, y + 1, z, player); breakBlock(world, itemStack, x, y - 1, z, player); return true; } return false; } private void breakBlock(World world, ItemStack itemStack, int x, int y, int z, EntityLivingBase entity) { Block block = world.getBlock(x, y, z); if(this.canHarvestBlock(block, itemStack)) { world.setBlock(x, y, z, Blocks.air); if(!world.isRemote) { List<ItemStack> loot = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 2 + EnchantmentHelper.getFortuneModifier(entity)); for(ItemStack lootItem : loot) { EntityItem lootEntity = new EntityItem(world, x, y, z, lootItem); world.spawnEntityInWorld(lootEntity); } } } } }
  21. Blehhhh, ok. I plan on having LOTS of data being stored in the world NBT and didn't want to bother having multiple fields.
  22. Hello, I'm making a structure only generate 3 times within a world using a custom WorldSavedData class. Whenever I try accessing it, it gives me this crash: ---- Minecraft Crash Report ---- // You're mean. Time: 10/11/14 1:05 AM Description: Exception in server tick loop java.lang.NullPointerException: Exception in server tick loop at terrarium.data.WorldSavedDataT.getInt(WorldSavedDataT.java:50) at terrarium.world.WorldGeneratorT.generateOverworld(WorldGeneratorT.java:26) at terrarium.world.WorldGeneratorT.generate(WorldGeneratorT.java:17) at cpw.mods.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:106) at net.minecraft.world.gen.ChunkProviderServer.populate(ChunkProviderServer.java:314) at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1157) at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:208) at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:149) at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:119) at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:305) at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:79) at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_67, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 787348752 bytes (750 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 9, tallocated: 72 FML: MCP v9.05 FML v7.10.85.1224 Minecraft Forge 10.13.1.1224 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available FML{7.10.85.1224} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.1.1224.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available Forge{10.13.1.1224} [Minecraft Forge] (forgeSrc-1.7.10-10.13.1.1224.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available terrarium{Indev} [Terrarium] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' WorldData: package terrarium.data; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraft.world.storage.MapStorage; public class WorldSavedDataT extends WorldSavedData { private static final String KEY = "TerrariumWorldSavedData"; private NBTTagCompound data; public WorldSavedDataT(String name) { super(name); } public static WorldSavedDataT getWorldDataFor(World world) { MapStorage storage = world.perWorldStorage; WorldSavedDataT worldData = (WorldSavedDataT) storage.loadData(WorldSavedDataT.class, KEY); if(worldData == null) { worldData = new WorldSavedDataT(KEY); storage.setData(KEY, worldData); } return (WorldSavedDataT) storage.loadData(WorldSavedDataT.class, KEY); } @Override public void readFromNBT(NBTTagCompound nbt) { if(!nbt.hasKey("Terrarium")) { nbt.setTag("Terrarium", new NBTTagCompound()); } data = nbt.getCompoundTag("Terrarium"); } @Override public void writeToNBT(NBTTagCompound nbt) { nbt.setTag("Terrarium", data); } public void setInt(String name, int value) { data.setInteger(name, value); this.markDirty(); } public int getInt(String name) { if(!data.hasKey(name)) { setInt(name, 0); } return data.getInteger(name); } public void setBoolean(String name, boolean value) { data.setBoolean(name, value); this.markDirty(); } public boolean getBoolean(String name) { if(!data.hasKey(name)) { setBoolean(name, false); } return data.getBoolean(name); } public void setFloat(String name, float value) { data.setFloat(name, value); this.markDirty(); } public float getFloat(String name) { if(!data.hasKey(name)) { setFloat(name, 0F); } return data.getFloat(name); } public void setDouble(String name, double value) { data.setDouble(name, value); this.markDirty(); } public double getDouble(String name) { if(!data.hasKey(name)) { setDouble(name, 0D); } return data.getDouble(name); } } WorldGenerator: package terrarium.world; import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import terrarium.data.WorldSavedDataT; import terrarium.util.MathUtil; import terrarium.world.gen.WorldGenFloatingIsland; import cpw.mods.fml.common.IWorldGenerator; public class WorldGeneratorT implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { case (0): { generateOverworld(random, chunkX * 16, chunkZ * 16, world); break; } } } public void generateOverworld(Random random, int x, int z, World world) { if(MathUtil.getChance(random, 1, 500)) { WorldSavedDataT worldData = WorldSavedDataT.getWorldDataFor(world); int amt = worldData.getInt("AmountOfStructures"); if(amt < 4) { worldData.setInt("Structure", amt++); int x2 = x + random.nextInt(16); int z2 = z + random.nextInt(16); //Generate something } } if(MathUtil.getChance(random, 1, 150)) { WorldGenFloatingIsland.generate(world, random, x + random.nextInt(16), 200 + random.nextInt(32), z + random.nextInt(16)); } } } The crash occurs when I try generating a world.
  23. Oh, I must've not copy and pasted the right code segment haha I was able to get the recipes working: for(i = 0; i < 16; i++) { GameRegistry.addShapelessRecipe(new ItemStack(Blocks.wool, 1, BlockColored.func_150031_c(i)), new ItemStack(paint, 1, i), new ItemStack(Blocks.wool, 1, 0)); }
  24. private static void renderIcon(IIcon icon) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), 255, 255, 0.0625F); } That should render the 3D item. I'm not an OpenGL wizard, but what I would do is:
  25. Hello, how would I make an item retain its damage after being crafted with something else? Item: package tf2crates.item; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import tf2crates.ReferenceTC; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ItemPaint extends Item { public static final String[] TYPES = { "black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white" }; public IIcon[] textures; public ItemPaint() { super(); this.setUnlocalizedName("paint"); this.setMaxStackSize(1); this.hasSubtypes = true; this.setContainerItem(this); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { textures = new IIcon[TYPES.length]; for(int i = 0; i < TYPES.length; i++) { textures[i] = iconRegister.registerIcon(ReferenceTC.ID + ":paint/" + TYPES[i]); } } @Override public String getItemStackDisplayName(ItemStack itemStack) { String res = StatCollector.translateToLocal("paint." + TYPES[itemStack.getItemDamage()] + ".name"); return res; } @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs tabs, List list) { for(int i = 0; i < TYPES.length; i++) { list.add(new ItemStack(item, 1, i)); } } @Override public EnumRarity getRarity(ItemStack itemStack) { return EnumRarity.rare; } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean f) { info.add(EnumChatFormatting.YELLOW + "Combine this with the helmet of your choice!"); } @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int dmg) { return textures[dmg]; } @Override public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) { return false; } } Recipe: public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) I was able to make the item persist through crafting, but it resets its damage. I've seen some people recommend using a recipe handler (IRecipe), but it doesn't seem like there's anything to help with achieving this.
×
×
  • Create New...

Important Information

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