Search in sources :

Example 6 with WorldClient

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

the class HamsterCompanion method onTick.

@InvokeEvent
public void onTick(TickEvent e) {
    WorldClient theWorld = Minecraft.getMinecraft().theWorld;
    if (theWorld == null)
        return;
    toAdd.forEach(this::spawnHamster);
    toAdd.clear();
    Iterator<Map.Entry<UUID, EntityHamster>> ite = hamsters.entrySet().iterator();
    while (ite.hasNext()) {
        Map.Entry<UUID, EntityHamster> next = ite.next();
        if (!worldHasEntityWithUUID(theWorld, next.getKey())) {
            theWorld.unloadEntities(Collections.singletonList(next.getValue()));
            ite.remove();
        }
    }
}
Also used : WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 7 with WorldClient

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

the class HamsterCompanion method spawnHamster.

public void spawnHamster(EntityPlayer player) {
    WorldClient theWorld = Minecraft.getMinecraft().theWorld;
    EntityHamster hamster = new EntityHamster(theWorld);
    hamster.setPosition(player.posX, player.posY, player.posZ);
    hamster.setOwnerId(player.getUniqueID().toString());
    theWorld.spawnEntityInWorld(hamster);
    hamsters.put(player.getUniqueID(), hamster);
}
Also used : WorldClient(net.minecraft.client.multiplayer.WorldClient)

Example 8 with WorldClient

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

the class EventHandler method onDebugOverlay.

/**
 * Event when the debug screen is opened. Event gets called by displayed
 * text on the screen, we only need it when f3 is clicked.
 *
 * @param event {@link net.minecraftforge.client.event.RenderGameOverlayEvent.Text}
 */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDebugOverlay(final RenderGameOverlayEvent.Text event) {
    if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
        final Minecraft mc = Minecraft.getMinecraft();
        if (mc.gameSettings.showDebugInfo) {
            final WorldClient world = mc.world;
            final EntityPlayerSP player = mc.player;
            IColony colony = ColonyManager.getIColony(world, player.getPosition());
            if (colony == null) {
                if (!ColonyManager.isTooCloseToColony(world, player.getPosition())) {
                    event.getLeft().add(LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.noCloseColony"));
                    return;
                }
                colony = ColonyManager.getClosestIColony(world, player.getPosition());
                if (colony == null) {
                    return;
                }
                event.getLeft().add(LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.nextColony", (int) Math.sqrt(colony.getDistanceSquared(player.getPosition())), ColonyManager.getMinimumDistanceBetweenTownHalls()));
                return;
            }
            event.getLeft().add(colony.getName() + " : " + LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.blocksFromCenter", (int) Math.sqrt(colony.getDistanceSquared(player.getPosition()))));
        }
    }
}
Also used : IColony(com.minecolonies.api.colony.IColony) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) WorldClient(net.minecraft.client.multiplayer.WorldClient) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project ClaySoldiersMod by SanAndreasP.

the class ClientProxy method spawnBlockParticles.

@Override
public void spawnBlockParticles(int ID, Object[] data) {
    WorldClient world = (WorldClient) this.getClientWorld();
    Random rand = new Random();
    Minecraft mc = Minecraft.getMinecraft();
    switch(ID) {
        case 0:
            mc.effectRenderer.addEffect(new EntityDiggingFX(CSMModRegistry.proxy.getClientWorld(), (Double) data[0], (Double) data[1], (Double) data[2], (Double) data[0] - (Double) data[3] - 0.5D, (Double) data[1] - (Double) data[4] - 0.5D, (Double) data[2] - (Double) data[5] - 0.5D, (Block) data[6], rand.nextInt(6), (Integer) data[7]));
            break;
    }
}
Also used : EntityDiggingFX(net.minecraft.client.particle.EntityDiggingFX) Random(java.util.Random) Block(net.minecraft.block.Block) WorldClient(net.minecraft.client.multiplayer.WorldClient) Minecraft(net.minecraft.client.Minecraft)

Example 10 with WorldClient

use of net.minecraft.client.multiplayer.WorldClient in project ClaySoldiersMod by SanAndreasP.

the class ClientProxy method spawnEntityParticles.

@Override
public void spawnEntityParticles(byte[] data, Player player) {
    WorldClient world = (WorldClient) ((EntityPlayer) player).worldObj;
    Entity entity = world.getEntityByID(getEntityIdFromByteArray(data));
    Random rand = new Random();
    Minecraft mc = Minecraft.getMinecraft();
    if (entity == null)
        return;
    switch(data[5]) {
        case 0:
            mc.effectRenderer.addEffect(new EntityNoteFX(world, entity.posX, entity.posY + 0.5D, entity.posZ, rand.nextFloat(), rand.nextFloat(), rand.nextFloat()));
            break;
        case 1:
            Vec3 vec3d = Vec3.createVectorHelper((rand.nextFloat() - 0.5D) * 0.10000000000000001D, Math.random() * 0.10000000000000001D + 0.10000000000000001D, 0.0D);
            vec3d.rotateAroundX((-entity.rotationPitch * 3.141593F) / 180F);
            vec3d.rotateAroundY((-entity.rotationYaw * 3.141593F) / 180F);
            Vec3 vec3d1 = Vec3.createVectorHelper((rand.nextFloat() - 0.5D) * 0.29999999999999999D, (-rand.nextFloat()) * 0.59999999999999998D - 0.29999999999999999D, 0.59999999999999998D);
            vec3d1.rotateAroundX((-entity.rotationPitch * 3.141593F) / 180F);
            vec3d1.rotateAroundY((-entity.rotationYaw * 3.141593F) / 180F);
            vec3d1 = vec3d1.addVector(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
            world.spawnParticle((new StringBuilder()).append("iconcrack_").append(Item.porkRaw.itemID).toString(), vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.050000000000000003D, vec3d.zCoord);
            break;
        case 2:
            // int color = 0;
            // if (entity instanceof EntityClayMan)
            // color = ((EntityClayMan)entity).teamCloth(((EntityClayMan)entity).getClayTeam());
            double a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            double b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            double c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            // mc.effectRenderer.addEffect((new EntityDiggingFX(world, a, b, c, 0.0D, 0.0D, 0.0D, Block.cloth, 0, color)));
            break;
        case 3:
            a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            mc.effectRenderer.addEffect((new EntityDiggingFX(world, a, b, c, 0.0D, 0.0D, 0.0D, Block.cloth, 0, 0)));
            break;
        case 4:
            a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            mc.effectRenderer.addEffect(new EntityDiggingFX(world, a, b, c, 0.0D, 0.0D, 0.0D, Block.glowStone, 0, 0));
            break;
        case 5:
            a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            mc.effectRenderer.addEffect(new EntityDiggingFX(world, a, b, c, 0.0D, 0.0D, 0.0D, Block.planks, 0, 0));
            break;
        case 6:
            a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            mc.effectRenderer.addEffect(new EntityDiggingFX(world, a, b, c, 0.0D, 0.0D, 0.0D, Block.blockIron, 0, 0));
            break;
        case 7:
            a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            mc.effectRenderer.addEffect(new EntityDiggingFX(world, a, b, c, 0.0D, 0.0D, 0.0D, Block.glass, 0, 0));
            break;
        case 8:
            a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            mc.effectRenderer.addEffect(new EntityDiggingFX(world, a, b, c, 0.0D, 0.0D, 0.0D, Block.blockClay, 0, 0));
            break;
        case 9:
            mc.effectRenderer.addEffect(new EntityCrit2FX(world, entity));
            break;
        case 10:
            EntityClayNexus nexus = (EntityClayNexus) entity;
            mc.effectRenderer.addEffect(new EntityNexusFX(world, nexus.posX + (rand.nextDouble() - 0.5D) * nexus.width, (nexus.posY + rand.nextDouble() * nexus.height) - 0.25D, nexus.posZ + (rand.nextDouble() - 0.5D) * nexus.width, (rand.nextDouble() - 0.5D) * 2D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2D, nexus.getTeamColor()[0], nexus.getTeamColor()[1], nexus.getTeamColor()[2]));
            break;
        case 11:
            for (int var1 = 0; var1 < 20; ++var1) {
                double var2 = rand.nextGaussian() * 0.02D;
                double var4 = rand.nextGaussian() * 0.02D;
                double var6 = rand.nextGaussian() * 0.02D;
                double var8 = 10.0D;
                world.spawnParticle("explode", entity.posX + (double) (rand.nextFloat() * entity.width * 2.0F) - (double) entity.width - var2 * var8, entity.posY + (double) (rand.nextFloat() * entity.height) - var4 * var8, entity.posZ + (double) (rand.nextFloat() * entity.width * 2.0F) - (double) entity.width - var6 * var8, var2, var4, var6);
            }
            break;
        case 12:
            a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            mc.effectRenderer.addEffect(new EntityDiggingFX(CSMModRegistry.proxy.getClientWorld(), a, b, c, 0.0D, 0.0D, 0.0D, Block.gravel, 0, 0));
            break;
        case 13:
            a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
            c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
            mc.effectRenderer.addEffect(new EntityDiggingFX(CSMModRegistry.proxy.getClientWorld(), a, b, c, 0.0D, 0.0D, 0.0D, Block.dirt, 0, 0));
            break;
        case 14:
            world.spawnParticle("reddust", entity.posX, entity.posY + 0.5F, entity.posZ, -0.4F, 1F, 0F);
            break;
        case 15:
            world.spawnParticle("reddust", entity.posX, entity.posY + 0.5F, entity.posZ, -1F, 0F, 0F);
            break;
        case 16:
            for (int j = 0; j < 4; j++) {
                a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                world.spawnParticle("reddust", a, b, c, 0.0D, 0.8D, 0.0D);
            }
            break;
        case 17:
            for (int j = 0; j < 4; j++) {
                a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                world.spawnParticle("reddust", a, b, c, 0.0D, 0.1D, 0.0D);
            }
            break;
        case 18:
            world.spawnParticle("flame", entity.posX, entity.posY + 0.1D, entity.posZ, 0.0D, 0.01D, 0.0D);
            break;
        case 19:
            world.spawnParticle("heart", entity.posX, entity.posY + 0.1D, entity.posZ, 0.0D, 0.01D, 0.0D);
            break;
        case 20:
            for (int j = 0; j < 4; j++) {
                a = entity.posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                b = entity.boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                c = entity.posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
                world.spawnParticle("slime", a, b, c, 0.0D, 0.1D, 0.0D);
            }
            break;
        case 21:
            world.spawnParticle("portal", entity.posX + (rand.nextDouble() - 0.5D) * entity.width * 0.5D, (entity.posY + rand.nextDouble() * entity.height) - 0.05D, entity.posZ + (rand.nextDouble() - 0.5D) * entity.width * 0.5D, (rand.nextDouble() - 0.5D) * 0.75D, -rand.nextDouble() * 0.5D, (rand.nextDouble() - 0.5D) * 0.75D);
            break;
    }
}
Also used : EntityDiggingFX(net.minecraft.client.particle.EntityDiggingFX) Entity(net.minecraft.entity.Entity) EntityNoteFX(net.minecraft.client.particle.EntityNoteFX) EntityClayNexus(sanandreasp.mods.ClaySoldiersMod.entity.EntityClayNexus) EntityNexusFX(sanandreasp.mods.ClaySoldiersMod.client.EntityNexusFX) WorldClient(net.minecraft.client.multiplayer.WorldClient) Minecraft(net.minecraft.client.Minecraft) Random(java.util.Random) Vec3(net.minecraft.util.Vec3) EntityCrit2FX(net.minecraft.client.particle.EntityCrit2FX)

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