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;
}
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);
}
}
}
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;
}
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;
}
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;
}
Aggregations