custom portal sizes added

This commit is contained in:
Kino 2016-12-28 21:09:06 -05:00
parent d0e77c2801
commit b8fee9aade
7 changed files with 558 additions and 422 deletions

View file

@ -27,8 +27,8 @@ import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import com.legacy.aether.server.blocks.BlockAetherPortal;
import com.legacy.aether.server.blocks.BlocksAether;
import com.legacy.aether.server.blocks.portal.BlockAetherPortal;
import com.legacy.aether.server.items.ItemsAether;
import com.legacy.aether.server.items.weapons.ItemSkyrootSword;
import com.legacy.aether.server.registry.achievements.AchievementsAether;
@ -85,7 +85,7 @@ public class AetherEventHandler
if (isWater)
{
if (((BlockAetherPortal) BlocksAether.aether_portal).setupAetherPortal(event.getWorld(), hitPos))
if (((BlockAetherPortal) BlocksAether.aether_portal).trySpawnPortal(event.getWorld(), hitPos))
{
if (!event.getEntityPlayer().capabilities.isCreativeMode)
{

View file

@ -1,168 +0,0 @@
package com.legacy.aether.server.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPortal;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.EnumFacing.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockAetherPortal extends BlockPortal
{
public BlockAetherPortal()
{
super();
this.setHardness(-1);
this.setResistance(900000F);
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
return;
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn)
{
}
@Override
public boolean trySpawnPortal(World worldIn, BlockPos p_176548_2_)
{
return false;
}
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos)
{
return world.getBlockState(pos.down()) != null && world.getBlockState(pos.up()) != this && world.getBlockState(pos.south()) != this && world.getBlockState(pos.north()) != this && world.getBlockState(pos.east()) != this && world.getBlockState(pos.west()) != this ? super.canPlaceBlockAt(world, pos) : false;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random)
{
if (random.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, random.nextFloat() * 0.4F + 0.8F, false);
}
}
@Override
public void updateTick(World par1World, BlockPos pos, IBlockState state, Random par5Random)
{
}
public boolean placeAetherPortal(World world, BlockPos pos)
{
byte b1 = 0;
if (world.getBlockState(pos.north()).getBlock() == Blocks.GLOWSTONE || world.getBlockState(pos.south()).getBlock() == Blocks.GLOWSTONE)
{
b1 = 1;
}
Axis axis = b1 == 1 ? EnumFacing.Axis.Z : EnumFacing.Axis.X;
loop:
for (int width = -1; width >= 1; ++ width)
{
for (int height = -2; height >= 2; ++height)
{
pos.add(width, 0, height);
if (world.getBlockState(pos).getBlock() != Blocks.AIR)
{
break loop;
}
world.setBlockState(pos, BlocksAether.aether_portal.getDefaultState().withProperty(AXIS, axis), 2);
}
}
return true;
}
public boolean setupAetherPortal(World world, BlockPos pos)
{
byte b0 = 0;
byte b1 = 0;
if (world.getBlockState(pos.west()).getBlock() == Blocks.GLOWSTONE || world.getBlockState(pos.east()).getBlock() == Blocks.GLOWSTONE)
{
b0 = 1;
}
if (world.getBlockState(pos.north()).getBlock() == Blocks.GLOWSTONE || world.getBlockState(pos.south()).getBlock() == Blocks.GLOWSTONE)
{
b1 = 1;
}
if (b0 == b1)
{
return false;
}
else
{
if (world.getBlockState(new BlockPos(pos.getX() - b0, pos.getY(), pos.getZ() - b1)).getBlock() == Blocks.AIR)
{
pos = pos.west(b0);
pos = pos.north(b1);
}
int l;
int i1;
for (l = -1; l <= 2; ++l)
{
for (i1 = -1; i1 <= 3; ++i1)
{
boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3;
if (l != -1 && l != 2 || i1 != -1 && i1 != 3)
{
Block j1 = world.getBlockState(new BlockPos(pos.getX() + b0 * l, pos.getY() + i1, pos.getZ() + b1 * l)).getBlock();
if (flag)
{
if (j1 != Blocks.GLOWSTONE)
{
return false;
}
}
else if (j1 != Blocks.AIR && (j1 != Blocks.FLOWING_WATER || j1 != Blocks.WATER))
{
return false;
}
}
}
}
for (l = 0; l < 2; ++l)
{
for (i1 = 0; i1 < 3; ++i1)
{
Axis axis = b1 == 1 ? EnumFacing.Axis.Z : EnumFacing.Axis.X;
world.setBlockState(new BlockPos(pos.getX() + b0 * l, pos.getY() + i1, pos.getZ() + b1 * l), BlocksAether.aether_portal.getDefaultState().withProperty(AXIS, axis), 2);
}
}
return true;
}
}
}

View file

@ -46,6 +46,7 @@ import com.legacy.aether.server.blocks.natural.enchanted.BlockEnchantedGravitite
import com.legacy.aether.server.blocks.natural.ore.BlockAmbrosiumOre;
import com.legacy.aether.server.blocks.natural.ore.BlockGravititeOre;
import com.legacy.aether.server.blocks.natural.ore.BlockZaniteOre;
import com.legacy.aether.server.blocks.portal.BlockAetherPortal;
import com.legacy.aether.server.items.block.ItemAetherSlab;
import com.legacy.aether.server.items.block.ItemSubtype;
import com.legacy.aether.server.registry.creative_tabs.AetherCreativeTabs;

View file

@ -0,0 +1,180 @@
package com.legacy.aether.server.blocks.portal;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import com.legacy.aether.server.blocks.BlocksAether;
public class AetherPortalSize
{
private final World world;
private final EnumFacing.Axis axis;
public final EnumFacing rightDir;
public final EnumFacing leftDir;
public int portalBlockCount;
public BlockPos bottomLeft;
public int height;
public int width;
public AetherPortalSize(World worldIn, BlockPos position, EnumFacing.Axis axis)
{
this.world = worldIn;
this.axis = axis;
if (axis == EnumFacing.Axis.X)
{
this.leftDir = EnumFacing.EAST;
this.rightDir = EnumFacing.WEST;
}
else
{
this.leftDir = EnumFacing.NORTH;
this.rightDir = EnumFacing.SOUTH;
}
for (BlockPos blockpos = position; position.getY() > blockpos.getY() - 21 && position.getY() > 0 && this.isEmptyBlock(worldIn.getBlockState(position.down()).getBlock()); position = position.down())
{
;
}
int i = this.getDistanceUntilEdge(position, this.leftDir) - 1;
if (i >= 0)
{
this.bottomLeft = position.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 position, EnumFacing axis)
{
int i;
for (i = 0; i < 22; ++i)
{
BlockPos blockpos = position.offset(axis, i);
if (!this.isEmptyBlock(this.world.getBlockState(blockpos).getBlock()) || this.world.getBlockState(blockpos.down()).getBlock() != Blocks.GLOWSTONE)
{
break;
}
}
Block block = this.world.getBlockState(position.offset(axis, i)).getBlock();
return block == Blocks.GLOWSTONE ? 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 == BlocksAether.aether_portal)
{
++this.portalBlockCount;
}
if (i == 0)
{
block = this.world.getBlockState(blockpos.offset(this.leftDir)).getBlock();
if (block != Blocks.GLOWSTONE)
{
break label24;
}
}
else if (i == this.width - 1)
{
block = this.world.getBlockState(blockpos.offset(this.rightDir)).getBlock();
if (block != Blocks.GLOWSTONE)
{
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.GLOWSTONE)
{
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 blockIn)
{
return blockIn.getDefaultState().getMaterial() == Material.AIR || blockIn == Blocks.FIRE || blockIn == BlocksAether.aether_portal;
}
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), BlocksAether.aether_portal.getDefaultState().withProperty(BlockAetherPortal.AXIS, this.axis), 2);
}
}
}
}

View file

@ -0,0 +1,163 @@
package com.legacy.aether.server.blocks.portal;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPortal;
import net.minecraft.block.material.Material;
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.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import com.google.common.cache.LoadingCache;
public class BlockAetherPortal extends BlockPortal
{
public BlockAetherPortal()
{
super();
this.setHardness(-1);
this.setResistance(900000F);
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
return;
}
@Override
public boolean trySpawnPortal(World worldIn, BlockPos pos)
{
AetherPortalSize aetherportal$size = new AetherPortalSize(worldIn, pos, EnumFacing.Axis.X);
if (aetherportal$size.isValid() && aetherportal$size.portalBlockCount == 0)
{
aetherportal$size.placePortalBlocks();
return true;
}
else
{
AetherPortalSize aetherportal$size1 = new AetherPortalSize(worldIn, pos, EnumFacing.Axis.Z);
if (aetherportal$size1.isValid() && aetherportal$size1.portalBlockCount == 0)
{
aetherportal$size1.placePortalBlocks();
return true;
}
else
{
return false;
}
}
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn)
{
EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)state.getValue(AXIS);
if (enumfacing$axis == EnumFacing.Axis.X)
{
AetherPortalSize blockportal$size = new AetherPortalSize(world, pos, EnumFacing.Axis.X);
if (!blockportal$size.isValid() || blockportal$size.portalBlockCount < blockportal$size.width * blockportal$size.height)
{
world.setBlockState(pos, Blocks.AIR.getDefaultState());
}
}
else if (enumfacing$axis == EnumFacing.Axis.Z)
{
AetherPortalSize blockportal$size1 = new AetherPortalSize(world, pos, EnumFacing.Axis.Z);
if (!blockportal$size1.isValid() || blockportal$size1.portalBlockCount < blockportal$size1.width * blockportal$size1.height)
{
world.setBlockState(pos, Blocks.AIR.getDefaultState());
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random)
{
if (random.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, random.nextFloat() * 0.4F + 0.8F, false);
}
}
@Override
public BlockPattern.PatternHelper createPatternHelper(World worldIn, BlockPos p_181089_2_)
{
EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Z;
AetherPortalSize blockportal$size = new AetherPortalSize(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 AetherPortalSize(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);
}
}
@Override
public void updateTick(World par1World, BlockPos pos, IBlockState state, Random par5Random)
{
}
}

View file

@ -153,7 +153,7 @@ public class PlayerAether
{
this.timeInPortal += 0.0125F;
if (!this.hasTeleported && (this.thePlayer.capabilities.isCreativeMode || this.timeInPortal < 2.0F && this.timeInPortal >= 1.0F))
if (!this.hasTeleported && (this.thePlayer.capabilities.isCreativeMode || this.timeInPortal < 1.5F && this.timeInPortal >= 1.0F))
{
this.teleportPlayer(true);
}
@ -276,6 +276,7 @@ public class PlayerAether
this.shouldRenderHalo = input.getBoolean("halo");
}
this.hasTeleported = true;
this.cooldown = input.getInteger("hammer_cooldown");
this.cooldownName = input.getString("notch_hammer_name");
this.cooldownMax = input.getInteger("max_hammer_cooldown");

View file

@ -5,315 +5,264 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPortal;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;
import com.legacy.aether.server.blocks.BlocksAether;
import com.legacy.aether.server.blocks.portal.BlockAetherPortal;
import com.legacy.aether.server.world.util.AetherPortalPosition;
import com.legacy.aether.server.world.util.Direction;
@SuppressWarnings("deprecation")
public class TeleporterAether extends Teleporter
{
private boolean portalSpawn;
private final WorldServer worldServerInstance;
private final boolean portalSpawn;
private final Random random;
private final WorldServer worldServerInstance;
private final Long2ObjectMap<AetherPortalPosition> destinationCoordinateCache = new Long2ObjectOpenHashMap<AetherPortalPosition>(4096);
public TeleporterAether(boolean portalSpawn, WorldServer world)
public TeleporterAether(boolean portalSpawn, WorldServer worldIn)
{
super(world);
super(worldIn);
this.portalSpawn = portalSpawn;
this.worldServerInstance = world;
this.random = new Random(world.getSeed());
this.worldServerInstance = worldIn;
this.random = new Random(worldIn.getSeed());
}
@Override
public void placeInPortal(Entity entity, float rotation)
public void placeInPortal(Entity entityIn, float rotationYaw)
{
if (!this.portalSpawn)
{
return;
}
if (!this.placeInExistingPortal(entity, rotation))
if (!this.placeInExistingPortal(entityIn, rotationYaw))
{
this.makePortal(entity);
this.placeInExistingPortal(entity, rotation);
this.makePortal(entityIn);
this.placeInExistingPortal(entityIn, rotationYaw);
}
}
@Override
public boolean placeInExistingPortal(Entity entity, float rotation)
@Override
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
{
double d0 = -1.0D;
int j = MathHelper.floor_double(entity.posX);
int k = MathHelper.floor_double(entity.posZ);
BlockPos pos = BlockPos.ORIGIN;
long l = ChunkPos.asLong(j, k);
int j = MathHelper.floor_double(entityIn.posX);
int k = MathHelper.floor_double(entityIn.posZ);
boolean flag = true;
BlockPos blockpos = BlockPos.ORIGIN;
long l = ChunkPos.asLong(j, k);
if (this.destinationCoordinateCache.containsKey(l))
{
AetherPortalPosition portalposition = (AetherPortalPosition)this.destinationCoordinateCache.get(l);
AetherPortalPosition teleporter$portalposition = (AetherPortalPosition)this.destinationCoordinateCache.get(l);
d0 = 0.0D;
pos = portalposition;
blockpos = teleporter$portalposition;
teleporter$portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
flag = false;
}
else
{
BlockPos blockpos3 = new BlockPos(entity);
BlockPos blockpos3 = new BlockPos(entityIn);
for (int i1 = -128; i1 <= 128; ++i1)
{
BlockPos blockpos2;
for (int i1 = -128; i1 <= 128; ++i1)
{
BlockPos blockpos2;
for (int j1 = -128; j1 <= 128; ++j1)
{
for (BlockPos blockpos1 = blockpos3.add(i1, this.worldServerInstance.getActualHeight() - 1 - blockpos3.getY(), j1); blockpos1.getY() >= 0; blockpos1 = blockpos2)
{
blockpos2 = blockpos1.down();
for (int j1 = -128; j1 <= 128; ++j1)
{
for (BlockPos blockpos1 = blockpos3.add(i1, this.worldServerInstance.getActualHeight() - 1 - blockpos3.getY(), j1); blockpos1.getY() >= 0; blockpos1 = blockpos2)
{
blockpos2 = blockpos1.down();
if (this.worldServerInstance.getBlockState(blockpos1).getBlock() == BlocksAether.aether_portal)
{
while (this.worldServerInstance.getBlockState(blockpos2 = blockpos1.down()).getBlock() == BlocksAether.aether_portal)
{
blockpos1 = blockpos2;
}
if (this.worldServerInstance.getBlockState(blockpos1).getBlock() == BlocksAether.aether_portal)
{
for (blockpos2 = blockpos1.down(); this.worldServerInstance.getBlockState(blockpos2).getBlock() == BlocksAether.aether_portal; blockpos2 = blockpos2.down())
{
blockpos1 = blockpos2;
}
double d1 = blockpos1.distanceSq(blockpos3);
double d1 = blockpos1.distanceSq(blockpos3);
if (d0 < 0.0D || d1 < d0)
{
d0 = d1;
pos = blockpos1;
}
}
}
}
}
if (d0 < 0.0D || d1 < d0)
{
d0 = d1;
blockpos = blockpos1;
}
}
}
}
}
}
if (d0 >= 0.0D)
{
if (flag)
{
this.destinationCoordinateCache.put(l, new AetherPortalPosition(pos, this.worldServerInstance.getTotalWorldTime()));
this.destinationCoordinateCache.put(l, new AetherPortalPosition(blockpos, this.worldServerInstance.getTotalWorldTime()));
}
double d11 = (double)pos.getX() + 0.5D;
double d6 = (double)pos.getY() + 0.5D;
double d7 = (double)pos.getZ() + 0.5D;
int i4 = -1;
double d5 = (double)blockpos.getX() + 0.5D;
double d7 = (double)blockpos.getZ() + 0.5D;
BlockPattern.PatternHelper blockpattern$patternhelper = ((BlockAetherPortal) BlocksAether.aether_portal).createPatternHelper(this.worldServerInstance, blockpos);
boolean flag1 = blockpattern$patternhelper.getForwards().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE;
double d2 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? (double)blockpattern$patternhelper.getFrontTopLeft().getZ() : (double)blockpattern$patternhelper.getFrontTopLeft().getX();
if (this.worldServerInstance.getBlockState(pos.west()).getBlock() == BlocksAether.aether_portal)
double d1 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? d7 : d5;
d1 = Math.abs(MathHelper.pct(d1 - (double)(blockpattern$patternhelper.getForwards().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ? 1 : 0), d2, d2 - (double)blockpattern$patternhelper.getWidth()));
double d22 = MathHelper.pct(blockpos.getY() - 1.0D, (double)blockpattern$patternhelper.getFrontTopLeft().getY(), (double)(blockpattern$patternhelper.getFrontTopLeft().getY() - blockpattern$patternhelper.getHeight()));
double d6 = (double)(blockpattern$patternhelper.getFrontTopLeft().getY() + 1) - new Vec3d(d1, d22, 0.0D).yCoord * (double)blockpattern$patternhelper.getHeight();
if (flag1)
{
i4 = 2;
++d2;
}
if (this.worldServerInstance.getBlockState(pos.east()).getBlock() == BlocksAether.aether_portal)
if (blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X)
{
i4 = 0;
d7 = d2 + (1.0D - new Vec3d(d1, d22, 0.0D).xCoord) * (double)blockpattern$patternhelper.getWidth() * (double)blockpattern$patternhelper.getForwards().rotateY().getAxisDirection().getOffset();
}
else
{
d5 = d2 + (1.0D - new Vec3d(d1, d22, 0.0D).xCoord) * (double)blockpattern$patternhelper.getWidth() * (double)blockpattern$patternhelper.getForwards().rotateY().getAxisDirection().getOffset();
}
if (this.worldServerInstance.getBlockState(pos.north()).getBlock() == BlocksAether.aether_portal)
float f = 0.0F;
float f1 = 0.0F;
float f2 = 0.0F;
float f3 = 0.0F;
if (blockpattern$patternhelper.getForwards().getOpposite() == blockpattern$patternhelper.getForwards())
{
i4 = 3;
f = 1.0F;
f1 = 1.0F;
}
else if (blockpattern$patternhelper.getForwards().getOpposite() == blockpattern$patternhelper.getForwards().getOpposite())
{
f = -1.0F;
f1 = -1.0F;
}
else if (blockpattern$patternhelper.getForwards().getOpposite() == blockpattern$patternhelper.getForwards().rotateY())
{
f2 = 1.0F;
f3 = -1.0F;
}
else
{
f2 = -1.0F;
f3 = 1.0F;
}
if (this.worldServerInstance.getBlockState(pos.south()).getBlock() == BlocksAether.aether_portal)
double d3 = entityIn.motionX;
double d4 = entityIn.motionZ;
entityIn.motionX = d3 * (double)f + d4 * (double)f3;
entityIn.motionZ = d3 * (double)f2 + d4 * (double)f1;
entityIn.rotationYaw = rotationYaw - (float)(blockpattern$patternhelper.getForwards().getOpposite().getHorizontalIndex() * 90) + (float)(blockpattern$patternhelper.getForwards().getHorizontalIndex() * 90);
if (entityIn instanceof EntityPlayerMP)
{
i4 = 1;
((EntityPlayerMP)entityIn).connection.setPlayerLocation(d5, d6, d7, entityIn.rotationYaw, entityIn.rotationPitch);
}
int j2 = Direction.getMovementDirection(entity.prevPosX - entity.posX, entity.prevPosZ - entity.posZ);
if (i4 > -1)
else
{
int k2 = Direction.rotateLeft[i4];
int l2 = Direction.offsetX[i4];
int i3 = Direction.offsetZ[i4];
int j3 = Direction.offsetX[k2];
int k3 = Direction.offsetZ[k2];
boolean flag1 = !this.worldServerInstance.isAirBlock(new BlockPos(pos.getX() + l2 + j3, pos.getY(), pos.getZ() + i3 + k3)) || !this.worldServerInstance.isAirBlock(new BlockPos(pos.getX() + l2 + j3, pos.getY() + 1, pos.getZ() + i3 + k3));
boolean flag2 = !this.worldServerInstance.isAirBlock(new BlockPos(pos.getX() + l2, pos.getY(), pos.getZ() + i3)) || !this.worldServerInstance.isAirBlock(new BlockPos(pos.getX() + l2, pos.getY() + 1, pos.getZ() + i3));
if (flag1 && flag2)
{
i4 = Direction.rotateOpposite[i4];
k2 = Direction.rotateOpposite[k2];
l2 = Direction.offsetX[i4];
i3 = Direction.offsetZ[i4];
j3 = Direction.offsetX[k2];
k3 = Direction.offsetZ[k2];
int l3 = pos.getX() - j3;
d11 -= (double)j3;
int k1 = pos.getZ() - k3;
d7 -= (double)k3;
flag1 = !this.worldServerInstance.isAirBlock(new BlockPos(l3 + l2 + j3, pos.getY(), k1 + i3 + k3)) || !this.worldServerInstance.isAirBlock(new BlockPos(l3 + l2 + j3, pos.getY() + 1, k1 + i3 + k3));
flag2 = !this.worldServerInstance.isAirBlock(new BlockPos(l3 + l2, pos.getY(), k1 + i3)) || !this.worldServerInstance.isAirBlock(new BlockPos(l3 + l2, pos.getY() + 1, k1 + i3));
}
float f1 = 0.5F;
float f2 = 0.5F;
if (!flag1 && flag2)
{
f1 = 1.0F;
}
else if (flag1 && !flag2)
{
f1 = 0.0F;
}
else if (flag1 && flag2)
{
f2 = 0.0F;
}
d11 += (double)((float)j3 * f1 + f2 * (float)l2);
d7 += (double)((float)k3 * f1 + f2 * (float)i3);
float f3 = 0.0F;
float f4 = 0.0F;
float f5 = 0.0F;
float f6 = 0.0F;
if (i4 == j2)
{
f3 = 1.0F;
f4 = 1.0F;
}
else if (i4 == Direction.rotateOpposite[j2])
{
f3 = -1.0F;
f4 = -1.0F;
}
else if (i4 == Direction.rotateRight[j2])
{
f5 = 1.0F;
f6 = -1.0F;
}
else
{
f5 = -1.0F;
f6 = 1.0F;
}
double d9 = entity.motionX;
double d10 = entity.motionZ;
entity.motionX = d9 * (double)f3 + d10 * (double)f6;
entity.motionZ = d9 * (double)f5 + d10 * (double)f4;
entity.rotationYaw = rotation - (float)(j2 * 90) + (float)(i4 * 90);
entity.setLocationAndAngles(d11, d6, d7, entity.rotationYaw, entity.rotationPitch);
entityIn.setLocationAndAngles(d5, d6, d7, entityIn.rotationYaw, entityIn.rotationPitch);
}
return true;
}
else
{
return false;
return false;
}
}
@Override
public boolean makePortal(Entity entity)
public boolean makePortal(Entity entityIn)
{
int b0 = 100;
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 j = MathHelper.floor_double(entityIn.posX);
int k = MathHelper.floor_double(entityIn.posY);
int l = MathHelper.floor_double(entityIn.posZ);
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;
int k1 = l;
int l1 = 0;
int i2 = this.random.nextInt(4);
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (i2 = i - b0; i2 <= i + b0; ++i2)
for (int j2 = j - 16; j2 <= j + 16; ++j2)
{
d1 = (double)i2 + 0.5D - entity.posX;
double d1 = (double)j2 + 0.5D - entityIn.posX;
for (k2 = k - b0; k2 <= k + b0; ++k2)
for (int l2 = l - 16; l2 <= l + 16; ++l2)
{
d2 = (double)k2 + 0.5D - entity.posZ;
label274:
double d2 = (double)l2 + 0.5D - entityIn.posZ;
label146:
for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3)
for (int j3 = this.worldServerInstance.getActualHeight() - 1; j3 >= 0; --j3)
{
if (this.worldServerInstance.isAirBlock(new BlockPos(i2, i3, k2)))
if (this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.setPos(j2, j3, l2)))
{
while (i3 > 0 && this.worldServerInstance.isAirBlock(new BlockPos(i2, i3 - 1, k2)))
while (j3 > 0 && this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.setPos(j2, j3 - 1, l2)))
{
--i3;
--j3;
}
for (j3 = l1; j3 < l1 + 4; ++j3)
for (int k3 = i2; k3 < i2 + 4; ++k3)
{
k3 = j3 % 2;
l3 = 1 - k3;
int l3 = k3 % 2;
int i4 = 1 - l3;
if (j3 % 4 >= 2)
if (k3 % 4 >= 2)
{
k3 = -k3;
l3 = -l3;
i4 = -i4;
}
for (i4 = 0; i4 < 3; ++i4)
for (int j4 = 0; j4 < 3; ++j4)
{
for (j4 = 0; j4 < 4; ++j4)
for (int k4 = 0; k4 < 4; ++k4)
{
for (k4 = -1; k4 < 4; ++k4)
for (int l4 = -1; l4 < 4; ++l4)
{
l4 = i2 + (j4 - 1) * k3 + i4 * l3;
i5 = i3 + k4;
int j5 = k2 + (j4 - 1) * l3 - i4 * k3;
int i5 = j2 + (k4 - 1) * l3 + j4 * i4;
int j5 = j3 + l4;
int k5 = l2 + (k4 - 1) * i4 - j4 * l3;
blockpos$mutableblockpos.setPos(i5, j5, k5);
BlockPos pos2 = new BlockPos(l4, i5, j5);
if (k4 < 0 && !this.worldServerInstance.getBlockState(pos2).getMaterial().isSolid() || this.worldServerInstance.getBlockState(pos2).getBlock() == BlocksAether.aercloud || k4 >= 0 && !this.worldServerInstance.isAirBlock(pos2))
if (l4 < 0 && !this.worldServerInstance.getBlockState(blockpos$mutableblockpos).getMaterial().isSolid() || l4 >= 0 && !this.worldServerInstance.isAirBlock(blockpos$mutableblockpos))
{
continue label274;
continue label146;
}
}
}
}
d3 = (double)i3 + 0.5D - entity.posY;
d4 = d1 * d1 + d3 * d3 + d2 * d2;
double d5 = (double)j3 + 0.5D - entityIn.posY;
double d7 = d1 * d1 + d5 * d5 + d2 * d2;
if (d0 < 0.0D || d4 < d0)
if (d0 < 0.0D || d7 < d0)
{
d0 = d4;
l = i2;
i1 = i3;
j1 = k2;
k1 = j3 % 4;
d0 = d7;
i1 = j2;
j1 = j3;
k1 = l2;
l1 = k3 % 4;
}
}
}
@ -323,56 +272,55 @@ public class TeleporterAether extends Teleporter
if (d0 < 0.0D)
{
for (i2 = i - b0; i2 <= i + b0; ++i2)
for (int l5 = j - 16; l5 <= j + 16; ++l5)
{
d1 = (double)i2 + 0.5D - entity.posX;
double d3 = (double)l5 + 0.5D - entityIn.posX;
for (k2 = k - b0; k2 <= k + b0; ++k2)
for (int j6 = l - 16; j6 <= l + 16; ++j6)
{
d2 = (double)k2 + 0.5D - entity.posZ;
label222:
double d4 = (double)j6 + 0.5D - entityIn.posZ;
label567:
for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3)
for (int i7 = this.worldServerInstance.getActualHeight() - 1; i7 >= 0; --i7)
{
if (this.worldServerInstance.isAirBlock(new BlockPos(i2, i3, k2)))
if (this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.setPos(l5, i7, j6)))
{
while (i3 > 0 && this.worldServerInstance.isAirBlock(new BlockPos(i2, i3 - 1, k2)))
while (i7 > 0 && this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.setPos(l5, i7 - 1, j6)))
{
--i3;
--i7;
}
for (j3 = l1; j3 < l1 + 2; ++j3)
for (int k7 = i2; k7 < i2 + 2; ++k7)
{
k3 = j3 % 2;
l3 = 1 - k3;
int j8 = k7 % 2;
int j9 = 1 - j8;
for (i4 = 0; i4 < 4; ++i4)
for (int j10 = 0; j10 < 4; ++j10)
{
for (j4 = -1; j4 < 4; ++j4)
for (int j11 = -1; j11 < 4; ++j11)
{
k4 = i2 + (i4 - 1) * k3;
l4 = i3 + j4;
i5 = k2 + (i4 - 1) * l3;
int j12 = l5 + (j10 - 1) * j8;
int i13 = i7 + j11;
int j13 = j6 + (j10 - 1) * j9;
blockpos$mutableblockpos.setPos(j12, i13, j13);
IBlockState stateInstance = this.worldServerInstance.getBlockState(new BlockPos(k4, l4, i5));
Block blockInstance = this.worldServerInstance.getBlockState(new BlockPos(k4, l4, i5)).getBlock();
if (j4 < 0 && !stateInstance.getMaterial().isSolid() || blockInstance == BlocksAether.aercloud || j4 >= 0 && !this.worldServerInstance.isAirBlock(new BlockPos(k4, l4, i5)))
if (j11 < 0 && !this.worldServerInstance.getBlockState(blockpos$mutableblockpos).getMaterial().isSolid() || j11 >= 0 && !this.worldServerInstance.isAirBlock(blockpos$mutableblockpos))
{
continue label222;
continue label567;
}
}
}
d3 = (double)i3 + 0.5D - entity.posY;
d4 = d1 * d1 + d3 * d3 + d2 * d2;
double d6 = (double)i7 + 0.5D - entityIn.posY;
double d8 = d3 * d3 + d6 * d6 + d4 * d4;
if (d0 < 0.0D || d4 < d0)
if (d0 < 0.0D || d8 < d0)
{
d0 = d4;
l = i2;
i1 = i3;
j1 = k2;
k1 = j3 % 2;
d0 = d8;
i1 = l5;
j1 = i7;
k1 = j6;
l1 = k7 % 2;
}
}
}
@ -381,55 +329,66 @@ public class TeleporterAether extends Teleporter
}
}
int k5 = l;
int j2 = i1;
k2 = j1;
int l5 = k1 % 2;
int l2 = 1 - l5;
int i6 = i1;
int k2 = j1;
int k6 = k1;
int l6 = l1 % 2;
int i3 = 1 - l6;
if (k1 % 4 >= 2)
if (l1 % 4 >= 2)
{
l5 = -l5;
l2 = -l2;
l6 = -l6;
i3 = -i3;
}
boolean flag;
if (d0 < 0.0D)
{
i1 = MathHelper.clamp_int(i1, 70, this.worldServerInstance.getActualHeight() - 10);
j2 = i1;
j1 = MathHelper.clamp_int(j1, 70, this.worldServerInstance.getActualHeight() - 10);
k2 = j1;
for (i3 = -1; i3 <= 1; ++i3)
for (int j7 = -1; j7 <= 1; ++j7)
{
for (j3 = 1; j3 < 3; ++j3)
for (int l7 = 1; l7 < 3; ++l7)
{
for (k3 = -1; k3 < 3; ++k3)
for (int k8 = -1; k8 < 3; ++k8)
{
l3 = k5 + (j3 - 1) * l5 + i3 * l2;
i4 = j2 + k3;
j4 = k2 + (j3 - 1) * l2 - i3 * l5;
flag = k3 < 0;
this.worldServerInstance.setBlockState(new BlockPos(l3, i4, j4), flag ? Blocks.GLOWSTONE.getDefaultState() : Blocks.AIR.getDefaultState());
int k9 = i6 + (l7 - 1) * l6 + j7 * i3;
int k10 = k2 + k8;
int k11 = k6 + (l7 - 1) * i3 - j7 * l6;
boolean flag = k8 < 0;
this.worldServerInstance.setBlockState(new BlockPos(k9, k10, k11), flag ? Blocks.GLOWSTONE.getDefaultState() : Blocks.AIR.getDefaultState());
}
}
}
}
for (i3 = 0; i3 < 4; ++i3)
IBlockState iblockstate = BlocksAether.aether_portal.getDefaultState().withProperty(BlockPortal.AXIS, l6 == 0 ? EnumFacing.Axis.Z : EnumFacing.Axis.X);
for (int i8 = 0; i8 < 4; ++i8)
{
for (j3 = 0; j3 < 4; ++j3)
for (int l8 = 0; l8 < 4; ++l8)
{
for (k3 = -1; k3 < 4; ++k3)
for (int l9 = -1; l9 < 4; ++l9)
{
l3 = k5 + (j3 - 1) * l5;
i4 = j2 + k3;
j4 = k2 + (j3 - 1) * l2;
flag = j3 == 0 || j3 == 3 || k3 == -1 || k3 == 3;
this.worldServerInstance.setBlockState(new BlockPos(l3, i4, j4), flag ? Blocks.GLOWSTONE.getDefaultState() : BlocksAether.aether_portal.getDefaultState().withProperty(BlockPortal.AXIS, l5 != 0 ? EnumFacing.Axis.X : EnumFacing.Axis.Z), 2);
int l10 = i6 + (l8 - 1) * l6;
int l11 = k2 + l9;
int k12 = k6 + (l8 - 1) * i3;
boolean flag1 = l8 == 0 || l8 == 3 || l9 == -1 || l9 == 3;
this.worldServerInstance.setBlockState(new BlockPos(l10, l11, k12), flag1 ? Blocks.GLOWSTONE.getDefaultState() : iblockstate, 2);
}
}
for (int i9 = 0; i9 < 4; ++i9)
{
for (int i10 = -1; i10 < 4; ++i10)
{
int i11 = i6 + (i9 - 1) * l6;
int i12 = k2 + i10;
int l12 = k6 + (i9 - 1) * i3;
BlockPos blockpos = new BlockPos(i11, i12, l12);
this.worldServerInstance.notifyNeighborsOfStateChange(blockpos, this.worldServerInstance.getBlockState(blockpos).getBlock());
}
}
}
return true;