use of micdoodle8.mods.galacticraft.core.client.SkyProviderOverworld in project Galacticraft by micdoodle8.
the class TransformerHooks method getFogColorHook.
@SideOnly(Side.CLIENT)
public static Vec3 getFogColorHook(World world) {
EntityPlayerSP player = FMLClientHandler.instance().getClient().thePlayer;
if (world.provider.getSkyRenderer() instanceof SkyProviderOverworld) {
float var20 = ((float) (player.posY) - Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) / 1000.0F;
var20 = MathHelper.sqrt_float(var20);
final float var21 = Math.max(1.0F - var20 * 40.0F, 0.0F);
Vec3 vec = world.getFogColor(1.0F);
return new Vec3(vec.xCoord * Math.max(1.0F - var20 * 1.29F, 0.0F), vec.yCoord * Math.max(1.0F - var20 * 1.29F, 0.0F), vec.zCoord * Math.max(1.0F - var20 * 1.29F, 0.0F));
}
return world.getFogColor(1.0F);
}
use of micdoodle8.mods.galacticraft.core.client.SkyProviderOverworld in project Galacticraft by micdoodle8.
the class EventHandlerGC method overrideSkyColor.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void overrideSkyColor(FogColors event) {
// Disable any night vision effects on the sky, if the planet has no atmosphere
if (event.entity instanceof EntityLivingBase && ((EntityLivingBase) event.entity).isPotionActive(Potion.nightVision)) {
WorldClient worldclient = Minecraft.getMinecraft().theWorld;
if (worldclient.provider instanceof IGalacticraftWorldProvider && ((IGalacticraftWorldProvider) worldclient.provider).hasNoAtmosphere() && event.block.getMaterial() == Material.air && !((IGalacticraftWorldProvider) worldclient.provider).hasBreathableAtmosphere()) {
Vec3 vec = worldclient.getFogColor(1.0F);
event.red = (float) vec.xCoord;
event.green = (float) vec.yCoord;
event.blue = (float) vec.zCoord;
return;
}
if (worldclient.provider.getSkyRenderer() instanceof SkyProviderOverworld && event.entity.posY > Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) {
Vec3 vec = TransformerHooks.getFogColorHook(event.entity.worldObj);
event.red = (float) vec.xCoord;
event.green = (float) vec.yCoord;
event.blue = (float) vec.zCoord;
return;
}
}
}
use of micdoodle8.mods.galacticraft.core.client.SkyProviderOverworld in project Galacticraft by micdoodle8.
the class TickHandlerClient method onClientTick.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
final Minecraft minecraft = FMLClientHandler.instance().getClient();
final WorldClient world = minecraft.theWorld;
final EntityPlayerSP player = minecraft.thePlayer;
if (teleportingGui != null) {
if (minecraft.currentScreen != teleportingGui) {
minecraft.currentScreen = teleportingGui;
}
}
if (menuReset) {
TickHandlerClient.resetClient();
menuReset = false;
}
if (event.phase == Phase.START && player != null) {
if (ClientProxyCore.playerHead == null && player.getGameProfile() != null) {
Map<Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(player.getGameProfile());
if (map.containsKey(Type.SKIN)) {
ClientProxyCore.playerHead = minecraft.getSkinManager().loadSkin((MinecraftProfileTexture) map.get(Type.SKIN), Type.SKIN);
} else {
ClientProxyCore.playerHead = DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(player.getGameProfile()));
}
}
TickHandlerClient.tickCount++;
if (!GalacticraftCore.proxy.isPaused()) {
Iterator<FluidNetwork> it = TickHandlerClient.fluidNetworks.iterator();
while (it.hasNext()) {
FluidNetwork network = it.next();
if (network.getTransmitters().size() == 0) {
it.remove();
} else {
network.clientTick();
}
}
}
if (TickHandlerClient.tickCount % 20 == 0) {
if (updateJEIhiding) {
updateJEIhiding = false;
if (CompressorRecipes.steelIngotsPresent) {
// Update JEI to hide the ingot compressor recipe for GC steel in hard mode
GalacticraftJEI.updateHiddenSteel(ConfigManagerCore.hardMode && !ConfigManagerCore.challengeRecipes);
}
// Update JEI to hide adventure mode recipes when not in adventure mode
GalacticraftJEI.updateHiddenAdventure(!ConfigManagerCore.challengeRecipes);
}
for (List<Footprint> fpList : FootprintRenderer.footprints.values()) {
Iterator<Footprint> fpIt = fpList.iterator();
while (fpIt.hasNext()) {
Footprint fp = fpIt.next();
fp.age += 20;
if (fp.age >= Footprint.MAX_AGE) {
fpIt.remove();
}
}
}
if (player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() instanceof ItemSensorGlasses) {
ClientProxyCore.valueableBlocks.clear();
for (int i = -4; i < 5; i++) {
int x = MathHelper.floor_double(player.posX + i);
for (int j = -4; j < 5; j++) {
int y = MathHelper.floor_double(player.posY + j);
for (int k = -4; k < 5; k++) {
int z = MathHelper.floor_double(player.posZ + k);
BlockPos pos = new BlockPos(x, y, z);
IBlockState state = player.worldObj.getBlockState(pos);
final Block block = state.getBlock();
if (block.getMaterial() != Material.air) {
int metadata = block.getMetaFromState(state);
boolean isDetectable = false;
for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks) {
if (blockMetaList.getBlock() == block && blockMetaList.getMetaList().contains(metadata)) {
isDetectable = true;
break;
}
}
if (isDetectable || (block instanceof IDetectableResource && ((IDetectableResource) block).isValueable(state))) {
ClientProxyCore.valueableBlocks.add(new BlockVec3(x, y, z));
}
}
}
}
}
TileEntityOxygenSealer nearestSealer = TileEntityOxygenSealer.getNearestSealer(world, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ));
if (nearestSealer != null && !nearestSealer.sealed) {
ClientProxyCore.leakTrace = nearestSealer.getLeakTraceClient();
} else {
ClientProxyCore.leakTrace = null;
}
} else {
ClientProxyCore.leakTrace = null;
}
if (world != null) {
if (MapUtil.resetClientFlag.getAndSet(false)) {
MapUtil.resetClientBody();
}
}
}
if (ClientProxyCore.leakTrace != null)
this.spawnLeakParticles();
if (world != null && TickHandlerClient.spaceRaceGuiScheduled && minecraft.currentScreen == null && ConfigManagerCore.enableSpaceRaceManagerPopup) {
player.openGui(GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_START, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
TickHandlerClient.spaceRaceGuiScheduled = false;
}
if (world != null && TickHandlerClient.checkedVersion) {
ThreadVersionCheck.startCheck();
TickHandlerClient.checkedVersion = false;
}
boolean inSpaceShip = false;
if (player.ridingEntity instanceof EntitySpaceshipBase) {
inSpaceShip = true;
EntitySpaceshipBase rocket = (EntitySpaceshipBase) player.ridingEntity;
if (rocket.prevRotationPitch != rocket.rotationPitch || rocket.prevRotationYaw != rocket.rotationYaw)
GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(player.ridingEntity));
}
if (world != null) {
if (world.provider instanceof WorldProviderSurface) {
if (world.provider.getSkyRenderer() == null && inSpaceShip && player.ridingEntity.posY > Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) {
world.provider.setSkyRenderer(new SkyProviderOverworld());
} else if (world.provider.getSkyRenderer() instanceof SkyProviderOverworld && player.posY <= Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) {
world.provider.setSkyRenderer(null);
}
} else if (world.provider instanceof WorldProviderSpaceStation) {
if (world.provider.getSkyRenderer() == null) {
((WorldProviderSpaceStation) world.provider).createSkyProvider();
}
} else if (world.provider instanceof WorldProviderMoon) {
if (world.provider.getSkyRenderer() == null) {
world.provider.setSkyRenderer(new SkyProviderMoon());
}
if (world.provider.getCloudRenderer() == null) {
world.provider.setCloudRenderer(new CloudRenderer());
}
}
}
if (inSpaceShip) {
final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;
boolean hasChanged = false;
if (minecraft.gameSettings.keyBindLeft.isKeyDown()) {
ship.turnYaw(-1.0F);
hasChanged = true;
}
if (minecraft.gameSettings.keyBindRight.isKeyDown()) {
ship.turnYaw(1.0F);
hasChanged = true;
}
if (minecraft.gameSettings.keyBindForward.isKeyDown()) {
if (ship.getLaunched()) {
ship.turnPitch(-0.7F);
hasChanged = true;
}
}
if (minecraft.gameSettings.keyBindBack.isKeyDown()) {
if (ship.getLaunched()) {
ship.turnPitch(0.7F);
hasChanged = true;
}
}
if (hasChanged) {
GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(ship));
}
}
if (world != null) {
List entityList = world.loadedEntityList;
for (Object e : entityList) {
if (e instanceof IEntityNoisy) {
IEntityNoisy vehicle = (IEntityNoisy) e;
if (vehicle.getSoundUpdater() == null) {
ISound noise = vehicle.setSoundUpdater(FMLClientHandler.instance().getClient().thePlayer);
if (noise != null) {
FMLClientHandler.instance().getClient().getSoundHandler().playSound(noise);
}
}
}
}
}
if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiCelestialSelection) {
player.motionY = 0;
}
if (world != null && world.provider instanceof IGalacticraftWorldProvider && OxygenUtil.noAtmosphericCombustion(world.provider) && ((IGalacticraftWorldProvider) world.provider).shouldDisablePrecipitation()) {
world.setRainStrength(0.0F);
}
boolean isPressed = KeyHandlerClient.spaceKey.isPressed();
if (!isPressed) {
ClientProxyCore.lastSpacebarDown = false;
}
if (player.ridingEntity != null && isPressed && !ClientProxyCore.lastSpacebarDown) {
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_IGNITE_ROCKET, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}));
ClientProxyCore.lastSpacebarDown = true;
}
if (!(this.screenConnectionsUpdateList.isEmpty())) {
HashSet<TileEntityScreen> updateListCopy = (HashSet<TileEntityScreen>) screenConnectionsUpdateList.clone();
screenConnectionsUpdateList.clear();
for (TileEntityScreen te : updateListCopy) {
if (te.getWorld().getBlockState(te.getPos()).getBlock() == GCBlocks.screen) {
if (te.refreshOnUpdate) {
te.refreshConnections(true);
}
te.getWorld().markBlockRangeForRenderUpdate(te.getPos(), te.getPos());
}
}
}
} else if (event.phase == Phase.END) {
if (world != null) {
for (GalacticraftPacketHandler handler : packetHandlers) {
handler.tick(world);
}
}
}
}
use of micdoodle8.mods.galacticraft.core.client.SkyProviderOverworld in project Galacticraft by micdoodle8.
the class TransformerHooks method getSkyColorHook.
@SideOnly(Side.CLIENT)
public static Vec3 getSkyColorHook(World world) {
EntityPlayerSP player = FMLClientHandler.instance().getClient().thePlayer;
if (world.provider.getSkyRenderer() instanceof SkyProviderOverworld || (player != null && player.posY > Constants.OVERWORLD_CLOUD_HEIGHT && player.ridingEntity instanceof EntitySpaceshipBase)) {
float f1 = world.getCelestialAngle(1.0F);
float f2 = MathHelper.cos(f1 * Constants.twoPI) * 2.0F + 0.5F;
if (f2 < 0.0F) {
f2 = 0.0F;
}
if (f2 > 1.0F) {
f2 = 1.0F;
}
int i = MathHelper.floor_double(player.posX);
int j = MathHelper.floor_double(player.posY);
int k = MathHelper.floor_double(player.posZ);
BlockPos pos = new BlockPos(i, j, k);
int l = ForgeHooksClient.getSkyBlendColour(world, pos);
float f4 = (float) (l >> 16 & 255) / 255.0F;
float f5 = (float) (l >> 8 & 255) / 255.0F;
float f6 = (float) (l & 255) / 255.0F;
f4 *= f2;
f5 *= f2;
f6 *= f2;
if (player.posY <= Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) {
Vec3 vec = world.getSkyColor(FMLClientHandler.instance().getClient().getRenderViewEntity(), 1.0F);
double blend = (player.posY - Constants.OVERWORLD_CLOUD_HEIGHT) / (Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT - Constants.OVERWORLD_CLOUD_HEIGHT);
double ablend = 1 - blend;
return new Vec3(f4 * blend + vec.xCoord * ablend, f5 * blend + vec.yCoord * ablend, f6 * blend + vec.zCoord * ablend);
} else {
double blend = Math.min(1.0D, (player.posY - Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) / 300.0D);
double ablend = 1.0D - blend;
blend /= 255.0D;
return new Vec3(f4 * ablend + blend * 31.0D, f5 * ablend + blend * 8.0D, f6 * ablend + blend * 99.0D);
}
}
return world.getSkyColor(FMLClientHandler.instance().getClient().getRenderViewEntity(), 1.0F);
}
Aggregations