use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class BlockIceAsteroids method harvestBlock.
@Override
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack tool) {
player.addStat(StatList.getBlockStats(this));
player.addExhaustion(0.025F);
if (this.canSilkHarvest(worldIn, pos, worldIn.getBlockState(pos), player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
items.add(this.getSilkTouchDrop(state));
ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
for (ItemStack is : items) {
Block.spawnAsEntity(worldIn, pos, is);
}
} else {
if (worldIn.provider.getDimension() == -1 || worldIn.provider instanceof IGalacticraftWorldProvider) {
worldIn.setBlockToAir(pos);
return;
}
int i1 = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, tool);
harvesters.set(player);
this.dropBlockAsItem(worldIn, pos, state, i1);
harvesters.set(null);
IBlockState state1 = worldIn.getBlockState(pos.down());
Material material = state1.getMaterial();
if (material.blocksMovement() || material.isLiquid()) {
worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
}
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class TickHandlerClient method onRenderTick.
@SubscribeEvent
public void onRenderTick(RenderTickEvent event) {
final Minecraft minecraft = FMLClientHandler.instance().getClient();
final EntityPlayerSP player = minecraft.player;
final EntityPlayerSP playerBaseClient = PlayerUtil.getPlayerBaseClientFromPlayer(player, false);
if (player == null || playerBaseClient == null) {
return;
}
GCPlayerStatsClient stats = GCPlayerStatsClient.get(playerBaseClient);
if (event.phase == Phase.END) {
if (minecraft.currentScreen instanceof GuiIngameMenu) {
int i = Mouse.getEventX() * minecraft.currentScreen.width / minecraft.displayWidth;
int j = minecraft.currentScreen.height - Mouse.getEventY() * minecraft.currentScreen.height / minecraft.displayHeight - 1;
int k = Mouse.getEventButton();
int deltaColor = 0;
if (i > minecraft.currentScreen.width - 100 && j > minecraft.currentScreen.height - 35) {
deltaColor = 20;
if (k == 0) {
if (Mouse.getEventButtonState()) {
minecraft.displayGuiScreen(new GuiNewSpaceRace(playerBaseClient));
}
}
}
this.drawGradientRect(minecraft.currentScreen.width - 100, minecraft.currentScreen.height - 35, minecraft.currentScreen.width, minecraft.currentScreen.height, ColorUtil.to32BitColor(150, 10 + deltaColor, 10 + deltaColor, 10 + deltaColor), ColorUtil.to32BitColor(250, 10 + deltaColor, 10 + deltaColor, 10 + deltaColor));
minecraft.fontRenderer.drawString(GCCoreUtil.translate("gui.space_race.create.title.name.0"), minecraft.currentScreen.width - 50 - minecraft.fontRenderer.getStringWidth(GCCoreUtil.translate("gui.space_race.create.title.name.0")) / 2, minecraft.currentScreen.height - 26, ColorUtil.to32BitColor(255, 240, 240, 240));
minecraft.fontRenderer.drawString(GCCoreUtil.translate("gui.space_race.create.title.name.1"), minecraft.currentScreen.width - 50 - minecraft.fontRenderer.getStringWidth(GCCoreUtil.translate("gui.space_race.create.title.name.1")) / 2, minecraft.currentScreen.height - 16, ColorUtil.to32BitColor(255, 240, 240, 240));
Gui.drawRect(minecraft.currentScreen.width - 100, minecraft.currentScreen.height - 35, minecraft.currentScreen.width - 99, minecraft.currentScreen.height, ColorUtil.to32BitColor(255, 0, 0, 0));
Gui.drawRect(minecraft.currentScreen.width - 100, minecraft.currentScreen.height - 35, minecraft.currentScreen.width, minecraft.currentScreen.height - 34, ColorUtil.to32BitColor(255, 0, 0, 0));
}
ClientProxyCore.playerPosX = player.prevPosX + (player.posX - player.prevPosX) * event.renderTickTime;
ClientProxyCore.playerPosY = player.prevPosY + (player.posY - player.prevPosY) * event.renderTickTime;
ClientProxyCore.playerPosZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.renderTickTime;
ClientProxyCore.playerRotationYaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * event.renderTickTime;
ClientProxyCore.playerRotationPitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.renderTickTime;
if (minecraft.currentScreen == null && minecraft.gameSettings.thirdPersonView != 0 && !minecraft.gameSettings.hideGUI) {
if (player.getRidingEntity() instanceof EntitySpaceshipBase) {
OverlayRocket.renderSpaceshipOverlay(minecraft, ((EntitySpaceshipBase) player.getRidingEntity()).getSpaceshipGui());
}
if (player.getRidingEntity() instanceof EntityLander) {
OverlayLander.renderLanderOverlay(minecraft, TickHandlerClient.tickCount);
}
if (player.getRidingEntity() instanceof EntityAutoRocket) {
OverlayDockingRocket.renderDockingOverlay(minecraft, TickHandlerClient.tickCount);
}
if (player.getRidingEntity() instanceof EntitySpaceshipBase && !((EntitySpaceshipBase) minecraft.player.getRidingEntity()).getLaunched()) {
OverlayLaunchCountdown.renderCountdownOverlay(minecraft);
}
}
if (player.world.provider instanceof IGalacticraftWorldProvider && OxygenUtil.shouldDisplayTankGui(minecraft.currentScreen) && OxygenUtil.noAtmosphericCombustion(player.world.provider) && !(playerBaseClient.isCreative() || playerBaseClient.isSpectator()) && !minecraft.gameSettings.showDebugInfo) {
int var6 = (TickHandlerClient.airRemaining - 90) * -1;
if (TickHandlerClient.airRemaining <= 0) {
var6 = 90;
}
int var7 = (TickHandlerClient.airRemaining2 - 90) * -1;
if (TickHandlerClient.airRemaining2 <= 0) {
var7 = 90;
}
int thermalLevel = stats.getThermalLevel() + 22;
OverlayOxygenTanks.renderOxygenTankIndicator(minecraft, thermalLevel, var6, var7, !ConfigManagerCore.oxygenIndicatorLeft, !ConfigManagerCore.oxygenIndicatorBottom, Math.abs(thermalLevel - 22) >= 10 && !stats.isThermalLevelNormalising());
}
if (playerBaseClient != null && player.world.provider instanceof IGalacticraftWorldProvider && !stats.isOxygenSetupValid() && OxygenUtil.noAtmosphericCombustion(player.world.provider) && minecraft.currentScreen == null && !minecraft.gameSettings.hideGUI && !(playerBaseClient.isCreative() || playerBaseClient.isSpectator())) {
OverlayOxygenWarning.renderOxygenWarningOverlay(minecraft, TickHandlerClient.tickCount);
}
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider 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.world;
final EntityPlayerSP player = minecraft.player;
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) {
BubbleRenderer.clearBubbles();
for (TileEntity tile : player.world.tickableTileEntities) {
if (tile instanceof IBubbleProviderColored) {
BubbleRenderer.addBubble((IBubbleProviderColored) tile);
}
}
if (updateJEIhiding) {
updateJEIhiding = false;
// Update JEI to hide the ingot compressor recipe for GC steel in hard mode
// Update JEI to hide adventure mode recipes when not in adventure mode
GalacticraftJEI.updateHidden(CompressorRecipes.steelIngotsPresent && ConfigManagerCore.hardMode && !ConfigManagerCore.challengeRecipes, !ConfigManagerCore.challengeRecipes);
}
for (List<Footprint> fpList : FootprintRenderer.footprints.values()) {
Iterator<Footprint> fpIt = fpList.iterator();
while (fpIt.hasNext()) {
Footprint fp = fpIt.next();
fp.age += 20;
fp.lightmapVal = player.world.getCombinedLight(new BlockPos(fp.position.x, fp.position.y, fp.position.z), 0);
if (fp.age >= Footprint.MAX_AGE) {
fpIt.remove();
}
}
}
if (!player.inventory.armorItemInSlot(3).isEmpty() && player.inventory.armorItemInSlot(3).getItem() instanceof ISensorGlassesArmor) {
ClientProxyCore.valueableBlocks.clear();
for (int i = -4; i < 5; i++) {
int x = MathHelper.floor(player.posX + i);
for (int j = -4; j < 5; j++) {
int y = MathHelper.floor(player.posY + j);
for (int k = -4; k < 5; k++) {
int z = MathHelper.floor(player.posZ + k);
BlockPos pos = new BlockPos(x, y, z);
IBlockState state = player.world.getBlockState(pos);
final Block block = state.getBlock();
if (block.getMaterial(state) != 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(player.posX), MathHelper.floor(player.posY), MathHelper.floor(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.world, (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.getRidingEntity() instanceof EntitySpaceshipBase) {
inSpaceShip = true;
EntitySpaceshipBase rocket = (EntitySpaceshipBase) player.getRidingEntity();
if (rocket.prevRotationPitch != rocket.rotationPitch || rocket.prevRotationYaw != rocket.rotationYaw) {
GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(player.getRidingEntity()));
}
}
if (world != null) {
if (world.provider instanceof WorldProviderSurface) {
if (world.provider.getSkyRenderer() == null && inSpaceShip && player.getRidingEntity().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.getRidingEntity();
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().player);
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.isKeyDown();
if (!isPressed) {
ClientProxyCore.lastSpacebarDown = false;
}
if (player.getRidingEntity() != null && isPressed && !ClientProxyCore.lastSpacebarDown) {
GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_IGNITE_ROCKET, GCCoreUtil.getDimensionID(player.world), 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