Résolu Encore un problème de mise à jour de ma dimension
-
Salut
Je reviens après une longue (très longue) absence pour un problème avec ma dimension. J’essaye de la mettre à jour.Déjà voilà la classe ChunkProviderFrightful (c’est dedans le problème) :
package thisishalloween.world.frightful; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA; import java.util.List; import java.util.Random; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Biomes; import net.minecraft.init.Blocks; import net.minecraft.util.IProgressUpdate; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.WorldEntitySpawner; import net.minecraft.world.WorldType; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.SpawnListEntry; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderSettings; import net.minecraft.world.gen.NoiseGeneratorOctaves; import net.minecraft.world.gen.NoiseGeneratorPerlin; import net.minecraft.world.gen.feature.WorldGenLakes; import net.minecraft.world.gen.structure.MapGenMineshaft; import net.minecraft.world.gen.structure.MapGenScatteredFeature; import net.minecraft.world.gen.structure.MapGenStronghold; import net.minecraft.world.gen.structure.MapGenVillage; import net.minecraft.world.gen.structure.StructureOceanMonument; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.ChunkGeneratorEvent; import net.minecraftforge.event.terraingen.InitNoiseGensEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; import net.minecraftforge.fml.common.eventhandler.Event.Result; import thisishalloween.ThisisHalloween; public class ChunkProviderFrightful implements IChunkGenerator { /** RNG. */ private Random rand; private NoiseGeneratorOctaves minLimitPerlinNoise; private NoiseGeneratorOctaves maxLimitPerlinNoise; private NoiseGeneratorOctaves mainPerlinNoise; private NoiseGeneratorPerlin surfaceNoise; public NoiseGeneratorOctaves scaleNoise; public NoiseGeneratorOctaves depthNoise; public NoiseGeneratorOctaves forestNoise; private World worldObj; private final boolean mapFeaturesEnabled; private WorldType field_177475_o; private final double[] field_147434_q; private final float[] biomeWeights; private ChunkProviderSettings settings; private double[] stoneNoise; private Biome[] biomesForGeneration; double[] field_147427_d; double[] field_147428_e; double[] field_147425_f; double[] field_147426_g; private IBlockState oceanBlock = Blocks.WATER.getDefaultState(); public ChunkProviderFrightful(World worldIn, long seed, boolean mapFeaturesEnabledIn, String p_i46668_5_) { this.worldObj = worldIn; this.mapFeaturesEnabled = mapFeaturesEnabledIn; this.field_177475_o = worldIn.getWorldInfo().getTerrainType(); this.rand = new Random(seed); this.minLimitPerlinNoise = new NoiseGeneratorOctaves(this.rand, 16); this.maxLimitPerlinNoise = new NoiseGeneratorOctaves(this.rand, 16); this.mainPerlinNoise = new NoiseGeneratorOctaves(this.rand, 8); this.surfaceNoise = new NoiseGeneratorPerlin(this.rand, 4); this.scaleNoise = new NoiseGeneratorOctaves(this.rand, 10); this.depthNoise = new NoiseGeneratorOctaves(this.rand, 16); this.forestNoise = new NoiseGeneratorOctaves(this.rand, 8); this.field_147434_q = new double[825]; this.biomeWeights = new float[25]; for (int i = -2; i <= 2; ++i) { for (int j = -2; j <= 2; ++j) { float f = 10.0F / MathHelper.sqrt_float((float)(i * i + j * j) + 0.2F); this.biomeWeights _= f; } } if (p_i46668_5_ != null) { this.settings = ChunkProviderSettings.Factory.jsonToFactory(p_i46668_5_).build(); this.oceanBlock = this.settings.useLavaOceans ? Blocks.LAVA.getDefaultState() : Blocks.WATER.getDefaultState(); worldIn.setSeaLevel(this.settings.seaLevel); } net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld ctx = new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld(minLimitPerlinNoise, maxLimitPerlinNoise, mainPerlinNoise, surfaceNoise, scaleNoise, depthNoise, forestNoise); ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(worldIn, this.rand, ctx); this.minLimitPerlinNoise = ctx.getLPerlin1(); this.maxLimitPerlinNoise = ctx.getLPerlin2(); this.mainPerlinNoise = ctx.getPerlin(); this.surfaceNoise = ctx.getHeight(); this.scaleNoise = ctx.getScale(); this.depthNoise = ctx.getDepth(); this.forestNoise = ctx.getForest(); } public void setBlocksInChunk(int x, int z, ChunkPrimer primer) { this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); this.generateHeightmap(x * 4, 0, z * 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 = this.field_147434_q[k1 + k2]; double d2 = this.field_147434_q[l1 + k2]; double d3 = this.field_147434_q[i2 + k2]; double d4 = this.field_147434_q[j2 + k2]; double d5 = (this.field_147434_q[k1 + k2 + 1] - d1) * d0; double d6 = (this.field_147434_q[l1 + k2 + 1] - d2) * d0; double d7 = (this.field_147434_q[i2 + k2 + 1] - d3) * d0; double d8 = (this.field_147434_q[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) { double d14 = 0.25D; double d16 = (d11 - d10) * d14; double d15 = d10 - d16; for (int j3 = 0; j3 < 4; ++j3) { if ((d15 += d16) > 0.0D) { primer.setBlockState(k * 4 + i3, k2 * 8 + l2, j1 * 4 + j3, Blocks.STONE.getDefaultState()); } else if (k2 * 8 + l2 < this.settings.seaLevel) { primer.setBlockState(k * 4 + i3, k2 * 8 + l2, j1 * 4 + j3, Blocks.WATER.getDefaultState()); } } d10 += d12; d11 += d13; } d1 += d5; d2 += d6; d3 += d7; d4 += d8; } } } } } public void replaceBiomeBlocks(int p_180517_1_, int p_180517_2_, ChunkPrimer p_180517_3_, Biome[] p_180517_4_) { ChunkGeneratorEvent.ReplaceBiomeBlocks event = new ChunkGeneratorEvent.ReplaceBiomeBlocks(this, p_180517_1_, p_180517_2_, p_180517_3_, this.worldObj); MinecraftForge.EVENT_BUS.post(event); if (event.getResult() == Result.DENY) return; double d0 = 0.03125D; this.stoneNoise = this.surfaceNoise.getRegion(this.stoneNoise, (double)(p_180517_1_ * 16), (double)(p_180517_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) { Biome biomegenbase = p_180517_4_[l + k * 16]; biomegenbase.genTerrainBlocks(this.worldObj, this.rand, p_180517_3_, p_180517_1_ * 16 + k, p_180517_2_ * 16 + l, this.stoneNoise[l + k * 16]); } } } /** * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the * specified chunk from the map seed and chunk seed */ public Chunk provideChunk(int x, int z) { this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L); ChunkPrimer chunkprimer = new ChunkPrimer(); this.setBlocksInChunk(x, z, chunkprimer); this.biomesForGeneration = this.worldObj.getBiomeProvider().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16); this.replaceBiomeBlocks(x, z, chunkprimer, this.biomesForGeneration); Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z); byte[] abyte = chunk.getBiomeArray(); for (int k = 0; k < abyte.length; ++k) { abyte[k] = (byte)this.biomesForGeneration[k].getIdForBiome(ThisisHalloween.biomeToSpawnIn); } chunk.generateSkylightMap(); return chunk; } private void generateHeightmap(int p_147423_1_, int p_147423_2_, int p_147423_3_) { this.field_147426_g = this.depthNoise.generateNoiseOctaves(this.field_147426_g, p_147423_1_, p_147423_3_, 5, 5, (double)this.settings.depthNoiseScaleX, (double)this.settings.depthNoiseScaleZ, (double)this.settings.depthNoiseScaleExponent); float f = this.settings.coordinateScale; float f1 = this.settings.heightScale; this.field_147427_d = this.mainPerlinNoise.generateNoiseOctaves(this.field_147427_d, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)(f / this.settings.mainNoiseScaleX), (double)(f1 / this.settings.mainNoiseScaleY), (double)(f / this.settings.mainNoiseScaleZ)); this.field_147428_e = this.minLimitPerlinNoise.generateNoiseOctaves(this.field_147428_e, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)f, (double)f1, (double)f); this.field_147425_f = this.maxLimitPerlinNoise.generateNoiseOctaves(this.field_147425_f, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)f, (double)f1, (double)f); boolean flag1 = false; boolean flag = false; int l = 0; int i1 = 0; for (int j1 = 0; j1 < 5; ++j1) { for (int k1 = 0; k1 < 5; ++k1) { float f2 = 0.0F; float f3 = 0.0F; float f4 = 0.0F; byte b0 = 2; Biome biomegenbase = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { Biome biomegenbase1 = this.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; float f5 = this.settings.biomeDepthOffSet + biomegenbase1.getBaseHeight() * this.settings.biomeDepthWeight; float f6 = this.settings.biomeScaleOffset + biomegenbase1.getHeightVariation() * this.settings.biomeScaleWeight; float f7 = this.biomeWeights[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F); if (biomegenbase1.getBaseHeight() > biomegenbase.getBaseHeight()) { f7 /= 2.0F; } f2 += f6 * f7; f3 += f5 * f7; f4 += f7; } } f2 /= f4; f3 /= f4; f2 = f2 * 0.9F + 0.1F; f3 = (f3 * 4.0F - 1.0F) / 8.0F; double d7 = this.field_147426_g[i1] / 8000.0D; if (d7 < 0.0D) { d7 = -d7 * 0.3D; } d7 = d7 * 3.0D - 2.0D; if (d7 < 0.0D) { d7 /= 2.0D; if (d7 < -1.0D) { d7 = -1.0D; } d7 /= 1.4D; d7 /= 2.0D; } else { if (d7 > 1.0D) { d7 = 1.0D; } d7 /= 8.0D; } ++i1; double d8 = (double)f3; double d9 = (double)f2; d8 += d7 * 0.2D; d8 = d8 * (double)this.settings.baseSize / 8.0D; double d0 = (double)this.settings.baseSize + d8 * 4.0D; for (int j2 = 0; j2 < 33; ++j2) { double d1 = ((double)j2 - d0) * (double)this.settings.stretchY * 128.0D / 256.0D / d9; if (d1 < 0.0D) { d1 *= 4.0D; } double d2 = this.field_147428_e[l] / (double)this.settings.lowerLimitScale; double d3 = this.field_147425_f[l] / (double)this.settings.upperLimitScale; double d4 = (this.field_147427_d[l] / 10.0D + 1.0D) / 2.0D; double d5 = MathHelper.denormalizeClamp(d2, d3, d4) - d1; if (j2 > 29) { double d6 = (double)((float)(j2 - 29) / 3.0F); d5 = d5 * (1.0D - d6) + -10.0D * d6; } this.field_147434_q[l] = d5; ++l; } } } } /** * Populates chunk with ores etc etc */ public void populate(int p_73153_2_, int p_73153_3_) { BlockFalling.fallInstantly = true; int k = p_73153_2_ * 16; int l = p_73153_3_ * 16; BlockPos blockpos = new BlockPos(k, 0, l); Biome biomegenbase = this.worldObj.getBiomeGenForCoords(blockpos.add(16, 0, 16)); this.rand.setSeed(this.worldObj.getSeed()); long i1 = this.rand.nextLong() / 2L * 2L + 1L; long j1 = this.rand.nextLong() / 2L * 2L + 1L; this.rand.setSeed((long)p_73153_2_ * i1 + (long)p_73153_3_ * j1 ^ this.worldObj.getSeed()); boolean flag = false; ChunkPos chunkcoordintpair = new ChunkPos(p_73153_2_, p_73153_3_); net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.worldObj, this.rand, p_73153_2_, p_73153_3_, flag); int k1; int l1; int i2; if (biomegenbase != Biomes.DESERT && biomegenbase != Biomes.DESERT_HILLS && this.settings.useWaterLakes && !flag && this.rand.nextInt(this.settings.waterLakeChance) == 0 && TerrainGen.populate(this, worldObj, rand, p_73153_2_, p_73153_3_, flag, LAKE)) { k1 = this.rand.nextInt(16) + 8; l1 = this.rand.nextInt(256); i2 = this.rand.nextInt(16) + 8; (new WorldGenLakes(Blocks.LAVA)).generate(this.worldObj, this.rand, blockpos.add(k1, l1, i2)); } if (TerrainGen.populate(this, worldObj, rand, p_73153_2_, p_73153_3_, flag, LAVA) && !flag && this.rand.nextInt(this.settings.lavaLakeChance / 10) == 0 && this.settings.useLavaLakes) { k1 = this.rand.nextInt(16) + 8; l1 = this.rand.nextInt(this.rand.nextInt(248) + 8); i2 = this.rand.nextInt(16) + 8; if (l1 < 63 || this.rand.nextInt(this.settings.lavaLakeChance / 8) == 0) { (new WorldGenLakes(Blocks.LAVA)).generate(this.worldObj, this.rand, blockpos.add(k1, l1, i2)); } } biomegenbase.decorate(this.worldObj, this.rand, new BlockPos(k, 0, l)); if (TerrainGen.populate(this, worldObj, rand, p_73153_2_, p_73153_3_, flag, ANIMALS)) { WorldEntitySpawner.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand); } blockpos = blockpos.add(8, 0, 8); boolean doGen = TerrainGen.populate(this, worldObj, rand, p_73153_2_, p_73153_3_, flag, ICE); for (k1 = 0; doGen && k1 < 16; ++k1) { for (l1 = 0; l1 < 16; ++l1) { BlockPos blockpos1 = this.worldObj.getPrecipitationHeight(blockpos.add(k1, 0, l1)); BlockPos blockpos2 = blockpos1.down(); if (this.worldObj.canBlockFreezeWater(blockpos2)) { this.worldObj.setBlockState(blockpos2, Blocks.ICE.getDefaultState(), 2); } } } net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.worldObj, this.rand, p_73153_2_, p_73153_3_, flag); BlockFalling.fallInstantly = false; } public List <biome.spawnlistentry>getPossibleCreatures(EnumCreatureType p_177458_1_, BlockPos p_177458_2_) { Biome biomegenbase = this.worldObj.getBiomeGenForCoords(p_177458_2_); return biomegenbase.getSpawnableList(p_177458_1_); } @Nullable public BlockPos getStrongholdGen(World worldIn, String p_180513_2_, BlockPos p_180513_3_) { return null; } public void recreateStructures(Chunk p_180514_1_, int p_180514_2_, int p_180514_3_) { } public boolean generateStructures(Chunk chunkIn, int x, int z) { return false; } }
Qui est appelé par ```java
public IChunkGenerator createChunkGenerator()
{
return new ChunkProviderFrightful(this.worldObj, this.worldObj.getSeed(), false, “”);
}de la classe WoldProviderFrightful. Comme vous pouvez voir, le dernier arguement, qui est un String, est nul. Donc cette condition ```java if (p_i46668_5_ != null) { this.settings = ChunkProviderSettings.Factory.jsonToFactory(p_i46668_5_).build(); this.oceanBlock = this.settings.useLavaOceans ? Blocks.LAVA.getDefaultState() : Blocks.WATER.getDefaultState(); worldIn.setSeaLevel(this.settings.seaLevel); } ``` ne devrait pas être considéré, vu que la condition n'est pas respectée. Or, c'est elle qui fait toute la différence. Quand je l'enlève et que je rentre dans le portail, ça met met une erreur (le jeu continue de fonctionner) :
[14:35:45] [Server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: net.minecraft.util.ReportedException: Exception generating new chunk
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_131]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_131]
at net.minecraft.util.Util.runTask(Util.java:29) [Util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:743) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:688) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:537) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
Caused by: net.minecraft.util.ReportedException: Exception generating new chunk
at net.minecraft.entity.Entity.moveEntity(Entity.java:969) ~[Entity.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:499) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.CPacketPlayer.processPacket(CPacketPlayer.java:36) ~[CPacketPlayer.class:?]
at net.minecraft.network.play.client.CPacketPlayer$Position.processPacket(CPacketPlayer.java:85) ~[CPacketPlayer$Position.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_131]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_131]
at net.minecraft.util.Util.runTask(Util.java:28) ~[Util.class:?]
… 5 more
Caused by: java.lang.NullPointerException
at thisishalloween.world.frightful.ChunkProviderFrightful.generateHeightmap(ChunkProviderFrightful.java:269) ~[ChunkProviderFrightful.class:?]
at thisishalloween.world.frightful.ChunkProviderFrightful.setBlocksInChunk(ChunkProviderFrightful.java:158) ~[ChunkProviderFrightful.class:?]
at thisishalloween.world.frightful.ChunkProviderFrightful.provideChunk(ChunkProviderFrightful.java:251) ~[ChunkProviderFrightful.class:?]
at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:150) ~[ChunkProviderServer.class:?]
at net.minecraft.world.World.getChunkFromChunkCoords(World.java:353) ~[World.class:?]
at net.minecraft.world.World.getChunkFromBlockCoords(World.java:345) ~[World.class:?]
at net.minecraft.world.World.getBlockState(World.java:915) ~[World.class:?]
at thisishalloween.world.frightful.TeleporterFrightful.placeInExistingPortal(TeleporterFrightful.java:109) ~[TeleporterFrightful.class:?]
at thisishalloween.block.BlockPortalFrightful.travelToDimension(BlockPortalFrightful.java:314) ~[BlockPortalFrightful.class:?]
at thisishalloween.block.BlockPortalFrightful.onEntityCollidedWithBlock(BlockPortalFrightful.java:244) ~[BlockPortalFrightful.class:?]
at net.minecraft.entity.Entity.doBlockCollisions(Entity.java:1044) ~[Entity.class:?]
at net.minecraft.entity.Entity.moveEntity(Entity.java:962) ~[Entity.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:499) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.CPacketPlayer.processPacket(CPacketPlayer.java:36) ~[CPacketPlayer.class:?]
at net.minecraft.network.play.client.CPacketPlayer$Position.processPacket(CPacketPlayer.java:85) ~[CPacketPlayer$Position.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_131]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_131]
at net.minecraft.util.Util.runTask(Util.java:28) ~[Util.class:?]
… 5 more
[14:35:50] [Server thread/WARN]: Can’t keep up! Did the system time change, or is the server overloaded? Running 4743ms behind, skipping 94 tick(s)Alors que quand je laisse la condition, quand je rentre dans le portail, le monde arrete de s'actualiser (les mobs bougent plus) et dans les logs, ça ne marque que des loading dimension, unloading dimension. Quand je déco reco, j'atteris bien dans ma dimension mais sans portail et parfois dans des blocks. Ma première question est : comment ça se fait que quand on enlève une fonction qui n'est pas prise en compte (la condition n'étant pas considéré), ça fait bug ? Ma deuxième question est : pourquoi je dois déco reco pour que le transfère vers ma dimension marche bien ? Et est-ce pour ça que le portail ne se créer pas ? J'ai essayé d'utiliser le Teleporter de base à la place du mien, pareil. Merci d'avance</biome.spawnlistentry>_
-
Alors déjà, c’est faux, le dernier argument n’est pas null mais c’est juste un string vide, donc la condition vaut vrai.
Ensuite l’erreur quand tu enlèves la condition vient du fait que “this.settings” vaut nul.
Et quand tu la laisse, ça a l’air de faire une boucle infinie de chargement/déchargement de la dimension du côté serveur selon ce que tu dis, et quand tu deco/reco il doi la considérer comme générée et donc ne pas générer de portail. La boucle est très certainement due au fait que ton dernier argument est un string vide, donc il doit pas arriver à charger les settings.En conclusion, je sais pas comment on utilise ces “settings” en 1.10 mais il faut que tu regardes ça et que tu ne mette pas un string vide.
-
Ok merci. Je vais voir les settings et je reviens quand j’aurais trouvé
-
Salut
Désolé du temps de la réponse.Ca ne marche toujours pas. J’ai enlevé tout ce qui faisait allusion aux settings, et j’ai remplacé la variable par la valeur correspondante (par exemple, lowerLimitScale vaut 512.0F).
Pas d’erreur quand je vais dans le portail, mais j’ai toujours le loading unloading à l’infini. Plus rien ne s’actualise.
Je vous remet la classe ChunkProviderFrightful :package thisishalloween.world.frightful; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA; import java.util.List; import java.util.Random; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Biomes; import net.minecraft.init.Blocks; import net.minecraft.util.IProgressUpdate; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.WorldEntitySpawner; import net.minecraft.world.WorldType; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.SpawnListEntry; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderSettings; import net.minecraft.world.gen.NoiseGeneratorOctaves; import net.minecraft.world.gen.NoiseGeneratorPerlin; import net.minecraft.world.gen.feature.WorldGenLakes; import net.minecraft.world.gen.structure.MapGenMineshaft; import net.minecraft.world.gen.structure.MapGenScatteredFeature; import net.minecraft.world.gen.structure.MapGenStronghold; import net.minecraft.world.gen.structure.MapGenVillage; import net.minecraft.world.gen.structure.StructureOceanMonument; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.ChunkGeneratorEvent; import net.minecraftforge.event.terraingen.InitNoiseGensEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; import net.minecraftforge.fml.common.eventhandler.Event.Result; import thisishalloween.ThisisHalloween; public class ChunkProviderFrightful implements IChunkGenerator { /** RNG. */ private Random rand; private NoiseGeneratorOctaves minLimitPerlinNoise; private NoiseGeneratorOctaves maxLimitPerlinNoise; private NoiseGeneratorOctaves mainPerlinNoise; private NoiseGeneratorPerlin surfaceNoise; public NoiseGeneratorOctaves scaleNoise; public NoiseGeneratorOctaves depthNoise; public NoiseGeneratorOctaves forestNoise; private World worldObj; private final boolean mapFeaturesEnabled; private WorldType field_177475_o; private final double[] field_147434_q; private final float[] biomeWeights; private double[] stoneNoise; private Biome[] biomesForGeneration; double[] field_147427_d; double[] field_147428_e; double[] field_147425_f; double[] field_147426_g; private IBlockState oceanBlock = Blocks.LAVA.getDefaultState(); public ChunkProviderFrightful(World worldIn, long seed, boolean mapFeaturesEnabledIn) { this.worldObj = worldIn; this.mapFeaturesEnabled = mapFeaturesEnabledIn; this.field_177475_o = worldIn.getWorldInfo().getTerrainType(); this.rand = new Random(seed); this.minLimitPerlinNoise = new NoiseGeneratorOctaves(this.rand, 16); this.maxLimitPerlinNoise = new NoiseGeneratorOctaves(this.rand, 16); this.mainPerlinNoise = new NoiseGeneratorOctaves(this.rand, 8); this.surfaceNoise = new NoiseGeneratorPerlin(this.rand, 4); this.scaleNoise = new NoiseGeneratorOctaves(this.rand, 10); this.depthNoise = new NoiseGeneratorOctaves(this.rand, 16); this.forestNoise = new NoiseGeneratorOctaves(this.rand, 8); this.field_147434_q = new double[825]; this.biomeWeights = new float[25]; for (int i = -2; i <= 2; ++i) { for (int j = -2; j <= 2; ++j) { float f = 10.0F / MathHelper.sqrt_float((float)(i * i + j * j) + 0.2F); this.biomeWeights _= f; } } this.oceanBlock = Blocks.LAVA.getDefaultState(); worldIn.setSeaLevel(40);//TODO net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld ctx = new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld(minLimitPerlinNoise, maxLimitPerlinNoise, mainPerlinNoise, surfaceNoise, scaleNoise, depthNoise, forestNoise); ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(worldIn, this.rand, ctx); this.minLimitPerlinNoise = ctx.getLPerlin1(); this.maxLimitPerlinNoise = ctx.getLPerlin2(); this.mainPerlinNoise = ctx.getPerlin(); this.surfaceNoise = ctx.getHeight(); this.scaleNoise = ctx.getScale(); this.depthNoise = ctx.getDepth(); this.forestNoise = ctx.getForest(); } public void setBlocksInChunk(int x, int z, ChunkPrimer primer) { this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); this.generateHeightmap(x * 4, 0, z * 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 = this.field_147434_q[k1 + k2]; double d2 = this.field_147434_q[l1 + k2]; double d3 = this.field_147434_q[i2 + k2]; double d4 = this.field_147434_q[j2 + k2]; double d5 = (this.field_147434_q[k1 + k2 + 1] - d1) * d0; double d6 = (this.field_147434_q[l1 + k2 + 1] - d2) * d0; double d7 = (this.field_147434_q[i2 + k2 + 1] - d3) * d0; double d8 = (this.field_147434_q[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) { double d14 = 0.25D; double d16 = (d11 - d10) * d14; double d15 = d10 - d16; for (int j3 = 0; j3 < 4; ++j3) { if ((d15 += d16) > 0.0D) { primer.setBlockState(k * 4 + i3, k2 * 8 + l2, j1 * 4 + j3, Blocks.STONE.getDefaultState()); } else if (k2 * 8 + l2 < 40)//TODO { primer.setBlockState(k * 4 + i3, k2 * 8 + l2, j1 * 4 + j3, Blocks.LAVA.getDefaultState()); } } d10 += d12; d11 += d13; } d1 += d5; d2 += d6; d3 += d7; d4 += d8; } } } } } public void replaceBiomeBlocks(int p_180517_1_, int p_180517_2_, ChunkPrimer p_180517_3_, Biome[] p_180517_4_) { ChunkGeneratorEvent.ReplaceBiomeBlocks event = new ChunkGeneratorEvent.ReplaceBiomeBlocks(this, p_180517_1_, p_180517_2_, p_180517_3_, this.worldObj); MinecraftForge.EVENT_BUS.post(event); if (event.getResult() == Result.DENY) return; double d0 = 0.03125D; this.stoneNoise = this.surfaceNoise.getRegion(this.stoneNoise, (double)(p_180517_1_ * 16), (double)(p_180517_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) { Biome biomegenbase = p_180517_4_[l + k * 16]; biomegenbase.genTerrainBlocks(this.worldObj, this.rand, p_180517_3_, p_180517_1_ * 16 + k, p_180517_2_ * 16 + l, this.stoneNoise[l + k * 16]); } } } /** * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the * specified chunk from the map seed and chunk seed */ public Chunk provideChunk(int x, int z) { this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L); ChunkPrimer chunkprimer = new ChunkPrimer(); this.setBlocksInChunk(x, z, chunkprimer); this.biomesForGeneration = this.worldObj.getBiomeProvider().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16); this.replaceBiomeBlocks(x, z, chunkprimer, this.biomesForGeneration); Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z); byte[] abyte = chunk.getBiomeArray(); for (int k = 0; k < abyte.length; ++k) { abyte[k] = (byte)this.biomesForGeneration[k].getIdForBiome(ThisisHalloween.biomeToSpawnIn); } chunk.generateSkylightMap(); return chunk; } private void generateHeightmap(int p_147423_1_, int p_147423_2_, int p_147423_3_) { this.field_147426_g = this.depthNoise.generateNoiseOctaves(this.field_147426_g, p_147423_1_, p_147423_3_, 5, 5, (double)200, (double)200, (double)0.5); float f = 684.412F; float f1 = 684.12F; this.field_147427_d = this.mainPerlinNoise.generateNoiseOctaves(this.field_147427_d, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)(f / 80), (double)(f1 / 160), (double)(f / 80)); this.field_147428_e = this.minLimitPerlinNoise.generateNoiseOctaves(this.field_147428_e, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)f, (double)f1, (double)f); this.field_147425_f = this.maxLimitPerlinNoise.generateNoiseOctaves(this.field_147425_f, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, (double)f, (double)f1, (double)f); boolean flag1 = false; boolean flag = false; int l = 0; int i1 = 0; for (int j1 = 0; j1 < 5; ++j1) { for (int k1 = 0; k1 < 5; ++k1) { float f2 = 0.0F; float f3 = 0.0F; float f4 = 0.0F; byte b0 = 2; Biome biomegenbase = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { Biome biomegenbase1 = this.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; float f5 = 0 + biomegenbase1.getBaseHeight() * 1.0F; float f6 = 0 + biomegenbase1.getHeightVariation() * 1.0F; float f7 = this.biomeWeights[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F); if (biomegenbase1.getBaseHeight() > biomegenbase.getBaseHeight()) { f7 /= 2.0F; } f2 += f6 * f7; f3 += f5 * f7; f4 += f7; } } f2 /= f4; f3 /= f4; f2 = f2 * 0.9F + 0.1F; f3 = (f3 * 4.0F - 1.0F) / 8.0F; double d7 = this.field_147426_g[i1] / 8000.0D; if (d7 < 0.0D) { d7 = -d7 * 0.3D; } d7 = d7 * 3.0D - 2.0D; if (d7 < 0.0D) { d7 /= 2.0D; if (d7 < -1.0D) { d7 = -1.0D; } d7 /= 1.4D; d7 /= 2.0D; } else { if (d7 > 1.0D) { d7 = 1.0D; } d7 /= 8.0D; } ++i1; double d8 = (double)f3; double d9 = (double)f2; d8 += d7 * 0.2D; d8 = d8 * (double)8.5F / 8.0D; double d0 = (double)8.5F + d8 * 4.0D; for (int j2 = 0; j2 < 33; ++j2) { double d1 = ((double)j2 - d0) * (double)12.0F * 128.0D / 256.0D / d9; if (d1 < 0.0D) { d1 *= 4.0D; } double d2 = this.field_147428_e[l] / (double)512.0F; double d3 = this.field_147425_f[l] / (double)512.0F; double d4 = (this.field_147427_d[l] / 10.0D + 1.0D) / 2.0D; double d5 = MathHelper.denormalizeClamp(d2, d3, d4) - d1; if (j2 > 29) { double d6 = (double)((float)(j2 - 29) / 3.0F); d5 = d5 * (1.0D - d6) + -10.0D * d6; } this.field_147434_q[l] = d5; ++l; } } } } /** * Populates chunk with ores etc etc */ public void populate(int p_73153_2_, int p_73153_3_) { BlockFalling.fallInstantly = true; int k = p_73153_2_ * 16; int l = p_73153_3_ * 16; BlockPos blockpos = new BlockPos(k, 0, l); Biome biomegenbase = this.worldObj.getBiomeGenForCoords(blockpos.add(16, 0, 16)); this.rand.setSeed(this.worldObj.getSeed()); long i1 = this.rand.nextLong() / 2L * 2L + 1L; long j1 = this.rand.nextLong() / 2L * 2L + 1L; this.rand.setSeed((long)p_73153_2_ * i1 + (long)p_73153_3_ * j1 ^ this.worldObj.getSeed()); boolean flag = false; ChunkPos chunkcoordintpair = new ChunkPos(p_73153_2_, p_73153_3_); net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.worldObj, this.rand, p_73153_2_, p_73153_3_, flag); int k1; int l1; int i2; if (biomegenbase != Biomes.DESERT && biomegenbase != Biomes.DESERT_HILLS && !flag && TerrainGen.populate(this, worldObj, rand, p_73153_2_, p_73153_3_, flag, LAKE)) { k1 = this.rand.nextInt(16) + 8; l1 = this.rand.nextInt(256); i2 = this.rand.nextInt(16) + 8; (new WorldGenLakes(Blocks.LAVA)).generate(this.worldObj, this.rand, blockpos.add(k1, l1, i2)); } if (TerrainGen.populate(this, worldObj, rand, p_73153_2_, p_73153_3_, flag, LAVA) && !flag) { k1 = this.rand.nextInt(16) + 8; l1 = this.rand.nextInt(this.rand.nextInt(248) + 8); i2 = this.rand.nextInt(16) + 8; if (l1 < 63) { (new WorldGenLakes(Blocks.LAVA)).generate(this.worldObj, this.rand, blockpos.add(k1, l1, i2)); } } biomegenbase.decorate(this.worldObj, this.rand, new BlockPos(k, 0, l)); if (TerrainGen.populate(this, worldObj, rand, p_73153_2_, p_73153_3_, flag, ANIMALS)) { WorldEntitySpawner.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand); } blockpos = blockpos.add(8, 0, 8); boolean doGen = TerrainGen.populate(this, worldObj, rand, p_73153_2_, p_73153_3_, flag, ICE); for (k1 = 0; doGen && k1 < 16; ++k1) { for (l1 = 0; l1 < 16; ++l1) { BlockPos blockpos1 = this.worldObj.getPrecipitationHeight(blockpos.add(k1, 0, l1)); BlockPos blockpos2 = blockpos1.down(); if (this.worldObj.canBlockFreezeWater(blockpos2)) { this.worldObj.setBlockState(blockpos2, Blocks.ICE.getDefaultState(), 2); } } } net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.worldObj, this.rand, p_73153_2_, p_73153_3_, flag); BlockFalling.fallInstantly = false; } public List <biome.spawnlistentry>getPossibleCreatures(EnumCreatureType p_177458_1_, BlockPos p_177458_2_) { Biome biomegenbase = this.worldObj.getBiomeGenForCoords(p_177458_2_); return biomegenbase.getSpawnableList(p_177458_1_); } @Nullable public BlockPos getStrongholdGen(World worldIn, String p_180513_2_, BlockPos p_180513_3_) { return null; } public void recreateStructures(Chunk p_180514_1_, int p_180514_2_, int p_180514_3_) { } public boolean generateStructures(Chunk chunkIn, int x, int z) { return false; } }
Pourtant ça ressemble comme deux gouttes d’eau à celui de l’Overworld. Je vais essayer d’autres trucs.
Je reviens si j’ai trouvé</biome.spawnlistentry>_ -
Salut
J’ai avancé et j’ai partiellement trouvé où chercher.
C’est soit dans le WorldProvider, soit dans la création du Dimension Typepackage thisishalloween.world.frightful; import net.minecraft.init.Biomes; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.DimensionType; import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldType; import net.minecraft.world.biome.BiomeProviderSingle; import net.minecraft.world.border.WorldBorder; import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.gen.ChunkProviderHell; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import thisishalloween.ThisisHalloween; public class WorldProviderFrightful extends WorldProvider{ protected int dimensionId; public final void createBiomeProvider() { this.biomeProvider = new BiomeProviderFrightful(worldObj.getWorldInfo()); } public String getSaveFolder() { return ThisisHalloween.DIMENSION_NAME; } public boolean isSurfaceWorld() { return false; } public boolean canRespawnHere() { return false; } protected void generateLightBrightnessTable() { float f = 0.2F; for(int i = 0; i <= 15; ++i) { float f1 = 1.0F - (float)i / 15.0F; this.lightBrightnessTable* = (1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f; } } public WorldBorder createWorldBorder() { return new WorldBorder() { public double getCenterX() { return super.getCenterX() / 8.0D; } public double getCenterZ() { return super.getCenterZ() / 8.0D; } }; } // Moon's and Sun's Angle public float calculateCelestialAngle(long par1, float par2) { int j = (int)(par1 % 24000L); float f1 = ((float)j + par2) / 24000.0F - 0.25F; if(f1 < 0.0F) { ++f1; } if(f1 > 1.0F) { –f1; } float f2 = f1; f1 = 1.0F - (float)((Math.cos((double)f1 * Math.PI) + 1.0D) / 2.0D); f1 = f2 + (f1 - f2) / 3.0F; return f1; } @SideOnly(Side.CLIENT) public boolean isSkyColored() { return true; } /**@Override public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) { return Vec3.createVectorHelper(10, 0, 20); }**/ public IChunkGenerator createChunkGenerator() { return new ChunkProviderFrightful(this.worldObj, this.worldObj.getSeed(), false); } @Override public DimensionType getDimensionType() { return ThisisHalloween.FRIGHTFUL_DIMENSION_TYPE; } public void setDimension(int dim) { this.dimensionId = ThisisHalloween.DIMENSION_ID; } public int getDimension() { return this.dimensionId; } public boolean getHasNoSky() { return false; } @SideOnly(Side.CLIENT) public Vec3d getFogColor(float p_76562_1_, float p_76562_2_) { float f = MathHelper.cos(p_76562_1_ * ((float)Math.PI * 2F)) * 2.0F + 0.5F; f = MathHelper.clamp_float(f, 0.0F, 1.0F); float f1 = 0.7529412F; float f2 = 0.84705883F; float f3 = 1.0F; f1 = f1 * (f * 0.94F + 0.06F); f2 = f2 * (f * 0.94F + 0.06F); f3 = f3 * (f * 0.91F + 0.09F); return new Vec3d((double)f1, (double)f2, (double)f3); } }
public static final DimensionType FRIGHTFUL_DIMENSION_TYPE = DimensionType.register("Frightful", "Frightful", DIMENSION_ID, WorldProviderFrightful.class, false);
Mais je pense que c’est dans le DimensionType. Je vais voir l’original, sur internet, et tout.
EDIT : dans le dimension type, j’ai changer la variable (qui permet le keep loading (en gros, s’il reste chargé)). Je l’ai passé en true. Dans les logs ça ne met plus les loading unloading, une seule fois loading (comme pour le nether). Par contre, ça bug quand même : plus rien ne s’actualise jusqu’à que je déco/reco (comme avant).
-
Salut
J’ai trouvé d’où vient le problème. Ce n’est pas la dimension (peut-être avant mais plus maintenant), c’est mon blockPortal. J’ai essayé de me transférer vers le nether en utilisant le teleporter de base, ça fait pareil.
Du coup, voillà mon blockPortail :package thisishalloween.block; import java.util.Random; import javax.annotation.Nullable; import com.google.common.cache.LoadingCache; import net.minecraft.block.Block; import net.minecraft.block.BlockBreakable; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockWorldState; import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.pattern.BlockPattern; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemMonsterPlacer; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.Rotation; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.Teleporter; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import thisishalloween.CreateBlocks; import thisishalloween.ThisisHalloween; import thisishalloween.world.frightful.TeleporterFrightful; public class BlockPortalFrightful extends BlockBreakable { public static final PropertyEnum <enumfacing.axis>AXIS = PropertyEnum.<enumfacing.axis>create("axis", EnumFacing.Axis.class, new EnumFacing.Axis[] {EnumFacing.Axis.X, EnumFacing.Axis.Z}); protected static final AxisAlignedBB field_185683_b = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D); protected static final AxisAlignedBB field_185684_c = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D); protected static final AxisAlignedBB field_185685_d = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D); public BlockPortalFrightful() { super(Material.PORTAL, false); this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.X)); this.setTickRandomly(true); this.setSoundType(SoundType.GLASS); } //TODO public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { super.updateTick(worldIn, pos, state, rand); if (worldIn.provider.isSurfaceWorld() && worldIn.getGameRules().getBoolean("doMobSpawning") && rand.nextInt(2000) < worldIn.getDifficulty().getDifficultyId()) { int i = pos.getY(); BlockPos blockpos; for (blockpos = pos; !worldIn.getBlockState(blockpos).isFullyOpaque() && blockpos.getY() > 0; blockpos = blockpos.down()) { ; } if (i > 0 && !worldIn.getBlockState(blockpos.up()).isNormalCube()) { Entity entity = ItemMonsterPlacer.spawnCreature(worldIn, EntityList.getEntityStringFromClass(EntityPigZombie.class), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 1.1D, (double)blockpos.getZ() + 0.5D); if (entity != null) { entity.timeUntilPortal = entity.getPortalCooldown(); } } } } @Nullable public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { return NULL_AABB; } public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { switch ((EnumFacing.Axis)state.getValue(AXIS)) { case X: return field_185683_b; case Y: default: return field_185685_d; case Z: return field_185684_c; } } public static int getMetaForAxis(EnumFacing.Axis axis) { return axis == EnumFacing.Axis.X ? 1 : (axis == EnumFacing.Axis.Z ? 2 : 0); } public boolean isFullCube(IBlockState state) { return false; } public boolean trySpawnPortal(World worldIn, BlockPos pos) { BlockPortalFrightful.Size blockportal$size = new BlockPortalFrightful.Size(worldIn, pos, EnumFacing.Axis.X); if (blockportal$size.isValid() && blockportal$size.portalBlockCount == 0) { blockportal$size.placePortalBlocks(); return true; } else { BlockPortalFrightful.Size blockportal$size1 = new BlockPortalFrightful.Size(worldIn, pos, EnumFacing.Axis.Z); if (blockportal$size1.isValid() && blockportal$size1.portalBlockCount == 0) { blockportal$size1.placePortalBlocks(); return true; } else { return false; } } } public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { EnumFacing.Axis axis = (EnumFacing.Axis)state.getValue(AXIS); if (axis == EnumFacing.Axis.X) { BlockPortalFrightful.Size size = new BlockPortalFrightful.Size(worldIn, pos, EnumFacing.Axis.X); if (!size.isValid() || size.portalBlockCount < size.width * size.height) { if(ThisisHalloween.portal) { worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); } } } else if (axis == EnumFacing.Axis.Z) { BlockPortalFrightful.Size size = new BlockPortalFrightful.Size(worldIn, pos, EnumFacing.Axis.Z); if (!size.isValid() || size.portalBlockCount < size.width * size.height) { if(ThisisHalloween.portal) { worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); } } } } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { EnumFacing.Axis axis = null; pos = pos.offset(side); if (blockState.getBlock() == this) { axis = (EnumFacing.Axis)blockState.getValue(AXIS); if (axis == null) { return false; } if (axis == EnumFacing.Axis.Z && side != EnumFacing.EAST && side != EnumFacing.WEST) { return false; } if (axis == EnumFacing.Axis.X && side != EnumFacing.SOUTH && side != EnumFacing.NORTH) { return false; } } boolean flag = blockAccess.getBlockState(pos.west()).getBlock() == this && blockAccess.getBlockState(pos.west(2)).getBlock() != this; boolean flag1 = blockAccess.getBlockState(pos.east()).getBlock() == this && blockAccess.getBlockState(pos.east(2)).getBlock() != this; boolean flag2 = blockAccess.getBlockState(pos.north()).getBlock() == this && blockAccess.getBlockState(pos.north(2)).getBlock() != this; boolean flag3 = blockAccess.getBlockState(pos.south()).getBlock() == this && blockAccess.getBlockState(pos.south(2)).getBlock() != this; boolean flag4 = flag || flag1 || axis == EnumFacing.Axis.X; boolean flag5 = flag2 || flag3 || axis == EnumFacing.Axis.Z; return flag4 && side == EnumFacing.WEST ? true : (flag4 && side == EnumFacing.EAST ? true : (flag5 && side == EnumFacing.NORTH ? true : flag5 && side == EnumFacing.SOUTH)); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random random) { return 0; } /** * Called When an Entity Collided with the Block */ @Override public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { if (entityIn.getRidingEntity() == null && entityIn.getRidingEntity() == null && entityIn.timeUntilPortal <= 0 && !worldIn.isRemote) { int id = -1; if (entityIn.dimension == id) { id = 0; } if (entityIn instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) entityIn; MinecraftServer mcServer = entityIn.getServer(); if (player.timeUntilPortal > 0) { player.timeUntilPortal = 100; } else if (player.dimension != id) { ThisisHalloween.portal = false; // mcServer.getPlayerList().transferPlayerToDimension(player, -1, new Teleporter(mcServer.worldServerForDimension(-1))); //entityIn.changeDimension(-1); travelToDimension(player, id); player.timeUntilPortal = 100; ThisisHalloween.portal = true; } else { // mcServer.getPlayerList().transferPlayerToDimension(player, 0, new TeleporterFrightful(mcServer.worldServerForDimension(0))); // entityIn.changeDimension(0); travelToDimension(player, 0); player.timeUntilPortal = 100; } // System.out.println("appel travel"); // player.timeUntilPortal = 100; } } } public Entity travelToDimension(Entity entity, int dimensionIn) { if (!entity.worldObj.isRemote && !entity.isDead) { if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(entity, dimensionIn)) return null; entity.worldObj.theProfiler.startSection("changeDimension"); MinecraftServer minecraftserver = entity.getServer(); int i = entity.dimension; WorldServer worldserver = minecraftserver.worldServerForDimension(i); WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionIn); entity.dimension = dimensionIn; if (i == 1 && dimensionIn == 1) { worldserver1 = minecraftserver.worldServerForDimension(0); entity.dimension = 0; } entity.worldObj.removeEntity(entity); entity.isDead = false; entity.worldObj.theProfiler.startSection("reposition"); BlockPos blockpos; if (dimensionIn == 1) { blockpos = worldserver1.getSpawnCoordinate(); } else { double d0 = entity.posX; double d1 = entity.posZ; double d2 = 8.0D; if (dimensionIn == -1) { d0 = MathHelper.clamp_double(d0 / d2, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D); d1 = MathHelper.clamp_double(d1 / d2, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D); } else if (dimensionIn == 0) { d0 = MathHelper.clamp_double(d0 * d2, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D); d1 = MathHelper.clamp_double(d1 * d2, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D); } d0 = (double)MathHelper.clamp_int((int)d0, -29999872, 29999872); d1 = (double)MathHelper.clamp_int((int)d1, -29999872, 29999872); float f = entity.rotationYaw; entity.setLocationAndAngles(d0, entity.posY, d1, 90.0F, 0.0F); Teleporter teleporter = new Teleporter(entity.getServer().worldServerForDimension(entity.dimension)); teleporter.placeInExistingPortal(entity, f); blockpos = new BlockPos(entity); } worldserver.updateEntityWithOptionalForce(entity, false); entity.worldObj.theProfiler.endStartSection("reloading"); Entity entity1 = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1); if (entity1 != null) { // entity1.copyDataFromOld(entity1); BlockPos lastPortalPos = new BlockPos(entity.posX, entity.posY, entity.posZ); Vec3d lastPortalVec = entity.getLastPortalVec(); EnumFacing teleportDirection = entity.getTeleportDirection(); entity.timeUntilPortal = entity1.timeUntilPortal; ObfuscationReflectionHelper.setPrivateValue(Entity.class, entity1, lastPortalPos, "lastPortalPos"); ObfuscationReflectionHelper.setPrivateValue(Entity.class, entity1, lastPortalVec, "lastPortalVec"); ObfuscationReflectionHelper.setPrivateValue(Entity.class, entity1, teleportDirection, "teleportDirection"); if (i == 1 && dimensionIn == 1) { BlockPos blockpos1 = worldserver1.getTopSolidOrLiquidBlock(worldserver1.getSpawnPoint()); entity1.moveToBlockPosAndAngles(blockpos1, entity1.rotationYaw, entity1.rotationPitch); } else { entity1.moveToBlockPosAndAngles(blockpos, entity1.rotationYaw, entity1.rotationPitch); } boolean flag = entity1.forceSpawn; entity1.forceSpawn = true; worldserver1.spawnEntityInWorld(entity1); entity1.forceSpawn = flag; worldserver1.updateEntityWithOptionalForce(entity1, false); } entity.isDead = true; entity.worldObj.theProfiler.endSection(); worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); entity.worldObj.theProfiler.endSection(); return entity1; } else { return null; } } /* public void transferEntityToWorld(Entity entityIn, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_) { transferEntityToWorld(entityIn, thisishalloween.ThisisHalloween.DIMENSIONID, DimensionManager.getWorld(0), DimensionManager.getWorld(thisishalloween.ThisisHalloween.DIMENSIONID)); }*/ /** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(AXIS, (meta & 3) == 2 ? EnumFacing.Axis.Z : EnumFacing.Axis.X); } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { if (rand.nextInt(100) == 0) { world.playSound((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, rand.nextFloat() * 0.4F + 0.8F, false); } for (int i = 0; i < 4; ++i) { double d0 = (double)((float)pos.getX() + rand.nextFloat()); double d1 = (double)((float)pos.getY() + rand.nextFloat()); double d2 = (double)((float)pos.getZ() + rand.nextFloat()); double d3 = ((double)rand.nextFloat() - 0.5D) * 0.5D; double d4 = ((double)rand.nextFloat() - 0.5D) * 0.5D; double d5 = ((double)rand.nextFloat() - 0.5D) * 0.5D; int j = rand.nextInt(2) * 2 - 1; if (world.getBlockState(pos.west()).getBlock() != this && world.getBlockState(pos.east()).getBlock() != this) { d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j; d3 = (double)(rand.nextFloat() * 2.0F * (float)j); } else { d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)j; d5 = (double)(rand.nextFloat() * 2.0F * (float)j); } world.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]); } } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return getMetaForAxis((EnumFacing.Axis)state.getValue(AXIS)); } @SideOnly(Side.CLIENT) public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { return null; } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {AXIS}); } public IBlockState withRotation(IBlockState state, Rotation rot) { switch (rot) { case COUNTERCLOCKWISE_90: case CLOCKWISE_90: switch ((EnumFacing.Axis)state.getValue(AXIS)) { case X: return state.withProperty(AXIS, EnumFacing.Axis.Z); case Z: return state.withProperty(AXIS, EnumFacing.Axis.X); default: return state; } default: return state; } } public BlockPattern.PatternHelper createPatternHelper(World worldIn, BlockPos p_181089_2_) { EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Z; BlockPortalFrightful.Size blockportal$size = new BlockPortalFrightful.Size(worldIn, p_181089_2_, EnumFacing.Axis.X); LoadingCache <blockpos, blockworldstate="">loadingcache = BlockPattern.createLoadingCache(worldIn, true); if (!blockportal$size.isValid()) { enumfacing$axis = EnumFacing.Axis.X; blockportal$size = new BlockPortalFrightful.Size(worldIn, p_181089_2_, EnumFacing.Axis.Z); } if (!blockportal$size.isValid()) { return new BlockPattern.PatternHelper(p_181089_2_, EnumFacing.NORTH, EnumFacing.UP, loadingcache, 1, 1, 1); } else { int[] aint = new int[EnumFacing.AxisDirection.values().length]; EnumFacing enumfacing = blockportal$size.rightDir.rotateYCCW(); BlockPos blockpos = blockportal$size.bottomLeft.up(blockportal$size.getHeight() - 1); for (EnumFacing.AxisDirection enumfacing$axisdirection : EnumFacing.AxisDirection.values()) { BlockPattern.PatternHelper blockpattern$patternhelper = new BlockPattern.PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1); for (int i = 0; i < blockportal$size.getWidth(); ++i) { for (int j = 0; j < blockportal$size.getHeight(); ++j) { BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, 1); if (blockworldstate.getBlockState() != null && blockworldstate.getBlockState().getMaterial() != Material.AIR) { ++aint[enumfacing$axisdirection.ordinal()]; } } } } EnumFacing.AxisDirection enumfacing$axisdirection1 = EnumFacing.AxisDirection.POSITIVE; for (EnumFacing.AxisDirection enumfacing$axisdirection2 : EnumFacing.AxisDirection.values()) { if (aint[enumfacing$axisdirection2.ordinal()] < aint[enumfacing$axisdirection1.ordinal()]) { enumfacing$axisdirection1 = enumfacing$axisdirection2; } } return new BlockPattern.PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection1 ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection1, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1); } } public static class Size { private final World world; private final EnumFacing.Axis axis; private final EnumFacing rightDir; private final EnumFacing leftDir; private int portalBlockCount; private BlockPos bottomLeft; private int height; private int width; public Size(World worldIn, BlockPos p_i45694_2_, EnumFacing.Axis p_i45694_3_) { this.world = worldIn; this.axis = p_i45694_3_; if (p_i45694_3_ == EnumFacing.Axis.X) { this.leftDir = EnumFacing.EAST; this.rightDir = EnumFacing.WEST; } else { this.leftDir = EnumFacing.NORTH; this.rightDir = EnumFacing.SOUTH; } for (BlockPos blockpos = p_i45694_2_; p_i45694_2_.getY() > blockpos.getY() - 21 && p_i45694_2_.getY() > 0 && this.isEmptyBlock(worldIn.getBlockState(p_i45694_2_.down()).getBlock()); p_i45694_2_ = p_i45694_2_.down()) { ; } int i = this.getDistanceUntilEdge(p_i45694_2_, this.leftDir) - 1; if (i >= 0) { this.bottomLeft = p_i45694_2_.offset(this.leftDir, i); this.width = this.getDistanceUntilEdge(this.bottomLeft, this.rightDir); if (this.width < 2 || this.width > 21) { this.bottomLeft = null; this.width = 0; } } if (this.bottomLeft != null) { this.height = this.calculatePortalHeight(); } } protected int getDistanceUntilEdge(BlockPos p_180120_1_, EnumFacing p_180120_2_) { int i; for (i = 0; i < 22; ++i) { BlockPos blockpos = p_180120_1_.offset(p_180120_2_, i); if (!this.isEmptyBlock(this.world.getBlockState(blockpos).getBlock()) || this.world.getBlockState(blockpos.down()).getBlock() != Blocks.NETHER_BRICK) { break; } } Block block = this.world.getBlockState(p_180120_1_.offset(p_180120_2_, i)).getBlock(); return block == Blocks.NETHER_BRICK ? i : 0; } public int getHeight() { return this.height; } public int getWidth() { return this.width; } protected int calculatePortalHeight() { label24: for (this.height = 0; this.height < 21; ++this.height) { for (int i = 0; i < this.width; ++i) { BlockPos blockpos = this.bottomLeft.offset(this.rightDir, i).up(this.height); Block block = this.world.getBlockState(blockpos).getBlock(); if (!this.isEmptyBlock(block)) { break label24; } if (block == Blocks.PORTAL) { ++this.portalBlockCount; } if (i == 0) { block = this.world.getBlockState(blockpos.offset(this.leftDir)).getBlock(); if (block != Blocks.NETHER_BRICK) { break label24; } } else if (i == this.width - 1) { block = this.world.getBlockState(blockpos.offset(this.rightDir)).getBlock(); if (block != Blocks.NETHER_BRICK) { break label24; } } } } for (int j = 0; j < this.width; ++j) { if (this.world.getBlockState(this.bottomLeft.offset(this.rightDir, j).up(this.height)).getBlock() != Blocks.NETHER_BRICK) { this.height = 0; break; } } if (this.height <= 21 && this.height >= 3) { return this.height; } else { this.bottomLeft = null; this.width = 0; this.height = 0; return 0; } } protected boolean isEmptyBlock(Block p_150857_1_) { return p_150857_1_.getMaterial(p_150857_1_.getDefaultState()) == Material.AIR || p_150857_1_ == CreateBlocks.portalFrightful; } public boolean isValid() { return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } public void placePortalBlocks() { for (int i = 0; i < this.width; ++i) { BlockPos blockpos = this.bottomLeft.offset(this.rightDir, i); for (int j = 0; j < this.height; ++j) { this.world.setBlockState(blockpos.up(j), CreateBlocks.portalFrightful.getDefaultState().withProperty(BlockPortalFrightful.AXIS, this.axis), 2); } } } } }
J’ai essayé plein de trucs, mais ça mène au même bug. Quelqu’un aurait une solution ?
Merci d’avanceEDIT : j’ai enfiiinnn résolu ce problème
Dans le blockPortal, j’ai utilisé pour me téléportermcServer.getPlayerList().transferPlayerToDimension(player, id, new TeleporterFrightful(mcServer.worldServerForDimension(id)));
Vous auriez dû voir ma joie quand j’ai vu que ça marchait. Ca fait plusieurs mois que je cherche sans succès</blockpos,></enumfacing.axis></enumfacing.axis>