Jump to content

[1.8.9] Weird Problems with custom Dimension [SOLVED]


Recommended Posts

Posted

I "made" a teleporter class and a BlockPortal class (basically copied it because I have no Idea what's going on nor did I find any good tutorials).

My problem is that the Portal Block teleports me to the nether instead of my Dimension. Where did I mess up?

My "Portal Frame" Block is called slimyBedrockium, my portal block bedrockiumPortal.

 

EDIT: I have one more Problem: The dimension doesn't get loaded when entering the portal for the first time. If I want it to load, I need to reconnect to the world. (I usually then spawn somewhere in the ground). The same thing happens when I go back to the Overworld...

 

This is my Teleporter Class:

package tschipp.bedrockium.dimension;

import java.util.Iterator;
import java.util.List;
import java.util.Random;

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.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 tschipp.bedrockium.BedrockiumMod;
import tschipp.bedrockium.blocks.BedrockiumBlocks;

import com.google.common.collect.Lists;

public class TeleporterBedrockium extends Teleporter
{
    private final WorldServer worldServerInstance;
    /** A private Random() function in Teleporter */
    private final Random random;
    private final LongHashMap<TeleporterBedrockium.PortalPosition> destinationCoordinateCache = new LongHashMap();
    private final List<Long> destinationCoordinateKeys = Lists.<Long>newArrayList();

    public TeleporterBedrockium(WorldServer worldIn)
    {
    	super(worldIn);
        this.worldServerInstance = worldIn;
        this.random = new Random(worldIn.getSeed());
    }

    @Override
    public void placeInPortal(Entity entityIn, float rotationYaw)
    {
        if (this.worldServerInstance.provider.getDimensionId() != 1)
        {
            if (!this.placeInExistingPortal(entityIn, rotationYaw))
            {
                this.makePortal(entityIn);
                this.placeInExistingPortal(entityIn, rotationYaw);
            }
        }
        else
        {
            int i = MathHelper.floor_double(entityIn.posX);
            int j = MathHelper.floor_double(entityIn.posY) - 1;
            int k = MathHelper.floor_double(entityIn.posZ);
            int l = 1;
            int i1 = 0;

            for (int j1 = -2; j1 <= 2; ++j1)
            {
                for (int k1 = -2; k1 <= 2; ++k1)
                {
                    for (int l1 = -1; l1 < 3; ++l1)
                    {
                        int i2 = i + k1 * l + j1 * i1;
                        int j2 = j + l1;
                        int k2 = k + k1 * i1 - j1 * l;
                        boolean flag = l1 < 0;
                        this.worldServerInstance.setBlockState(new BlockPos(i2, j2, k2), flag ? BedrockiumBlocks.slimyBedrockium.getDefaultState() : Blocks.air.getDefaultState());
                    }
                }
            }

            entityIn.setLocationAndAngles((double)i, (double)j, (double)k, entityIn.rotationYaw, 0.0F);
            entityIn.motionX = entityIn.motionY = entityIn.motionZ = 0.0D;
        }
    }

    @Override
    public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
    {
        int i = 128;
        double d0 = -1.0D;
        int j = MathHelper.floor_double(entityIn.posX);
        int k = MathHelper.floor_double(entityIn.posZ);
        boolean flag = true;
        BlockPos blockpos = BlockPos.ORIGIN;
        long l = ChunkCoordIntPair.chunkXZ2Int(j, k);

        if (this.destinationCoordinateCache.containsItem(l))
        {
            TeleporterBedrockium.PortalPosition teleporter$portalposition = (TeleporterBedrockium.PortalPosition)this.destinationCoordinateCache.getValueByKey(l);
            d0 = 0.0D;
            blockpos = teleporter$portalposition;
            teleporter$portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
            flag = false;
        }
        else
        {
            BlockPos blockpos3 = new BlockPos(entityIn);

            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();

                        if (this.worldServerInstance.getBlockState(blockpos1).getBlock() == BedrockiumBlocks.bedrockiumPortal)
                        {
                            while (this.worldServerInstance.getBlockState(blockpos2 = blockpos1.down()).getBlock() == BedrockiumBlocks.bedrockiumPortal)
                            {
                                blockpos1 = blockpos2;
                            }

                            double d1 = blockpos1.distanceSq(blockpos3);

                            if (d0 < 0.0D || d1 < d0)
                            {
                                d0 = d1;
                                blockpos = blockpos1;
                            }
                        }
                    }
                }
            }
        }

        if (d0 >= 0.0D)
        {
            if (flag)
            {
                this.destinationCoordinateCache.add(l, new TeleporterBedrockium.PortalPosition(blockpos, this.worldServerInstance.getTotalWorldTime()));
                this.destinationCoordinateKeys.add(Long.valueOf(l));
            }

            double d5 = (double)blockpos.getX() + 0.5D;
            double d6 = (double)blockpos.getY() + 0.5D;
            double d7 = (double)blockpos.getZ() + 0.5D;
            BlockPattern.PatternHelper blockpattern$patternhelper = BedrockiumBlocks.bedrockiumPortal.func_181089_f(this.worldServerInstance, blockpos);
            boolean flag1 = blockpattern$patternhelper.getFinger().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE;
            double d2 = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? (double)blockpattern$patternhelper.func_181117_a().getZ() : (double)blockpattern$patternhelper.func_181117_a().getX();
            d6 = (double)(blockpattern$patternhelper.func_181117_a().getY() + 1) - entityIn.func_181014_aG().yCoord * (double)blockpattern$patternhelper.func_181119_e();

            if (flag1)
            {
                ++d2;
            }

            if (blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X)
            {
                d7 = d2 + (1.0D - entityIn.func_181014_aG().xCoord) * (double)blockpattern$patternhelper.func_181118_d() * (double)blockpattern$patternhelper.getFinger().rotateY().getAxisDirection().getOffset();
            }
            else
            {
                d5 = d2 + (1.0D - entityIn.func_181014_aG().xCoord) * (double)blockpattern$patternhelper.func_181118_d() * (double)blockpattern$patternhelper.getFinger().rotateY().getAxisDirection().getOffset();
            }

            float f = 0.0F;
            float f1 = 0.0F;
            float f2 = 0.0F;
            float f3 = 0.0F;

            if (blockpattern$patternhelper.getFinger().getOpposite() == entityIn.func_181012_aH())
            {
                f = 1.0F;
                f1 = 1.0F;
            }
            else if (blockpattern$patternhelper.getFinger().getOpposite() == entityIn.func_181012_aH().getOpposite())
            {
                f = -1.0F;
                f1 = -1.0F;
            }
            else if (blockpattern$patternhelper.getFinger().getOpposite() == entityIn.func_181012_aH().rotateY())
            {
                f2 = 1.0F;
                f3 = -1.0F;
            }
            else
            {
                f2 = -1.0F;
                f3 = 1.0F;
            }

            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)(entityIn.func_181012_aH().getOpposite().getHorizontalIndex() * 90) + (float)(blockpattern$patternhelper.getFinger().getHorizontalIndex() * 90);
            entityIn.setLocationAndAngles(d5, d6, d7, entityIn.rotationYaw, entityIn.rotationPitch);
            return true;
        }
        else
        {
            return false;
        }
    }

    @Override
    public boolean makePortal(Entity entity)
    {
        int i = 16;
        double d0 = -1.0D;
        int j = MathHelper.floor_double(entity.posX);
        int k = MathHelper.floor_double(entity.posY);
        int l = MathHelper.floor_double(entity.posZ);
        int i1 = j;
        int j1 = k;
        int k1 = l;
        int l1 = 0;
        int i2 = this.random.nextInt(4);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

        for (int j2 = j - i; j2 <= j + i; ++j2)
        {
            double d1 = (double)j2 + 0.5D - entity.posX;

            for (int l2 = l - i; l2 <= l + i; ++l2)
            {
                double d2 = (double)l2 + 0.5D - entity.posZ;
                label142:

                for (int j3 = this.worldServerInstance.getActualHeight() - 1; j3 >= 0; --j3)
                {
                    if (this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.set(j2, j3, l2)))
                    {
                        while (j3 > 0 && this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.set(j2, j3 - 1, l2)))
                        {
                            --j3;
                        }

                        for (int k3 = i2; k3 < i2 + 4; ++k3)
                        {
                            int l3 = k3 % 2;
                            int i4 = 1 - l3;

                            if (k3 % 4 >= 2)
                            {
                                l3 = -l3;
                                i4 = -i4;
                            }

                            for (int j4 = 0; j4 < 3; ++j4)
                            {
                                for (int k4 = 0; k4 < 4; ++k4)
                                {
                                    for (int l4 = -1; l4 < 4; ++l4)
                                    {
                                        int i5 = j2 + (k4 - 1) * l3 + j4 * i4;
                                        int j5 = j3 + l4;
                                        int k5 = l2 + (k4 - 1) * i4 - j4 * l3;
                                        blockpos$mutableblockpos.set(i5, j5, k5);

                                        if (l4 < 0 && !this.worldServerInstance.getBlockState(blockpos$mutableblockpos).getBlock().getMaterial().isSolid() || l4 >= 0 && !this.worldServerInstance.isAirBlock(blockpos$mutableblockpos))
                                        {
                                            continue label142;
                                        }
                                    }
                                }
                            }

                            double d5 = (double)j3 + 0.5D - entity.posY;
                            double d7 = d1 * d1 + d5 * d5 + d2 * d2;

                            if (d0 < 0.0D || d7 < d0)
                            {
                                d0 = d7;
                                i1 = j2;
                                j1 = j3;
                                k1 = l2;
                                l1 = k3 % 4;
                            }
                        }
                    }
                }
            }
        }

        if (d0 < 0.0D)
        {
            for (int l5 = j - i; l5 <= j + i; ++l5)
            {
                double d3 = (double)l5 + 0.5D - entity.posX;

                for (int j6 = l - i; j6 <= l + i; ++j6)
                {
                    double d4 = (double)j6 + 0.5D - entity.posZ;
                    label562:

                    for (int i7 = this.worldServerInstance.getActualHeight() - 1; i7 >= 0; --i7)
                    {
                        if (this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.set(l5, i7, j6)))
                        {
                            while (i7 > 0 && this.worldServerInstance.isAirBlock(blockpos$mutableblockpos.set(l5, i7 - 1, j6)))
                            {
                                --i7;
                            }

                            for (int k7 = i2; k7 < i2 + 2; ++k7)
                            {
                                int j8 = k7 % 2;
                                int j9 = 1 - j8;

                                for (int j10 = 0; j10 < 4; ++j10)
                                {
                                    for (int j11 = -1; j11 < 4; ++j11)
                                    {
                                        int j12 = l5 + (j10 - 1) * j8;
                                        int i13 = i7 + j11;
                                        int j13 = j6 + (j10 - 1) * j9;
                                        blockpos$mutableblockpos.set(j12, i13, j13);

                                        if (j11 < 0 && !this.worldServerInstance.getBlockState(blockpos$mutableblockpos).getBlock().getMaterial().isSolid() || j11 >= 0 && !this.worldServerInstance.isAirBlock(blockpos$mutableblockpos))
                                        {
                                            continue label562;
                                        }
                                    }
                                }

                                double d6 = (double)i7 + 0.5D - entity.posY;
                                double d8 = d3 * d3 + d6 * d6 + d4 * d4;

                                if (d0 < 0.0D || d8 < d0)
                                {
                                    d0 = d8;
                                    i1 = l5;
                                    j1 = i7;
                                    k1 = j6;
                                    l1 = k7 % 2;
                                }
                            }
                        }
                    }
                }
            }
        }

        int i6 = i1;
        int k2 = j1;
        int k6 = k1;
        int l6 = l1 % 2;
        int i3 = 1 - l6;

        if (l1 % 4 >= 2)
        {
            l6 = -l6;
            i3 = -i3;
        }

        if (d0 < 0.0D)
        {
            j1 = MathHelper.clamp_int(j1, 70, this.worldServerInstance.getActualHeight() - 10);
            k2 = j1;

            for (int j7 = -1; j7 <= 1; ++j7)
            {
                for (int l7 = 1; l7 < 3; ++l7)
                {
                    for (int k8 = -1; k8 < 3; ++k8)
                    {
                        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 ? BedrockiumBlocks.slimyBedrockium.getDefaultState() : Blocks.air.getDefaultState());
                    }
                }
            }
        }

        IBlockState iblockstate = BedrockiumBlocks.bedrockiumPortal.getDefaultState().withProperty(BlockPortal.AXIS, l6 != 0 ? EnumFacing.Axis.X : EnumFacing.Axis.Z);

        for (int i8 = 0; i8 < 4; ++i8)
        {
            for (int l8 = 0; l8 < 4; ++l8)
            {
                for (int l9 = -1; l9 < 4; ++l9)
                {
                    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 ? BedrockiumBlocks.slimyBedrockium.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;
    }

    /**
     * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a
     * WorldServer.getTotalWorldTime() value.
     */
    @Override
    public void removeStalePortalLocations(long worldTime)
    {
        if (worldTime % 100L == 0L)
        {
            Iterator<Long> iterator = this.destinationCoordinateKeys.iterator();
            long i = worldTime - 300L;

            while (iterator.hasNext())
            {
                Long olong = (Long)iterator.next();
                TeleporterBedrockium.PortalPosition teleporter$portalposition = (TeleporterBedrockium.PortalPosition)this.destinationCoordinateCache.getValueByKey(olong.longValue());

                if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i)
                {
                    iterator.remove();
                    this.destinationCoordinateCache.remove(olong.longValue());
                }
            }
        }
    }

    public class PortalPosition extends BlockPos
    {
        /** The worldtime at which this PortalPosition was last verified */
        public long lastUpdateTime;

        public PortalPosition(BlockPos pos, long lastUpdate)
        {
            super(pos.getX(), pos.getY(), pos.getZ());
            this.lastUpdateTime = lastUpdate;
        }
    }
}

 

 

And this is my Portal Block class:

package tschipp.bedrockium.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockPortal;
import net.minecraft.block.material.MapColor;
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.BlockWorldState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMonsterPlacer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import tschipp.bedrockium.BedrockiumMod;
import tschipp.bedrockium.dimension.TeleporterBedrockium;

import com.google.common.cache.LoadingCache;

public class BedrockiumPortal extends BlockPortal {

public static final PropertyEnum<EnumFacing.Axis> AXIS = PropertyEnum.<EnumFacing.Axis>create("axis", EnumFacing.Axis.class, new EnumFacing.Axis[] {EnumFacing.Axis.X, EnumFacing.Axis.Z});

public BedrockiumPortal() {
	super();
	this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.X));
	this.setTickRandomly(true);
	this.setUnlocalizedName("bedrockiumPortal");
	this.setStepSound(soundTypeGlass);
	this.setBlockUnbreakable();
	this.setResistance(5000F);
}

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity) {
	if(entity.ridingEntity == null && entity.riddenByEntity == null && entity instanceof EntityPlayerMP) {
		EntityPlayerMP player = (EntityPlayerMP) entity;
		FMLCommonHandler.instance().getMinecraftServerInstance();
		MinecraftServer server = MinecraftServer.getServer();

		if(player.timeUntilPortal > 0) {
			player.timeUntilPortal = 10;
		} else if(player.dimension != BedrockiumMod.dimensionIdBedrockium) {
			player.timeUntilPortal = 10;
			player.mcServer.getConfigurationManager().transferPlayerToDimension(player, BedrockiumMod.dimensionIdBedrockium, new TeleporterBedrockium(server.worldServerForDimension(BedrockiumMod.dimensionIdBedrockium)));


		}else {
			player.timeUntilPortal = 10;
			player.mcServer.getConfigurationManager().transferPlayerToDimension(player, 0, new TeleporterBedrockium(server.worldServerForDimension(0)));
		}
	}

}

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {

	if(player instanceof EntityPlayerMP) {
		((EntityPlayerMP)player).mcServer.getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) player, BedrockiumMod.dimensionIdBedrockium, new TeleporterBedrockium(MinecraftServer.getServer().worldServerForDimension(BedrockiumMod.dimensionIdBedrockium)));

	}
	return true;
}


@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
	super.updateTick(worldIn, pos, state, rand);

	if (worldIn.provider.isSurfaceWorld() && worldIn.getGameRules().getBoolean("doMobSpawning") && rand.nextInt(2000) < worldIn.getDifficulty().getDifficultyId())
	{
		int i = pos.getY();
		BlockPos blockpos;

		for (blockpos = pos; !World.doesBlockHaveSolidTopSurface(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
		{
			;
		}

		if (i > 0 && !worldIn.getBlockState(blockpos.up()).getBlock().isNormalCube())
		{
			Entity entity = ItemMonsterPlacer.spawnCreature(worldIn, 58, (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 1.1D, (double)blockpos.getZ() + 0.5D);

			if (entity != null)
			{
				entity.timeUntilPortal = entity.getPortalCooldown();
			}
		}
	}
}



@Override
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
	EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)worldIn.getBlockState(pos).getValue(AXIS);
	float f = 0.125F;
	float f1 = 0.125F;

	if (enumfacing$axis == EnumFacing.Axis.X)
	{
		f = 0.5F;
	}

	if (enumfacing$axis == EnumFacing.Axis.Z)
	{
		f1 = 0.5F;
	}

	this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1);
}


public static int getMetaForAxis(EnumFacing.Axis axis)
{
	return axis == EnumFacing.Axis.X ? 1 : (axis == EnumFacing.Axis.Z ? 2 : 0);
}

@Override
public boolean isFullCube()
{
	return false;
}


public boolean func_176548_d(World worldIn, BlockPos p_176548_2_)
{
	BedrockiumPortal.Size blockportal$size = new BedrockiumPortal.Size(worldIn, p_176548_2_, EnumFacing.Axis.X);

	if (blockportal$size.func_150860_b() && blockportal$size.field_150864_e == 0)
	{
		blockportal$size.func_150859_c();
		return true;
	}
	else
	{
		BedrockiumPortal.Size blockportal$size1 = new BedrockiumPortal.Size(worldIn, p_176548_2_, EnumFacing.Axis.Z);

		if (blockportal$size1.func_150860_b() && blockportal$size1.field_150864_e == 0)
		{
			blockportal$size1.func_150859_c();
			return true;
		}
		else
		{
			return false;
		}
	}
}

/**
 * Called when a neighboring block changes.
 */
@Override
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
	EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)state.getValue(AXIS);

	if (enumfacing$axis == EnumFacing.Axis.X)
	{
		BedrockiumPortal.Size blockportal$size = new BedrockiumPortal.Size(worldIn, pos, EnumFacing.Axis.X);

		if (!blockportal$size.func_150860_b() || blockportal$size.field_150864_e < blockportal$size.field_150868_h * blockportal$size.field_150862_g)
		{
			worldIn.setBlockState(pos, Blocks.air.getDefaultState());
		}
	}
	else if (enumfacing$axis == EnumFacing.Axis.Z)
	{
		BedrockiumPortal.Size blockportal$size1 = new BedrockiumPortal.Size(worldIn, pos, EnumFacing.Axis.Z);

		if (!blockportal$size1.func_150860_b() || blockportal$size1.field_150864_e < blockportal$size1.field_150868_h * blockportal$size1.field_150862_g)
		{
			worldIn.setBlockState(pos, Blocks.air.getDefaultState());
		}
	}
}

@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
	EnumFacing.Axis enumfacing$axis = null;
	IBlockState iblockstate = worldIn.getBlockState(pos);

	if (worldIn.getBlockState(pos).getBlock() == this)
	{
		enumfacing$axis = (EnumFacing.Axis)iblockstate.getValue(AXIS);

		if (enumfacing$axis == null)
		{
			return false;
		}

		if (enumfacing$axis == EnumFacing.Axis.Z && side != EnumFacing.EAST && side != EnumFacing.WEST)
		{
			return false;
		}

		if (enumfacing$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 || enumfacing$axis == EnumFacing.Axis.X;
	boolean flag5 = flag2 || flag3 || enumfacing$axis == EnumFacing.Axis.Z;
	return flag4 && side == EnumFacing.WEST ? true : (flag4 && side == EnumFacing.EAST ? true : (flag5 && side == EnumFacing.NORTH ? true : flag5 && side == EnumFacing.SOUTH));
}

/**
 * Returns the quantity of items to drop on block destruction.
 */
@Override
public int quantityDropped(Random random)
{
	return 0;
}

/**
 * Called When an Entity Collided with the Block
 */


/**
 * Convert the given metadata into a BlockState for this Block
 */
@Override
public IBlockState getStateFromMeta(int meta)
{
	return this.getDefaultState().withProperty(AXIS, (meta & 3) == 2 ? EnumFacing.Axis.Z : EnumFacing.Axis.X);
}

@Override
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer()
{
	return EnumWorldBlockLayer.TRANSLUCENT;
}

@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
	if (rand.nextInt(100) == 0)
	{
		worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "portal.portal", 0.5F, rand.nextFloat() * 0.4F + 0.8F, false);
	}

	for (int i = 0; i < 4; ++i)
	{
		double d0 = (double)((float)pos.getX() + rand.nextFloat());
		double d1 = (double)((float)pos.getY() + rand.nextFloat());
		double d2 = (double)((float)pos.getZ() + rand.nextFloat());
		double d3 = ((double)rand.nextFloat() - 0.5D) * 0.5D;
		double d4 = ((double)rand.nextFloat() - 0.5D) * 0.5D;
		double d5 = ((double)rand.nextFloat() - 0.5D) * 0.5D;
		int j = rand.nextInt(2) * 2 - 1;

		if (worldIn.getBlockState(pos.west()).getBlock() != this && worldIn.getBlockState(pos.east()).getBlock() != this)
		{
			d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j;
			d3 = (double)(rand.nextFloat() * 2.0F * (float)j);
		}
		else
		{
			d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)j;
			d5 = (double)(rand.nextFloat() * 2.0F * (float)j);
		}

		worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]);
	}
}

@Override
@SideOnly(Side.CLIENT)
public Item getItem(World worldIn, BlockPos pos)
{
	return null;
}

/**
 * Convert the BlockState into the correct metadata value
 */
@Override
public int getMetaFromState(IBlockState state)
{
	return getMetaForAxis((EnumFacing.Axis)state.getValue(AXIS));
}

@Override
protected BlockState createBlockState()
{
	return new BlockState(this, new IProperty[] {AXIS});
}


public BlockPattern.PatternHelper func_181089_f(World world, BlockPos pos)
{
	EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Z;
	BedrockiumPortal.Size blockportal$size = new BedrockiumPortal.Size(world, pos, EnumFacing.Axis.X);
	LoadingCache<BlockPos, BlockWorldState> loadingcache = BlockPattern.func_181627_a(world, true);

	if (!blockportal$size.func_150860_b())
	{
		enumfacing$axis = EnumFacing.Axis.X;
		blockportal$size = new BedrockiumPortal.Size(world, pos, EnumFacing.Axis.Z);
	}

	if (!blockportal$size.func_150860_b())
	{
		return new BlockPattern.PatternHelper(pos, EnumFacing.NORTH, EnumFacing.UP, loadingcache, 1, 1, 1);
	}
	else
	{
		int[] aint = new int[EnumFacing.AxisDirection.values().length];
		EnumFacing enumfacing = blockportal$size.field_150866_c.rotateYCCW();
		BlockPos blockpos = blockportal$size.field_150861_f.up(blockportal$size.func_181100_a() - 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.field_150866_c, blockportal$size.func_181101_b() - 1), EnumFacing.func_181076_a(enumfacing$axisdirection, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.func_181101_b(), blockportal$size.func_181100_a(), 1);

			for (int i = 0; i < blockportal$size.func_181101_b(); ++i)
			{
				for (int j = 0; j < blockportal$size.func_181100_a(); ++j)
				{
					BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, 1);

					if (blockworldstate.getBlockState() != null && blockworldstate.getBlockState().getBlock().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.field_150866_c, blockportal$size.func_181101_b() - 1), EnumFacing.func_181076_a(enumfacing$axisdirection1, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.func_181101_b(), blockportal$size.func_181100_a(), 1);
	}
}



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 pos, EnumFacing.Axis axis)
	{
		this.world = worldIn;
		this.axis = axis;

		if (axis == 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 blockpos = pos; pos.getY() > blockpos.getY() - 21 && pos.getY() > 0 && this.func_150857_a(worldIn.getBlockState(pos.down()).getBlock()); pos = pos.down())
		{
			;
		}

		int i = this.func_180120_a(pos, this.field_150863_d) - 1;

		if (i >= 0)
		{
			this.field_150861_f = pos.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 p_180120_1_, EnumFacing p_180120_2_)
	{
		int i;

		for (i = 0; i < 22; ++i)
		{
			BlockPos blockpos = p_180120_1_.offset(p_180120_2_, i);

			if (!this.func_150857_a(this.world.getBlockState(blockpos).getBlock()) || this.world.getBlockState(blockpos.down()).getBlock() != BedrockiumBlocks.slimyBedrockium)
			{
				break;
			}
		}

		Block block = this.world.getBlockState(p_180120_1_.offset(p_180120_2_, i)).getBlock();
		return block == BedrockiumBlocks.slimyBedrockium ? i : 0;
	}

	public int func_181100_a()
	{
		return this.field_150862_g;
	}

	public int func_181101_b()
	{
		return this.field_150868_h;
	}

	protected int func_150858_a()
	{
		label24:

			for (this.field_150862_g = 0; this.field_150862_g < 21; ++this.field_150862_g)
			{
				for (int 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 label24;
					}

					if (block == BedrockiumBlocks.bedrockiumPortal)
					{
						++this.field_150864_e;
					}

					if (i == 0)
					{
						block = this.world.getBlockState(blockpos.offset(this.field_150863_d)).getBlock();

						if (block != BedrockiumBlocks.slimyBedrockium)
						{
							break label24;
						}
					}
					else if (i == this.field_150868_h - 1)
					{
						block = this.world.getBlockState(blockpos.offset(this.field_150866_c)).getBlock();

						if (block != BedrockiumBlocks.slimyBedrockium)
						{
							break label24;
						}
					}
				}
			}

	for (int j = 0; j < this.field_150868_h; ++j)
	{
		if (this.world.getBlockState(this.field_150861_f.offset(this.field_150866_c, j).up(this.field_150862_g)).getBlock() != BedrockiumBlocks.slimyBedrockium)
		{
			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 == BedrockiumBlocks.bedrockiumPortal;
	}

	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), BedrockiumBlocks.bedrockiumPortal.getDefaultState().withProperty(BedrockiumPortal.AXIS, this.axis), 2);
			}
		}
	}
}

}

 

Also, the portal doesn't get created when lit with flint and steel... ???

Any help would be very much apprechiated

Posted

I think that this

this.worldServerInstance.provider.getDimensionId() != 1

should be changed to this

this.worldServerInstance.provider.getDimensionId() != BedrockiumMod.dimensionIdBedrockium

Also is the dimension correctly registered?

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

I tried that, it doesn't make a difference.

The Dimension works, i have visited it already (using McEdit).

I register it like this in the init method of my main mod class:

	DimensionManager.registerProviderType(dimensionIdBedrockium, WorldProviderBedrockium.class, false);
	DimensionManager.registerDimension(dimensionIdBedrockium, dimensionIdBedrockium);

Posted

Mmm, you can debug to see if the teleporter code is actually called and what it does. Also try changing the onEntityCollide method to this

public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
    {
        if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn instanceof EntityPlayerMP)
        {
        	entityIn.setPortal(pos);
        	EntityPlayerMP thePlayer = (EntityPlayerMP)entityIn;
        	if (thePlayer.timeUntilPortal > 0)
            {
                thePlayer.timeUntilPortal = 10;
            }
            else if (thePlayer.dimension != BedrockiumMod.dimensionIdBedrockium)
            {
                thePlayer.timeUntilPortal = 10;
                thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, BedrockiumMod.dimensionIdBedrockium, new TeleporterCorrupted(thePlayer.mcServer.worldServerForDimension(BedrockiumMod.dimensionIdBedrockium)));
            }
            
            else if (thePlayer.dimension == BedrockiumMod.dimensionIdBedrockium)
            {
                thePlayer.timeUntilPortal = 10;
                thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, new TeleporterCorrupted(thePlayer.mcServer.worldServerForDimension(0)));
            }
        }
    }

 

I'm using in my mod and it works fine (notice that something could be different as i take the code from 1.10)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

That could be related to the Teleporter class, i suggest to run the game in debug mode, add a breakpoint in the teleporter class and see what the game does so you can understand why it takes you back to the Nether

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

I did that, but I can't find anything abnormal. In fact, I can't even find anything in the teleporter class that says to what dimension it should teleport the player anyway...  :o

  • 2 weeks later...
Posted

I just would like to add that it sort of works now, but the dimension doesn't load when entering the first time. I need to reconnect for it to start loading. Same with when I go back from the dimension.

Posted

I seem to be getting a null pointer:

java.util.concurrent.ExecutionException: net.minecraft.util.ReportedException: Colliding entity with block
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_65]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_65]
at net.minecraft.util.Util.runTask(Util.java:23) [util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:681) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:159) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_65]
Caused by: net.minecraft.util.ReportedException: Colliding entity with block
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:417) ~[EntityPlayerMP.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:347) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:36) ~[C03PacketPlayer.class:?]
at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:177) ~[C03PacketPlayer$C06PacketPlayerPosLook.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_65]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_65]
at net.minecraft.util.Util.runTask(Util.java:22) ~[util.class:?]
... 5 more
Caused by: java.lang.NullPointerException
at tschipp.bedrockium.dimension.TeleporterBedrockium.placeInExistingPortal(TeleporterBedrockium.java:158) ~[TeleporterBedrockium.class:?]
at tschipp.bedrockium.dimension.TeleporterBedrockium.placeInPortal(TeleporterBedrockium.java:44) ~[TeleporterBedrockium.class:?]
at net.minecraft.server.management.ServerConfigurationManager.transferEntityToWorld(ServerConfigurationManager.java:663) ~[serverConfigurationManager.class:?]
at net.minecraft.server.management.ServerConfigurationManager.transferPlayerToDimension(ServerConfigurationManager.java:571) ~[serverConfigurationManager.class:?]
at tschipp.bedrockium.blocks.BedrockiumPortal.onEntityCollidedWithBlock(BedrockiumPortal.java:61) ~[bedrockiumPortal.class:?]
at net.minecraft.entity.Entity.doBlockCollisions(Entity.java:917) ~[Entity.class:?]
at net.minecraft.entity.Entity.moveEntity(Entity.java:843) ~[Entity.class:?]
at net.minecraft.entity.EntityLivingBase.moveEntityWithHeading(EntityLivingBase.java:1644) ~[EntityLivingBase.class:?]
at net.minecraft.entity.player.EntityPlayer.moveEntityWithHeading(EntityPlayer.java:1868) ~[EntityPlayer.class:?]
at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2022) ~[EntityLivingBase.class:?]
at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:613) ~[EntityPlayer.class:?]
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1824) ~[EntityLivingBase.class:?]
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:323) ~[EntityPlayer.class:?]
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:366) ~[EntityPlayerMP.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:347) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:36) ~[C03PacketPlayer.class:?]
at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:177) ~[C03PacketPlayer$C06PacketPlayerPosLook.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_65]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_65]
at net.minecraft.util.Util.runTask(Util.java:22) ~[util.class:?]
... 5 more[/Code]

 

That is here in my Teleporter Class:

[Code]@Override
    public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
    {
        int i = 128;
        double d0 = -1.0D;
        int j = MathHelper.floor_double(entityIn.posX);
        int k = MathHelper.floor_double(entityIn.posZ);
        boolean flag = true;
        BlockPos blockpos = BlockPos.ORIGIN;
        long l = ChunkCoordIntPair.chunkXZ2Int(j, k);

        if (this.destinationCoordinateCache.containsItem(l))
        {
            TeleporterBedrockium.PortalPosition teleporter$portalposition = (TeleporterBedrockium.PortalPosition)this.destinationCoordinateCache.getValueByKey(l);
            d0 = 0.0D;
            blockpos = teleporter$portalposition;
            teleporter$portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
            flag = false;
        }
        else
        {
            BlockPos blockpos3 = new BlockPos(entityIn);

            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();

                        if (this.worldServerInstance.getBlockState(blockpos1).getBlock() == BedrockiumBlocks.bedrockiumPortal)
                        {
                            while (this.worldServerInstance.getBlockState(blockpos2 = blockpos1.down()).getBlock() == BedrockiumBlocks.bedrockiumPortal)
                            {
                                blockpos1 = blockpos2;
                            }

                            double d1 = blockpos1.distanceSq(blockpos3);

                            if (d0 < 0.0D || d1 < d0)
                            {
                                d0 = d1;
                                blockpos = blockpos1;
                            }
                        }
                    }
                }
            }
        }

        if (d0 >= 0.0D)
        {
            if (flag)
            {
                this.destinationCoordinateCache.add(l, new TeleporterBedrockium.PortalPosition(blockpos, this.worldServerInstance.getTotalWorldTime()));
                this.destinationCoordinateKeys.add(Long.valueOf(l));
            }

            double d5 = (double)blockpos.getX() + 0.5D;
            double d6 = (double)blockpos.getY() + 0.5D;
            double d7 = (double)blockpos.getZ() + 0.5D;
            BlockPattern.PatternHelper blockpattern$patternhelper = BedrockiumBlocks.bedrockiumPortal.func_181089_f(this.worldServerInstance, blockpos);
            boolean flag1 = blockpattern$patternhelper.getFinger().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE;
            double d2 = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? (double)blockpattern$patternhelper.func_181117_a().getZ() : (double)blockpattern$patternhelper.func_181117_a().getX();
            d6 = (double)(blockpattern$patternhelper.func_181117_a().getY() + 1) - entityIn.func_181014_aG().yCoord * (double)blockpattern$patternhelper.func_181119_e();
            //Null Pointer here!
            if (flag1)
            {
                ++d2;
            }

            if (blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X)
            {
                d7 = d2 + (1.0D - entityIn.func_181014_aG().xCoord) * (double)blockpattern$patternhelper.func_181118_d() * (double)blockpattern$patternhelper.getFinger().rotateY().getAxisDirection().getOffset();
            }
            else
            {
                d5 = d2 + (1.0D - entityIn.func_181014_aG().xCoord) * (double)blockpattern$patternhelper.func_181118_d() * (double)blockpattern$patternhelper.getFinger().rotateY().getAxisDirection().getOffset();
            }

            float f = 0.0F;
            float f1 = 0.0F;
            float f2 = 0.0F;
            float f3 = 0.0F;

            if (blockpattern$patternhelper.getFinger().getOpposite() == entityIn.func_181012_aH())
            {
                f = 1.0F;
                f1 = 1.0F;
            }
            else if (blockpattern$patternhelper.getFinger().getOpposite() == entityIn.func_181012_aH().getOpposite())
            {
                f = -1.0F;
                f1 = -1.0F;
            }
            else if (blockpattern$patternhelper.getFinger().getOpposite() == entityIn.func_181012_aH().rotateY())
            {
                f2 = 1.0F;
                f3 = -1.0F;
            }
            else
            {
                f2 = -1.0F;
                f3 = 1.0F;
            }

            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)(entityIn.func_181012_aH().getOpposite().getHorizontalIndex() * 90) + (float)(blockpattern$patternhelper.getFinger().getHorizontalIndex() * 90);
            entityIn.setLocationAndAngles(d5, d6, d7, entityIn.rotationYaw, entityIn.rotationPitch);
            return true;
        }
        else
        {
            return false;
        }
    }[/Code]

Posted

...and which line of that stupidly large method is line 158?

Look at that line.  Find the thing that is null. Figure out why.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

So it errors on

d6 = (double)(blockpattern$patternhelper.func_181117_a().getY() + 1) - entityIn.func_181014_aG().yCoord * (double)blockpattern$patternhelper.func_181119_e();

?

 

And I mean that line exactly.  Because if so, there's literally nothing there that could be null: every object referenced on that line has already been referenced on a previous line.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

So it errors on

d6 = (double)(blockpattern$patternhelper.func_181117_a().getY() + 1) - entityIn.func_181014_aG().yCoord * (double)blockpattern$patternhelper.func_181119_e();

?

 

And I mean that line exactly.  Because if so, there's literally nothing there that could be null: every object referenced on that line has already been referenced on a previous line.

I might've overlooked, but I think
entityIn.func_181014_aG()

isn't called before that line, making it the possible issue.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

I might've overlooked, but I think

entityIn.func_181014_aG()

isn't called before that line, making it the possible issue.

 

Ah, yes, you are correct.  I had assumed that if the entity wasn't null, then that method was probably safe.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

So it errors on

d6 = (double)(blockpattern$patternhelper.func_181117_a().getY() + 1) - entityIn.func_181014_aG().yCoord * (double)blockpattern$patternhelper.func_181119_e();

?

 

And I mean that line exactly.  Because if so, there's literally nothing there that could be null: every object referenced on that line has already been referenced on a previous line.

I might've overlooked, but I think
entityIn.func_181014_aG()

isn't called before that line, making it the possible issue.

 

You were right, entityIn.func_181014_aG() returns the Vec3 field_181017_ao which is actually null at the time... What can I do? I have no Idea what that field corresponds to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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