Search in sources :

Example 36 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project Hyperium by HyperiumClient.

the class YeetHandler method yeet.

public void yeet(UUID uuid) {
    WorldClient theWorld = Minecraft.getMinecraft().theWorld;
    if (theWorld == null)
        return;
    EntityPlayer player = theWorld.getPlayerEntityByUUID(uuid);
    if (player != null)
        yeets.add(new Yeet(player));
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 37 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project minecolonies by Minecolonies.

the class ClientEventHandler method renderWorldLastEvent.

/**
 * Used to catch the renderWorldLastEvent in order to draw the debug nodes for pathfinding.
 *
 * @param event the catched event.
 */
@SubscribeEvent
public void renderWorldLastEvent(@NotNull final RenderWorldLastEvent event) {
    Pathfinding.debugDraw(event.getPartialTicks());
    final Structure structure = Settings.instance.getActiveStructure();
    final WorldClient world = Minecraft.getMinecraft().world;
    final EntityPlayer player = Minecraft.getMinecraft().player;
    if (structure != null) {
        final BlockPos position = Settings.instance.getPosition();
        if (Settings.instance.getStructureName().contains(AbstractEntityAIStructure.WAYPOINT_STRING)) {
            RenderUtils.renderWayPoints(position, world, event.getPartialTicks());
        } else {
            RenderUtils.renderColonyBorder(position, world, event.getPartialTicks(), player, colonyBorder);
        }
        return;
    } else {
        if (citizen != null) {
            final Entity entityCitizen = world.getEntityByID(citizen.getEntityId());
            if (entityCitizen instanceof EntityCitizen) {
                RenderUtils.renderSigns(world, event.getPartialTicks(), citizen, player, entityCitizen.getPosition());
                ticksPassed += event.getPartialTicks();
                if (ticksPassed > Constants.TICKS_SECOND * SECONDS_TO_SHOW) {
                    ticksPassed = 0;
                    citizen = null;
                }
            } else {
                citizen = null;
                ticksPassed = 0;
            }
            return;
        }
        final ColonyView colony = ColonyManager.getClosestColonyView(world, player.getPosition());
        if (colony != null && player != null && colony.getPermissions().hasPermission(player, Action.ACCESS_HUTS)) {
            for (final CitizenDataView citizenDataView : new ArrayList<CitizenDataView>(colony.getCitizens().values())) {
                final Entity entityCitizen = world.getEntityByID(citizenDataView.getEntityId());
                if (entityCitizen instanceof EntityCitizen && entityCitizen.getPosition().distanceSq(player.getPosition()) <= 2) {
                    RenderUtils.renderSigns(world, event.getPartialTicks(), citizenDataView, player, entityCitizen.getPosition());
                    citizen = citizenDataView;
                    return;
                }
            }
        }
    }
    colonyBorder.clear();
}
Also used : Entity(net.minecraft.entity.Entity) ColonyView(com.minecolonies.coremod.colony.ColonyView) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) Structure(com.minecolonies.structures.helpers.Structure) AbstractEntityAIStructure(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIStructure) EntityCitizen(com.minecolonies.coremod.entity.EntityCitizen) WorldClient(net.minecraft.client.multiplayer.WorldClient) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 38 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project XNet by McJty.

the class RenderWorldLastEventHandler method renderCablesInt.

private static void renderCablesInt(RenderWorldLastEvent evt, Minecraft mc) {
    EntityPlayerSP p = mc.player;
    WorldClient world = mc.world;
    double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * evt.getPartialTicks();
    double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * evt.getPartialTicks();
    double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * evt.getPartialTicks();
    GlStateManager.pushMatrix();
    GlStateManager.color(1.0f, 0, 0);
    GlStateManager.glLineWidth(2);
    GlStateManager.translate(-doubleX, -doubleY, -doubleZ);
    GlStateManager.disableDepth();
    GlStateManager.disableTexture2D();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
    for (int dx = -20; dx <= 20; dx++) {
        for (int dy = -20; dy <= 20; dy++) {
            for (int dz = -20; dz <= 20; dz++) {
                BlockPos c = p.getPosition().add(dx, dy, dz);
                IBlockState state = world.getBlockState(c);
                Block block = state.getBlock();
                if (block instanceof FacadeBlock || block instanceof ConnectorBlock || block instanceof GenericCableBlock) {
                    IExtendedBlockState extendedBlockState;
                    if (state.getBlock() instanceof FacadeBlock) {
                        extendedBlockState = (IExtendedBlockState) ((FacadeBlock) state.getBlock()).getStateInternal(state, world, c);
                    } else {
                        extendedBlockState = (IExtendedBlockState) state.getBlock().getExtendedState(state, world, c);
                    }
                    FacadeBlockId facadeId = extendedBlockState.getValue(GenericCableBlock.FACADEID);
                    if (((!GeneralConfiguration.showNonFacadedCablesWhileSneaking) || (!p.isSneaking())) && facadeId == null && !(block instanceof FacadeBlock)) {
                        continue;
                    }
                    CableColor color = extendedBlockState.getValue(GenericCableBlock.COLOR);
                    float r = 0;
                    float g = 0;
                    float b = 0;
                    switch(color) {
                        case BLUE:
                            r = .4f;
                            g = .4f;
                            b = 1f;
                            break;
                        case RED:
                            r = 1f;
                            g = .4f;
                            b = .4f;
                            break;
                        case YELLOW:
                            r = 1f;
                            g = 1f;
                            b = .4f;
                            break;
                        case GREEN:
                            r = .4f;
                            g = 1f;
                            b = .4f;
                            break;
                        case ROUTING:
                            r = .7f;
                            g = .7f;
                            b = .7f;
                            break;
                    }
                    List<Rect> quads = getQuads(extendedBlockState);
                    for (Rect quad : quads) {
                        renderRect(buffer, quad, c, r, g, b, 0.5f);
                    }
                }
            }
        }
    }
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IBlockState(net.minecraft.block.state.IBlockState) FacadeBlockId(mcjty.xnet.blocks.facade.FacadeBlockId) GenericCableBlock(mcjty.xnet.blocks.generic.GenericCableBlock) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) WorldClient(net.minecraft.client.multiplayer.WorldClient) FacadeBlock(mcjty.xnet.blocks.facade.FacadeBlock) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) FacadeBlock(mcjty.xnet.blocks.facade.FacadeBlock) GenericCableBlock(mcjty.xnet.blocks.generic.GenericCableBlock) Block(net.minecraft.block.Block) ConnectorBlock(mcjty.xnet.blocks.cables.ConnectorBlock) ItemBlock(net.minecraft.item.ItemBlock) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) CableColor(mcjty.xnet.blocks.generic.CableColor) ConnectorBlock(mcjty.xnet.blocks.cables.ConnectorBlock)

Example 39 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project BetterRain by OreCruncher.

the class StormSplashRenderer method addRainParticles.

public void addRainParticles(final EntityRenderer theThis) {
    if (theThis.mc.gameSettings.particleSetting == 2)
        return;
    if (!DimensionRegistry.hasWeather(EnvironState.getWorld()))
        return;
    float rainStrengthFactor = theThis.mc.theWorld.getRainStrength(1.0F);
    if (!theThis.mc.gameSettings.fancyGraphics)
        rainStrengthFactor /= 2.0F;
    if (rainStrengthFactor <= 0.0F)
        return;
    RANDOM.setSeed((long) theThis.rendererUpdateCount * 312987231L);
    final Entity entity = theThis.mc.getRenderViewEntity();
    final WorldClient worldclient = theThis.mc.theWorld;
    final int playerX = MathHelper.floor_double(entity.posX);
    final int playerY = MathHelper.floor_double(entity.posY);
    final int playerZ = MathHelper.floor_double(entity.posZ);
    double spawnX = 0.0D;
    double spawnY = 0.0D;
    double spawnZ = 0.0D;
    int particlesSpawned = 0;
    int particleCount = (int) (ModOptions.particleCountBase * rainStrengthFactor * rainStrengthFactor);
    if (theThis.mc.gameSettings.particleSetting == 1)
        particleCount >>= 1;
    BlockPos.MutableBlockPos posXZ = new BlockPos.MutableBlockPos();
    for (int j1 = 0; j1 < particleCount; ++j1) {
        final int locX = playerX + RANDOM.nextInt(RANGE) - RANDOM.nextInt(RANGE);
        final int locZ = playerZ + RANDOM.nextInt(RANGE) - RANDOM.nextInt(RANGE);
        posXZ.set(locX, 0, locZ);
        final BlockPos precipHeight = getPrecipitationHeight(worldclient, RANGE / 2, posXZ);
        final BiomeGenBase biome = worldclient.getBiomeGenForCoords(posXZ);
        final boolean hasDust = WeatherUtils.biomeHasDust(biome);
        if (precipHeight.getY() <= playerY + RANGE && precipHeight.getY() >= playerY - RANGE && (hasDust || (BiomeRegistry.hasPrecipitation(biome) && biome.getFloatTemperature(precipHeight) >= 0.15F))) {
            final Block block = worldclient.getBlockState(precipHeight.down()).getBlock();
            final double posX = locX + RANDOM.nextFloat();
            final double posY = precipHeight.getY() + 0.1F - block.getBlockBoundsMinY();
            final double posZ = locZ + RANDOM.nextFloat();
            final EntityFX particle = getBlockParticleFX(block, hasDust, worldclient, posX, posY, posZ);
            if (particle != null)
                theThis.mc.effectRenderer.addEffect(particle);
            if (RANDOM.nextInt(++particlesSpawned) == 0) {
                spawnX = posX;
                spawnY = posY;
                spawnZ = posZ;
            }
        }
    }
    if (particlesSpawned > 0 && RANDOM.nextInt(PARTICLE_SOUND_CHANCE) < theThis.rainSoundCounter++) {
        theThis.rainSoundCounter = 0;
        playSplashSound(theThis, worldclient, entity, spawnX, spawnY, spawnZ);
    }
}
Also used : Entity(net.minecraft.entity.Entity) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.BlockPos) EntityFX(net.minecraft.client.particle.EntityFX) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) WorldClient(net.minecraft.client.multiplayer.WorldClient)

Aggregations

WorldClient (net.minecraft.client.multiplayer.WorldClient)39 Minecraft (net.minecraft.client.Minecraft)19 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)12 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)10 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)10 Entity (net.minecraft.entity.Entity)9 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 BlockPos (net.minecraft.util.math.BlockPos)7 Block (net.minecraft.block.Block)6 IBlockState (net.minecraft.block.state.IBlockState)6 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)4 IRenderHandler (net.minecraftforge.client.IRenderHandler)4 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 ItemStack (net.minecraft.item.ItemStack)3 TileEntity (net.minecraft.tileentity.TileEntity)3 BlockPos (net.minecraft.util.BlockPos)3 Function (com.google.common.base.Function)2 Random (java.util.Random)2 GuiCelestialSelection (micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection)2 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)2