Skip to content

Instantly share code, notes, and snippets.

@SteveKunG
Created November 10, 2022 08:42
Show Gist options
  • Save SteveKunG/e0dca75de265ca64cecd0dbc6e44fce3 to your computer and use it in GitHub Desktop.
Save SteveKunG/e0dca75de265ca64cecd0dbc6e44fce3 to your computer and use it in GitHub Desktop.
package com.stevekung.snapshottest.mixin.test;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.LightBlock;
@Mixin(targets = "net.minecraft.world.item.CreativeModeTabs$4")
public class MixinCreativeModeTabs_REDSTONE
{
@Inject(method = "generateDisplayItems", at = @At(value = "FIELD", target = "net/minecraft/world/item/Items.LIGHT:Lnet/minecraft/world/item/Item;"))
private void addNewLightBlock(FeatureFlagSet featureFlagSet, CreativeModeTab.Output output, boolean canUseGameMasterBlocks, CallbackInfo info)
{
for (var i = 0; i < 15; i++)
{
var itemStack = new ItemStack(Items.LIGHT);
var compoundTag = new CompoundTag();
compoundTag.putString(LightBlock.LEVEL.getName(), String.valueOf(i));
itemStack.addTagElement("BlockStateTag", compoundTag);
output.accept(itemStack);
}
}
@Inject(method = "generateDisplayItems", at = @At(value = "FIELD", target = "net/minecraft/world/item/Items.JIGSAW:Lnet/minecraft/world/item/Item;"))
private void addStructureBlock(FeatureFlagSet featureFlagSet, CreativeModeTab.Output output, boolean canUseGameMasterBlocks, CallbackInfo info)
{
output.accept(Items.STRUCTURE_BLOCK);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment