use of micdoodle8.mods.galacticraft.core.dimension.WorldProviderMoon in project Galacticraft by micdoodle8.
the class OreGenOtherMods method onPlanetDecorated.
@SubscribeEvent
public void onPlanetDecorated(GCCoreEventPopulate.Post event) {
this.worldObj = event.worldObj;
this.randomGenerator = event.rand;
this.pos = event.pos;
int dimDetected = 0;
WorldProvider prov = worldObj.provider;
if (!(prov instanceof IGalacticraftWorldProvider) || (prov instanceof WorldProviderSpaceStation)) {
return;
}
Block stoneBlock = null;
int stoneMeta = 0;
if (prov instanceof WorldProviderMoon) {
stoneBlock = GCBlocks.blockMoon;
stoneMeta = 4;
dimDetected = 1;
} else if (GalacticraftCore.isPlanetsLoaded && prov instanceof WorldProviderMars) {
stoneBlock = MarsBlocks.marsBlock;
stoneMeta = 9;
dimDetected = 2;
}
if (stoneBlock == null) {
return;
}
for (OreGenData ore : OreGenOtherMods.data) {
if (ore.dimRestrict == 0 || ore.dimRestrict == dimDetected) {
this.oreGen = new WorldGenMinableMeta(ore.oreBlock, ore.sizeCluster, ore.oreMeta, true, stoneBlock, stoneMeta);
this.genStandardOre1(ore.numClusters, this.oreGen, ore.minHeight, ore.maxHeight);
}
}
}
use of micdoodle8.mods.galacticraft.core.dimension.WorldProviderMoon in project Galacticraft by micdoodle8.
the class SkyProviderMoon method render.
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
if (!ClientProxyCore.overworldTextureRequestSent) {
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(PacketSimple.EnumSimplePacket.S_REQUEST_OVERWORLD_IMAGE, GCCoreUtil.getDimensionID(mc.theWorld), new Object[] {}));
ClientProxyCore.overworldTextureRequestSent = true;
}
WorldProviderMoon gcProvider = null;
if (world.provider instanceof WorldProviderMoon) {
gcProvider = (WorldProviderMoon) world.provider;
}
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glColor3f(1F, 1F, 1F);
final Tessellator var23 = Tessellator.getInstance();
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_FOG);
GL11.glColor3f(0, 0, 0);
GL11.glCallList(this.glSkyList);
GL11.glDisable(GL11.GL_FOG);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.disableStandardItemLighting();
float var10;
float var11;
float var12;
float var20 = 0;
if (gcProvider != null) {
var20 = gcProvider.getStarBrightness(partialTicks);
}
if (var20 > 0.0F) {
GL11.glPushMatrix();
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(-19.0F, 0, 1.0F, 0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, var20);
GL11.glCallList(this.starGLCallList);
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glPushMatrix();
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 5F);
GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 1.0F);
var12 = 20.0F / 3.5F;
WorldRenderer worldRenderer = var23.getWorldRenderer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
worldRenderer.pos(-var12, 99.9D, -var12).endVertex();
worldRenderer.pos(var12, 99.9D, -var12).endVertex();
worldRenderer.pos(var12, 99.9D, var12).endVertex();
worldRenderer.pos(-var12, 99.9D, var12).endVertex();
var23.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
var12 = 20.0F;
FMLClientHandler.instance().getClient().renderEngine.bindTexture(SkyProviderMoon.sunTexture);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
worldRenderer.pos(-var12, 100.0D, -var12).tex(0.0D, 0.0D).endVertex();
worldRenderer.pos(var12, 100.0D, -var12).tex(1.0D, 0.0D).endVertex();
worldRenderer.pos(var12, 100.0D, var12).tex(1.0D, 1.0D).endVertex();
worldRenderer.pos(-var12, 100.0D, var12).tex(0.0D, 1.0D).endVertex();
var23.draw();
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_BLEND);
// HOME:
var12 = 10.0F;
final float earthRotation = (float) (world.getSpawnPoint().getZ() - mc.thePlayer.posZ) * 0.01F;
GL11.glScalef(0.6F, 0.6F, 0.6F);
GL11.glRotatef(earthRotation, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(200F, 1.0F, 0.0F, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F);
double v = 1.0D;
if (ClientProxyCore.overworldTexturesValid) {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, ClientProxyCore.overworldTextureClient.getGlTextureId());
} else {
// Overworld texture is 48x48 in a 64x64 .png file
FMLClientHandler.instance().getClient().renderEngine.bindTexture(SkyProviderMoon.overworldTexture);
v = 0.75D;
}
world.getMoonPhase();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
worldRenderer.pos(-var12, -100.0D, var12).tex(0D, v).endVertex();
worldRenderer.pos(var12, -100.0D, var12).tex(v, v).endVertex();
worldRenderer.pos(var12, -100.0D, -var12).tex(v, 0D).endVertex();
worldRenderer.pos(-var12, -100.0D, -var12).tex(0D, 0D).endVertex();
var23.draw();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_FOG);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(0.0F, 0.0F, 0.0F);
final double var25 = mc.thePlayer.getPosition().getY() - world.getHorizon();
if (var25 < 0.0D) {
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 12.0F, 0.0F);
GL11.glCallList(this.glSkyList2);
GL11.glPopMatrix();
var10 = 1.0F;
var11 = -((float) (var25 + 65.0D));
var12 = -var10;
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
worldRenderer.pos(-var10, var11, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var11, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var12, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var12, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var12, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var12, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var11, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var11, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var12, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var12, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var11, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var11, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var11, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var11, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var12, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var12, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var12, -var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(-var10, var12, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var12, var10).color(0, 0, 0, 1.0F).endVertex();
worldRenderer.pos(var10, var12, -var10).color(0, 0, 0, 1.0F).endVertex();
var23.draw();
}
GL11.glColor3f(70F / 256F, 70F / 256F, 70F / 256F);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, -((float) (var25 - 16.0D)), 0.0F);
GL11.glCallList(this.glSkyList2);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glDisable(GL11.GL_FOG);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_BLEND);
}
use of micdoodle8.mods.galacticraft.core.dimension.WorldProviderMoon in project Galacticraft by micdoodle8.
the class PlayerClient method updateFeet.
private void updateFeet(EntityPlayerSP player, double motionX, double motionZ) {
GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
double motionSqrd = motionX * motionX + motionZ * motionZ;
// If the player is on the moon, not airbourne and not riding anything
if (motionSqrd > 0.001 && player.worldObj != null && player.worldObj.provider instanceof WorldProviderMoon && player.ridingEntity == null && !player.capabilities.isFlying) {
int iPosX = MathHelper.floor_double(player.posX);
int iPosY = MathHelper.floor_double(player.posY - 0.05);
int iPosZ = MathHelper.floor_double(player.posZ);
BlockPos pos1 = new BlockPos(iPosX, iPosY, iPosZ);
IBlockState state = player.worldObj.getBlockState(pos1);
// If the block below is the moon block
if (state.getBlock() == GCBlocks.blockMoon) {
// And is the correct metadata (moon turf)
if (state.getValue(BlockBasicMoon.BASIC_TYPE_MOON) == BlockBasicMoon.EnumBlockBasicMoon.MOON_TURF) {
// If it has been long enough since the last step
if (stats.getDistanceSinceLastStep() > 0.35) {
Vector3 pos = new Vector3(player);
// Set the footprint position to the block below and add random number to stop z-fighting
pos.y = MathHelper.floor_double(player.posY) + player.getRNG().nextFloat() / 100.0F;
// Adjust footprint to left or right depending on step count
switch(stats.getLastStep()) {
case 0:
pos.translate(new Vector3(Math.sin(Math.toRadians(-player.rotationYaw + 90)) * 0.25, 0, Math.cos(Math.toRadians(-player.rotationYaw + 90)) * 0.25));
break;
case 1:
pos.translate(new Vector3(Math.sin(Math.toRadians(-player.rotationYaw - 90)) * 0.25, 0, Math.cos(Math.toRadians(-player.rotationYaw - 90)) * 0.25));
break;
}
pos = WorldUtil.getFootprintPosition(player.worldObj, player.rotationYaw - 180, pos, new BlockVec3(player));
long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.intX() >> 4, pos.intZ() >> 4);
FootprintRenderer.addFootprint(chunkKey, GCCoreUtil.getDimensionID(player.worldObj), pos, player.rotationYaw, player.getName());
// Increment and cap step counter at 1
stats.setLastStep((stats.getLastStep() + 1) % 2);
stats.setDistanceSinceLastStep(0);
} else {
stats.setDistanceSinceLastStep(stats.getDistanceSinceLastStep() + motionSqrd);
}
}
}
}
}
use of micdoodle8.mods.galacticraft.core.dimension.WorldProviderMoon 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);
}
}
}
}
Aggregations