Search in sources :

Example 76 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityPainter method onServerTick.

public static void onServerTick(World world) {
    Set<BlockVec3> loaded = getLoadedTiles(world);
    int dimID = GCCoreUtil.getDimensionID(world);
    List<EntityPlayerMP> allPlayers = PlayerUtil.getPlayersOnline();
    for (final EntityPlayerMP player : allPlayers) {
        if (player.dimension != dimID)
            continue;
        BlockVec3 playerPos = new BlockVec3(player);
        BlockVec3 nearest = null;
        int shortestDistance = RANGE_DEFAULT * RANGE_DEFAULT;
        for (final BlockVec3 bv : loaded) {
            int distance = bv.distanceSquared(playerPos);
            if (distance < shortestDistance) {
                shortestDistance = distance;
                nearest = bv;
            }
        }
        if (nearest != null) {
            TileEntity te = nearest.getTileEntity(world);
            if (te instanceof TileEntityPainter) {
                ((TileEntityPainter) te).dominantToPlayer(player);
            }
        }
    // TODO
    // Make sure this works in a way so that the nearest Painter quickly takes priority, but there is no race condition...
    // Also maybe some hysteresis?
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 77 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class MapUtil method setupColours.

private static void setupColours() {
    // ocean = Ocean(0) colour(112) "Ocean"
    MapUtil.biomeColours.add(new BlockVec3(Material.water.getMaterialMapColor().colorValue, 0, 0));
    // plains = Plains(1) colour(9286496) "Plains"
    MapUtil.biomeColours.add(new BlockVec3(0x497436, 0, 0));
    // desert = Desert(2) colour(16421912) "Desert"
    MapUtil.biomeColours.add(new BlockVec3(0xd4cd98, Material.cactus.getMaterialMapColor().colorValue, 3));
    // extremeHills = Hills(3, false) colour(6316128) "Extreme Hills"
    MapUtil.biomeColours.add(new BlockVec3(0x4d654c, Material.rock.getMaterialMapColor().colorValue, 15));
    // forest = Forest(4, 0) colour(353825) "Forest"
    MapUtil.biomeColours.add(new BlockVec3(0x3c7521, 0x295416, 45));
    // taiga = Taiga(5, 0) colour(747097) "Taiga"
    MapUtil.biomeColours.add(new BlockVec3(0x627e61, 0x172a17, 18));
    // swampland = Swamp(6) colour(522674) "Swampland"
    MapUtil.biomeColours.add(new BlockVec3(0x43541b, 0x111309, 25));
    // river = River(7) colour(255) "River"
    MapUtil.biomeColours.add(new BlockVec3(0x497436, 0, 0));
    MapUtil.biomeColours.add(new BlockVec3(0, 0, 0));
    MapUtil.biomeColours.add(new BlockVec3(0, 0, 0));
    // frozenOcean = Ocean(10) colour(9474208) "FrozenOcean"
    MapUtil.biomeColours.add(new BlockVec3(Material.ice.getMaterialMapColor().colorValue, 0, 0));
    // frozenRiver = River(11) colour(10526975) "FrozenRiver"
    MapUtil.biomeColours.add(new BlockVec3(Material.ice.getMaterialMapColor().colorValue, 0, 0));
    // icePlains = Snow(12, false) colour(16777215) "Ice Plains"
    MapUtil.biomeColours.add(new BlockVec3(Material.snow.getMaterialMapColor().colorValue, 0x497436, 3));
    // iceMountains = Snow(13, false) colour(10526880) "Ice Mountains"
    MapUtil.biomeColours.add(new BlockVec3(Material.snow.getMaterialMapColor().colorValue, Material.ice.getMaterialMapColor().colorValue, 5));
    // mushroomIsland = MushroomIsland(14) colour(16711935) "MushroomIsland"
    MapUtil.biomeColours.add(new BlockVec3(0x63565f, 0x7c1414, 10));
    // mushroomIslandShore = MushroomIsland(15) colour(10486015) "MushroomIslandShore"
    MapUtil.biomeColours.add(new BlockVec3(0x6a6066, 0, 0));
    // beach = Beach(16) colour(16440917) "Beach"
    MapUtil.biomeColours.add(new BlockVec3(Material.sand.getMaterialMapColor().colorValue, 0, 0));
    // desertHills = Desert(17) colour(13786898) "DesertHills"
    MapUtil.biomeColours.add(new BlockVec3(0xd4cd98, 0, 0));
    // forestHills = Forest(18, 0) colour(2250012) "ForestHills"
    MapUtil.biomeColours.add(new BlockVec3(0x3c7521, 0x295416, 35));
    // taigaHills = Taiga(19, 0) colour(1456435) "TaigaHills"
    MapUtil.biomeColours.add(new BlockVec3(0x627e61, 0x172a17, 14));
    // extremeHillsEdge = Hills(20, true) colour(7501978) "Extreme Hills Edge"
    MapUtil.biomeColours.add(new BlockVec3(0x4d654c, 0x497436, 50));
    // jungle = Jungle(21, false) colour(5470985) "Jungle"
    MapUtil.biomeColours.add(new BlockVec3(0x176c03, 0x0f4502, 25));
    // jungleHills = Jungle(22, false) colour(2900485) "JungleHills"
    MapUtil.biomeColours.add(new BlockVec3(0x176c03, 0x0f4502, 25));
    // jungleEdge = Jungle(23, true) colour(6458135) "JungleEdge"
    MapUtil.biomeColours.add(new BlockVec3(0x176c03, 0x0f4502, 25));
    // deepOcean = Ocean(24) colour(48) "Deep Ocean"
    MapUtil.biomeColours.add(new BlockVec3(0x2f2fd4, 0, 0));
    // stoneBeach = StoneBeach(25) colour(10658436) "Stone Beach"
    MapUtil.biomeColours.add(new BlockVec3(Material.rock.getMaterialMapColor().colorValue, 0, 0));
    // coldBeach = Beach(26) colour(16445632) "Cold Beach"
    MapUtil.biomeColours.add(new BlockVec3(Material.sand.getMaterialMapColor().colorValue, Material.snow.getMaterialMapColor().colorValue, 75));
    // birchForest = Forest(27, 2)) colour(3175492) "Birch Forest"
    MapUtil.biomeColours.add(new BlockVec3(0x516b36, 0x497436, 65));
    // birchForestHills = Forest(28, 2)) colour(2055986) "Birch Forest Hills"
    MapUtil.biomeColours.add(new BlockVec3(0x516b36, 0x497436, 55));
    // roofedForest = Forest(29, 3) colour(4215066) "Roofed Forest"
    MapUtil.biomeColours.add(new BlockVec3(0x9c2424, 0x1e2e18, 98));
    // coldTaiga = Taiga(30, 0) colour(3233098) "Cold Taiga"
    MapUtil.biomeColours.add(new BlockVec3(Material.snow.getMaterialMapColor().colorValue, 0x172a17, 12));
    // coldTaigaHills = Taiga(31, 0) colour(2375478) "Cold Taiga Hills"
    MapUtil.biomeColours.add(new BlockVec3(Material.snow.getMaterialMapColor().colorValue, 0x172a17, 12));
    // megaTaiga = Taiga(32, 1) colour(5858897) "Mega Taiga"
    MapUtil.biomeColours.add(new BlockVec3(0x172a17, 0x6e4e35, 12));
    // megaTaigaHills = Taiga(33, 1) colour(4542270) "Mega Taiga Hills"
    MapUtil.biomeColours.add(new BlockVec3(0x172a17, 0x6e4e35, 12));
    // extremeHillsPlus = Hills(34, true) colour(5271632) "Extreme Hills+"
    MapUtil.biomeColours.add(new BlockVec3(0x7b7978, 0x497436, 10));
    // savanna = Savanna(35) colour(12431967) "Savanna"
    MapUtil.biomeColours.add(new BlockVec3(0x565529, 0x262304, 20));
    // savannaPlateau = Savanna(36) colour(10984804) "Savanna Plateau"
    MapUtil.biomeColours.add(new BlockVec3(0x565529, 0x262304, 14));
    // mesa = Mesa(37, false, false) colour(14238997) "Mesa"
    MapUtil.biomeColours.add(new BlockVec3(0xa0521f, 0x712f23, 14));
    // mesaPlateau_F = Mesa(38, false, true) colour(11573093) "Mesa Plateau F"
    MapUtil.biomeColours.add(new BlockVec3(0xa0521f, 0x712f23, 17));
    // mesaPlateau = Mesa(39, false, false) colour(13274213) "Mesa Plateau"
    MapUtil.biomeColours.add(new BlockVec3(0xa0521f, 0x712f23, 20));
}
Also used : BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 78 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class OxygenUtil method getAdjacentFluidConnections.

public static TileEntity[] getAdjacentFluidConnections(TileEntity tile, boolean ignoreConnect) {
    TileEntity[] adjacentConnections = new TileEntity[EnumFacing.VALUES.length];
    boolean isMekLoaded = EnergyConfigHandler.isMekanismLoaded();
    BlockVec3 thisVec = new BlockVec3(tile);
    for (EnumFacing direction : EnumFacing.VALUES) {
        TileEntity tileEntity = thisVec.getTileEntityOnSide(tile.getWorld(), direction);
        if (tileEntity instanceof IFluidHandler) {
            if (ignoreConnect || !(tileEntity instanceof IConnector) || ((IConnector) tileEntity).canConnect(direction.getOpposite(), NetworkType.FLUID)) {
                adjacentConnections[direction.ordinal()] = tileEntity;
            }
        }
    // else if (isMekLoaded)
    // {
    // if (tileEntity instanceof ITubeConnection && (!(tileEntity instanceof IGasTransmitter) || TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, tileEntity)))
    // {
    // if (((ITubeConnection) tileEntity).canTubeConnect(direction))
    // {
    // adjacentConnections[direction.ordinal()] = tileEntity;
    // }
    // }
    // }
    }
    return adjacentConnections;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) IConnector(micdoodle8.mods.galacticraft.api.transmission.tile.IConnector) IFluidHandler(net.minecraftforge.fluids.IFluidHandler) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 79 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class WorldUtil method getFootprintPosition.

public static Vector3 getFootprintPosition(World world, float rotation, Vector3 startPosition, BlockVec3 playerCenter) {
    Vector3 position = startPosition.clone();
    float footprintScale = 0.375F;
    int mainPosX = position.intX();
    int mainPosY = position.intY();
    int mainPosZ = position.intZ();
    BlockPos posMain = new BlockPos(mainPosX, mainPosY, mainPosZ);
    // If the footprint is hovering over air...
    if (world.getBlockState(posMain).getBlock().isAir(world, posMain)) {
        position.x += (playerCenter.x - mainPosX);
        position.z += (playerCenter.z - mainPosZ);
        BlockPos pos1 = new BlockPos(position.intX(), position.intY(), position.intZ());
        // If the footprint is still over air....
        Block b2 = world.getBlockState(pos1).getBlock();
        if (b2 != null && b2.isAir(world, pos1)) {
            for (EnumFacing direction : EnumFacing.VALUES) {
                BlockPos offsetPos = posMain.offset(direction);
                if (direction != EnumFacing.DOWN && direction != EnumFacing.UP) {
                    if (!world.getBlockState(offsetPos).getBlock().isAir(world, offsetPos)) {
                        position.x += direction.getFrontOffsetX();
                        position.z += direction.getFrontOffsetZ();
                        break;
                    }
                }
            }
        }
    }
    mainPosX = position.intX();
    mainPosZ = position.intZ();
    double x0 = (Math.sin((45 - rotation) / Constants.RADIANS_TO_DEGREES_D) * footprintScale) + position.x;
    double x1 = (Math.sin((135 - rotation) / Constants.RADIANS_TO_DEGREES_D) * footprintScale) + position.x;
    double x2 = (Math.sin((225 - rotation) / Constants.RADIANS_TO_DEGREES_D) * footprintScale) + position.x;
    double x3 = (Math.sin((315 - rotation) / Constants.RADIANS_TO_DEGREES_D) * footprintScale) + position.x;
    double z0 = (Math.cos((45 - rotation) / Constants.RADIANS_TO_DEGREES_D) * footprintScale) + position.z;
    double z1 = (Math.cos((135 - rotation) / Constants.RADIANS_TO_DEGREES_D) * footprintScale) + position.z;
    double z2 = (Math.cos((225 - rotation) / Constants.RADIANS_TO_DEGREES_D) * footprintScale) + position.z;
    double z3 = (Math.cos((315 - rotation) / Constants.RADIANS_TO_DEGREES_D) * footprintScale) + position.z;
    double xMin = Math.min(Math.min(x0, x1), Math.min(x2, x3));
    double xMax = Math.max(Math.max(x0, x1), Math.max(x2, x3));
    double zMin = Math.min(Math.min(z0, z1), Math.min(z2, z3));
    double zMax = Math.max(Math.max(z0, z1), Math.max(z2, z3));
    if (xMin < mainPosX) {
        position.x += mainPosX - xMin;
    }
    if (xMax > mainPosX + 1) {
        position.x -= xMax - (mainPosX + 1);
    }
    if (zMin < mainPosZ) {
        position.z += mainPosZ - zMin;
    }
    if (zMax > mainPosZ + 1) {
        position.z -= zMax - (mainPosZ + 1);
    }
    return position;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) BlockPos(net.minecraft.util.BlockPos)

Example 80 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class GCPlayerHandler method updateFeet.

protected static void updateFeet(EntityPlayerMP player, double motionX, double motionZ) {
    double motionSqrd = motionX * motionX + motionZ * motionZ;
    if (motionSqrd > 0.001D && !player.capabilities.isFlying) {
        int iPosX = MathHelper.floor_double(player.posX);
        int iPosY = MathHelper.floor_double(player.posY - 0.05);
        int iPosZ = MathHelper.floor_double(player.posZ);
        // If the block below is the moon block
        IBlockState state = player.worldObj.getBlockState(new BlockPos(iPosX, iPosY, iPosZ));
        if (state.getBlock() == GCBlocks.blockMoon) {
            // And is the correct metadata (moon turf)
            if (state.getValue(BlockBasicMoon.BASIC_TYPE_MOON) == BlockBasicMoon.EnumBlockBasicMoon.MOON_TURF) {
                GCPlayerStats stats = GCPlayerStats.get(player);
                // If it has been long enough since the last step
                if (stats.getDistanceSinceLastStep() > 0.35D) {
                    Vector3 pos = new Vector3(player);
                    // Set the footprint position to the block below and add random number to stop z-fighting
                    pos.y = MathHelper.floor_double(player.posY - 1D) + player.worldObj.rand.nextFloat() / 100.0F;
                    // Adjust footprint to left or right depending on step count
                    switch(stats.getLastStep()) {
                        case 0:
                            float a = (-player.rotationYaw + 90F) / Constants.RADIANS_TO_DEGREES;
                            pos.translate(new Vector3(MathHelper.sin(a) * 0.25F, 0, MathHelper.cos(a) * 0.25F));
                            break;
                        case 1:
                            a = (-player.rotationYaw - 90F) / Constants.RADIANS_TO_DEGREES;
                            pos.translate(new Vector3(MathHelper.sin(a) * 0.25, 0, MathHelper.cos(a) * 0.25));
                            break;
                    }
                    float rotation = player.rotationYaw - 180;
                    pos = WorldUtil.getFootprintPosition(player.worldObj, rotation, pos, new BlockVec3(player));
                    long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.intX() >> 4, pos.intZ() >> 4);
                    TickHandlerServer.addFootprint(chunkKey, new Footprint(GCCoreUtil.getDimensionID(player.worldObj), pos, rotation, player.getName()), GCCoreUtil.getDimensionID(player.worldObj));
                    // Increment and cap step counter at 1
                    stats.setLastStep((stats.getLastStep() + 1) % 2);
                    stats.setDistanceSinceLastStep(0);
                } else {
                    stats.setDistanceSinceLastStep(stats.getDistanceSinceLastStep() + motionSqrd);
                }
            }
        }
    }
}
Also used : Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.BlockPos) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)104 TileEntity (net.minecraft.tileentity.TileEntity)44 EnumFacing (net.minecraft.util.EnumFacing)20 IBlockState (net.minecraft.block.state.IBlockState)14 BlockPos (net.minecraft.util.BlockPos)13 World (net.minecraft.world.World)10 IPartialSealableBlock (micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock)9 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)9 Block (net.minecraft.block.Block)9 ArrayList (java.util.ArrayList)7 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)7 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)7 NBTTagList (net.minecraft.nbt.NBTTagList)7 IConductor (micdoodle8.mods.galacticraft.api.transmission.tile.IConductor)6 TileEntityOxygenSealer (micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 Entity (net.minecraft.entity.Entity)5 LinkedList (java.util.LinkedList)4 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)4 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4