Java Code Examples for net.minecraftforge.api.distmarker.Dist#CLIENT

The following examples show how to use net.minecraftforge.api.distmarker.Dist#CLIENT . 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: MiningGadget.java    From MiningGadgets with MIT License 5 votes vote down vote up
@OnlyIn(Dist.CLIENT)
public void playLoopSound(LivingEntity player, ItemStack stack) {
    float volume = MiningProperties.getVolume(stack);
    PlayerEntity myplayer = Minecraft.getInstance().player;
    if (myplayer.equals(player)) {
        if (volume != 0.0f) {
            if (laserLoopSound == null) {
                laserLoopSound = new LaserLoopSound((PlayerEntity) player, volume);
                Minecraft.getInstance().getSoundHandler().play(laserLoopSound);
            }
        }
    }
}
 
Example 2
Source File: GuiOverlay.java    From XRay-Mod with GNU General Public License v3.0 5 votes vote down vote up
@OnlyIn(Dist.CLIENT)
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void RenderGameOverlayEvent(RenderGameOverlayEvent event) {
    // Draw Indicator
    if(!Controller.isXRayActive() || !Configuration.general.showOverlay.get() || event.isCanceled() || event.getType() != RenderGameOverlayEvent.ElementType.TEXT )
        return;

    RenderSystem.color3f(0, 255, 0);
    XRay.mc.getTextureManager().bindTexture(circle);
    Screen.func_238463_a_(event.getMatrixStack(), 5, 5, 0f, 0f, 5, 5, 5, 5); // @mcp: func_238463_a_ = blit (7 parms) =

    // @mcp: func_238405_a_ = drawStringWithShadow
    XRay.mc.fontRenderer.func_238405_a_(event.getMatrixStack(), I18n.format("xray.overlay"), 15, 4, 0xffffffff);
}
 
Example 3
Source File: BlockRenderingRegistry.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public static void init() {
    if (!initialized) {
        Minecraft mc = Minecraft.getInstance();
        BlockRendererDispatcher parentDispatcher = mc.getBlockRendererDispatcher();
        mc.blockRenderDispatcher = new CCBlockRendererDispatcher(parentDispatcher, mc.getBlockColors());
        initialized = true;
    }
}
 
Example 4
Source File: CustomParticleHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@link Block#addHitEffects}
 * Provided the model bound is an instance of IModelParticleProvider, you will have landing particles just handled for you.
 * Use the default PerspectiveModel implementations inside CCL, Destroy effects will just be handled for you.
 *
 * @param world   The world.
 * @param pos     The position of the block.
 * @param manager The ParticleManager.
 * @return True if particles were added, basically just return the result of this method inside {@link Block#addHitEffects}
 */
@OnlyIn (Dist.CLIENT)
public static boolean handleDestroyEffects(World world, BlockPos pos, BlockState state, ParticleManager manager) {
    BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes();
    IBakedModel model = modelShapes.getModel(state);
    if (model instanceof IModelParticleProvider) {
        IModelData modelData = ModelDataManager.getModelData(world, pos);
        Cuboid6 bounds = new Cuboid6(state.getShape(world, pos).getBoundingBox());
        addBlockDestroyEffects(world, bounds.add(pos), new ArrayList<>(((IModelParticleProvider) model).getDestroyEffects(state, world, pos, modelData)), manager);
        return true;
    }
    return false;
}
 
Example 5
Source File: CustomParticleHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public static void addBlockHitEffects(World world, Cuboid6 bounds, Direction side, TextureAtlasSprite icon, ParticleManager particleManager) {
    float border = 0.1F;
    Vector3 diff = bounds.max.copy().subtract(bounds.min).add(-2 * border);
    diff.x *= world.rand.nextDouble();
    diff.y *= world.rand.nextDouble();
    diff.z *= world.rand.nextDouble();
    Vector3 pos = diff.add(bounds.min).add(border);

    if (side == Direction.DOWN) {
        diff.y = bounds.min.y - border;
    }
    if (side == Direction.UP) {
        diff.y = bounds.max.y + border;
    }
    if (side == Direction.NORTH) {
        diff.z = bounds.min.z - border;
    }
    if (side == Direction.SOUTH) {
        diff.z = bounds.max.z + border;
    }
    if (side == Direction.WEST) {
        diff.x = bounds.min.x - border;
    }
    if (side == Direction.EAST) {
        diff.x = bounds.max.x + border;
    }

    particleManager.addEffect(new CustomBreakingParticle(world, pos.x, pos.y, pos.z, 0, 0, 0, icon).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
}
 
Example 6
Source File: Vector3.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public Vector4f vector4f() {
    return new Vector4f((float) x, (float) y, (float) z, 1);
}
 
Example 7
Source File: RenderBlock.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
@OnlyIn(Dist.CLIENT)
public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
    return 1.0f;
}
 
Example 8
Source File: PacketCustom.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public static void sendToServer(IPacket<?> packet) {
    Minecraft.getInstance().getConnection().sendPacket(packet);
}
 
Example 9
Source File: ICustomParticleBlock.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@OnlyIn (Dist.CLIENT)
default boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager manager) {
    return CustomParticleHandler.handleDestroyEffects(world, pos, state, manager);
}
 
Example 10
Source File: ICustomParticleBlock.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@OnlyIn (Dist.CLIENT)
default boolean addHitEffects(BlockState state, World worldObj, RayTraceResult target, ParticleManager manager) {
    return CustomParticleHandler.handleHitEffects(state, worldObj, target, manager);
}
 
Example 11
Source File: ICustomParticleBlock.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@OnlyIn (Dist.CLIENT)
default boolean addRunningEffects(BlockState state, World world, BlockPos pos, Entity entity) {
    return world.isRemote && CustomParticleHandler.handleRunningEffects(world, pos, state, entity);
}
 
Example 12
Source File: RayTracer.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@OnlyIn (Dist.CLIENT)
private static double getBlockReachDistance_client() {
    return Minecraft.getInstance().playerController.getBlockReachDistance();
}
 
Example 13
Source File: Colour.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public void glColour(int a) {
    RenderSystem.color4f((r & 0xFF) / 255F, (g & 0xFF) / 255F, (b & 0xFF) / 255F, a / 255F);
}
 
Example 14
Source File: Colour.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public void glColour() {
    RenderSystem.color4f((r & 0xFF) / 255F, (g & 0xFF) / 255F, (b & 0xFF) / 255F, (a & 0xFF) / 255F);
}
 
Example 15
Source File: ItemEnderPouch.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
@OnlyIn (Dist.CLIENT)
public IBakery getBakery() {
    return EnderPouchBakery.INSTANCE;
}
 
Example 16
Source File: PacketCustomChannelBuilder.java    From CodeChickenLib with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Register a double Supplier, to construct the {@link IClientPacketHandler} for the client side.
 * The double Supplier is used to avoid class loading issues on the server side, you do NOT
 * need any external sided checks if you call using the following example:
 * <br/>
 * <code>builder.assignClientHandler(() -> ClientPacketHandler::new);</code>
 * <p/>
 *
 * @param clientHandler The Supplier.
 * @return The same builder.
 */
public PacketCustomChannelBuilder assignClientHandler(Supplier<Supplier<IClientPacketHandler>> clientHandler) {
    if (FMLEnvironment.dist == Dist.CLIENT) {
        this.clientHandler = clientHandler.get().get();
    }
    return this;
}
 
Example 17
Source File: IBakeryProvider.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Used to provide a bakery for the Item OR Block.
 * This should basically always return either ILayeredBlockBakery or ISimpleBlockBakery for blocks or,
 * IItemBakery for items.
 *
 * @return The Bakery!
 */
@OnlyIn (Dist.CLIENT)
IBakery getBakery();
 
Example 18
Source File: ILayeredBlockBakery.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Used to actually generate quads for your block based on the face and layer being requested.
 * Use {@link Block#canRenderInLayer(IBlockState, BlockRenderLayer)} to cull layers from this.
 * You will ONLY be requested for quads if canRenderInLayer returns true for the specific layer.
 * <p>
 * Face may be null!!
 * Treat a null face as "general" quads, Quads that will NOT be culled by neighboring blocks.
 * <p>
 * Each layer you agree to with canRenderInLayer will be requested for "general" AND face quads.
 *
 * @param face  The face quads are requested for.
 * @param layer The layer quads are requested for.
 * @param state The IExtendedBlockState of your block. {@link IBlockBakery#handleState(IExtendedBlockState, IBlockAccess, BlockPos)} has already been called.
 * @return The quads for the layer, May be an empty list. Never null.
 */
@Nonnull
@OnlyIn (Dist.CLIENT)
List<BakedQuad> bakeLayerFace(@Nullable Direction face, RenderType layer, BlockState state, IModelData data);
 
Example 19
Source File: ISimpleBlockBakery.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Used to actually generate quads for your block. Using this interface it is assumed that you only wish to render on one specific layer.
 * If you want to render on multiple layers use {@link ILayeredBlockBakery}
 *
 * Face may be null!!
 * Treat a null face as "general" quads, Quads that will NOT be culled by neighboring blocks.
 *
 * You will be requested for "general" AND face quads.
 *
 * @param face  The face quads are requested for.
 * @param state The IExtendedBlockState of your block. {@link IBlockBakery#handleState(IExtendedBlockState, IBlockAccess, BlockPos)} has already been called.
 * @return The quads for the face, May be an empty list. Never null.
 */
@Nonnull
@OnlyIn (Dist.CLIENT)
List<BakedQuad> bakeQuads(@Nullable Direction face, BlockState state, IModelData data);
 
Example 20
Source File: IItemBakery.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Used to actually generate quads for your ItemStack based on the face being requested.
 *
 * Face may be null!
 * Treat a null face as "general" quads, Item Rendering doesn't have any sense of "faces" this is more so a fall over
 * of blocks having face quads. It is fine to have all your quads in the "general" face, but Recommended against for debugging.
 *
 * @param face  The face quads are requested for.
 * @param stack The stack!
 * @return The quads for the layer, May be an empty list. Never null.
 */
@Nonnull
@OnlyIn (Dist.CLIENT)
List<BakedQuad> bakeItemQuads(@Nullable Direction face, ItemStack stack);