use of micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus 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.theWorld;
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());
}
}
}
}
use of micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus in project Galacticraft by micdoodle8.
the class TickHandlerClientVenus method onPlayerTick.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
final Minecraft minecraft = FMLClientHandler.instance().getClient();
final EntityPlayerSP player = minecraft.thePlayer;
if (player == event.player) {
if (!ConfigManagerVenus.disableAmbientLightning) {
Iterator<Map.Entry<BlockPos, Integer>> it = lightning.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<BlockPos, Integer> entry = it.next();
int val = entry.getValue();
if (val - 1 <= 0) {
it.remove();
} else {
entry.setValue(val - 1);
}
}
if (player.getRNG().nextInt(500) == 0 && minecraft.theWorld.provider instanceof WorldProviderVenus) {
double freq = player.getRNG().nextDouble() * Math.PI * 2.0F;
double dist = 180.0F;
double dX = dist * Math.cos(freq);
double dZ = dist * Math.sin(freq);
double posX = player.posX + dX;
double posY = 70;
double posZ = player.posZ + dZ;
minecraft.theWorld.playSound(posX, posY, posZ, "ambient.weather.thunder", 1000.0F, 1.0F + player.getRNG().nextFloat() * 0.2F, false);
lightning.put(new BlockPos(posX, posY, posZ), 20);
}
}
}
}
use of micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus in project Galacticraft by micdoodle8.
the class TileEntitySolar method update.
@Override
public void update() {
if (!this.initialised) {
int metadata = this.getBlockMetadata();
if (metadata >= BlockSolar.ADVANCED_METADATA) {
this.storage.setCapacity(30000);
this.setTierGC(2);
}
this.initialised = true;
}
if (!this.initialisedMulti) {
this.initialisedMulti = this.initialiseMultiTiles(this.getPos(), this.worldObj);
}
if (!this.worldObj.isRemote) {
this.receiveEnergyGC(null, this.generateWatts, false);
}
super.update();
if (!this.worldObj.isRemote) {
this.recharge(this.containingItems[0]);
if (this.disableCooldown > 0) {
this.disableCooldown--;
}
if (!this.getDisabled(0) && this.ticks % 20 == 0) {
this.solarStrength = 0;
if (this.worldObj.isDaytime() && (this.worldObj.provider instanceof IGalacticraftWorldProvider || !this.worldObj.isRaining() && !this.worldObj.isThundering())) {
double distance = 100.0D;
double sinA = -Math.sin((this.currentAngle - 77.5D) / Constants.RADIANS_TO_DEGREES_D);
double cosA = Math.abs(Math.cos((this.currentAngle - 77.5D) / Constants.RADIANS_TO_DEGREES_D));
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
if (this.tierGC == 1) {
if (this.worldObj.canBlockSeeSky(this.getPos().add(x, 2, z))) {
boolean valid = true;
for (int y = this.getPos().getY() + 3; y < 256; y++) {
Block block = this.worldObj.getBlockState(new BlockPos(this.getPos().getX() + x, y, this.getPos().getZ() + z)).getBlock();
if (block.isOpaqueCube()) {
valid = false;
break;
}
}
if (valid) {
this.solarStrength++;
}
}
} else {
boolean valid = true;
BlockVec3 blockVec = new BlockVec3(this).translate(x, 3, z);
for (double d = 0.0D; d < distance; d++) {
BlockVec3 blockAt = blockVec.clone().translate((int) (d * sinA), (int) (d * cosA), 0);
Block block = blockAt.getBlock(this.worldObj);
if (block.isOpaqueCube()) {
valid = false;
break;
}
}
if (valid) {
this.solarStrength++;
}
}
}
}
}
}
}
float angle = this.worldObj.getCelestialAngle(1.0F) - 0.7845194F < 0 ? 1.0F - 0.7845194F : -0.7845194F;
float celestialAngle = (this.worldObj.getCelestialAngle(1.0F) + angle) * 360.0F;
if (!(this.worldObj.provider instanceof WorldProviderSpaceStation))
celestialAngle += 12.5F;
if (GalacticraftCore.isPlanetsLoaded && this.worldObj.provider instanceof WorldProviderVenus)
celestialAngle = 180F - celestialAngle;
celestialAngle %= 360;
boolean isDaytime = this.worldObj.isDaytime() && (celestialAngle < 180.5F || celestialAngle > 359.5F) || this.worldObj.provider instanceof WorldProviderSpaceStation;
if (this.tierGC == 1) {
if (!isDaytime || this.worldObj.isRaining() || this.worldObj.isThundering()) {
this.targetAngle = 77.5F + 180.0F;
} else {
this.targetAngle = 77.5F;
}
} else {
if (!isDaytime || this.worldObj.isRaining() || this.worldObj.isThundering()) {
this.targetAngle = 77.5F + 180F;
} else if (celestialAngle > 27.5F && celestialAngle < 152.5F) {
float difference = this.targetAngle - celestialAngle + 12.5F;
this.targetAngle -= difference / 20.0F;
} else if (celestialAngle <= 27.5F || celestialAngle > 270F) {
this.targetAngle = 15F;
} else if (celestialAngle >= 152.5F) {
this.targetAngle = 140F;
}
}
float difference = this.targetAngle - this.currentAngle;
this.currentAngle += difference / 20.0F;
if (!this.worldObj.isRemote) {
int generated = this.getGenerate();
if (generated > 0) {
this.generateWatts = Math.min(Math.max(generated, 0), TileEntitySolar.MAX_GENERATE_WATTS);
} else {
this.generateWatts = 0;
}
}
this.produce();
}
use of micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus in project MorePlanets by SteveKunG.
the class TeleportUtils method teleportPlayerToPlanet.
public static EntityPlayer teleportPlayerToPlanet(EntityPlayerMP player, MinecraftServer server, int sourceDim, int targetDim) {
WorldServer sourceWorld = server.getWorld(sourceDim);
WorldServer targetWorld = server.getWorld(targetDim);
BlockPos spawnPos = targetWorld.getTopSolidOrLiquidBlock(targetWorld.getSpawnPoint());
PlayerList playerList = server.getPlayerList();
GCPlayerStats stats = GCPlayerStats.get(player);
InventoryExtended inv = stats.getExtendedInventory();
player.dimension = targetDim;
player.connection.sendPacket(new SPacketRespawn(player.dimension, targetWorld.getDifficulty(), targetWorld.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
playerList.updatePermissionLevel(player);
sourceWorld.removeEntityDangerously(player);
player.isDead = false;
// world transfer
player.setLocationAndAngles(spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), player.rotationYaw, player.rotationPitch);
player.connection.setPlayerLocation(spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), player.rotationYaw, player.rotationPitch);
targetWorld.spawnEntity(player);
targetWorld.updateEntityWithOptionalForce(player, false);
player.setWorld(targetWorld);
// prevent kicked from LAN or server world
MorePlanetsMod.PROXY.resetFloatingTick(player);
playerList.preparePlayer(player, sourceWorld);
player.connection.setPlayerLocation(spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), player.rotationYaw, player.rotationPitch);
player.interactionManager.setWorld(targetWorld);
player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));
playerList.updateTimeAndWeatherForPlayer(player, targetWorld);
playerList.syncPlayerInventory(player);
if (targetWorld.provider instanceof IStartedDimension) {
IStartedDimension dimension = (IStartedDimension) targetWorld.provider;
LoggerMP.info("Setting up survival player gear");
dimension.setup(player);
} else if (targetWorld.provider instanceof WorldProviderMoon) {
LoggerMP.info("Setting up default survival player gear for Moon");
inv.setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
inv.setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
inv.setInventorySlotContents(2, new ItemStack(GCItems.oxTankMedium));
inv.setInventorySlotContents(3, new ItemStack(GCItems.oxTankMedium));
inv.setInventorySlotContents(4, new ItemStack(GCItems.parachute));
inv.setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.LOG, 32 + player.world.rand.nextInt(32)));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.COBBLESTONE, 32 + player.world.rand.nextInt(32)));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.DIRT, 16));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.SAPLING, 8 + player.world.rand.nextInt(8)));
player.inventory.addItemStackToInventory(new ItemStack(Items.IRON_INGOT, 32 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.WHEAT_SEEDS, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.POTATO, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.CARROT, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.WATER_BUCKET));
player.inventory.addItemStackToInventory(new ItemStack(Items.WATER_BUCKET));
player.inventory.addItemStackToInventory(new ItemStack(GCBlocks.landingPad, 9));
ItemStack rocket = new ItemStack(GCItems.rocketTier1);
rocket.setTagCompound(new NBTTagCompound());
rocket.getTagCompound().setInteger("RocketFuel", 1000);
player.inventory.addItemStackToInventory(rocket);
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
} else if (targetWorld.provider instanceof WorldProviderMars) {
LoggerMP.info("Setting up default survival player gear for Mars");
// Knows how to build T2 rocket
SchematicRegistry.unlockNewPage(player, new ItemStack(GCItems.schematic, 1, 1));
inv.setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
inv.setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
inv.setInventorySlotContents(2, new ItemStack(GCItems.oxTankMedium));
inv.setInventorySlotContents(3, new ItemStack(GCItems.oxTankMedium));
inv.setInventorySlotContents(4, new ItemStack(GCItems.parachute));
inv.setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
inv.setInventorySlotContents(6, new ItemStack(AsteroidsItems.thermalPadding));
inv.setInventorySlotContents(7, new ItemStack(AsteroidsItems.thermalPadding, 1, 1));
inv.setInventorySlotContents(8, new ItemStack(AsteroidsItems.thermalPadding, 1, 2));
inv.setInventorySlotContents(9, new ItemStack(AsteroidsItems.thermalPadding, 1, 3));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.LOG, 32 + player.world.rand.nextInt(32)));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.COBBLESTONE, 32 + player.world.rand.nextInt(32)));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.DIRT, 16));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.SAPLING, 8 + player.world.rand.nextInt(8)));
player.inventory.addItemStackToInventory(new ItemStack(Items.IRON_INGOT, 32 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.WHEAT_SEEDS, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.POTATO, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.CARROT, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.WATER_BUCKET));
player.inventory.addItemStackToInventory(new ItemStack(Items.WATER_BUCKET));
player.inventory.addItemStackToInventory(new ItemStack(GCBlocks.landingPad, 9));
ItemStack rocket = new ItemStack(MarsItems.rocketMars);
rocket.setTagCompound(new NBTTagCompound());
rocket.getTagCompound().setInteger("RocketFuel", 1000);
player.inventory.addItemStackToInventory(rocket);
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
} else if (targetWorld.provider instanceof WorldProviderVenus) {
LoggerMP.info("Setting up default survival player gear for Venus");
// 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));
inv.setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
inv.setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
inv.setInventorySlotContents(2, new ItemStack(GCItems.oxTankHeavy));
inv.setInventorySlotContents(3, new ItemStack(GCItems.oxTankHeavy));
inv.setInventorySlotContents(4, new ItemStack(GCItems.parachute));
inv.setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
inv.setInventorySlotContents(6, new ItemStack(VenusItems.thermalPaddingTier2));
inv.setInventorySlotContents(7, new ItemStack(VenusItems.thermalPaddingTier2, 1, 1));
inv.setInventorySlotContents(8, new ItemStack(VenusItems.thermalPaddingTier2, 1, 2));
inv.setInventorySlotContents(9, new ItemStack(VenusItems.thermalPaddingTier2, 1, 3));
inv.setInventorySlotContents(10, new ItemStack(VenusItems.basicItem));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.LOG, 32 + player.world.rand.nextInt(32)));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.COBBLESTONE, 32 + player.world.rand.nextInt(32)));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.DIRT, 16));
player.inventory.addItemStackToInventory(new ItemStack(Blocks.SAPLING, 8 + player.world.rand.nextInt(8)));
player.inventory.addItemStackToInventory(new ItemStack(Items.IRON_INGOT, 32 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.WHEAT_SEEDS, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.POTATO, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.CARROT, 16 + player.world.rand.nextInt(16)));
player.inventory.addItemStackToInventory(new ItemStack(Items.WATER_BUCKET));
player.inventory.addItemStackToInventory(new ItemStack(Items.WATER_BUCKET));
player.inventory.addItemStackToInventory(new ItemStack(GCBlocks.landingPad, 9));
ItemStack rocket = new ItemStack(AsteroidsItems.tier3Rocket);
rocket.setTagCompound(new NBTTagCompound());
rocket.getTagCompound().setInteger("RocketFuel", 1000);
player.inventory.addItemStackToInventory(rocket);
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
} else if (targetWorld.provider instanceof WorldProviderAsteroids) {
LoggerMP.info("Setting up default survival player gear for Asteroids");
ITeleportType type = GalacticraftRegistry.getTeleportTypeForDimension(targetWorld.provider.getClass());
Vector3 spawnPosVec = type.getPlayerSpawnLocation(targetWorld, player);
ChunkPos pair = targetWorld.getChunk(spawnPosVec.intX() >> 4, spawnPosVec.intZ() >> 4).getPos();
player.setLocationAndAngles(spawnPosVec.x, spawnPosVec.y, spawnPosVec.z, player.rotationYaw, player.rotationPitch);
player.setSpawnChunk(new BlockPos(spawnPosVec.intX(), spawnPosVec.intY(), spawnPosVec.intZ()), true, GCCoreUtil.getDimensionID(targetWorld));
targetWorld.getChunkProvider().loadChunk(pair.x, pair.z);
type.setupAdventureSpawn(player);
type.onSpaceDimensionChanged(targetWorld, player, false);
} else {
LoggerMP.info("Setting up default survival 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));
inv.setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
inv.setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
inv.setInventorySlotContents(2, new ItemStack(GCItems.oxTankHeavy));
inv.setInventorySlotContents(3, new ItemStack(GCItems.oxTankHeavy));
inv.setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
inv.setInventorySlotContents(6, new ItemStack(AsteroidsItems.thermalPadding));
inv.setInventorySlotContents(7, new ItemStack(AsteroidsItems.thermalPadding, 1, 1));
inv.setInventorySlotContents(8, new ItemStack(AsteroidsItems.thermalPadding, 1, 2));
inv.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));
}
player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 15 * 20, 5));
player.getActivePotionEffects().forEach(potion -> player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potion)));
player.connection.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
player.connection.sendPacket(new SPacketSpawnPosition(spawnPos));
AttributeMap attributemap = (AttributeMap) player.getAttributeMap();
Collection<IAttributeInstance> watchedAttribs = attributemap.getWatchedAttributes();
if (!watchedAttribs.isEmpty()) {
player.connection.sendPacket(new SPacketEntityProperties(player.getEntityId(), watchedAttribs));
}
FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, sourceDim, targetDim);
if (!(targetWorld.provider instanceof WorldProviderAsteroids)) {
player.setLocationAndAngles(spawnPos.getX(), spawnPos.getY(), spawnPos.getZ(), player.rotationYaw, player.rotationPitch);
player.setSpawnChunk(spawnPos, true, GCCoreUtil.getDimensionID(player.world));
}
if (!(targetWorld.provider instanceof WorldProviderAsteroids) && player.onGround && player.getBedLocation(GCCoreUtil.getDimensionID(player.world)) == null) {
int i = 30000000;
int x = Math.min(i, Math.max(-i, MathHelper.floor(player.posX + 0.5D)));
int y = Math.min(256, Math.max(0, MathHelper.floor(player.posY + 1.5D)));
int z = Math.min(i, Math.max(-i, MathHelper.floor(player.posZ + 0.5D)));
BlockPos spawnChunkPos = targetWorld.getTopSolidOrLiquidBlock(new BlockPos(x, y, z));
player.setSpawnChunk(spawnChunkPos, true, GCCoreUtil.getDimensionID(player.world));
}
GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMP(EnumSimplePacketMP.C_RELOAD_RENDERER, player.dimension), player);
GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMP(EnumSimplePacketMP.C_MESSAGE_SURVIVAL_PLANET, player.dimension, new Object[] { WorldUtil.getProviderForDimensionServer(targetDim).getDimensionType().getName() }), player);
return player;
}
Aggregations