use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class GameScreenCelestial method render.
@Override
public void render(int type, float ticks, float scaleX, float scaleY, IScreenManager scr) {
centreX = scaleX / 2;
centreY = scaleY / 2;
frameBx = scaleX - frameA;
frameBy = scaleY - frameA;
this.scale = Math.max(scaleX, scaleY) - 0.2F;
drawBlackBackground(0.0F);
planeEquation(frameA, frameA, 0, frameA, frameBy, 0, frameA, frameBy, 1);
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, planes);
GL11.glEnable(GL11.GL_CLIP_PLANE0);
planeEquation(frameBx, frameBy, 0, frameBx, frameA, 0, frameBx, frameA, 1);
GL11.glClipPlane(GL11.GL_CLIP_PLANE1, planes);
GL11.glEnable(GL11.GL_CLIP_PLANE1);
planeEquation(frameA, frameBy, 0, frameBx, frameBy, 0, frameBx, frameBy, 1);
GL11.glClipPlane(GL11.GL_CLIP_PLANE2, planes);
GL11.glEnable(GL11.GL_CLIP_PLANE2);
planeEquation(frameBx, frameA, 0, frameA, frameA, 0, frameA, frameA, 1);
GL11.glClipPlane(GL11.GL_CLIP_PLANE3, planes);
GL11.glEnable(GL11.GL_CLIP_PLANE3);
switch(type) {
case 2:
WorldProvider wp = scr.getWorldProvider();
CelestialBody body = null;
if (wp instanceof IGalacticraftWorldProvider) {
body = ((IGalacticraftWorldProvider) wp).getCelestialBody();
}
if (body == null) {
body = GalacticraftCore.planetOverworld;
}
drawCelestialBodies(body, ticks);
break;
case 3:
drawCelestialBodiesZ(GalacticraftCore.planetOverworld, ticks);
break;
case 4:
drawPlanetsTest(ticks);
break;
}
GL11.glDisable(GL11.GL_CLIP_PLANE3);
GL11.glDisable(GL11.GL_CLIP_PLANE2);
GL11.glDisable(GL11.GL_CLIP_PLANE1);
GL11.glDisable(GL11.GL_CLIP_PLANE0);
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class WorldUtil method getGravityFactor.
public static float getGravityFactor(Entity entity) {
if (entity.world.provider instanceof IGalacticraftWorldProvider) {
final IGalacticraftWorldProvider customProvider = (IGalacticraftWorldProvider) entity.world.provider;
float returnValue = MathHelper.sqrt(0.08F / (0.08F - customProvider.getGravity()));
if (returnValue > 2.5F) {
returnValue = 2.5F;
}
if (returnValue < 0.75F) {
returnValue = 0.75F;
}
return returnValue;
} else if (entity instanceof IAntiGrav) {
return 1F;
} else {
return 1F;
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class OreGenOtherMods method onPlanetDecorated.
@SubscribeEvent
public void onPlanetDecorated(GCCoreEventPopulate.Post event) {
this.world = event.world;
this.randomGenerator = event.rand;
this.pos = event.pos;
int dimDetected = 0;
WorldProvider prov = world.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.api.world.IGalacticraftWorldProvider in project MorePlanets by SteveKunG.
the class TeleportUtil method startNewDimension.
@Deprecated
public static void startNewDimension(EntityPlayerMP player) {
WorldServer worldOld = (WorldServer) player.world;
WorldServer worldNew = WorldDimensionHelper.getStartWorld(worldOld);
BlockPos blockpos = worldNew.getTopSolidOrLiquidBlock(worldNew.getSpawnPoint());
boolean dimChange = player.world != worldNew;
player.world.updateEntityWithOptionalForce(player, false);
int oldDimID = GCCoreUtil.getDimensionID(player.world);
ChunkPos pair = worldNew.getChunkFromChunkCoords(blockpos.getX(), blockpos.getZ()).getPos();
if (dimChange) {
try {
worldOld.getPlayerChunkMap().removePlayer(player);
} catch (Exception e) {
e.printStackTrace();
}
player.closeScreen();
player.dimension = GCCoreUtil.getDimensionID(worldNew);
player.connection.sendPacket(new SPacketRespawn(GCCoreUtil.getDimensionID(worldNew), player.world.getDifficulty(), player.world.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
worldOld.playerEntities.remove(player);
worldOld.updateAllPlayersSleepingFlag();
if (player.addedToChunk && worldOld.getChunkProvider().chunkExists(player.chunkCoordX, player.chunkCoordZ)) {
Chunk chunkOld = worldOld.getChunkFromChunkCoords(player.chunkCoordX, player.chunkCoordZ);
chunkOld.removeEntity(player);
chunkOld.setModified(true);
}
worldOld.loadedEntityList.remove(player);
worldOld.onEntityRemoved(player);
worldNew.spawnEntity(player);
player.setWorld(worldNew);
MorePlanetsCore.PROXY.resetFloatingTick(player);
if (!(worldNew.provider instanceof IGalacticraftWorldProvider)) {
MPLog.error("{} is not space world!", ConfigManagerMP.startedPlanet);
throw new RuntimeException(ConfigManagerMP.startedPlanet + " is not space world!");
}
if (worldNew.provider instanceof IStartedDimension) {
IStartedDimension dimension = (IStartedDimension) worldNew.provider;
MPLog.debug("Setting up player gear");
dimension.setup(player);
} else {
GCPlayerStats stats = GCPlayerStats.get(player);
MPLog.debug("Setting up player gear for Non-IStartedDimension world");
// Knows how to build T2 rocket
SchematicRegistry.unlockNewPage(player, new ItemStack(GCItems.schematic, 1, 1));
// Knows how to build T3 rocket
SchematicRegistry.unlockNewPage(player, new ItemStack(MarsItems.schematic, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(0, new ItemStack(GCItems.oxMask, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(2, new ItemStack(GCItems.oxTankHeavy, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(3, new ItemStack(GCItems.oxTankHeavy, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
stats.getExtendedInventory().setInventorySlotContents(6, new ItemStack(AsteroidsItems.thermalPadding, 1, 0));
stats.getExtendedInventory().setInventorySlotContents(7, new ItemStack(AsteroidsItems.thermalPadding, 1, 1));
stats.getExtendedInventory().setInventorySlotContents(8, new ItemStack(AsteroidsItems.thermalPadding, 1, 2));
stats.getExtendedInventory().setInventorySlotContents(9, new ItemStack(AsteroidsItems.thermalPadding, 1, 3));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
}
worldNew.getChunkProvider().loadChunk(pair.x, pair.z);
worldNew.updateEntityWithOptionalForce(player, false);
player.setLocationAndAngles(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 15 * 20, 5));
player.mcServer.getPlayerList().preparePlayer(player, worldNew);
player.connection.setPlayerLocation(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.interactionManager.setWorld(worldNew);
player.mcServer.getPlayerList().updateTimeAndWeatherForPlayer(player, worldNew);
player.mcServer.getPlayerList().syncPlayerInventory(player);
for (Object o : player.getActivePotionEffects()) {
PotionEffect potion = (PotionEffect) o;
player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potion));
}
player.connection.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
} else {
player.closeScreen();
worldNew.updateEntityWithOptionalForce(player, false);
player.connection.setPlayerLocation(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.setLocationAndAngles(blockpos.getX(), blockpos.getY() + 16.0D, blockpos.getZ(), player.rotationYaw, player.rotationPitch);
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 15 * 20, 5));
worldNew.updateEntityWithOptionalForce(player, false);
}
FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDimID, GCCoreUtil.getDimensionID(worldNew));
if (player.onGround && player.getBedLocation(GCCoreUtil.getDimensionID(player.world)) == null) {
int i = 30000000;
int j = Math.min(i, Math.max(-i, MathHelper.floor(player.posX + 0.5D)));
int k = Math.min(256, Math.max(0, MathHelper.floor(player.posY + 1.5D)));
int l = Math.min(i, Math.max(-i, MathHelper.floor(player.posZ + 0.5D)));
BlockPos coords = new BlockPos(j, k, l);
player.setSpawnChunk(coords, true, GCCoreUtil.getDimensionID(player.world));
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project MorePlanets by SteveKunG.
the class TileEntityTreasureChestMP method update.
@Override
public void update() {
int i = this.pos.getX();
int j = this.pos.getY();
int k = this.pos.getZ();
++this.ticksSinceSync;
float f;
if (this.locked) {
this.numPlayersUsing = 0;
}
if (!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + i + j + k) % 200 == 0) {
this.numPlayersUsing = 0;
f = 5.0F;
List list = this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(i - f, j - f, k - f, i + 1 + f, j + 1 + f, k + 1 + f));
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
if (entityplayer.openContainer instanceof ContainerChest) {
IInventory iinventory = ((ContainerChest) entityplayer.openContainer).getLowerChestInventory();
if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest) iinventory).isPartOfLargeChest(this)) {
++this.numPlayersUsing;
}
}
}
}
this.prevLidAngle = this.lidAngle;
f = this.world.provider instanceof IGalacticraftWorldProvider ? 0.05F : 0.1F;
double d2;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F) {
double d1 = i + 0.5D;
d2 = k + 0.5D;
this.world.playSound((EntityPlayer) null, d1, j + 0.5D, d2, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.provider instanceof IGalacticraftWorldProvider ? this.world.rand.nextFloat() * 0.1F + 0.6F : this.world.rand.nextFloat() * 0.1F + 0.9F);
}
if ((this.numPlayersUsing == 0 || this.locked) && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
float f1 = this.lidAngle;
if (this.numPlayersUsing == 0 || this.locked) {
this.lidAngle -= f;
} else {
this.lidAngle += f;
}
if (this.lidAngle > 1.0F) {
this.lidAngle = 1.0F;
}
float f2 = 0.5F;
if (this.lidAngle < f2 && f1 >= f2) {
d2 = i + 0.5D;
double d0 = k + 0.5D;
this.world.playSound((EntityPlayer) null, d2, j + 0.5D, d0, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.provider instanceof IGalacticraftWorldProvider ? this.world.rand.nextFloat() * 0.1F + 0.6F : this.world.rand.nextFloat() * 0.1F + 0.9F);
}
if (this.lidAngle < 0.0F) {
this.lidAngle = 0.0F;
}
}
super.update();
}
Aggregations