Search in sources :

Example 1 with TileEntityLandingPad

use of micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad in project MorePlanets by SteveKunG.

the class ItemRocketBaseMP method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack itemStack = player.getHeldItem(hand);
    boolean padFound = false;
    TileEntity tile = null;
    if (world.isRemote) {
        return EnumActionResult.PASS;
    } else {
        float centerX = -1;
        float centerY = -1;
        float centerZ = -1;
        for (int i = -1; i < 2; i++) {
            for (int j = -1; j < 2; j++) {
                BlockPos pos1 = pos.add(i, 0, j);
                IBlockState state = world.getBlockState(pos1);
                Block block = state.getBlock();
                int meta = block.getMetaFromState(state);
                if (block == GCBlocks.landingPadFull && meta == 0) {
                    padFound = true;
                    tile = world.getTileEntity(pos1);
                    centerX = pos.getX() + i + 0.5F;
                    centerY = pos.getY() + 0.4F;
                    centerZ = pos.getZ() + j + 0.5F;
                    break;
                }
            }
            if (padFound) {
                break;
            }
        }
        if (padFound) {
            if (tile instanceof TileEntityLandingPad) {
                if (((TileEntityLandingPad) tile).getDockedEntity() != null) {
                    return EnumActionResult.PASS;
                }
            } else {
                return EnumActionResult.PASS;
            }
            this.spawnRocket(itemStack, world, player, centerX, centerY, centerZ);
        } else {
            return EnumActionResult.PASS;
        }
    }
    return EnumActionResult.SUCCESS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) TileEntityLandingPad(micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad)

Example 2 with TileEntityLandingPad

use of micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad in project Galacticraft by micdoodle8.

the class TileEntityLaunchController method updateRocketOnDockSettings.

public void updateRocketOnDockSettings() {
    if (this.attachedDock instanceof TileEntityLandingPad) {
        TileEntityLandingPad pad = ((TileEntityLandingPad) this.attachedDock);
        IDockable rocket = pad.getDockedEntity();
        if (rocket instanceof EntityAutoRocket) {
            ((EntityAutoRocket) rocket).updateControllerSettings(pad);
        }
    }
}
Also used : EntityAutoRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket) TileEntityLandingPad(micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad) IDockable(micdoodle8.mods.galacticraft.api.entity.IDockable)

Example 3 with TileEntityLandingPad

use of micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad in project Galacticraft by micdoodle8.

the class ItemTier3Rocket method placeRocketOnPad.

public static boolean placeRocketOnPad(ItemStack stack, World worldIn, TileEntity tile, float centerX, float centerY, float centerZ) {
    // Check whether there is already a rocket on the pad
    if (tile instanceof TileEntityLandingPad) {
        if (((TileEntityLandingPad) tile).getDockedEntity() != null) {
            return false;
        }
    } else {
        return false;
    }
    EntityTier3Rocket rocket = new EntityTier3Rocket(worldIn, centerX, centerY, centerZ, EnumRocketType.values()[stack.getItemDamage()]);
    rocket.rotationYaw += 45;
    rocket.setPosition(rocket.posX, rocket.posY + rocket.getOnPadYOffset(), rocket.posZ);
    worldIn.spawnEntityInWorld(rocket);
    if (rocket.getType().getPreFueled()) {
        rocket.fuelTank.fill(new FluidStack(GCFluids.fluidFuel, rocket.getMaxFuel()), true);
    } else if (stack.hasTagCompound() && stack.getTagCompound().hasKey("RocketFuel")) {
        rocket.fuelTank.fill(new FluidStack(GCFluids.fluidFuel, stack.getTagCompound().getInteger("RocketFuel")), true);
    }
    return true;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EntityTier3Rocket(micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityTier3Rocket) TileEntityLandingPad(micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad)

Example 4 with TileEntityLandingPad

use of micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad in project Galacticraft by micdoodle8.

the class ItemTier1Rocket method placeRocketOnPad.

public static boolean placeRocketOnPad(ItemStack stack, World worldIn, TileEntity tile, float centerX, float centerY, float centerZ) {
    // Check whether there is already a rocket on the pad
    if (tile instanceof TileEntityLandingPad) {
        if (((TileEntityLandingPad) tile).getDockedEntity() != null) {
            return false;
        }
    } else {
        return false;
    }
    final EntityTier1Rocket spaceship = new EntityTier1Rocket(worldIn, centerX, centerY, centerZ, EnumRocketType.values()[stack.getItemDamage()]);
    spaceship.setPosition(spaceship.posX, spaceship.posY + spaceship.getOnPadYOffset(), spaceship.posZ);
    worldIn.spawnEntityInWorld(spaceship);
    if (spaceship.rocketType.getPreFueled()) {
        spaceship.fuelTank.fill(new FluidStack(GCFluids.fluidFuel, spaceship.getMaxFuel()), true);
    } else if (stack.hasTagCompound() && stack.getTagCompound().hasKey("RocketFuel")) {
        spaceship.fuelTank.fill(new FluidStack(GCFluids.fluidFuel, stack.getTagCompound().getInteger("RocketFuel")), true);
    }
    return true;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EntityTier1Rocket(micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket) TileEntityLandingPad(micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad)

Example 5 with TileEntityLandingPad

use of micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad in project Galacticraft by micdoodle8.

the class ItemTier2Rocket method placeRocketOnPad.

public static boolean placeRocketOnPad(ItemStack stack, World world, TileEntity tile, float centerX, float centerY, float centerZ) {
    // Check whether there is already a rocket on the pad
    if (tile instanceof TileEntityLandingPad) {
        if (((TileEntityLandingPad) tile).getDockedEntity() != null) {
            return false;
        }
    } else {
        return false;
    }
    EntityAutoRocket rocket;
    if (stack.getItemDamage() < 10) {
        rocket = new EntityTier2Rocket(world, centerX, centerY, centerZ, EnumRocketType.values()[stack.getItemDamage()]);
    } else {
        rocket = new EntityCargoRocket(world, centerX, centerY, centerZ, EnumRocketType.values()[stack.getItemDamage() - 10]);
    }
    rocket.setPosition(rocket.posX, rocket.posY + rocket.getOnPadYOffset(), rocket.posZ);
    world.spawnEntityInWorld(rocket);
    if (((IRocketType) rocket).getType().getPreFueled()) {
        if (rocket instanceof EntityTieredRocket) {
            ((EntityTieredRocket) rocket).fuelTank.fill(new FluidStack(GCFluids.fluidFuel, rocket.getMaxFuel()), true);
        } else {
            ((EntityCargoRocket) rocket).fuelTank.fill(new FluidStack(GCFluids.fluidFuel, rocket.getMaxFuel()), true);
        }
    } else if (stack.hasTagCompound() && stack.getTagCompound().hasKey("RocketFuel")) {
        rocket.fuelTank.fill(new FluidStack(GCFluids.fluidFuel, stack.getTagCompound().getInteger("RocketFuel")), true);
    }
    return true;
}
Also used : EntityCargoRocket(micdoodle8.mods.galacticraft.planets.mars.entities.EntityCargoRocket) EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) FluidStack(net.minecraftforge.fluids.FluidStack) EntityAutoRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket) TileEntityLandingPad(micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad) EntityTier2Rocket(micdoodle8.mods.galacticraft.planets.mars.entities.EntityTier2Rocket)

Aggregations

TileEntityLandingPad (micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad)5 FluidStack (net.minecraftforge.fluids.FluidStack)3 EntityAutoRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket)2 IDockable (micdoodle8.mods.galacticraft.api.entity.IDockable)1 EntityTieredRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket)1 EntityTier1Rocket (micdoodle8.mods.galacticraft.core.entities.EntityTier1Rocket)1 EntityTier3Rocket (micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityTier3Rocket)1 EntityCargoRocket (micdoodle8.mods.galacticraft.planets.mars.entities.EntityCargoRocket)1 EntityTier2Rocket (micdoodle8.mods.galacticraft.planets.mars.entities.EntityTier2Rocket)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1