Skip to content

Instantly share code, notes, and snippets.

New tab

Use the CreativeModeTabEvent.Register event to register your tab, the items will appear in the order you declare them. The accept method has an optional parameter to specify if the items also appear in the search tab or not. Defaults to appearing in both.

    public static CreativeModeTab MY_TAB;

    private void registerTabs(CreativeModeTabEvent.Register event)
    {
 MY_TAB = event.registerCreativeModeTab(new ResourceLocation(MODID, "main_tab"), builder -> builder
@gigaherz
gigaherz / XNbt.java
Last active December 19, 2021 20:43
/*
Copyright (c) 2021, David Quintana <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
@gigaherz
gigaherz / test.xml
Last active December 19, 2021 23:37
Schema definition for XNBT: A format for Xml-encoded NBT
<?xml version="1.0" encoding="UTF-8"?>
<n:compound xmlns:n="https://dogforce-games.com/xnbt/2021/XNbtSchema">
<n:byte key="byte">1</n:byte>
<n:short key="short">2</n:short>
<n:int key="int">3</n:int>
<n:long key="long">4</n:long>
<n:float key="float">5.0</n:float>
<n:double key="double">6.0</n:double>
<n:string key="string">seven</n:string>
<n:list key="list">
@gigaherz
gigaherz / fmllegacy.xml
Last active February 7, 2023 14:13
Updates fmllegacy class references from 1.17 to their new locations and names in 1.18
<?xml version="1.0" encoding="UTF-8"?>
<migrationMap>
<name value="FMLLegacy refactorings" />
<description value="Updates class references from 1.17 to 1.18" />
<entry oldName="net.minecraftforge.fmllegacy.BrandingControl" newName="net.minecraftforge.internal.BrandingControl" type="class" />
<entry oldName="net.minecraftforge.fmllegacy.CrashReportExtender" newName="net.minecraftforge.logging.CrashReportExtender" type="class" />
<entry oldName="net.minecraftforge.fmllegacy.DatagenModLoader" newName="net.minecraftforge.data.loading.DatagenModLoader" type="class" />
<entry oldName="net.minecraftforge.fmllegacy.FMLWorldPersistenceHook" newName="net.minecraftforge.common.ForgeMod.FMLWorldPersistenceHook" type="class" />
<entry oldName="net.minecraftforge.fmllegacy.ForgeBindings" newName="net.minecraftforge.internal.ForgeBindings" type="class" />
<entry oldName="net.minecraftforge.fmllegacy.ForgeI18n" newName="net.minecraftforge.common.ForgeI18n" type="class" />
@gigaherz
gigaherz / toolsystem.md
Last active September 1, 2023 19:05
Explanation of the new tool system

So... You have updated to latest forge and harvestTool, harvestLevel, ToolType, ... are all gone. AAA PANIC!

Here's how to fix it:

Blocks

First, Remove the harvestTool and harvestLevel calls from the block properties.

Then, add the blocks to the relevant tags. You can use datagen, or make the jsons yourself. Datagen is more future-proof.

@gigaherz
gigaherz / 00 Explanation.md
Last active October 4, 2024 22:23
Custom shader rendertype mini-howto example (forge 37.0.15+)

Making a custom render type with a custom shader requires a number of things to exist at once:

  1. A ShaderInstance which references your shader json. The RegisterShadersEvent lets you define a ShaderInstance, and has a callback for when the shader is fully loaded from disk.
  2. A ShaderStateShard with a supplier that returns the ShaderInstance. The supplier exists so that shaders can reload themselves when you change resourcepacks or do a F3+T reload.
  3. A RenderType which uses the ShaderStateShard as its shader state.
  4. A shader json, which declares the shader properties and points to the shader programs (vsh and fsh).
  5. A vertex shader program, which describes how the vertex data is transformed before passing into the rasterizer and being turned into pixels.
  6. A fragment shader program, which describes how the interpolated values from the vertices get turned into color values before being passed into the output blending stage.

Note: The vanilla logic does not normally allow namespaces in the shader

@gigaherz
gigaherz / 00ExampleRender.java
Last active July 27, 2024 19:47
Animated Gif for Minecraft -- Public Domain, or the closest to it, see CC0 at https://creativecommons.org/share-your-work/public-domain/cc0/
package gigaherz.eyes.client;
import gigaherz.eyes.EyesInTheDarkness;
import gigaherz.eyes.entity.EyesEntity;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public static <T extends IModPacket> void registerPacket(SimpleChannel channel, int discriminator, PacketHandler<T> handler)
{
channel.registerMessage(discriminator, handler.getPacketClass(), handler::encode, handler::decode, handler::handle);
}
public static abstract class PacketHandler<T extends IModPacket>
{
private final Class<T> tClass;
package gigaherz.signbutton;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
public class MultiplyAlphaRenderTypeBuffer implements IRenderTypeBuffer
{
private final IRenderTypeBuffer inner;
private final float constantAlpha;
@gigaherz
gigaherz / 1152to1161.xml
Created June 26, 2020 19:42 — forked from sobrinth/1152to1161.xml
1.15.2 -> 1.16.1 migration mappings for intellij
<?xml version="1.0" encoding="UTF-8"?>
<migrationMap>
<name value="1.15.2 to 1.16.1" />
<description value="1.15.2 to 1.16.1 MCPConfig changes" />
<entry oldName="net.minecraft.entity.item.minecart.MinecartCommandBlockEntity" newName="net.minecraft.entity.item.minecart.CommandBlockMinecartEntity" type="class" />
<entry oldName="net.minecraft.util.math.Matrix3f" newName="net.minecraft.util.math.vector.Matrix3f" type="class" />
<entry oldName="net.minecraft.util.math.Matrix4f" newName="net.minecraft.util.math.vector.Matrix4f" type="class" />
<entry oldName="net.minecraft.util.math.Vector3f" newName="net.minecraft.util.math.vector.Vector3f" type="class" />
<entry oldName="net.minecraft.util.math.Vector4f" newName="net.minecraft.util.math.vector.Vector4f" type="class" />
<entry oldName="net.minecraft.util.math.Vec2f" newName="net.minecraft.util.math.vector.Vector2f" type="class" />