Search in sources :

Example 41 with BlockVec3

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

the class OverlaySensorGlasses method renderSensorGlassesValueableBlocks.

public static void renderSensorGlassesValueableBlocks(ItemStack stack, EntityPlayer player, ScaledResolution resolution, float partialTicks) {
    final Iterator<BlockVec3> var51 = ClientProxyCore.valueableBlocks.iterator();
    double var52;
    double var58;
    double var59;
    double var20;
    double var21;
    float var60;
    while (var51.hasNext()) {
        BlockVec3 coords = var51.next();
        var52 = ClientProxyCore.playerPosX - coords.x - 0.5D;
        var58 = ClientProxyCore.playerPosY - coords.y - 0.5D;
        var59 = ClientProxyCore.playerPosZ - coords.z - 0.5D;
        var60 = (float) Math.toDegrees(Math.atan2(var52, var59));
        var20 = Math.sqrt(var52 * var52 + var58 * var58 + var59 * var59) * 0.5D;
        var21 = Math.sqrt(var52 * var52 + var59 * var59) * 0.5D;
        final ScaledResolution var5 = ClientUtil.getScaledRes(OverlaySensorGlasses.minecraft, OverlaySensorGlasses.minecraft.displayWidth, OverlaySensorGlasses.minecraft.displayHeight);
        final int var6 = var5.getScaledWidth();
        final int var7 = var5.getScaledHeight();
        boolean var2 = false;
        final EntityPlayerSP client = PlayerUtil.getPlayerBaseClientFromPlayer(OverlaySensorGlasses.minecraft.thePlayer, false);
        if (client != null) {
            GCPlayerStatsClient stats = GCPlayerStatsClient.get(client);
            var2 = stats.isUsingAdvancedGoggles();
        }
        OverlaySensorGlasses.minecraft.fontRendererObj.drawString(GCCoreUtil.translate("gui.sensor.advanced") + ": " + (var2 ? GCCoreUtil.translate("gui.sensor.advancedon") : GCCoreUtil.translate("gui.sensor.advancedoff")), var6 / 2 - 50, 4, 0x03b88f);
        try {
            GL11.glPushMatrix();
            if (var20 < 4.0D) {
                GL11.glColor4f(0.0F, 255F / 255F, 198F / 255F, (float) Math.min(1.0D, Math.max(0.2D, (var20 - 1.0D) * 0.1D)));
                FMLClientHandler.instance().getClient().renderEngine.bindTexture(OverlaySensorGlasses.indicatorTexture);
                GL11.glRotatef(-var60 - ClientProxyCore.playerRotationYaw + 180.0F, 0.0F, 0.0F, 1.0F);
                GL11.glTranslated(0.0D, var2 ? -var20 * 16 : -var21 * 16, 0.0D);
                GL11.glRotatef(-(-var60 - ClientProxyCore.playerRotationYaw + 180.0F), 0.0F, 0.0F, 1.0F);
                Overlay.drawCenteringRectangle(var6 / 2, var7 / 2, 1.0D, 8.0D, 8.0D);
            }
        } finally {
            GL11.glPopMatrix();
        }
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 42 with BlockVec3

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

the class TileBaseUniversalElectricalSource method produce.

/*
     * Function to produce energy each tick into the outputs of a source.
     * If simulate is true, no energy is in fact transferred.
     *
     * Note: even if simulate is false this does NOT reduce the source's own
     * energy storage by the amount produced, that needs to be done elsewhere
     * See this.produce() for an example.
     */
public float produce(boolean simulate) {
    float amountProduced = 0;
    if (!this.worldObj.isRemote) {
        EnumSet<EnumFacing> outputDirections = this.getElectricalOutputDirections();
        // outputDirections.remove(EnumFacing.UNKNOWN);
        BlockVec3 thisVec = new BlockVec3(this);
        for (EnumFacing direction : outputDirections) {
            TileEntity tileAdj = thisVec.getTileEntityOnSide(this.worldObj, direction);
            if (tileAdj != null) {
                float toSend = this.extractEnergyGC(null, Math.min(this.getEnergyStoredGC() - amountProduced, this.getEnergyStoredGC() / outputDirections.size()), true);
                if (toSend <= 0) {
                    continue;
                }
                if (tileAdj instanceof TileBaseConductor && ((TileBaseConductor) tileAdj).canConnect(direction.getOpposite(), NetworkType.POWER)) {
                    IElectricityNetwork network = ((IConductor) tileAdj).getNetwork();
                    if (network != null) {
                        amountProduced += (toSend - network.produce(toSend, !simulate, this.tierGC, this));
                    }
                } else if (tileAdj instanceof TileBaseUniversalElectrical) {
                    amountProduced += ((TileBaseUniversalElectrical) tileAdj).receiveElectricity(direction.getOpposite(), toSend, this.tierGC, !simulate);
                } else {
                    amountProduced += EnergyUtil.otherModsEnergyTransfer(tileAdj, direction.getOpposite(), toSend, simulate);
                }
            }
        }
    }
    return amountProduced;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IConductor(micdoodle8.mods.galacticraft.api.transmission.tile.IConductor) EnumFacing(net.minecraft.util.EnumFacing) IElectricityNetwork(micdoodle8.mods.galacticraft.api.transmission.grid.IElectricityNetwork) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 43 with BlockVec3

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

the class TileBaseUniversalConductor method injectEnergy.

@RuntimeInterface(clazz = "ic2.api.energy.tile.IEnergySink", modID = "IC2")
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
    TileEntity tile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, directionFrom);
    int tier = ((int) voltage > 120) ? 2 : 1;
    if (tile instanceof IEnergySource && ((IEnergySource) tile).getOfferedEnergy() >= 128) {
        tier = 2;
    }
    float convertedEnergy = (float) amount * EnergyConfigHandler.IC2_RATIO;
    float surplus = this.getNetwork().produce(convertedEnergy, true, tier, this, tile);
    if (surplus >= 0.001F) {
        this.IC2surplusJoules = surplus;
    } else {
        this.IC2surplusJoules = 0F;
    }
    return 0D;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IEnergySource(ic2.api.energy.tile.IEnergySource) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) RuntimeInterface(micdoodle8.mods.miccore.Annotations.RuntimeInterface)

Example 44 with BlockVec3

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

the class TileBaseConductor method getAdjacentConnections.

@Override
public TileEntity[] getAdjacentConnections() {
    /**
     * Cache the adjacentConnections.
     */
    if (this.adjacentConnections == null) {
        this.adjacentConnections = new TileEntity[6];
        BlockVec3 thisVec = new BlockVec3(this);
        for (int i = 0; i < 6; i++) {
            EnumFacing side = EnumFacing.getFront(i);
            TileEntity tileEntity = thisVec.getTileEntityOnSide(this.worldObj, side);
            if (tileEntity instanceof IConnector) {
                if (((IConnector) tileEntity).canConnect(side.getOpposite(), NetworkType.POWER)) {
                    this.adjacentConnections[i] = tileEntity;
                }
            }
        }
    }
    return this.adjacentConnections;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) IConnector(micdoodle8.mods.galacticraft.api.transmission.tile.IConnector) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 45 with BlockVec3

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

the class PlayerClient method updateFeet.

private void updateFeet(EntityPlayerSP player, double motionX, double motionZ) {
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    double motionSqrd = motionX * motionX + motionZ * motionZ;
    // If the player is on the moon, not airbourne and not riding anything
    if (motionSqrd > 0.001 && player.worldObj != null && player.worldObj.provider instanceof WorldProviderMoon && player.ridingEntity == null && !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);
        BlockPos pos1 = new BlockPos(iPosX, iPosY, iPosZ);
        IBlockState state = player.worldObj.getBlockState(pos1);
        // If the block below is the moon block
        if (state.getBlock() == GCBlocks.blockMoon) {
            // And is the correct metadata (moon turf)
            if (state.getValue(BlockBasicMoon.BASIC_TYPE_MOON) == BlockBasicMoon.EnumBlockBasicMoon.MOON_TURF) {
                // If it has been long enough since the last step
                if (stats.getDistanceSinceLastStep() > 0.35) {
                    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) + player.getRNG().nextFloat() / 100.0F;
                    // Adjust footprint to left or right depending on step count
                    switch(stats.getLastStep()) {
                        case 0:
                            pos.translate(new Vector3(Math.sin(Math.toRadians(-player.rotationYaw + 90)) * 0.25, 0, Math.cos(Math.toRadians(-player.rotationYaw + 90)) * 0.25));
                            break;
                        case 1:
                            pos.translate(new Vector3(Math.sin(Math.toRadians(-player.rotationYaw - 90)) * 0.25, 0, Math.cos(Math.toRadians(-player.rotationYaw - 90)) * 0.25));
                            break;
                    }
                    pos = WorldUtil.getFootprintPosition(player.worldObj, player.rotationYaw - 180, pos, new BlockVec3(player));
                    long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.intX() >> 4, pos.intZ() >> 4);
                    FootprintRenderer.addFootprint(chunkKey, GCCoreUtil.getDimensionID(player.worldObj), pos, player.rotationYaw, player.getName());
                    // Increment and cap step counter at 1
                    stats.setLastStep((stats.getLastStep() + 1) % 2);
                    stats.setDistanceSinceLastStep(0);
                } else {
                    stats.setDistanceSinceLastStep(stats.getDistanceSinceLastStep() + motionSqrd);
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) WorldProviderMoon(micdoodle8.mods.galacticraft.core.dimension.WorldProviderMoon) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) 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