use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class TickHandlerClientVenus method onClientTick.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
final Minecraft minecraft = FMLClientHandler.instance().getClient();
final WorldClient world = minecraft.world;
if (world != null) {
if (world.provider instanceof WorldProviderVenus) {
if (world.provider.getSkyRenderer() == null) {
world.provider.setSkyRenderer(new SkyProviderVenus((IGalacticraftWorldProvider) world.provider));
}
if (world.provider.getCloudRenderer() == null) {
world.provider.setCloudRenderer(new CloudRenderer());
}
if (world.provider.getWeatherRenderer() == null) {
world.provider.setWeatherRenderer(new WeatherRendererVenus());
}
}
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class RoomTreasureMars method addComponentParts.
@Override
public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox boundingBox) {
for (int i = 0; i <= this.sizeX; i++) {
for (int j = 0; j <= this.sizeY; j++) {
for (int k = 0; k <= this.sizeZ; k++) {
if (i == 0 || i == this.sizeX || j == 0 || j == this.sizeY || k == 0 || k == this.sizeZ) {
boolean placeBlock = true;
if (getDirection().getAxis() == EnumFacing.Axis.Z) {
int start = (this.boundingBox.maxX - this.boundingBox.minX) / 2 - 1;
int end = (this.boundingBox.maxX - this.boundingBox.minX) / 2 + 1;
if (i > start && i <= end && j < 3 && j > 0) {
if (getDirection() == EnumFacing.SOUTH && k == 0) {
placeBlock = false;
} else if (getDirection() == EnumFacing.NORTH && k == this.sizeZ) {
placeBlock = false;
}
}
} else {
int start = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 - 1;
int end = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 + 1;
if (k > start && k <= end && j < 3 && j > 0) {
if (getDirection() == EnumFacing.EAST && i == 0) {
placeBlock = false;
} else if (getDirection() == EnumFacing.WEST && i == this.sizeX) {
placeBlock = false;
}
}
}
if (placeBlock) {
this.setBlockState(worldIn, this.configuration.getBrickBlock(), i, j, k, boundingBox);
} else {
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), i, j, k, boundingBox);
}
} else if ((i == 1 && k == 1) || (i == 1 && k == this.sizeZ - 1) || (i == this.sizeX - 1 && k == 1) || (i == this.sizeX - 1 && k == this.sizeZ - 1)) {
this.setBlockState(worldIn, Blocks.GLOWSTONE.getDefaultState(), i, j, k, boundingBox);
} else if (i == this.sizeX / 2 && j == 1 && k == this.sizeZ / 2) {
BlockPos blockpos = new BlockPos(this.getXWithOffset(i, k), this.getYWithOffset(j), this.getZWithOffset(i, k));
if (boundingBox.isVecInside(blockpos)) {
worldIn.setBlockState(blockpos, MarsBlocks.treasureChestTier2.getDefaultState().withProperty(BlockTier2TreasureChest.FACING, this.getDirection().getOpposite()), 2);
TileEntityTreasureChest treasureChest = (TileEntityTreasureChest) worldIn.getTileEntity(blockpos);
if (treasureChest != null) {
ResourceLocation chesttype = TABLE_TIER_2_DUNGEON;
if (worldIn.provider instanceof IGalacticraftWorldProvider) {
chesttype = ((IGalacticraftWorldProvider) worldIn.provider).getDungeonChestType();
}
treasureChest.setLootTable(chesttype, random.nextLong());
}
}
} else {
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), i, j, k, boundingBox);
}
}
}
}
return true;
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class EntityTieredRocket method onReachAtmosphere.
@Override
public void onReachAtmosphere() {
// Launch controlled
if (this.destinationFrequency != -1) {
if (this.world.isRemote) {
// stop the sounds on the client - but do not reset, the rocket may start again
this.stopRocketSound();
return;
}
this.setTarget(true, this.destinationFrequency);
if (this.targetVec != null) {
if (this.targetDimension != this.world.provider.getDimension()) {
WorldProvider targetDim = WorldUtil.getProviderForDimensionServer(this.targetDimension);
if (targetDim != null && targetDim.world instanceof WorldServer) {
boolean dimensionAllowed = this.targetDimension == ConfigManagerCore.idDimensionOverworld;
if (targetDim instanceof IGalacticraftWorldProvider) {
if (((IGalacticraftWorldProvider) targetDim).canSpaceshipTierPass(this.getRocketTier()))
dimensionAllowed = true;
else
dimensionAllowed = false;
} else // No rocket flight to non-Galacticraft dimensions other than the Overworld allowed unless config
if ((this.targetDimension > 1 || this.targetDimension < -1) && marsConfigAllDimsAllowed != null) {
try {
if (marsConfigAllDimsAllowed.getBoolean(null)) {
dimensionAllowed = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (dimensionAllowed) {
if (!this.getPassengers().isEmpty()) {
for (Entity passenger : this.getPassengers()) {
if (passenger instanceof EntityPlayerMP) {
WorldUtil.transferEntityToDimension(passenger, this.targetDimension, (WorldServer) targetDim.world, false, this);
}
}
} else {
Entity e = WorldUtil.transferEntityToDimension(this, this.targetDimension, (WorldServer) targetDim.world, false, null);
if (e instanceof EntityAutoRocket) {
e.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5f);
((EntityAutoRocket) e).setLaunchPhase(EnumLaunchPhase.LANDING);
((EntityAutoRocket) e).setWaitForPlayer(false);
} else {
GCLog.info("Error: failed to recreate the unmanned rocket in landing mode on target planet.");
e.setDead();
this.setDead();
}
}
return;
}
}
// No destination world found - in this situation continue into regular take-off (as if Not launch controlled)
} else {
// Same dimension controlled rocket flight
this.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F);
// Stop any lateral motion, otherwise it will update to an incorrect x,z position first tick after spawning above target
this.motionX = this.motionZ = 0.0D;
// Small upward motion initially, to keep clear of own flame trail from launch
this.motionY = 0.1D;
for (Entity passenger : this.getPassengers()) {
if (passenger instanceof EntityPlayerMP) {
WorldUtil.forceMoveEntityToPos(passenger, (WorldServer) this.world, new Vector3(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F), false);
this.setWaitForPlayer(true);
GCLog.debug("Rocket repositioned, waiting for player");
}
}
this.setLaunchPhase(EnumLaunchPhase.LANDING);
// Do not destroy the rocket, we still need it!
return;
}
} else {
// Launch controlled launch but no valid target frequency = rocket loss [INVESTIGATE]
GCLog.info("Error: the launch controlled rocket failed to find a valid landing spot when it reached space.");
this.fuelTank.drain(Integer.MAX_VALUE, true);
this.posY = Math.max(255, (this.world.provider instanceof IExitHeight ? ((IExitHeight) this.world.provider).getYCoordinateToTeleport() : 1200) - 200);
return;
}
}
// Not launch controlled
if (!this.world.isRemote) {
for (Entity e : this.getPassengers()) {
if (e instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) e;
this.onTeleport(player);
GCPlayerStats stats = GCPlayerStats.get(player);
WorldUtil.toCelestialSelection(player, stats, this.getRocketTier());
}
}
// Destroy any rocket which reached the top of the atmosphere and is not controlled by a Launch Controller
this.setDead();
}
// Client side, non-launch controlled, do nothing - no reason why it can't continue flying until the GUICelestialSelection activates
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class BlockUnlitTorch method onOxygenRemoved.
@Override
public void onOxygenRemoved(World world, BlockPos pos, IBlockState state) {
if (world.provider instanceof IGalacticraftWorldProvider) {
EnumFacing enumfacing = state.getValue(FACING);
world.setBlockState(pos, this.unlitVersion.getDefaultState().withProperty(FACING, enumfacing), 2);
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class BlockUnlitTorch method checkOxygen.
private void checkOxygen(World world, BlockPos pos, IBlockState state) {
if (world.provider instanceof IGalacticraftWorldProvider) {
if (OxygenUtil.checkTorchHasOxygen(world, pos)) {
this.onOxygenAdded(world, pos, state);
} else {
this.onOxygenRemoved(world, pos, state);
}
} else {
EnumFacing enumfacing = state.getValue(FACING);
world.setBlockState(pos, this.fallback.getDefaultState().withProperty(FACING, enumfacing), 2);
}
}
Aggregations