Java Code Examples for net.minecraft.client.Minecraft#getRenderViewEntity()
The following examples show how to use
net.minecraft.client.Minecraft#getRenderViewEntity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientProxy.java From TofuCraftReload with MIT License | 5 votes |
@Override public void spawnParticle(World world, TofuParticleType particleType, double x, double y, double z, double velX, double velY, double velZ) { Minecraft mc = Minecraft.getMinecraft(); Entity entity = mc.getRenderViewEntity(); // ignore the passed-in world, since on SP we get the integrated server world, which is not really what we want world = this.getClientWorld(); if (entity != null && mc.effectRenderer != null) { int i = mc.gameSettings.particleSetting; if (i == 1 && world.rand.nextInt(3) == 0) { i = 2; } double d0 = entity.posX - x; double d1 = entity.posY - y; double d2 = entity.posZ - z; if (d0 * d0 + d1 * d1 + d2 * d2 <= 1024D && i <= 1) { Particle particle = null; switch (particleType) { case TOFUPORTAL: particle = new ParticleTofuPortal(world, x, y, z, velX, velY, velZ); break; case ZUNDAPOWDER: particle = new ParticleZundaPowder(world, x, y, z, velX, velY, velZ); break; } if (particle != null) { mc.effectRenderer.addEffect(particle); } } } }
Example 2
Source File: HyperiumEntityRenderer.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
public void drawOutline(float part,Minecraft mc) { DrawBlockHighlightEvent drawBlockHighlightEvent = new DrawBlockHighlightEvent(((EntityPlayer) mc.getRenderViewEntity()), mc.objectMouseOver, part); EventBus.INSTANCE.post(drawBlockHighlightEvent); if (drawBlockHighlightEvent.isCancelled()) { Hyperium.INSTANCE.getHandlers().getConfigOptions().isCancelBox = true; } }
Example 3
Source File: MixinEntityRenderer.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Redirect( method = "Lnet/minecraft/client/renderer/EntityRenderer;orientCamera(F)V", at = @At( value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getRenderViewEntity()Lnet/minecraft/entity/Entity;" )) private Entity resetThingsBeforeOrientCamera(Minecraft mc, float partialTicks) { Entity entity = mc.getRenderViewEntity(); { //set up state this.vs_partialTicks = partialTicks; EntityShipMountData mountData = ValkyrienUtils.getMountedShipAndPos(entity); this.mountData = mountData.isMounted() ? mountData : null; this.eyeVector.setValue(0.0d, entity.getEyeHeight() + ( entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isPlayerSleeping() ? 0.7d : 0.0d), 0.0d); } if (this.mountData != null && this.mountData.getMountedShip().getShipRenderer().offsetPos != null) { //transform vectors Quaternion orientationQuat = this.mountData.getMountedShip().getShipRenderer() .getSmoothRotationQuat(partialTicks); double[] radians = orientationQuat.toRadians(); float moddedPitch = (float) Math.toDegrees(radians[0]); float moddedYaw = (float) Math.toDegrees(radians[1]); float moddedRoll = (float) Math.toDegrees(radians[2]); double[] orientationMatrix = RotationMatrices .getRotationMatrix(moddedPitch, moddedYaw, moddedRoll); RotationMatrices.applyTransform(orientationMatrix, this.eyeVector); this.cachedPosition.setValue(this.mountData.getMountPos()); this.mountData.getMountedShip().getShipTransformationManager().getRenderTransform() .transform(this.cachedPosition, TransformType.SUBSPACE_TO_GLOBAL); } return entity; }
Example 4
Source File: WeatherRenderer.java From TFC2 with GNU General Public License v3.0 | 4 votes |
public static void addRainParticles(Random random, int rendererUpdateCount) { Minecraft mc = Minecraft.getMinecraft(); WorldClient worldclient = mc.world; if(worldclient.provider.getDimension() != 0) return; float rainStrength = (float)WeatherManager.getInstance().getPrecipitation((int)mc.player.posX, (int)mc.player.posZ); double tempPlayer = WeatherManager.getInstance().getTemperature((int)mc.player.posX,(int)mc.player.posY, (int)mc.player.posZ); if(tempPlayer <= 0) return; if (!mc.gameSettings.fancyGraphics) { rainStrength /= 2.0F; } if (rainStrength > 0.0F) { worldclient.rand.setSeed((long)rendererUpdateCount * 312987231L); Entity entity = mc.getRenderViewEntity(); BlockPos blockpos = new BlockPos(entity); byte b0 = 10; double d0 = 0.0D; double d1 = 0.0D; double d2 = 0.0D; int i = 0; int rainParticles = Math.max((int)(100.0F * rainStrength * rainStrength), 4); if (mc.gameSettings.particleSetting == 1) { rainParticles >>= 1; } else if (mc.gameSettings.particleSetting == 2) { rainParticles = 0; } for (int k = 0; k < rainParticles; ++k) { BlockPos blockPos1 = worldclient.getPrecipitationHeight(blockpos.add(worldclient.rand.nextInt(b0) - worldclient.rand.nextInt(b0), 0, worldclient.rand.nextInt(b0) - worldclient.rand.nextInt(b0))); double temp = WeatherManager.getInstance().getTemperature(blockPos1); BlockPos blockpos2 = blockPos1.down(); IBlockState state = worldclient.getBlockState(blockpos2); Block block = worldclient.getBlockState(blockpos2).getBlock(); if (blockPos1.getY() <= blockpos.getY() + b0 && blockPos1.getY() >= blockpos.getY() - b0 && temp > 0) { float f1 = worldclient.rand.nextFloat(); float f2 = worldclient.rand.nextFloat(); AxisAlignedBB axisalignedbb = state.getBoundingBox(worldclient, blockpos2); if (block.getMaterial(state) == Material.LAVA) { mc.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)((float)blockPos1.getX() + f1), (double)((float)blockPos1.getY() + 0.1F) - axisalignedbb.minY, (double)((float)blockPos1.getZ() + f2), 0.0D, 0.0D, 0.0D, new int[0]); } else if (block.getMaterial(state) != Material.AIR) { //block.setBlockBoundsBasedOnState(worldclient, blockpos2); ++i; if (worldclient.rand.nextInt(i) == 0) { d0 = (double)((float)blockpos2.getX() + f1); d1 = (double)((float)blockpos2.getY() + 0.1F) + axisalignedbb.maxY - 1.0D; d2 = (double)((float)blockpos2.getZ() + f2); } mc.world.spawnParticle(EnumParticleTypes.WATER_DROP, (double)((float)blockpos2.getX() + f1), (double)((float)blockpos2.getY() + 0.1F) + axisalignedbb.maxY, (double)((float)blockpos2.getZ() + f2), 0.0D, 0.0D, 0.0D, new int[0]); } } } if (i > 0 && worldclient.rand.nextInt(3) < rainSoundCounter++) { rainSoundCounter = 0; if (d1 > (double)(blockpos.getY() + 1) && worldclient.getPrecipitationHeight(blockpos).getY() > MathHelper.floor((float)blockpos.getY())) { mc.world.playSound(d0, d1, d2, SoundEvents.WEATHER_RAIN_ABOVE, SoundCategory.WEATHER, 0.1F*rainStrength, 0.5F, false); } else { mc.world.playSound(d0, d1, d2, SoundEvents.WEATHER_RAIN, SoundCategory.WEATHER, 0.2F*rainStrength, 1.0F, false); } } } }