net.minecraftforge.api.distmarker.OnlyIn Java Examples

The following examples show how to use net.minecraftforge.api.distmarker.OnlyIn. 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: CustomParticleHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public static boolean handleRunningEffects(World world, BlockPos pos, BlockState state, Entity entity) {
    //Spoof a raytrace from the feet.
    BlockRayTraceResult traceResult = new BlockRayTraceResult(entity.getPositionVec().add(0, 1, 0), Direction.UP, pos, false);
    BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes();
    IBakedModel model = modelShapes.getModel(state);
    if (model instanceof IModelParticleProvider) {
        IModelData modelData = ModelDataManager.getModelData(world, pos);
        ParticleManager particleManager = Minecraft.getInstance().particles;
        List<TextureAtlasSprite> sprites = new ArrayList<>(((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, modelData));
        TextureAtlasSprite rolledSprite = sprites.get(world.rand.nextInt(sprites.size()));
        double x = entity.getPosX() + (world.rand.nextFloat() - 0.5D) * entity.getWidth();
        double y = entity.getBoundingBox().minY + 0.1D;
        double z = entity.getPosZ() + (world.rand.nextFloat() - 0.5D) * entity.getWidth();
        particleManager.addEffect(new CustomBreakingParticle(world, x, y, z, -entity.getMotion().x * 4.0D, 1.5D, -entity.getMotion().z * 4.0D, rolledSprite));
        return true;
    }

    return false;
}
 
Example #2
Source File: CustomParticleHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public static void addLandingEffects(World world, BlockPos pos, BlockState state, Vector3 entityPos, int numParticles) {
    //Spoof a raytrace from the feet.
    BlockRayTraceResult traceResult = new BlockRayTraceResult(new Vec3d(entityPos.x, pos.getY() + 1, entityPos.z), Direction.UP, pos, false);
    ParticleManager manager = Minecraft.getInstance().particles;
    Random randy = new Random();
    BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes();
    IBakedModel model = modelShapes.getModel(state);
    if (model instanceof IModelParticleProvider) {
        IModelData modelData = ModelDataManager.getModelData(world, pos);
        List<TextureAtlasSprite> sprites = new ArrayList<>(((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, modelData));

        double speed = 0.15000000596046448D;
        if (numParticles != 0) {
            for (int i = 0; i < numParticles; i++) {
                double mX = randy.nextGaussian() * speed;
                double mY = randy.nextGaussian() * speed;
                double mZ = randy.nextGaussian() * speed;
                manager.addEffect(CustomBreakingParticle.newLandingParticle(world, entityPos.x, entityPos.y, entityPos.z, mX, mY, mZ, sprites.get(randy.nextInt(sprites.size()))));
            }
        }
    }
}
 
Example #3
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 #4
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 #5
Source File: CCRenderEventHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@OnlyIn (Dist.CLIENT)
@SubscribeEvent (priority = EventPriority.LOW)
public void onBlockHighlight(DrawHighlightEvent.HighlightBlock event) {
    //We have found a CuboidRayTraceResult, Lets render it properly..
    BlockRayTraceResult hit = event.getTarget();
    if (hit instanceof CuboidRayTraceResult) {
        CuboidRayTraceResult cuboidHit = (CuboidRayTraceResult) hit;
        event.setCanceled(true);
        Matrix4 mat = new Matrix4(event.getMatrix());
        mat.translate(cuboidHit.getPos());
        RenderUtils.bufferHitbox(mat, event.getBuffers(), event.getInfo(), cuboidHit.cuboid6);
    }
}
 
Example #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: PacketPipeline.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
@OnlyIn(Dist.CLIENT)
private PlayerEntity getClientPlayer(){
	return Minecraft.getInstance().player;
}
 
Example #12
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 #13
Source File: PacketCustom.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public void sendToServer() {
    sendToServer(toPacket(NetworkDirection.PLAY_TO_SERVER));
}
 
Example #14
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 PacketCustom fromTilePacket(SUpdateTileEntityPacket tilePacket) {
    return fromNBTTag(tilePacket.getNbtCompound());
}
 
Example #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
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 #23
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);
 
Example #24
Source File: IItemBakery.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Using this allows you to change the way your model appears. You are able to override Gui3d and such.
 * Including Transforms.
 *
 * @return The properties to use for the model.
 */
@OnlyIn (Dist.CLIENT)
default PerspectiveProperties getModelProperties(ItemStack stack) {
    return stack.getItem() instanceof BlockItem ? PerspectiveProperties.DEFAULT_BLOCK : PerspectiveProperties.DEFAULT_ITEM;
}
 
Example #25
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 #26
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 #27
Source File: ICustomPacketHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Called on the client to handle a packet sent from the server.
 *
 * @param packet  The packet.
 * @param mc      The Minecraft instance.
 * @param handler The ClientPlayNetHandler.
 */
@OnlyIn (Dist.CLIENT)
void handlePacket(PacketCustom packet, Minecraft mc, IClientPlayNetHandler handler);
 
Example #28
Source File: ICustomPacketHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Called on the client to handle a login packet provided through {@link #gatherLoginPackets}.
 * This method unlike the other handlers, does not sync to the main thread for processing, instead
 * it is fired on the network thread, this is to allow mods to choose if the packet is important
 * in the handshake cycle and must be handled before anything else can continue. If the data isn't
 * critical to the handshake process, feel free to use {@link NetworkEvent.Context#enqueueWork(Runnable)}
 * to throw things on the main thread.
 *
 * @param packet  The packet to handle.
 * @param mc      The Minecraft instance.
 * @param handler Vanilla's NetHandler.
 * @param context The network context.
 */
@OnlyIn (Dist.CLIENT)
void handleLoginPacket(PacketCustom packet, Minecraft mc, IClientLoginNetHandler handler, NetworkEvent.Context context);