Résolu Problème dimension /:
-
Yop everybody , je fais un sujet car j’ai un problème avec ma dimension , quand je rentre en contact avec le portail block , bah je suis téléporté nulle part pourtant j’ai bien dans les logs quand je met sur pause la dimension que j’ai créer enregistrer ::) Donc déjà une bonne nouvelle ::p J’ai aussi un problème le portail ne tourne selon “l’inclinaison” de la structure du portail
Je met toutes mes classes etc
Ancient Teleporterpackage mod.common.world.structure; import java.util.ArrayList; import java.util.List; import java.util.Random; import mod.common.block.BlockPortail; import mod.common.block.BlockRegister; import net.minecraft.block.Block; import net.minecraft.block.BlockPortal; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.LongHashMap; import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.Teleporter; import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.ChunkCoordComparator; public class AncientTeleporter extends Teleporter { private final WorldServer worldServerInstance; private final Random random; private final LongHashMap destinationCoordinateCache = new LongHashMap(); private final List destinationCoordinateKeys = new ArrayList(); public AncientTeleporter(WorldServer worldServer) { super(worldServer); this.worldServerInstance = worldServer; this.random = new Random(worldServer.getSeed()); } public void placeInPortal(Entity entity, double x, double y, double z, float rotationYaw) { if(this.worldServerInstance.provider.getDimensionId() != 1) { if(!this.placeInExistingPortal(entity, rotationYaw))
Portail Block
package mod.common.block; import java.util.Random; import mod.common.world.structure.AncientTeleporter; import mod.common.world.structure.DimensionRegister; import net.minecraft.block.Block; import net.minecraft.block.BlockPortal; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockPortail extends Block { protected BlockPortail(Material material) { super(material.portal); this.setTickRandomly(true); this.setStepSound(Block.soundTypeGlass); this.setLightLevel(0.75F); this.setCreativeTab(CreativeTabs.tabBlock); this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.X)); } //RENDER / JSON / SPECIAL BLOCK PROPERITES public static final PropertyEnum AXIS = PropertyEnum.create("axis", EnumFacing.Axis.class, new EnumFacing.Axis[] {EnumFacing.Axis.X, EnumFacing.Axis.Z}); public int fieldDinocraft = 0; @Override public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) { float f; float f1; int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); if(!world.getBlockState(new BlockPos(x - 1, y, z)).equals(this) && !world.getBlockState(new BlockPos(x + 1, y, z)).equals(this)) { f = 0.125F; f1 = 0.5F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); } else { f = 0.5F; f1 = 0.125F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); } EnumFacing.Axis axis = (EnumFacing.Axis)world.getBlockState(pos).getValue(AXIS); float f3 = 0.125F; float f4 = 0.125F; if (axis == EnumFacing.Axis.X) { f3 = 0.5F; } if (axis == EnumFacing.Axis.Z) { f4 = 0.5F; } this.setBlockBounds(0.5F - f3, 0.0F, 0.5F - f4, 0.5F + f3, 1.0F, 0.5F + f4); } public static int getMetaForAxis(EnumFacing.Axis axis) { return axis == EnumFacing.Axis.X ? 1 : (axis == EnumFacing.Axis.Z ? 2 : 0); } public boolean func_176548_d(World worldIn, BlockPos p_176548_2_) { BlockPortail.Size size = new BlockPortail.Size(worldIn, p_176548_2_, EnumFacing.Axis.X); if (size.func_150860_b() && size.field_150864_e == 0) { size.func_150859_c(); return true; } else { BlockPortail.Size size1 = new BlockPortail.Size(worldIn, p_176548_2_, EnumFacing.Axis.Z); if (size1.func_150860_b() && size1.field_150864_e == 0) { size1.func_150859_c(); return true; } else { return false; } } } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) { EnumFacing.Axis axis = null; IBlockState iblockstate = worldIn.getBlockState(pos); if (worldIn.getBlockState(pos).getBlock() == this) { axis = (EnumFacing.Axis)iblockstate.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 = worldIn.getBlockState(pos.west()).getBlock() == this && worldIn.getBlockState(pos.west(2)).getBlock() != this; boolean flag1 = worldIn.getBlockState(pos.east()).getBlock() == this && worldIn.getBlockState(pos.east(2)).getBlock() != this; boolean flag2 = worldIn.getBlockState(pos.north()).getBlock() == this && worldIn.getBlockState(pos.north(2)).getBlock() != this; boolean flag3 = worldIn.getBlockState(pos.south()).getBlock() == this && worldIn.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)); } public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(AXIS, (meta & 3) == 2 ? EnumFacing.Axis.Z : EnumFacing.Axis.X); } public int getMetaFromState(IBlockState state) { return getMetaForAxis((EnumFacing.Axis)state.getValue(AXIS)); } protected BlockState createBlockState() { return new BlockState(this, new IProperty[] {AXIS}); } //BLOCK NOT VERY SPECIAL PROPERTIES @Override public void setBlockBoundsForItemRender() { float f1 = 0.125F; this.setBlockBounds(0, 0.0F, 0.5F - f1, 1F, 1.0F, 0.5F + f1); } @Override public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { return null; } @Override public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); int y2 = y; while(world.getBlockState(new BlockPos(x, y2, z)).equals(this)) { y2–; } if(!world.getBlockState(new BlockPos(x, y2, z)).equals(BlockRegister.BlockAmbre)) { world.setBlockToAir(new BlockPos(x, y, z)); } int y3 = y2 + 1; boolean portalIsGood = false; if(world.getBlockState(new BlockPos(x, y3, z + 1)).equals(this)) { portalIsGood = (world.getBlockState(new BlockPos(x, y2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2, z + 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 1, z + 2)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 2, z + 2)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 3, z + 2)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 1, z - 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 2, z - 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 3, z - 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 4, z - 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 4, z)).equals(BlockRegister.BlockAmbre)); } else if(world.getBlockState(new BlockPos(x, y3, z - 1)).equals(this)) { portalIsGood = (world.getBlockState(new BlockPos(x, y2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2, z - 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 1, z - 2)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 2, z - 2)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 3, z - 2)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 1, z + 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 2, z + 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 3, z + 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 4, z + 1)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 4, z)).equals(BlockRegister.BlockAmbre)); } else if(world.getBlockState(new BlockPos(x + 1, y3, z)).equals(this)) { portalIsGood = (world.getBlockState(new BlockPos(x, y2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 1, y2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 2, y2 + 1, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 2, y2 + 2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 2, y2 + 3, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x - 1, y2 + 1, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x - 1, y2 + 2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x - 1, y2 + 3, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 1, y2 + 4, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 4, z)).equals(BlockRegister.BlockAmbre)); } else if(world.getBlockState(new BlockPos(x - 1, y3, z)).equals(this)) { portalIsGood = (world.getBlockState(new BlockPos(x, y2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x - 1, y2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x - 2, y2 + 1, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x - 2, y2 + 2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x - 2, y2 + 3, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 1, y2 + 1, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 1, y2 + 2, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 1, y2 + 3, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x + 1, y2 + 4, z)).equals(BlockRegister.BlockAmbre) && world.getBlockState(new BlockPos(x, y2 + 4, z)).equals(BlockRegister.BlockAmbre)); } } @SideOnly(Side.CLIENT) public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.TRANSLUCENT; } @Override public boolean isOpaqueCube() { return false; } @Override public boolean isFullCube() { return false; } @Override public int quantityDropped(Random random) { return 0; } /** Fonction use to enter to your own dimension **/ @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity) { if((entity.ridingEntity == null) && (entity.riddenByEntity == null)) { if(entity.dimension != DimensionRegister.DimAncient) { if(entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP)entity; if(player.timeUntilPortal > 0) { player.timeUntilPortal = 10; } else { player.timeUntilPortal = 10; player.mcServer.getConfigurationManager().transferPlayerToDimension(player, DimensionRegister.DimAncient, new AncientTeleporter(player.mcServer.worldServerForDimension(DimensionRegister.DimAncient))); } } } else { if(entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP)entity; if(player.timeUntilPortal > 0) { player.timeUntilPortal = 10; } else { player.timeUntilPortal = 10; player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 0, new AncientTeleporter(player.mcServer.worldServerForDimension(0))); } } } } } @SideOnly(Side.CLIENT) @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos) { return null; } @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); super.breakBlock(world, pos, state); if(world.getBlockState(new BlockPos(x, y + 1, z)).equals(this)) { world.setBlockToAir(new BlockPos(x, y + 1, z)); } if(world.getBlockState(new BlockPos(x, y - 1, z)).equals(this)) { world.setBlockToAir(new BlockPos(x, y - 1, z)); } if(world.getBlockState(new BlockPos(x + 1, y, z)).equals(this)) { world.setBlockToAir(new BlockPos(x + 1, y, z)); } if(world.getBlockState(new BlockPos(x - 1, y, z)).equals(this)) { world.setBlockToAir(new BlockPos(x - 1, y, z)); } if(world.getBlockState(new BlockPos(x, y, z + 1)).equals(this)) { world.setBlockToAir(new BlockPos(x, y, z + 1)); } if(world.getBlockState(new BlockPos(x, y, z - 1)).equals(this)) { world.setBlockToAir(new BlockPos(x, y, z - 1)); } } // NEW CLASS INSIDE public static class Size { private final World world; private final EnumFacing.Axis axis; private final EnumFacing field_150866_c; private final EnumFacing field_150863_d; private int field_150864_e = 0; private BlockPos field_150861_f; private int field_150862_g; private int field_150868_h; 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.field_150863_d = EnumFacing.EAST; this.field_150866_c = EnumFacing.WEST; } else { this.field_150863_d = EnumFacing.NORTH; this.field_150866_c = EnumFacing.SOUTH; } for (BlockPos blockpos1 = p_i45694_2_; p_i45694_2_.getY() > blockpos1.getY() - 21 && p_i45694_2_.getY() > 0 && this.func_150857_a(worldIn.getBlockState(p_i45694_2_.down()).getBlock()); p_i45694_2_ = p_i45694_2_.down()) { ; } int i = this.func_180120_a(p_i45694_2_, this.field_150863_d) - 1; if (i >= 0) { this.field_150861_f = p_i45694_2_.offset(this.field_150863_d, i); this.field_150868_h = this.func_180120_a(this.field_150861_f, this.field_150866_c); if (this.field_150868_h < 2 || this.field_150868_h > 21) { this.field_150861_f = null; this.field_150868_h = 0; } } if (this.field_150861_f != null) { this.field_150862_g = this.func_150858_a(); } } protected int func_180120_a(BlockPos pos, EnumFacing enumfacing) { int i; for (i = 0; i < 22; ++i) { BlockPos blockpos1 = pos.offset(enumfacing, i); if (!this.func_150857_a(this.world.getBlockState(blockpos1).getBlock()) || this.world.getBlockState(blockpos1.down()).getBlock() != BlockRegister.BlockAmbre) { break; } } Block block = this.world.getBlockState(pos.offset(enumfacing, i)).getBlock(); return block == BlockRegister.BlockAmbre ? i : 0; } protected int func_150858_a() { int i; label56: for (this.field_150862_g = 0; this.field_150862_g < 21; ++this.field_150862_g) { for (i = 0; i < this.field_150868_h; ++i) { BlockPos blockpos = this.field_150861_f.offset(this.field_150866_c, i).up(this.field_150862_g); Block block = this.world.getBlockState(blockpos).getBlock(); if (!this.func_150857_a(block)) { break label56; } if (block == BlockRegister.BlockPortail) { ++this.field_150864_e; } if (i == 0) { block = this.world.getBlockState(blockpos.offset(this.field_150863_d)).getBlock(); if (block != BlockRegister.BlockAmbre) { break label56; } } else if (i == this.field_150868_h - 1) { block = this.world.getBlockState(blockpos.offset(this.field_150866_c)).getBlock(); if (block != BlockRegister.BlockAmbre) { break label56; } } } } for (i = 0; i < this.field_150868_h; ++i) { if (this.world.getBlockState(this.field_150861_f.offset(this.field_150866_c, i).up(this.field_150862_g)).getBlock() != BlockRegister.BlockAmbre) { this.field_150862_g = 0; break; } } if (this.field_150862_g <= 21 && this.field_150862_g >= 3) { return this.field_150862_g; } else { this.field_150861_f = null; this.field_150868_h = 0; this.field_150862_g = 0; return 0; } } protected boolean func_150857_a(Block block) { return block.getMaterial() == Material.air || block == Blocks.fire || block == BlockRegister.BlockPortail; } public boolean func_150860_b() { return this.field_150861_f != null && this.field_150868_h >= 2 && this.field_150868_h <= 21 && this.field_150862_g >= 3 && this.field_150862_g <= 21; } public void func_150859_c() { for (int i = 0; i < this.field_150868_h; ++i) { BlockPos blockpos = this.field_150861_f.offset(this.field_150866_c, i); for (int j = 0; j < this.field_150862_g; ++j) { this.world.setBlockState(blockpos.up(j), BlockRegister.BlockPortail.getDefaultState().withProperty(BlockPortail.AXIS, this.axis), 2); } } } } }
:::
Ancient Biome
package mod.common.world.biome; import java.util.List; import java.util.Random; import mod.common.world.structure.WorldGenAncientAcacia; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; import net.minecraft.world.biome.BiomeGenPlains; import net.minecraft.world.gen.NoiseGeneratorPerlin; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraft.world.gen.feature.WorldGenDoublePlant; import net.minecraft.world.gen.feature.WorldGenSavannaTree; import net.minecraft.world.gen.feature.WorldGenTrees; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.BiomeEvent; public class AncientBiome extends BiomeGenBase { private static final WorldGenAncientAcacia treeGenerator = new WorldGenAncientAcacia(); public AncientBiome(int par1) { super(par1); setTemperatureRainfall(0.0F, 0.0F); setHeight(height_LowPlains); this.theBiomeDecorator.treesPerChunk = -999; this.theBiomeDecorator.flowersPerChunk = 4; this.theBiomeDecorator.grassPerChunk = 10; this.flowers.clear(); } /* public String decorate(Random random, BlockPos pos) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); double d0 = plantNoise.func_151601_a(x / 200.0D, z / 200.0D); if (d0 < -0.8D) { int l = random.nextInt(4); return net.minecraft.block.BlockFlower.field_149859_a[(4 + l)]; } if (random.nextInt(3) > 0) { int l = random.nextInt(3); return l == 1 ? net.minecraft.block.BlockFlower.random[3] : l == 0 ? net.minecraft.block.BlockFlower.field_149859_a[0] : net.minecraft.block.BlockFlower.field_149859_a[8]; } return net.minecraft.block.BlockFlower.random[0]; }*/ /* public void decorate(World world, Random random, BlockPos pos) { int x = pos.getX(); int z = pos.getZ(); double d0 = plantNoise.func_151601_a((x + 8) / 200.0D, (z + 8) / 200.0D); if (d0 < -0.8D) { this.theBiomeDecorator.flowersPerChunk = 15; this.theBiomeDecorator.grassPerChunk = 5; } else { this.theBiomeDecorator.flowersPerChunk = 4; this.theBiomeDecorator.grassPerChunk = 10; flowers.get(2); for (int k = 0; k < 7; k++) { int l = x + random.nextInt(16) + 8; int i1 = z + random.nextInt(16) + 8; int j1 = random.nextInt(world.getHeight(l, i1 + 32)); flowers.generate(world, random, l, j1, i1); } } super.decorate(world, random, pos); } */ public WorldGenAbstractTree genBigTreeChance(Random p_150567_1_) { return (WorldGenAbstractTree)(p_150567_1_.nextInt(5) > 0 ? treeGenerator : this.worldGeneratorTrees); } public BiomeGenBase createMutation() { BiomeGenPlains biomegenplains = new BiomeGenPlains(this.biomeID + 128); biomegenplains.setBiomeName("Sunflower Plains"); biomegenplains.setColor(9286496); biomegenplains.field_150609_ah = 14273354; return biomegenplains; } @Override public int getModdedBiomeGrassColor(int original) { BiomeEvent.GetGrassColor event = new BiomeEvent.GetGrassColor(this, 0xCC9900); MinecraftForge.EVENT_BUS.post(event); return event.newColor; } @Override public int getModdedBiomeFoliageColor(int original) { BiomeEvent.GetFoliageColor event = new BiomeEvent.GetFoliageColor(this, 0xCC9900); MinecraftForge.EVENT_BUS.post(event); return event.newColor; } }
BiomeRegister
package mod.common.world.biome; import net.minecraft.world.biome.BiomeGenBase; public class BiomeRegister { public static BiomeGenBase AncientBiome; public static void register() { AncientBiome = new AncientBiome(40).setBiomeName("AncientBiome").setDisableRain().setTemperatureRainfall(1.2F, 0.9F); } }
AncientGenLayerBiome
package mod.common.world.generator; import mod.DinoCraft; import mod.common.world.biome.BiomeRegister; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.IntCache; public class AncientGenLayerBiome extends GenLayer { protected BiomeGenBase[] baseBiome = {BiomeRegister.AncientBiome}; public AncientGenLayerBiome(long seed) { super(seed); } @Override public int[] getInts(int coordX, int coordZ, int width, int depth) { int[] dest = IntCache.getIntCache(width * depth); for(int dz = 0; dz < depth; dz++) { for(int dx = 0; dx < width; dx++) { this.initChunkSeed(dx + coordX, dz + coordZ); dest[(dx + dz * width)] = this.baseBiome[nextInt(this.baseBiome.length)].biomeID; } } return dest; } }
ChunkProviderAncient
package mod.common.world.generator; import java.util.Iterator; import java.util.List; import java.util.Random; import com.google.common.collect.Lists; import mod.common.world.biome.AncientBiome; import mod.common.world.structure.Ruins; import mod.common.world.structure.WorldGenAncientAcacia; 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.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.IProgressUpdate; import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkCoordIntPair; 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.ChunkPrimer; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderSettings; import net.minecraft.world.gen.MapGenBase; import net.minecraft.world.gen.MapGenCaves; import net.minecraft.world.gen.MapGenRavine; 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.MapGenMineshaft; import net.minecraft.world.gen.structure.MapGenScatteredFeature; import net.minecraft.world.gen.structure.MapGenStructure; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.ChunkProviderEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; import net.minecraftforge.fml.common.eventhandler.Event.Result; import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.*; import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.*; public class ChunkProviderAncient implements IChunkProvider { private Random rand; private NoiseGeneratorOctaves noiseGen1; private NoiseGeneratorOctaves noiseGen2; private NoiseGeneratorOctaves noiseGen3; private NoiseGeneratorPerlin noiseGen4; public NoiseGeneratorOctaves noiseGen5; public NoiseGeneratorOctaves noiseGen6; public NoiseGeneratorOctaves mobSpawnerNoise; private Block block; private World worldObj; private ChunkProviderSettings settings; private WorldType worldType; private final double[] noiseArray; private final float[] parabolicField; private MapGenBase caveGenerator; private MapGenMineshaft mineshaftGenerator; private MapGenBase ravineGenerator; private boolean mapFeaturesEnabled; private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); private final List structureGenerators = Lists.newArrayList(); private double[] stoneNoise = new double[256]; private BiomeGenBase[] biomesForGeneration; double[] noiseData1; double[] noiseData2; double[] noiseData3; double[] noiseData4; private final IBlockState[] cachedBlockIDs = new IBlockState[256]; { caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT); scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE); ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE); } public ChunkProviderAncient(World world, long seed, boolean features, String p_i45636_5_) { this.block = Blocks.water; this.worldObj = world; this.mapFeaturesEnabled = features; this.worldType = world.getWorldInfo().getTerrainType(); this.rand = new Random(seed); this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16); this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16); this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8); this.noiseGen4 = new NoiseGeneratorPerlin(this.rand, 4); this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10); this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16); this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8); this.noiseArray = new double[825]; this.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); this.parabolicField[j + 2 + (k + 2) * 5] = f; } } NoiseGenerator[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6, mobSpawnerNoise}; noiseGens = TerrainGen.getModdedNoiseGenerators(world, this.rand, noiseGens); this.noiseGen1 = (NoiseGeneratorOctaves)noiseGens[0]; this.noiseGen2 = (NoiseGeneratorOctaves)noiseGens[1]; this.noiseGen3 = (NoiseGeneratorOctaves)noiseGens[2]; this.noiseGen4 = (NoiseGeneratorPerlin)noiseGens[3]; this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4]; this.noiseGen6 = (NoiseGeneratorOctaves)noiseGens[5]; this.mobSpawnerNoise = (NoiseGeneratorOctaves)noiseGens[6]; } 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.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16); this.replaceBlockForBiome(x, z, chunkprimer, this.biomesForGeneration); this.caveGenerator.func_175792_a(this, this.worldObj, x, z, chunkprimer); this.ravineGenerator.func_175792_a(this, this.worldObj, x, z, chunkprimer); if(this.mapFeaturesEnabled) { this.scatteredFeatureGenerator.func_175792_a(this, this.worldObj, x, z, chunkprimer); } 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].biomeID; } chunk.generateSkylightMap(); return chunk; } public void setBlocksInChunk(int p_180518_1_, int p_180518_2_, ChunkPrimer p_180518_3_) { this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, p_180518_1_ * 4 - 2, p_180518_2_ * 4 - 2, 10, 10); this.func_147423_a(p_180518_1_ * 4, 0, p_180518_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 = this.noiseArray[k1 + k2];//TODO double d2 = this.noiseArray[l1 + k2]; double d3 = this.noiseArray[i2 + k2]; double d4 = this.noiseArray[j2 + k2]; double d5 = (this.noiseArray[k1 + k2 + 1] - d1) * d0; double d6 = (this.noiseArray[l1 + k2 + 1] - d2) * d0; double d7 = (this.noiseArray[i2 + k2 + 1] - d3) * d0; double d8 = (this.noiseArray[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) { p_180518_3_.setBlockState(k * 4 + i3, k2 * 8 + l2, j1 * 4 + j3, Blocks.stone.getDefaultState()); } else if(k2 * 8 + l2 < 64)//TODO { p_180518_3_.setBlockState(k * 4 + i3, k2 * 8 + l2, j1 * 4 + j3, this.block.getDefaultState()); } } d10 += d12; d11 += d13; } d1 += d5; d2 += d6; d3 += d7; d4 += d8; } } } } } public void replaceBlockForBiome(int coordX, int coordZ, ChunkPrimer p_180517_3_, BiomeGenBase[] p_180517_4_) { ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, coordX, coordZ, p_180517_3_, this.worldObj); MinecraftForge.EVENT_BUS.post(event); if (event.getResult() == Result.DENY) return; double d0 = 0.03125D; this.stoneNoise = this.noiseGen4.func_151599_a(this.stoneNoise, (double)(coordX * 16), (double)(coordZ * 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) { AncientBiome biomegenbase = (AncientBiome)p_180517_4_[l + k * 16]; biomegenbase.genTerrainBlocks(this.worldObj, this.rand, p_180517_3_, coordX * 16 + k, coordZ * 16 + l, this.stoneNoise[l + k * 16]); } } } public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_) { return false; } private void func_147423_a(int x, int y, int z) { double d0 = 684.412D; double d1 = 684.412D; double d2 = 512.0D; double d3 = 512.0D; this.noiseData4 = this.noiseGen6.generateNoiseOctaves(this.noiseData4, x, z, 5, 5, 200.0D, 200.0D, 0.5D); this.noiseData1 = this.noiseGen3.generateNoiseOctaves(this.noiseData1, x, y, z, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); this.noiseData2 = this.noiseGen1.generateNoiseOctaves(this.noiseData2, x, y, z, 5, 33, 5, 684.412D, 684.412D, 684.412D); this.noiseData3 = this.noiseGen2.generateNoiseOctaves(this.noiseData3, x, y, z, 5, 33, 5, 684.412D, 684.412D, 684.412D); 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 = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; for(int l1 = -b0; l1 <= b0; ++l1) { for(int i2 = -b0; i2 <= b0; ++i2) { BiomeGenBase biomegenbase1 = this.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; float f3 = biomegenbase1.minHeight; float f4 = biomegenbase1.maxHeight; float f5 = this.parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F); if(biomegenbase1.minHeight > biomegenbase.minHeight) { 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 d13 = this.noiseData4[i1] / 8000.0D; if(d13 < 0.0D) { d13 = -d13 * 0.3D; } d13 = d13 * 3.0D - 2.0D; if(d13 < 0.0D) { d13 /= 2.0D; if(d13 < -1.0D) { d13 = -1.0D; } d13 /= 1.4D; d13 /= 2.0D; } else { if(d13 > 1.0D) { d13 = 1.0D; } d13 /= 8.0D; } ++i1; double d12 = (double)f1; double d14 = (double)f; d12 += d13 * 0.2D; d12 = d12 * 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 = this.noiseData2[l] / 512.0D; double d8 = this.noiseData3[l] / 512.0D; double d9 = (this.noiseData1[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; } this.noiseArray[l] = d10; ++l; } } } } public boolean chunkExists(int par1, int par2) { return true; } public void populate(IChunkProvider chunkProvider, int x, int z) { BlockFalling.fallInstantly = true; int x1 = x * 16; int z1 = z * 16; BlockPos blockpos = new BlockPos(x1, 0, z1); BiomeGenBase 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)x * i1 + (long)z * j1 ^ this.worldObj.getSeed()); boolean flag = false; ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z); MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(chunkProvider, worldObj, rand, x, z, flag)); if (this.mapFeaturesEnabled) { this.scatteredFeatureGenerator.func_175794_a(this.worldObj, this.rand, chunkcoordintpair); } int k1; int l1; int i2; if(this.settings.useDungeons) { boolean doGen = TerrainGen.populate(chunkProvider, worldObj, rand, x, z, flag, DUNGEON); for(k1 = 0; doGen && k1 < this.settings.dungeonChance; ++k1) { l1 = this.rand.nextInt(16) + 8; i2 = this.rand.nextInt(256); int j2 = this.rand.nextInt(16) + 8; (new WorldGenDungeons()).generate(this.worldObj, this.rand, blockpos.add(l1, i2, j2)); } } biomegenbase.decorate(this.worldObj, this.rand, new BlockPos(x1, 0, z1)); if(TerrainGen.populate(chunkProvider, worldObj, rand, x, z, flag, ANIMALS)) { SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, x1 + 8, z1 + 8, 16, 16, this.rand); } blockpos = blockpos.add(8, 0, 8); boolean doGen1 = TerrainGen.populate(chunkProvider, worldObj, rand, x, z, flag, ICE); for(k1 = 0; doGen1 && 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.func_175675_v(blockpos2)) { this.worldObj.setBlockState(blockpos2, Blocks.ice.getDefaultState(), 2); } if(this.worldObj.canSnowAt(blockpos1, true)) { this.worldObj.setBlockState(blockpos1, Blocks.snow_layer.getDefaultState(), 2); } } } MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(chunkProvider, worldObj, rand, x, z, flag)); BlockFalling.fallInstantly = false; } public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) { return true; } public void saveExtraData() {} public boolean unloadQueuedChunks() { return false; } public boolean canSave() { return true; } public String makeString() { return "RandomLevelSource"; } public List func_177458_a(EnumCreatureType par1EnumCreatureType, BlockPos pos) { AncientBiome biomegenbase = (AncientBiome)this.worldObj.getBiomeGenForCoords(pos); return biomegenbase.getSpawnableList(par1EnumCreatureType); } public int getLoadedChunkCount() { return 0; } @Override public Chunk provideChunk(BlockPos blockPosIn) { return this.provideChunk(blockPosIn.getX() >> 4, blockPosIn.getZ() >> 4); } @Override public BlockPos getStrongholdGen(World worldIn, String p_180513_2_, BlockPos p_180513_3_) { return null; } @Override public void recreateStructures(Chunk p_180514_1_, int p_180514_2_, int p_180514_3_) { Iterator iterator = this.structureGenerators.iterator(); while(iterator.hasNext()) { MapGenStructure mapgenstructure = (MapGenStructure)iterator.next(); mapgenstructure.func_175792_a(this, this.worldObj, p_180514_2_, p_180514_3_, (ChunkPrimer)null); } } }
:::
-
SUITE CLASSE
:::GenLayer Ancient
package mod.common.world.generator; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.GenLayerVoronoiZoom; import net.minecraft.world.gen.layer.GenLayerZoom; public abstract class GenLayerAncient extends GenLayer { public GenLayerAncient(long par1) { super(par1); } public static GenLayer[] makeTheWorld(long l) { GenLayer biomes = new AncientGenLayerBiome(1L); biomes = new GenLayerZoom(1000L, biomes); biomes = new GenLayerZoom(1001L, biomes); biomes = new GenLayerZoom(1002L, biomes); biomes = new GenLayerZoom(1003L, biomes); biomes = new GenLayerZoom(1004L, biomes); biomes = new GenLayerZoom(1005L, biomes); GenLayer genlayervoronoizoom = new GenLayerVoronoiZoom(10L, biomes); biomes.initWorldGenSeed(l); genlayervoronoizoom.initWorldGenSeed(l); return new GenLayer[] {biomes, genlayervoronoizoom}; } } { this.makePortal(entity); this.placeInExistingPortal(entity, rotationYaw); } } else { int i = MathHelper.floor_double(entity.posX); int j = MathHelper.floor_double(entity.posY) - 1; int k = MathHelper.floor_double(entity.posZ); byte b0 = 1; byte b1 = 0; for(int l = -2; l <= 2; ++l) { for(int i1 = -2; i1 <= 2; ++i1) { for(int j1 = -1; j1 < 3; ++j1) { int k1 = i + i1 * b0 + l * b1; int l1 = j + j1; int i2 = k + i1 * b1 - l * b0; boolean flag = j1 < 0; this.worldServerInstance.setBlockState(new BlockPos(k1, l1, i2), (flag ? BlockRegister.BlockAmbre.getDefaultState() : Blocks.air.getDefaultState())); } } } entity.setLocationAndAngles((double)i, (double)j, (double)k, entity.rotationYaw, 0.0F); entity.motionX = entity.motionY = entity.motionZ = 0.0D; } } public boolean placeInExistingPortal(Entity entity, float rotationYaw) { boolean flag = true; double d0 = -1.0D; int i = MathHelper.floor_double(entity.posX); int j = MathHelper.floor_double(entity.posZ); boolean flag1 = true; Object object = BlockPos.ORIGIN; long k = ChunkCoordIntPair.chunkXZ2Int(i, j); if (this.destinationCoordinateCache.containsItem(k)) { Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.getValueByKey(k); d0 = 0.0D; object = portalposition; portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); flag1 = false; } else { BlockPos blockpos4 = new BlockPos(entity); for (int l = -128; l <= 128; ++l) { BlockPos blockpos1; for (int i1 = -128; i1 <= 128; ++i1) { for (BlockPos blockpos = blockpos4.add(l, this.worldServerInstance.getActualHeight() - 1 - blockpos4.getY(), i1); blockpos.getY() >= 0; blockpos = blockpos1) { blockpos1 = blockpos.down(); if (this.worldServerInstance.getBlockState(blockpos).getBlock() == Blocks.portal) { while (this.worldServerInstance.getBlockState(blockpos1 = blockpos.down()).getBlock() == Blocks.portal) { blockpos = blockpos1; } double d1 = blockpos.distanceSq(blockpos4); if (d0 < 0.0D || d1 < d0) { d0 = d1; object = blockpos; } } } } } } if (d0 >= 0.0D) { if (flag1) { this.destinationCoordinateCache.add(k, new Teleporter.PortalPosition((BlockPos)object, this.worldServerInstance.getTotalWorldTime())); this.destinationCoordinateKeys.add(Long.valueOf(k)); } double d4 = (double)((BlockPos)object).getX() + 0.5D; double d5 = (double)((BlockPos)object).getY() + 0.5D; double d6 = (double)((BlockPos)object).getZ() + 0.5D; EnumFacing enumfacing = null; if (this.worldServerInstance.getBlockState(((BlockPos)object).west()).getBlock() == BlockRegister.BlockPortail) { enumfacing = EnumFacing.NORTH; } if (this.worldServerInstance.getBlockState(((BlockPos)object).east()).getBlock() == Blocks.portal) { enumfacing = EnumFacing.SOUTH; } if (this.worldServerInstance.getBlockState(((BlockPos)object).north()).getBlock() == Blocks.portal) { enumfacing = EnumFacing.EAST; } if (this.worldServerInstance.getBlockState(((BlockPos)object).south()).getBlock() == Blocks.portal) { enumfacing = EnumFacing.WEST; } EnumFacing enumfacing1 = EnumFacing.getHorizontal(entity.getTeleportDirection()); if (enumfacing != null) { EnumFacing enumfacing2 = enumfacing.rotateYCCW(); BlockPos blockpos2 = ((BlockPos)object).offset(enumfacing); boolean flag2 = this.func_180265_a(blockpos2); boolean flag3 = this.func_180265_a(blockpos2.offset(enumfacing2)); if (flag3 && flag2) { object = ((BlockPos)object).offset(enumfacing2); enumfacing = enumfacing.getOpposite(); enumfacing2 = enumfacing2.getOpposite(); BlockPos blockpos3 = ((BlockPos)object).offset(enumfacing); flag2 = this.func_180265_a(blockpos3); flag3 = this.func_180265_a(blockpos3.offset(enumfacing2)); } float f6 = 0.5F; float f1 = 0.5F; if (!flag3 && flag2) { f6 = 1.0F; } else if (flag3 && !flag2) { f6 = 0.0F; } else if (flag3) { f1 = 0.0F; } d4 = (double)((BlockPos)object).getX() + 0.5D; d5 = (double)((BlockPos)object).getY() + 0.5D; d6 = (double)((BlockPos)object).getZ() + 0.5D; d4 += (double)((float)enumfacing2.getFrontOffsetX() * f6 + (float)enumfacing.getFrontOffsetX() * f1); d6 += (double)((float)enumfacing2.getFrontOffsetZ() * f6 + (float)enumfacing.getFrontOffsetZ() * f1); float f2 = 0.0F; float f3 = 0.0F; float f4 = 0.0F; float f5 = 0.0F; if (enumfacing == enumfacing1) { f2 = 1.0F; f3 = 1.0F; } else if (enumfacing == enumfacing1.getOpposite()) { f2 = -1.0F; f3 = -1.0F; } else if (enumfacing == enumfacing1.rotateY()) { f4 = 1.0F; f5 = -1.0F; } else { f4 = -1.0F; f5 = 1.0F; } double d2 = entity.motionX; double d3 = entity.motionZ; entity.motionX = d2 * (double)f2 + d3 * (double)f5; entity.motionZ = d2 * (double)f4 + d3 * (double)f3; entity.rotationYaw = rotationYaw - (float)(enumfacing1.getHorizontalIndex() * 90) + (float)(enumfacing.getHorizontalIndex() * 90); } else { entity.motionX = entity.motionY = entity.motionZ = 0.0D; } entity.setLocationAndAngles(d4, d5, d6, entity.rotationYaw, entity.rotationPitch); return true; } else { return false; } } private boolean func_180265_a(BlockPos pos) { return !this.worldServerInstance.isAirBlock(pos) || !this.worldServerInstance.isAirBlock(pos.up()); } public boolean makePortal(Entity entity) { byte b0 = 16; double d0 = -1.0D; int i = MathHelper.floor_double(entity.posX); int j = MathHelper.floor_double(entity.posY); int k = MathHelper.floor_double(entity.posZ); int l = i; int i1 = j; int j1 = k; int k1 = 0; int l1 = this.random.nextInt(4); int i2; double d1; int k2; double d2; int i3; int j3; int k3; int l3; int i4; int j4; int k4; int l4; int i5; double d3; double d4; for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double)i2 + 0.5D - entity.posX; for (k2 = k - b0; k2 <= k + b0; ++k2) { d2 = (double)k2 + 0.5D - entity.posZ; label271: for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; –i3) { if (this.worldServerInstance.isAirBlock(new BlockPos(i2, i3, k2))) { while (i3 > 0 && this.worldServerInstance.isAirBlock(new BlockPos(i2, i3 - 1, k2))) { --i3; } for (j3 = l1; j3 < l1 + 4; ++j3) { k3 = j3 % 2; l3 = 1 - k3; if (j3 % 4 >= 2) { k3 = -k3; l3 = -l3; } for (i4 = 0; i4 < 3; ++i4) { for (j4 = 0; j4 < 4; ++j4) { for (k4 = -1; k4 < 4; ++k4) { l4 = i2 + (j4 - 1) * k3 + i4 * l3; i5 = i3 + k4; int j5 = k2 + (j4 - 1) * l3 - i4 * k3; if (k4 < 0 && !this.worldServerInstance.getBlockState(new BlockPos(l4, i5, j5)).getBlock().getMaterial().isSolid() || k4 >= 0 && !this.worldServerInstance.isAirBlock(new BlockPos(l4, i5, j5))) { continue label271; } } } } d3 = (double)i3 + 0.5D - entity.posY; d4 = d1 * d1 + d3 * d3 + d2 * d2; if (d0 < 0.0D || d4 < d0) { d0 = d4; l = i2; i1 = i3; j1 = k2; k1 = j3 % 4; } } } } } } if (d0 < 0.0D) { for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double)i2 + 0.5D - entity.posX; for (k2 = k - b0; k2 <= k + b0; ++k2) { d2 = (double)k2 + 0.5D - entity.posZ; label219: for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) { if (this.worldServerInstance.isAirBlock(new BlockPos(i2, i3, k2))) { while (i3 > 0 && this.worldServerInstance.isAirBlock(new BlockPos(i2, i3 - 1, k2))) { --i3; } for (j3 = l1; j3 < l1 + 2; ++j3) { k3 = j3 % 2; l3 = 1 - k3; for (i4 = 0; i4 < 4; ++i4) { for (j4 = -1; j4 < 4; ++j4) { k4 = i2 + (i4 - 1) * k3; l4 = i3 + j4; i5 = k2 + (i4 - 1) * l3; if (j4 < 0 && !this.worldServerInstance.getBlockState(new BlockPos(k4, l4, i5)).getBlock().getMaterial().isSolid() || j4 >= 0 && !this.worldServerInstance.isAirBlock(new BlockPos(k4, l4, i5))) { continue label219; } } } d3 = (double)i3 + 0.5D - entity.posY; d4 = d1 * d1 + d3 * d3 + d2 * d2; if (d0 < 0.0D || d4 < d0) { d0 = d4; l = i2; i1 = i3; j1 = k2; k1 = j3 % 2; } } } } } } } int k5 = l; int j2 = i1; k2 = j1; int l5 = k1 % 2; int l2 = 1 - l5; if (k1 % 4 >= 2) { l5 = -l5; l2 = -l2; } if (d0 < 0.0D) { i1 = MathHelper.clamp_int(i1, 70, this.worldServerInstance.getActualHeight() - 10); j2 = i1; for (i3 = -1; i3 <= 1; ++i3) { for (j3 = 1; j3 < 3; ++j3) { for (k3 = -1; k3 < 3; ++k3) { l3 = k5 + (j3 - 1) * l5 + i3 * l2; i4 = j2 + k3; j4 = k2 + (j3 - 1) * l2 - i3 * l5; boolean flag = k3 < 0; this.worldServerInstance.setBlockState(new BlockPos(l3, i4, j4), flag ? BlockRegister.BlockAmbre.getDefaultState() : Blocks.air.getDefaultState()); } } } } IBlockState iblockstate = BlockRegister.BlockPortail.getDefaultState().withProperty(BlockPortail.AXIS, l5 != 0 ? EnumFacing.Axis.X : EnumFacing.Axis.Z); for (j3 = 0; j3 < 4; ++j3) { for (k3 = 0; k3 < 4; ++k3) { for (l3 = -1; l3 < 4; ++l3) { i4 = k5 + (k3 - 1) * l5; j4 = j2 + l3; k4 = k2 + (k3 - 1) * l2; boolean flag1 = k3 == 0 || k3 == 3 || l3 == -1 || l3 == 3; this.worldServerInstance.setBlockState(new BlockPos(i4, j4, k4), flag1 ? BlockRegister.BlockAmbre.getDefaultState() : iblockstate, 2); } } for (k3 = 0; k3 < 4; ++k3) { for (l3 = -1; l3 < 4; ++l3) { i4 = k5 + (k3 - 1) * l5; j4 = j2 + l3; k4 = k2 + (k3 - 1) * l2; this.worldServerInstance.notifyNeighborsOfStateChange(new BlockPos(i4, j4, k4), this.worldServerInstance.getBlockState(new BlockPos(i4, j4, k4)).getBlock()); } } } return true; } class AncientPortalPosition extends ChunkCoordComparator { public long time; final AncientTeleporter teleporter; public AncientPortalPosition(AncientTeleporter teleporter, EntityPlayerMP player, long creationTime) { super(player); this.teleporter = teleporter; this.time = creationTime; } } }
Dimension Register
package mod.common.world.structure; import mod.common.world.biome.AncientBiome; import mod.common.world.biome.BiomeRegister; import mod.common.world.type.AncientWorldProvider; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.world.biome.BiomeCache; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.BiomeManager; import net.minecraftforge.common.DimensionManager; public class DimensionRegister { public static int DimAncient = 2; public static void register() { DimensionManager.registerProviderType(DimensionRegister.DimAncient, AncientWorldProvider.class, false); DimensionManager.registerDimension(DimensionRegister.DimAncient , DimensionRegister.DimAncient); } }
AncientWorldChunkManager
package mod.common.world.type; import static net.minecraft.world.biome.BiomeGenBase.forest; import static net.minecraft.world.biome.BiomeGenBase.forestHills; import static net.minecraft.world.biome.BiomeGenBase.jungle; import static net.minecraft.world.biome.BiomeGenBase.jungleHills; import static net.minecraft.world.biome.BiomeGenBase.plains; import static net.minecraft.world.biome.BiomeGenBase.taiga; import static net.minecraft.world.biome.BiomeGenBase.taigaHills; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; import com.google.common.collect.Lists; import mod.common.world.biome.BiomeRegister; import mod.common.world.generator.GenLayerAncient; import mod.common.world.structure.DimensionRegister; import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.util.BlockPos; import net.minecraft.util.ReportedException; import net.minecraft.world.World; 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 net.minecraft.world.gen.layer.IntCache; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.WorldTypeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class AncientWorldChunkManager extends WorldChunkManager { private GenLayer GenBiomes; private GenLayer BiomeIndexLayer; private BiomeCache BiomeCache; private List <biomegenbase>BiomesToSpawnIn; public AncientWorldChunkManager() { this.BiomeCache = new BiomeCache(this); this.BiomesToSpawnIn = new ArrayList<biomegenbase>(); this.BiomesToSpawnIn.add(BiomeGenBase.forest); } public AncientWorldChunkManager(long seed, WorldType worldtype, long height) { this(); GenLayer[] agenlayer = GenLayerAncient.makeTheWorld(seed); this.GenBiomes = agenlayer[0]; this.BiomeIndexLayer = agenlayer[1]; } public AncientWorldChunkManager(World world) { this(world.getSeed(), world.getWorldInfo().getTerrainType(), world.getActualHeight()); } public List <biomegenbase>getBiomesToSpawnIn() { return this.BiomesToSpawnIn; } public BiomeGenBase getBiomeGenAt(int x, int z, BiomeGenBase biome) { this.BiomeCache.func_180284_a(x, z, biome); if(biome == null) { return BiomeGenBase.forest; } return biome; } public float[] getRainfall(float[] listToReuse, int x, int z, int width, int length) { if(listToReuse == null || listToReuse.length < width * length) { listToReuse = new float[width * length]; } Arrays.fill(listToReuse, 0, width * length, 0.0F); return listToReuse; } @SideOnly(Side.CLIENT) public float getTemperatureAtHeight(float par1, int par2) { return par1; } public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) { IntCache.resetIntCache(); if(par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) { par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; } int[] aint = this.GenBiomes.getInts(par2, par3, par4, par5); for(int i = 0; i < par4 * par5; ++i) { if(aint* >= 0) { par1ArrayOfBiomeGenBase* = BiomeGenBase.getBiome(aint*); } else { par1ArrayOfBiomeGenBase* = BiomeRegister.AncientBiome; } } return par1ArrayOfBiomeGenBase; } public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] oldBiomeList, int x, int z, int width, int depth) { return this.getBiomeGenAt(oldBiomeList, x, z, width, depth, true); } public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] listToReuse, int x, int z, int width, int length, boolean cacheFlag) { IntCache.resetIntCache(); if (listToReuse == null || listToReuse.length < width * length) { listToReuse = new BiomeGenBase[width * length]; } if (cacheFlag && width == 16 && length == 16 && (x & 15) == 0 && (z & 15) == 0) { BiomeGenBase[] abiomegenbase1 = this.BiomeCache.getCachedBiomes(x, z); System.arraycopy(abiomegenbase1, 0, listToReuse, 0, width * length); return listToReuse; } else { int[] aint = this.BiomeIndexLayer.getInts(x, z, width, length); for(int i1 = 0; i1 < width * length; ++i1) { if(aint[i1] >= 0) { listToReuse[i1] = BiomeGenBase.getBiome(aint[i1]); } else { listToReuse[i1] = BiomeRegister.AncientBiome; } } return listToReuse; } } public boolean areBiomesViable(int par1, int par2, int par3, List par4List) { IntCache.resetIntCache(); int l = par1 - par3 >> 2; int i1 = par2 - par3 >> 2; int j1 = par1 + par3 >> 2; int k1 = par2 + par3 >> 2; int l1 = j1 - l + 1; int i2 = k1 - i1 + 1; int[] aint = this.GenBiomes.getInts(l, i1, l1, i2); for(int j2 = 0; j2 < l1 * i2; ++j2) { BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[j2]); if(!par4List.contains(biomegenbase)) { return false; } } return true; } public BlockPos findBiomePosition(int x, int z, int range, List list, Random random) { IntCache.resetIntCache(); int l = x - range >> 2; int i1 = z - range >> 2; int j1 = x + range >> 2; int k1 = z + range >> 2; int l1 = j1 - l + 1; int i2 = k1 - i1 + 1; int[] aint = this.GenBiomes.getInts(l, i1, l1, i2); BlockPos blockpos = null; int j2 = 0; for(int k2 = 0; k2 < l1 * i2; ++k2) { int l2 = l + k2 % l1 << 2; int i3 = i1 + k2 / l1 << 2; BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[k2]); if(((List<biomegenbase>)BiomeCache).contains(biomegenbase) && (blockpos == null || random.nextInt(j2 + 1) == 0)) { blockpos = new BlockPos(l2, 0, i3); ++j2; } } return blockpos; } public void cleanupCache() { this.BiomeCache.cleanupCache(); } }
AncientWorldProvider
package mod.common.world.type; import mod.common.world.generator.ChunkProviderAncient; import mod.common.world.structure.DimensionRegister; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.Vec3; import net.minecraft.util.Vec3i; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class AncientWorldProvider extends WorldProvider { private WorldType terrainType; private String generatorSettings; public void registerWorldChunkManager() { this.worldChunkMgr = new AncientWorldChunkManager(worldObj.getSeed(), terrainType, dimensionId); this.dimensionId = DimensionRegister.DimAncient; this.hasNoSky = false; this.isHellWorld = false; } public IChunkProvider createChunkGenerator() { return new ChunkProviderAncient(this.worldObj, this.worldObj.getSeed(), false, generatorSettings); } public String getDimensionName() { return "Ancient Dimension"; } @Override public String getInternalNameSuffix() { // TODO Auto-generated method stub return "AD"; } public String getSaveFolder() { return "AncientDimension"; } public boolean canRespawnHere() { return true; } public boolean isSurfaceWorld() { return true; } public boolean getWorldHasVoidParticles() { return true; } public int getHeight() { return 256; } public boolean canCoordinateBeSpawn(BlockPos pos) { int par1 = pos.getX(); int par2 = pos.getZ(); return this.worldObj.getTopSolidOrLiquidBlock(new BlockPos(par1, 0, par2)).equals(Blocks.grass); } 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 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; } public int getMoonPhase(long par1) { return (int) (par1 / 24000L % 8L + 8L) % 8; } public String getWelcomeMessage() { if (this instanceof AncientWorldProvider) { return "Entering the Ancient Dimension"; } return null; } public String getDepartMessage() { if (this instanceof AncientWorldProvider) { return "Leaving the Ancient Dimension"; } return null; } public double getMovementFactor() { if (this instanceof AncientWorldProvider) { return 10.0; } return 1.0; } @SideOnly(Side.CLIENT) public boolean isSkyColored() { return true; } @Override public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) { return Vec3(2.8, 1.1, 1.7); } private Vec3 Vec3(double d, double e, double f) { // TODO Auto-generated method stub return Vec3(d,e,f); } }
:::
Beaucoup de classe hein ? xD
Voila j’ai vérifié une deuxième fois avec le tuto 1.7 et les classes de minecraft pour moi j’ia tout bien fait bon maintenant je suis pas parfait et la preuve puisque sa marche pas lol
Voila si quelqu’un sais :/</biomegenbase></biomegenbase></biomegenbase></biomegenbase>
-
Désolé du triple post , mais j’essaye par moi même de résoudre le problème et la dimension est créer no soucis du coup juste , que quand on rentre en collision avec le portail on dirait que c’est buggé , que c’est pas détecté directement faut en placer plusieurs pour y rentrer , fin bizarre , toutes les classes sont au dessus si vous savez ^^ J’essaye encore de résoudre par moi même mais de l’aide n’est pas de refus Fin si je trouve je le dirais
-
demain je regarderai. Pour se soir je pense pas
-
No soucy en tout cas j’ai déja régler la dimension elle fonctionne mais c’est le portail surtout
-
Ton post est indigeste. Fait le trie, fait du débuggage et post uniquement ce qui pose problème.
-
@‘Blackout’:
Ton post est indigeste. Fait le trie, fait du débuggage et post uniquement ce qui pose problème.
Certes il est indigeste , mais j’avais mis toutes les classes CAR au départ j’avais carrément toute la dimension qui ne fonctionnait pas, j’ai réussi a régler et je n’ai plus que le soucis du portail qui ne détecte pas le player lorsqu’il rentre en collision et ce post s’adresse surtout a Diangle qui lui s’y connais beaucoup en dimension, de plus en général les classes s’utilise l’une dans l’autre
Merci.
-
Donc, on va commencer simplement. Edit les post est supprime toute les classes autres que ton bloc et le la classes pour téléporter. Sinon Met toute les autres classes dans un onglet spoiler. Ensuite tu t’es servit de quoi pour faire ton portail et ton téléporter ? Regarde quel partit du code n’est pas appeler dans ton portail quand tu entres en collision avec. Comme ça on sera précisément d’où viens le soucis. Pour le fait que la bloc ne s’aligne pas avec la direction on verra ça plus tard.
edit: J’ai oublié. Legrandfifou, Blackout et un dev java très bon dans son domaine, donc c’est conseille sont à prendre et non pas à rejeter.
-
Je n’ai jamais fais de dimension, donc si c’est une mauvaise condition ou une variable qui n’est pas incrémentée ou tout autre truc du genre, je vais devoir chercher dans tout le code pour savoir où ça se trouve. Diangle s’y connait en dimension, donc lui il sait où peut se trouver l’erreur. En postant tout ton code, seul ceux qui s’y connaissent en dimension peuvent t’aider efficacement.
Et encore, le simple fait de supprimer les imports, tu gagnes 200 lignes, tu rends la lecture plus agréable et tu rends le moteur de recherche du forum plus performant -
@‘Diangle’:
Donc, on va commencer simplement. Edit les post est supprime toute les classes autres que ton bloc et le la classes pour téléporter. Sinon Met toute les autres classes dans un onglet spoiler. Ensuite tu t’es servit de quoi pour faire ton portail et ton téléporter ? Regarde quel partit du code n’est pas appeler dans ton portail quand tu entres en collision avec. Comme ça on sera précisément d’où viens le soucis. Pour le fait que la bloc ne s’aligne pas avec la direction on verra ça plus tard.
edit: J’ai oublié. Legrandfifou, Blackout et un dev java très bon dans son domaine, donc c’est conseille sont à prendre et non pas à rejeter.
Oké je vias faire ca , je ne rejette pas ce qu’a dit blackout mais je l’ai vraiment pris comme une attaque , il aurait tout simplement le dire plus cool genre Tu devrais modifier ton post et mettre tout ce qui ne va pas à part.
@‘Blackout’:
Je n’ai jamais fais de dimension, donc si c’est une mauvaise condition ou une variable qui n’est pas incrémentée ou tout autre truc du genre, je vais devoir chercher dans tout le code pour savoir où ça se trouve. Diangle s’y connait en dimension, donc lui il sait où peut se trouver l’erreur. En postant tout ton code, seul ceux qui s’y connaissent en dimension peuvent t’aider efficacement.
Et encore, le simple fait de supprimer les imports, tu gagnes 200 lignes, tu rends la lecture plus agréable et tu rends le moteur de recherche du forum plus performantJe dis ca car c’est le tuto Diangle qui ma permis de créer la dimension , donc c’est pour ca que je le dis car c’est " son code " maintenant je suis ouvert a toute propositions , sache juste que le
@Blackout:
Ton post est indigeste. Fait le trie, fait du débuggage et post uniquement ce qui pose problème.
je trouve ca mal formulé et personnellement je l’ai pris comme une " attaque /pic" , fin voila mon ressenti , soit je vais modifier mon premier post
-
Non il ne s’agit absolument pas une attaque, désolé pour ce malentendu
-
@‘Blackout’:
Non il ne s’agit absolument pas une attaque, désolé pour ce malentendu
Ah bah excuse alors de ma réponse ^^ Je modifierais surement mon post demain car je suis asser occupay
-
Post modifié pour la compréhension de tous
-
Tu as fait se que on t’a dit ? regarder précisément où étais le problème ?
-
Il semble que ce sois dans la fonction :
@Override public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity) { if((entity.ridingEntity == null) && (entity.riddenByEntity == null)) { System.out.println("ridingentitynull"); if(entity.dimension != DimensionRegister.DimAncient) { System.out.println("dimension"); if(entity instanceof EntityPlayerMP) { System.out.println("cesunjoueur"); EntityPlayerMP player = (EntityPlayerMP)entity; if(player.timeUntilPortal > 0) { System.out.println("dansleportail"); player.timeUntilPortal = 10; } else { System.out.println("dansleportailELSE"); player.timeUntilPortal = 10; player.mcServer.getConfigurationManager().transferPlayerToDimension(player, DimensionRegister.DimAncient, new AncientTeleporter(player.mcServer.worldServerForDimension(DimensionRegister.DimAncient))); } } } else { if(entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP)entity; if(player.timeUntilPortal > 0) { player.timeUntilPortal = 10; } else { player.timeUntilPortal = 10; player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 0, new AncientTeleporter(player.mcServer.worldServerForDimension(0))); } } } } }
Donc dans chaque IF , donc c’est cette fonction qui bug
Aucun des messages n’apparaît
EDIT : Problème régler pour finir ::) Juste le portail qui change pas de sens
-
up je pense que la les directions sont buger car la face du portail s’affiche mais pas les petits bords ( c.f portail end )
-
Up , je viens de régler le probleme du spawn dans le sol et dans les airs donc maintenant je spawn dans mon portail mais j’aimerais que le portail qui se génère se tourne suivant la direction du portail la pour l’instant j’ai
BlockRegister.BlockPortail.getDefaultState()
et je suppose qu’il faut que je rajoute un ```java
.withProperty(BlockPortail.AXIS , ET ICI J’AVAIS vu une fonctione du genre rotatefromAnglemais je ne pense pas que ca marchera :/
-
@‘Legrandfifou’:
Up , je viens de régler le probleme du spawn dans le sol et dans les airs donc maintenant je spawn dans mon portail mais j’aimerais que le portail qui se génère se tourne suivant la direction du portail la pour l’instant j’ai
BlockRegister.BlockPortail.getDefaultState()
et je suppose qu’il faut que je rajoute un ```java
.withProperty(BlockPortail.AXIS , ET ICI J’AVAIS vu une fonctione du genre rotatefromAngle -
Tu m’a aidé alors je te rend l’appareil. Déjà on créer une variable “axis” :
EnumFacing.Axis axis = EnumFacing.Axis.X;
Après on prend la position du bloque dans le monde par rapport au joueur et on-dit que si il y a un bloque de portail à “droite” ou à “gauche” ce sera l’axe X et inversement en “face” ou “derrière” l’axe Z :
if(this.worldServerInstance.getBlockState(new BlockPos(entity.posX + 1, entity.posY, entity.posZ)).equals(EmotionBlocks.purpuraBlock.getDefaultState()) || this.worldServerInstance.getBlockState(new BlockPos(entity.posX - 1, entity.posY, entity.posZ)).equals(EmotionBlocks.purpuraBlock.getDefaultState())) { axis = EnumFacing.Axis.Z; } else if(this.worldServerInstance.getBlockState(new BlockPos(entity.posX, entity.posY, entity.posZ + 1)).equals(EmotionBlocks.purpuraBlock.getDefaultState()) || this.worldServerInstance.getBlockState(new BlockPos(entity.posX, entity.posY, entity.posZ -1)).equals(EmotionBlocks.purpuraBlock.getDefaultState())) { axis = EnumFacing.Axis.X; }
Et enfin on applique à la création du bloque notre axis :
EmotionBlocks.dreamPortal.getDefaultState().withProperty(DreamPortal.AXIS, axis)
Voilà ça devrait fonctionner ,)
P.S: Tu a 1 chance sur deux que ça fonctionne, dans le pire des cas il suffit d’inverser Z et X.
-
Merci j’en prend note