Search in sources :

Example 11 with Vector3

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

the class TileEntityGeothermalGenerator method update.

@Override
public void update() {
    if (!this.worldObj.isRemote) {
        this.receiveEnergyGC(null, this.generateWatts, false);
    }
    super.update();
    if (this.ticks % 20 == 0) {
        BlockPos below = this.getPos().down();
        IBlockState stateBelow = this.worldObj.getBlockState(below);
        boolean lastValidSpout = this.validSpout;
        this.validSpout = false;
        if (stateBelow.getBlock() == VenusBlocks.spout) {
            BlockPos pos1 = below.down();
            for (; this.getPos().getY() - pos1.getY() < 20; pos1 = pos1.down()) {
                IBlockState state = this.worldObj.getBlockState(pos1);
                if (state.getBlock() == VenusModule.sulphuricAcid.getBlock()) {
                    this.validSpout = true;
                    break;
                } else if (!state.getBlock().isAir(this.worldObj, pos1)) {
                    // Not valid
                    break;
                }
            }
        }
        if (this.worldObj.isRemote && this.validSpout != lastValidSpout) {
            // Update active texture
            this.worldObj.markBlockForUpdate(this.getPos());
        }
    }
    if (!this.worldObj.isRemote) {
        this.recharge(this.containingItems[0]);
        if (this.disableCooldown > 0) {
            this.disableCooldown--;
        }
        this.generateWatts = Math.min(Math.max(this.getGenerate(), 0), TileEntityGeothermalGenerator.MAX_GENERATE_GJ_PER_TICK);
    } else {
        if (this.generateWatts > 0 && this.ticks % ((int) ((float) MAX_GENERATE_GJ_PER_TICK / (this.generateWatts + 1)) * 5 + 1) == 0) {
            double posX = pos.getX() + 0.5;
            double posY = pos.getY() + 1.0;
            double posZ = pos.getZ() + 0.5;
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX - 0.25, posY, posZ - 0.25), new Vector3(0.0, 0.025, 0.0));
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX - 0.25, posY, posZ), new Vector3(0.0, 0.025, 0.0));
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX - 0.25, posY, posZ + 0.25), new Vector3(0.0, 0.025, 0.0));
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX, posY, posZ - 0.25), new Vector3(0.0, 0.025, 0.0));
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX, posY, posZ), new Vector3(0.0, 0.025, 0.0));
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX, posY, posZ + 0.25), new Vector3(0.0, 0.025, 0.0));
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX + 0.25, posY, posZ - 0.25), new Vector3(0.0, 0.025, 0.0));
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX + 0.25, posY, posZ), new Vector3(0.0, 0.025, 0.0));
            GalacticraftPlanets.spawnParticle("acidExhaust", new Vector3(posX + 0.25, posY, posZ + 0.25), new Vector3(0.0, 0.025, 0.0));
        }
    }
    this.produce();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.BlockPos) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 12 with Vector3

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

the class PacketSimpleAsteroids method handleClientSide.

@SideOnly(Side.CLIENT)
@Override
public void handleClientSide(EntityPlayer player) {
    EntityPlayerSP playerBaseClient = null;
    if (player instanceof EntityPlayerSP) {
        playerBaseClient = (EntityPlayerSP) player;
    }
    TileEntity tile;
    switch(this.type) {
        case C_TELEPAD_SEND:
            Entity entity = playerBaseClient.worldObj.getEntityByID((Integer) this.data.get(1));
            if (entity != null && entity instanceof EntityLivingBase) {
                BlockVec3 pos = (BlockVec3) this.data.get(0);
                entity.setPosition(pos.x + 0.5, pos.y + 2.2, pos.z + 0.5);
            }
            break;
        case C_UPDATE_GRAPPLE_POS:
            entity = playerBaseClient.worldObj.getEntityByID((Integer) this.data.get(0));
            if (entity != null && entity instanceof EntityGrapple) {
                Vector3 vec = (Vector3) this.data.get(1);
                entity.setPosition(vec.x, vec.y, vec.z);
            }
            break;
        default:
            break;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityGrapple(micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityGrapple) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 13 with Vector3

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

the class TileEntityBeamReflector method getInputPoint.

// @Override
// public void update()
// {
// super.update();
// }
@Override
public Vector3 getInputPoint() {
    float distance = 0.15F;
    Vector3 deviation = new Vector3(Math.sin(Math.toRadians(this.yaw - 180)) * distance, 0, Math.cos(Math.toRadians(this.yaw - 180)) * distance);
    Vector3 headVec = new Vector3(this.getPos().getX() + 0.5, this.getPos().getY() + 1.13228 / 2.0, this.getPos().getZ() + 0.5);
    headVec.translate(deviation.clone().invert());
    return headVec;
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 14 with Vector3

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

the class TileEntityBeamOutput method updateOrientation.

public void updateOrientation() {
    if (this.getTarget() != null) {
        Vector3 direction = Vector3.subtract(this.getOutputPoint(false), this.getTarget().getInputPoint()).normalize();
        this.pitch = (float) -Vector3.getAngle(new Vector3(-direction.x, -direction.y, -direction.z), new Vector3(0, 1, 0)) * Constants.RADIANS_TO_DEGREES + 90;
        this.yaw = (float) -(Math.atan2(direction.z, direction.x) * Constants.RADIANS_TO_DEGREES) + 90;
    }
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 15 with Vector3

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

the class TileEntityBeamReceiver method getInputPoint.

@Override
public Vector3 getInputPoint() {
    Vector3 headVec = new Vector3(this.getPos().getX() + 0.5, this.getPos().getY() + 0.5, this.getPos().getZ() + 0.5);
    if (this.facing != null) {
        headVec.x += this.facing.getFrontOffsetX() * 0.1F;
        headVec.y += this.facing.getFrontOffsetY() * 0.1F;
        headVec.z += this.facing.getFrontOffsetZ() * 0.1F;
    }
    return headVec;
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Aggregations

Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)74 BlockPos (net.minecraft.util.BlockPos)13 Entity (net.minecraft.entity.Entity)12 TileEntity (net.minecraft.tileentity.TileEntity)11 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)8 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)6 IBlockState (net.minecraft.block.state.IBlockState)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 ItemStack (net.minecraft.item.ItemStack)6 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)4 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4 FlagData (micdoodle8.mods.galacticraft.core.wrappers.FlagData)4 WorldServer (net.minecraft.world.WorldServer)4 GameProfile (com.mojang.authlib.GameProfile)3