Files
MinecraftForge/src/main/java/net/minecraftforge/event/BuildCreativeModeTabContentsEvent.java
T
d8c84e2949 Forge 1.20
- Creative mode tabs are now a registry; the `BuildContents` event was renamed to `BuildCreativeModeTabContentsEvent` and moved it to its own class
- The pack format is now 15 for both resource packs and data packs
- `ScreenUtils` was deprecated in favor of a `GuiGraphics` extension
- Forge and the MDK were updated to Gradle 8 and FG6
- The Forge common config file was removed (it only contained the deprecated old fields for resource caching, which was removed in 1.19.3)
- Registry dummy entries were removed
- `RemappingVertexPipeline` was fixed to forward the `endVertex()` call
- Forge tool tags were removed in favor of vanilla ones

Co-authored-by: ChampionAsh5357 <ash@ashwork.net>
Co-authored-by: coehlrich <coehlrich@users.noreply.github.com>
Co-authored-by: Dennis C <11262040+XFactHD@users.noreply.github.com>
Co-authored-by: Matyrobbrt <matyrobbrt@gmail.com>
2023-06-07 20:55:09 -05:00

89 lines
3.1 KiB
Java

/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.event;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.common.util.MutableHashedLinkedMap;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.jetbrains.annotations.ApiStatus;
import java.util.function.Supplier;
/**
* Fired when the contents of a specific creative mode tab are being populated.
* This event may be fired multiple times if the operator status of the local player or enabled feature flags changes.
* <p>
* This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
* <p>
* This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.
*/
public final class BuildCreativeModeTabContentsEvent extends Event implements IModBusEvent, CreativeModeTab.Output {
private final CreativeModeTab tab;
private final CreativeModeTab.ItemDisplayParameters parameters;
private final MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> entries;
private final ResourceKey<CreativeModeTab> tabKey;
@ApiStatus.Internal
public BuildCreativeModeTabContentsEvent(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.ItemDisplayParameters parameters, MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> entries) {
this.tab = tab;
this.tabKey = tabKey;
this.parameters = parameters;
this.entries = entries;
}
/**
* {@return the creative mode tab currently populating its contents}
*/
public CreativeModeTab getTab() {
return this.tab;
}
/**
* {@return the key of the creative mode tab currently populating its contents}
*/
public ResourceKey<CreativeModeTab> getTabKey() {
return this.tabKey;
}
public FeatureFlagSet getFlags() {
return this.parameters.enabledFeatures();
}
public CreativeModeTab.ItemDisplayParameters getParameters() {
return parameters;
}
public boolean hasPermissions() {
return this.parameters.hasPermissions();
}
public MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> getEntries() {
return this.entries;
}
@Override
public void accept(ItemStack stack, CreativeModeTab.TabVisibility visibility) {
getEntries().put(stack, visibility);
}
public void accept(Supplier<? extends ItemLike> item, CreativeModeTab.TabVisibility visibility) {
this.accept(item.get(), visibility);
}
public void accept(Supplier<? extends ItemLike> item) {
this.accept(item.get());
}
}