mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Redesign CreativeTab collection event to be a lot more straight forward. (#9198)
This commit is contained in:
1 parent
4cf5508e04
commit
ec3abdea14
41 files changed
+696
-512
No files matched your search
@@ -9,8 +9,10 @@ import java.util.List;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTab.TabVisibility;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
@@ -62,28 +64,28 @@ public class CreativeModeTabTest
|
||||
}));
|
||||
}
|
||||
|
||||
private static ItemStack i(ItemLike item) { return new ItemStack(item); }
|
||||
|
||||
private static void onCreativeModeTabBuildContents(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
var entries = event.getEntries();
|
||||
var vis = TabVisibility.PARENT_AND_SEARCH_TABS;
|
||||
if (event.getTab() == LOGS)
|
||||
{
|
||||
event.register((flags, builder, hasPermissions) -> {
|
||||
builder.accept(new ItemStack(Blocks.STRIPPED_ACACIA_LOG), ItemStack.EMPTY, new ItemStack(Blocks.ACACIA_LOG));
|
||||
builder.accept(new ItemStack(Blocks.STRIPPED_BIRCH_LOG), ItemStack.EMPTY, new ItemStack(Blocks.BIRCH_LOG));
|
||||
builder.accept(new ItemStack(Blocks.STRIPPED_DARK_OAK_LOG), ItemStack.EMPTY, new ItemStack(Blocks.DARK_OAK_LOG));
|
||||
builder.accept(new ItemStack(Blocks.STRIPPED_JUNGLE_LOG), ItemStack.EMPTY, new ItemStack(Blocks.JUNGLE_LOG));
|
||||
builder.accept(new ItemStack(Blocks.STRIPPED_OAK_LOG), ItemStack.EMPTY, new ItemStack(Blocks.OAK_LOG));
|
||||
builder.accept(new ItemStack(Blocks.STRIPPED_SPRUCE_LOG), ItemStack.EMPTY, new ItemStack(Blocks.SPRUCE_LOG));
|
||||
});
|
||||
entries.putAfter(i(Blocks.ACACIA_LOG), i(Blocks.STRIPPED_ACACIA_LOG), vis);
|
||||
entries.putAfter(i(Blocks.BIRCH_LOG), i(Blocks.STRIPPED_BIRCH_LOG), vis);
|
||||
entries.putAfter(i(Blocks.DARK_OAK_LOG), i(Blocks.STRIPPED_DARK_OAK_LOG), vis);
|
||||
entries.putAfter(i(Blocks.JUNGLE_LOG), i(Blocks.STRIPPED_JUNGLE_LOG), vis);
|
||||
entries.putAfter(i(Blocks.OAK_LOG), i(Blocks.STRIPPED_OAK_LOG), vis);
|
||||
entries.putAfter(i(Blocks.SPRUCE_LOG), i(Blocks.STRIPPED_SPRUCE_LOG), vis);
|
||||
}
|
||||
|
||||
if (event.getTab() == STONE)
|
||||
{
|
||||
event.register((flags, builder, hasPermissions) -> {
|
||||
builder.accept(new ItemStack(Blocks.SMOOTH_STONE), new ItemStack(Blocks.GRANITE), new ItemStack(Blocks.STONE));
|
||||
builder.accept(new ItemStack(Blocks.POLISHED_GRANITE), new ItemStack(Blocks.DIORITE), new ItemStack(Blocks.GRANITE));
|
||||
builder.accept(new ItemStack(Blocks.POLISHED_DIORITE), new ItemStack(Blocks.ANDESITE), new ItemStack(Blocks.DIORITE));
|
||||
builder.accept(new ItemStack(Blocks.POLISHED_ANDESITE), ItemStack.EMPTY, new ItemStack(Blocks.ANDESITE));
|
||||
});
|
||||
entries.putBefore(i(Blocks.STONE), i(Blocks.SMOOTH_STONE), vis);
|
||||
entries.putBefore(i(Blocks.GRANITE), i(Blocks.POLISHED_GRANITE), vis);
|
||||
entries.putBefore(i(Blocks.DIORITE), i(Blocks.POLISHED_DIORITE), vis);
|
||||
entries.putBefore(i(Blocks.ANDESITE), i(Blocks.POLISHED_ANDESITE), vis);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(CustomSoundTypeTest.MODID)
|
||||
public class CustomSoundTypeTest
|
||||
{
|
||||
@@ -51,7 +48,12 @@ public class CustomSoundTypeTest
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
SOUND_EVENTS.register(modEventBus);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, TEST_STEP_BLOCK_ITEM.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_STEP_BLOCK_ITEM);
|
||||
}
|
||||
}
|
||||
@@ -78,8 +78,13 @@ public class DeferredRegistryTest {
|
||||
modBus.addListener(this::gatherData);
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStarted);
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, ITEM.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(ITEM);
|
||||
}
|
||||
|
||||
public void serverStarted(ServerStartedEvent event)
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod("be_onload_test")
|
||||
public class BlockEntityOnLoadTest
|
||||
@@ -54,11 +53,16 @@ public class BlockEntityOnLoadTest
|
||||
BLOCKS.register(modBus);
|
||||
ITEMS.register(modBus);
|
||||
BE_TYPES.register(modBus);
|
||||
|
||||
modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, TEST_BLOCK_ITEM.get()));
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_BLOCK_ITEM);
|
||||
}
|
||||
|
||||
private static class TestBlock extends Block implements EntityBlock
|
||||
{
|
||||
public TestBlock(Properties props) { super(props); }
|
||||
|
||||
@@ -35,8 +35,6 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Adds a blaze head block and item to test the event for registering a custom skull model and to demonstrate the proper way to register a custom mob skull.
|
||||
*
|
||||
@@ -61,8 +59,13 @@ public class CustomHeadTest
|
||||
BLOCKS.register(modBus);
|
||||
ITEMS.register(modBus);
|
||||
BLOCK_ENTITIES.register(modBus);
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, BLAZE_HEAD_ITEM.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(BLAZE_HEAD_ITEM);
|
||||
}
|
||||
|
||||
private static class CustomSkullBlock extends SkullBlock
|
||||
|
||||
@@ -35,8 +35,6 @@ import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.WoodType;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(CustomSignsTest.MODID)
|
||||
public class CustomSignsTest
|
||||
{
|
||||
@@ -66,11 +64,16 @@ public class CustomSignsTest
|
||||
|
||||
eventBus.addListener(this::clientSetup);
|
||||
eventBus.addListener(this::commonSetup);
|
||||
|
||||
eventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, TEST_SIGN.get()));
|
||||
eventBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_SIGN);
|
||||
}
|
||||
|
||||
private void clientSetup(final FMLClientSetupEvent event)
|
||||
{
|
||||
BlockEntityRenderers.register(CUSTOM_SIGN.get(), SignRenderer::new);
|
||||
|
||||
@@ -56,7 +56,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -88,11 +87,16 @@ public class FullPotsAccessorDemo
|
||||
BLOCKS.register(bus);
|
||||
ITEMS.register(bus);
|
||||
BLOCK_ENTITIES.register(bus);
|
||||
|
||||
bus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, DIORITE_POT_ITEM.get()));
|
||||
bus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(DIORITE_POT_ITEM);
|
||||
}
|
||||
|
||||
private static class DioriteFlowerPotBlock extends Block implements EntityBlock
|
||||
{
|
||||
private static final VoxelShape SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D);
|
||||
|
||||
@@ -7,8 +7,6 @@ package net.minecraftforge.debug.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -66,8 +64,13 @@ public class PistonEventTest
|
||||
BLOCKS.register(modBus);
|
||||
ITEMS.register(modBus);
|
||||
modBus.addListener(this::gatherData);
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, SHIFT_ON_MOVE_ITEM.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(SHIFT_ON_MOVE_ITEM);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -25,8 +25,6 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(RedstoneSidedConnectivityTest.MODID)
|
||||
public class RedstoneSidedConnectivityTest
|
||||
{
|
||||
@@ -48,8 +46,13 @@ public class RedstoneSidedConnectivityTest
|
||||
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
BLOCKS.register(modBus);
|
||||
ITEMS.register(modBus);
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, TEST_REDSTONE_BLOCKITEM.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_REDSTONE_BLOCKITEM);
|
||||
}
|
||||
|
||||
private static class EastRedstoneBlock extends Block
|
||||
|
||||
@@ -19,8 +19,6 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Test mod that demos disabling ambient occlusion on specific faces of "elements" models.
|
||||
*/
|
||||
@@ -50,8 +48,17 @@ public class AmbientOcclusionElementsTest
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS,
|
||||
AO_BLOCK_SHADE_ITEM.get(), AO_BLOCK_NO_SHADE_ITEM.get(), NO_AO_BLOCK_SHADE_ITEM.get(), NO_AO_BLOCK_NO_SHADE_ITEM.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
{
|
||||
event.accept(AO_BLOCK_SHADE_ITEM);
|
||||
event.accept(AO_BLOCK_NO_SHADE_ITEM);
|
||||
event.accept(NO_AO_BLOCK_SHADE_ITEM);
|
||||
event.accept(NO_AO_BLOCK_NO_SHADE_ITEM);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,9 +48,17 @@ public class CustomArmorModelTest
|
||||
{
|
||||
final IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modBus);
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS,
|
||||
RED_LEGGINGS.get(), ENDERMAN_CHESTPLATE.get(), ENDERMAN_BOOTS.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
{
|
||||
event.accept(RED_LEGGINGS);
|
||||
event.accept(ENDERMAN_CHESTPLATE);
|
||||
event.accept(ENDERMAN_BOOTS);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TintedArmorItem extends ArmorItem
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(CustomTooltipTest.ID)
|
||||
public class CustomTooltipTest
|
||||
@@ -65,10 +64,16 @@ public class CustomTooltipTest
|
||||
modEventBus.register(ClientModBusEventHandler.class);
|
||||
}
|
||||
ITEMS.register(modEventBus);
|
||||
modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, CUSTOM_ITEM.get()));
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(CUSTOM_ITEM);
|
||||
}
|
||||
|
||||
static record CustomTooltip(int color) implements TooltipComponent
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,7 +37,12 @@ public class EmissiveElementsTest
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.BUILDING_BLOCKS, TEST_BLOCK_ITEM.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_BLOCK_ITEM);
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,6 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(CompositeModelTest.MODID)
|
||||
public class CompositeModelTest
|
||||
{
|
||||
@@ -87,7 +85,12 @@ public class CompositeModelTest
|
||||
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
modEventBus.addListener((CreativeModeTabEvent.BuildContents event) -> event.registerSimple(CreativeModeTabs.INGREDIENTS, composite_item.get()));
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(composite_item);
|
||||
}
|
||||
}
|
||||
@@ -50,8 +50,6 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
* Test mod for the custom transform types feature.
|
||||
* This test mod adds an item that should be held in the main hand, while another item is in the offhand.
|
||||
@@ -129,13 +127,13 @@ public class CustomTransformTypeTest
|
||||
BLOCKS.register(modBus);
|
||||
BLOCK_ENTITY_TYPES.register(modBus);
|
||||
ITEMS.register(modBus);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(ITEM_HANGER_ITEM.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(ITEM_HANGER_ITEM);
|
||||
}
|
||||
|
||||
public void gatherData(GatherDataEvent event)
|
||||
|
||||
@@ -15,8 +15,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(DynBucketModelTest.MODID)
|
||||
public class DynBucketModelTest
|
||||
{
|
||||
@@ -33,14 +31,16 @@ public class DynBucketModelTest
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modEventBus);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(DRIP_BUCKET.get());
|
||||
output.accept(LAVA_OBSIDIAN.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
{
|
||||
event.accept(DRIP_BUCKET);
|
||||
event.accept(LAVA_OBSIDIAN);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,12 +88,13 @@ public class MegaModelTest
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
BLOCK_ENTITIES.register(modEventBus);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.BUILDING_BLOCKS) {
|
||||
onBuildContents.register((p_259204_, p_259752_, p_260123_) -> p_259752_.accept(TEST_BLOCK_ITEM.get()));
|
||||
}
|
||||
});
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_BLOCK_ITEM);
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
|
||||
@@ -12,17 +12,14 @@ import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
@Mod(MultiLayerModelTest.MODID)
|
||||
public class MultiLayerModelTest
|
||||
@@ -32,44 +29,34 @@ public class MultiLayerModelTest
|
||||
public static final String VERSION = "0.0";
|
||||
|
||||
private static final String blockName = "test_layer_block";
|
||||
private static final ResourceLocation blockId = new ResourceLocation(MODID, blockName);
|
||||
@ObjectHolder(registryName = "block", value = blockName)
|
||||
public static final Block TEST_BLOCK = null;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class Registration
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register(blockName, () -> new Block(Block.Properties.of(Material.WOOD).noOcclusion()));
|
||||
private static final RegistryObject<Item> TEST_BLOCK_ITEM = ITEMS.register(blockName, () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties()));
|
||||
|
||||
public MultiLayerModelTest()
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegisterEvent event)
|
||||
{
|
||||
if (!ENABLED || !event.getRegistryKey().equals(ForgeRegistries.Keys.BLOCKS))
|
||||
return;
|
||||
event.register(ForgeRegistries.Keys.BLOCKS, blockId, () -> new Block(Block.Properties.of(Material.WOOD).noOcclusion()));
|
||||
}
|
||||
if (!ENABLED)
|
||||
return;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegisterEvent event)
|
||||
{
|
||||
if (!ENABLED || !event.getRegistryKey().equals(ForgeRegistries.Keys.ITEMS))
|
||||
return;
|
||||
event.register(ForgeRegistries.Keys.ITEMS, blockId, () -> new BlockItem(TEST_BLOCK, new Item.Properties()));
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(TEST_BLOCK.asItem());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
modEventBus.addListener(this::clientSetup);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
return;
|
||||
ItemBlockRenderTypes.setRenderLayer(TEST_BLOCK, (layer) -> {
|
||||
return layer == RenderType.solid() || layer == RenderType.translucent();
|
||||
});
|
||||
}
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_BLOCK);
|
||||
}
|
||||
|
||||
private void clientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
ItemBlockRenderTypes.setRenderLayer(TEST_BLOCK.get(), (layer) -> {
|
||||
return layer == RenderType.solid() || layer == RenderType.translucent();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ package net.minecraftforge.debug.client.model;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.ModelBaker;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -48,7 +47,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
@@ -127,20 +126,22 @@ public class NewModelLoaderTest
|
||||
|
||||
modEventBus.addListener(this::modelRegistry);
|
||||
modEventBus.addListener(this::datagen);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(obj_item.get());
|
||||
output.accept(custom_transforms.get());
|
||||
output.accept(custom_vanilla_loader.get());
|
||||
output.accept(custom_loader.get());
|
||||
output.accept(item_layers.get());
|
||||
output.accept(separate_perspective.get());
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
{
|
||||
Arrays.asList(
|
||||
obj_item,
|
||||
custom_transforms,
|
||||
custom_vanilla_loader,
|
||||
custom_loader,
|
||||
item_layers,
|
||||
separate_perspective
|
||||
).forEach(event::accept);
|
||||
}
|
||||
}
|
||||
|
||||
public void modelRegistry(ModelEvent.RegisterGeometryLoaders event)
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
@@ -56,12 +54,13 @@ public class TRSRTransformerTest {
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> mod.addListener(this::onModelBake));
|
||||
BLOCKS.register(mod);
|
||||
ITEMS.register(mod);
|
||||
mod.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.BUILDING_BLOCKS) {
|
||||
onBuildContents.register((p_259204_, p_259752_, p_260123_) -> p_259752_.accept(TEST_ITEM.get()));
|
||||
}
|
||||
});
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(TEST_ITEM);
|
||||
}
|
||||
|
||||
public void onModelBake(ModelEvent.BakingCompleted e) {
|
||||
|
||||
@@ -8,19 +8,19 @@ package net.minecraftforge.debug.entity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -39,20 +39,24 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
import net.minecraft.world.item.Item.Properties;
|
||||
|
||||
@Mod("gravity_attribute_test")
|
||||
@Mod(GravityAttributeTest.MODID)
|
||||
public class GravityAttributeTest
|
||||
{
|
||||
public static final boolean ENABLE = false;
|
||||
private static Logger logger = LogManager.getLogger();
|
||||
public static final String MODID = "gravity_attribute_test";
|
||||
private static Logger logger = LogManager.getLogger(MODID);
|
||||
private int ticks;
|
||||
private static final UUID REDUCED_GRAVITY_ID = UUID.fromString("DEB06000-7979-4242-8888-00000DEB0600");
|
||||
private static final AttributeModifier REDUCED_GRAVITY = (new AttributeModifier(REDUCED_GRAVITY_ID, "Reduced gravity", (double)-0.80, Operation.MULTIPLY_TOTAL));
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final RegistryObject<Item> TEST_ITEM = ITEMS.register("gravity_stick", () -> new ItemGravityStick(new Properties().rarity(Rarity.RARE)));
|
||||
|
||||
|
||||
public GravityAttributeTest()
|
||||
@@ -60,7 +64,10 @@ public class GravityAttributeTest
|
||||
if (ENABLE)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(this);
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
modEventBus.register(this);
|
||||
ITEMS.register(modEventBus);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,19 +122,10 @@ public class GravityAttributeTest
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerItems(RegisterEvent event)
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
event.register(ForgeRegistries.Keys.ITEMS, helper -> helper.register("gravity_stick",
|
||||
new ItemGravityStick(new Properties().rarity(Rarity.RARE))));
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(ForgeRegistries.ITEMS.getValue(new ResourceLocation("gravity_attribute_test", "gravity_stick")));
|
||||
});
|
||||
}
|
||||
});
|
||||
if (event.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES)
|
||||
event.accept(TEST_ITEM);
|
||||
}
|
||||
|
||||
public static class ItemGravityStick extends Item
|
||||
|
||||
@@ -41,14 +41,15 @@ public class ItemUseAnimationTest
|
||||
|
||||
public ItemUseAnimationTest()
|
||||
{
|
||||
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(THING.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
var modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modBus);
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
event.accept(THING);
|
||||
}
|
||||
|
||||
private static class ThingItem extends Item
|
||||
|
||||
@@ -21,7 +21,6 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Tests if the patch to PlayerEntity to make it utilize Attributes.ATTACK_KNOCKBACK works
|
||||
@@ -46,13 +45,13 @@ public class PlayerAttackKnockbackTest {
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modEventBus);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(KNOCKBACK_SWORD.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
event.accept(KNOCKBACK_SWORD);
|
||||
}
|
||||
|
||||
static class KnockbackSwordItem extends SwordItem {
|
||||
|
||||
@@ -173,22 +173,18 @@ public class FluidTypeTest
|
||||
ITEMS.register(modEventBus);
|
||||
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> new FluidTypeTestClient(modEventBus));
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(new Consumer<CreativeModeTabEvent.BuildContents>() {
|
||||
@Override
|
||||
public void accept(CreativeModeTabEvent.BuildContents onBuildContents) {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permission) -> {
|
||||
output.accept(new ItemStack(TEST_FLUID_BUCKET.get()));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_FLUID_BUCKET);
|
||||
}
|
||||
|
||||
private void commonSetup(FMLCommonSetupEvent event)
|
||||
{
|
||||
// Add Interactions for sources
|
||||
@@ -218,7 +214,7 @@ public class FluidTypeTest
|
||||
|
||||
private void registerBlockColors(RegisterColorHandlersEvent.Block event)
|
||||
{
|
||||
event.getBlockColors().register((state, getter, pos, index) ->
|
||||
event.register((state, getter, pos, index) ->
|
||||
{
|
||||
if (getter != null && pos != null)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ public class NewFluidTest
|
||||
private static ForgeFlowingFluid.Properties makeProperties()
|
||||
{
|
||||
return new ForgeFlowingFluid.Properties(test_fluid_type, test_fluid, test_fluid_flowing)
|
||||
.bucket(test_fluid_bucket).block(test_fluid_block);
|
||||
.bucket(TEST_FLUID_BUCKET).block(test_fluid_block);
|
||||
}
|
||||
|
||||
public static RegistryObject<FluidType> test_fluid_type = FLUID_TYPES.register("test_fluid", () -> new FluidType(FluidType.Properties.create())
|
||||
@@ -111,7 +111,7 @@ public class NewFluidTest
|
||||
public static RegistryObject<LiquidBlock> test_fluid_block = BLOCKS.register("test_fluid_block", () ->
|
||||
new LiquidBlock(test_fluid, Properties.of(Material.WATER).noCollission().strength(100.0F).noLootTable())
|
||||
);
|
||||
public static RegistryObject<Item> test_fluid_bucket = ITEMS.register("test_fluid_bucket", () ->
|
||||
public static RegistryObject<Item> TEST_FLUID_BUCKET = ITEMS.register("test_fluid_bucket", () ->
|
||||
new BucketItem(test_fluid, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1))
|
||||
);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class NewFluidTest
|
||||
public static RegistryObject<Block> fluidloggable_block = BLOCKS.register("fluidloggable_block", () ->
|
||||
new FluidloggableBlock(Properties.of(Material.WOOD).noCollission().strength(100.0F).noLootTable())
|
||||
);
|
||||
public static RegistryObject<Item> fluidloggable_blockitem = ITEMS.register("fluidloggable_block", () ->
|
||||
public static RegistryObject<Item> FLUID_LOGGABLE_BLOCK_ITEM = ITEMS.register("fluidloggable_block", () ->
|
||||
new BlockItem(fluidloggable_block.get(), new Item.Properties())
|
||||
);
|
||||
|
||||
@@ -135,15 +135,16 @@ public class NewFluidTest
|
||||
ITEMS.register(modEventBus);
|
||||
FLUID_TYPES.register(modEventBus);
|
||||
FLUIDS.register(modEventBus);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(fluidloggable_blockitem.get());
|
||||
output.accept(test_fluid_bucket.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
{
|
||||
event.accept(FLUID_LOGGABLE_BLOCK_ITEM);
|
||||
event.accept(TEST_FLUID_BUCKET);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ public class NewFluidTest
|
||||
Validate.isTrue(state.getBlock() == Blocks.WATER && state2 == state);
|
||||
ItemStack stack = Fluids.WATER.getFluidType().getBucket(new FluidStack(Fluids.WATER, 1));
|
||||
Validate.isTrue(stack.getItem() == Fluids.WATER.getBucket());
|
||||
event.enqueueWork(() -> DispenserBlock.registerBehavior(test_fluid_bucket.get(), DispenseFluidContainer.getInstance()));
|
||||
event.enqueueWork(() -> DispenserBlock.registerBehavior(TEST_FLUID_BUCKET.get(), DispenseFluidContainer.getInstance()));
|
||||
}
|
||||
|
||||
// WARNING: this doesn't allow "any fluid", only the fluid from this test mod!
|
||||
@@ -198,7 +199,7 @@ public class NewFluidTest
|
||||
public ItemStack pickupBlock(LevelAccessor worldIn, BlockPos pos, BlockState state) {
|
||||
if (state.getValue(FLUIDLOGGED)) {
|
||||
worldIn.setBlock(pos, state.setValue(FLUIDLOGGED, false), 3);
|
||||
return new ItemStack(test_fluid_bucket.get());
|
||||
return new ItemStack(TEST_FLUID_BUCKET.get());
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ import net.minecraft.world.item.Item.Properties;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(CustomElytraTest.MOD_ID)
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = CustomElytraTest.MOD_ID)
|
||||
public class CustomElytraTest
|
||||
@@ -48,13 +46,13 @@ public class CustomElytraTest
|
||||
final IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modBus);
|
||||
modBus.addListener(this::onClientSetup);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(TEST_ELYTRA.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_ELYTRA);
|
||||
}
|
||||
|
||||
private void onClientSetup(FMLClientSetupEvent event)
|
||||
|
||||
@@ -19,8 +19,6 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(CustomMobBucketTest.MODID)
|
||||
public class CustomMobBucketTest
|
||||
{
|
||||
@@ -41,13 +39,13 @@ public class CustomMobBucketTest
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modEventBus);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(COW_BUCKET.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(COW_BUCKET);
|
||||
}
|
||||
}
|
||||
@@ -31,14 +31,15 @@ public class CustomShieldTest
|
||||
|
||||
public CustomShieldTest()
|
||||
{
|
||||
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(CUSTOM_SHIELD_ITEM.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
var modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modBus);
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
event.accept(CUSTOM_SHIELD_ITEM);
|
||||
}
|
||||
|
||||
private static class CustomShieldItem extends Item
|
||||
|
||||
@@ -17,15 +17,13 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(EnderMaskTest.MODID)
|
||||
public class EnderMaskTest
|
||||
{
|
||||
public static final String MODID = "ender_mask_test";
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Item> ender_mask = ITEMS.register("ender_mask", () ->
|
||||
public static RegistryObject<Item> ENDER_MASK = ITEMS.register("ender_mask", () ->
|
||||
new ArmorItem(ArmorMaterials.LEATHER, EquipmentSlot.HEAD, (new Item.Properties()))
|
||||
{
|
||||
@Override
|
||||
@@ -40,12 +38,12 @@ public class EnderMaskTest
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modEventBus);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(ender_mask.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(ENDER_MASK);
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,6 @@
|
||||
package net.minecraftforge.debug.item;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.client.renderer.entity.PigRenderer;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
@@ -51,20 +49,20 @@ public class ForgeSpawnEggItemTest
|
||||
{
|
||||
if (ENABLED)
|
||||
{
|
||||
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(this);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(EGG.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
var eventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(eventBus);
|
||||
ENTITIES.register(eventBus);
|
||||
eventBus.register(this);
|
||||
eventBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(EGG);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterAttributes(final EntityAttributeCreationEvent event)
|
||||
{
|
||||
|
||||
@@ -23,8 +23,6 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(HiddenTooltipPartsTest.MOD_ID)
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, modid = HiddenTooltipPartsTest.MOD_ID)
|
||||
public class HiddenTooltipPartsTest
|
||||
@@ -37,14 +35,15 @@ public class HiddenTooltipPartsTest
|
||||
|
||||
public HiddenTooltipPartsTest()
|
||||
{
|
||||
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(TEST_ITEM.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
var modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modBus);
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(TEST_ITEM);
|
||||
}
|
||||
|
||||
static class TestItem extends Item
|
||||
|
||||
@@ -17,8 +17,6 @@ import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(RangedMobsUseModdedWeaponsTest.MOD_ID)
|
||||
public class RangedMobsUseModdedWeaponsTest {
|
||||
|
||||
@@ -45,14 +43,16 @@ public class RangedMobsUseModdedWeaponsTest {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modEventBus);
|
||||
modEventBus.addListener(this::onClientSetup);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(MODDED_BOW.get());
|
||||
output.accept(MODDED_CROSSBOW.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
{
|
||||
event.accept(MODDED_BOW);
|
||||
event.accept(MODDED_CROSSBOW);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,13 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Mod(SnowBootsTest.MODID)
|
||||
public class SnowBootsTest
|
||||
{
|
||||
public static final String MODID = "snow_boots_test";
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Item> snow_boots = ITEMS.register("snow_boots", () ->
|
||||
public static RegistryObject<Item> SNOW_BOOTS = ITEMS.register("snow_boots", () ->
|
||||
new ArmorItem(ArmorMaterials.DIAMOND, EquipmentSlot.FEET, (new Item.Properties()))
|
||||
{
|
||||
@Override
|
||||
@@ -38,12 +36,12 @@ public class SnowBootsTest
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ITEMS.register(modEventBus);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.COMBAT) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(snow_boots.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.COMBAT)
|
||||
event.accept(SNOW_BOOTS);
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,6 @@ import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -97,22 +96,15 @@ public class TagBasedToolTypesTest
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
modEventBus.addListener(this::gatherData);
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(new Consumer<CreativeModeTabEvent.BuildContents>() {
|
||||
@Override
|
||||
public void accept(CreativeModeTabEvent.BuildContents onBuildContents) {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
|
||||
onBuildContents.register((flags, output, permission) -> {
|
||||
output.accept(TOOL.get());
|
||||
});
|
||||
} else if (onBuildContents.getTab() == CreativeModeTabs.BUILDING_BLOCKS) {
|
||||
onBuildContents.register((flags, output, permission) -> {
|
||||
output.accept(ORE_ITEM.get());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES)
|
||||
event.accept(TOOL);
|
||||
if (event.getTab() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(ORE_ITEM);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -70,17 +70,16 @@ public class GameTestTest
|
||||
BLOCKS.register(modBus);
|
||||
ITEMS.register(modBus);
|
||||
BLOCK_ENTITIES.register(modBus);
|
||||
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(ENERGY_BLOCK_ITEM.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modBus.addListener(this::addCreative);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(ENERGY_BLOCK_ITEM);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterGameTests(RegisterGameTestsEvent event)
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ import com.mojang.datafixers.util.Pair;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -51,13 +49,13 @@ public class ForgeChunkManagerTest
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener((Consumer<CreativeModeTabEvent.BuildContents>) onBuildContents -> {
|
||||
if (onBuildContents.getTab() == CreativeModeTabs.INGREDIENTS) {
|
||||
onBuildContents.register((flags, output, permissions) -> {
|
||||
output.accept(CHUNK_LOADER_ITEM.get());
|
||||
});
|
||||
}
|
||||
});
|
||||
modEventBus.addListener(this::addCreative);
|
||||
}
|
||||
|
||||
private void addCreative(CreativeModeTabEvent.BuildContents event)
|
||||
{
|
||||
if (event.getTab() == CreativeModeTabs.INGREDIENTS)
|
||||
event.accept(CHUNK_LOADER_ITEM);
|
||||
}
|
||||
|
||||
private void commonSetup(FMLCommonSetupEvent event)
|
||||
|
||||
Reference in new issue
Block a user