mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +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
@@ -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
|
||||
|
||||
Reference in new issue
Block a user