mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
1.21.6 - New EventBus 7
A full rewrite and redesign of the library that offers much better performance, new features and fixes all previous design flaws See the migration guide here: https://gist.github.com/PaintNinja/ad82c224aecee25efac1ea3e2cf19b91 Co-authored-by: Paint_Ninja <[email protected]>
This commit is contained in:
642 files changed
+7258
-6187
No files matched your search
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An immutable ordered set (not implementing {@link java.util.Set}) of chunk {@linkplain RenderType render types}.
|
||||
* <p>
|
||||
* Considerably speeds up lookups and merges of sets of chunk {@linkplain RenderType render types}.
|
||||
* Users should cache their instances of this class whenever possible, as instantiating it is cheap, but not free.
|
||||
*/
|
||||
public sealed class ChunkRenderTypeSet implements Iterable<RenderType>
|
||||
{
|
||||
private static final List<RenderType> CHUNK_RENDER_TYPES_LIST = RenderType.chunkBufferLayers();
|
||||
private static final RenderType[] CHUNK_RENDER_TYPES = CHUNK_RENDER_TYPES_LIST.toArray(new RenderType[0]);
|
||||
|
||||
private static final ChunkRenderTypeSet NONE = new None();
|
||||
private static final ChunkRenderTypeSet ALL = new All();
|
||||
|
||||
public static ChunkRenderTypeSet none()
|
||||
{
|
||||
return NONE;
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet all()
|
||||
{
|
||||
return ALL;
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet of(RenderType... renderTypes)
|
||||
{
|
||||
return of(Arrays.asList(renderTypes));
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet of(Collection<RenderType> renderTypes)
|
||||
{
|
||||
if (renderTypes.isEmpty())
|
||||
return none();
|
||||
return of((Iterable<RenderType>) renderTypes);
|
||||
}
|
||||
|
||||
private static ChunkRenderTypeSet of(Iterable<RenderType> renderTypes)
|
||||
{
|
||||
var bits = new BitSet();
|
||||
for (RenderType renderType : renderTypes)
|
||||
{
|
||||
int index = renderType.getChunkLayerId();
|
||||
Preconditions.checkArgument(index >= 0, "Attempted to create chunk render type set with a non-chunk render type: " + renderType);
|
||||
bits.set(index);
|
||||
}
|
||||
return new ChunkRenderTypeSet(bits);
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet union(ChunkRenderTypeSet... sets)
|
||||
{
|
||||
return union(Arrays.asList(sets));
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet union(Collection<ChunkRenderTypeSet> sets)
|
||||
{
|
||||
if (sets.isEmpty())
|
||||
return none();
|
||||
return union((Iterable<ChunkRenderTypeSet>) sets);
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet union(Iterable<ChunkRenderTypeSet> sets)
|
||||
{
|
||||
var bits = new BitSet();
|
||||
for (var set : sets)
|
||||
bits.or(set.bits);
|
||||
return new ChunkRenderTypeSet(bits);
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet intersection(ChunkRenderTypeSet... sets)
|
||||
{
|
||||
return intersection(Arrays.asList(sets));
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet intersection(Collection<ChunkRenderTypeSet> sets)
|
||||
{
|
||||
if (sets.isEmpty())
|
||||
return all();
|
||||
return intersection((Iterable<ChunkRenderTypeSet>) sets);
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet intersection(Iterable<ChunkRenderTypeSet> sets)
|
||||
{
|
||||
var bits = new BitSet();
|
||||
bits.set(0, CHUNK_RENDER_TYPES.length);
|
||||
for (var set : sets)
|
||||
bits.and(set.bits);
|
||||
return new ChunkRenderTypeSet(bits);
|
||||
}
|
||||
|
||||
private final BitSet bits;
|
||||
|
||||
private ChunkRenderTypeSet(BitSet bits)
|
||||
{
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return bits.isEmpty();
|
||||
}
|
||||
|
||||
public boolean contains(RenderType renderType)
|
||||
{
|
||||
int id = renderType.getChunkLayerId();
|
||||
return id >= 0 && bits.get(id);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<RenderType> iterator()
|
||||
{
|
||||
return new IteratorImpl();
|
||||
}
|
||||
|
||||
public List<RenderType> asList()
|
||||
{
|
||||
return ImmutableList.copyOf(this);
|
||||
}
|
||||
|
||||
private final class IteratorImpl implements Iterator<RenderType>
|
||||
{
|
||||
private int index = bits.nextSetBit(0);
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return index >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType next()
|
||||
{
|
||||
var renderType = CHUNK_RENDER_TYPES[index];
|
||||
index = bits.nextSetBit(index + 1);
|
||||
return renderType;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class None extends ChunkRenderTypeSet
|
||||
{
|
||||
private None()
|
||||
{
|
||||
super(new BitSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(RenderType renderType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<RenderType> iterator()
|
||||
{
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RenderType> asList()
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class All extends ChunkRenderTypeSet
|
||||
{
|
||||
private All()
|
||||
{
|
||||
super(Util.make(new BitSet(), bits -> bits.set(0, CHUNK_RENDER_TYPES.length)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(RenderType renderType)
|
||||
{
|
||||
return renderType.getChunkLayerId() >= 0; // Could just return true for efficiency purposes, but checking is near-free
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<RenderType> iterator()
|
||||
{
|
||||
return CHUNK_RENDER_TYPES_LIST.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RenderType> asList()
|
||||
{
|
||||
return CHUNK_RENDER_TYPES_LIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.multiplayer.ClientSuggestionProvider;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
@@ -39,7 +40,7 @@ public class ClientCommandHandler {
|
||||
private static CommandDispatcher<CommandSourceStack> commands = null;
|
||||
|
||||
public static void init() {
|
||||
MinecraftForge.EVENT_BUS.addListener(ClientCommandHandler::handleClientPlayerLogin);
|
||||
ClientPlayerNetworkEvent.LoggingIn.BUS.addListener(ClientCommandHandler::handleClientPlayerLogin);
|
||||
}
|
||||
|
||||
private static void handleClientPlayerLogin(ClientPlayerNetworkEvent.LoggingIn event) {
|
||||
@@ -56,24 +57,24 @@ public class ClientCommandHandler {
|
||||
* with server commands in suggestions
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static CommandDispatcher<SharedSuggestionProvider> mergeServerCommands(CommandDispatcher<SharedSuggestionProvider> serverCommands, CommandBuildContext buildContext) {
|
||||
public static <T extends SharedSuggestionProvider> CommandDispatcher<T> mergeServerCommands(CommandDispatcher<T> serverCommands, CommandBuildContext buildContext) {
|
||||
CommandDispatcher<CommandSourceStack> commandsTemp = new CommandDispatcher<>();
|
||||
MinecraftForge.EVENT_BUS.post(new RegisterClientCommandsEvent(commandsTemp, buildContext));
|
||||
RegisterClientCommandsEvent.BUS.post(new RegisterClientCommandsEvent(commandsTemp, buildContext));
|
||||
|
||||
// Copies the client commands into another RootCommandNode so that redirects can't be used with server commands
|
||||
commands = new CommandDispatcher<>();
|
||||
copy(commandsTemp.getRoot(), commands.getRoot());
|
||||
|
||||
// Copies the server commands into another RootCommandNode so that redirects can't be used with client commands
|
||||
RootCommandNode<SharedSuggestionProvider> serverCommandsRoot = serverCommands.getRoot();
|
||||
CommandDispatcher<SharedSuggestionProvider> newServerCommands = new CommandDispatcher<>();
|
||||
RootCommandNode<T> serverCommandsRoot = serverCommands.getRoot();
|
||||
CommandDispatcher<T> newServerCommands = new CommandDispatcher<>();
|
||||
copy(serverCommandsRoot, newServerCommands.getRoot());
|
||||
|
||||
// Copies the client side commands into the server side commands to be used for suggestions
|
||||
CommandHelper.mergeCommandNode(commands.getRoot(), newServerCommands.getRoot(), new IdentityHashMap<>(), getSource(), (context) -> 0, (suggestions) -> {
|
||||
@SuppressWarnings("unchecked")
|
||||
var shared = (SuggestionProvider<SharedSuggestionProvider>)(SuggestionProvider<?>)suggestions;
|
||||
var suggestionProvider = SuggestionProviders.safelySwap(shared);
|
||||
var shared = (SuggestionProvider<T>)(SuggestionProvider<?>)suggestions;
|
||||
var suggestionProvider = shared; //SuggestionProviders.safelySwap(shared);
|
||||
if (suggestionProvider == SuggestionProviders.ASK_SERVER) {
|
||||
suggestionProvider = (context, builder) -> {
|
||||
ClientCommandSourceStack source = getSource();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
import net.minecraft.client.resources.model.UnbakedGeometry;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
@@ -14,7 +14,7 @@ import net.minecraftforge.client.event.RegisterNamedRenderTypesEvent;
|
||||
import net.minecraftforge.client.model.DynamicFluidContainerModel;
|
||||
import net.minecraftforge.client.model.ItemLayerGeometry;
|
||||
import net.minecraftforge.client.model.obj.ObjLoader;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD, modid = "forge")
|
||||
@@ -34,6 +34,6 @@ public class ClientForgeMod {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterNamedRenderTypes(RegisterNamedRenderTypesEvent event) {
|
||||
event.register("item_unlit", RenderType.translucent(), ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get());
|
||||
event.register("item_unlit", ChunkSectionLayer.TRANSLUCENT, ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get());
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.mojang.math.Transformation;
|
||||
|
||||
import net.minecraft.FileUtil;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
@@ -40,12 +41,12 @@ import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.client.particle.ParticleRenderType;
|
||||
import net.minecraft.client.player.ClientInput;
|
||||
import net.minecraft.client.renderer.FogParameters;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
||||
import net.minecraft.client.renderer.fog.FogData;
|
||||
import net.minecraft.client.renderer.texture.SpriteContents;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -126,7 +127,6 @@ import net.minecraftforge.client.textures.ForgeTextureMetadata;
|
||||
import net.minecraftforge.client.textures.TextureAtlasSpriteLoaderManager;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
@@ -144,6 +144,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -196,7 +197,7 @@ public class ForgeHooksClient {
|
||||
guiLayers.push(minecraft.screen);
|
||||
minecraft.screen = Objects.requireNonNull(screen);
|
||||
screen.init(minecraft, minecraft.getWindow().getGuiScaledWidth(), minecraft.getWindow().getGuiScaledHeight());
|
||||
minecraft.getNarrator().sayNow(screen.getNarrationMessage());
|
||||
minecraft.getNarrator().saySystemNow(screen.getNarrationMessage());
|
||||
}
|
||||
|
||||
public static void popGuiLayer(Minecraft minecraft) {
|
||||
@@ -207,7 +208,7 @@ public class ForgeHooksClient {
|
||||
|
||||
popGuiLayerInternal(minecraft);
|
||||
if (minecraft.screen != null)
|
||||
minecraft.getNarrator().sayNow(minecraft.screen.getNarrationMessage());
|
||||
minecraft.getNarrator().saySystemNow(minecraft.screen.getNarrationMessage());
|
||||
}
|
||||
|
||||
public static float getGuiFarPlane() {
|
||||
@@ -218,11 +219,11 @@ public class ForgeHooksClient {
|
||||
}
|
||||
|
||||
public static boolean onClientPauseChangePre(boolean pause) {
|
||||
return MinecraftForge.EVENT_BUS.post(new ClientPauseChangeEvent.Pre(pause));
|
||||
return ClientPauseChangeEvent.Pre.BUS.post(new ClientPauseChangeEvent.Pre(pause));
|
||||
}
|
||||
|
||||
public static void onClientPauseChangePost(boolean pause) {
|
||||
MinecraftForge.EVENT_BUS.post(new ClientPauseChangeEvent.Post(pause));
|
||||
ClientPauseChangeEvent.Post.BUS.post(new ClientPauseChangeEvent.Post(pause));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -236,17 +237,17 @@ public class ForgeHooksClient {
|
||||
switch (target.getType()) {
|
||||
case BLOCK:
|
||||
if (!(target instanceof BlockHitResult blockTarget)) return false;
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHighlightEvent.Block(context, camera, blockTarget, partialTick, poseStack, bufferSource));
|
||||
return RenderHighlightEvent.Block.BUS.post(new RenderHighlightEvent.Block(context, camera, blockTarget, partialTick, poseStack, bufferSource));
|
||||
case ENTITY:
|
||||
if (!(target instanceof EntityHitResult entityTarget)) return false;
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHighlightEvent.Entity(context, camera, entityTarget, partialTick, poseStack, bufferSource));
|
||||
return RenderHighlightEvent.Entity.BUS.post(new RenderHighlightEvent.Entity(context, camera, entityTarget, partialTick, poseStack, bufferSource));
|
||||
default:
|
||||
return false; // NO-OP - This doesn't even get called for anything other than blocks and entities
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, float partialTick, float interpPitch, float swingProgress, float equipProgress, ItemStack stack) {
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(hand, poseStack, bufferSource, packedLight, partialTick, interpPitch, swingProgress, equipProgress, stack));
|
||||
return RenderHandEvent.BUS.post(new RenderHandEvent(hand, poseStack, bufferSource, packedLight, partialTick, interpPitch, swingProgress, equipProgress, stack));
|
||||
}
|
||||
|
||||
public static void onTextureStitchedPost(TextureAtlas map) {
|
||||
@@ -294,24 +295,24 @@ public class ForgeHooksClient {
|
||||
|
||||
@Nullable
|
||||
public static SoundInstance playSound(SoundEngine manager, SoundInstance sound) {
|
||||
return MinecraftForge.EVENT_BUS.fire(new PlaySoundEvent(manager, sound)).getSound();
|
||||
return PlaySoundEvent.BUS.fire(new PlaySoundEvent(manager, sound)).getSound();
|
||||
}
|
||||
|
||||
public static void drawScreen(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().pushMatrix();
|
||||
for (Screen layer : guiLayers) {
|
||||
// Prevent the background layers from thinking the mouse is over their controls and showing them as highlighted.
|
||||
drawScreenInternal(layer, guiGraphics, Integer.MAX_VALUE, Integer.MAX_VALUE, partialTick);
|
||||
guiGraphics.pose().translate(0, 0, 10000);
|
||||
//guiGraphics.pose().translate(0, 0, 10000);
|
||||
}
|
||||
drawScreenInternal(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
guiGraphics.pose().popPose();
|
||||
guiGraphics.pose().popMatrix();
|
||||
}
|
||||
|
||||
private static void drawScreenInternal(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
if (!MinecraftForge.EVENT_BUS.post(new ScreenEvent.Render.Pre(screen, guiGraphics, mouseX, mouseY, partialTick)))
|
||||
if (!ScreenEvent.Render.Pre.BUS.post(new ScreenEvent.Render.Pre(screen, guiGraphics, mouseX, mouseY, partialTick)))
|
||||
screen.renderWithTooltip(guiGraphics, mouseX, mouseY, partialTick);
|
||||
MinecraftForge.EVENT_BUS.post(new ScreenEvent.Render.Post(screen, guiGraphics, mouseX, mouseY, partialTick));
|
||||
ScreenEvent.Render.Post.BUS.post(new ScreenEvent.Render.Post(screen, guiGraphics, mouseX, mouseY, partialTick));
|
||||
}
|
||||
|
||||
public static Vector3f getFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, float fogRed, float fogGreen, float fogBlue) {
|
||||
@@ -321,29 +322,20 @@ public class ForgeHooksClient {
|
||||
if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(level, camera.getBlockPosition())))
|
||||
fluidFogColor = IClientFluidTypeExtensions.of(state).modifyFogColor(camera, partialTick, level, renderDistance, darkenWorldAmount, fluidFogColor);
|
||||
|
||||
ViewportEvent.ComputeFogColor event = new ViewportEvent.ComputeFogColor(camera, partialTick, fluidFogColor.x(), fluidFogColor.y(), fluidFogColor.z());
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
var event = ViewportEvent.ComputeFogColor.BUS.fire(new ViewportEvent.ComputeFogColor(camera, partialTick, fluidFogColor.x(), fluidFogColor.y(), fluidFogColor.z()));
|
||||
|
||||
fluidFogColor.set(event.getRed(), event.getGreen(), event.getBlue());
|
||||
return fluidFogColor;
|
||||
}
|
||||
|
||||
public static FogParameters getFogParameters(FogRenderer.FogMode mode, FogType type, Camera camera, float partialTick, float renderDistance, FogParameters original) {
|
||||
var ret = original;
|
||||
public static Vector4f setupFog(FogType type, Camera camera, DeltaTracker delta, FogData data, Vector4f color) {
|
||||
// Modify fog rendering depending on the fluid
|
||||
FluidState state = camera.getEntity().level().getFluidState(camera.getBlockPosition());
|
||||
if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(camera.getEntity().level(), camera.getBlockPosition())))
|
||||
ret = IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, ret);
|
||||
IClientFluidTypeExtensions.of(state).modifyFogRender(camera, type, delta.getRealtimeDeltaTicks(), data, color);
|
||||
|
||||
var event = new ViewportEvent.RenderFog(mode, type, camera, partialTick, ret.start(), ret.end(), ret.shape());
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) {
|
||||
return new FogParameters(
|
||||
event.getNearPlaneDistance(), event.getFarPlaneDistance(), event.getFogShape(),
|
||||
ret.red(), ret.green(), ret.blue(), ret.alpha()
|
||||
);
|
||||
}
|
||||
|
||||
return ret;
|
||||
ViewportEvent.RenderFog.BUS.post(new ViewportEvent.RenderFog(type, camera, delta.getRealtimeDeltaTicks(), data, color));
|
||||
return color;
|
||||
}
|
||||
|
||||
public static void onModifyBakingResult(ModelBakery modelBakery, ModelBakery.BakingResult results) {
|
||||
@@ -384,38 +376,37 @@ public class ForgeHooksClient {
|
||||
return from.getItem().shouldCauseReequipAnimation(from, to, changed);
|
||||
}
|
||||
|
||||
public static CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(GuiGraphics guiGraphics, Window window, LerpingBossEvent bossInfo, int x, int y, int increment) {
|
||||
public static @Nullable CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(GuiGraphics guiGraphics, Window window, LerpingBossEvent bossInfo, int x, int y, int increment) {
|
||||
var evt = new CustomizeGuiOverlayEvent.BossEventProgress(window, guiGraphics,
|
||||
Minecraft.getInstance().getDeltaTracker().getGameTimeDeltaPartialTick(false), bossInfo, x, y, increment);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt;
|
||||
return CustomizeGuiOverlayEvent.BossEventProgress.BUS.post(evt) ? null : evt;
|
||||
}
|
||||
|
||||
public static void onCustomizeChatEvent(GuiGraphics guiGraphics, ChatComponent chat, Window window, int mouseX, int mouseY, int tickCount) {
|
||||
var minecraft = Minecraft.getInstance();
|
||||
var evt = new CustomizeGuiOverlayEvent.Chat(window, guiGraphics, minecraft.getDeltaTracker().getRealtimeDeltaTicks(), 0, chat.getHeight() - 40);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
guiGraphics.pose().pushPose();
|
||||
CustomizeGuiOverlayEvent.Chat.BUS.post(evt);
|
||||
guiGraphics.pose().pushMatrix();
|
||||
// We give the absolute Y position of the chat component in the event and account for the chat component's own offsetting here.
|
||||
guiGraphics.pose().translate(evt.getPosX(), (evt.getPosY() - chat.getHeight() + 40) / chat.getScale(), 0.0D);
|
||||
guiGraphics.pose().translate(evt.getPosX(), (float) ((evt.getPosY() - chat.getHeight() + 40) / chat.getScale()));
|
||||
chat.render(guiGraphics, tickCount, mouseX, mouseY, false);
|
||||
guiGraphics.pose().popPose();
|
||||
guiGraphics.pose().popMatrix();
|
||||
}
|
||||
|
||||
public static void onCustomizeDebugEvent(GuiGraphics guiGraphics, Window window, float partialTick, List<String> text, boolean isLeft) {
|
||||
var evt = new CustomizeGuiOverlayEvent.DebugText(window, guiGraphics, partialTick, text,
|
||||
isLeft ? CustomizeGuiOverlayEvent.DebugText.Side.Left : CustomizeGuiOverlayEvent.DebugText.Side.Right);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
CustomizeGuiOverlayEvent.DebugText.BUS.post(evt);
|
||||
}
|
||||
|
||||
public static void onClientChangeGameType(PlayerInfo info, GameType currentGameMode, GameType newGameMode) {
|
||||
if (currentGameMode != newGameMode) {
|
||||
MinecraftForge.EVENT_BUS.post(new ClientPlayerChangeGameTypeEvent(info, currentGameMode, newGameMode));
|
||||
ClientPlayerChangeGameTypeEvent.BUS.post(new ClientPlayerChangeGameTypeEvent(info, currentGameMode, newGameMode));
|
||||
}
|
||||
}
|
||||
|
||||
public static void onMovementInputUpdate(Player player, ClientInput movementInput) {
|
||||
MinecraftForge.EVENT_BUS.post(new MovementInputUpdateEvent(player, movementInput));
|
||||
MovementInputUpdateEvent.BUS.post(new MovementInputUpdateEvent(player, movementInput));
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyPressed(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
@@ -437,7 +428,7 @@ public class ForgeHooksClient {
|
||||
}
|
||||
|
||||
public static void onKeyInput(int key, int scanCode, int action, int modifiers) {
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.Key(key, scanCode, action, modifiers));
|
||||
InputEvent.Key.BUS.post(new InputEvent.Key(key, scanCode, action, modifiers));
|
||||
}
|
||||
|
||||
public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) {
|
||||
@@ -576,13 +567,13 @@ public class ForgeHooksClient {
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.unknown", target.forgeData.type());
|
||||
}
|
||||
|
||||
guiGraphics.blit(RenderType::guiTextured, ICON_SHEET, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256);
|
||||
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, ICON_SHEET, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256);
|
||||
|
||||
if(relativeMouseX > width - 15 && relativeMouseX < width && relativeMouseY > 10 && relativeMouseY < 26) {
|
||||
//this is not the most proper way to do it,
|
||||
//but works best here and has the least maintenance overhead
|
||||
var lines = Arrays.stream(tooltip.split("\n")).map(Component::literal).toList();
|
||||
gui.setTooltipForNextRenderPass(Lists.transform(lines, Component::getVisualOrderText));
|
||||
guiGraphics.setTooltipForNextFrame(Lists.transform(lines, Component::getVisualOrderText), relativeMouseX + x, relativeMouseY + y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,26 +599,26 @@ public class ForgeHooksClient {
|
||||
@Nullable
|
||||
public static Component onClientChat(ChatType.Bound boundChatType, Component message, UUID sender) {
|
||||
ClientChatReceivedEvent event = new ClientChatReceivedEvent(boundChatType, message, sender);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
|
||||
return ClientChatReceivedEvent.BUS.post(event) ? null : event.getMessage();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Component onClientPlayerChat(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, UUID sender) {
|
||||
ClientChatReceivedEvent.Player event = new ClientChatReceivedEvent.Player(boundChatType, message, playerChatMessage, sender);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
|
||||
return ClientChatReceivedEvent.Player.BUS.post(event) ? null : event.getMessage();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Component onClientSystemMessage(Component message, boolean overlay) {
|
||||
var event = new SystemMessageReceivedEvent(message, overlay);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
|
||||
return SystemMessageReceivedEvent.BUS.post(event) ? null : event.getMessage();
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String onClientSendMessage(String message) {
|
||||
ClientChatEvent event = new ClientChatEvent(message);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? "" : event.getMessage();
|
||||
return ClientChatEvent.BUS.post(event) ? "" : event.getMessage();
|
||||
}
|
||||
|
||||
public static Font getTooltipFont(@NotNull ItemStack stack, Font fallbackFont) {
|
||||
@@ -635,10 +626,9 @@ public class ForgeHooksClient {
|
||||
return stackFont == null ? fallbackFont : stackFont;
|
||||
}
|
||||
|
||||
public static RenderTooltipEvent.Pre onRenderTooltipPre(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, @NotNull List<ClientTooltipComponent> components, @NotNull Font fallbackFont, @NotNull ClientTooltipPositioner positioner) {
|
||||
public static @Nullable RenderTooltipEvent.Pre onRenderTooltipPre(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, @NotNull List<ClientTooltipComponent> components, @NotNull Font fallbackFont, @NotNull ClientTooltipPositioner positioner) {
|
||||
var preEvent = new RenderTooltipEvent.Pre(stack, graphics, x, y, screenWidth, screenHeight, getTooltipFont(stack, fallbackFont), components, positioner);
|
||||
MinecraftForge.EVENT_BUS.post(preEvent);
|
||||
return preEvent;
|
||||
return RenderTooltipEvent.Pre.BUS.post(preEvent) ? null : preEvent;
|
||||
}
|
||||
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponents(ItemStack stack, List<? extends FormattedText> textElements, int mouseX, int screenWidth, int screenHeight, Font fallbackFont) {
|
||||
@@ -657,7 +647,7 @@ public class ForgeHooksClient {
|
||||
Font font = getTooltipFont(stack, fallbackFont);
|
||||
|
||||
var event = new RenderTooltipEvent.GatherComponents(stack, screenWidth, screenHeight, elements, -1);
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return List.of();
|
||||
if (RenderTooltipEvent.GatherComponents.BUS.post(event)) return List.of();
|
||||
|
||||
// text wrapping
|
||||
int tooltipTextWidth = event.getTooltipElements().stream()
|
||||
@@ -723,7 +713,7 @@ public class ForgeHooksClient {
|
||||
|
||||
public static boolean isBlockInSolidLayer(BlockState state) {
|
||||
var model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state);
|
||||
return model.getRenderTypes(state, RandomSource.create(), ModelData.EMPTY).contains(RenderType.solid());
|
||||
return model.getRenderTypes(state, RandomSource.create(), ModelData.EMPTY).contains(ChunkSectionLayer.SOLID);
|
||||
}
|
||||
|
||||
public static void createWorldConfirmationScreen(Runnable doConfirmedWorldLoad) {
|
||||
@@ -751,7 +741,7 @@ public class ForgeHooksClient {
|
||||
}
|
||||
|
||||
public static boolean renderBlockOverlay(Player player, PoseStack mat, RenderBlockScreenEffectEvent.OverlayType type, BlockState block, BlockPos pos) {
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderBlockScreenEffectEvent(player, mat, type, block, pos));
|
||||
return RenderBlockScreenEffectEvent.BUS.post(new RenderBlockScreenEffectEvent(player, mat, type, block, pos));
|
||||
}
|
||||
|
||||
public static int getMaxMipmapLevel(int width, int height) {
|
||||
|
||||
@@ -6,13 +6,15 @@
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.opengl.GlConst;
|
||||
import com.mojang.blaze3d.opengl.GlTexture;
|
||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||
import com.mojang.blaze3d.platform.DepthTestFunction;
|
||||
import com.mojang.blaze3d.platform.DestFactor;
|
||||
import com.mojang.blaze3d.platform.SourceFactor;
|
||||
import com.mojang.blaze3d.systems.GpuDevice;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.textures.GpuTexture;
|
||||
import com.mojang.blaze3d.textures.GpuTextureView;
|
||||
import com.mojang.blaze3d.textures.TextureFormat;
|
||||
|
||||
import net.minecraft.Util;
|
||||
@@ -25,14 +27,11 @@ import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.TriState;
|
||||
import net.minecraftforge.common.util.NonNullLazy;
|
||||
import net.minecraftforge.common.util.NonNullSupplier;
|
||||
import net.minecraftforge.fml.earlydisplay.DisplayWindow;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.lwjgl.opengl.GL30C;
|
||||
|
||||
@@ -56,7 +55,7 @@ public enum ForgeRenderTypes {
|
||||
* @see ForgeRenderTypes#getTextSeeThrough
|
||||
* @see ForgeRenderTypes#getTextIntensitySeeThrough
|
||||
*/
|
||||
public static TriState enableTextTextureLinearFiltering = TriState.FALSE;
|
||||
public static boolean enableTextTextureLinearFiltering = false;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static ResourceLocation blockAtlas() {
|
||||
@@ -230,7 +229,7 @@ public enum ForgeRenderTypes {
|
||||
false,
|
||||
RenderPipelines.ENTITY_TRANSLUCENT,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false))
|
||||
.setTextureState(new TextureStateShard(textureLocation, false))
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
@@ -244,7 +243,7 @@ public enum ForgeRenderTypes {
|
||||
true,
|
||||
RenderPipelines.ENTITY_TRANSLUCENT,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false))
|
||||
.setTextureState(new TextureStateShard(textureLocation, false))
|
||||
.setLightmapState(NO_LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
@@ -258,7 +257,7 @@ public enum ForgeRenderTypes {
|
||||
false,
|
||||
RenderPipelines.ENTITY_TRANSLUCENT,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(textureLocation, TriState.FALSE, false))
|
||||
.setTextureState(new TextureStateShard(textureLocation, false))
|
||||
.setLightmapState(NO_LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
@@ -273,7 +272,7 @@ public enum ForgeRenderTypes {
|
||||
false,
|
||||
RenderPipelines.ENTITY_SOLID,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false))
|
||||
.setTextureState(new TextureStateShard(locationIn, false))
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true)
|
||||
@@ -289,7 +288,7 @@ public enum ForgeRenderTypes {
|
||||
false,
|
||||
RenderPipelines.ENTITY_CUTOUT,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false))
|
||||
.setTextureState(new TextureStateShard(locationIn, false))
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true)
|
||||
@@ -305,7 +304,7 @@ public enum ForgeRenderTypes {
|
||||
false,
|
||||
RenderPipelines.ENTITY_SMOOTH_CUTOUT,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(locationIn, TriState.FALSE, true))
|
||||
.setTextureState(new TextureStateShard(locationIn, true))
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true)
|
||||
@@ -321,7 +320,7 @@ public enum ForgeRenderTypes {
|
||||
true,
|
||||
RenderPipelines.ITEM_ENTITY_TRANSLUCENT_CULL,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false))
|
||||
.setTextureState(new TextureStateShard(locationIn, false))
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true)
|
||||
@@ -367,7 +366,7 @@ public enum ForgeRenderTypes {
|
||||
true,
|
||||
RenderPipelines.TEXT_POLYGON_OFFSET,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new CustomizableTextureState(locationIn, () -> enableTextTextureLinearFiltering, () -> false))
|
||||
.setTextureState(new CustomizableTextureState(locationIn, false))
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.createCompositeState(false)
|
||||
);
|
||||
@@ -438,7 +437,7 @@ public enum ForgeRenderTypes {
|
||||
true,
|
||||
RenderPipelines.TRANSLUCENT_PARTICLE,
|
||||
CompositeState.builder()
|
||||
.setTextureState(new TextureStateShard(locationIn, TriState.FALSE, false))
|
||||
.setTextureState(new TextureStateShard(locationIn, false))
|
||||
.setOutputState(PARTICLES_TARGET)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.createCompositeState(true)
|
||||
@@ -467,41 +466,35 @@ public enum ForgeRenderTypes {
|
||||
}
|
||||
|
||||
private static class CustomizableTextureState extends TextureStateShard {
|
||||
// [VEN] Here to make init shorter
|
||||
private static final Supplier<TriState> BLUR_STATE = () -> enableTextTextureLinearFiltering;
|
||||
private static final Supplier<Boolean> MIP_ON_STATE = () -> true;
|
||||
private static final Supplier<Boolean> MIP_OFF_STATE = () -> false;
|
||||
private CustomizableTextureState(ResourceLocation resLoc, boolean mipmap) {
|
||||
this(resLoc, BLUR_STATE, mipmap ? MIP_ON_STATE : MIP_OFF_STATE);
|
||||
}
|
||||
|
||||
private CustomizableTextureState(ResourceLocation resLoc, Supplier<TriState> blur, Supplier<Boolean> mipmap) {
|
||||
super(resLoc, blur.get(), mipmap.get());
|
||||
super(resLoc, mipmap);
|
||||
this.setupState = () -> {
|
||||
this.blur = blur.get();
|
||||
this.mipmap = mipmap.get();
|
||||
TextureManager manager = Minecraft.getInstance().getTextureManager();
|
||||
var texture = manager.getTexture(resLoc);
|
||||
texture.setFilter(this.blur, this.mipmap);
|
||||
RenderSystem.setShaderTexture(0, texture.getTexture());
|
||||
texture.setFilter(enableTextTextureLinearFiltering, this.mipmap);
|
||||
RenderSystem.setShaderTexture(0, texture.getTextureView());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static class LoadingOverlayTextureState extends TextureStateShard {
|
||||
private static final ResourceLocation LOADING_TEXTURE = ResourceLocation.fromNamespaceAndPath("forge", "loading_overlay");
|
||||
private final GlTexture texture;
|
||||
private final GpuTexture texture;
|
||||
private final GpuTextureView textureView;
|
||||
|
||||
private LoadingOverlayTextureState(DisplayWindow window) {
|
||||
super(LOADING_TEXTURE, TriState.DEFAULT, false);
|
||||
this.texture = new GlTexture(LOADING_TEXTURE.toString(), TextureFormat.RGBA8,
|
||||
window.context().width(), window.context().height(), 0,
|
||||
window.getFramebufferTextureId()) {};
|
||||
super(LOADING_TEXTURE, false);
|
||||
|
||||
GpuDevice gpu = RenderSystem.getDevice();
|
||||
this.texture = gpu.createTexture(LOADING_TEXTURE.toString(), 5, TextureFormat.RGBA8,
|
||||
window.context().width(), window.context().height(),
|
||||
1, window.getFramebufferTextureId());
|
||||
this.textureView = gpu.createTextureView(this.texture);
|
||||
|
||||
this.setupState = () -> {
|
||||
GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_NEAREST);
|
||||
GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MAG_FILTER, GlConst.GL_NEAREST);
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
RenderSystem.setShaderTexture(0, this.textureView);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RegisterNamedRenderTypesEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
@@ -43,13 +44,13 @@ public final class NamedRenderTypeManager {
|
||||
* Pre-registers vanilla render types.
|
||||
*/
|
||||
private static void preRegisterVanillaRenderTypes(Map<ResourceLocation, RenderTypeGroup> blockRenderTypes) {
|
||||
blockRenderTypes.put(rl("solid"), new RenderTypeGroup(RenderType.solid(), ForgeRenderTypes.ITEM_LAYERED_SOLID.get()));
|
||||
blockRenderTypes.put(rl("cutout"), new RenderTypeGroup(RenderType.cutout(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get()));
|
||||
blockRenderTypes.put(rl("solid"), new RenderTypeGroup(ChunkSectionLayer.SOLID, ForgeRenderTypes.ITEM_LAYERED_SOLID.get()));
|
||||
blockRenderTypes.put(rl("cutout"), new RenderTypeGroup(ChunkSectionLayer.CUTOUT, ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get()));
|
||||
// Generally entity/item rendering shouldn't use mipmaps, so cutout_mipped has them off by default. To enforce them, use cutout_mipped_all.
|
||||
blockRenderTypes.put(rl("cutout_mipped"), new RenderTypeGroup(RenderType.cutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get()));
|
||||
blockRenderTypes.put(rl("cutout_mipped_all"), new RenderTypeGroup(RenderType.cutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get()));
|
||||
blockRenderTypes.put(rl("translucent"), new RenderTypeGroup(RenderType.translucent(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get()));
|
||||
blockRenderTypes.put(rl("tripwire"), new RenderTypeGroup(RenderType.tripwire(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get()));
|
||||
blockRenderTypes.put(rl("cutout_mipped"), new RenderTypeGroup(ChunkSectionLayer.CUTOUT_MIPPED, ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get()));
|
||||
blockRenderTypes.put(rl("cutout_mipped_all"), new RenderTypeGroup(ChunkSectionLayer.CUTOUT_MIPPED, ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get()));
|
||||
blockRenderTypes.put(rl("translucent_moving_block"), new RenderTypeGroup(ChunkSectionLayer.TRANSLUCENT, ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get()));
|
||||
blockRenderTypes.put(rl("tripwire"), new RenderTypeGroup(ChunkSectionLayer.TRIPWIRE, ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get()));
|
||||
}
|
||||
|
||||
private static ResourceLocation rl(String paht) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
|
||||
/**
|
||||
* A set of functionally equivalent shaders. One using {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#BLOCK},
|
||||
@@ -13,7 +14,7 @@ import net.minecraft.client.renderer.RenderType;
|
||||
* {@code entityFabulous} may support custom render targets and other aspects of the fabulous pipeline, or can otherwise
|
||||
* be the same as {@code entity}.
|
||||
*/
|
||||
public record RenderTypeGroup(RenderType block, RenderType entity, RenderType entityFabulous) {
|
||||
public record RenderTypeGroup(ChunkSectionLayer block, RenderType entity, RenderType entityFabulous) {
|
||||
public static final RenderTypeGroup EMPTY = new RenderTypeGroup(null, null, null);
|
||||
|
||||
public RenderTypeGroup {
|
||||
@@ -21,7 +22,7 @@ public record RenderTypeGroup(RenderType block, RenderType entity, RenderType en
|
||||
throw new IllegalArgumentException("The render types in a group must either be all null, or all non-null.");
|
||||
}
|
||||
|
||||
public RenderTypeGroup(RenderType block, RenderType entity) {
|
||||
public RenderTypeGroup(ChunkSectionLayer block, RenderType entity) {
|
||||
this(block, entity, entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.block.model.BlockStateModel;
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -28,8 +29,8 @@ public final class RenderTypeHelper {
|
||||
* Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(BlockState)}.
|
||||
*/
|
||||
@NotNull
|
||||
public static RenderType getEntityRenderType(RenderType chunkRenderType) {
|
||||
return chunkRenderType == RenderType.translucent() ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet();
|
||||
public static RenderType getEntityRenderType(ChunkSectionLayer layer) {
|
||||
return layer == ChunkSectionLayer.TRANSLUCENT ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,10 +40,17 @@ public final class RenderTypeHelper {
|
||||
* Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getMovingBlockRenderType(BlockState)}.
|
||||
*/
|
||||
@NotNull
|
||||
public static RenderType getMovingBlockRenderType(RenderType renderType) {
|
||||
if (renderType == RenderType.translucent())
|
||||
return RenderType.translucentMovingBlock();
|
||||
return renderType;
|
||||
public static RenderType getMovingBlockRenderType(ChunkSectionLayer layer) {
|
||||
if (layer == null)
|
||||
return RenderType.solid();
|
||||
|
||||
return switch (layer) {
|
||||
case SOLID -> RenderType.solid();
|
||||
case CUTOUT_MIPPED -> RenderType.cutoutMipped();
|
||||
case CUTOUT -> RenderType.cutout();
|
||||
case TRANSLUCENT -> RenderType.translucentMovingBlock();
|
||||
case TRIPWIRE -> RenderType.tripwire();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,8 +63,8 @@ public final class RenderTypeHelper {
|
||||
public static RenderType getFallbackItemRenderType(ItemStack stack, BlockStateModel model) {
|
||||
if (stack.getItem() instanceof BlockItem blockItem) {
|
||||
var renderTypes = model.getRenderTypes(blockItem.getBlock().defaultBlockState(), RandomSource.create(42), ModelData.EMPTY);
|
||||
if (renderTypes.contains(RenderType.translucent()))
|
||||
return getEntityRenderType(RenderType.translucent());
|
||||
if (renderTypes.contains(ChunkSectionLayer.TRANSLUCENT))
|
||||
return getEntityRenderType(ChunkSectionLayer.TRANSLUCENT);
|
||||
return Sheets.cutoutBlockSheet();
|
||||
}
|
||||
return Sheets.translucentItemSheet();
|
||||
|
||||
@@ -7,8 +7,9 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -21,15 +22,14 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
**/
|
||||
@Cancelable
|
||||
public final class ClientChatEvent extends Event
|
||||
{
|
||||
public final class ClientChatEvent extends MutableEvent implements Cancellable {
|
||||
public static final CancellableEventBus<ClientChatEvent> BUS = CancellableEventBus.create(ClientChatEvent.class);
|
||||
|
||||
private String message;
|
||||
private final String originalMessage;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ClientChatEvent(String message)
|
||||
{
|
||||
public ClientChatEvent(String message) {
|
||||
this.setMessage(message);
|
||||
this.originalMessage = Strings.nullToEmpty(message);
|
||||
this.message = this.originalMessage;
|
||||
@@ -38,8 +38,7 @@ public final class ClientChatEvent extends Event
|
||||
/**
|
||||
* {@return the message that will be sent to the server, if the event is not cancelled. This can be changed by mods}
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
@@ -48,16 +47,14 @@ public final class ClientChatEvent extends Event
|
||||
*
|
||||
* @param message the new message to be sent
|
||||
*/
|
||||
public void setMessage(String message)
|
||||
{
|
||||
public void setMessage(String message) {
|
||||
this.message = Strings.nullToEmpty(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original message that was to be sent to the server. This cannot be changed by mods}
|
||||
*/
|
||||
public String getOriginalMessage()
|
||||
{
|
||||
public String getOriginalMessage() {
|
||||
return this.originalMessage;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,10 @@ import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import java.util.UUID;
|
||||
@@ -28,8 +30,9 @@ import java.util.UUID;
|
||||
*
|
||||
* @see ChatType
|
||||
*/
|
||||
@Cancelable
|
||||
public sealed class ClientChatReceivedEvent extends Event {
|
||||
public sealed class ClientChatReceivedEvent extends MutableEvent implements Cancellable, InheritableEvent {
|
||||
public static final CancellableEventBus<ClientChatReceivedEvent> BUS = CancellableEventBus.create(ClientChatReceivedEvent.class);
|
||||
|
||||
private Component message;
|
||||
private final ChatType.Bound boundChatType;
|
||||
private final UUID sender;
|
||||
@@ -75,7 +78,7 @@ public sealed class ClientChatReceivedEvent extends Event {
|
||||
/**
|
||||
* {@return {@code true} if the message was sent by the system, {@code false} otherwise}
|
||||
*
|
||||
* @Deprecated Mojang made ChatType a registry, which isn't always accessible when the System messages are sent.
|
||||
* @deprecated Mojang made ChatType a registry, which isn't always accessible when the System messages are sent.
|
||||
* So moved to it's own event. {@link SystemMessageReceivedEvent}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
@@ -95,6 +98,8 @@ public sealed class ClientChatReceivedEvent extends Event {
|
||||
* @see ChatType
|
||||
*/
|
||||
public static final class Player extends ClientChatReceivedEvent {
|
||||
public static final CancellableEventBus<Player> BUS = CancellableEventBus.create(Player.class);
|
||||
|
||||
private final PlayerChatMessage playerChatMessage;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -120,6 +125,8 @@ public sealed class ClientChatReceivedEvent extends Event {
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
public static final class System extends ClientChatReceivedEvent {
|
||||
public static final CancellableEventBus<System> BUS = CancellableEventBus.create(System.class);
|
||||
|
||||
private final boolean overlay;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
@@ -21,7 +24,9 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
* @see ClientPauseChangeEvent.Pre
|
||||
* @see ClientPauseChangeEvent.Post
|
||||
*/
|
||||
public abstract sealed class ClientPauseChangeEvent extends Event {
|
||||
public abstract sealed class ClientPauseChangeEvent extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<ClientPauseChangeEvent> BUS = EventBus.create(ClientPauseChangeEvent.class);
|
||||
|
||||
private final boolean pause;
|
||||
|
||||
public ClientPauseChangeEvent(boolean pause) {
|
||||
@@ -37,8 +42,8 @@ public abstract sealed class ClientPauseChangeEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends ClientPauseChangeEvent {
|
||||
public static final class Pre extends ClientPauseChangeEvent implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
public Pre(boolean pause) {
|
||||
super(pause);
|
||||
@@ -54,6 +59,7 @@ public abstract sealed class ClientPauseChangeEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Post extends ClientPauseChangeEvent {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
public Post(boolean pause) {
|
||||
super(pause);
|
||||
|
||||
+15
-41
@@ -7,55 +7,29 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.common.util.HasResult;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.RecordEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when the client player is notified of a change of {@link GameType} from the server.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @param getInfo the client player information
|
||||
* @param getCurrentGameType the current game type of the player
|
||||
* @param getNewGameType the new game type of the player
|
||||
*/
|
||||
public final class ClientPlayerChangeGameTypeEvent extends Event
|
||||
{
|
||||
private final PlayerInfo info;
|
||||
private final GameType currentGameType;
|
||||
private final GameType newGameType;
|
||||
@NullMarked
|
||||
public record ClientPlayerChangeGameTypeEvent(PlayerInfo getInfo, GameType getCurrentGameType, GameType getNewGameType) implements RecordEvent {
|
||||
public static final EventBus<ClientPlayerChangeGameTypeEvent> BUS = EventBus.create(ClientPlayerChangeGameTypeEvent.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ClientPlayerChangeGameTypeEvent(PlayerInfo info, GameType currentGameType, GameType newGameType)
|
||||
{
|
||||
this.info = info;
|
||||
this.currentGameType = currentGameType;
|
||||
this.newGameType = newGameType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the client player information}
|
||||
*/
|
||||
public PlayerInfo getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the current game type of the player}
|
||||
*/
|
||||
public GameType getCurrentGameType()
|
||||
{
|
||||
return currentGameType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the new game type of the player}
|
||||
*/
|
||||
public GameType getNewGameType()
|
||||
{
|
||||
return newGameType;
|
||||
}
|
||||
public ClientPlayerChangeGameTypeEvent {}
|
||||
}
|
||||
@@ -9,8 +9,9 @@ import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -26,7 +27,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @see LoggingOut
|
||||
* @see Clone
|
||||
**/
|
||||
public abstract sealed class ClientPlayerNetworkEvent extends Event {
|
||||
public abstract sealed class ClientPlayerNetworkEvent extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<ClientPlayerNetworkEvent> BUS = EventBus.create(ClientPlayerNetworkEvent.class);
|
||||
|
||||
private final MultiPlayerGameMode multiPlayerGameMode;
|
||||
private final LocalPlayer player;
|
||||
private final Connection connection;
|
||||
@@ -68,6 +71,8 @@ public abstract sealed class ClientPlayerNetworkEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class LoggingIn extends ClientPlayerNetworkEvent {
|
||||
public static final EventBus<LoggingIn> BUS = EventBus.create(LoggingIn.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public LoggingIn(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) {
|
||||
super(controller, player, networkManager);
|
||||
@@ -85,6 +90,8 @@ public abstract sealed class ClientPlayerNetworkEvent extends Event {
|
||||
@SuppressWarnings("NullableProblems")
|
||||
// Shush IntelliJ, we override non-nullables as nullables in this specific event; see later comment
|
||||
public static final class LoggingOut extends ClientPlayerNetworkEvent {
|
||||
public static final EventBus<LoggingOut> BUS = EventBus.create(LoggingOut.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public LoggingOut(@Nullable final MultiPlayerGameMode controller, @Nullable final LocalPlayer player, @Nullable final Connection networkManager) {
|
||||
//noinspection ConstantConditions we know these are nullable, but we don't want to annotate the super as nullable since this is the only event with nullables
|
||||
@@ -134,6 +141,8 @@ public abstract sealed class ClientPlayerNetworkEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Clone extends ClientPlayerNetworkEvent {
|
||||
public static final EventBus<Clone> BUS = EventBus.create(Clone.class);
|
||||
|
||||
private final LocalPlayer oldPlayer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -24,7 +23,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see ViewportEvent.ComputeFov
|
||||
*/
|
||||
public final class ComputeFovModifierEvent extends Event {
|
||||
public final class ComputeFovModifierEvent extends MutableEvent {
|
||||
public static final EventBus<ComputeFovModifierEvent> BUS = EventBus.create(ComputeFovModifierEvent.class);
|
||||
|
||||
private final Player player;
|
||||
private final float fovModifier;
|
||||
private final float scale;
|
||||
|
||||
@@ -8,8 +8,9 @@ package net.minecraftforge.client.event;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -23,7 +24,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see Render.Foreground
|
||||
* @see Render.Background
|
||||
*/
|
||||
public abstract sealed class ContainerScreenEvent extends Event {
|
||||
public abstract sealed class ContainerScreenEvent extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<ContainerScreenEvent> BUS = EventBus.create(ContainerScreenEvent.class);
|
||||
|
||||
private final AbstractContainerScreen<?> containerScreen;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -49,6 +52,8 @@ public abstract sealed class ContainerScreenEvent extends Event {
|
||||
* @see Background
|
||||
*/
|
||||
public static abstract sealed class Render extends ContainerScreenEvent {
|
||||
public static final EventBus<Render> BUS = EventBus.create(Render.class);
|
||||
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
@@ -95,6 +100,8 @@ public abstract sealed class ContainerScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Foreground extends Render {
|
||||
public static final EventBus<Foreground> BUS = EventBus.create(Foreground.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Foreground(AbstractContainerScreen<?> guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||
super(guiContainer, guiGraphics, mouseX, mouseY);
|
||||
@@ -111,6 +118,8 @@ public abstract sealed class ContainerScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Background extends Render {
|
||||
public static final EventBus<Background> BUS = EventBus.create(Background.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Background(AbstractContainerScreen<?> guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||
super(guiContainer, guiGraphics, mouseX, mouseY);
|
||||
|
||||
@@ -9,9 +9,12 @@ import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.special.SpecialModelRenderer;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
|
||||
public final class CreateSpecialBlockRendererEvent extends MutableEvent {
|
||||
public static final EventBus<CreateSpecialBlockRendererEvent> BUS = EventBus.create(CreateSpecialBlockRendererEvent.class);
|
||||
|
||||
public final class CreateSpecialBlockRendererEvent extends Event {
|
||||
private final Map<Block, SpecialModelRenderer.Unbaked> map;
|
||||
|
||||
public CreateSpecialBlockRendererEvent(Map<Block, SpecialModelRenderer.Unbaked> map) {
|
||||
|
||||
@@ -9,8 +9,10 @@ import com.mojang.blaze3d.platform.Window;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -23,7 +25,9 @@ import java.util.List;
|
||||
* @see DebugText
|
||||
* @see Chat
|
||||
*/
|
||||
public abstract sealed class CustomizeGuiOverlayEvent extends Event {
|
||||
public abstract sealed class CustomizeGuiOverlayEvent extends MutableEvent implements Cancellable, InheritableEvent {
|
||||
public static final CancellableEventBus<CustomizeGuiOverlayEvent> BUS = CancellableEventBus.create(CustomizeGuiOverlayEvent.class);
|
||||
|
||||
private final Window window;
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final float partialTick;
|
||||
@@ -56,8 +60,9 @@ public abstract sealed class CustomizeGuiOverlayEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class BossEventProgress extends CustomizeGuiOverlayEvent {
|
||||
public static final CancellableEventBus<BossEventProgress> BUS = CancellableEventBus.create(BossEventProgress.class);
|
||||
|
||||
private final LerpingBossEvent bossEvent;
|
||||
private final int x;
|
||||
private final int y;
|
||||
@@ -120,6 +125,8 @@ public abstract sealed class CustomizeGuiOverlayEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class DebugText extends CustomizeGuiOverlayEvent {
|
||||
public static final CancellableEventBus<DebugText> BUS = CancellableEventBus.create(DebugText.class);
|
||||
|
||||
private final List<String> text;
|
||||
|
||||
private final Side side;
|
||||
@@ -160,6 +167,8 @@ public abstract sealed class CustomizeGuiOverlayEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Chat extends CustomizeGuiOverlayEvent {
|
||||
public static final CancellableEventBus<Chat> BUS = CancellableEventBus.create(Chat.class);
|
||||
|
||||
private int posX;
|
||||
private int posY;
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ import net.minecraft.world.level.block.SkullBlock.Type;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -53,7 +53,7 @@ import java.util.function.Supplier;
|
||||
* @see EntityRenderersEvent.RegisterRenderers
|
||||
* @see EntityRenderersEvent.AddLayers
|
||||
*/
|
||||
public abstract sealed class EntityRenderersEvent extends Event implements IModBusEvent {
|
||||
public abstract sealed class EntityRenderersEvent implements IModBusEvent {
|
||||
@ApiStatus.Internal
|
||||
protected EntityRenderersEvent() {}
|
||||
|
||||
@@ -66,6 +66,10 @@ public abstract sealed class EntityRenderersEvent extends Event implements IModB
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class RegisterLayerDefinitions extends EntityRenderersEvent {
|
||||
public static EventBus<RegisterLayerDefinitions> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterLayerDefinitions.class);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterLayerDefinitions() {}
|
||||
|
||||
@@ -94,6 +98,10 @@ public abstract sealed class EntityRenderersEvent extends Event implements IModB
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class RegisterRenderers extends EntityRenderersEvent {
|
||||
public static EventBus<RegisterRenderers> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterRenderers.class);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterRenderers() {}
|
||||
|
||||
@@ -128,6 +136,10 @@ public abstract sealed class EntityRenderersEvent extends Event implements IModB
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class AddLayers extends EntityRenderersEvent {
|
||||
public static EventBus<AddLayers> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, AddLayers.class);
|
||||
}
|
||||
|
||||
private final Map<EntityType<?>, EntityRenderer<?, ?>> renderers;
|
||||
private final Map<PlayerSkin.Model, EntityRenderer<? extends Player, ?>> skinMap;
|
||||
private final EntityRendererProvider.Context context;
|
||||
@@ -202,6 +214,10 @@ public abstract sealed class EntityRenderersEvent extends Event implements IModB
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class CreateSkullModels extends EntityRenderersEvent {
|
||||
public static EventBus<CreateSkullModels> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, CreateSkullModels.class);
|
||||
}
|
||||
|
||||
private final ImmutableMap.Builder<Type, Function<EntityModelSet, SkullModelBase>> builder;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.Result;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -67,7 +67,6 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SkullBlock.Type;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundSourceEvent;
|
||||
import net.minecraftforge.client.event.sound.PlayStreamingSourceEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ForgeEventFactoryClient {
|
||||
@@ -75,28 +74,11 @@ public final class ForgeEventFactoryClient {
|
||||
|
||||
private ForgeEventFactoryClient() {}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link MinecraftForge#EVENT_BUS}
|
||||
* @return true if the event is {@link Cancelable} and has been canceled
|
||||
*/
|
||||
private static boolean post(Event e) {
|
||||
return MinecraftForge.EVENT_BUS.post(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link MinecraftForge#EVENT_BUS}, then return the event object
|
||||
* @return the event object passed in and possibly modified by listeners
|
||||
*/
|
||||
private static <E extends Event> E fire(E e) {
|
||||
return MinecraftForge.EVENT_BUS.fire(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an event to the {@link ModLoader#get()} event bus
|
||||
*/
|
||||
private static <T extends Event & IModBusEvent> T fireModBus(T e) {
|
||||
ML.postEvent(e);
|
||||
return e;
|
||||
private static <T extends IModBusEvent> T fireModBus(T e) {
|
||||
return ML.postEventWithReturn(e);
|
||||
}
|
||||
|
||||
public static void onGatherLayers(Map<EntityType<?>, EntityRenderer<?, ?>> renderers, Map<Model, EntityRenderer<? extends Player, ?>> playerRenderers, Context context) {
|
||||
@@ -105,192 +87,190 @@ public final class ForgeEventFactoryClient {
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseReleased(Screen screen, double mouseX, double mouseY, int button) {
|
||||
if (post(new ScreenEvent.MouseButtonReleased.Pre(screen, mouseX, mouseY, button)))
|
||||
if (ScreenEvent.MouseButtonReleased.Pre.BUS.post(new ScreenEvent.MouseButtonReleased.Pre(screen, mouseX, mouseY, button)))
|
||||
return true;
|
||||
|
||||
var ret = screen.mouseReleased(mouseX, mouseY, button);
|
||||
var result = fire(new ScreenEvent.MouseButtonReleased.Post(screen, mouseX, mouseY, button, ret)).getResult();
|
||||
return result == Event.Result.DEFAULT ? ret : result == Event.Result.ALLOW;
|
||||
var result = ScreenEvent.MouseButtonReleased.Post.BUS.fire(new ScreenEvent.MouseButtonReleased.Post(screen, mouseX, mouseY, button, ret)).getResult();
|
||||
return result == Result.DEFAULT ? ret : result == Result.ALLOW;
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseClicked(Screen screen, double mouseX, double mouseY, int button) {
|
||||
var ret = post(new ScreenEvent.MouseButtonPressed.Pre(screen, mouseX, mouseY, button));
|
||||
var ret = ScreenEvent.MouseButtonPressed.Pre.BUS.post(new ScreenEvent.MouseButtonPressed.Pre(screen, mouseX, mouseY, button));
|
||||
if (!ret)
|
||||
ret = screen.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
var result = fire(new ScreenEvent.MouseButtonPressed.Post(screen, mouseX, mouseY, button, ret)).getResult();
|
||||
return result == Event.Result.DEFAULT ? ret : result == Event.Result.ALLOW;
|
||||
var result = ScreenEvent.MouseButtonPressed.Post.BUS.fire(new ScreenEvent.MouseButtonPressed.Post(screen, mouseX, mouseY, button, ret)).getResult();
|
||||
return result == Result.DEFAULT ? ret : result == Result.ALLOW;
|
||||
}
|
||||
|
||||
public static boolean onMouseButtonPre(int button, int action, int mods) {
|
||||
return post(new InputEvent.MouseButton.Pre(button, action, mods));
|
||||
return InputEvent.MouseButton.Pre.BUS.post(new InputEvent.MouseButton.Pre(button, action, mods));
|
||||
}
|
||||
|
||||
public static void onMouseButtonPost(int button, int action, int mods) {
|
||||
post(new InputEvent.MouseButton.Post(button, action, mods));
|
||||
InputEvent.MouseButton.Post.BUS.post(new InputEvent.MouseButton.Post(button, action, mods));
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseScrollPre(Screen guiScreen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
return post(new ScreenEvent.MouseScrolled.Pre(guiScreen, mouseX, mouseY, deltaX, deltaY));
|
||||
return ScreenEvent.MouseScrolled.Pre.BUS.post(new ScreenEvent.MouseScrolled.Pre(guiScreen, mouseX, mouseY, deltaX, deltaY));
|
||||
}
|
||||
|
||||
public static void onScreenMouseScrollPost(Screen guiScreen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
post(new ScreenEvent.MouseScrolled.Post(guiScreen, mouseX, mouseY, deltaX, deltaY));
|
||||
ScreenEvent.MouseScrolled.Post.BUS.post(new ScreenEvent.MouseScrolled.Post(guiScreen, mouseX, mouseY, deltaX, deltaY));
|
||||
}
|
||||
|
||||
public static boolean onMouseScroll(MouseHandler mouseHelper, double deltaX, double deltaY) {
|
||||
return post(new InputEvent.MouseScrollingEvent(deltaX, deltaY, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos()));
|
||||
return InputEvent.MouseScrollingEvent.BUS.post(new InputEvent.MouseScrollingEvent(deltaX, deltaY, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos()));
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseDragPre(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
return post(new ScreenEvent.MouseDragged.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY));
|
||||
return ScreenEvent.MouseDragged.Pre.BUS.post(new ScreenEvent.MouseDragged.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY));
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
return post(new ScreenEvent.MouseDragged.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY));
|
||||
return ScreenEvent.MouseDragged.Post.BUS.post(new ScreenEvent.MouseDragged.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY));
|
||||
}
|
||||
|
||||
public static @Nullable Screen onScreenOpening(Screen old, Screen screen) {
|
||||
var event = new ScreenEvent.Opening(old, screen);
|
||||
if (post(event))
|
||||
if (ScreenEvent.Opening.BUS.post(event))
|
||||
return null;
|
||||
return event.getNewScreen();
|
||||
}
|
||||
|
||||
public static void onScreenClose(Screen screen) {
|
||||
post(new ScreenEvent.Closing(screen));
|
||||
ScreenEvent.Closing.BUS.post(new ScreenEvent.Closing(screen));
|
||||
}
|
||||
|
||||
public static void onPlaySoundSource(SoundEngine engine, SoundInstance sound, Channel channel) {
|
||||
post(new PlaySoundSourceEvent(engine, sound, channel));
|
||||
PlaySoundSourceEvent.BUS.post(new PlaySoundSourceEvent(engine, sound, channel));
|
||||
}
|
||||
|
||||
public static void onPlayStreamingSource(SoundEngine engine, SoundInstance sound, Channel channel) {
|
||||
post(new PlayStreamingSourceEvent(engine, sound, channel));
|
||||
}
|
||||
|
||||
public static ScreenshotEvent onScreenshot(NativeImage image, File screenshotFile) {
|
||||
return fire(new ScreenshotEvent(image, screenshotFile));
|
||||
PlayStreamingSourceEvent.BUS.post(new PlayStreamingSourceEvent(engine, sound, channel));
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyPressedPre(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
return post(new ScreenEvent.KeyPressed.Pre(screen, keyCode, scanCode, modifiers));
|
||||
return ScreenEvent.KeyPressed.Pre.BUS.post(new ScreenEvent.KeyPressed.Pre(screen, keyCode, scanCode, modifiers));
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyPressedPost(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
return post(new ScreenEvent.KeyPressed.Post(screen, keyCode, scanCode, modifiers));
|
||||
return ScreenEvent.KeyPressed.Post.BUS.post(new ScreenEvent.KeyPressed.Post(screen, keyCode, scanCode, modifiers));
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyReleasedPre(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
return post(new ScreenEvent.KeyReleased.Pre(screen, keyCode, scanCode, modifiers));
|
||||
return ScreenEvent.KeyReleased.Pre.BUS.post(new ScreenEvent.KeyReleased.Pre(screen, keyCode, scanCode, modifiers));
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyReleasedPost(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
return post(new ScreenEvent.KeyReleased.Post(screen, keyCode, scanCode, modifiers));
|
||||
return ScreenEvent.KeyReleased.Post.BUS.post(new ScreenEvent.KeyReleased.Post(screen, keyCode, scanCode, modifiers));
|
||||
}
|
||||
|
||||
public static boolean onScreenCharTypedPre(Screen screen, char codePoint, int modifiers) {
|
||||
return post(new ScreenEvent.CharacterTyped.Pre(screen, codePoint, modifiers));
|
||||
return ScreenEvent.CharacterTyped.Pre.BUS.post(new ScreenEvent.CharacterTyped.Pre(screen, codePoint, modifiers));
|
||||
}
|
||||
|
||||
public static boolean onScreenCharTypedPost(Screen screen, char codePoint, int modifiers) {
|
||||
return post(new ScreenEvent.CharacterTyped.Post(screen, codePoint, modifiers));
|
||||
return ScreenEvent.CharacterTyped.Post.BUS.post(new ScreenEvent.CharacterTyped.Post(screen, codePoint, modifiers));
|
||||
}
|
||||
|
||||
public static InputEvent.InteractionKeyMappingTriggered onClickInput(int button, KeyMapping keyBinding, InteractionHand hand) {
|
||||
return fire(new InputEvent.InteractionKeyMappingTriggered(button, keyBinding, hand));
|
||||
public static boolean onClickInputPickBlock(KeyMapping keyBinding) {
|
||||
var event = new InputEvent.InteractionKeyMappingTriggered(2, keyBinding, InteractionHand.MAIN_HAND);
|
||||
return InputEvent.InteractionKeyMappingTriggered.BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onContainerRenderBackground(AbstractContainerScreen<?> screen, GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
post(new ContainerScreenEvent.Render.Background(screen, graphics, mouseX, mouseY));
|
||||
ContainerScreenEvent.Render.Background.BUS.post(new ContainerScreenEvent.Render.Background(screen, graphics, mouseX, mouseY));
|
||||
}
|
||||
|
||||
public static void onContainerRenderForeground(AbstractContainerScreen<?> screen, GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
post(new ContainerScreenEvent.Render.Foreground(screen, graphics, mouseX, mouseY));
|
||||
ContainerScreenEvent.Render.Foreground.BUS.post(new ContainerScreenEvent.Render.Foreground(screen, graphics, mouseX, mouseY));
|
||||
}
|
||||
|
||||
public static void firePlayerLogin(MultiPlayerGameMode pc, LocalPlayer player, Connection networkManager) {
|
||||
post(new ClientPlayerNetworkEvent.LoggingIn(pc, player, networkManager));
|
||||
ClientPlayerNetworkEvent.LoggingIn.BUS.post(new ClientPlayerNetworkEvent.LoggingIn(pc, player, networkManager));
|
||||
}
|
||||
|
||||
public static void firePlayerLogout(@Nullable MultiPlayerGameMode pc, @Nullable LocalPlayer player) {
|
||||
post(new ClientPlayerNetworkEvent.LoggingOut(pc, player, player != null ? player.connection != null ? player.connection.getConnection() : null : null));
|
||||
ClientPlayerNetworkEvent.LoggingOut.BUS.post(new ClientPlayerNetworkEvent.LoggingOut(pc, player, player != null ? player.connection != null ? player.connection.getConnection() : null : null));
|
||||
}
|
||||
|
||||
public static void firePlayerRespawn(MultiPlayerGameMode pc, LocalPlayer oldPlayer, LocalPlayer newPlayer, Connection networkManager) {
|
||||
post(new ClientPlayerNetworkEvent.Clone(pc, oldPlayer, newPlayer, networkManager));
|
||||
ClientPlayerNetworkEvent.Clone.BUS.post(new ClientPlayerNetworkEvent.Clone(pc, oldPlayer, newPlayer, networkManager));
|
||||
}
|
||||
|
||||
public static ViewportEvent.ComputeFov fireComputeFov(GameRenderer renderer, Camera camera, double partialTick, float fov, boolean usedConfiguredFov) {
|
||||
return fire(new ViewportEvent.ComputeFov(renderer, camera, partialTick, fov, usedConfiguredFov));
|
||||
return ViewportEvent.ComputeFov.BUS.fire(new ViewportEvent.ComputeFov(renderer, camera, partialTick, fov, usedConfiguredFov));
|
||||
}
|
||||
|
||||
public static ViewportEvent.ComputeCameraAngles fireComputeCameraAngles(GameRenderer renderer, Camera camera, float partial) {
|
||||
return fire(new ViewportEvent.ComputeCameraAngles(renderer, camera, partial, camera.getYRot(), camera.getXRot(), 0));
|
||||
return ViewportEvent.ComputeCameraAngles.BUS.fire(new ViewportEvent.ComputeCameraAngles(renderer, camera, partial, camera.getYRot(), camera.getXRot(), 0));
|
||||
}
|
||||
|
||||
public static <T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> boolean onRenderLivingPre(S state, LivingEntityRenderer<T, S, M> renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
return post(new RenderLivingEvent.Pre<T, S, M>(state, renderer, poseStack, multiBufferSource, packedLight));
|
||||
return RenderLivingEvent.Pre.BUS.post(new RenderLivingEvent.Pre<T, S, M>(state, renderer, poseStack, multiBufferSource, packedLight));
|
||||
}
|
||||
|
||||
public static <T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> boolean onRenderLivingPost(S state, LivingEntityRenderer<T, S, M> renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
return post(new RenderLivingEvent.Post<T, S, M>(state, renderer, poseStack, multiBufferSource, packedLight));
|
||||
return RenderLivingEvent.Post.BUS.post(new RenderLivingEvent.Post<T, S, M>(state, renderer, poseStack, multiBufferSource, packedLight));
|
||||
}
|
||||
|
||||
public static boolean onRenderPlayerPre(PlayerRenderState player, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
return post(new RenderPlayerEvent.Pre(player, renderer, poseStack, multiBufferSource, packedLight));
|
||||
return RenderPlayerEvent.Pre.BUS.post(new RenderPlayerEvent.Pre(player, renderer, poseStack, multiBufferSource, packedLight));
|
||||
}
|
||||
|
||||
public static boolean onRenderPlayerPost(PlayerRenderState player, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
return post(new RenderPlayerEvent.Post(player, renderer, poseStack, multiBufferSource, packedLight));
|
||||
return RenderPlayerEvent.Post.BUS.post(new RenderPlayerEvent.Post(player, renderer, poseStack, multiBufferSource, packedLight));
|
||||
}
|
||||
|
||||
public static boolean onRenderArm(PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, HumanoidArm arm) {
|
||||
return post(new RenderArmEvent(poseStack, multiBufferSource, packedLight, arm));
|
||||
return RenderArmEvent.BUS.post(new RenderArmEvent(poseStack, multiBufferSource, packedLight, arm));
|
||||
}
|
||||
|
||||
public static boolean onRenderItemInFrame(ItemFrameRenderState state, ItemFrameRenderer<?> renderItemFrame, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
return post(new RenderItemInFrameEvent(state, renderItemFrame, poseStack, multiBufferSource, packedLight));
|
||||
return RenderItemInFrameEvent.BUS.post(new RenderItemInFrameEvent(state, renderItemFrame, poseStack, multiBufferSource, packedLight));
|
||||
}
|
||||
|
||||
public static RenderNameTagEvent fireRenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer<?, ?> entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
return fire(new RenderNameTagEvent(state, content, entityRenderer, poseStack, multiBufferSource, packedLight));
|
||||
return RenderNameTagEvent.BUS.fire(new RenderNameTagEvent(state, content, entityRenderer, poseStack, multiBufferSource, packedLight));
|
||||
}
|
||||
|
||||
public static void onRenderScreenBackground(Screen screen, GuiGraphics guiGraphics) {
|
||||
fire(new ScreenEvent.BackgroundRendered(screen, guiGraphics));
|
||||
ScreenEvent.BackgroundRendered.BUS.post(new ScreenEvent.BackgroundRendered(screen, guiGraphics));
|
||||
}
|
||||
|
||||
public static void onRenderTickStart(DeltaTracker timer) {
|
||||
post(new TickEvent.RenderTickEvent.Pre(timer));
|
||||
TickEvent.RenderTickEvent.Pre.BUS.post(new TickEvent.RenderTickEvent.Pre(timer));
|
||||
}
|
||||
|
||||
public static void onRenderTickEnd(DeltaTracker timer) {
|
||||
post(new TickEvent.RenderTickEvent.Post(timer));
|
||||
TickEvent.RenderTickEvent.Post.BUS.post(new TickEvent.RenderTickEvent.Post(timer));
|
||||
}
|
||||
|
||||
public static RenderTooltipEvent.Background onRenderTooltipBackground(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, @NotNull Font font, @NotNull List<ClientTooltipComponent> components, @Nullable ResourceLocation backgroundPrefix) {
|
||||
return fire(new RenderTooltipEvent.Background(stack, graphics, x, y, font, components, backgroundPrefix));
|
||||
return RenderTooltipEvent.Background.BUS.fire(new RenderTooltipEvent.Background(stack, graphics, x, y, font, components, backgroundPrefix));
|
||||
}
|
||||
|
||||
public static boolean onToastAdd(Toast toast) {
|
||||
return post(new ToastAddEvent(toast));
|
||||
return ToastAddEvent.BUS.post(new ToastAddEvent(toast));
|
||||
}
|
||||
|
||||
public static ScreenEvent.RenderInventoryMobEffects onScreenEffectSize(Screen screen, int availableSpace, boolean compact, int horizontalOffset) {
|
||||
return fire(new ScreenEvent.RenderInventoryMobEffects(screen, availableSpace, compact, horizontalOffset));
|
||||
public static @Nullable ScreenEvent.RenderInventoryMobEffects onScreenEffectSize(Screen screen, int availableSpace, boolean compact, int horizontalOffset) {
|
||||
var event = new ScreenEvent.RenderInventoryMobEffects(screen, availableSpace, compact, horizontalOffset);
|
||||
return ScreenEvent.RenderInventoryMobEffects.BUS.post(event) ? null : event;
|
||||
}
|
||||
|
||||
public static void onRecipesUpdated(ClientRecipeBook book) {
|
||||
post(new RecipesUpdatedEvent(book));
|
||||
RecipesUpdatedEvent.BUS.post(new RecipesUpdatedEvent(book));
|
||||
}
|
||||
|
||||
public static ComputeFovModifierEvent fireFovModifierEvent(Player entity, float modifier, float scale) {
|
||||
return fire(new ComputeFovModifierEvent(entity, modifier, scale));
|
||||
return ComputeFovModifierEvent.BUS.fire(new ComputeFovModifierEvent(entity, modifier, scale));
|
||||
}
|
||||
|
||||
public static void onCreateSpecialBlockRenderers(Map<Block, SpecialModelRenderer.Unbaked> map) {
|
||||
post(new CreateSpecialBlockRendererEvent(map));
|
||||
CreateSpecialBlockRendererEvent.BUS.post(new CreateSpecialBlockRendererEvent(map));
|
||||
}
|
||||
|
||||
public static Map<Type, Function<EntityModelSet, SkullModelBase>> onCreateSkullModels() {
|
||||
|
||||
@@ -8,9 +8,11 @@ package net.minecraftforge.client.event;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -24,21 +26,24 @@ import org.lwjgl.glfw.GLFW;
|
||||
* @see Key
|
||||
* @see InteractionKeyMappingTriggered
|
||||
*/
|
||||
public abstract sealed class InputEvent extends Event {
|
||||
public abstract sealed class InputEvent extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<InputEvent> BUS = EventBus.create(InputEvent.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected InputEvent() {}
|
||||
|
||||
/**
|
||||
* Fired when a mouse button is pressed/released. Sub-events get fired {@link Pre before} and {@link Post after} this happens.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
* <p>These events are fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
* @see Pre
|
||||
* @see Post
|
||||
*/
|
||||
public static abstract sealed class MouseButton extends InputEvent {
|
||||
public static final EventBus<MouseButton> BUS = EventBus.create(MouseButton.class);
|
||||
|
||||
private final int button;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
@@ -88,16 +93,15 @@ public abstract sealed class InputEvent extends Event {
|
||||
/**
|
||||
* Fired when a mouse button is pressed/released, <b>before</b> being processed by vanilla.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the mouse event will not be processed by vanilla (e.g. keymappings and screens) </p>
|
||||
* <p>If the event is cancelled, then the mouse event will not be processed by vanilla (e.g. keymappings and screens) </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends MouseButton {
|
||||
public static final class Pre extends MouseButton implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(int button, int action, int modifiers) {
|
||||
super(button, action, modifiers);
|
||||
@@ -107,14 +111,13 @@ public abstract sealed class InputEvent extends Event {
|
||||
/**
|
||||
* Fired when a mouse button is pressed/released, <b>after</b> processing.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public static final class Post extends MouseButton {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(int button, int action, int modifiers) {
|
||||
super(button, action, modifiers);
|
||||
@@ -126,16 +129,15 @@ public abstract sealed class InputEvent extends Event {
|
||||
* Fired when a mouse scroll wheel is used outside of a screen and a player is loaded, <b>before</b> being
|
||||
* processed by vanilla.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the mouse scroll event will not be processed further.</p>
|
||||
* <p>If the event is cancelled, then the mouse scroll event will not be processed further.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class MouseScrollingEvent extends InputEvent {
|
||||
public static final class MouseScrollingEvent extends InputEvent implements Cancellable {
|
||||
public static final CancellableEventBus<MouseScrollingEvent> BUS = CancellableEventBus.create(MouseScrollingEvent.class);
|
||||
|
||||
private final double deltaX;
|
||||
private final double deltaY;
|
||||
private final double mouseX;
|
||||
@@ -208,12 +210,11 @@ public abstract sealed class InputEvent extends Event {
|
||||
/**
|
||||
* Fired when a keyboard key input occurs, such as pressing, releasing, or repeating a key.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Key extends InputEvent {
|
||||
public static final EventBus<Key> BUS = EventBus.create(Key.class);
|
||||
|
||||
private final int key;
|
||||
private final int scanCode;
|
||||
private final int action;
|
||||
@@ -288,16 +289,15 @@ public abstract sealed class InputEvent extends Event {
|
||||
* <li><b>Attack</b> - defaults to <em>right mouse click</em></li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the keymapping's action is not processed further, and the hand will be swung
|
||||
* <p>If this event is cancelled, then the keymapping's action is not processed further, and the hand will be swung
|
||||
* according to {@link #shouldSwingHand()}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
// TODO: Change the 'button' to sub events. - Lex 0422202
|
||||
@Cancelable
|
||||
public static final class InteractionKeyMappingTriggered extends InputEvent {
|
||||
public static final class InteractionKeyMappingTriggered extends InputEvent implements Cancellable {
|
||||
public static final CancellableEventBus<InteractionKeyMappingTriggered> BUS = CancellableEventBus.create(InteractionKeyMappingTriggered.class);
|
||||
|
||||
private final int button;
|
||||
private final KeyMapping keyMapping;
|
||||
private final InteractionHand hand;
|
||||
|
||||
@@ -13,8 +13,8 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
@@ -28,9 +28,9 @@ import java.util.Map;
|
||||
/**
|
||||
* Houses events related to models.
|
||||
*/
|
||||
public abstract sealed class ModelEvent extends Event {
|
||||
public abstract sealed class ModelEvent {
|
||||
@ApiStatus.Internal
|
||||
protected ModelEvent() { }
|
||||
protected ModelEvent() {}
|
||||
|
||||
/**
|
||||
* Fired while the {@link ModelManager} is reloading models, after the model registry is set up, but before it's
|
||||
@@ -49,6 +49,10 @@ public abstract sealed class ModelEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class ModifyBakingResult extends ModelEvent implements IModBusEvent {
|
||||
public static EventBus<ModifyBakingResult> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, ModifyBakingResult.class);
|
||||
}
|
||||
|
||||
private final ModelBakery modelBakery;
|
||||
private final ModelBakery.BakingResult results;
|
||||
|
||||
@@ -85,6 +89,10 @@ public abstract sealed class ModelEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class BakingCompleted extends ModelEvent implements IModBusEvent {
|
||||
public static EventBus<BakingCompleted> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, BakingCompleted.class);
|
||||
}
|
||||
|
||||
private final ModelManager modelManager;
|
||||
private final ModelBakery modelBakery;
|
||||
|
||||
@@ -119,6 +127,10 @@ public abstract sealed class ModelEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class RegisterModelStateDefinitions extends ModelEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterModelStateDefinitions> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterModelStateDefinitions.class);
|
||||
}
|
||||
|
||||
private final Map<ResourceLocation, StateDefinition<Block, BlockState>> states = new HashMap<>();
|
||||
private final Map<ResourceLocation, StateDefinition<Block, BlockState>> view = Collections.unmodifiableMap(states);
|
||||
|
||||
@@ -149,6 +161,10 @@ public abstract sealed class ModelEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class RegisterGeometryLoaders extends ModelEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterGeometryLoaders> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterGeometryLoaders.class);
|
||||
}
|
||||
|
||||
private final Map<ResourceLocation, IGeometryLoader> loaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.client.player.ClientInput;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class MovementInputUpdateEvent extends PlayerEvent {
|
||||
public static final EventBus<MovementInputUpdateEvent> BUS = EventBus.create(MovementInputUpdateEvent.class);
|
||||
|
||||
private final ClientInput input;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -7,8 +7,8 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.ClientRecipeBook;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.RecordEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -19,19 +19,12 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @param getRecipeBook the recipe manager
|
||||
*/
|
||||
public final class RecipesUpdatedEvent extends Event {
|
||||
private final ClientRecipeBook recipeBook;
|
||||
public record RecipesUpdatedEvent(ClientRecipeBook getRecipeBook) implements RecordEvent {
|
||||
public static final EventBus<RecipesUpdatedEvent> BUS = EventBus.create(RecipesUpdatedEvent.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RecipesUpdatedEvent(ClientRecipeBook recipeBook) {
|
||||
this.recipeBook = recipeBook;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the recipe manager}
|
||||
*/
|
||||
public ClientRecipeBook getRecipeBook() {
|
||||
return recipeBook;
|
||||
}
|
||||
public RecipesUpdatedEvent {}
|
||||
}
|
||||
@@ -10,11 +10,13 @@ import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.ObjectiveArgument;
|
||||
import net.minecraft.commands.arguments.ResourceLocationArgument;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.common.util.HasResult;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.RecordEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired to allow mods to register client commands.
|
||||
@@ -27,38 +29,22 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* objectives that are displayed to the player.
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @param getDispatcher the command dispatcher for registering commands to be executed on the client
|
||||
* @param getBuildContext the context to build the commands for
|
||||
*
|
||||
* @see net.minecraftforge.event.RegisterCommandsEvent
|
||||
*/
|
||||
public final class RegisterClientCommandsEvent extends Event
|
||||
{
|
||||
private final CommandDispatcher<CommandSourceStack> dispatcher;
|
||||
private final CommandBuildContext context;
|
||||
@NullMarked
|
||||
public record RegisterClientCommandsEvent(
|
||||
CommandDispatcher<CommandSourceStack> getDispatcher,
|
||||
CommandBuildContext getBuildContext
|
||||
) implements RecordEvent {
|
||||
public static final EventBus<RegisterClientCommandsEvent> BUS = EventBus.create(RegisterClientCommandsEvent.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterClientCommandsEvent(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context)
|
||||
{
|
||||
this.dispatcher = dispatcher;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the command dispatcher for registering commands to be executed on the client}
|
||||
*/
|
||||
public CommandDispatcher<CommandSourceStack> getDispatcher()
|
||||
{
|
||||
return dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the context to build the commands for}
|
||||
*/
|
||||
public CommandBuildContext getBuildContext()
|
||||
{
|
||||
return context;
|
||||
}
|
||||
public RegisterClientCommandsEvent {}
|
||||
}
|
||||
+9
-8
@@ -9,8 +9,8 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -27,13 +27,15 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterClientReloadListenersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterClientReloadListenersEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterClientReloadListenersEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterClientReloadListenersEvent.class);
|
||||
}
|
||||
|
||||
private final ReloadableResourceManager resourceManager;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterClientReloadListenersEvent(ReloadableResourceManager resourceManager)
|
||||
{
|
||||
public RegisterClientReloadListenersEvent(ReloadableResourceManager resourceManager) {
|
||||
this.resourceManager = resourceManager;
|
||||
}
|
||||
|
||||
@@ -42,8 +44,7 @@ public final class RegisterClientReloadListenersEvent extends Event implements I
|
||||
*
|
||||
* @param reloadListener the reload listener
|
||||
*/
|
||||
public void registerReloadListener(PreparableReloadListener reloadListener)
|
||||
{
|
||||
public void registerReloadListener(PreparableReloadListener reloadListener) {
|
||||
resourceManager.registerReloadListener(reloadListener);
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -7,8 +7,8 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -26,13 +26,15 @@ import java.util.function.Function;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterClientTooltipComponentFactoriesEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterClientTooltipComponentFactoriesEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterClientTooltipComponentFactoriesEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterClientTooltipComponentFactoriesEvent.class);
|
||||
}
|
||||
|
||||
private final Map<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> factories;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterClientTooltipComponentFactoriesEvent(Map<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> factories)
|
||||
{
|
||||
public RegisterClientTooltipComponentFactoriesEvent(Map<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> factories) {
|
||||
this.factories = factories;
|
||||
}
|
||||
|
||||
@@ -40,8 +42,7 @@ public final class RegisterClientTooltipComponentFactoriesEvent extends Event im
|
||||
* Registers a {@link ClientTooltipComponent} factory for a {@link TooltipComponent}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends TooltipComponent> void register(Class<T> type, Function<? super T, ? extends ClientTooltipComponent> factory)
|
||||
{
|
||||
public <T extends TooltipComponent> void register(Class<T> type, Function<? super T, ? extends ClientTooltipComponent> factory) {
|
||||
factories.put(type, (Function<TooltipComponent, ClientTooltipComponent>) factory);
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -25,9 +25,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see RegisterColorHandlersEvent.Block
|
||||
* @see RegisterColorHandlersEvent.Item
|
||||
* @see RegisterColorHandlersEvent.ColorResolvers
|
||||
*/
|
||||
public abstract sealed class RegisterColorHandlersEvent extends Event implements IModBusEvent {
|
||||
public abstract sealed class RegisterColorHandlersEvent implements IModBusEvent {
|
||||
@ApiStatus.Internal
|
||||
protected RegisterColorHandlersEvent() {}
|
||||
|
||||
@@ -40,6 +40,10 @@ public abstract sealed class RegisterColorHandlersEvent extends Event implements
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Block extends RegisterColorHandlersEvent {
|
||||
public static EventBus<Block> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, Block.class);
|
||||
}
|
||||
|
||||
private final BlockColors blockColors;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -73,6 +77,10 @@ public abstract sealed class RegisterColorHandlersEvent extends Event implements
|
||||
* {@link net.minecraft.world.level.BlockAndTintGetter#getBlockTint(BlockPos, ColorResolver)}.
|
||||
*/
|
||||
public static final class ColorResolvers extends RegisterColorHandlersEvent {
|
||||
public static EventBus<ColorResolvers> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, ColorResolvers.class);
|
||||
}
|
||||
|
||||
private final ImmutableList.Builder<ColorResolver> builder;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
+9
-8
@@ -7,8 +7,8 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -24,21 +24,22 @@ import java.util.Map;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterDimensionSpecialEffectsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterDimensionSpecialEffectsEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterDimensionSpecialEffectsEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterDimensionSpecialEffectsEvent.class);
|
||||
}
|
||||
|
||||
private final Map<ResourceLocation, DimensionSpecialEffects> effects;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterDimensionSpecialEffectsEvent(Map<ResourceLocation, DimensionSpecialEffects> effects)
|
||||
{
|
||||
public RegisterDimensionSpecialEffectsEvent(Map<ResourceLocation, DimensionSpecialEffects> effects) {
|
||||
this.effects = effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the effects for a given dimension type.
|
||||
*/
|
||||
public void register(ResourceLocation dimensionType, DimensionSpecialEffects effects)
|
||||
{
|
||||
public void register(ResourceLocation dimensionType, DimensionSpecialEffects effects) {
|
||||
this.effects.put(dimensionType, effects);
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -7,8 +7,8 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -25,21 +25,22 @@ import java.util.Map;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterEntitySpectatorShadersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterEntitySpectatorShadersEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterEntitySpectatorShadersEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterEntitySpectatorShadersEvent.class);
|
||||
}
|
||||
|
||||
private final Map<EntityType<?>, ResourceLocation> shaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterEntitySpectatorShadersEvent(Map<EntityType<?>, ResourceLocation> shaders)
|
||||
{
|
||||
public RegisterEntitySpectatorShadersEvent(Map<EntityType<?>, ResourceLocation> shaders) {
|
||||
this.shaders = shaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a spectator shader for a given entity type.
|
||||
*/
|
||||
public void register(EntityType<?> entityType, ResourceLocation shader)
|
||||
{
|
||||
public void register(EntityType<?> entityType, ResourceLocation shader) {
|
||||
shaders.put(entityType, shader);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.client.IItemDecorator;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -28,22 +28,22 @@ import java.util.Map;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterItemDecorationsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterItemDecorationsEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterItemDecorationsEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterItemDecorationsEvent.class);
|
||||
}
|
||||
|
||||
private final Map<Item, List<IItemDecorator>> decorators;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterItemDecorationsEvent(Map<Item, List<IItemDecorator>> decorators)
|
||||
{
|
||||
public RegisterItemDecorationsEvent(Map<Item, List<IItemDecorator>> decorators) {
|
||||
this.decorators = decorators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an ItemDecorator to an Item
|
||||
*/
|
||||
public void register(ItemLike itemLike, IItemDecorator decorator)
|
||||
{
|
||||
public void register(ItemLike itemLike, IItemDecorator decorator) {
|
||||
List<IItemDecorator> itemDecoratorList = decorators.computeIfAbsent(itemLike.asItem(), item -> new ArrayList<>());
|
||||
itemDecoratorList.add(decorator);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -23,21 +23,22 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterKeyMappingsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterKeyMappingsEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterKeyMappingsEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterKeyMappingsEvent.class);
|
||||
}
|
||||
|
||||
private final Options options;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterKeyMappingsEvent(Options options)
|
||||
{
|
||||
public RegisterKeyMappingsEvent(Options options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new key mapping.
|
||||
*/
|
||||
public void register(KeyMapping key)
|
||||
{
|
||||
public void register(KeyMapping key) {
|
||||
options.keyMappings = ArrayUtils.add(options.keyMappings, key);
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,14 @@ package net.minecraftforge.client.event;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.RenderTypeGroup;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -23,18 +23,17 @@ import java.util.Map;
|
||||
/**
|
||||
* Allows users to register custom named {@link RenderType render types}.
|
||||
*
|
||||
* <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}.</p>
|
||||
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterNamedRenderTypesEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterNamedRenderTypesEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterNamedRenderTypesEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterNamedRenderTypesEvent.class);
|
||||
}
|
||||
|
||||
private final Map<ResourceLocation, RenderTypeGroup> renderTypes;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterNamedRenderTypesEvent(Map<ResourceLocation, RenderTypeGroup> renderTypes)
|
||||
{
|
||||
public RegisterNamedRenderTypesEvent(Map<ResourceLocation, RenderTypeGroup> renderTypes) {
|
||||
this.renderTypes = renderTypes;
|
||||
}
|
||||
|
||||
@@ -42,11 +41,10 @@ public final class RegisterNamedRenderTypesEvent extends Event implements IModBu
|
||||
* Registers a named {@link RenderTypeGroup}.
|
||||
*
|
||||
* @param name The name
|
||||
* @param blockRenderType One of the values returned by {@link RenderType#chunkBufferLayers()}
|
||||
* @param blockRenderType What ChunkSectionLayer to render in
|
||||
* @param entityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY}
|
||||
*/
|
||||
public void register(String name, RenderType blockRenderType, RenderType entityRenderType)
|
||||
{
|
||||
public void register(String name, ChunkSectionLayer blockRenderType, RenderType entityRenderType) {
|
||||
register(name, blockRenderType, entityRenderType, entityRenderType);
|
||||
}
|
||||
|
||||
@@ -54,17 +52,15 @@ public final class RegisterNamedRenderTypesEvent extends Event implements IModBu
|
||||
* Registers a named {@link RenderTypeGroup}.
|
||||
*
|
||||
* @param name The name
|
||||
* @param blockRenderType One of the values returned by {@link RenderType#chunkBufferLayers()}
|
||||
* @param blockRenderType What ChunkSectionLayer to render in
|
||||
* @param entityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY}
|
||||
* @param fabulousEntityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} for use when
|
||||
* "fabulous" rendering is enabled
|
||||
*/
|
||||
public void register(String name, RenderType blockRenderType, RenderType entityRenderType, RenderType fabulousEntityRenderType)
|
||||
{
|
||||
public void register(String name, ChunkSectionLayer blockRenderType, RenderType entityRenderType, RenderType fabulousEntityRenderType) {
|
||||
@SuppressWarnings("removal")
|
||||
var key = ResourceLocation.fromNamespaceAndPath(ModLoadingContext.get().getActiveNamespace(), name);
|
||||
Preconditions.checkArgument(!renderTypes.containsKey(key), "Render type already registered: " + key);
|
||||
Preconditions.checkArgument(blockRenderType.format() == DefaultVertexFormat.BLOCK, "The block render type must use the BLOCK vertex format.");
|
||||
Preconditions.checkArgument(blockRenderType.getChunkLayerId() >= 0, "Only chunk render types can be used for block rendering. Query RenderType#chunkBufferLayers() for a list.");
|
||||
Preconditions.checkArgument(entityRenderType.format() == DefaultVertexFormat.NEW_ENTITY, "The entity render type must use the NEW_ENTITY vertex format.");
|
||||
Preconditions.checkArgument(fabulousEntityRenderType.format() == DefaultVertexFormat.NEW_ENTITY, "The fabulous entity render type must use the NEW_ENTITY vertex format.");
|
||||
renderTypes.put(key, new RenderTypeGroup(blockRenderType, entityRenderType, fabulousEntityRenderType));
|
||||
|
||||
@@ -10,8 +10,8 @@ import net.minecraft.client.particle.ParticleProvider;
|
||||
import net.minecraft.client.particle.TextureSheetParticle;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -29,13 +29,15 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterParticleProvidersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterParticleProvidersEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterParticleProvidersEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterParticleProvidersEvent.class);
|
||||
}
|
||||
|
||||
private final ParticleEngine particleEngine;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterParticleProvidersEvent(ParticleEngine particleEngine)
|
||||
{
|
||||
public RegisterParticleProvidersEvent(ParticleEngine particleEngine) {
|
||||
this.particleEngine = particleEngine;
|
||||
}
|
||||
|
||||
@@ -67,8 +69,7 @@ public final class RegisterParticleProvidersEvent extends Event implements IModB
|
||||
* @param sprite Sprite function responsible for providing that ParticleType's particles.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public <T extends ParticleOptions> void registerSprite(ParticleType<T> type, ParticleProvider.Sprite<T> sprite)
|
||||
{
|
||||
public <T extends ParticleOptions> void registerSprite(ParticleType<T> type, ParticleProvider.Sprite<T> sprite) {
|
||||
particleEngine.register(type, sprite);
|
||||
}
|
||||
|
||||
@@ -84,9 +85,7 @@ public final class RegisterParticleProvidersEvent extends Event implements IModB
|
||||
* @param registration SpriteParticleRegistration function responsible for providing that ParticleType's particles.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public <T extends ParticleOptions> void registerSpriteSet(ParticleType<T> type, ParticleEngine.SpriteParticleRegistration<T> registration)
|
||||
{
|
||||
public <T extends ParticleOptions> void registerSpriteSet(ParticleType<T> type, ParticleEngine.SpriteParticleRegistration<T> registration) {
|
||||
particleEngine.register(type, registration);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,8 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -14,8 +16,6 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import net.minecraft.client.gui.screens.worldselection.PresetEditor;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
@@ -29,26 +29,26 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterPresetEditorsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class RegisterPresetEditorsEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterPresetEditorsEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterPresetEditorsEvent.class);
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final Map<ResourceKey<WorldPreset>, PresetEditor> editors;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterPresetEditorsEvent(Map<ResourceKey<WorldPreset>, PresetEditor> editors)
|
||||
{
|
||||
public RegisterPresetEditorsEvent(Map<ResourceKey<WorldPreset>, PresetEditor> editors) {
|
||||
this.editors = editors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a PresetEditor for a given world preset key.
|
||||
*/
|
||||
public void register(ResourceKey<WorldPreset> key, PresetEditor editor)
|
||||
{
|
||||
public void register(ResourceKey<WorldPreset> key, PresetEditor editor) {
|
||||
PresetEditor old = this.editors.put(key, editor);
|
||||
if (old != null)
|
||||
{
|
||||
if (old != null) {
|
||||
LOGGER.debug("PresetEditor {} overridden by mod {}", key.location(), ModLoadingContext.get().getActiveNamespace());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -10,8 +10,8 @@ import com.google.common.collect.BiMap;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
@@ -26,7 +26,11 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class RegisterTextureAtlasSpriteLoadersEvent extends Event implements IModBusEvent {
|
||||
public final class RegisterTextureAtlasSpriteLoadersEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterTextureAtlasSpriteLoadersEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterTextureAtlasSpriteLoadersEvent.class);
|
||||
}
|
||||
|
||||
private final BiMap<ResourceLocation, ITextureAtlasSpriteLoader> loaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -10,8 +10,9 @@ import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -26,8 +27,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public final class RenderArmEvent extends Event {
|
||||
public final class RenderArmEvent extends MutableEvent implements Cancellable {
|
||||
public static final CancellableEventBus<RenderArmEvent> BUS = CancellableEventBus.create(RenderArmEvent.class);
|
||||
|
||||
private final PoseStack poseStack;
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
|
||||
@@ -10,8 +10,9 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -24,16 +25,15 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public final class RenderBlockScreenEffectEvent extends Event
|
||||
{
|
||||
public final class RenderBlockScreenEffectEvent extends MutableEvent implements Cancellable {
|
||||
public static final CancellableEventBus<RenderBlockScreenEffectEvent> BUS = CancellableEventBus.create(RenderBlockScreenEffectEvent.class);
|
||||
|
||||
/**
|
||||
* The type of the block overlay to be rendered.
|
||||
*
|
||||
* @see RenderBlockScreenEffectEvent
|
||||
*/
|
||||
public enum OverlayType
|
||||
{
|
||||
public enum OverlayType {
|
||||
/**
|
||||
* The type of the overlay when the player is burning / on fire.
|
||||
*/
|
||||
@@ -55,8 +55,7 @@ public final class RenderBlockScreenEffectEvent extends Event
|
||||
private final BlockPos blockPos;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RenderBlockScreenEffectEvent(Player player, PoseStack poseStack, OverlayType type, BlockState block, BlockPos blockPos)
|
||||
{
|
||||
public RenderBlockScreenEffectEvent(Player player, PoseStack poseStack, OverlayType type, BlockState block, BlockPos blockPos) {
|
||||
this.player = player;
|
||||
this.poseStack = poseStack;
|
||||
this.overlayType = type;
|
||||
@@ -67,40 +66,35 @@ public final class RenderBlockScreenEffectEvent extends Event
|
||||
/**
|
||||
* {@return the player which the overlay will apply to}
|
||||
*/
|
||||
public Player getPlayer()
|
||||
{
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
public PoseStack getPoseStack() {
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the type of the overlay}
|
||||
*/
|
||||
public OverlayType getOverlayType()
|
||||
{
|
||||
public OverlayType getOverlayType() {
|
||||
return overlayType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the block which the overlay is gotten from}
|
||||
*/
|
||||
public BlockState getBlockState()
|
||||
{
|
||||
public BlockState getBlockState() {
|
||||
return blockState;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the position of the block which the overlay is gotten from}
|
||||
*/
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
public BlockPos getBlockPos() {
|
||||
return blockPos;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,9 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -27,9 +28,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see RenderArmEvent
|
||||
*/
|
||||
@Cancelable
|
||||
public final class RenderHandEvent extends Event
|
||||
{
|
||||
public final class RenderHandEvent extends MutableEvent implements Cancellable {
|
||||
public static final CancellableEventBus<RenderHandEvent> BUS = CancellableEventBus.create(RenderHandEvent.class);
|
||||
|
||||
private final InteractionHand hand;
|
||||
private final PoseStack poseStack;
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
@@ -59,24 +60,21 @@ public final class RenderHandEvent extends Event
|
||||
/**
|
||||
* {@return the hand being rendered}
|
||||
*/
|
||||
public InteractionHand getHand()
|
||||
{
|
||||
public InteractionHand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
public PoseStack getPoseStack() {
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
public MultiBufferSource getMultiBufferSource() {
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
@@ -85,48 +83,42 @@ public final class RenderHandEvent extends Event
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight()
|
||||
{
|
||||
public int getPackedLight() {
|
||||
return packedLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
public float getPartialTick() {
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the interpolated pitch of the player entity}
|
||||
*/
|
||||
public float getInterpolatedPitch()
|
||||
{
|
||||
public float getInterpolatedPitch() {
|
||||
return interpolatedPitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the swing progress of the hand being rendered}
|
||||
*/
|
||||
public float getSwingProgress()
|
||||
{
|
||||
public float getSwingProgress() {
|
||||
return swingProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the progress of the equip animation, from {@code 0.0} to {@code 1.0}}
|
||||
*/
|
||||
public float getEquipProgress()
|
||||
{
|
||||
public float getEquipProgress() {
|
||||
return equipProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the item stack to be rendered}
|
||||
*/
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
public ItemStack getItemStack() {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,10 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -25,9 +27,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see Block
|
||||
* @see Entity
|
||||
*/
|
||||
@Cancelable
|
||||
public abstract sealed class RenderHighlightEvent extends Event
|
||||
{
|
||||
public abstract sealed class RenderHighlightEvent extends MutableEvent implements Cancellable, InheritableEvent {
|
||||
public static final CancellableEventBus<RenderHighlightEvent> BUS = CancellableEventBus.create(RenderHighlightEvent.class);
|
||||
|
||||
private final LevelRenderer levelRenderer;
|
||||
private final Camera camera;
|
||||
private final HitResult target;
|
||||
@@ -36,8 +38,7 @@ public abstract sealed class RenderHighlightEvent extends Event
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected RenderHighlightEvent(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource)
|
||||
{
|
||||
protected RenderHighlightEvent(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource) {
|
||||
this.levelRenderer = levelRenderer;
|
||||
this.camera = camera;
|
||||
this.target = target;
|
||||
@@ -49,48 +50,42 @@ public abstract sealed class RenderHighlightEvent extends Event
|
||||
/**
|
||||
* {@return the level renderer}
|
||||
*/
|
||||
public LevelRenderer getLevelRenderer()
|
||||
{
|
||||
public LevelRenderer getLevelRenderer() {
|
||||
return levelRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the camera information}
|
||||
*/
|
||||
public Camera getCamera()
|
||||
{
|
||||
public Camera getCamera() {
|
||||
return camera;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the hit result which triggered the selection highlight}
|
||||
*/
|
||||
public HitResult getTarget()
|
||||
{
|
||||
public HitResult getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
public float getPartialTick() {
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
public PoseStack getPoseStack() {
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
public MultiBufferSource getMultiBufferSource() {
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
@@ -103,12 +98,11 @@ public abstract sealed class RenderHighlightEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Block extends RenderHighlightEvent
|
||||
{
|
||||
public static final class Block extends RenderHighlightEvent {
|
||||
public static final CancellableEventBus<Block> BUS = CancellableEventBus.create(Block.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Block(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
{
|
||||
public Block(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) {
|
||||
super(levelRenderer, camera, target, partialTick, poseStack, bufferSource);
|
||||
}
|
||||
|
||||
@@ -116,8 +110,7 @@ public abstract sealed class RenderHighlightEvent extends Event
|
||||
* {@return the block hit result}
|
||||
*/
|
||||
@Override
|
||||
public BlockHitResult getTarget()
|
||||
{
|
||||
public BlockHitResult getTarget() {
|
||||
return (BlockHitResult) super.target;
|
||||
}
|
||||
}
|
||||
@@ -130,11 +123,11 @@ public abstract sealed class RenderHighlightEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Entity extends RenderHighlightEvent
|
||||
{
|
||||
public static final class Entity extends RenderHighlightEvent {
|
||||
public static final CancellableEventBus<Entity> BUS = CancellableEventBus.create(Entity.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Entity(LevelRenderer levelRenderer, Camera camera, EntityHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
{
|
||||
public Entity(LevelRenderer levelRenderer, Camera camera, EntityHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource) {
|
||||
super(levelRenderer, camera, target, partialTick, poseStack, bufferSource);
|
||||
}
|
||||
|
||||
@@ -142,8 +135,7 @@ public abstract sealed class RenderHighlightEvent extends Event
|
||||
* {@return the entity hit result}
|
||||
*/
|
||||
@Override
|
||||
public EntityHitResult getTarget()
|
||||
{
|
||||
public EntityHitResult getTarget() {
|
||||
return (EntityHitResult) super.target;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -28,8 +29,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see ItemFrameRenderer
|
||||
*/
|
||||
@Cancelable
|
||||
public final class RenderItemInFrameEvent extends Event {
|
||||
public final class RenderItemInFrameEvent extends MutableEvent implements Cancellable {
|
||||
public static final CancellableEventBus<RenderItemInFrameEvent> BUS = CancellableEventBus.create(RenderItemInFrameEvent.class);
|
||||
|
||||
private final ItemFrameRenderState state;
|
||||
private final ItemFrameRenderer<?> renderer;
|
||||
private final PoseStack poseStack;
|
||||
|
||||
@@ -13,8 +13,11 @@ import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -32,7 +35,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see RenderPlayerEvent
|
||||
* @see LivingEntityRenderer
|
||||
*/
|
||||
public abstract sealed class RenderLivingEvent<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends Event {
|
||||
public abstract sealed class RenderLivingEvent<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<RenderLivingEvent> BUS = EventBus.create(RenderLivingEvent.class);
|
||||
|
||||
private final S state;
|
||||
private final LivingEntityRenderer<T, S, M> renderer;
|
||||
private final PoseStack poseStack;
|
||||
@@ -99,8 +104,9 @@ public abstract sealed class RenderLivingEvent<T extends LivingEntity, S extends
|
||||
* @param <T> the living entity that is being rendered
|
||||
* @param <M> the model for the living entity
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends RenderLivingEvent<T, S, M> {
|
||||
public static final class Pre<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends RenderLivingEvent<T, S, M> implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(S state, LivingEntityRenderer<T, S, M> renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(state, renderer, poseStack, multiBufferSource, packedLight);
|
||||
@@ -119,6 +125,8 @@ public abstract sealed class RenderLivingEvent<T extends LivingEntity, S extends
|
||||
* @param <M> the model for the living entity
|
||||
*/
|
||||
public static final class Post<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends RenderLivingEvent<T, S, M> {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(S state, LivingEntityRenderer<T, S, M> renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(state, renderer, poseStack, multiBufferSource, packedLight);
|
||||
|
||||
@@ -11,8 +11,10 @@ import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.common.util.HasResult;
|
||||
import net.minecraftforge.common.util.Result;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -31,8 +33,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see EntityRenderer
|
||||
*/
|
||||
@Event.HasResult
|
||||
public final class RenderNameTagEvent extends Event {
|
||||
public final class RenderNameTagEvent extends MutableEvent implements HasResult {
|
||||
public static final EventBus<RenderNameTagEvent> BUS = EventBus.create(RenderNameTagEvent.class);
|
||||
|
||||
private Component nameplateContent;
|
||||
private final EntityRenderState state;
|
||||
private final Component originalContent;
|
||||
@@ -40,6 +43,7 @@ public final class RenderNameTagEvent extends Event {
|
||||
private final PoseStack poseStack;
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
private Result result = Result.DEFAULT;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer<?, ?> entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
@@ -109,4 +113,14 @@ public final class RenderNameTagEvent extends Event {
|
||||
public int getPackedLight() {
|
||||
return this.packedLight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResult(Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,11 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.PlayerRenderState;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -24,7 +27,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see RenderPlayerEvent.Post
|
||||
* @see PlayerRenderer
|
||||
*/
|
||||
public abstract sealed class RenderPlayerEvent extends Event {
|
||||
public abstract sealed class RenderPlayerEvent extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<RenderPlayerEvent> BUS = EventBus.create(RenderPlayerEvent.class);
|
||||
|
||||
private final PlayerRenderState state;
|
||||
private final PlayerRenderer renderer;
|
||||
private final PoseStack poseStack;
|
||||
@@ -85,8 +90,9 @@ public abstract sealed class RenderPlayerEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends RenderPlayerEvent {
|
||||
public static final class Pre extends RenderPlayerEvent implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(state, renderer, poseStack, multiBufferSource, packedLight);
|
||||
@@ -102,6 +108,8 @@ public abstract sealed class RenderPlayerEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Post extends RenderPlayerEvent {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(state, renderer, poseStack, multiBufferSource, packedLight);
|
||||
|
||||
@@ -16,8 +16,11 @@ import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -34,8 +37,9 @@ import java.util.List;
|
||||
* @see RenderTooltipEvent.Pre
|
||||
* @see RenderTooltipEvent.Background
|
||||
*/
|
||||
public abstract sealed class RenderTooltipEvent extends Event
|
||||
{
|
||||
public abstract sealed class RenderTooltipEvent extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<RenderTooltipEvent> BUS = EventBus.create(RenderTooltipEvent.class);
|
||||
|
||||
@NotNull
|
||||
protected final ItemStack itemStack;
|
||||
protected final GuiGraphics graphics;
|
||||
@@ -120,9 +124,9 @@ public abstract sealed class RenderTooltipEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class GatherComponents extends Event
|
||||
{
|
||||
public static final class GatherComponents extends MutableEvent implements Cancellable {
|
||||
public static final CancellableEventBus<GatherComponents> BUS = CancellableEventBus.create(GatherComponents.class);
|
||||
|
||||
private final ItemStack itemStack;
|
||||
private final int screenWidth;
|
||||
private final int screenHeight;
|
||||
@@ -209,9 +213,9 @@ public abstract sealed class RenderTooltipEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends RenderTooltipEvent
|
||||
{
|
||||
public static final class Pre extends RenderTooltipEvent implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
private final int screenWidth;
|
||||
private final int screenHeight;
|
||||
private final ClientTooltipPositioner positioner;
|
||||
@@ -290,6 +294,8 @@ public abstract sealed class RenderTooltipEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Background extends RenderTooltipEvent {
|
||||
public static final EventBus<Background> BUS = EventBus.create(Background.class);
|
||||
|
||||
private final ResourceLocation originalBackground;
|
||||
private ResourceLocation background;
|
||||
|
||||
|
||||
@@ -10,8 +10,12 @@ import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.common.util.HasResult;
|
||||
import net.minecraftforge.common.util.Result;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -35,7 +39,9 @@ import java.util.function.Consumer;
|
||||
* @see MouseInput
|
||||
* @see KeyInput
|
||||
*/
|
||||
public abstract sealed class ScreenEvent extends Event {
|
||||
public abstract sealed class ScreenEvent extends MutableEvent {
|
||||
public static final EventBus<ScreenEvent> BUS = EventBus.create(ScreenEvent.class);
|
||||
|
||||
private final Screen screen;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -110,8 +116,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends Init {
|
||||
public static final class Pre extends Init implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
|
||||
super(screen, list, add, remove);
|
||||
@@ -127,6 +134,8 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Post extends Init {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
|
||||
super(screen, list, add, remove);
|
||||
@@ -193,8 +202,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends Render {
|
||||
public static final class Pre extends Render implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
super(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
@@ -210,6 +220,8 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Post extends Render {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
super(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
@@ -227,6 +239,8 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class BackgroundRendered extends ScreenEvent {
|
||||
public static final EventBus<BackgroundRendered> BUS = EventBus.create(BackgroundRendered.class);
|
||||
|
||||
private final GuiGraphics guiGraphics;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -254,8 +268,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class RenderInventoryMobEffects extends ScreenEvent {
|
||||
public static final class RenderInventoryMobEffects extends ScreenEvent implements Cancellable {
|
||||
public static final CancellableEventBus<RenderInventoryMobEffects> BUS = CancellableEventBus.create(RenderInventoryMobEffects.class);
|
||||
|
||||
private final int availableSpace;
|
||||
private boolean compact;
|
||||
private int horizontalOffset;
|
||||
@@ -382,8 +397,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends MouseButtonPressed {
|
||||
public static final class Pre extends MouseButtonPressed implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button) {
|
||||
super(screen, mouseX, mouseY, button);
|
||||
@@ -405,9 +421,11 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static final class Post extends MouseButtonPressed {
|
||||
public static final class Post extends MouseButtonPressed implements HasResult {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
private final boolean handled;
|
||||
private Result result = Result.DEFAULT;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) {
|
||||
@@ -421,6 +439,16 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
public boolean wasHandled() {
|
||||
return handled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResult(Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,8 +488,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends MouseButtonReleased {
|
||||
public static final class Pre extends MouseButtonReleased implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button) {
|
||||
super(screen, mouseX, mouseY, button);
|
||||
@@ -483,9 +512,11 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static final class Post extends MouseButtonReleased {
|
||||
public static final class Post extends MouseButtonReleased implements HasResult {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
private final boolean handled;
|
||||
private Result result = Result.DEFAULT;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) {
|
||||
@@ -499,6 +530,16 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
public boolean wasHandled() {
|
||||
return handled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResult(Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,8 +597,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends MouseDragged {
|
||||
public static final class Pre extends MouseDragged implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
@@ -575,6 +617,8 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Post extends MouseDragged {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
@@ -624,8 +668,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends MouseScrolled {
|
||||
public static final class Pre extends MouseScrolled implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
super(screen, mouseX, mouseY, deltaX, deltaY);
|
||||
@@ -643,6 +688,8 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Post extends MouseScrolled {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
super(screen, mouseX, mouseY, deltaX, deltaY);
|
||||
@@ -735,8 +782,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends KeyPressed {
|
||||
public static final class Pre extends KeyPressed implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -753,8 +801,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Post extends KeyPressed {
|
||||
public static final class Post extends KeyPressed implements Cancellable {
|
||||
public static final CancellableEventBus<Post> BUS = CancellableEventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -785,8 +834,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends KeyReleased {
|
||||
public static final class Pre extends KeyReleased implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -803,8 +853,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Post extends KeyReleased {
|
||||
public static final class Post extends KeyReleased implements Cancellable {
|
||||
public static final CancellableEventBus<Post> BUS = CancellableEventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -863,8 +914,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Pre extends CharacterTyped {
|
||||
public static final class Pre extends CharacterTyped implements Cancellable {
|
||||
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, char codePoint, int modifiers) {
|
||||
super(screen, codePoint, modifiers);
|
||||
@@ -882,6 +934,8 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Post extends CharacterTyped {
|
||||
public static final EventBus<Post> BUS = EventBus.create(Post.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, char codePoint, int modifiers) {
|
||||
super(screen, codePoint, modifiers);
|
||||
@@ -901,8 +955,9 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class Opening extends ScreenEvent {
|
||||
public static final class Opening extends ScreenEvent implements Cancellable {
|
||||
public static final CancellableEventBus<Opening> BUS = CancellableEventBus.create(Opening.class);
|
||||
|
||||
@Nullable
|
||||
private final Screen currentScreen;
|
||||
private Screen newScreen;
|
||||
@@ -950,6 +1005,8 @@ public abstract sealed class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Closing extends ScreenEvent {
|
||||
public static final EventBus<Closing> BUS = EventBus.create(Closing.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Closing(Screen screen) {
|
||||
super(screen);
|
||||
|
||||
@@ -9,8 +9,9 @@ import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.Screenshot;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -30,8 +31,8 @@ import java.io.IOException;
|
||||
*
|
||||
* @see Screenshot
|
||||
*/
|
||||
@Cancelable
|
||||
public final class ScreenshotEvent extends Event {
|
||||
public final class ScreenshotEvent extends MutableEvent implements Cancellable {
|
||||
public static final CancellableEventBus<ScreenshotEvent> BUS = CancellableEventBus.create(ScreenshotEvent.class);
|
||||
public static final Component DEFAULT_CANCEL_REASON = Component.literal("Screenshot canceled");
|
||||
|
||||
private final NativeImage image;
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
@@ -17,8 +18,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>If the event is cancelled, the message is not displayed in the chat message window.</p>
|
||||
*
|
||||
*/
|
||||
@Cancelable
|
||||
public final class SystemMessageReceivedEvent extends Event {
|
||||
public final class SystemMessageReceivedEvent extends MutableEvent implements Cancellable {
|
||||
public static final CancellableEventBus<SystemMessageReceivedEvent> BUS = CancellableEventBus.create(SystemMessageReceivedEvent.class);
|
||||
|
||||
private Component message;
|
||||
private final boolean overlay;
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -19,21 +19,18 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see TextureStitchEvent.Post
|
||||
* @see TextureAtlas
|
||||
*/
|
||||
public sealed class TextureStitchEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public sealed class TextureStitchEvent extends MutableEvent implements IModBusEvent, InheritableEvent {
|
||||
private final TextureAtlas atlas;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public TextureStitchEvent(TextureAtlas atlas)
|
||||
{
|
||||
public TextureStitchEvent(TextureAtlas atlas) {
|
||||
this.atlas = atlas;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the texture atlas}
|
||||
*/
|
||||
public TextureAtlas getAtlas()
|
||||
{
|
||||
public TextureAtlas getAtlas() {
|
||||
return atlas;
|
||||
}
|
||||
|
||||
@@ -80,11 +77,9 @@ public sealed class TextureStitchEvent extends Event implements IModBusEvent
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class Post extends TextureStitchEvent
|
||||
{
|
||||
public static final class Post extends TextureStitchEvent {
|
||||
@ApiStatus.Internal
|
||||
public Post(TextureAtlas map)
|
||||
{
|
||||
public Post(TextureAtlas map) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,9 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.gui.components.toasts.Toast;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.event.RecordEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
@@ -21,15 +22,6 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public final class ToastAddEvent extends Event {
|
||||
private final Toast toast;
|
||||
|
||||
public ToastAddEvent(Toast toast) {
|
||||
this.toast = toast;
|
||||
}
|
||||
|
||||
public Toast getToast() {
|
||||
return toast;
|
||||
}
|
||||
public record ToastAddEvent(Toast getToast) implements Cancellable, RecordEvent {
|
||||
public static final CancellableEventBus<ToastAddEvent> BUS = CancellableEventBus.create(ToastAddEvent.class);
|
||||
}
|
||||
@@ -5,17 +5,20 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.shaders.FogShape;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.fog.FogData;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
/**
|
||||
* Fired for hooking into the entity view rendering in {@link GameRenderer}.
|
||||
@@ -30,7 +33,9 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see ComputeCameraAngles
|
||||
* @see ComputeFov
|
||||
*/
|
||||
public abstract sealed class ViewportEvent extends Event {
|
||||
public abstract sealed class ViewportEvent extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<ViewportEvent> BUS = EventBus.create(ViewportEvent.class);
|
||||
|
||||
private final GameRenderer renderer;
|
||||
private final Camera camera;
|
||||
private final double partialTick;
|
||||
@@ -72,30 +77,28 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static final class RenderFog extends ViewportEvent {
|
||||
private final FogMode mode;
|
||||
public static final class RenderFog extends ViewportEvent implements Cancellable {
|
||||
public static final CancellableEventBus<RenderFog> BUS = CancellableEventBus.create(RenderFog.class);
|
||||
|
||||
private final FogType type;
|
||||
private float farPlaneDistance;
|
||||
private float nearPlaneDistance;
|
||||
private FogShape fogShape;
|
||||
private final FogData data;
|
||||
private final Vector4f color;
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@ApiStatus.Internal
|
||||
public RenderFog(FogMode mode, FogType type, Camera camera, float partialTicks, float nearPlaneDistance, float farPlaneDistance, FogShape fogShape) {
|
||||
public RenderFog(FogType type, Camera camera, float partialTicks, FogData data, Vector4f color) {
|
||||
super(Minecraft.getInstance().gameRenderer, camera, partialTicks);
|
||||
this.mode = mode;
|
||||
this.type = type;
|
||||
setFarPlaneDistance(farPlaneDistance);
|
||||
setNearPlaneDistance(nearPlaneDistance);
|
||||
setFogShape(fogShape);
|
||||
this.data = data;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the mode of fog being rendered}
|
||||
*/
|
||||
public FogMode getMode() {
|
||||
return mode;
|
||||
public FogData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public Vector4f getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,21 +112,14 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* {@return the distance to the far plane where the fog ends}
|
||||
*/
|
||||
public float getFarPlaneDistance() {
|
||||
return farPlaneDistance;
|
||||
return this.getData().renderDistanceEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the distance to the near plane where the fog starts}
|
||||
*/
|
||||
public float getNearPlaneDistance() {
|
||||
return nearPlaneDistance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the shape of the fog being rendered}
|
||||
*/
|
||||
public FogShape getFogShape() {
|
||||
return fogShape;
|
||||
return this.getData().renderDistanceStart;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +129,7 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* @see #scaleFarPlaneDistance(float)
|
||||
*/
|
||||
public void setFarPlaneDistance(float distance) {
|
||||
farPlaneDistance = distance;
|
||||
getData().renderDistanceEnd = distance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,16 +139,7 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* @see #scaleNearPlaneDistance(float)
|
||||
*/
|
||||
public void setNearPlaneDistance(float distance) {
|
||||
nearPlaneDistance = distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new shape of the fog being rendered. The new shape will only take effect if the event is cancelled.
|
||||
*
|
||||
* @param shape the new shape of the fog
|
||||
*/
|
||||
public void setFogShape(FogShape shape) {
|
||||
fogShape = shape;
|
||||
getData().renderDistanceStart = distance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +148,7 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* @param factor the factor to scale the far plane distance by
|
||||
*/
|
||||
public void scaleFarPlaneDistance(float factor) {
|
||||
farPlaneDistance *= factor;
|
||||
getData().renderDistanceEnd *= factor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +157,7 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* @param factor the factor to scale the near plane distance by
|
||||
*/
|
||||
public void scaleNearPlaneDistance(float factor) {
|
||||
nearPlaneDistance *= factor;
|
||||
getData().renderDistanceStart *= factor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +170,8 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class ComputeFogColor extends ViewportEvent {
|
||||
public static final EventBus<ComputeFogColor> BUS = EventBus.create(ComputeFogColor.class);
|
||||
|
||||
private float red;
|
||||
private float green;
|
||||
private float blue;
|
||||
@@ -255,6 +244,8 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static final class ComputeCameraAngles extends ViewportEvent {
|
||||
public static final EventBus<ComputeCameraAngles> BUS = EventBus.create(ComputeCameraAngles.class);
|
||||
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
private float roll;
|
||||
@@ -328,6 +319,8 @@ public abstract sealed class ViewportEvent extends Event {
|
||||
* @see ComputeFovModifierEvent
|
||||
*/
|
||||
public static final class ComputeFov extends ViewportEvent {
|
||||
public static final EventBus<ComputeFov> BUS = EventBus.create(ComputeFov.class);
|
||||
|
||||
private final boolean usedConfiguredFov;
|
||||
private float fov;
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.common.util.HasResult;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Fired when a sound is about to be played by the sound engine. This fires before the sound is played and before any
|
||||
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* others). This can be used to change or prevent (by passing {@code null)} a sound from being played through
|
||||
* {@link #setSound(SoundInstance)}).
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
@@ -27,16 +27,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @see PlaySoundSourceEvent
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public final class PlaySoundEvent extends SoundEvent
|
||||
{
|
||||
public final class PlaySoundEvent extends SoundEvent {
|
||||
public static final EventBus<PlaySoundEvent> BUS = EventBus.create(PlaySoundEvent.class);
|
||||
|
||||
private final String name;
|
||||
private final SoundInstance originalSound;
|
||||
@Nullable
|
||||
private SoundInstance sound;
|
||||
private @Nullable SoundInstance sound;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlaySoundEvent(SoundEngine manager, SoundInstance sound)
|
||||
{
|
||||
public PlaySoundEvent(SoundEngine manager, SoundInstance sound) {
|
||||
super(manager);
|
||||
this.originalSound = sound;
|
||||
this.name = sound.getLocation().getPath();
|
||||
@@ -46,16 +45,14 @@ public final class PlaySoundEvent extends SoundEvent
|
||||
/**
|
||||
* {@return the name of the original sound} This is equivalent to the path of the location of the original sound.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original sound that was to be played}
|
||||
*/
|
||||
public SoundInstance getOriginalSound()
|
||||
{
|
||||
public SoundInstance getOriginalSound() {
|
||||
return originalSound;
|
||||
}
|
||||
|
||||
@@ -63,8 +60,7 @@ public final class PlaySoundEvent extends SoundEvent
|
||||
* {@return the sound to be played, or {@code null} if no sound will be played}
|
||||
*/
|
||||
@Nullable
|
||||
public SoundInstance getSound()
|
||||
{
|
||||
public SoundInstance getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
@@ -73,8 +69,7 @@ public final class PlaySoundEvent extends SoundEvent
|
||||
*
|
||||
* @param newSound the new sound to be played, or {@code null} for no sound
|
||||
*/
|
||||
public void setSound(@Nullable SoundInstance newSound)
|
||||
{
|
||||
public void setSound(@Nullable SoundInstance newSound) {
|
||||
this.sound = newSound;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -26,11 +26,11 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public final class PlaySoundSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
public final class PlaySoundSourceEvent extends SoundSourceEvent {
|
||||
public static final EventBus<PlaySoundSourceEvent> BUS = EventBus.create(PlaySoundSourceEvent.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlaySoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
public PlaySoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel) {
|
||||
super(engine, sound, channel);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -26,11 +26,11 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public final class PlayStreamingSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
public final class PlayStreamingSourceEvent extends SoundSourceEvent {
|
||||
public static final EventBus<PlayStreamingSourceEvent> BUS = EventBus.create(PlayStreamingSourceEvent.class);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayStreamingSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
public PlayStreamingSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel) {
|
||||
super(engine, sound, channel);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,10 @@
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.common.util.HasResult;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.characteristic.Cancellable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -16,16 +19,18 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* Fired when the {@link SoundEngine} is constructed or (re)loaded, such as during game initialization or when the sound
|
||||
* output device is changed.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
* <p>This event is not {@linkplain Cancellable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public final class SoundEngineLoadEvent extends SoundEvent implements IModBusEvent
|
||||
{
|
||||
public final class SoundEngineLoadEvent extends SoundEvent implements IModBusEvent {
|
||||
public static EventBus<SoundEngineLoadEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, SoundEngineLoadEvent.class);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SoundEngineLoadEvent(SoundEngine manager)
|
||||
{
|
||||
public SoundEngineLoadEvent(SoundEngine manager) {
|
||||
super(manager);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
import net.minecraftforge.eventbus.api.event.MutableEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -23,21 +25,20 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see PlaySoundEvent
|
||||
* @see SoundEngineLoadEvent
|
||||
*/
|
||||
public abstract class SoundEvent extends Event
|
||||
{
|
||||
public abstract class SoundEvent extends MutableEvent implements InheritableEvent {
|
||||
public static final EventBus<SoundEvent> BUS = EventBus.create(SoundEvent.class);
|
||||
|
||||
private final SoundEngine engine;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected SoundEvent(SoundEngine engine)
|
||||
{
|
||||
protected SoundEvent(SoundEngine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the sound engine}
|
||||
*/
|
||||
public SoundEngine getEngine()
|
||||
{
|
||||
public SoundEngine getEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
@@ -50,15 +51,15 @@ public abstract class SoundEvent extends Event
|
||||
* @see PlaySoundSourceEvent
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public static abstract class SoundSourceEvent extends SoundEvent
|
||||
{
|
||||
public static abstract class SoundSourceEvent extends SoundEvent {
|
||||
public static final EventBus<SoundSourceEvent> BUS = EventBus.create(SoundSourceEvent.class);
|
||||
|
||||
private final SoundInstance sound;
|
||||
private final Channel channel;
|
||||
private final String name;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected SoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
protected SoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel) {
|
||||
super(engine);
|
||||
this.name = sound.getLocation().getPath();
|
||||
this.sound = sound;
|
||||
@@ -68,24 +69,21 @@ public abstract class SoundEvent extends Event
|
||||
/**
|
||||
* {@return the sound being played}
|
||||
*/
|
||||
public SoundInstance getSound()
|
||||
{
|
||||
public SoundInstance getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the audio channel on which the sound is playing on}
|
||||
*/
|
||||
public Channel getChannel()
|
||||
{
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the name of the sound being played} This is equivalent to the path of the location of the original sound.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
|
||||
public interface IForgeBlockModelPart {
|
||||
/*
|
||||
private BlockModelPart self() {
|
||||
return (BlockModelPart)this;
|
||||
}
|
||||
*/
|
||||
|
||||
default ChunkSectionLayer layer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default ChunkSectionLayer layerFast() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,19 @@ import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.BlockModelPart;
|
||||
import net.minecraft.client.renderer.block.model.BlockStateModel;
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.ChunkRenderTypeSet;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -29,7 +30,6 @@ public interface IForgeBlockStateModel {
|
||||
return (BlockStateModel)this;
|
||||
}
|
||||
|
||||
|
||||
default @NotNull ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData) {
|
||||
return modelData;
|
||||
}
|
||||
@@ -44,8 +44,7 @@ public interface IForgeBlockStateModel {
|
||||
* <p>
|
||||
* By default, defers query to {@link ItemBlockRenderTypes}.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
default ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) {
|
||||
default Collection<ChunkSectionLayer> getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) {
|
||||
return ItemBlockRenderTypes.getRenderLayers(state);
|
||||
}
|
||||
|
||||
@@ -54,7 +53,7 @@ public interface IForgeBlockStateModel {
|
||||
* Not all paths call this, or use a valid render type. So it is recommended to also implement a sane default in
|
||||
* the normal {@link BlockStateModel#collectParts(RandomSource, List)} method.
|
||||
*/
|
||||
default List<BlockModelPart> collectParts(RandomSource random, ModelData data, @Nullable RenderType renderType) {
|
||||
default List<BlockModelPart> collectParts(RandomSource random, ModelData data, @Nullable ChunkSectionLayer renderType) {
|
||||
List<BlockModelPart> list = new ObjectArrayList<>();
|
||||
this.collectParts(random, list, data, renderType);
|
||||
return list;
|
||||
@@ -65,7 +64,7 @@ public interface IForgeBlockStateModel {
|
||||
* Not all paths call this, or use a valid render type. So it is recommended to also implement a sane default in
|
||||
* the normal {@link BlockStateModel#collectParts(RandomSource, List)} method.
|
||||
*/
|
||||
default void collectParts(RandomSource random, List<BlockModelPart> dest, ModelData data, @Nullable RenderType renderType) {
|
||||
default void collectParts(RandomSource random, List<BlockModelPart> dest, ModelData data, @Nullable ChunkSectionLayer renderType) {
|
||||
self().collectParts(random, dest);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
@@ -80,31 +80,31 @@ public interface IForgeGuiGraphics {
|
||||
|
||||
// Draw Border
|
||||
// Top Left
|
||||
self().blit(RenderType::guiTextured, texture, x, y, 0, u, v, leftBorder, topBorder, 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x, y, 0, u, v, leftBorder, topBorder, 256, 256);
|
||||
// Top Right
|
||||
self().blit(RenderType::guiTextured, texture, x + leftBorder + canvasWidth, y, 0, u + leftBorder + fillerWidth, v, rightBorder, topBorder, 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x + leftBorder + canvasWidth, y, 0, u + leftBorder + fillerWidth, v, rightBorder, topBorder, 256, 256);
|
||||
// Bottom Left
|
||||
self().blit(RenderType::guiTextured, texture, x, y + topBorder + canvasHeight, 0, u, v + topBorder + fillerHeight, leftBorder, bottomBorder, 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x, y + topBorder + canvasHeight, 0, u, v + topBorder + fillerHeight, leftBorder, bottomBorder, 256, 256);
|
||||
// Bottom Right
|
||||
self().blit(RenderType::guiTextured, texture, x + leftBorder + canvasWidth, y + topBorder + canvasHeight, 0, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x + leftBorder + canvasWidth, y + topBorder + canvasHeight, 0, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, 256, 256);
|
||||
|
||||
for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++) {
|
||||
// Top Border
|
||||
self().blit(RenderType::guiTextured, texture, x + leftBorder + (i * fillerWidth), y, 0, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder, 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x + leftBorder + (i * fillerWidth), y, 0, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder, 256, 256);
|
||||
// Bottom Border
|
||||
self().blit(RenderType::guiTextured, texture, x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, 0, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder, 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, 0, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder, 256, 256);
|
||||
|
||||
// Throw in some filler for good measure
|
||||
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
|
||||
self().blit(RenderType::guiTextured, texture, x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), 0, u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight), 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), 0, u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight), 256, 256);
|
||||
}
|
||||
|
||||
// Side Borders
|
||||
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++) {
|
||||
// Left Border
|
||||
self().blit(RenderType::guiTextured, texture, x, y + topBorder + (j * fillerHeight), 0, u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight), 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x, y + topBorder + (j * fillerHeight), 0, u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight), 256, 256);
|
||||
// Right Border
|
||||
self().blit(RenderType::guiTextured, texture, x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), 0, u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight), 256, 256);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), 0, u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight), 256, 256);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public interface IForgeGuiGraphics {
|
||||
if (centerX) x += (w - boundsWidth) / 2;
|
||||
}
|
||||
|
||||
//self().blit(RenderType::guiTextured, texture, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight);
|
||||
self().blit(RenderType::guiTextured, texture, x, y, 0.0f, 0.0f, boundsWidth, boundsHeight, boundsWidth, boundsHeight);
|
||||
//self().blit(RenderPipelines.GUI_TEXTURED, texture, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight);
|
||||
self().blit(RenderPipelines.GUI_TEXTURED, texture, x, y, 0.0f, 0.0f, boundsWidth, boundsHeight, boundsWidth, boundsHeight);
|
||||
}
|
||||
}
|
||||
+4
-9
@@ -10,22 +10,23 @@ import java.util.function.Consumer;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.FogParameters;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.ScreenEffectRenderer;
|
||||
import net.minecraft.client.renderer.fog.FogData;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
/**
|
||||
* {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link FluidType}.
|
||||
@@ -163,14 +164,8 @@ public interface IClientFluidTypeExtensions {
|
||||
/**
|
||||
* Modifies how the fog is currently being rendered when the camera is
|
||||
* within a fluid.
|
||||
*
|
||||
* @param camera the camera instance
|
||||
* @param mode the type of fog being rendered
|
||||
* @param renderDistance the render distance of the client
|
||||
* @param partialTick the delta time of where the current frame is within a tick
|
||||
*/
|
||||
default FogParameters modifyFogRender(Camera camera, FogRenderer.FogMode mode, float renderDistance, float partialTick, FogParameters original) {
|
||||
return original;
|
||||
default void modifyFogRender(Camera camera, FogType type, float partialTick, FogData data, Vector4f color) {
|
||||
}
|
||||
|
||||
/* Level-Based Accessors */
|
||||
|
||||
@@ -78,8 +78,8 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
|
||||
private void drawMultiLineCenteredString(GuiGraphics guiGraphics, Font fr, Component str, int x, int y) {
|
||||
for (FormattedCharSequence s : fr.split(str, this.width)) {
|
||||
guiGraphics.drawString(fr, s, (float) (x - fr.width(s) / 2.0), (float) y, 0xFFFFFF, true);
|
||||
y+=fr.lineHeight;
|
||||
guiGraphics.drawString(fr, s, x - fr.width(s) / 2, y, 0xFFFFFF);
|
||||
y += fr.lineHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
int y = top + 2;
|
||||
for (var string : strings) {
|
||||
if (center)
|
||||
guiGraphics.drawString(font, string, left + (width / 2F) - (font.width(string) / 2F), y, 0xFFFFFF, false);
|
||||
guiGraphics.drawString(font, string, left + (width / 2) - (font.width(string) / 2), y, 0xFFFFFF, false);
|
||||
else
|
||||
guiGraphics.drawString(font, string, left + 5, y, 0xFFFFFF, false);
|
||||
y += font.lineHeight;
|
||||
|
||||
@@ -24,8 +24,6 @@ import net.minecraftforge.client.gui.widget.ScrollPanel;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import org.apache.maven.artifact.versioning.ComparableVersion;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
@@ -38,6 +36,7 @@ import net.minecraft.client.gui.components.StringWidget;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ARGB;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.Util;
|
||||
@@ -164,7 +163,7 @@ public class ModListScreen extends Screen {
|
||||
@Override
|
||||
protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY) {
|
||||
if (logoPath != null) {
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
//RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// Draw the logo image inscribed in a rectangle with width entryWidth (minus some padding) and height 50
|
||||
int headerHeight = 50;
|
||||
guiGraphics.blitInscribed(logoPath, left + PADDING, relativeY, width - (PADDING * 2), headerHeight, logoDims.width(), logoDims.height(), false, true);
|
||||
@@ -173,7 +172,7 @@ public class ModListScreen extends Screen {
|
||||
|
||||
for (FormattedCharSequence line : lines) {
|
||||
if (line != null)
|
||||
guiGraphics.drawString(ModListScreen.this.font, line, left + PADDING, relativeY, 0xFFFFFF);
|
||||
guiGraphics.drawString(ModListScreen.this.font, line, left + PADDING, relativeY, ARGB.white(1));
|
||||
relativeY += font.lineHeight;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ package net.minecraftforge.client.gui;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -49,7 +49,7 @@ public class TitleScreenModUpdateIndicator extends Screen {
|
||||
int w = modButton.getWidth();
|
||||
int h = modButton.getHeight();
|
||||
|
||||
guiGraphics.blit(RenderType::guiTextured, VERSION_CHECK_ICONS, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
|
||||
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, VERSION_CHECK_ICONS, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
|
||||
}
|
||||
|
||||
public static TitleScreenModUpdateIndicator init(TitleScreen guiMainMenu, Button modButton) {
|
||||
|
||||
@@ -8,7 +8,7 @@ package net.minecraftforge.client.gui.widget;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
@@ -40,7 +40,7 @@ public class ExtendedButton extends Button {
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
guiGraphics.blitSprite(RenderType::guiTextured, SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
|
||||
guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
|
||||
|
||||
final FormattedText buttonText = mc.font.ellipsize(this.getMessage(), this.width - 6); // Remove 6 pixels so that the text is always contained within the button's borders
|
||||
guiGraphics.drawCenteredString(mc.font, Language.getInstance().getVisualOrder(buttonText), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, getFGColor());
|
||||
|
||||
@@ -8,7 +8,7 @@ package net.minecraftforge.client.gui.widget;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -197,8 +197,8 @@ public class ForgeSlider extends AbstractSliderButton {
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
final Minecraft mc = Minecraft.getInstance();
|
||||
guiGraphics.blitSprite(RenderType::guiTextured, this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight());
|
||||
guiGraphics.blitSprite(RenderType::guiTextured, this.getHandleSprite(), this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 8, this.getHeight());
|
||||
guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight());
|
||||
guiGraphics.blitSprite(RenderPipelines.GUI_TEXTURED, this.getHandleSprite(), this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 8, this.getHeight());
|
||||
|
||||
renderScrollingString(guiGraphics, mc.font, 2, getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ package net.minecraftforge.client.gui.widget;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
@@ -19,8 +19,6 @@ import net.minecraftforge.common.util.MavenVersionStringHelper;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry> {
|
||||
private static String stripControlCodes(String value) { return net.minecraft.util.StringUtil.stripColor(value); }
|
||||
private static final ResourceLocation VERSION_CHECK_ICONS = ResourceLocation.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png");
|
||||
@@ -80,14 +78,13 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry> {
|
||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
|
||||
Font font = this.parent.getFontRenderer();
|
||||
var barOffset = ModListWidget.this.scrollbarVisible() ? 6 : 0;
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth - 6 - barOffset))), left + 3, top + 2, 0xFFFFFF, false);
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth - 6 - barOffset))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC, false);
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth - 6 - barOffset))), left + 3, top + 2, 0xFFFFFFFF, false);
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth - 6 - barOffset))), left + 3, top + 2 + font.lineHeight, 0xFFCCCCCC, false);
|
||||
if (vercheck.status().shouldDraw()) {
|
||||
//TODO: [Forge][ModList] Consider adding more icons for visualization
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.blit(RenderType::guiTextured, VERSION_CHECK_ICONS, getX() + width - 12 - barOffset, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
|
||||
guiGraphics.pose().popPose();
|
||||
guiGraphics.pose().pushMatrix();
|
||||
guiGraphics.blit(RenderPipelines.GUI_TEXTURED, VERSION_CHECK_ICONS, getX() + width - 12 - barOffset, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
|
||||
guiGraphics.pose().popMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -264,24 +262,29 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
if (barTop < this.top)
|
||||
barTop = this.top;
|
||||
|
||||
guiGraphics.fill(barLeft, this.top, barLeft + barWidth, this.bottom, barBgColor);
|
||||
guiGraphics.fill(barLeft, barTop, barLeft + barWidth, barTop + barHeight, barColor);
|
||||
guiGraphics.fill(barLeft, barTop + barHeight - 1, barLeft + barWidth - 1, barTop, barBorderColor);
|
||||
/*
|
||||
var source = guiGraphics.getBufferSource();
|
||||
var buf = source.getBuffer(RenderType.gui());
|
||||
var buf = source.getBuffer(RenderPipelines.GUI);
|
||||
buf.addVertex(barLeft, this.bottom, 0.0F).setColor(barBgColor);
|
||||
buf.addVertex(barLeft + barWidth, this.bottom, 0.0F).setColor(barBgColor);
|
||||
buf.addVertex(barLeft + barWidth, this.top, 0.0F).setColor(barBgColor);
|
||||
buf.addVertex(barLeft, this.top, 0.0F).setColor(barBgColor);
|
||||
|
||||
buf = source.getBuffer(RenderType.gui());
|
||||
buf = source.getBuffer(RenderPipelines.GUI);
|
||||
buf.addVertex(barLeft, barTop + barHeight, 0.0F).setColor(barColor);
|
||||
buf.addVertex(barLeft + barWidth, barTop + barHeight, 0.0F).setColor(barColor);
|
||||
buf.addVertex(barLeft + barWidth, barTop, 0.0F).setColor(barColor);
|
||||
buf.addVertex(barLeft, barTop, 0.0F).setColor(barColor);
|
||||
|
||||
buf = source.getBuffer(RenderType.gui());
|
||||
buf = source.getBuffer(RenderPipelines.GUI);
|
||||
buf.addVertex(barLeft, barTop + barHeight - 1, 0.0F).setColor(barBorderColor);
|
||||
buf.addVertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0F).setColor(barBorderColor);
|
||||
buf.addVertex(barLeft + barWidth - 1, barTop, 0.0F).setColor(barBorderColor);
|
||||
buf.addVertex(barLeft, barTop, 0.0F).setColor(barBorderColor);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.world.level.DataPackConfig;
|
||||
import net.minecraftforge.event.AddPackFindersEvent;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.fml.*;
|
||||
import net.minecraftforge.fml.loading.ImmediateWindowHandler;
|
||||
import net.minecraftforge.internal.BrandingControl;
|
||||
@@ -106,16 +107,14 @@ public class ClientModLoader {
|
||||
}
|
||||
|
||||
File dumpedLocation = null;
|
||||
if (error == null) {
|
||||
// We can finally start the forge eventbus up
|
||||
MinecraftForge.EVENT_BUS.start();
|
||||
} else {
|
||||
if (error != null) {
|
||||
// Double check we have the langs loaded for forge
|
||||
LanguageHook.loadForgeAndMCLangs();
|
||||
dumpedLocation = CrashReportExtender.dumpModLoadingCrashReport(LOGGER, error, mc.gameDirectory);
|
||||
}
|
||||
|
||||
if (error != null || !warnings.isEmpty()) {
|
||||
BusGroup.DEFAULT.shutdown();
|
||||
mc.setScreen(new LoadingErrorScreen(error, warnings, dumpedLocation));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.LoadingOverlay;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.server.packs.resources.ReloadInstance;
|
||||
import net.minecraft.util.ARGB;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.client.ForgeRenderTypes;
|
||||
import net.minecraftforge.fml.StartupMessageManager;
|
||||
@@ -33,7 +34,7 @@ import java.util.function.Supplier;
|
||||
* It is somewhat a copy of the superclass render method.
|
||||
*/
|
||||
public class ForgeLoadingOverlay extends LoadingOverlay {
|
||||
private static final boolean ENABLE = Boolean.parseBoolean("forge.enableForgeLoadingOverlay");
|
||||
private static final boolean ENABLE = false; //Boolean.parseBoolean("forge.enableForgeLoadingOverlay");
|
||||
private final Minecraft minecraft;
|
||||
private final ReloadInstance reload;
|
||||
private final DisplayWindow displayWindow;
|
||||
@@ -60,6 +61,10 @@ public class ForgeLoadingOverlay extends LoadingOverlay {
|
||||
protected boolean renderContents(GuiGraphics gui, float fade) {
|
||||
if (!ENABLE)
|
||||
return true;
|
||||
/* This should render the framebuffer but it doesnt work in 1.21.6's rendering changes.
|
||||
* The proper way to fix this is to just kill off the display window when Vanilla gets to this phase, and render our extra elements normally.
|
||||
* TODO: [Forge][Rendering] Render only out elements from the loading screen
|
||||
*
|
||||
progress.setAbsolute(Mth.clamp((int)(this.reload.getActualProgress() * 100f), 0, 100));
|
||||
|
||||
int alpha = (int)(fade * 255);
|
||||
@@ -72,39 +77,12 @@ public class ForgeLoadingOverlay extends LoadingOverlay {
|
||||
var fbHeight = this.minecraft.getWindow().getHeight();
|
||||
GL30C.glViewport(0, 0, fbWidth, fbHeight);
|
||||
|
||||
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, fade);
|
||||
Matrix4f pos = gui.pose().last().pose();
|
||||
/*
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(GlConst.GL_SRC_ALPHA, GlConst.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.setShader(CoreShaders.POSITION_TEX_COLOR);
|
||||
RenderSystem.setShaderTexture(0, displayWindow.getFramebufferTextureId());
|
||||
GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MIN_FILTER, GlConst.GL_NEAREST);
|
||||
GL30C.glTexParameterIi(GlConst.GL_TEXTURE_2D, GlConst.GL_TEXTURE_MAG_FILTER, GlConst.GL_NEAREST);
|
||||
*/
|
||||
|
||||
var buf = gui.getBufferSource().getBuffer(earlyBuffer);
|
||||
buf.addVertex(pos, 0, 0, 0f).setUv(0, 0).setColor(1f, 1f, 1f, fade);
|
||||
buf.addVertex(pos, 0, height, 0f).setUv(0, 1).setColor(1f, 1f, 1f, fade);
|
||||
buf.addVertex(pos, width, height, 0f).setUv(1, 1).setColor(1f, 1f, 1f, fade);
|
||||
buf.addVertex(pos, width, 0, 0f).setUv(1, 0).setColor(1f, 1f, 1f, fade);
|
||||
/*
|
||||
BufferUploader.drawWithShader(buf.buildOrThrow());
|
||||
|
||||
// I dont know what exactly this does, but without it the screen flickers black.
|
||||
// So as a hack we just render the mojang logo as a 0x0 cube
|
||||
// TODO: Remove this when early screen is re-written to not be a texture based renderer
|
||||
var logo = gui.getBufferSource().getBuffer(RenderType.mojangLogo());
|
||||
logo.addVertex(pos, 0, 0, 0f).setUv(0, 0).setColor(1f, 1f, 1f, fade);
|
||||
logo.addVertex(pos, 0, 0, 0f).setUv(0, 1).setColor(1f, 1f, 1f, fade);
|
||||
logo.addVertex(pos, 0, 0, 0f).setUv(1, 1).setColor(1f, 1f, 1f, fade);
|
||||
logo.addVertex(pos, 0, 0, 0f).setUv(1, 0).setColor(1f, 1f, 1f, fade);
|
||||
|
||||
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.disableBlend();
|
||||
*/
|
||||
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1f);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ package net.minecraftforge.client.model;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.TextureSlots;
|
||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
@@ -61,7 +61,7 @@ public class DynamicFluidContainerModel implements UnbakedGeometry {
|
||||
}
|
||||
|
||||
public static RenderTypeGroup getLayerRenderTypes(boolean unlit) {
|
||||
return new RenderTypeGroup(RenderType.translucent(), unlit ? ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get() : ForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get());
|
||||
return new RenderTypeGroup(ChunkSectionLayer.TRANSLUCENT, unlit ? ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get() : ForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.level.ChunkEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -8,7 +8,6 @@ package net.minecraftforge.client.model.obj;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.TextureSlots;
|
||||
import net.minecraft.client.resources.model.ModelBaker;
|
||||
@@ -21,12 +20,10 @@ import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraftforge.client.model.IModelBuilder;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.client.model.geometry.StandaloneGeometryBakingContext;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.listener.EventListener;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.unsafe.UnsafeHacks;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A small helper class to aid Forge modders in migrating from EventBus 6 to the new EventBus 7.
|
||||
* <br>
|
||||
* Refer to the migration guide mentioned in the Forge 1.21.6 announcement or ask in the Forge Discord for help with
|
||||
* migrating your mod to the new system.
|
||||
*/
|
||||
public final class EventBusMigrationHelper {
|
||||
public static final EventBusMigrationHelper INSTANCE = new EventBusMigrationHelper(BusGroup.DEFAULT);
|
||||
|
||||
private final BusGroup group;
|
||||
|
||||
public EventBusMigrationHelper(BusGroup group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of {@link BusGroup#register(Lookup, Class)} that doesn't require a lookup. It is strongly recommended
|
||||
* to use the BusGroup method directly with {@code MethodHandles.lookup()} as the first argument, as this migration
|
||||
* helper method relies on JDK internals that may break without notice.
|
||||
* @param clazz the class containing static event listener methods that you want to register.
|
||||
* @return a collection of {@link EventListener} instances that were registered, can be passed to
|
||||
* {@link BusGroup#unregister(Collection)} to unregister them later.
|
||||
* @see BusGroup#register(Lookup, Class)
|
||||
*/
|
||||
public Collection<EventListener> register(Class<?> clazz) {
|
||||
return registerListeners(group, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of {@link BusGroup#register(Lookup, Object)} that doesn't require a lookup. It is strongly recommended
|
||||
* to use the BusGroup method directly with {@code MethodHandles.lookup()} as the first argument, as this migration
|
||||
* helper method relies on JDK internals that may break without notice.
|
||||
* @param instance the instance of a class containing instance and static event listener methods that you want to register.
|
||||
* @return a collection of {@link EventListener} instances that were registered, can be passed to
|
||||
* {@link BusGroup#unregister(Collection)} to unregister them later.
|
||||
* @see BusGroup#register(Lookup, Object)
|
||||
*/
|
||||
public Collection<EventListener> register(Object instance) {
|
||||
return registerListeners(group, instance);
|
||||
}
|
||||
|
||||
private static Collection<EventListener> registerListeners(BusGroup group, Object instance) {
|
||||
final class DodgyLookup {
|
||||
private DodgyLookup() {}
|
||||
private static final Lookup INSTANCE;
|
||||
static {
|
||||
try {
|
||||
var lookupField = Lookup.class.getDeclaredField("IMPL_LOOKUP");
|
||||
UnsafeHacks.setAccessible(lookupField);
|
||||
INSTANCE = (Lookup) lookupField.get(null);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (instance.getClass() == Class.class) {
|
||||
Class<?> clazz = (Class<?>) instance;
|
||||
return group.register(DodgyLookup.INSTANCE.in(clazz), clazz);
|
||||
} else {
|
||||
return group.register(DodgyLookup.INSTANCE.in(instance.getClass()), instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The unique name of this BusGroup.
|
||||
*/
|
||||
public String name() {
|
||||
return group.name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all static methods annotated with {@link SubscribeEvent} in the given class.
|
||||
*
|
||||
* @param callerLookup {@code MethodHandles.lookup()} from the class containing listeners
|
||||
* @param utilityClassWithStaticListeners the class containing the static listeners
|
||||
* @return A collection of the registered listeners, which can be used to optionally unregister them later
|
||||
*
|
||||
* @apiNote This method only registers static listeners.
|
||||
* <p>If you want to register both instance and static methods, use
|
||||
* {@link BusGroup#register(MethodHandles.Lookup, Object)} instead.</p>
|
||||
*/
|
||||
public Collection<EventListener> register(MethodHandles.Lookup callerLookup, Class<?> utilityClassWithStaticListeners) {
|
||||
return group.register(callerLookup, utilityClassWithStaticListeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all methods annotated with {@link SubscribeEvent} in the given object.
|
||||
*
|
||||
* @param callerLookup {@code MethodHandles.lookup()} from the class containing the listeners
|
||||
* @param listener the object containing the static and/or instance listeners
|
||||
* @return A collection of the registered listeners, which can be used to optionally unregister them later
|
||||
*
|
||||
* @apiNote If you know all the listeners are static methods, use
|
||||
* {@link BusGroup#register(MethodHandles.Lookup, Class)} instead for better registration performance.
|
||||
*/
|
||||
public Collection<EventListener> register(MethodHandles.Lookup callerLookup, Object listener) {
|
||||
return group.register(callerLookup, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the given listeners from this BusGroup.
|
||||
* @param listeners A collection of listeners to unregister, obtained from
|
||||
* {@link #register(Class)} or {@link #register(Object)}
|
||||
* {@link #register(MethodHandles.Lookup, Class)} or {@link #register(MethodHandles.Lookup, Object)}
|
||||
*/
|
||||
public void unregister(Collection<EventListener> listeners) {
|
||||
group.unregister(listeners);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.Logging;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -16,7 +15,7 @@ import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ForgeConfig {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public static class Server {
|
||||
public final BooleanValue removeErroringBlockEntities;
|
||||
@@ -152,13 +151,11 @@ public class ForgeConfig {
|
||||
SERVER = specPair.getLeft();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onLoad(final ModConfigEvent.Loading configEvent) {
|
||||
static void onLoad(final ModConfigEvent.Loading configEvent) {
|
||||
LOGGER.debug(Logging.FORGEMOD, "Loaded forge config file {}", configEvent.getConfig().getFileName());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onFileChange(final ModConfigEvent.Reloading configEvent) {
|
||||
static void onFileChange(final ModConfigEvent.Reloading configEvent) {
|
||||
LOGGER.debug(Logging.FORGEMOD, "Forge config just got changed on the file system!");
|
||||
}
|
||||
|
||||
|
||||
@@ -127,11 +127,7 @@ import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraftforge.common.crafting.conditions.ConditionCodec;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.crafting.ingredients.IIngredientSerializer;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.BrainBuilder;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
import net.minecraftforge.common.util.MavenVersionStringHelper;
|
||||
import net.minecraftforge.common.util.MutableHashedLinkedMap;
|
||||
import net.minecraftforge.common.util.*;
|
||||
import net.minecraftforge.entity.IEntityAdditionalSpawnData;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
@@ -157,11 +153,11 @@ import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.CriticalHitEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingGetProjectileEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.event.level.NoteBlockEvent;
|
||||
import net.minecraftforge.event.level.ChunkEvent;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
@@ -215,7 +211,7 @@ public final class ForgeHooks {
|
||||
private ForgeHooks() {}
|
||||
|
||||
public static void fireLightingCalculatedEvent(ChunkAccess chunk) {
|
||||
MinecraftForge.EVENT_BUS.post(new ChunkEvent.LightingCalculated(chunk));
|
||||
ChunkEvent.LightingCalculated.BUS.post(new ChunkEvent.LightingCalculated(chunk));
|
||||
}
|
||||
|
||||
public static boolean canContinueUsing(@NotNull ItemStack from, @NotNull ItemStack to) {
|
||||
@@ -233,37 +229,39 @@ public final class ForgeHooks {
|
||||
}
|
||||
|
||||
public static Brain<?> onLivingMakeBrain(LivingEntity entity, Brain<?> originalBrain, Dynamic<?> dynamic) {
|
||||
if (!LivingMakeBrainEvent.BUS.hasListeners())
|
||||
return originalBrain;
|
||||
|
||||
BrainBuilder<?> brainBuilder = originalBrain.createBuilder();
|
||||
LivingMakeBrainEvent event = new LivingMakeBrainEvent(entity, brainBuilder);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
LivingMakeBrainEvent.BUS.post(new LivingMakeBrainEvent(entity, brainBuilder));
|
||||
return brainBuilder.makeBrain(dynamic);
|
||||
}
|
||||
|
||||
public static boolean onLivingAttack(LivingEntity entity, DamageSource src, float amount) {
|
||||
return entity instanceof Player || !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
|
||||
return entity instanceof Player || !LivingAttackEvent.BUS.post(new LivingAttackEvent(entity, src, amount));
|
||||
}
|
||||
|
||||
public static boolean onPlayerAttack(LivingEntity entity, DamageSource src, float amount) {
|
||||
return !MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
|
||||
return !LivingAttackEvent.BUS.post(new LivingAttackEvent(entity, src, amount));
|
||||
}
|
||||
|
||||
public static boolean onLivingUseTotem(LivingEntity entity, DamageSource damageSource, ItemStack totem, InteractionHand hand) {
|
||||
return !MinecraftForge.EVENT_BUS.post(new LivingUseTotemEvent(entity, damageSource, totem, hand));
|
||||
return !LivingUseTotemEvent.BUS.post(new LivingUseTotemEvent(entity, damageSource, totem, hand));
|
||||
}
|
||||
|
||||
public static float onLivingHurt(LivingEntity entity, DamageSource src, float amount) {
|
||||
LivingHurtEvent event = new LivingHurtEvent(entity, src, amount);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
|
||||
return LivingHurtEvent.BUS.post(event) ? 0 : event.getAmount();
|
||||
}
|
||||
|
||||
public static float onLivingDamage(LivingEntity entity, DamageSource src, float amount) {
|
||||
LivingDamageEvent event = new LivingDamageEvent(entity, src, amount);
|
||||
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
|
||||
return LivingDamageEvent.BUS.post(event) ? 0 : event.getAmount();
|
||||
}
|
||||
|
||||
public static InteractionResult onInteractEntityAt(Entity entity, Player player, Vec3 vec3d, InteractionHand hand) {
|
||||
var ret = ForgeEventFactory.onEntityInteractSpecific(player, entity, hand, vec3d);
|
||||
if (ret.isCanceled())
|
||||
var ret = new PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, vec3d);
|
||||
if (PlayerInteractEvent.EntityInteractSpecific.BUS.post(ret))
|
||||
return ret.getCancellationResult();
|
||||
return entity.interactAt(player, vec3d, hand);
|
||||
}
|
||||
@@ -281,7 +279,7 @@ public final class ForgeHooks {
|
||||
|
||||
public static double getEntityVisibilityMultiplier(LivingEntity entity, Entity lookingEntity, double originalMultiplier){
|
||||
LivingEvent.LivingVisibilityEvent event = new LivingEvent.LivingVisibilityEvent(entity, lookingEntity, originalMultiplier);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
LivingEvent.LivingVisibilityEvent.BUS.post(event);
|
||||
return Math.max(0,event.getVisibilityModifier());
|
||||
}
|
||||
|
||||
@@ -310,33 +308,33 @@ public final class ForgeHooks {
|
||||
}
|
||||
|
||||
public static void onLivingJump(LivingEntity entity) {
|
||||
MinecraftForge.EVENT_BUS.post(new LivingJumpEvent(entity));
|
||||
LivingJumpEvent.BUS.post(new LivingJumpEvent(entity));
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Nullable
|
||||
public static ItemEntity onPlayerTossEvent(@NotNull Player player, @NotNull ItemStack item, boolean includeName) {
|
||||
player.captureDrops(Lists.newArrayList());
|
||||
player.captureDrops(new ArrayList<>());
|
||||
ItemEntity ret = player.drop(item, false, includeName);
|
||||
player.captureDrops(null);
|
||||
|
||||
if (ret == null)
|
||||
return null;
|
||||
|
||||
ItemTossEvent event = new ItemTossEvent(ret, player);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
var event = new ItemTossEvent(ret, player);
|
||||
if (ItemTossEvent.BUS.post(event))
|
||||
return null;
|
||||
|
||||
if (!player.level().isClientSide)
|
||||
player.getCommandSenderWorld().addFreshEntity(event.getEntity());
|
||||
player.level().addFreshEntity(event.getEntity());
|
||||
return event.getEntity();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Component onServerChatSubmittedEvent(ServerPlayer player, Component message) {
|
||||
var plain = message.getContents() instanceof LiteralContents literalContents ? literalContents.text() : "";
|
||||
ServerChatEvent event = new ServerChatEvent(player, plain, message);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
|
||||
var event = new ServerChatEvent(player, plain, message);
|
||||
return ServerChatEvent.BUS.post(event) ? null : event.getMessage();
|
||||
}
|
||||
|
||||
static final Pattern URL_PATTERN = Pattern.compile(
|
||||
@@ -439,12 +437,11 @@ public final class ForgeHooks {
|
||||
level.sendBlockUpdated(pos, state, state, 3);
|
||||
}
|
||||
|
||||
var event = new BlockEvent.BreakEvent(level, pos, state, entityPlayer);
|
||||
event.setCanceled(preCancelEvent);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
var event = new BlockEvent.BreakEvent(level, pos, state, entityPlayer, preCancelEvent ? Result.DENY : Result.DEFAULT);
|
||||
var eventIsDenied = BlockEvent.BreakEvent.BUS.fire(event).getResult().isDenied();
|
||||
|
||||
// Handle if the event is canceled
|
||||
if (event.isCanceled()) {
|
||||
// Handle if the event is cancelled
|
||||
if (eventIsDenied) {
|
||||
// Let the client know the block still exists
|
||||
entityPlayer.connection.send(new ClientboundBlockUpdatePacket(level, pos));
|
||||
|
||||
@@ -456,7 +453,7 @@ public final class ForgeHooks {
|
||||
entityPlayer.connection.send(pkt);
|
||||
}
|
||||
}
|
||||
return event.isCanceled() ? -1 : event.getExpToDrop();
|
||||
return eventIsDenied ? -1 : event.getExpToDrop();
|
||||
}
|
||||
|
||||
public static InteractionResult onPlaceItemIntoWorld(@NotNull UseOnContext context) {
|
||||
@@ -494,12 +491,12 @@ public final class ForgeHooks {
|
||||
if (blockSnapshots.size() > 1)
|
||||
eventResult = ForgeEventFactory.onMultiBlockPlace(player, blockSnapshots, side);
|
||||
else if (blockSnapshots.size() == 1)
|
||||
eventResult = ForgeEventFactory.onBlockPlace(player, blockSnapshots.get(0), side);
|
||||
eventResult = ForgeEventFactory.onBlockPlace(player, blockSnapshots.getFirst(), side);
|
||||
|
||||
if (eventResult) {
|
||||
ret = InteractionResult.FAIL; // cancel placement
|
||||
// revert back all captured blocks
|
||||
for (BlockSnapshot blocksnapshot : Lists.reverse(blockSnapshots)) {
|
||||
for (BlockSnapshot blocksnapshot : blockSnapshots.reversed()) {
|
||||
level.restoringBlockSnapshots = true;
|
||||
blocksnapshot.restore(true, false);
|
||||
level.restoringBlockSnapshots = false;
|
||||
@@ -527,7 +524,7 @@ public final class ForgeHooks {
|
||||
|
||||
public static boolean onAnvilChange(AnvilMenu container, @NotNull ItemStack left, @NotNull ItemStack right, Container outputSlot, String name, long baseCost, Player player) {
|
||||
AnvilUpdateEvent e = new AnvilUpdateEvent(left, right, name, baseCost, player);
|
||||
if (MinecraftForge.EVENT_BUS.post(e)) return false;
|
||||
if (AnvilUpdateEvent.BUS.post(e)) return false;
|
||||
if (e.getOutput().isEmpty()) return true;
|
||||
|
||||
outputSlot.setItem(0, e.getOutput());
|
||||
@@ -539,8 +536,8 @@ public final class ForgeHooks {
|
||||
public static boolean onGrindstoneTake(Container inputSlots, ContainerLevelAccess access, Function<Level, Integer> xpFunction) {
|
||||
access.execute((l,p) -> {
|
||||
int xp = xpFunction.apply(l);
|
||||
GrindstoneEvent.OnTakeItem e = new GrindstoneEvent.OnTakeItem(inputSlots.getItem(0), inputSlots.getItem(1), xp);
|
||||
if (MinecraftForge.EVENT_BUS.post(e))
|
||||
var e = new GrindstoneEvent.OnTakeItem(inputSlots.getItem(0), inputSlots.getItem(1), xp);
|
||||
if (GrindstoneEvent.OnTakeItem.BUS.post(e))
|
||||
return;
|
||||
|
||||
if (l instanceof ServerLevel server)
|
||||
@@ -578,14 +575,14 @@ public final class ForgeHooks {
|
||||
}
|
||||
|
||||
public static boolean onPlayerAttackTarget(Player player, Entity target) {
|
||||
if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false;
|
||||
if (AttackEntityEvent.BUS.post(new AttackEntityEvent(player, target))) return false;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
return stack.isEmpty() || !stack.getItem().onLeftClickEntity(stack, player, target);
|
||||
}
|
||||
|
||||
public static InteractionResult onItemRightClick(Player player, InteractionHand hand) {
|
||||
var evt = ForgeEventFactory.onRightClickItem(player, hand);
|
||||
return evt.isCanceled() ? evt.getCancellationResult() : null;
|
||||
var evt = new PlayerInteractEvent.RightClickItem(player, hand);
|
||||
return PlayerInteractEvent.RightClickItem.BUS.post(evt) ? evt.getCancellationResult() : null;
|
||||
}
|
||||
|
||||
public static GameType onChangeGameType(Player player, GameType currentGameType, GameType newGameType) {
|
||||
@@ -593,7 +590,7 @@ public final class ForgeHooks {
|
||||
return currentGameType;
|
||||
|
||||
var evt = new PlayerEvent.PlayerChangeGameModeEvent(player, currentGameType, newGameType);
|
||||
if (MinecraftForge.EVENT_BUS.post(evt))
|
||||
if (PlayerEvent.PlayerChangeGameModeEvent.BUS.post(evt))
|
||||
return currentGameType;
|
||||
|
||||
return evt.getNewGameMode();
|
||||
@@ -654,19 +651,19 @@ public final class ForgeHooks {
|
||||
}
|
||||
|
||||
public static boolean onCropsGrowPre(Level level, BlockPos pos, BlockState state, boolean def) {
|
||||
var result = MinecraftForge.EVENT_BUS.fire(new BlockEvent.CropGrowEvent.Pre(level,pos,state)).getResult();
|
||||
var result = BlockEvent.CropGrowEvent.Pre.BUS.fire(new BlockEvent.CropGrowEvent.Pre(level, pos, state)).getResult();
|
||||
return (result.isAllowed() || (def && result.isDefault()));
|
||||
}
|
||||
|
||||
public static void onCropsGrowPost(Level level, BlockPos pos, BlockState state) {
|
||||
MinecraftForge.EVENT_BUS.post(new BlockEvent.CropGrowEvent.Post(level, pos, state, level.getBlockState(pos)));
|
||||
BlockEvent.CropGrowEvent.Post.BUS.post(new BlockEvent.CropGrowEvent.Post(level, pos, state, level.getBlockState(pos)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CriticalHitEvent getCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier) {
|
||||
CriticalHitEvent hitResult = new CriticalHitEvent(player, target, damageModifier, vanillaCritical);
|
||||
MinecraftForge.EVENT_BUS.post(hitResult);
|
||||
if (hitResult.getResult() == Event.Result.ALLOW || (vanillaCritical && hitResult.getResult() == Event.Result.DEFAULT))
|
||||
CriticalHitEvent.BUS.post(hitResult);
|
||||
if (hitResult.getResult().isAllowed() || (vanillaCritical && hitResult.getResult().isDefault()))
|
||||
return hitResult;
|
||||
return null;
|
||||
}
|
||||
@@ -675,9 +672,8 @@ public final class ForgeHooks {
|
||||
* Hook to fire {@link LivingGetProjectileEvent}. Returns the ammo to be used.
|
||||
*/
|
||||
public static ItemStack getProjectile(LivingEntity entity, ItemStack projectileWeaponItem, ItemStack projectile) {
|
||||
LivingGetProjectileEvent event = new LivingGetProjectileEvent(entity, projectileWeaponItem, projectile);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getProjectileItemStack();
|
||||
var event = new LivingGetProjectileEvent(entity, projectileWeaponItem, projectile);
|
||||
return LivingGetProjectileEvent.BUS.fire(event).getProjectileItemStack();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -717,8 +713,8 @@ public final class ForgeHooks {
|
||||
}
|
||||
|
||||
public static int onNoteChange(Level level, BlockPos pos, BlockState state, int old, int _new) {
|
||||
NoteBlockEvent.Change event = new NoteBlockEvent.Change(level, pos, state, old, _new);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
var event = new NoteBlockEvent.Change(level, pos, state, old, _new);
|
||||
if (NoteBlockEvent.Change.BUS.post(event))
|
||||
return -1;
|
||||
return event.getVanillaNoteId();
|
||||
}
|
||||
@@ -962,14 +958,14 @@ public final class ForgeHooks {
|
||||
return true;
|
||||
|
||||
var mask = player.getItemBySlot(EquipmentSlot.HEAD);
|
||||
return !mask.isMonsterDisguise(player, monster) || MinecraftForge.EVENT_BUS.post(new MonsterDisguiseEvent(monster, player));
|
||||
return !mask.isMonsterDisguise(player, monster) || MonsterDisguiseEvent.BUS.post(new MonsterDisguiseEvent(monster, player));
|
||||
};
|
||||
}
|
||||
|
||||
private static final Lazy<Map<String, StructuresBecomeConfiguredFix.Conversion>> FORGE_CONVERSION_MAP = Lazy.concurrentOf(() -> {
|
||||
Map<String, StructuresBecomeConfiguredFix.Conversion> map = new HashMap<>();
|
||||
MinecraftForge.EVENT_BUS.post(new RegisterStructureConversionsEvent(map));
|
||||
return ImmutableMap.copyOf(map);
|
||||
RegisterStructureConversionsEvent.BUS.post(new RegisterStructureConversionsEvent(map));
|
||||
return Map.copyOf(map);
|
||||
});
|
||||
|
||||
// DO NOT CALL from within RegisterStructureConversionsEvent, otherwise you'll get a deadlock
|
||||
@@ -1032,8 +1028,8 @@ public final class ForgeHooks {
|
||||
entity.setAirSupply(entity.getAirSupply() - breatheEvent.getConsumeAirAmount());
|
||||
|
||||
if (entity.getAirSupply() <= -20) {
|
||||
var drownEvent = ForgeEventFactory.onLivingDrown(entity, entity.getAirSupply() <= -20, 2.0F, 8);
|
||||
if (!drownEvent.isCanceled() && drownEvent.isDrowning()) {
|
||||
var drownEvent = new LivingDrownEvent(entity, entity.getAirSupply() <= -20, 2.0F, 8);
|
||||
if (!LivingDrownEvent.BUS.post(drownEvent) && drownEvent.isDrowning()) {
|
||||
entity.setAirSupply(0);
|
||||
Vec3 vec3 = entity.getDeltaMovement();
|
||||
|
||||
@@ -1129,7 +1125,7 @@ public final class ForgeHooks {
|
||||
|
||||
// Should we always fire this, even if the channel consumed the packet?
|
||||
if (!event.getSource().getPacketHandled()) {
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
CustomPayloadEvent.BUS.fire(event);
|
||||
return event.getSource().getPacketHandled();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,73 +19,83 @@ import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.level.ChunkEvent;
|
||||
import net.minecraftforge.event.network.ConnectionStartEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.listener.Priority;
|
||||
import net.minecraftforge.eventbus.api.listener.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.network.filters.NetworkFilters;
|
||||
import net.minecraftforge.common.util.LogicalSidedProvider;
|
||||
import net.minecraftforge.server.command.ForgeCommand;
|
||||
import net.minecraftforge.server.permission.events.PermissionGatherEvent;
|
||||
import net.minecraftforge.server.command.ConfigCommand;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public class ForgeInternalHandler {
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onEntityJoinWorld(EntityJoinLevelEvent event) {
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ForgeInternalHandler {
|
||||
static void register() {
|
||||
BusGroup.DEFAULT.register(MethodHandles.lookup(), ForgeInternalHandler.class);
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = Priority.HIGH)
|
||||
static boolean onEntityJoinWorld(EntityJoinLevelEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity.getClass().equals(ItemEntity.class)) {
|
||||
if (entity.getClass() == ItemEntity.class) {
|
||||
ItemStack stack = ((ItemEntity)entity).getItem();
|
||||
Item item = stack.getItem();
|
||||
if (item.hasCustomEntity(stack)) {
|
||||
Entity newEntity = item.createEntity(event.getLevel(), entity, stack);
|
||||
if (newEntity != null) {
|
||||
entity.discard();
|
||||
event.setCanceled(true);
|
||||
@SuppressWarnings("resource")
|
||||
var executor = LogicalSidedProvider.WORKQUEUE.get(event.getLevel().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER);
|
||||
executor.schedule(new TickTask(0, () -> event.getLevel().addFreshEntity(newEntity)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerTick(ServerTickEvent.Pre event) {
|
||||
static void onServerTick(ServerTickEvent.Pre event) {
|
||||
WorldWorkerManager.tick(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerTick(ServerTickEvent.Post event) {
|
||||
static void onServerTick(ServerTickEvent.Post event) {
|
||||
WorldWorkerManager.tick(false);
|
||||
}
|
||||
|
||||
// @SubscribeEvent
|
||||
// public void checkSettings(ClientTickEvent event) {
|
||||
// static void checkSettings(ClientTickEvent event) {
|
||||
// if (event.phase == Phase.END)
|
||||
// CloudRenderer.updateCloudSettings();
|
||||
// }
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkUnload(ChunkEvent.Unload event) {
|
||||
static void onChunkUnload(ChunkEvent.Unload event) {
|
||||
if (!event.getLevel().isClientSide())
|
||||
FarmlandWaterManager.removeTickets(event.getChunk());
|
||||
}
|
||||
|
||||
/*
|
||||
@SubscribeEvent
|
||||
public void playerChangeDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
static void playerChangeDimension(PlayerEvent.PlayerChangedDimensionEvent event) {
|
||||
if (event.getPlayer() instanceof ServerPlayerEntity)
|
||||
DimensionManager.rebuildPlayerMap(((ServerPlayerEntity)event.getPlayer()).server.getPlayerList(), true);
|
||||
}
|
||||
*/
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
static void playerLogin(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
UsernameCache.setUsername(event.getEntity().getUUID(), event.getEntity().getGameProfile().getName());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCommandsRegister(RegisterCommandsEvent event) {
|
||||
static void onCommandsRegister(RegisterCommandsEvent event) {
|
||||
new ForgeCommand(event.getDispatcher());
|
||||
ConfigCommand.register(event.getDispatcher());
|
||||
}
|
||||
@@ -93,7 +103,7 @@ public class ForgeInternalHandler {
|
||||
private static LootModifierManager INSTANCE;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onResourceReload(AddReloadListenerEvent event) {
|
||||
static void onResourceReload(AddReloadListenerEvent event) {
|
||||
INSTANCE = new LootModifierManager(event.getRegistries());
|
||||
event.addListener(INSTANCE);
|
||||
}
|
||||
@@ -105,30 +115,27 @@ public class ForgeInternalHandler {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void resourceReloadListeners(AddReloadListenerEvent event) {
|
||||
static void resourceReloadListeners(AddReloadListenerEvent event) {
|
||||
event.addListener(CreativeModeTabRegistry.getReloadListener());
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void builtinMobSpawnBlocker(EntityJoinLevelEvent event) {
|
||||
if(event.getEntity() instanceof Mob mob && mob.isSpawnCancelled())
|
||||
event.setCanceled(true);
|
||||
@SubscribeEvent(priority = Priority.HIGHEST)
|
||||
static boolean builtinMobSpawnBlocker(EntityJoinLevelEvent event) {
|
||||
return event.getEntity() instanceof Mob mob && mob.isSpawnCancelled();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConnectionStart(ConnectionStartEvent event) {
|
||||
static void onConnectionStart(ConnectionStartEvent event) {
|
||||
NetworkFilters.injectIfNecessary(event.getConnection());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStopping(ServerStoppingEvent evt) {
|
||||
static void serverStopping(ServerStoppingEvent evt) {
|
||||
WorldWorkerManager.clear();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerPermissionNodes(PermissionGatherEvent.Nodes event) {
|
||||
static void registerPermissionNodes(PermissionGatherEvent.Nodes event) {
|
||||
event.addNodes(ForgeMod.USE_SELECTORS_PERMISSION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.DetectedVersion;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BiomeColors;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfo;
|
||||
@@ -61,12 +61,14 @@ import net.minecraftforge.common.world.ForgeBiomeModifiers.RemoveSpawnsBiomeModi
|
||||
import net.minecraftforge.common.world.NoneBiomeModifier;
|
||||
import net.minecraftforge.common.world.NoneStructureModifier;
|
||||
import net.minecraftforge.common.world.StructureModifier;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.network.GatherLoginConfigurationTasksEvent;
|
||||
import net.minecraftforge.event.server.ServerAboutToStartEvent;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||
import net.minecraftforge.fml.*;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.*;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.*;
|
||||
@@ -381,33 +383,37 @@ public class ForgeMod {
|
||||
CrashReportCallables.registerCrashCallable("FML", ForgeVersion::getSpec);
|
||||
CrashReportCallables.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion());
|
||||
|
||||
final IEventBus modEventBus = context.getModEventBus();
|
||||
BusGroup modBusGroup = context.getModBusGroup();
|
||||
// Forge-provided datapack registries
|
||||
modEventBus.addListener((DataPackRegistryEvent.NewRegistry event) -> {
|
||||
DataPackRegistryEvent.NewRegistry.getBus(modBusGroup).addListener(event -> {
|
||||
event.dataPackRegistry(ForgeRegistries.Keys.BIOME_MODIFIERS, BiomeModifier.DIRECT_CODEC);
|
||||
event.dataPackRegistry(ForgeRegistries.Keys.STRUCTURE_MODIFIERS, StructureModifier.DIRECT_CODEC);
|
||||
});
|
||||
modEventBus.addListener(this::preInit);
|
||||
modEventBus.addListener(this::gatherData);
|
||||
modEventBus.addListener(this::registerFluids);
|
||||
modEventBus.addListener(this::registerVanillaDisplayContexts);
|
||||
modEventBus.addListener(this::onRegisterAttributes);
|
||||
ForgeDeferredRegistriesSetup.setup(modEventBus);
|
||||
FMLCommonSetupEvent.getBus(modBusGroup).addListener(ForgeMod::preInit);
|
||||
GatherDataEvent.getBus(modBusGroup).addListener(ForgeMod::gatherData);
|
||||
var registerEventBus = RegisterEvent.getBus(modBusGroup);
|
||||
registerEventBus.addListener(ForgeMod::registerFluids);
|
||||
registerEventBus.addListener(ForgeMod::registerVanillaDisplayContexts);
|
||||
EntityAttributeModificationEvent.getBus(modBusGroup).addListener(ForgeMod::onRegisterAttributes);
|
||||
ForgeDeferredRegistriesSetup.setup(modBusGroup);
|
||||
for (var reg : registries)
|
||||
reg.register(modEventBus);
|
||||
reg.register(modBusGroup);
|
||||
|
||||
context.registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec);
|
||||
context.registerConfig(ModConfig.Type.SERVER, ForgeConfig.serverSpec);
|
||||
context.registerConfig(ModConfig.Type.COMMON, ForgeConfig.commonSpec);
|
||||
modEventBus.register(ForgeConfig.class);
|
||||
if (ForgeConfig.LOGGER.isDebugEnabled()) {
|
||||
ModConfigEvent.Loading.getBus(modBusGroup).addListener(ForgeConfig::onLoad);
|
||||
ModConfigEvent.Reloading.getBus(modBusGroup).addListener(ForgeConfig::onFileChange);
|
||||
}
|
||||
|
||||
// Forge does not display problems when the remote is not matching.
|
||||
context.registerDisplayTest(IExtensionPoint.DisplayTest.IGNORE_ALL_VERSION);
|
||||
StartupMessageManager.addModMessage("Forge version "+ForgeVersion.getVersion());
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener(VillagerTradingManager::loadTrades);
|
||||
MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER);
|
||||
MinecraftForge.EVENT_BUS.register(new ForgeNetworkConfigurationHandler());
|
||||
ServerAboutToStartEvent.BUS.addListener(VillagerTradingManager::loadTrades);
|
||||
ForgeInternalHandler.register();
|
||||
GatherLoginConfigurationTasksEvent.BUS.addListener(ForgeNetworkConfigurationHandler::gatherInit);
|
||||
|
||||
ForgeRegistries.ITEMS.tags().addOptionalTagDefaults(Tags.Items.ENCHANTING_FUELS, Set.of(ForgeRegistries.ITEMS.getDelegateOrThrow(Items.LAPIS_LAZULI)));
|
||||
|
||||
@@ -416,21 +422,19 @@ public class ForgeMod {
|
||||
addAlias(ForgeRegistries.ATTRIBUTES, ResourceLocation.fromNamespaceAndPath("forge", "attack_range"), ResourceLocation.fromNamespaceAndPath("forge", "entity_reach"));
|
||||
}
|
||||
|
||||
public void preInit(FMLCommonSetupEvent evt) {
|
||||
private static void preInit(FMLCommonSetupEvent evt) {
|
||||
VersionChecker.startVersionCheck();
|
||||
//VanillaPacketSplitter.register();
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterAttributes(EntityAttributeModificationEvent event) {
|
||||
private static void onRegisterAttributes(EntityAttributeModificationEvent event) {
|
||||
for (var type : event.getTypes()) {
|
||||
event.add(type, ForgeMod.SWIM_SPEED.getHolder().get());
|
||||
event.add(type, ForgeMod.NAMETAG_DISTANCE.getHolder().get());
|
||||
}
|
||||
}
|
||||
|
||||
public void gatherData(GatherDataEvent event) {
|
||||
private static void gatherData(GatherDataEvent event) {
|
||||
DataGenerator gen = event.getGenerator();
|
||||
PackOutput packOutput = gen.getPackOutput();
|
||||
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
|
||||
@@ -439,13 +443,13 @@ public class ForgeMod {
|
||||
gen.addProvider(true, new PackMetadataGenerator(packOutput)
|
||||
.add(PackMetadataSection.TYPE, new PackMetadataSection(
|
||||
Component.translatable("pack.forge.description"),
|
||||
DetectedVersion.BUILT_IN.getPackVersion(PackType.SERVER_DATA),
|
||||
SharedConstants.getCurrentVersion().packVersion(PackType.SERVER_DATA),
|
||||
Optional.empty() //Arrays.stream(PackType.values()).collect(Collectors.toMap(Function.identity(), DetectedVersion.BUILT_IN::getPackVersion))
|
||||
))
|
||||
);
|
||||
ForgeBlockTagsProvider blockTags = new ForgeBlockTagsProvider(packOutput, lookupProvider, existingFileHelper);
|
||||
gen.addProvider(event.includeServer(), blockTags);
|
||||
gen.addProvider(event.includeServer(), new ForgeItemTagsProvider(packOutput, lookupProvider, blockTags.contentsGetter(), existingFileHelper));
|
||||
gen.addProvider(event.includeServer(), new ForgeItemTagsProvider(packOutput, lookupProvider, existingFileHelper));
|
||||
gen.addProvider(event.includeServer(), new ForgeEntityTypeTagsProvider(packOutput, lookupProvider, existingFileHelper));
|
||||
gen.addProvider(event.includeServer(), new ForgeFluidTagsProvider(packOutput, lookupProvider, existingFileHelper));
|
||||
gen.addProvider(event.includeServer(), new ForgeEnchantmentTagsProvider(packOutput, lookupProvider, existingFileHelper));
|
||||
@@ -459,7 +463,7 @@ public class ForgeMod {
|
||||
}
|
||||
|
||||
// done in an event instead of deferred to only enable if a mod requests it
|
||||
public void registerFluids(RegisterEvent event) {
|
||||
private static void registerFluids(RegisterEvent event) {
|
||||
if (enableMilkFluid) {
|
||||
// register milk fill, empty sounds (delegates to water fill, empty sounds)
|
||||
event.register(ForgeRegistries.Keys.SOUND_EVENTS, helper -> {
|
||||
@@ -503,7 +507,7 @@ public class ForgeMod {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerVanillaDisplayContexts(RegisterEvent event) {
|
||||
private static void registerVanillaDisplayContexts(RegisterEvent event) {
|
||||
if (event.getRegistryKey().equals(ForgeRegistries.Keys.DISPLAY_CONTEXTS)) {
|
||||
IForgeRegistryInternal<ItemDisplayContext> forgeRegistry = (IForgeRegistryInternal<ItemDisplayContext>) event.<ItemDisplayContext>getForgeRegistry();
|
||||
if (forgeRegistry == null)
|
||||
|
||||
@@ -10,8 +10,6 @@ import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
import net.minecraftforge.client.ConfigScreenHandler;
|
||||
import net.minecraftforge.eventbus.api.BusBuilder;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.config.IConfigSpec;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
@@ -34,9 +32,8 @@ public class MinecraftForge {
|
||||
* Events marked with {@link net.minecraftforge.fml.event.IModBusEvent}
|
||||
* belong on the ModBus and not this bus
|
||||
*/
|
||||
public static final IEventBus EVENT_BUS = BusBuilder.builder().startShutdown().useModLauncher().build();
|
||||
public static final EventBusMigrationHelper EVENT_BUS = EventBusMigrationHelper.INSTANCE;
|
||||
|
||||
static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker FORGE = MarkerManager.getMarker("FORGE");
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class TagConventionMigrationHelper {
|
||||
private static final ArrayList<TagKey<?>> FOUND_LEGACY_TAGS = new ArrayList<>();
|
||||
|
||||
static void init() {
|
||||
MinecraftForge.EVENT_BUS.addListener(TagConventionMigrationHelper::onServerStarting);
|
||||
ServerStartingEvent.BUS.addListener(TagConventionMigrationHelper::onServerStarting);
|
||||
}
|
||||
|
||||
public static void onServerStarting(ServerStartingEvent event) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class VillagerTradingManager {
|
||||
|
||||
/** Posts the WandererTradesEvent. */
|
||||
private static void postWandererEvent() {
|
||||
var event = MinecraftForge.EVENT_BUS.fire(new WandererTradesEvent(WANDERER_TRADES));
|
||||
var event = WandererTradesEvent.BUS.fire(new WandererTradesEvent(WANDERER_TRADES));
|
||||
VillagerTrades.WANDERING_TRADER_TRADES.clear();
|
||||
for (var pool : event.getPools())
|
||||
VillagerTrades.WANDERING_TRADER_TRADES.add(Pair.of(pool.getEntries().toArray(ItemListing[]::new), pool.getRolls()));
|
||||
@@ -65,7 +65,7 @@ public class VillagerTradingManager {
|
||||
for (var entry : trades.int2ObjectEntrySet())
|
||||
Arrays.stream(entry.getValue()).forEach(mutableTrades.get(entry.getIntKey())::add);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new VillagerTradesEvent(mutableTrades, prof));
|
||||
VillagerTradesEvent.BUS.post(new VillagerTradesEvent(mutableTrades, prof));
|
||||
Int2ObjectMap<ItemListing[]> newTrades = new Int2ObjectOpenHashMap<>();
|
||||
for (var entry : mutableTrades.int2ObjectEntrySet())
|
||||
newTrades.put(entry.getIntKey(), entry.getValue().toArray(new ItemListing[0]));
|
||||
|
||||
@@ -11,8 +11,13 @@ import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -26,22 +31,100 @@ public abstract class CapabilityProvider<B extends ICapabilityProviderImpl<B>> i
|
||||
@VisibleForTesting
|
||||
static boolean SUPPORTS_LAZY_CAPABILITIES = true;
|
||||
|
||||
private final @NotNull Class<B> baseClass;
|
||||
private @Nullable CapabilityDispatcher capabilities;
|
||||
private boolean valid = true;
|
||||
|
||||
private boolean isLazy = false;
|
||||
private final boolean isLazy;
|
||||
private Supplier<ICapabilityProvider> lazyParentSupplier = null;
|
||||
private CompoundTag lazyData = null;
|
||||
private HolderLookup.Provider registryAccess = null;
|
||||
private boolean initialized = false;
|
||||
|
||||
protected CapabilityProvider(Class<B> baseClass) {
|
||||
this(baseClass, false);
|
||||
public static class Entities extends CapabilityProvider<Entity> {
|
||||
protected Entities() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
protected Entities(boolean isLazy) {
|
||||
super(isLazy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AttachCapabilitiesEvent<Entity> fireAttachCapabilitiesEvent(Entity provider) {
|
||||
return AttachCapabilitiesEvent.Entities.BUS.fire(new AttachCapabilitiesEvent.Entities(provider));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldFireAttachCapabilitiesEvent() {
|
||||
return AttachCapabilitiesEvent.Entities.BUS.hasListeners();
|
||||
}
|
||||
}
|
||||
|
||||
protected CapabilityProvider(final Class<B> baseClass, final boolean isLazy) {
|
||||
this.baseClass = baseClass;
|
||||
public static class BlockEntities extends CapabilityProvider<BlockEntity> {
|
||||
protected BlockEntities() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
protected BlockEntities(boolean isLazy) {
|
||||
super(isLazy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AttachCapabilitiesEvent<BlockEntity> fireAttachCapabilitiesEvent(BlockEntity provider) {
|
||||
return AttachCapabilitiesEvent.BlockEntities.BUS.fire(new AttachCapabilitiesEvent.BlockEntities(provider));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldFireAttachCapabilitiesEvent() {
|
||||
return AttachCapabilitiesEvent.BlockEntities.BUS.hasListeners();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemStacks extends CapabilityProvider<ItemStack> {
|
||||
protected ItemStacks() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
protected ItemStacks(boolean isLazy) {
|
||||
super(isLazy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AttachCapabilitiesEvent<ItemStack> fireAttachCapabilitiesEvent(ItemStack provider) {
|
||||
return AttachCapabilitiesEvent.ItemStacks.BUS.fire(new AttachCapabilitiesEvent.ItemStacks(provider));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldFireAttachCapabilitiesEvent() {
|
||||
return AttachCapabilitiesEvent.ItemStacks.BUS.hasListeners();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Levels extends CapabilityProvider<Level> {
|
||||
protected Levels() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
protected Levels(boolean isLazy) {
|
||||
super(isLazy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AttachCapabilitiesEvent<Level> fireAttachCapabilitiesEvent(Level provider) {
|
||||
return AttachCapabilitiesEvent.Levels.BUS.fire(new AttachCapabilitiesEvent.Levels(provider));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldFireAttachCapabilitiesEvent() {
|
||||
return AttachCapabilitiesEvent.Levels.BUS.hasListeners();
|
||||
}
|
||||
}
|
||||
|
||||
protected CapabilityProvider() {
|
||||
this.isLazy = false;
|
||||
}
|
||||
|
||||
protected CapabilityProvider(boolean isLazy) {
|
||||
this.isLazy = SUPPORTS_LAZY_CAPABILITIES && isLazy;
|
||||
}
|
||||
|
||||
@@ -50,10 +133,20 @@ public abstract class CapabilityProvider<B extends ICapabilityProviderImpl<B>> i
|
||||
}
|
||||
|
||||
protected final void gatherCapabilities(@Nullable ICapabilityProvider parent) {
|
||||
if (!shouldFireAttachCapabilitiesEvent()) {
|
||||
this.initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
gatherCapabilities(() -> parent);
|
||||
}
|
||||
|
||||
protected final void gatherCapabilities(@Nullable Supplier<ICapabilityProvider> parent) {
|
||||
if (!shouldFireAttachCapabilitiesEvent()) {
|
||||
this.initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isLazy && !initialized) {
|
||||
lazyParentSupplier = parent == null ? () -> null : parent;
|
||||
return;
|
||||
@@ -62,8 +155,11 @@ public abstract class CapabilityProvider<B extends ICapabilityProviderImpl<B>> i
|
||||
doGatherCapabilities(parent == null ? null : parent.get());
|
||||
}
|
||||
|
||||
protected abstract AttachCapabilitiesEvent<?> fireAttachCapabilitiesEvent(B provider);
|
||||
protected abstract boolean shouldFireAttachCapabilitiesEvent();
|
||||
|
||||
private void doGatherCapabilities(@Nullable ICapabilityProvider parent) {
|
||||
this.capabilities = ForgeEventFactory.gatherCapabilities(baseClass, getProvider(), parent);
|
||||
this.capabilities = ForgeEventFactory.gatherCapabilities(fireAttachCapabilitiesEvent(getProvider()), parent);
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
@@ -144,16 +240,16 @@ public abstract class CapabilityProvider<B extends ICapabilityProviderImpl<B>> i
|
||||
* Special implementation for cases which have a superclass and can't extend CapabilityProvider directly.
|
||||
* See {@link LevelChunk}
|
||||
*/
|
||||
public static class AsField<B extends ICapabilityProviderImpl<B>> extends CapabilityProvider<B> {
|
||||
public static abstract class AsField<B extends ICapabilityProviderImpl<B>> extends CapabilityProvider<B> {
|
||||
private final B owner;
|
||||
|
||||
public AsField(Class<B> baseClass, B owner) {
|
||||
super(baseClass);
|
||||
public AsField(B owner) {
|
||||
super();
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public AsField(Class<B> baseClass, B owner, boolean isLazy) {
|
||||
super(baseClass, isLazy);
|
||||
public AsField(B owner, boolean isLazy) {
|
||||
super(isLazy);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@@ -175,6 +271,26 @@ public abstract class CapabilityProvider<B extends ICapabilityProviderImpl<B>> i
|
||||
B getProvider() {
|
||||
return owner;
|
||||
}
|
||||
};
|
||||
|
||||
public static class LevelChunks extends AsField<LevelChunk> {
|
||||
public LevelChunks(LevelChunk owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
public LevelChunks(LevelChunk owner, boolean isLazy) {
|
||||
super(owner, isLazy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AttachCapabilitiesEvent<LevelChunk> fireAttachCapabilitiesEvent(LevelChunk provider) {
|
||||
return AttachCapabilitiesEvent.LevelChunks.BUS.fire(new AttachCapabilitiesEvent.LevelChunks(provider));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldFireAttachCapabilitiesEvent() {
|
||||
return AttachCapabilitiesEvent.LevelChunks.BUS.hasListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,8 +10,7 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ICapabilityProvider
|
||||
{
|
||||
public interface ICapabilityProvider {
|
||||
/**
|
||||
* Retrieves the Optional handler for the capability requested on the specific side.
|
||||
* The return value <strong>CAN</strong> be the same for multiple faces.
|
||||
|
||||
@@ -7,9 +7,10 @@ package net.minecraftforge.common.capabilities;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,11 @@ import net.minecraftforge.fml.event.IModBusEvent;
|
||||
* @deprecated Use {@link AutoRegisterCapability} annotation on your class.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21")
|
||||
public final class RegisterCapabilitiesEvent extends Event implements IModBusEvent {
|
||||
public final class RegisterCapabilitiesEvent implements IModBusEvent {
|
||||
public static EventBus<RegisterCapabilitiesEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, RegisterCapabilitiesEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a capability to be consumed by others.
|
||||
* APIs who define the capability should call this.
|
||||
@@ -32,4 +37,4 @@ public final class RegisterCapabilitiesEvent extends Event implements IModBusEve
|
||||
Objects.requireNonNull(type, "Attempted to register a capability with invalid type");
|
||||
CapabilityManager.get(Type.getInternalName(type), null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,9 @@ import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class BlockTagsProvider extends IntrinsicHolderTagsProvider<Block>
|
||||
{
|
||||
public abstract class BlockTagsProvider extends IntrinsicHolderTagsProvider<Block> {
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, String modId, @Nullable ExistingFileHelper existingFileHelper)
|
||||
{
|
||||
public BlockTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, String modId, @Nullable ExistingFileHelper existingFileHelper) {
|
||||
super(output, Registries.BLOCK, lookupProvider, block -> block.builtInRegistryHolder().key(), modId, existingFileHelper);
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,15 @@
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.tags.TagsProvider;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class EnchantmentTagsProvider extends TagsProvider<Enchantment> {
|
||||
/** Use {@link net.minecraft.data.tags.EnchantmentTagsProvider Vanilla's EnchantmentTagsProvider} */
|
||||
@Deprecated(forRemoval = true, since = "1.21.6")
|
||||
public abstract class EnchantmentTagsProvider extends net.minecraft.data.tags.EnchantmentTagsProvider {
|
||||
public EnchantmentTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, String modId, @Nullable ExistingFileHelper existingFileHelper) {
|
||||
super(output, Registries.ENCHANTMENT, lookupProvider, modId, existingFileHelper);
|
||||
super(output, lookupProvider, modId, existingFileHelper);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
.add(Biomes.BASALT_DELTAS)
|
||||
.addOptionalTag(forgeTagKey("is_hot/nether"));
|
||||
tag(IS_HOT_END); // forge:is_hot/end
|
||||
tag(IS_HOT).addTag(IS_HOT_OVERWORLD).addTag(IS_HOT_NETHER).addOptionalTag(IS_HOT_END.location());
|
||||
tag(IS_HOT).addTag(IS_HOT_OVERWORLD).addTag(IS_HOT_NETHER).addOptionalTag(IS_HOT_END);
|
||||
|
||||
tag(IS_COLD_OVERWORLD)
|
||||
.add(Biomes.TAIGA)
|
||||
@@ -94,7 +94,7 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
.add(Biomes.END_HIGHLANDS)
|
||||
.add(Biomes.END_BARRENS)
|
||||
.addOptionalTag(forgeTagKey("is_cold/end"));
|
||||
tag(IS_COLD).addTag(IS_COLD_OVERWORLD).addOptionalTag(IS_COLD_NETHER.location()).addTag(IS_COLD_END);
|
||||
tag(IS_COLD).addTag(IS_COLD_OVERWORLD).addOptionalTag(IS_COLD_NETHER).addTag(IS_COLD_END);
|
||||
|
||||
tag(IS_DEAD)
|
||||
.addOptionalTag(forgeTagKey("is_dead"));
|
||||
@@ -114,7 +114,7 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
//.addOptionalTag(forgeTagKey("is_sparse/overworld")); // can't because forge:is_sparse/overworld contains dripstone caves and eroded badlands, while c:is_sparse_vegetation/overworld does not
|
||||
tag(IS_SPARSE_NETHER); // forge:is_sparse/nether
|
||||
tag(IS_SPARSE_END); // forge:is_sparse/end
|
||||
tag(IS_SPARSE_VEGETATION).addTag(IS_SPARSE_VEGETATION_OVERWORLD).addOptionalTag(IS_SPARSE_NETHER.location()).addOptionalTag(IS_SPARSE_END.location());
|
||||
tag(IS_SPARSE_VEGETATION).addTag(IS_SPARSE_VEGETATION_OVERWORLD).addOptionalTag(IS_SPARSE_NETHER).addOptionalTag(IS_SPARSE_END);
|
||||
|
||||
tag(IS_DENSE_VEGETATION_OVERWORLD)
|
||||
.add(Biomes.DARK_FOREST)
|
||||
@@ -126,7 +126,7 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
.addOptionalTag(forgeTagKey("is_dense/overworld"));
|
||||
tag(IS_DENSE_NETHER);
|
||||
tag(IS_DENSE_END);
|
||||
tag(IS_DENSE_VEGETATION).addTag(IS_DENSE_VEGETATION_OVERWORLD).addOptionalTag(IS_DENSE_NETHER.location()).addOptionalTag(IS_DENSE_END.location());
|
||||
tag(IS_DENSE_VEGETATION).addTag(IS_DENSE_VEGETATION_OVERWORLD).addOptionalTag(IS_DENSE_NETHER).addOptionalTag(IS_DENSE_END);
|
||||
|
||||
tag(IS_WET_OVERWORLD)
|
||||
.add(Biomes.SWAMP)
|
||||
@@ -140,7 +140,7 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
.addOptionalTag(forgeTagKey("is_wet/overworld"));
|
||||
tag(IS_WET_NETHER);
|
||||
tag(IS_WET_END);
|
||||
tag(IS_WET).addTag(IS_WET_OVERWORLD).addOptionalTag(IS_WET_NETHER.location()).addOptionalTag(IS_WET_END.location());
|
||||
tag(IS_WET).addTag(IS_WET_OVERWORLD).addOptionalTag(IS_WET_NETHER).addOptionalTag(IS_WET_END);
|
||||
|
||||
tag(IS_DRY_OVERWORLD)
|
||||
.add(Biomes.DESERT)
|
||||
@@ -201,7 +201,14 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
tag(IS_SAVANNA).addTag(BiomeTags.IS_SAVANNA);
|
||||
tag(IS_JUNGLE).addTag(BiomeTags.IS_JUNGLE);
|
||||
tag(IS_SNOWY)
|
||||
.add(Biomes.SNOWY_BEACH, Biomes.SNOWY_PLAINS, Biomes.ICE_SPIKES, Biomes.SNOWY_TAIGA, Biomes.GROVE, Biomes.SNOWY_SLOPES, Biomes.JAGGED_PEAKS, Biomes.FROZEN_PEAKS);
|
||||
.add(Biomes.SNOWY_BEACH)
|
||||
.add(Biomes.SNOWY_PLAINS)
|
||||
.add(Biomes.ICE_SPIKES)
|
||||
.add(Biomes.SNOWY_TAIGA)
|
||||
.add(Biomes.GROVE)
|
||||
.add(Biomes.SNOWY_SLOPES)
|
||||
.add(Biomes.JAGGED_PEAKS)
|
||||
.add(Biomes.FROZEN_PEAKS);
|
||||
//.addOptionalTag(forgeTagKey("is_snowy")); // can't add forge:is_snowy because it contains frozen ocean and frozen river, while c:is_snowy does not
|
||||
tag(IS_ICY).add(Biomes.ICE_SPIKES).add(Biomes.FROZEN_PEAKS);
|
||||
tag(IS_SWAMP).add(Biomes.SWAMP).add(Biomes.MANGROVE_SWAMP);
|
||||
@@ -288,11 +295,11 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
tag(Biomes.MANGROVE_SWAMP, forgeTagKey("is_wet/overworld"), forgeTagKey("is_hot/overworld"), forgeTagKey("is_swamp"));
|
||||
tag(Biomes.DEEP_DARK, forgeTagKey("is_cave"), forgeTagKey("is_rare"), forgeTagKey("is_spooky"));
|
||||
|
||||
tag(forgeTagKey("is_hot")).addTag(forgeTagKey("is_hot/overworld")).addTag(forgeTagKey("is_hot/nether")).addOptionalTag(Tags.Biomes.IS_HOT_END.location());
|
||||
tag(forgeTagKey("is_cold")).addTag(forgeTagKey("is_cold/overworld")).addOptionalTag(Tags.Biomes.IS_COLD_NETHER.location()).addTag(forgeTagKey("is_cold/end"));
|
||||
tag(forgeTagKey("is_sparse")).addTag(forgeTagKey("is_sparse/overworld")).addOptionalTag(Tags.Biomes.IS_SPARSE_NETHER.location()).addOptionalTag(Tags.Biomes.IS_SPARSE_END.location());
|
||||
tag(forgeTagKey("is_dense")).addTag(forgeTagKey("is_dense/overworld")).addOptionalTag(Tags.Biomes.IS_DENSE_NETHER.location()).addOptionalTag(Tags.Biomes.IS_DENSE_END.location());
|
||||
tag(forgeTagKey("is_wet")).addTag(forgeTagKey("is_wet/overworld")).addOptionalTag(Tags.Biomes.IS_WET_NETHER.location()).addOptionalTag(Tags.Biomes.IS_WET_END.location());
|
||||
tag(forgeTagKey("is_hot")).addTag(forgeTagKey("is_hot/overworld")).addTag(forgeTagKey("is_hot/nether")).addOptionalTag(Tags.Biomes.IS_HOT_END);
|
||||
tag(forgeTagKey("is_cold")).addTag(forgeTagKey("is_cold/overworld")).addOptionalTag(Tags.Biomes.IS_COLD_NETHER).addTag(forgeTagKey("is_cold/end"));
|
||||
tag(forgeTagKey("is_sparse")).addTag(forgeTagKey("is_sparse/overworld")).addOptionalTag(Tags.Biomes.IS_SPARSE_NETHER).addOptionalTag(Tags.Biomes.IS_SPARSE_END);
|
||||
tag(forgeTagKey("is_dense")).addTag(forgeTagKey("is_dense/overworld")).addOptionalTag(Tags.Biomes.IS_DENSE_NETHER).addOptionalTag(Tags.Biomes.IS_DENSE_END);
|
||||
tag(forgeTagKey("is_wet")).addTag(forgeTagKey("is_wet/overworld")).addOptionalTag(Tags.Biomes.IS_WET_NETHER).addOptionalTag(Tags.Biomes.IS_WET_END);
|
||||
tag(forgeTagKey("is_dry")).addTag(forgeTagKey("is_dry/overworld")).addTag(forgeTagKey("is_dry/nether")).addTag(forgeTagKey("is_dry/end"));
|
||||
tag(forgeTagKey("is_dead"));
|
||||
|
||||
@@ -308,14 +315,6 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private TagAppender<Biome> tagWithOptionalLegacy(TagKey<Biome> tag) {
|
||||
return tag(tag).addOptionalTag(ResourceLocation.fromNamespaceAndPath("forge", tag.location().getPath()));
|
||||
}
|
||||
|
||||
private static ResourceLocation forgeRl(String path) {
|
||||
return ResourceLocation.fromNamespaceAndPath("forge", path);
|
||||
}
|
||||
|
||||
private static TagKey<Biome> forgeTagKey(String path) {
|
||||
return BiomeTags.create(ResourceLocation.fromNamespaceAndPath("forge", path));
|
||||
}
|
||||
@@ -324,4 +323,5 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
|
||||
public String getName() {
|
||||
return "Forge Biome Tags";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,842 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.data.tags.BlockItemTagsProvider;
|
||||
import net.minecraft.data.tags.TagAppender;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "removal" })
|
||||
protected void run() {
|
||||
tag(Tags.Blocks.BARRELS, Tags.Items.BARRELS)
|
||||
.addTag(Tags.Blocks.BARRELS_WOODEN)
|
||||
.addOptionalTag(Legacy.Blocks.BARRELS);
|
||||
tag(Tags.Blocks.BARRELS_WOODEN, Tags.Items.BARRELS_WOODEN, Legacy.Blocks.BARRELS_WOODEN, Legacy.Items.BARRELS_WOODEN)
|
||||
.add(Blocks.BARREL)
|
||||
.addOptionalTag(Legacy.Blocks.BARRELS_WOODEN);
|
||||
tag(Tags.Blocks.BOOKSHELVES, Tags.Items.BOOKSHELVES, Legacy.Blocks.BOOKSHELVES, Legacy.Items.BOOKSHELVES)
|
||||
.add(Blocks.BOOKSHELF)
|
||||
.addOptionalTag(Legacy.Blocks.BOOKSHELVES);
|
||||
tag(Tags.Blocks.BUDDING_BLOCKS, Tags.Items.BUDDING_BLOCKS)
|
||||
.add(Blocks.BUDDING_AMETHYST);
|
||||
tag(Tags.Blocks.BUDS, Tags.Items.BUDS)
|
||||
.add(Blocks.SMALL_AMETHYST_BUD)
|
||||
.add(Blocks.MEDIUM_AMETHYST_BUD)
|
||||
.add(Blocks.LARGE_AMETHYST_BUD);
|
||||
tag(Tags.Blocks.CHAINS, Tags.Items.CHAINS)
|
||||
.add(Blocks.CHAIN);
|
||||
tag(Tags.Blocks.CHESTS, Tags.Items.CHESTS)
|
||||
.addTags(
|
||||
Tags.Blocks.CHESTS_ENDER,
|
||||
Tags.Blocks.CHESTS_TRAPPED,
|
||||
Tags.Blocks.CHESTS_WOODEN
|
||||
)
|
||||
.addOptionalTag(Legacy.Blocks.CHESTS);
|
||||
//copy(forgeBlockTagKey("chests/ender"), forgeItemTagKey("chests/ender"));
|
||||
tag(Tags.Blocks.CHESTS_ENDER, Tags.Items.CHESTS_ENDER)
|
||||
.add(Blocks.ENDER_CHEST); // forge:chests/ender
|
||||
//copy(forgeBlockTagKey("chests/trapped"), forgeItemTagKey("chests/trapped")));
|
||||
tag(Tags.Blocks.CHESTS_TRAPPED, Tags.Items.CHESTS_TRAPPED)
|
||||
.add(Blocks.TRAPPED_CHEST); // forge:chests/trapped
|
||||
tag(Tags.Blocks.CHESTS_WOODEN, Tags.Items.CHESTS_WOODEN, Legacy.Blocks.CHESTS_WOODEN, Legacy.Items.CHESTS_WOODEN)
|
||||
.add(
|
||||
Blocks.CHEST,
|
||||
Blocks.TRAPPED_CHEST
|
||||
)
|
||||
.addOptionalTag(Legacy.Blocks.CHESTS_WOODEN);
|
||||
tag(Tags.Blocks.CLUSTERS, Tags.Items.CLUSTERS)
|
||||
.add(Blocks.AMETHYST_CLUSTER);
|
||||
tag(Tags.Blocks.COBBLESTONES, Tags.Items.COBBLESTONES, Legacy.Blocks.COBBLESTONE, Legacy.Items.COBBLESTONE)
|
||||
.addTags(
|
||||
Tags.Blocks.COBBLESTONE_NORMAL,
|
||||
Tags.Blocks.COBBLESTONE_INFESTED,
|
||||
Tags.Blocks.COBBLESTONE_MOSSY,
|
||||
Tags.Blocks.COBBLESTONE_DEEPSLATE
|
||||
)
|
||||
.addOptionalTag(Legacy.Blocks.COBBLESTONE);
|
||||
//copy(forgeBlockTagKey("cobblestone/normal"), forgeItemTagKey("cobblestone/normal"));
|
||||
tag(Tags.Blocks.COBBLESTONE_NORMAL, Tags.Items.COBBLESTONE_NORMAL)
|
||||
.add(Blocks.COBBLESTONE); // forge:cobblestone/normal
|
||||
//copy(forgeBlockTagKey("cobblestone/infested"), forgeItemTagKey("cobblestone/infested"));
|
||||
tag(Tags.Blocks.COBBLESTONE_INFESTED, Tags.Items.COBBLESTONE_INFESTED)
|
||||
.add(Blocks.INFESTED_COBBLESTONE); // forge:cobblestone/infested
|
||||
//copy(forgeBlockTagKey("cobblestone/mossy"), forgeItemTagKey("cobblestone/mossy"));
|
||||
tag(Tags.Blocks.COBBLESTONE_MOSSY, Tags.Items.COBBLESTONE_MOSSY)
|
||||
.add(Blocks.MOSSY_COBBLESTONE); // forge:cobblestone/mossy
|
||||
//copy(forgeBlockTagKey("cobblestone/deepslate"), forgeItemTagKey("cobblestone/deepslate"));
|
||||
tag(Tags.Blocks.COBBLESTONE_DEEPSLATE, Tags.Items.COBBLESTONE_DEEPSLATE)
|
||||
.add(Blocks.COBBLED_DEEPSLATE); // forge:cobblestone/deepslate
|
||||
tag(Tags.Blocks.CONCRETES, Tags.Items.CONCRETES)
|
||||
.add(
|
||||
Blocks.WHITE_CONCRETE,
|
||||
Blocks.ORANGE_CONCRETE,
|
||||
Blocks.MAGENTA_CONCRETE,
|
||||
Blocks.LIGHT_BLUE_CONCRETE,
|
||||
Blocks.YELLOW_CONCRETE,
|
||||
Blocks.LIME_CONCRETE,
|
||||
Blocks.PINK_CONCRETE,
|
||||
Blocks.GRAY_CONCRETE,
|
||||
Blocks.LIGHT_GRAY_CONCRETE,
|
||||
Blocks.CYAN_CONCRETE,
|
||||
Blocks.PURPLE_CONCRETE,
|
||||
Blocks.BLUE_CONCRETE,
|
||||
Blocks.BROWN_CONCRETE,
|
||||
Blocks.GREEN_CONCRETE,
|
||||
Blocks.RED_CONCRETE,
|
||||
Blocks.BLACK_CONCRETE
|
||||
);
|
||||
//copy(forgeBlockTagKey("end_stones"), forgeItemTagKey("end_stones"));
|
||||
tag(Tags.Blocks.END_STONES, Tags.Items.END_STONES)
|
||||
.add(Blocks.END_STONE); // forge:end_stones
|
||||
//copy(forgeBlockTagKey("fence_gates"), forgeItemTagKey("fence_gates"));
|
||||
tag(Tags.Blocks.FENCE_GATES, Tags.Items.FENCE_GATES)
|
||||
.addTags(Tags.Blocks.FENCE_GATES_WOODEN); // forge:fence_gates
|
||||
//copy(forgeBlockTagKey("fence_gates/wooden"), forgeItemTagKey("fence_gates/wooden"));
|
||||
tag(Tags.Blocks.FENCE_GATES_WOODEN, Tags.Items.FENCE_GATES_WOODEN)
|
||||
.add(
|
||||
Blocks.OAK_FENCE_GATE,
|
||||
Blocks.SPRUCE_FENCE_GATE,
|
||||
Blocks.BIRCH_FENCE_GATE,
|
||||
Blocks.JUNGLE_FENCE_GATE,
|
||||
Blocks.ACACIA_FENCE_GATE,
|
||||
Blocks.DARK_OAK_FENCE_GATE,
|
||||
Blocks.CRIMSON_FENCE_GATE,
|
||||
Blocks.WARPED_FENCE_GATE,
|
||||
Blocks.MANGROVE_FENCE_GATE,
|
||||
Blocks.BAMBOO_FENCE_GATE,
|
||||
Blocks.CHERRY_FENCE_GATE
|
||||
);
|
||||
//copy(forgeBlockTagKey("fences"), forgeItemTagKey("fences"));
|
||||
tag(Tags.Blocks.FENCES, Tags.Items.FENCES)
|
||||
.addTags(
|
||||
Tags.Blocks.FENCES_NETHER_BRICK,
|
||||
Tags.Blocks.FENCES_WOODEN
|
||||
); // forge:fences
|
||||
//copy(forgeBlockTagKey("fences/nether_brick"), forgeItemTagKey("fences/nether_brick"));
|
||||
tag(Tags.Blocks.FENCES_NETHER_BRICK, Tags.Items.FENCES_NETHER_BRICK)
|
||||
.add(Blocks.NETHER_BRICK_FENCE); // forge:fences/nether_brick
|
||||
//copy(forgeBlockTagKey("fences/wooden"), forgeItemTagKey("fences/wooden"));
|
||||
tag(Tags.Blocks.FENCES_WOODEN, Tags.Items.FENCES_WOODEN)
|
||||
.addTag(BlockTags.WOODEN_FENCES); // forge:fences/wooden
|
||||
tag(Tags.Blocks.FLOWERS_SMALL, Tags.Items.FLOWERS_SMALL)
|
||||
.add(
|
||||
Blocks.DANDELION,
|
||||
Blocks.POPPY,
|
||||
Blocks.BLUE_ORCHID,
|
||||
Blocks.ALLIUM,
|
||||
Blocks.AZURE_BLUET,
|
||||
Blocks.RED_TULIP,
|
||||
Blocks.ORANGE_TULIP,
|
||||
Blocks.WHITE_TULIP,
|
||||
Blocks.PINK_TULIP,
|
||||
Blocks.OXEYE_DAISY,
|
||||
Blocks.CORNFLOWER,
|
||||
Blocks.LILY_OF_THE_VALLEY,
|
||||
Blocks.WITHER_ROSE,
|
||||
Blocks.TORCHFLOWER,
|
||||
Blocks.OPEN_EYEBLOSSOM,
|
||||
Blocks.CLOSED_EYEBLOSSOM
|
||||
)
|
||||
.addOptionalTag(BlockTags.SMALL_FLOWERS);
|
||||
tag(Tags.Blocks.FLOWERS_TALL, Tags.Items.FLOWERS_TALL)
|
||||
.add(
|
||||
Blocks.SUNFLOWER,
|
||||
Blocks.LILAC,
|
||||
Blocks.PEONY,
|
||||
Blocks.ROSE_BUSH,
|
||||
Blocks.PITCHER_PLANT
|
||||
)
|
||||
.addOptionalTag(tagKey("tall_flowers")); //This is old vanilla tag, should it be removed?
|
||||
tag(Tags.Blocks.FLOWERS, Tags.Items.FLOWERS)
|
||||
.add(
|
||||
Blocks.FLOWERING_AZALEA_LEAVES,
|
||||
Blocks.FLOWERING_AZALEA,
|
||||
Blocks.MANGROVE_PROPAGULE,
|
||||
Blocks.PINK_PETALS,
|
||||
Blocks.CHORUS_FLOWER,
|
||||
Blocks.SPORE_BLOSSOM
|
||||
)
|
||||
.addTags(
|
||||
Tags.Blocks.FLOWERS_SMALL,
|
||||
Tags.Blocks.FLOWERS_TALL
|
||||
)
|
||||
.addOptionalTag(BlockTags.FLOWERS);
|
||||
tag(Tags.Blocks.GLASS_BLOCKS, Tags.Items.GLASS_BLOCKS)
|
||||
.addTags(
|
||||
Tags.Blocks.GLASS_BLOCKS_COLORLESS,
|
||||
Tags.Blocks.GLASS_BLOCKS_CHEAP,
|
||||
Tags.Blocks.GLASS_BLOCKS_TINTED
|
||||
)
|
||||
.addOptionalTag(Tags.Blocks.GLASS);
|
||||
tag(Tags.Blocks.GLASS_BLOCKS_COLORLESS, Tags.Items.GLASS_BLOCKS_COLORLESS)
|
||||
.add(Blocks.GLASS)
|
||||
.addOptionalTag(Tags.Blocks.GLASS_COLORLESS);
|
||||
tag(Tags.Blocks.GLASS_BLOCKS_TINTED, Tags.Items.GLASS_BLOCKS_TINTED)
|
||||
.add(Blocks.TINTED_GLASS)
|
||||
.addOptionalTag(Legacy.Blocks.GLASS_TINTED);
|
||||
|
||||
tag(Tags.Blocks.GLASS_BLOCKS_CHEAP, Tags.Items.GLASS_BLOCKS_CHEAP, Legacy.Blocks.GLASS_SILICA, Legacy.Items.GLASS_SILICA)
|
||||
.add(
|
||||
Blocks.GLASS,
|
||||
Blocks.WHITE_STAINED_GLASS,
|
||||
Blocks.ORANGE_STAINED_GLASS,
|
||||
Blocks.MAGENTA_STAINED_GLASS,
|
||||
Blocks.LIGHT_BLUE_STAINED_GLASS,
|
||||
Blocks.YELLOW_STAINED_GLASS,
|
||||
Blocks.LIME_STAINED_GLASS,
|
||||
Blocks.PINK_STAINED_GLASS,
|
||||
Blocks.GRAY_STAINED_GLASS,
|
||||
Blocks.LIGHT_GRAY_STAINED_GLASS,
|
||||
Blocks.CYAN_STAINED_GLASS,
|
||||
Blocks.PURPLE_STAINED_GLASS,
|
||||
Blocks.BLUE_STAINED_GLASS,
|
||||
Blocks.BROWN_STAINED_GLASS,
|
||||
Blocks.GREEN_STAINED_GLASS,
|
||||
Blocks.RED_STAINED_GLASS,
|
||||
Blocks.BLACK_STAINED_GLASS
|
||||
)
|
||||
.addOptionalTag(Legacy.Blocks.GLASS_SILICA);
|
||||
tag(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES)
|
||||
.addTags(Tags.Blocks.GLASS_PANES_COLORLESS)
|
||||
.add(
|
||||
Blocks.WHITE_STAINED_GLASS_PANE,
|
||||
Blocks.ORANGE_STAINED_GLASS_PANE,
|
||||
Blocks.MAGENTA_STAINED_GLASS_PANE,
|
||||
Blocks.LIGHT_BLUE_STAINED_GLASS_PANE,
|
||||
Blocks.YELLOW_STAINED_GLASS_PANE,
|
||||
Blocks.LIME_STAINED_GLASS_PANE,
|
||||
Blocks.PINK_STAINED_GLASS_PANE,
|
||||
Blocks.GRAY_STAINED_GLASS_PANE,
|
||||
Blocks.LIGHT_GRAY_STAINED_GLASS_PANE,
|
||||
Blocks.CYAN_STAINED_GLASS_PANE,
|
||||
Blocks.PURPLE_STAINED_GLASS_PANE,
|
||||
Blocks.BLUE_STAINED_GLASS_PANE,
|
||||
Blocks.BROWN_STAINED_GLASS_PANE,
|
||||
Blocks.GREEN_STAINED_GLASS_PANE,
|
||||
Blocks.RED_STAINED_GLASS_PANE,
|
||||
Blocks.BLACK_STAINED_GLASS_PANE
|
||||
)
|
||||
.addOptionalTag(Legacy.Blocks.GLASS_PANES);
|
||||
tag(Tags.Blocks.GLASS_PANES_COLORLESS, Tags.Items.GLASS_PANES_COLORLESS)
|
||||
.add(Blocks.GLASS_PANE)
|
||||
.addOptionalTag(forgeTagKey("glass_panes/colorless"));
|
||||
tag(Tags.Blocks.GLAZED_TERRACOTTAS, Tags.Items.GLAZED_TERRACOTTAS)
|
||||
.add(
|
||||
Blocks.WHITE_GLAZED_TERRACOTTA,
|
||||
Blocks.ORANGE_GLAZED_TERRACOTTA,
|
||||
Blocks.MAGENTA_GLAZED_TERRACOTTA,
|
||||
Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA,
|
||||
Blocks.YELLOW_GLAZED_TERRACOTTA,
|
||||
Blocks.LIME_GLAZED_TERRACOTTA,
|
||||
Blocks.PINK_GLAZED_TERRACOTTA,
|
||||
Blocks.GRAY_GLAZED_TERRACOTTA,
|
||||
Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA,
|
||||
Blocks.CYAN_GLAZED_TERRACOTTA,
|
||||
Blocks.PURPLE_GLAZED_TERRACOTTA,
|
||||
Blocks.BLUE_GLAZED_TERRACOTTA,
|
||||
Blocks.BROWN_GLAZED_TERRACOTTA,
|
||||
Blocks.GREEN_GLAZED_TERRACOTTA,
|
||||
Blocks.RED_GLAZED_TERRACOTTA,
|
||||
Blocks.BLACK_GLAZED_TERRACOTTA
|
||||
);
|
||||
//copy(forgeBlockTagKey("gravel"), forgeItemTagKey("gravel"));
|
||||
tag(Tags.Blocks.GRAVEL, Tags.Items.GRAVEL)
|
||||
.add(Blocks.GRAVEL); // forge:gravel
|
||||
//copy(forgeBlockTagKey("netherrack"), forgeItemTagKey("netherrack"));
|
||||
tag(Tags.Blocks.NETHERRACK, Tags.Items.NETHERRACK)
|
||||
.add(Blocks.NETHERRACK); // forge:netherrack
|
||||
tag(Tags.Blocks.OBSIDIANS, Tags.Items.OBSIDIANS)
|
||||
.addTags(
|
||||
Tags.Blocks.OBSIDIANS_NORMAL,
|
||||
Tags.Blocks.OBSIDIANS_CRYING
|
||||
)
|
||||
.addOptionalTag(Legacy.Blocks.OBSIDIAN);
|
||||
tag(Tags.Blocks.OBSIDIANS_NORMAL, Tags.Items.OBSIDIANS_NORMAL)
|
||||
.add(Blocks.OBSIDIAN);
|
||||
tag(Tags.Blocks.OBSIDIANS_CRYING, Tags.Items.OBSIDIANS_CRYING)
|
||||
.add(Blocks.CRYING_OBSIDIAN);
|
||||
tag(Tags.Blocks.ORE_BEARING_GROUND_DEEPSLATE, Tags.Items.ORE_BEARING_GROUND_DEEPSLATE)
|
||||
.add(Blocks.DEEPSLATE); // forge:ore_bearing_ground/deepslate
|
||||
tag(Tags.Blocks.ORE_BEARING_GROUND_NETHERRACK, Tags.Items.ORE_BEARING_GROUND_NETHERRACK)
|
||||
.add(Blocks.NETHERRACK); // forge:ore_bearing_ground/netherrack
|
||||
tag(Tags.Blocks.ORE_BEARING_GROUND_STONE, Tags.Items.ORE_BEARING_GROUND_STONE)
|
||||
.add(Blocks.STONE); // forge:ore_bearing_ground/stone
|
||||
tag(Tags.Blocks.ORE_RATES_DENSE, Tags.Items.ORE_RATES_DENSE)
|
||||
.add(
|
||||
Blocks.COPPER_ORE,
|
||||
Blocks.DEEPSLATE_COPPER_ORE,
|
||||
Blocks.DEEPSLATE_LAPIS_ORE,
|
||||
Blocks.DEEPSLATE_REDSTONE_ORE,
|
||||
Blocks.LAPIS_ORE,
|
||||
Blocks.REDSTONE_ORE
|
||||
);
|
||||
tag(Tags.Blocks.ORE_RATES_SINGULAR, Tags.Items.ORE_RATES_SINGULAR)
|
||||
.add(
|
||||
Blocks.ANCIENT_DEBRIS,
|
||||
Blocks.COAL_ORE,
|
||||
Blocks.DEEPSLATE_COAL_ORE,
|
||||
Blocks.DEEPSLATE_DIAMOND_ORE,
|
||||
Blocks.DEEPSLATE_EMERALD_ORE,
|
||||
Blocks.DEEPSLATE_GOLD_ORE,
|
||||
Blocks.DEEPSLATE_IRON_ORE,
|
||||
Blocks.DIAMOND_ORE,
|
||||
Blocks.EMERALD_ORE,
|
||||
Blocks.GOLD_ORE,
|
||||
Blocks.IRON_ORE,
|
||||
Blocks.NETHER_QUARTZ_ORE
|
||||
);
|
||||
tag(Tags.Blocks.ORE_RATES_SPARSE, Tags.Items.ORE_RATES_SPARSE)
|
||||
.add(Blocks.NETHER_GOLD_ORE);
|
||||
tag(Tags.Blocks.ORES, Tags.Items.ORES)
|
||||
.addTags(
|
||||
Tags.Blocks.ORES_COAL,
|
||||
Tags.Blocks.ORES_COPPER,
|
||||
Tags.Blocks.ORES_DIAMOND,
|
||||
Tags.Blocks.ORES_EMERALD,
|
||||
Tags.Blocks.ORES_GOLD,
|
||||
Tags.Blocks.ORES_IRON,
|
||||
Tags.Blocks.ORES_LAPIS,
|
||||
Tags.Blocks.ORES_NETHERITE_SCRAP,
|
||||
Tags.Blocks.ORES_REDSTONE,
|
||||
Tags.Blocks.ORES_QUARTZ
|
||||
)
|
||||
.addOptionalTag(Legacy.Blocks.ORES);
|
||||
tag(Tags.Blocks.ORES_COAL, Tags.Items.ORES_COAL)
|
||||
.addTag(BlockTags.COAL_ORES); // forge:ores/coal
|
||||
tag(Tags.Blocks.ORES_COPPER, Tags.Items.ORES_COPPER)
|
||||
.addTag(BlockTags.COPPER_ORES); // forge:ores/copper
|
||||
tag(Tags.Blocks.ORES_DIAMOND, Tags.Items.ORES_DIAMOND)
|
||||
.addTag(BlockTags.DIAMOND_ORES); // forge:ores/diamond
|
||||
tag(Tags.Blocks.ORES_EMERALD, Tags.Items.ORES_EMERALD)
|
||||
.addTag(BlockTags.EMERALD_ORES); // forge:ores/emerald
|
||||
tag(Tags.Blocks.ORES_GOLD, Tags.Items.ORES_GOLD)
|
||||
.addTag(BlockTags.GOLD_ORES); // forge:ores/gold
|
||||
tag(Tags.Blocks.ORES_IRON, Tags.Items.ORES_IRON)
|
||||
.addTag(BlockTags.IRON_ORES); // forge:ores/iron
|
||||
tag(Tags.Blocks.ORES_LAPIS, Tags.Items.ORES_LAPIS)
|
||||
.addTag(BlockTags.LAPIS_ORES); // forge:ores/lapis
|
||||
tag(Tags.Blocks.ORES_QUARTZ, Tags.Items.ORES_QUARTZ, Legacy.Blocks.ORES_QUARTZ, Legacy.Items.QUARTZ_ORES)
|
||||
.add(Blocks.NETHER_QUARTZ_ORE)
|
||||
.addOptionalTag(Legacy.Blocks.ORES_QUARTZ);
|
||||
tag(Tags.Blocks.ORES_REDSTONE, Tags.Items.ORES_REDSTONE)
|
||||
.addTag(BlockTags.REDSTONE_ORES); // forge:ores/redstone
|
||||
tag(Tags.Blocks.ORES_NETHERITE_SCRAP, Tags.Items.ORES_NETHERITE_SCRAP, Legacy.Blocks.ORES_NETHERITE_SCRAP, Legacy.Items.ORES_NEHTERITE_SCRAP)
|
||||
.add(Blocks.ANCIENT_DEBRIS)
|
||||
.addOptionalTag(Legacy.Blocks.ORES_NETHERITE_SCRAP);
|
||||
tag(Tags.Blocks.ORES_IN_GROUND_DEEPSLATE, Tags.Items.ORES_IN_GROUND_DEEPSLATE)
|
||||
.add(
|
||||
Blocks.DEEPSLATE_COAL_ORE,
|
||||
Blocks.DEEPSLATE_COPPER_ORE,
|
||||
Blocks.DEEPSLATE_DIAMOND_ORE,
|
||||
Blocks.DEEPSLATE_EMERALD_ORE,
|
||||
Blocks.DEEPSLATE_GOLD_ORE,
|
||||
Blocks.DEEPSLATE_IRON_ORE,
|
||||
Blocks.DEEPSLATE_LAPIS_ORE,
|
||||
Blocks.DEEPSLATE_REDSTONE_ORE
|
||||
);
|
||||
tag(Tags.Blocks.ORES_IN_GROUND_NETHERRACK, Tags.Items.ORES_IN_GROUND_NETHERRACK)
|
||||
.add(
|
||||
Blocks.NETHER_GOLD_ORE,
|
||||
Blocks.NETHER_QUARTZ_ORE
|
||||
);
|
||||
tag(Tags.Blocks.ORES_IN_GROUND_STONE, Tags.Items.ORES_IN_GROUND_STONE)
|
||||
.add(
|
||||
Blocks.COAL_ORE,
|
||||
Blocks.COPPER_ORE,
|
||||
Blocks.DIAMOND_ORE,
|
||||
Blocks.EMERALD_ORE,
|
||||
Blocks.GOLD_ORE,
|
||||
Blocks.IRON_ORE,
|
||||
Blocks.LAPIS_ORE,
|
||||
Blocks.REDSTONE_ORE
|
||||
);
|
||||
tag(Tags.Blocks.PLAYER_WORKSTATIONS_CRAFTING_TABLES, Tags.Items.PLAYER_WORKSTATIONS_CRAFTING_TABLES)
|
||||
.add(Blocks.CRAFTING_TABLE);
|
||||
tag(Tags.Blocks.PLAYER_WORKSTATIONS_FURNACES, Tags.Items.PLAYER_WORKSTATIONS_FURNACES)
|
||||
.add(Blocks.FURNACE);
|
||||
tag(Tags.Blocks.PUMPKINS, Tags.Items.PUMPKINS)
|
||||
.addTags(
|
||||
Tags.Blocks.PUMPKINS_NORMAL,
|
||||
Tags.Blocks.PUMPKINS_CARVED,
|
||||
Tags.Blocks.PUMPKINS_JACK_O_LANTERNS
|
||||
);
|
||||
tag(Tags.Blocks.PUMPKINS_NORMAL, Tags.Items.PUMPKINS_NORMAL)
|
||||
.add(Blocks.PUMPKIN);
|
||||
tag(Tags.Blocks.PUMPKINS_CARVED, Tags.Items.PUMPKINS_CARVED)
|
||||
.add(Blocks.CARVED_PUMPKIN);
|
||||
tag(Tags.Blocks.PUMPKINS_JACK_O_LANTERNS, Tags.Items.PUMPKINS_JACK_O_LANTERNS)
|
||||
.add(Blocks.JACK_O_LANTERN);
|
||||
tag(Tags.Blocks.ROPES, Tags.Items.ROPES);
|
||||
tag(Tags.Blocks.SAND, Tags.Items.SAND) // forge:sand
|
||||
.addTags(
|
||||
Tags.Blocks.SAND_COLORLESS,
|
||||
Tags.Blocks.SAND_RED
|
||||
);
|
||||
tag(Tags.Blocks.SAND_COLORLESS, Tags.Items.SAND_COLORLESS) // forge:sand/colorless
|
||||
.add(Blocks.SAND);
|
||||
tag(Tags.Blocks.SAND_RED, Tags.Items.SAND_RED) // forge:sand/red
|
||||
.add(Blocks.RED_SAND);
|
||||
tag(Tags.Blocks.SANDSTONE_BLOCKS, Tags.Items.SANDSTONE_BLOCKS)
|
||||
.addTags(
|
||||
Tags.Blocks.SANDSTONE_RED_BLOCKS,
|
||||
Tags.Blocks.SANDSTONE_UNCOLORED_BLOCKS
|
||||
)
|
||||
.addOptionalTag(Legacy.Blocks.SANDSTONE);
|
||||
tag(Tags.Blocks.SANDSTONE_SLABS, Tags.Items.SANDSTONE_SLABS)
|
||||
.addTags(
|
||||
Tags.Blocks.SANDSTONE_RED_SLABS,
|
||||
Tags.Blocks.SANDSTONE_UNCOLORED_SLABS
|
||||
);
|
||||
tag(Tags.Blocks.SANDSTONE_STAIRS, Tags.Items.SANDSTONE_STAIRS)
|
||||
.addTags(
|
||||
Tags.Blocks.SANDSTONE_RED_STAIRS,
|
||||
Tags.Blocks.SANDSTONE_UNCOLORED_STAIRS
|
||||
);
|
||||
tag(Tags.Blocks.SANDSTONE_RED_BLOCKS, Tags.Items.SANDSTONE_RED_BLOCKS)
|
||||
.add(
|
||||
Blocks.RED_SANDSTONE,
|
||||
Blocks.CUT_RED_SANDSTONE,
|
||||
Blocks.CHISELED_RED_SANDSTONE,
|
||||
Blocks.SMOOTH_RED_SANDSTONE
|
||||
);
|
||||
tag(Tags.Blocks.SANDSTONE_RED_SLABS, Tags.Items.SANDSTONE_RED_SLABS)
|
||||
.add(
|
||||
Blocks.RED_SANDSTONE_SLAB,
|
||||
Blocks.CUT_RED_SANDSTONE_SLAB,
|
||||
Blocks.SMOOTH_RED_SANDSTONE_SLAB
|
||||
);
|
||||
tag(Tags.Blocks.SANDSTONE_RED_STAIRS, Tags.Items.SANDSTONE_RED_STAIRS)
|
||||
.add(
|
||||
Blocks.RED_SANDSTONE_STAIRS,
|
||||
Blocks.SMOOTH_RED_SANDSTONE_STAIRS
|
||||
);
|
||||
tag(Tags.Blocks.SANDSTONE_UNCOLORED_BLOCKS, Tags.Items.SANDSTONE_UNCOLORED_BLOCKS)
|
||||
.add(
|
||||
Blocks.SANDSTONE,
|
||||
Blocks.CUT_SANDSTONE,
|
||||
Blocks.CHISELED_SANDSTONE,
|
||||
Blocks.SMOOTH_SANDSTONE
|
||||
);
|
||||
tag(Tags.Blocks.SANDSTONE_UNCOLORED_SLABS, Tags.Items.SANDSTONE_UNCOLORED_SLABS)
|
||||
.add(
|
||||
Blocks.SANDSTONE_SLAB,
|
||||
Blocks.CUT_SANDSTONE_SLAB,
|
||||
Blocks.SMOOTH_SANDSTONE_SLAB
|
||||
);
|
||||
tag(Tags.Blocks.SANDSTONE_UNCOLORED_STAIRS, Tags.Items.SANDSTONE_UNCOLORED_STAIRS)
|
||||
.add(
|
||||
Blocks.SANDSTONE_STAIRS,
|
||||
Blocks.SMOOTH_SANDSTONE_STAIRS
|
||||
);
|
||||
tag(Tags.Blocks.STONES, Tags.Items.STONES)
|
||||
.add(
|
||||
Blocks.ANDESITE,
|
||||
Blocks.DIORITE,
|
||||
Blocks.GRANITE,
|
||||
Blocks.STONE,
|
||||
Blocks.DEEPSLATE,
|
||||
Blocks.TUFF
|
||||
);
|
||||
//.addOptionalTag(forgeTagKey("stone")); // can't add this because it would include infested/polished variants which aren't contained in Fabric's `c:stones`
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS, Tags.Items.STORAGE_BLOCKS)
|
||||
.addTags(
|
||||
Tags.Blocks.STORAGE_BLOCKS_BONE_MEAL,
|
||||
Tags.Blocks.STORAGE_BLOCKS_COAL,
|
||||
Tags.Blocks.STORAGE_BLOCKS_COPPER,
|
||||
Tags.Blocks.STORAGE_BLOCKS_DIAMOND,
|
||||
Tags.Blocks.STORAGE_BLOCKS_DRIED_KELP,
|
||||
Tags.Blocks.STORAGE_BLOCKS_EMERALD,
|
||||
Tags.Blocks.STORAGE_BLOCKS_GOLD,
|
||||
Tags.Blocks.STORAGE_BLOCKS_IRON,
|
||||
Tags.Blocks.STORAGE_BLOCKS_LAPIS,
|
||||
Tags.Blocks.STORAGE_BLOCKS_NETHERITE,
|
||||
Tags.Blocks.STORAGE_BLOCKS_RAW_COPPER,
|
||||
Tags.Blocks.STORAGE_BLOCKS_RAW_GOLD,
|
||||
Tags.Blocks.STORAGE_BLOCKS_RAW_IRON,
|
||||
Tags.Blocks.STORAGE_BLOCKS_REDSTONE,
|
||||
Tags.Blocks.STORAGE_BLOCKS_SLIME,
|
||||
Tags.Blocks.STORAGE_BLOCKS_WHEAT
|
||||
)
|
||||
//.addOptionalTag(forgeTagKey("storage_blocks")); // can't add this because it would include contents from the non-common forge:storage_blocks/amethyst and forge:storage_blocks/quartz, which are not in the c namespace
|
||||
.addOptionalTags(
|
||||
Legacy.Blocks.STORAGE_BLOCKS_COAL,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_COPPER,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_DIAMOND,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_EMERALD,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_GOLD,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_IRON,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_LAPIS,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_NETHERITE,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_RAW_COPPER,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_RAW_GOLD,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_RAW_IRON,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_REDSTONE
|
||||
);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_AMETHYST, Tags.Items.STORAGE_BLOCKS_AMETHYST)
|
||||
.add(Blocks.AMETHYST_BLOCK);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_BONE_MEAL, Tags.Items.STORAGE_BLOCKS_BONE_MEAL)
|
||||
.add(Blocks.BONE_BLOCK);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_COAL, Tags.Items.STORAGE_BLOCKS_COAL, Legacy.Blocks.STORAGE_BLOCKS_COAL, Legacy.Items.STORAGE_BLOCKS_COAL)
|
||||
.add(Blocks.COAL_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_COAL);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_COPPER, Tags.Items.STORAGE_BLOCKS_COPPER, Legacy.Blocks.STORAGE_BLOCKS_COPPER, Legacy.Items.STORAGE_BLOCKS_COPPER)
|
||||
.add(Blocks.COPPER_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_COPPER);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_DIAMOND, Tags.Items.STORAGE_BLOCKS_DIAMOND, Legacy.Blocks.STORAGE_BLOCKS_DIAMOND, Legacy.Items.STORAGE_BLOCKS_DIAMOND)
|
||||
.add(Blocks.DIAMOND_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_DIAMOND);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_DRIED_KELP, Tags.Items.STORAGE_BLOCKS_DRIED_KELP)
|
||||
.add(Blocks.DRIED_KELP_BLOCK);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_EMERALD, Tags.Items.STORAGE_BLOCKS_EMERALD, Legacy.Blocks.STORAGE_BLOCKS_EMERALD, Legacy.Items.STORAGE_BLOCKS_EMERALD)
|
||||
.add(Blocks.EMERALD_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_EMERALD);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_GOLD, Tags.Items.STORAGE_BLOCKS_GOLD, Legacy.Blocks.STORAGE_BLOCKS_GOLD, Legacy.Items.STORAGE_BLOCKS_GOLD)
|
||||
.add(Blocks.GOLD_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_GOLD);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_IRON, Tags.Items.STORAGE_BLOCKS_IRON, Legacy.Blocks.STORAGE_BLOCKS_IRON, Legacy.Items.STORAGE_BLOCKS_IRON)
|
||||
.add(Blocks.IRON_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_IRON);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_LAPIS, Tags.Items.STORAGE_BLOCKS_LAPIS, Legacy.Blocks.STORAGE_BLOCKS_LAPIS, Legacy.Items.STORAGE_BLOCKS_LAPIS)
|
||||
.add(Blocks.LAPIS_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_LAPIS);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_NETHERITE, Tags.Items.STORAGE_BLOCKS_NETHERITE, Legacy.Blocks.STORAGE_BLOCKS_NETHERITE, Legacy.Items.STORAGE_BLOCKS_NETHERITE)
|
||||
.add(Blocks.NETHERITE_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_NETHERITE);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_QUARTZ, Tags.Items.STORAGE_BLOCKS_QUARTZ)
|
||||
.add(Blocks.QUARTZ_BLOCK);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_RAW_COPPER, Tags.Items.STORAGE_BLOCKS_RAW_COPPER, Legacy.Blocks.STORAGE_BLOCKS_RAW_COPPER, Legacy.Items.STORAGE_BLOCKS_RAW_COPPER)
|
||||
.add(Blocks.RAW_COPPER_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_RAW_COPPER);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_RAW_GOLD, Tags.Items.STORAGE_BLOCKS_RAW_GOLD, Legacy.Blocks.STORAGE_BLOCKS_RAW_GOLD, Legacy.Items.STORAGE_BLOCKS_RAW_GOLD)
|
||||
.add(Blocks.RAW_GOLD_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_RAW_GOLD);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_RAW_IRON, Tags.Items.STORAGE_BLOCKS_RAW_IRON, Legacy.Blocks.STORAGE_BLOCKS_RAW_IRON, Legacy.Items.STORAGE_BLOCKS_RAW_IRON)
|
||||
.add(Blocks.RAW_IRON_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_RAW_IRON);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, Tags.Items.STORAGE_BLOCKS_REDSTONE, Legacy.Blocks.STORAGE_BLOCKS_REDSTONE, Legacy.Items.STORAGE_BLOCKS_REDSTONE)
|
||||
.add(Blocks.REDSTONE_BLOCK)
|
||||
.addOptionalTag(Legacy.Blocks.STORAGE_BLOCKS_REDSTONE);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_SLIME, Tags.Items.STORAGE_BLOCKS_SLIME)
|
||||
.add(Blocks.SLIME_BLOCK);
|
||||
tag(Tags.Blocks.STORAGE_BLOCKS_WHEAT, Tags.Items.STORAGE_BLOCKS_WHEAT)
|
||||
.add(Blocks.HAY_BLOCK);
|
||||
tag(Tags.Blocks.STRIPPED_LOGS, Tags.Items.STRIPPED_LOGS)
|
||||
.add(
|
||||
Blocks.STRIPPED_ACACIA_LOG,
|
||||
Blocks.STRIPPED_BAMBOO_BLOCK,
|
||||
Blocks.STRIPPED_BIRCH_LOG,
|
||||
Blocks.STRIPPED_CHERRY_LOG,
|
||||
Blocks.STRIPPED_DARK_OAK_LOG,
|
||||
Blocks.STRIPPED_JUNGLE_LOG,
|
||||
Blocks.STRIPPED_MANGROVE_LOG,
|
||||
Blocks.STRIPPED_OAK_LOG,
|
||||
Blocks.STRIPPED_SPRUCE_LOG
|
||||
);
|
||||
tag(Tags.Blocks.STRIPPED_WOODS, Tags.Items.STRIPPED_WOODS)
|
||||
.add(
|
||||
Blocks.STRIPPED_ACACIA_WOOD,
|
||||
Blocks.STRIPPED_BIRCH_WOOD,
|
||||
Blocks.STRIPPED_CHERRY_WOOD,
|
||||
Blocks.STRIPPED_DARK_OAK_WOOD,
|
||||
Blocks.STRIPPED_JUNGLE_WOOD,
|
||||
Blocks.STRIPPED_MANGROVE_WOOD,
|
||||
Blocks.STRIPPED_OAK_WOOD,
|
||||
Blocks.STRIPPED_SPRUCE_WOOD
|
||||
);
|
||||
|
||||
// Backwards compat definitions for pre-1.21 legacy `forge:` tags.
|
||||
// TODO: [Forge][Tags][Old] Remove backwards compat tag entries in 1.22
|
||||
tag(Legacy.Blocks.BARRELS, Legacy.Items.BARRELS)
|
||||
.addTag(Legacy.Blocks.BARRELS_WOODEN);
|
||||
|
||||
tag(Legacy.Blocks.CHESTS, Legacy.Items.CHESTS)
|
||||
.addTags(
|
||||
Tags.Blocks.CHESTS_ENDER,
|
||||
Tags.Blocks.CHESTS_TRAPPED,
|
||||
Legacy.Blocks.CHESTS_WOODEN
|
||||
);
|
||||
|
||||
//copy(forgeBlockTagKey("glass/tinted"), forgeItemTagKey("glass/tinted"));
|
||||
addColored(tag(Tags.Blocks.STAINED_GLASS, Tags.Items.STAINED_GLASS)::add, Tags.Blocks.GLASS, "{color}_stained_glass");
|
||||
addColored(tag(Tags.Blocks.STAINED_GLASS_PANES, Tags.Items.STAINED_GLASS_PANES)::add, Tags.Blocks.GLASS_PANES, "{color}_stained_glass_pane");
|
||||
|
||||
// tag(Tags.Blocks.GLASS, Tags.Items.GLASS, forgeBlockTagKey("glass"), forgeItemTagKey("glass")) // these are the same thing
|
||||
tag(Tags.Blocks.GLASS, Tags.Items.GLASS)
|
||||
.addTags(
|
||||
Tags.Blocks.GLASS_COLORLESS,
|
||||
Tags.Blocks.STAINED_GLASS,
|
||||
Legacy.Blocks.GLASS_TINTED
|
||||
);
|
||||
tag(Tags.Blocks.GLASS_COLORLESS, Tags.Items.GLASS_COLORLESS)
|
||||
.add(Blocks.GLASS);
|
||||
tag(Legacy.Blocks.GLASS_PANES, Legacy.Items.GLASS_PANES)
|
||||
.addTags(
|
||||
Legacy.Blocks.GLASS_PANES_COLORLESS,
|
||||
Tags.Blocks.STAINED_GLASS_PANES
|
||||
);
|
||||
tag(Legacy.Blocks.GLASS_PANES_COLORLESS, Legacy.Items.GLASS_PANES_COLORLESS)
|
||||
.add(Blocks.GLASS_PANE);
|
||||
tag(Legacy.Blocks.GLASS_TINTED, Legacy.Items.GLASS_TINTED)
|
||||
.add(Blocks.TINTED_GLASS);
|
||||
tag(Legacy.Blocks.OBSIDIAN, Legacy.Items.OBSIDIAN)
|
||||
.add(Blocks.OBSIDIAN);
|
||||
tag(Legacy.Blocks.ORES, Legacy.Items.ORES)
|
||||
.addTags(
|
||||
Tags.Blocks.ORES_COAL,
|
||||
Tags.Blocks.ORES_COPPER,
|
||||
Tags.Blocks.ORES_DIAMOND,
|
||||
Tags.Blocks.ORES_EMERALD,
|
||||
Tags.Blocks.ORES_GOLD,
|
||||
Tags.Blocks.ORES_IRON,
|
||||
Tags.Blocks.ORES_LAPIS,
|
||||
Tags.Blocks.ORES_REDSTONE,
|
||||
Legacy.Blocks.ORES_QUARTZ,
|
||||
Legacy.Blocks.ORES_NETHERITE_SCRAP
|
||||
);
|
||||
tag(Legacy.Blocks.SANDSTONE, Legacy.Items.SANDSTONE)
|
||||
.add(
|
||||
Blocks.SANDSTONE,
|
||||
Blocks.CUT_SANDSTONE,
|
||||
Blocks.CHISELED_SANDSTONE,
|
||||
Blocks.SMOOTH_SANDSTONE,
|
||||
Blocks.RED_SANDSTONE,
|
||||
Blocks.CUT_RED_SANDSTONE,
|
||||
Blocks.CHISELED_RED_SANDSTONE,
|
||||
Blocks.SMOOTH_RED_SANDSTONE
|
||||
);
|
||||
tag(Legacy.Blocks.STONE, Legacy.Items.STONE)
|
||||
.add(
|
||||
Blocks.ANDESITE,
|
||||
Blocks.DIORITE,
|
||||
Blocks.GRANITE,
|
||||
Blocks.INFESTED_STONE,
|
||||
Blocks.STONE,
|
||||
Blocks.POLISHED_ANDESITE,
|
||||
Blocks.POLISHED_DIORITE,
|
||||
Blocks.POLISHED_GRANITE,
|
||||
Blocks.DEEPSLATE,
|
||||
Blocks.POLISHED_DEEPSLATE,
|
||||
Blocks.INFESTED_DEEPSLATE,
|
||||
Blocks.TUFF
|
||||
);
|
||||
|
||||
tag(Legacy.Blocks.STORAGE_BLOCKS, Legacy.Items.STORAGE_BLOCKS)
|
||||
.addTags(
|
||||
Tags.Blocks.STORAGE_BLOCKS_AMETHYST,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_COAL,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_COPPER,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_DIAMOND,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_EMERALD,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_GOLD,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_IRON,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_LAPIS,
|
||||
Tags.Blocks.STORAGE_BLOCKS_QUARTZ,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_RAW_COPPER,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_RAW_GOLD,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_RAW_IRON,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_REDSTONE,
|
||||
Legacy.Blocks.STORAGE_BLOCKS_NETHERITE
|
||||
);
|
||||
}
|
||||
|
||||
private static TagKey<Block> forgeTagKey(String path) {
|
||||
return BlockTags.create(ResourceLocation.fromNamespaceAndPath("forge", path));
|
||||
}
|
||||
|
||||
private static TagKey<Block> tagKey(String name) {
|
||||
return BlockTags.create(ResourceLocation.withDefaultNamespace(name));
|
||||
}
|
||||
|
||||
private void addColored(Consumer<Block> consumer, TagKey<Block> group, String pattern) {
|
||||
String prefix = group.location().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
for (DyeColor color : DyeColor.values()) {
|
||||
ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName()));
|
||||
TagKey<Block> blockTag = getForgeTag(Tags.Blocks.class, prefix + color.getName());
|
||||
TagKey<Item> itemTag = getForgeTag(Tags.Items.class, prefix + color.getName());
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(key);
|
||||
if (block == null || block == Blocks.AIR)
|
||||
throw new IllegalStateException("Unknown vanilla block: " + key.toString());
|
||||
tag(blockTag, itemTag).add(block);
|
||||
consumer.accept(block);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> TagKey<T> getForgeTag(Class<?> cls, String name) {
|
||||
try {
|
||||
name = name.toUpperCase(Locale.ENGLISH);
|
||||
return (TagKey<T>)cls.getDeclaredField(name).get(null);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
||||
throw new IllegalStateException(cls.getName() + " is missing tag name: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
private static ResourceLocation forgeRl(String path) {
|
||||
return ResourceLocation.fromNamespaceAndPath("forge", path);
|
||||
}
|
||||
|
||||
private TagAppender<Block, Block> tag(TagKey<Block> block, TagKey<Item> item, TagKey<Block> oldBlock, TagKey<Item> oldItem) {
|
||||
var tag = tag(block, item);
|
||||
var old = tag(oldBlock, oldItem);
|
||||
return wrap(tag, old, oldBlock);
|
||||
}
|
||||
|
||||
private static TagAppender<Block, Block> wrap(TagAppender<Block, Block> tag, TagAppender<Block, Block> old, TagKey<Block> oldBlock) {
|
||||
return new TagAppender<Block, Block>() {
|
||||
@Override
|
||||
public TagAppender<Block, Block> add(Block value) {
|
||||
tag.add(value);
|
||||
old.add(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagAppender<Block, Block> addOptional(Block value) {
|
||||
tag.addOptional(value);
|
||||
old.addOptional(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagAppender<Block, Block> addTag(TagKey<Block> value) {
|
||||
tag.addTag(value);
|
||||
old.addTag(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagAppender<Block, Block> addOptionalTag(TagKey<Block> value) {
|
||||
tag.addOptionalTag(value);
|
||||
if (value != oldBlock)
|
||||
old.addOptionalTag(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagAppender<Block, Block> replace(boolean value) {
|
||||
tag.replace(value);
|
||||
old.replace(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagAppender<Block, Block> remove(ResourceLocation value) {
|
||||
tag.remove(value);
|
||||
old.remove(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagAppender<Block, Block> remove(TagKey<Block> value) {
|
||||
tag.remove(value);
|
||||
old.remove(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagAppender<Block, Block> remove(Block value) {
|
||||
tag.remove(value);
|
||||
old.remove(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceName() {
|
||||
return tag.getSourceName();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class Legacy {
|
||||
@Deprecated
|
||||
private static class Blocks {
|
||||
private static TagKey<Block> tag(String path) {
|
||||
return BlockTags.create(forgeRl(path));
|
||||
}
|
||||
|
||||
public static final TagKey<Block> BARRELS = tag("barrels");
|
||||
public static final TagKey<Block> BARRELS_WOODEN = tag("barrels/wooden");
|
||||
public static final TagKey<Block> BOOKSHELVES = tag("bookshelves");
|
||||
public static final TagKey<Block> CHESTS = tag("chests");
|
||||
public static final TagKey<Block> CHESTS_WOODEN = tag("chests/wooden");
|
||||
public static final TagKey<Block> COBBLESTONE = tag("cobblestone");
|
||||
public static final TagKey<Block> GLASS_PANES = tag("glass_panes");
|
||||
public static final TagKey<Block> GLASS_PANES_COLORLESS = tag("glass_panes/colorless");
|
||||
public static final TagKey<Block> GLASS_SILICA = tag("glass/silica");
|
||||
public static final TagKey<Block> GLASS_TINTED = tag("glass/tinted");
|
||||
public static final TagKey<Block> OBSIDIAN = tag("obsidian");
|
||||
public static final TagKey<Block> ORES = tag("ores");
|
||||
public static final TagKey<Block> ORES_QUARTZ = tag("ores/quartz");
|
||||
public static final TagKey<Block> ORES_NETHERITE_SCRAP = tag("ores/netherite_scrap");
|
||||
public static final TagKey<Block> SANDSTONE = tag("sandstone");
|
||||
public static final TagKey<Block> STONE = tag("stone");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS = tag("storage_blocks");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_COAL = tag("storage_blocks/coal");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_COPPER = tag("storage_blocks/copper");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_DIAMOND = tag("storage_blocks/diamond");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_EMERALD = tag("storage_blocks/emerald");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_GOLD = tag("storage_blocks/gold");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_IRON = tag("storage_blocks/iron");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_LAPIS = tag("storage_blocks/lapis");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_NETHERITE = tag("storage_blocks/netherite");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_RAW_COPPER = tag("storage_blocks/raw_copper");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_RAW_GOLD = tag("storage_blocks/raw_gold");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_RAW_IRON = tag("storage_blocks/raw_iron");
|
||||
public static final TagKey<Block> STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static class Items {
|
||||
private static TagKey<Item> tag(String path) {
|
||||
return ItemTags.create(forgeRl(path));
|
||||
}
|
||||
|
||||
public static final TagKey<Item> BARRELS = tag("barrels");
|
||||
public static final TagKey<Item> BARRELS_WOODEN = tag("barrels/wooden");
|
||||
public static final TagKey<Item> BOOKSHELVES = tag("bookshelves");
|
||||
public static final TagKey<Item> CHESTS = tag("chests");
|
||||
public static final TagKey<Item> CHESTS_WOODEN = tag("chests/wooden");
|
||||
public static final TagKey<Item> COBBLESTONE = tag("cobblestone");
|
||||
public static final TagKey<Item> GLASS_PANES = tag("glass_panes");
|
||||
public static final TagKey<Item> GLASS_PANES_COLORLESS = tag("glass_panes/colorless");
|
||||
public static final TagKey<Item> GLASS_SILICA = tag("glass/silica");
|
||||
public static final TagKey<Item> GLASS_TINTED = tag("glass/tinted");
|
||||
public static final TagKey<Item> OBSIDIAN = tag("obsidian");
|
||||
public static final TagKey<Item> ORES = tag("ores");
|
||||
public static final TagKey<Item> QUARTZ_ORES = tag("ores/quartz");
|
||||
public static final TagKey<Item> ORES_NEHTERITE_SCRAP = tag("ores/netherite_scrap");
|
||||
public static final TagKey<Item> SANDSTONE = tag("sandstone");
|
||||
public static final TagKey<Item> STONE = tag("stone");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS = tag("storage_blocks");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_COAL = tag("storage_blocks/coal");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_COPPER = tag("storage_blocks/copper");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_DIAMOND = tag("storage_blocks/diamond");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_EMERALD = tag("storage_blocks/emerald");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_GOLD = tag("storage_blocks/gold");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_IRON = tag("storage_blocks/iron");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_LAPIS = tag("storage_blocks/lapis");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_NETHERITE = tag("storage_blocks/netherite");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_RAW_COPPER = tag("storage_blocks/raw_copper");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_RAW_GOLD = tag("storage_blocks/raw_gold");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_RAW_IRON = tag("storage_blocks/raw_iron");
|
||||
public static final TagKey<Item> STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,13 @@ package net.minecraftforge.common.data;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
|
||||
import net.minecraft.data.tags.TagAppender;
|
||||
import net.minecraft.data.tags.VanillaBlockTagsProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.common.Tags;
|
||||
@@ -27,45 +29,21 @@ import java.util.function.Consumer;
|
||||
import static net.minecraftforge.common.Tags.Blocks.*;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ForgeBlockTagsProvider extends BlockTagsProvider {
|
||||
public final class ForgeBlockTagsProvider extends VanillaBlockTagsProvider {
|
||||
public ForgeBlockTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
|
||||
super(output, lookupProvider, "forge", existingFileHelper);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void addTags(HolderLookup.Provider p_256380_) {
|
||||
tag(BARRELS)
|
||||
.addTag(BARRELS_WOODEN)
|
||||
.addOptionalTag(forgeTagKey("barrels"));
|
||||
tag(BARRELS_WOODEN)
|
||||
.add(Blocks.BARREL)
|
||||
.addOptionalTag(forgeTagKey("barrels/wooden"));
|
||||
tag(BOOKSHELVES)
|
||||
.add(Blocks.BOOKSHELF)
|
||||
.addOptionalTag(forgeTagKey("bookshelves"));
|
||||
tag(BUDDING_BLOCKS).add(Blocks.BUDDING_AMETHYST);
|
||||
tag(BUDS).add(Blocks.SMALL_AMETHYST_BUD).add(Blocks.MEDIUM_AMETHYST_BUD).add(Blocks.LARGE_AMETHYST_BUD);
|
||||
tag(CHAINS).add(Blocks.CHAIN);
|
||||
tag(CHESTS)
|
||||
.addTags(CHESTS_ENDER, CHESTS_TRAPPED, CHESTS_WOODEN)
|
||||
.addOptionalTag(forgeTagKey("chests"));
|
||||
tag(CHESTS_ENDER).add(Blocks.ENDER_CHEST); // forge:chests/ender
|
||||
tag(CHESTS_TRAPPED).add(Blocks.TRAPPED_CHEST); // forge:chests/trapped
|
||||
tag(CHESTS_WOODEN)
|
||||
.add(Blocks.CHEST, Blocks.TRAPPED_CHEST)
|
||||
.addOptionalTag(forgeTagKey("chests/wooden"));
|
||||
(new ForgeBlockItemTagsProvider() {
|
||||
@Override
|
||||
protected TagAppender<Block, Block> tag(TagKey<Block> p_406922_, TagKey<Item> p_408417_) {
|
||||
return ForgeBlockTagsProvider.this.tag(p_406922_);
|
||||
}
|
||||
}).run();
|
||||
tag(CHORUS_ADDITIONALLY_GROWS_ON)
|
||||
.addTag(END_STONES);
|
||||
tag(CLUSTERS).add(Blocks.AMETHYST_CLUSTER);
|
||||
tag(COBBLESTONES)
|
||||
.addTags(COBBLESTONE_NORMAL, COBBLESTONE_INFESTED, COBBLESTONE_MOSSY, COBBLESTONE_DEEPSLATE)
|
||||
.addOptionalTag(forgeTagKey("cobblestone"));
|
||||
tag(COBBLESTONE_NORMAL).add(Blocks.COBBLESTONE); // forge:cobblestone/normal
|
||||
tag(COBBLESTONE_INFESTED).add(Blocks.INFESTED_COBBLESTONE); // forge:cobblestone/infested
|
||||
tag(COBBLESTONE_MOSSY).add(Blocks.MOSSY_COBBLESTONE); // forge:cobblestone/mossy
|
||||
tag(COBBLESTONE_DEEPSLATE).add(Blocks.COBBLED_DEEPSLATE); // forge:cobblestone/deepslate
|
||||
tag(CONCRETES).add(Blocks.WHITE_CONCRETE, Blocks.ORANGE_CONCRETE, Blocks.MAGENTA_CONCRETE, Blocks.LIGHT_BLUE_CONCRETE, Blocks.YELLOW_CONCRETE, Blocks.LIME_CONCRETE, Blocks.PINK_CONCRETE, Blocks.GRAY_CONCRETE, Blocks.LIGHT_GRAY_CONCRETE, Blocks.CYAN_CONCRETE, Blocks.PURPLE_CONCRETE, Blocks.BLUE_CONCRETE, Blocks.BROWN_CONCRETE, Blocks.GREEN_CONCRETE, Blocks.RED_CONCRETE, Blocks.BLACK_CONCRETE);
|
||||
.addTag(END_STONES);
|
||||
addColored(DYED, "{color}_banner");
|
||||
addColored(DYED, "{color}_bed");
|
||||
addColored(DYED, "{color}_candle");
|
||||
@@ -80,210 +58,15 @@ public final class ForgeBlockTagsProvider extends BlockTagsProvider {
|
||||
addColored(DYED, "{color}_wall_banner");
|
||||
addColored(DYED, "{color}_wool");
|
||||
addColoredTags(tag(DYED)::addTag, DYED);
|
||||
tag(END_STONES).add(Blocks.END_STONE); // forge:end_stones
|
||||
tag(ENDERMAN_PLACE_ON_BLACKLIST); // forge:enderman_place_on_blacklist
|
||||
tag(FENCE_GATES).addTags(FENCE_GATES_WOODEN); // forge:fence_gates
|
||||
tag(FENCE_GATES_WOODEN).add(Blocks.OAK_FENCE_GATE, Blocks.SPRUCE_FENCE_GATE, Blocks.BIRCH_FENCE_GATE, Blocks.JUNGLE_FENCE_GATE, Blocks.ACACIA_FENCE_GATE, Blocks.DARK_OAK_FENCE_GATE, Blocks.CRIMSON_FENCE_GATE, Blocks.WARPED_FENCE_GATE, Blocks.MANGROVE_FENCE_GATE, Blocks.BAMBOO_FENCE_GATE, Blocks.CHERRY_FENCE_GATE);
|
||||
tag(FENCES).addTags(FENCES_NETHER_BRICK, FENCES_WOODEN); // forge:fences
|
||||
tag(FENCES_NETHER_BRICK).add(Blocks.NETHER_BRICK_FENCE); // forge:fences/nether_brick
|
||||
tag(FENCES_WOODEN).addTag(BlockTags.WOODEN_FENCES); // forge:fences/wooden
|
||||
tag(Tags.Blocks.FLOWERS_SMALL)
|
||||
.add(Blocks.DANDELION, Blocks.POPPY, Blocks.BLUE_ORCHID, Blocks.ALLIUM, Blocks.AZURE_BLUET, Blocks.RED_TULIP, Blocks.ORANGE_TULIP, Blocks.WHITE_TULIP, Blocks.PINK_TULIP, Blocks.OXEYE_DAISY, Blocks.CORNFLOWER, Blocks.LILY_OF_THE_VALLEY, Blocks.WITHER_ROSE, Blocks.TORCHFLOWER, Blocks.OPEN_EYEBLOSSOM, Blocks.CLOSED_EYEBLOSSOM)
|
||||
.addOptionalTag(BlockTags.SMALL_FLOWERS);
|
||||
tag(Tags.Blocks.FLOWERS_TALL)
|
||||
.add(Blocks.SUNFLOWER, Blocks.LILAC, Blocks.PEONY, Blocks.ROSE_BUSH, Blocks.PITCHER_PLANT)
|
||||
.addOptional(ResourceLocation.withDefaultNamespace("tall_flowers"));
|
||||
tag(Tags.Blocks.FLOWERS)
|
||||
.add(Blocks.FLOWERING_AZALEA_LEAVES, Blocks.FLOWERING_AZALEA, Blocks.MANGROVE_PROPAGULE, Blocks.PINK_PETALS, Blocks.CHORUS_FLOWER, Blocks.SPORE_BLOSSOM)
|
||||
.addTags(Tags.Blocks.FLOWERS_SMALL, Tags.Blocks.FLOWERS_TALL)
|
||||
.addOptionalTag(BlockTags.FLOWERS);
|
||||
tag(GLASS_BLOCKS)
|
||||
.addTags(GLASS_BLOCKS_COLORLESS, GLASS_BLOCKS_CHEAP, GLASS_BLOCKS_TINTED)
|
||||
.addOptionalTag(forgeTagKey("glass"));
|
||||
tag(GLASS_BLOCKS_COLORLESS)
|
||||
.add(Blocks.GLASS)
|
||||
.addOptionalTag(forgeTagKey("glass/colorless"));
|
||||
tag(GLASS_BLOCKS_CHEAP)
|
||||
.add(Blocks.GLASS, Blocks.WHITE_STAINED_GLASS, Blocks.ORANGE_STAINED_GLASS, Blocks.MAGENTA_STAINED_GLASS, Blocks.LIGHT_BLUE_STAINED_GLASS, Blocks.YELLOW_STAINED_GLASS, Blocks.LIME_STAINED_GLASS, Blocks.PINK_STAINED_GLASS, Blocks.GRAY_STAINED_GLASS, Blocks.LIGHT_GRAY_STAINED_GLASS, Blocks.CYAN_STAINED_GLASS, Blocks.PURPLE_STAINED_GLASS, Blocks.BLUE_STAINED_GLASS, Blocks.BROWN_STAINED_GLASS, Blocks.GREEN_STAINED_GLASS, Blocks.RED_STAINED_GLASS, Blocks.BLACK_STAINED_GLASS)
|
||||
.addOptionalTag(forgeTagKey("glass/silica"));
|
||||
tag(GLASS_BLOCKS_TINTED)
|
||||
.add(Blocks.TINTED_GLASS)
|
||||
.addOptionalTag(forgeTagKey("glass/tinted"));
|
||||
tag(GLASS_PANES)
|
||||
.addTags(GLASS_PANES_COLORLESS).add(Blocks.WHITE_STAINED_GLASS_PANE, Blocks.ORANGE_STAINED_GLASS_PANE, Blocks.MAGENTA_STAINED_GLASS_PANE, Blocks.LIGHT_BLUE_STAINED_GLASS_PANE, Blocks.YELLOW_STAINED_GLASS_PANE, Blocks.LIME_STAINED_GLASS_PANE, Blocks.PINK_STAINED_GLASS_PANE, Blocks.GRAY_STAINED_GLASS_PANE, Blocks.LIGHT_GRAY_STAINED_GLASS_PANE, Blocks.CYAN_STAINED_GLASS_PANE, Blocks.PURPLE_STAINED_GLASS_PANE, Blocks.BLUE_STAINED_GLASS_PANE, Blocks.BROWN_STAINED_GLASS_PANE, Blocks.GREEN_STAINED_GLASS_PANE, Blocks.RED_STAINED_GLASS_PANE, Blocks.BLACK_STAINED_GLASS_PANE)
|
||||
.addOptionalTag(forgeTagKey("glass_panes"));
|
||||
tag(GLASS_PANES_COLORLESS)
|
||||
.add(Blocks.GLASS_PANE)
|
||||
.addOptionalTag(forgeTagKey("glass_panes/colorless"));
|
||||
tag(GLAZED_TERRACOTTAS).add(Blocks.WHITE_GLAZED_TERRACOTTA, Blocks.ORANGE_GLAZED_TERRACOTTA, Blocks.MAGENTA_GLAZED_TERRACOTTA, Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA, Blocks.YELLOW_GLAZED_TERRACOTTA, Blocks.LIME_GLAZED_TERRACOTTA, Blocks.PINK_GLAZED_TERRACOTTA, Blocks.GRAY_GLAZED_TERRACOTTA, Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA, Blocks.CYAN_GLAZED_TERRACOTTA, Blocks.PURPLE_GLAZED_TERRACOTTA, Blocks.BLUE_GLAZED_TERRACOTTA, Blocks.BROWN_GLAZED_TERRACOTTA, Blocks.GREEN_GLAZED_TERRACOTTA, Blocks.RED_GLAZED_TERRACOTTA, Blocks.BLACK_GLAZED_TERRACOTTA);
|
||||
tag(GRAVEL).add(Blocks.GRAVEL); // forge:gravel
|
||||
tag(SKULLS).add(Blocks.SKELETON_SKULL, Blocks.SKELETON_WALL_SKULL, Blocks.WITHER_SKELETON_SKULL, Blocks.WITHER_SKELETON_WALL_SKULL, Blocks.PLAYER_HEAD, Blocks.PLAYER_WALL_HEAD, Blocks.ZOMBIE_HEAD, Blocks.ZOMBIE_WALL_HEAD, Blocks.CREEPER_HEAD, Blocks.CREEPER_WALL_HEAD, Blocks.PIGLIN_HEAD, Blocks.PIGLIN_WALL_HEAD, Blocks.DRAGON_HEAD, Blocks.DRAGON_WALL_HEAD);
|
||||
tag(HIDDEN_FROM_RECIPE_VIEWERS);
|
||||
tag(NETHERRACK).add(Blocks.NETHERRACK); // forge:netherrack
|
||||
tag(OBSIDIANS_NORMAL).add(Blocks.OBSIDIAN);
|
||||
tag(OBSIDIANS_CRYING).add(Blocks.CRYING_OBSIDIAN);
|
||||
tag(OBSIDIANS)
|
||||
.addTags(OBSIDIANS_NORMAL, OBSIDIANS_CRYING)
|
||||
.addOptionalTag(forgeTagKey("obsidian"));
|
||||
tag(ORE_BEARING_GROUND_DEEPSLATE).add(Blocks.DEEPSLATE); // forge:ore_bearing_ground/deepslate
|
||||
tag(ORE_BEARING_GROUND_NETHERRACK).add(Blocks.NETHERRACK); // forge:ore_bearing_ground/netherrack
|
||||
tag(ORE_BEARING_GROUND_STONE).add(Blocks.STONE); // forge:ore_bearing_ground/stone
|
||||
tag(ORE_RATES_DENSE).add(Blocks.COPPER_ORE, Blocks.DEEPSLATE_COPPER_ORE, Blocks.DEEPSLATE_LAPIS_ORE, Blocks.DEEPSLATE_REDSTONE_ORE, Blocks.LAPIS_ORE, Blocks.REDSTONE_ORE);
|
||||
tag(ORE_RATES_SINGULAR).add(Blocks.ANCIENT_DEBRIS, Blocks.COAL_ORE, Blocks.DEEPSLATE_COAL_ORE, Blocks.DEEPSLATE_DIAMOND_ORE, Blocks.DEEPSLATE_EMERALD_ORE, Blocks.DEEPSLATE_GOLD_ORE, Blocks.DEEPSLATE_IRON_ORE, Blocks.DIAMOND_ORE, Blocks.EMERALD_ORE, Blocks.GOLD_ORE, Blocks.IRON_ORE, Blocks.NETHER_QUARTZ_ORE);
|
||||
tag(ORE_RATES_SPARSE).add(Blocks.NETHER_GOLD_ORE);
|
||||
tag(ORES)
|
||||
.addTags(ORES_COAL, ORES_COPPER, ORES_DIAMOND, ORES_EMERALD, ORES_GOLD, ORES_IRON, ORES_LAPIS, ORES_NETHERITE_SCRAP, ORES_REDSTONE, ORES_QUARTZ)
|
||||
.addOptionalTag(forgeTagKey("ores"));
|
||||
tag(ORES_COAL).addTag(BlockTags.COAL_ORES); // forge:ores/coal
|
||||
tag(ORES_COPPER).addTag(BlockTags.COPPER_ORES); // forge:ores/copper
|
||||
tag(ORES_DIAMOND).addTag(BlockTags.DIAMOND_ORES); // forge:ores/diamond
|
||||
tag(ORES_EMERALD).addTag(BlockTags.EMERALD_ORES); // forge:ores/emerald
|
||||
tag(ORES_GOLD).addTag(BlockTags.GOLD_ORES); // forge:ores/gold
|
||||
tag(ORES_IRON).addTag(BlockTags.IRON_ORES); // forge:ores/iron
|
||||
tag(ORES_LAPIS).addTag(BlockTags.LAPIS_ORES); // forge:ores/lapis
|
||||
tag(ORES_QUARTZ)
|
||||
.add(Blocks.NETHER_QUARTZ_ORE)
|
||||
.addOptionalTag(forgeTagKey("ores/quartz"));
|
||||
tag(ORES_REDSTONE).addTag(BlockTags.REDSTONE_ORES); // forge:ores/redstone
|
||||
tag(ORES_NETHERITE_SCRAP)
|
||||
.add(Blocks.ANCIENT_DEBRIS)
|
||||
.addOptionalTag(forgeTagKey("ores/netherite_scrap"));
|
||||
tag(ORES_IN_GROUND_DEEPSLATE).add(Blocks.DEEPSLATE_COAL_ORE, Blocks.DEEPSLATE_COPPER_ORE, Blocks.DEEPSLATE_DIAMOND_ORE, Blocks.DEEPSLATE_EMERALD_ORE, Blocks.DEEPSLATE_GOLD_ORE, Blocks.DEEPSLATE_IRON_ORE, Blocks.DEEPSLATE_LAPIS_ORE, Blocks.DEEPSLATE_REDSTONE_ORE);
|
||||
tag(ORES_IN_GROUND_NETHERRACK).add(Blocks.NETHER_GOLD_ORE, Blocks.NETHER_QUARTZ_ORE);
|
||||
tag(ORES_IN_GROUND_STONE).add(Blocks.COAL_ORE, Blocks.COPPER_ORE, Blocks.DIAMOND_ORE, Blocks.EMERALD_ORE, Blocks.GOLD_ORE, Blocks.IRON_ORE, Blocks.LAPIS_ORE, Blocks.REDSTONE_ORE);
|
||||
tag(PLAYER_WORKSTATIONS_CRAFTING_TABLES).add(Blocks.CRAFTING_TABLE);
|
||||
tag(PLAYER_WORKSTATIONS_FURNACES).add(Blocks.FURNACE);
|
||||
tag(PUMPKINS).addTags(PUMPKINS_NORMAL, PUMPKINS_CARVED, PUMPKINS_JACK_O_LANTERNS);
|
||||
tag(PUMPKINS_NORMAL).add(Blocks.PUMPKIN);
|
||||
tag(PUMPKINS_CARVED).add(Blocks.CARVED_PUMPKIN);
|
||||
tag(PUMPKINS_JACK_O_LANTERNS).add(Blocks.JACK_O_LANTERN);
|
||||
tag(SAND).addTags(SAND_COLORLESS, SAND_RED); // forge:sand
|
||||
tag(RELOCATION_NOT_SUPPORTED);
|
||||
tag(ROPES);
|
||||
tag(SAND_COLORLESS).add(Blocks.SAND); // forge:sand/colorless
|
||||
tag(SAND_RED).add(Blocks.RED_SAND); // forge:sand/red
|
||||
|
||||
tag(SANDSTONE_RED_BLOCKS).add(Blocks.RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.SMOOTH_RED_SANDSTONE);
|
||||
tag(SANDSTONE_UNCOLORED_BLOCKS).add(Blocks.SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.SMOOTH_SANDSTONE);
|
||||
tag(SANDSTONE_BLOCKS)
|
||||
.addTags(SANDSTONE_RED_BLOCKS, SANDSTONE_UNCOLORED_BLOCKS)
|
||||
.addOptionalTag(forgeTagKey("sandstone"));
|
||||
tag(SANDSTONE_RED_SLABS).add(Blocks.RED_SANDSTONE_SLAB, Blocks.CUT_RED_SANDSTONE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB);
|
||||
tag(SANDSTONE_UNCOLORED_SLABS).add(Blocks.SANDSTONE_SLAB, Blocks.CUT_SANDSTONE_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB);
|
||||
tag(SANDSTONE_SLABS).addTags(SANDSTONE_RED_SLABS, SANDSTONE_UNCOLORED_SLABS);
|
||||
tag(SANDSTONE_RED_STAIRS).add(Blocks.RED_SANDSTONE_STAIRS, Blocks.SMOOTH_RED_SANDSTONE_STAIRS);
|
||||
tag(SANDSTONE_UNCOLORED_STAIRS).add(Blocks.SANDSTONE_STAIRS, Blocks.SMOOTH_SANDSTONE_STAIRS);
|
||||
tag(SANDSTONE_STAIRS).addTags(SANDSTONE_RED_STAIRS, SANDSTONE_UNCOLORED_STAIRS);
|
||||
|
||||
tag(STONES)
|
||||
.add(Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.STONE, Blocks.DEEPSLATE, Blocks.TUFF);
|
||||
//.addOptionalTag(forgeTagKey("stone")); // can't add this because it would include infested/polished variants which aren't contained in Fabric's `c:stones`
|
||||
tag(STORAGE_BLOCKS)
|
||||
.addTags(STORAGE_BLOCKS_BONE_MEAL, STORAGE_BLOCKS_COAL,
|
||||
STORAGE_BLOCKS_COPPER, STORAGE_BLOCKS_DIAMOND, STORAGE_BLOCKS_DRIED_KELP,
|
||||
STORAGE_BLOCKS_EMERALD, STORAGE_BLOCKS_GOLD, STORAGE_BLOCKS_IRON,
|
||||
STORAGE_BLOCKS_LAPIS, STORAGE_BLOCKS_NETHERITE, STORAGE_BLOCKS_RAW_COPPER,
|
||||
STORAGE_BLOCKS_RAW_GOLD, STORAGE_BLOCKS_RAW_IRON, STORAGE_BLOCKS_REDSTONE,
|
||||
STORAGE_BLOCKS_SLIME, STORAGE_BLOCKS_WHEAT)
|
||||
//.addOptionalTag(forgeTagKey("storage_blocks")); // can't add this because it would include contents from the non-common forge:storage_blocks/amethyst and forge:storage_blocks/quartz, which are not in the c namespace
|
||||
.addOptionalTags(forgeTagKey("storage_blocks/coal"), forgeTagKey("storage_blocks/copper"),
|
||||
forgeTagKey("storage_blocks/diamond"), forgeTagKey("storage_blocks/emerald"),
|
||||
forgeTagKey("storage_blocks/gold"), forgeTagKey("storage_blocks/iron"),
|
||||
forgeTagKey("storage_blocks/lapis"), forgeTagKey("storage_blocks/netherite"),
|
||||
forgeTagKey("storage_blocks/raw_copper"), forgeTagKey("storage_blocks/raw_gold"),
|
||||
forgeTagKey("storage_blocks/raw_iron"), forgeTagKey("storage_blocks/redstone"));
|
||||
tag(STORAGE_BLOCKS_BONE_MEAL).add(Blocks.BONE_BLOCK);
|
||||
tag(STORAGE_BLOCKS_COAL)
|
||||
.add(Blocks.COAL_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/coal"));
|
||||
tag(STORAGE_BLOCKS_COPPER)
|
||||
.add(Blocks.COPPER_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/copper"));
|
||||
tag(STORAGE_BLOCKS_DIAMOND)
|
||||
.add(Blocks.DIAMOND_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/diamond"));
|
||||
tag(STORAGE_BLOCKS_DRIED_KELP).add(Blocks.DRIED_KELP_BLOCK);
|
||||
tag(STORAGE_BLOCKS_EMERALD)
|
||||
.add(Blocks.EMERALD_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/emerald"));
|
||||
tag(STORAGE_BLOCKS_GOLD)
|
||||
.add(Blocks.GOLD_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/gold"));
|
||||
tag(STORAGE_BLOCKS_IRON)
|
||||
.add(Blocks.IRON_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/iron"));
|
||||
tag(STORAGE_BLOCKS_LAPIS)
|
||||
.add(Blocks.LAPIS_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/lapis"));
|
||||
tag(STORAGE_BLOCKS_NETHERITE)
|
||||
.add(Blocks.NETHERITE_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/netherite"));
|
||||
tag(STORAGE_BLOCKS_RAW_COPPER)
|
||||
.add(Blocks.RAW_COPPER_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/raw_copper"));
|
||||
tag(STORAGE_BLOCKS_RAW_GOLD)
|
||||
.add(Blocks.RAW_GOLD_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/raw_gold"));
|
||||
tag(STORAGE_BLOCKS_RAW_IRON)
|
||||
.add(Blocks.RAW_IRON_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/raw_iron"));
|
||||
tag(STORAGE_BLOCKS_REDSTONE)
|
||||
.add(Blocks.REDSTONE_BLOCK)
|
||||
.addOptionalTag(forgeTagKey("storage_blocks/redstone"));
|
||||
tag(STORAGE_BLOCKS_SLIME).add(Blocks.SLIME_BLOCK);
|
||||
tag(STORAGE_BLOCKS_WHEAT).add(Blocks.HAY_BLOCK);
|
||||
tag(Tags.Blocks.STRIPPED_LOGS).add(
|
||||
Blocks.STRIPPED_ACACIA_LOG, Blocks.STRIPPED_BAMBOO_BLOCK, Blocks.STRIPPED_BIRCH_LOG,
|
||||
Blocks.STRIPPED_CHERRY_LOG, Blocks.STRIPPED_DARK_OAK_LOG, Blocks.STRIPPED_JUNGLE_LOG,
|
||||
Blocks.STRIPPED_MANGROVE_LOG, Blocks.STRIPPED_OAK_LOG, Blocks.STRIPPED_SPRUCE_LOG);
|
||||
tag(Tags.Blocks.STRIPPED_WOODS).add(
|
||||
Blocks.STRIPPED_ACACIA_WOOD, Blocks.STRIPPED_BIRCH_WOOD, Blocks.STRIPPED_CHERRY_WOOD,
|
||||
Blocks.STRIPPED_DARK_OAK_WOOD, Blocks.STRIPPED_JUNGLE_WOOD, Blocks.STRIPPED_MANGROVE_WOOD,
|
||||
Blocks.STRIPPED_OAK_WOOD, Blocks.STRIPPED_SPRUCE_WOOD);
|
||||
tag(VILLAGER_JOB_SITES).add(
|
||||
Blocks.BARREL, Blocks.BLAST_FURNACE, Blocks.BREWING_STAND, Blocks.CARTOGRAPHY_TABLE,
|
||||
Blocks.CAULDRON, Blocks.WATER_CAULDRON, Blocks.LAVA_CAULDRON, Blocks.POWDER_SNOW_CAULDRON,
|
||||
Blocks.COMPOSTER, Blocks.FLETCHING_TABLE, Blocks.GRINDSTONE, Blocks.LECTERN,
|
||||
Blocks.LOOM, Blocks.SMITHING_TABLE, Blocks.SMOKER, Blocks.STONECUTTER);
|
||||
|
||||
// Backwards compat definitions for pre-1.21 legacy `forge:` tags.
|
||||
// TODO: Remove backwards compat tag entries in 1.22
|
||||
tag(forgeTagKey("barrels")).addTag(forgeTagKey("barrels/wooden"));
|
||||
tag(forgeTagKey("barrels/wooden")).add(Blocks.BARREL);
|
||||
tag(forgeTagKey("bookshelves")).add(Blocks.BOOKSHELF);
|
||||
tag(forgeTagKey("chests")).addTags(forgeTagKey("chests/ender"), forgeTagKey("chests/trapped"), forgeTagKey("chests/wooden"));
|
||||
tag(forgeTagKey("chests/wooden")).add(Blocks.CHEST, Blocks.TRAPPED_CHEST);
|
||||
tag(forgeTagKey("cobblestone")).addTags(forgeTagKey("cobblestone/normal"), forgeTagKey("cobblestone/infested"), forgeTagKey("cobblestone/mossy"), forgeTagKey("cobblestone/deepslate"));
|
||||
tag(forgeTagKey("glass")).addTags(forgeTagKey("glass/colorless"), forgeTagKey("stained_glass"), forgeTagKey("glass/tinted"));
|
||||
tag(forgeTagKey("glass/colorless")).add(Blocks.GLASS);
|
||||
tag(forgeTagKey("glass/silica")).add(Blocks.GLASS, Blocks.BLACK_STAINED_GLASS, Blocks.BLUE_STAINED_GLASS, Blocks.BROWN_STAINED_GLASS, Blocks.CYAN_STAINED_GLASS, Blocks.GRAY_STAINED_GLASS, Blocks.GREEN_STAINED_GLASS, Blocks.LIGHT_BLUE_STAINED_GLASS, Blocks.LIGHT_GRAY_STAINED_GLASS, Blocks.LIME_STAINED_GLASS, Blocks.MAGENTA_STAINED_GLASS, Blocks.ORANGE_STAINED_GLASS, Blocks.PINK_STAINED_GLASS, Blocks.PURPLE_STAINED_GLASS, Blocks.RED_STAINED_GLASS, Blocks.WHITE_STAINED_GLASS, Blocks.YELLOW_STAINED_GLASS);
|
||||
tag(forgeTagKey("glass/tinted")).add(Blocks.TINTED_GLASS);
|
||||
addColored(tag(forgeTagKey("stained_glass"))::add, forgeTagKey("glass"), "{color}_stained_glass");
|
||||
tag(forgeTagKey("glass_panes")).addTags(forgeTagKey("glass_panes/colorless"), forgeTagKey("stained_glass_panes"));
|
||||
tag(forgeTagKey("glass_panes/colorless")).add(Blocks.GLASS_PANE);
|
||||
addColored(tag(forgeTagKey("stained_glass_panes"))::add, forgeTagKey("glass_panes"), "{color}_stained_glass_pane");
|
||||
tag(forgeTagKey("obsidian")).add(Blocks.OBSIDIAN);
|
||||
tag(forgeTagKey("ores")).addTags(forgeTagKey("ores/coal"), forgeTagKey("ores/copper"), forgeTagKey("ores/diamond"), forgeTagKey("ores/emerald"), forgeTagKey("ores/gold"), forgeTagKey("ores/iron"), forgeTagKey("ores/lapis"), forgeTagKey("ores/redstone"), forgeTagKey("ores/quartz"), forgeTagKey("ores/netherite_scrap"));
|
||||
tag(forgeTagKey("ores/quartz")).add(Blocks.NETHER_QUARTZ_ORE);
|
||||
tag(forgeTagKey("ores/netherite_scrap")).add(Blocks.ANCIENT_DEBRIS);
|
||||
tag(forgeTagKey("sandstone")).add(Blocks.SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.SMOOTH_RED_SANDSTONE);
|
||||
tag(forgeTagKey("stone")).add(Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.INFESTED_STONE, Blocks.STONE, Blocks.POLISHED_ANDESITE, Blocks.POLISHED_DIORITE, Blocks.POLISHED_GRANITE, Blocks.DEEPSLATE, Blocks.POLISHED_DEEPSLATE, Blocks.INFESTED_DEEPSLATE, Blocks.TUFF);
|
||||
tag(forgeTagKey("storage_blocks"))
|
||||
.addTags(forgeTagKey("storage_blocks/amethyst"), forgeTagKey("storage_blocks/coal"), forgeTagKey("storage_blocks/copper"), forgeTagKey("storage_blocks/diamond"), forgeTagKey("storage_blocks/emerald"), forgeTagKey("storage_blocks/gold"), forgeTagKey("storage_blocks/iron"), forgeTagKey("storage_blocks/lapis"), forgeTagKey("storage_blocks/quartz"), forgeTagKey("storage_blocks/raw_copper"), forgeTagKey("storage_blocks/raw_gold"), forgeTagKey("storage_blocks/raw_iron"), forgeTagKey("storage_blocks/redstone"), forgeTagKey("storage_blocks/netherite"));
|
||||
tag(forgeTagKey("storage_blocks/amethyst")).add(Blocks.AMETHYST_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/coal")).add(Blocks.COAL_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/copper")).add(Blocks.COPPER_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/diamond")).add(Blocks.DIAMOND_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/emerald")).add(Blocks.EMERALD_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/gold")).add(Blocks.GOLD_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/iron")).add(Blocks.IRON_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/lapis")).add(Blocks.LAPIS_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/quartz")).add(Blocks.QUARTZ_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/raw_copper")).add(Blocks.RAW_COPPER_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/raw_gold")).add(Blocks.RAW_GOLD_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/raw_iron")).add(Blocks.RAW_IRON_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/redstone")).add(Blocks.REDSTONE_BLOCK);
|
||||
tag(forgeTagKey("storage_blocks/netherite")).add(Blocks.NETHERITE_BLOCK);
|
||||
}
|
||||
|
||||
private void addColored(TagKey<Block> group, String pattern) {
|
||||
@@ -298,19 +81,6 @@ public final class ForgeBlockTagsProvider extends BlockTagsProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private void addColored(Consumer<Block> consumer, TagKey<Block> group, String pattern) {
|
||||
String prefix = group.location().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
for (DyeColor color : DyeColor.values()) {
|
||||
ResourceLocation key = ResourceLocation.fromNamespaceAndPath("minecraft", pattern.replace("{color}", color.getName()));
|
||||
TagKey<Block> tag = getForgeTag(prefix + color.getName());
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(key);
|
||||
if (block == null || block == Blocks.AIR)
|
||||
throw new IllegalStateException("Unknown vanilla block: " + key.toString());
|
||||
tag(tag).add(block);
|
||||
consumer.accept(block);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addColoredTags(Consumer<TagKey<Block>> consumer, TagKey<Block> group) {
|
||||
String prefix = group.location().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
for (var color : DyeColor.values()) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import static net.minecraftforge.common.Tags.Enchantments.*;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ForgeEnchantmentTagsProvider extends EnchantmentTagsProvider {
|
||||
public final class ForgeEnchantmentTagsProvider extends net.minecraft.data.tags.EnchantmentTagsProvider {
|
||||
public ForgeEnchantmentTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, ExistingFileHelper existingFileHelper) {
|
||||
super(output, lookupProvider, "forge", existingFileHelper);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,9 @@ public final class ForgeFluidTagsProvider extends FluidTagsProvider {
|
||||
public void addTags(HolderLookup.Provider lookupProvider) {
|
||||
tag(WATER).add(net.minecraft.world.level.material.Fluids.WATER).add(net.minecraft.world.level.material.Fluids.FLOWING_WATER);
|
||||
tag(LAVA).add(net.minecraft.world.level.material.Fluids.LAVA).add(net.minecraft.world.level.material.Fluids.FLOWING_LAVA);
|
||||
tag(MILK).addOptional(ForgeMod.MILK.getId()).addOptional(ForgeMod.FLOWING_MILK.getId());
|
||||
tag(MILK)
|
||||
.addOptional(ForgeMod.MILK.getKey().location())
|
||||
.addOptional(ForgeMod.FLOWING_MILK.getKey().location());
|
||||
tag(GASEOUS);
|
||||
tag(HONEY);
|
||||
tag(POTION);
|
||||
@@ -41,8 +43,8 @@ public final class ForgeFluidTagsProvider extends FluidTagsProvider {
|
||||
// Backwards compat definitions for pre-1.21 legacy `forge:` tags.
|
||||
// TODO: Remove backwards compat tag entries in 1.22
|
||||
tag(forgeTagKey("milk"))
|
||||
.addOptional(ForgeMod.MILK.getId())
|
||||
.addOptional(ForgeMod.FLOWING_MILK.getId());
|
||||
.addOptional(ForgeMod.MILK.getKey().location())
|
||||
.addOptional(ForgeMod.FLOWING_MILK.getKey().location());
|
||||
}
|
||||
|
||||
private static TagKey<Fluid> forgeTagKey(String path) {
|
||||
|
||||
@@ -8,9 +8,9 @@ package net.minecraftforge.common.data;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.tags.ItemTagsProvider;
|
||||
import net.minecraft.data.tags.TagAppender;
|
||||
import net.minecraft.data.tags.VanillaItemTagsProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
@@ -26,18 +26,21 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
public ForgeItemTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, CompletableFuture<TagLookup<Block>> blockTagProvider, ExistingFileHelper existingFileHelper) {
|
||||
super(output, lookupProvider, blockTagProvider, "forge", existingFileHelper);
|
||||
public final class ForgeItemTagsProvider extends VanillaItemTagsProvider {
|
||||
public ForgeItemTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, ExistingFileHelper existingFileHelper) {
|
||||
super(output, lookupProvider, "forge", existingFileHelper);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "removal" })
|
||||
@Override
|
||||
public void addTags(HolderLookup.Provider lookupProvider) {
|
||||
copy(Tags.Blocks.BARRELS, Tags.Items.BARRELS);
|
||||
copy(Tags.Blocks.BARRELS_WOODEN, Tags.Items.BARRELS_WOODEN);
|
||||
(new ForgeBlockItemTagsProvider() {
|
||||
@Override
|
||||
protected TagAppender<Block, Block> tag(TagKey<Block> p_409856_, TagKey<Item> p_406371_) {
|
||||
return new VanillaItemTagsProvider.BlockToItemConverter(ForgeItemTagsProvider.this.tag(p_406371_));
|
||||
}
|
||||
}).run();
|
||||
tag(Tags.Items.BONES).add(Items.BONE);
|
||||
copy(Tags.Blocks.BOOKSHELVES, Tags.Items.BOOKSHELVES);
|
||||
tag(Tags.Items.BRICKS).addTags(Tags.Items.BRICKS_NORMAL, Tags.Items.BRICKS_NETHER);
|
||||
tag(Tags.Items.BRICKS_NORMAL).add(Items.BRICK);
|
||||
tag(Tags.Items.BRICKS_NETHER).add(Items.NETHER_BRICK);
|
||||
@@ -48,20 +51,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(Tags.Items.BUCKETS_POWDER_SNOW).add(Items.POWDER_SNOW_BUCKET);
|
||||
tag(Tags.Items.BUCKETS_ENTITY_WATER).add(Items.AXOLOTL_BUCKET, Items.COD_BUCKET, Items.PUFFERFISH_BUCKET, Items.TADPOLE_BUCKET, Items.TROPICAL_FISH_BUCKET, Items.SALMON_BUCKET);
|
||||
tag(Tags.Items.BUCKETS).addTags(Tags.Items.BUCKETS_EMPTY, Tags.Items.BUCKETS_WATER, Tags.Items.BUCKETS_LAVA, Tags.Items.BUCKETS_MILK, Tags.Items.BUCKETS_POWDER_SNOW, Tags.Items.BUCKETS_ENTITY_WATER);
|
||||
copy(Tags.Blocks.BUDDING_BLOCKS, Tags.Items.BUDDING_BLOCKS);
|
||||
copy(Tags.Blocks.BUDS, Tags.Items.BUDS);
|
||||
copy(Tags.Blocks.CHAINS, Tags.Items.CHAINS);
|
||||
copy(Tags.Blocks.CHESTS, Tags.Items.CHESTS);
|
||||
copy(Tags.Blocks.CHESTS_ENDER, Tags.Items.CHESTS_ENDER);
|
||||
copy(Tags.Blocks.CHESTS_TRAPPED, Tags.Items.CHESTS_TRAPPED);
|
||||
copy(Tags.Blocks.CHESTS_WOODEN, Tags.Items.CHESTS_WOODEN);
|
||||
copy(Tags.Blocks.CLUSTERS, Tags.Items.CLUSTERS);
|
||||
copy(Tags.Blocks.COBBLESTONES, Tags.Items.COBBLESTONES);
|
||||
copy(Tags.Blocks.COBBLESTONE_NORMAL, Tags.Items.COBBLESTONE_NORMAL);
|
||||
copy(Tags.Blocks.COBBLESTONE_INFESTED, Tags.Items.COBBLESTONE_INFESTED);
|
||||
copy(Tags.Blocks.COBBLESTONE_MOSSY, Tags.Items.COBBLESTONE_MOSSY);
|
||||
copy(Tags.Blocks.COBBLESTONE_DEEPSLATE, Tags.Items.COBBLESTONE_DEEPSLATE);
|
||||
copy(Tags.Blocks.CONCRETES, Tags.Items.CONCRETES);
|
||||
tag(Tags.Items.CONCRETE_POWDERS)
|
||||
.add(Items.WHITE_CONCRETE_POWDER, Items.ORANGE_CONCRETE_POWDER, Items.MAGENTA_CONCRETE_POWDER,
|
||||
Items.LIGHT_BLUE_CONCRETE_POWDER, Items.YELLOW_CONCRETE_POWDER, Items.LIME_CONCRETE_POWDER,
|
||||
@@ -119,22 +108,13 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
addColoredTags(tag(Tags.Items.DYES)::addTags, Tags.Items.DYES);
|
||||
tag(Tags.Items.EGGS).add(Items.EGG); // forge:eggs
|
||||
tag(Tags.Items.ENCHANTING_FUELS).addTag(Tags.Items.GEMS_LAPIS); // forge:enchanting_fuels
|
||||
copy(Tags.Blocks.END_STONES, Tags.Items.END_STONES);
|
||||
tag(Tags.Items.ENDER_PEARLS)
|
||||
.add(Items.ENDER_PEARL)
|
||||
.addOptionalTag(forgeItemTagKey("ender_pearls"));
|
||||
tag(Tags.Items.FEATHERS)
|
||||
.add(Items.FEATHER)
|
||||
.addOptionalTag(forgeItemTagKey("feathers"));
|
||||
copy(Tags.Blocks.FENCE_GATES, Tags.Items.FENCE_GATES);
|
||||
copy(Tags.Blocks.FENCE_GATES_WOODEN, Tags.Items.FENCE_GATES_WOODEN);
|
||||
copy(Tags.Blocks.FENCES, Tags.Items.FENCES);
|
||||
copy(Tags.Blocks.FENCES_NETHER_BRICK, Tags.Items.FENCES_NETHER_BRICK);
|
||||
copy(Tags.Blocks.FENCES_WOODEN, Tags.Items.FENCES_WOODEN);
|
||||
tag(Tags.Items.FERTILIZERS).add(Items.BONE_MEAL);
|
||||
copy(Tags.Blocks.FLOWERS_SMALL, Tags.Items.FLOWERS_SMALL);
|
||||
copy(Tags.Blocks.FLOWERS_TALL, Tags.Items.FLOWERS_TALL);
|
||||
copy(Tags.Blocks.FLOWERS, Tags.Items.FLOWERS);
|
||||
tag(Tags.Items.FOODS_FRUIT).add(Items.APPLE, Items.GOLDEN_APPLE, Items.ENCHANTED_GOLDEN_APPLE, Items.CHORUS_FRUIT, Items.MELON_SLICE);
|
||||
tag(Tags.Items.FOODS_VEGETABLE).add(Items.CARROT, Items.GOLDEN_CARROT, Items.POTATO, Items.BEETROOT);
|
||||
tag(Tags.Items.FOODS_BERRY).add(Items.SWEET_BERRIES, Items.GLOW_BERRIES);
|
||||
@@ -183,14 +163,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(Tags.Items.GEMS_QUARTZ)
|
||||
.add(Items.QUARTZ)
|
||||
.addOptionalTag(forgeItemTagKey("gems/quartz"));
|
||||
copy(Tags.Blocks.GLASS_BLOCKS, Tags.Items.GLASS_BLOCKS);
|
||||
copy(Tags.Blocks.GLASS_BLOCKS_COLORLESS, Tags.Items.GLASS_BLOCKS_COLORLESS);
|
||||
copy(Tags.Blocks.GLASS_BLOCKS_TINTED, Tags.Items.GLASS_BLOCKS_TINTED);
|
||||
copy(Tags.Blocks.GLASS_BLOCKS_CHEAP, Tags.Items.GLASS_BLOCKS_CHEAP);
|
||||
copy(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES);
|
||||
copy(Tags.Blocks.GLASS_PANES_COLORLESS, Tags.Items.GLASS_PANES_COLORLESS);
|
||||
copy(Tags.Blocks.GLAZED_TERRACOTTAS, Tags.Items.GLAZED_TERRACOTTAS);
|
||||
copy(Tags.Blocks.GRAVEL, Tags.Items.GRAVEL);
|
||||
tag(Tags.Items.GUNPOWDER).add(Items.GUNPOWDER); // forge:gunpowder
|
||||
tag(Tags.Items.HIDDEN_FROM_RECIPE_VIEWERS);
|
||||
tag(Tags.Items.INGOTS)
|
||||
@@ -222,7 +194,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(Tags.Items.NETHER_STARS)
|
||||
.add(Items.NETHER_STAR)
|
||||
.addOptionalTag(forgeItemTagKey("nether_stars"));
|
||||
copy(Tags.Blocks.NETHERRACK, Tags.Items.NETHERRACK);
|
||||
tag(Tags.Items.NUGGETS)
|
||||
.addTags(Tags.Items.NUGGETS_GOLD, Tags.Items.NUGGETS_IRON)
|
||||
.addOptionalTag(forgeItemTagKey("nuggets"));
|
||||
@@ -232,35 +203,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(Tags.Items.NUGGETS_GOLD)
|
||||
.add(Items.GOLD_NUGGET)
|
||||
.addOptionalTag(forgeItemTagKey("nuggets/gold"));
|
||||
copy(Tags.Blocks.OBSIDIANS, Tags.Items.OBSIDIANS);
|
||||
copy(Tags.Blocks.OBSIDIANS_NORMAL, Tags.Items.OBSIDIANS_NORMAL);
|
||||
copy(Tags.Blocks.OBSIDIANS_CRYING, Tags.Items.OBSIDIANS_CRYING);
|
||||
copy(Tags.Blocks.ORE_BEARING_GROUND_DEEPSLATE, Tags.Items.ORE_BEARING_GROUND_DEEPSLATE);
|
||||
copy(Tags.Blocks.ORE_BEARING_GROUND_NETHERRACK, Tags.Items.ORE_BEARING_GROUND_NETHERRACK);
|
||||
copy(Tags.Blocks.ORE_BEARING_GROUND_STONE, Tags.Items.ORE_BEARING_GROUND_STONE);
|
||||
copy(Tags.Blocks.ORE_RATES_DENSE, Tags.Items.ORE_RATES_DENSE);
|
||||
copy(Tags.Blocks.ORE_RATES_SINGULAR, Tags.Items.ORE_RATES_SINGULAR);
|
||||
copy(Tags.Blocks.ORE_RATES_SPARSE, Tags.Items.ORE_RATES_SPARSE);
|
||||
copy(Tags.Blocks.ORES, Tags.Items.ORES);
|
||||
copy(Tags.Blocks.ORES_COAL, Tags.Items.ORES_COAL);
|
||||
copy(Tags.Blocks.ORES_COPPER, Tags.Items.ORES_COPPER);
|
||||
copy(Tags.Blocks.ORES_DIAMOND, Tags.Items.ORES_DIAMOND);
|
||||
copy(Tags.Blocks.ORES_EMERALD, Tags.Items.ORES_EMERALD);
|
||||
copy(Tags.Blocks.ORES_GOLD, Tags.Items.ORES_GOLD);
|
||||
copy(Tags.Blocks.ORES_IRON, Tags.Items.ORES_IRON);
|
||||
copy(Tags.Blocks.ORES_LAPIS, Tags.Items.ORES_LAPIS);
|
||||
copy(Tags.Blocks.ORES_QUARTZ, Tags.Items.ORES_QUARTZ);
|
||||
copy(Tags.Blocks.ORES_REDSTONE, Tags.Items.ORES_REDSTONE);
|
||||
copy(Tags.Blocks.ORES_NETHERITE_SCRAP, Tags.Items.ORES_NETHERITE_SCRAP);
|
||||
copy(Tags.Blocks.ORES_IN_GROUND_DEEPSLATE, Tags.Items.ORES_IN_GROUND_DEEPSLATE);
|
||||
copy(Tags.Blocks.ORES_IN_GROUND_NETHERRACK, Tags.Items.ORES_IN_GROUND_NETHERRACK);
|
||||
copy(Tags.Blocks.ORES_IN_GROUND_STONE, Tags.Items.ORES_IN_GROUND_STONE);
|
||||
copy(Tags.Blocks.PLAYER_WORKSTATIONS_CRAFTING_TABLES, Tags.Items.PLAYER_WORKSTATIONS_CRAFTING_TABLES);
|
||||
copy(Tags.Blocks.PLAYER_WORKSTATIONS_FURNACES, Tags.Items.PLAYER_WORKSTATIONS_FURNACES);
|
||||
copy(Tags.Blocks.PUMPKINS, Tags.Items.PUMPKINS);
|
||||
copy(Tags.Blocks.PUMPKINS_NORMAL, Tags.Items.PUMPKINS_NORMAL);
|
||||
copy(Tags.Blocks.PUMPKINS_CARVED, Tags.Items.PUMPKINS_CARVED);
|
||||
copy(Tags.Blocks.PUMPKINS_JACK_O_LANTERNS, Tags.Items.PUMPKINS_JACK_O_LANTERNS);
|
||||
tag(Tags.Items.RAW_MATERIALS)
|
||||
.addTags(Tags.Items.RAW_MATERIALS_COPPER, Tags.Items.RAW_MATERIALS_GOLD, Tags.Items.RAW_MATERIALS_IRON)
|
||||
.addOptionalTag(forgeItemTagKey("raw_materials"));
|
||||
@@ -283,19 +225,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(Tags.Items.RODS_WOODEN)
|
||||
.add(Items.STICK)
|
||||
.addOptionalTag(forgeItemTagKey("rods/wooden"));
|
||||
copy(Tags.Blocks.ROPES, Tags.Items.ROPES);
|
||||
copy(Tags.Blocks.SAND, Tags.Items.SAND); // forge:sand
|
||||
copy(Tags.Blocks.SAND_COLORLESS, Tags.Items.SAND_COLORLESS); // forge:sand/colorless
|
||||
copy(Tags.Blocks.SAND_RED, Tags.Items.SAND_RED); // forge:sand/red
|
||||
copy(Tags.Blocks.SANDSTONE_BLOCKS, Tags.Items.SANDSTONE_BLOCKS);
|
||||
copy(Tags.Blocks.SANDSTONE_SLABS, Tags.Items.SANDSTONE_SLABS);
|
||||
copy(Tags.Blocks.SANDSTONE_STAIRS, Tags.Items.SANDSTONE_STAIRS);
|
||||
copy(Tags.Blocks.SANDSTONE_RED_BLOCKS, Tags.Items.SANDSTONE_RED_BLOCKS);
|
||||
copy(Tags.Blocks.SANDSTONE_RED_SLABS, Tags.Items.SANDSTONE_RED_SLABS);
|
||||
copy(Tags.Blocks.SANDSTONE_RED_STAIRS, Tags.Items.SANDSTONE_RED_STAIRS);
|
||||
copy(Tags.Blocks.SANDSTONE_UNCOLORED_BLOCKS, Tags.Items.SANDSTONE_UNCOLORED_BLOCKS);
|
||||
copy(Tags.Blocks.SANDSTONE_UNCOLORED_SLABS, Tags.Items.SANDSTONE_UNCOLORED_SLABS);
|
||||
copy(Tags.Blocks.SANDSTONE_UNCOLORED_STAIRS, Tags.Items.SANDSTONE_UNCOLORED_STAIRS);
|
||||
tag(Tags.Items.SEEDS).addTags(Tags.Items.SEEDS_BEETROOT, Tags.Items.SEEDS_MELON, Tags.Items.SEEDS_PUMPKIN, Tags.Items.SEEDS_WHEAT);
|
||||
tag(Tags.Items.SEEDS_BEETROOT).add(Items.BEETROOT_SEEDS);
|
||||
tag(Tags.Items.SEEDS_MELON).add(Items.MELON_SEEDS);
|
||||
@@ -311,29 +240,9 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
Items.LIGHT_GRAY_SHULKER_BOX, Items.CYAN_SHULKER_BOX, Items.PURPLE_SHULKER_BOX,
|
||||
Items.BLUE_SHULKER_BOX, Items.BROWN_SHULKER_BOX, Items.GREEN_SHULKER_BOX,
|
||||
Items.RED_SHULKER_BOX, Items.BLACK_SHULKER_BOX);
|
||||
copy(Tags.Blocks.STONES, Tags.Items.STONES);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS, Tags.Items.STORAGE_BLOCKS);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_BONE_MEAL, Tags.Items.STORAGE_BLOCKS_BONE_MEAL);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_COAL, Tags.Items.STORAGE_BLOCKS_COAL);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_COPPER, Tags.Items.STORAGE_BLOCKS_COPPER);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_DIAMOND, Tags.Items.STORAGE_BLOCKS_DIAMOND);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_DRIED_KELP, Tags.Items.STORAGE_BLOCKS_DRIED_KELP);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_EMERALD, Tags.Items.STORAGE_BLOCKS_EMERALD);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_GOLD, Tags.Items.STORAGE_BLOCKS_GOLD);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_IRON, Tags.Items.STORAGE_BLOCKS_IRON);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_LAPIS, Tags.Items.STORAGE_BLOCKS_LAPIS);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_NETHERITE, Tags.Items.STORAGE_BLOCKS_NETHERITE);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_RAW_COPPER, Tags.Items.STORAGE_BLOCKS_RAW_COPPER);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_RAW_GOLD, Tags.Items.STORAGE_BLOCKS_RAW_GOLD);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_RAW_IRON, Tags.Items.STORAGE_BLOCKS_RAW_IRON);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, Tags.Items.STORAGE_BLOCKS_REDSTONE);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_SLIME, Tags.Items.STORAGE_BLOCKS_SLIME);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_WHEAT, Tags.Items.STORAGE_BLOCKS_WHEAT);
|
||||
tag(Tags.Items.STRINGS)
|
||||
.add(Items.STRING)
|
||||
.addOptionalTag(forgeItemTagKey("strings"));
|
||||
copy(Tags.Blocks.STRIPPED_LOGS, Tags.Items.STRIPPED_LOGS);
|
||||
copy(Tags.Blocks.STRIPPED_WOODS, Tags.Items.STRIPPED_WOODS);
|
||||
tag(Tags.Items.VILLAGER_JOB_SITES).add(
|
||||
Items.BARREL, Items.BLAST_FURNACE, Items.BREWING_STAND, Items.CARTOGRAPHY_TABLE,
|
||||
Items.CAULDRON, Items.COMPOSTER, Items.FLETCHING_TABLE, Items.GRINDSTONE,
|
||||
@@ -374,21 +283,9 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
.addOptionalTag(forgeItemTagKey("armors"));
|
||||
tag(Tags.Items.ENCHANTABLES).addTags(ItemTags.ARMOR_ENCHANTABLE, ItemTags.EQUIPPABLE_ENCHANTABLE, ItemTags.WEAPON_ENCHANTABLE, ItemTags.SWORD_ENCHANTABLE, ItemTags.MINING_ENCHANTABLE, ItemTags.MINING_LOOT_ENCHANTABLE, ItemTags.FISHING_ENCHANTABLE, ItemTags.TRIDENT_ENCHANTABLE, ItemTags.BOW_ENCHANTABLE, ItemTags.CROSSBOW_ENCHANTABLE, ItemTags.MACE_ENCHANTABLE, ItemTags.FIRE_ASPECT_ENCHANTABLE, ItemTags.DURABILITY_ENCHANTABLE, ItemTags.VANISHING_ENCHANTABLE);
|
||||
|
||||
tag(forgeItemTagKey("bones")).add(Items.BONE);
|
||||
// Backwards compat definitions for pre-1.21 legacy `forge:` tags.
|
||||
// TODO: Remove backwards compat tag entries in 1.22
|
||||
copy(forgeBlockTagKey("barrels"), forgeItemTagKey("barrels"));
|
||||
copy(forgeBlockTagKey("barrels/wooden"), forgeItemTagKey("barrels/wooden"));
|
||||
tag(forgeItemTagKey("bones")).add(Items.BONE);
|
||||
copy(forgeBlockTagKey("bookshelves"), forgeItemTagKey("bookshelves"));
|
||||
copy(forgeBlockTagKey("chests"), forgeItemTagKey("chests"));
|
||||
copy(forgeBlockTagKey("chests/ender"), forgeItemTagKey("chests/ender"));
|
||||
copy(forgeBlockTagKey("chests/trapped"), forgeItemTagKey("chests/trapped"));
|
||||
copy(forgeBlockTagKey("chests/wooden"), forgeItemTagKey("chests/wooden"));
|
||||
copy(forgeBlockTagKey("cobblestone"), forgeItemTagKey("cobblestone"));
|
||||
copy(forgeBlockTagKey("cobblestone/normal"), forgeItemTagKey("cobblestone/normal"));
|
||||
copy(forgeBlockTagKey("cobblestone/infested"), forgeItemTagKey("cobblestone/infested"));
|
||||
copy(forgeBlockTagKey("cobblestone/mossy"), forgeItemTagKey("cobblestone/mossy"));
|
||||
copy(forgeBlockTagKey("cobblestone/deepslate"), forgeItemTagKey("cobblestone/deepslate"));
|
||||
tag(forgeItemTagKey("crops"))
|
||||
.addTags(forgeItemTagKey("crops/beetroot"), forgeItemTagKey("crops/carrot"), forgeItemTagKey("crops/nether_wart"),
|
||||
forgeItemTagKey("crops/potato"), forgeItemTagKey("crops/wheat"));
|
||||
@@ -405,14 +302,8 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
addColored(tag(forgeItemTagKey("dyes"))::addTags, forgeItemTagKey("dyes"), "{color}_dye");
|
||||
tag(forgeItemTagKey("eggs")).add(Items.EGG);
|
||||
tag(forgeItemTagKey("enchanting_fuels")).addTag(forgeItemTagKey("gems/lapis"));
|
||||
copy(forgeBlockTagKey("end_stones"), forgeItemTagKey("end_stones"));
|
||||
tag(forgeItemTagKey("ender_pearls")).add(Items.ENDER_PEARL);
|
||||
tag(forgeItemTagKey("feathers")).add(Items.FEATHER);
|
||||
copy(forgeBlockTagKey("fence_gates"), forgeItemTagKey("fence_gates"));
|
||||
copy(forgeBlockTagKey("fence_gates/wooden"), forgeItemTagKey("fence_gates/wooden"));
|
||||
copy(forgeBlockTagKey("fences"), forgeItemTagKey("fences"));
|
||||
copy(forgeBlockTagKey("fences/nether_brick"), forgeItemTagKey("fences/nether_brick"));
|
||||
copy(forgeBlockTagKey("fences/wooden"), forgeItemTagKey("fences/wooden"));
|
||||
tag(forgeItemTagKey("gems"))
|
||||
.addTags(forgeItemTagKey("gems/amethyst"), forgeItemTagKey("gems/diamond"), forgeItemTagKey("gems/emerald"),
|
||||
forgeItemTagKey("gems/lapis"), forgeItemTagKey("gems/prismarine"), forgeItemTagKey("gems/quartz"));
|
||||
@@ -422,14 +313,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(forgeItemTagKey("gems/lapis")).add(Items.LAPIS_LAZULI);
|
||||
tag(forgeItemTagKey("gems/prismarine")).add(Items.PRISMARINE_CRYSTALS);
|
||||
tag(forgeItemTagKey("gems/quartz")).add(Items.QUARTZ);
|
||||
copy(forgeBlockTagKey("glass"), forgeItemTagKey("glass"));
|
||||
copy(forgeBlockTagKey("glass/tinted"), forgeItemTagKey("glass/tinted"));
|
||||
copy(forgeBlockTagKey("glass/silica"), forgeItemTagKey("glass/silica"));
|
||||
copyColored(forgeBlockTagKey("glass"), forgeItemTagKey("glass"));
|
||||
copy(forgeBlockTagKey("glass_panes"), forgeItemTagKey("glass_panes"));
|
||||
copyColored(forgeBlockTagKey("glass_panes"), forgeItemTagKey("glass_panes"));
|
||||
copy(forgeBlockTagKey("glass_panes/colorless"), forgeItemTagKey("glass_panes/colorless"));
|
||||
copy(forgeBlockTagKey("gravel"), forgeItemTagKey("gravel"));
|
||||
tag(forgeItemTagKey("gunpowder")).add(Items.GUNPOWDER);
|
||||
tag(forgeItemTagKey("heads")).add(Items.CREEPER_HEAD, Items.DRAGON_HEAD, Items.PLAYER_HEAD, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.ZOMBIE_HEAD);
|
||||
tag(forgeItemTagKey("ingots"))
|
||||
@@ -444,31 +327,9 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(forgeItemTagKey("leather")).add(Items.LEATHER);
|
||||
tag(forgeItemTagKey("mushrooms")).add(Items.BROWN_MUSHROOM, Items.RED_MUSHROOM);
|
||||
tag(forgeItemTagKey("nether_stars")).add(Items.NETHER_STAR);
|
||||
copy(forgeBlockTagKey("netherrack"), forgeItemTagKey("netherrack"));
|
||||
tag(forgeItemTagKey("nuggets")).addTags(forgeItemTagKey("nuggets/iron"), forgeItemTagKey("nuggets/gold"));
|
||||
tag(forgeItemTagKey("nuggets/iron")).add(Items.IRON_NUGGET);
|
||||
tag(forgeItemTagKey("nuggets/gold")).add(Items.GOLD_NUGGET);
|
||||
copy(forgeBlockTagKey("obsidian"), forgeItemTagKey("obsidian"));
|
||||
copy(Tags.Blocks.ORE_BEARING_GROUND_DEEPSLATE, Tags.Items.ORE_BEARING_GROUND_DEEPSLATE);
|
||||
copy(Tags.Blocks.ORE_BEARING_GROUND_NETHERRACK, Tags.Items.ORE_BEARING_GROUND_NETHERRACK);
|
||||
copy(Tags.Blocks.ORE_BEARING_GROUND_STONE, Tags.Items.ORE_BEARING_GROUND_STONE);
|
||||
copy(Tags.Blocks.ORE_RATES_DENSE, Tags.Items.ORE_RATES_DENSE);
|
||||
copy(Tags.Blocks.ORE_RATES_SINGULAR, Tags.Items.ORE_RATES_SINGULAR);
|
||||
copy(Tags.Blocks.ORE_RATES_SPARSE, Tags.Items.ORE_RATES_SPARSE);
|
||||
copy(forgeBlockTagKey("ores"), forgeItemTagKey("ores"));
|
||||
copy(Tags.Blocks.ORES_COAL, Tags.Items.ORES_COAL);
|
||||
copy(Tags.Blocks.ORES_COPPER, Tags.Items.ORES_COPPER);
|
||||
copy(Tags.Blocks.ORES_DIAMOND, Tags.Items.ORES_DIAMOND);
|
||||
copy(Tags.Blocks.ORES_EMERALD, Tags.Items.ORES_EMERALD);
|
||||
copy(Tags.Blocks.ORES_GOLD, Tags.Items.ORES_GOLD);
|
||||
copy(Tags.Blocks.ORES_IRON, Tags.Items.ORES_IRON);
|
||||
copy(Tags.Blocks.ORES_LAPIS, Tags.Items.ORES_LAPIS);
|
||||
copy(forgeBlockTagKey("ores/quartz"), forgeItemTagKey("ores/quartz"));
|
||||
copy(Tags.Blocks.ORES_REDSTONE, Tags.Items.ORES_REDSTONE);
|
||||
copy(forgeBlockTagKey("ores/netherite_scrap"), forgeItemTagKey("ores/netherite_scrap"));
|
||||
copy(Tags.Blocks.ORES_IN_GROUND_DEEPSLATE, Tags.Items.ORES_IN_GROUND_DEEPSLATE);
|
||||
copy(Tags.Blocks.ORES_IN_GROUND_NETHERRACK, Tags.Items.ORES_IN_GROUND_NETHERRACK);
|
||||
copy(Tags.Blocks.ORES_IN_GROUND_STONE, Tags.Items.ORES_IN_GROUND_STONE);
|
||||
tag(forgeItemTagKey("raw_materials")).addTags(forgeItemTagKey("raw_materials/copper"), forgeItemTagKey("raw_materials/gold"), forgeItemTagKey("raw_materials/iron"));
|
||||
tag(forgeItemTagKey("raw_materials/copper")).add(Items.RAW_COPPER);
|
||||
tag(forgeItemTagKey("raw_materials/gold")).add(Items.RAW_GOLD);
|
||||
@@ -476,10 +337,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(forgeItemTagKey("rods")).addTags(forgeItemTagKey("rods/blaze"), forgeItemTagKey("rods/wooden"));
|
||||
tag(forgeItemTagKey("rods/blaze")).add(Items.BLAZE_ROD);
|
||||
tag(forgeItemTagKey("rods/wooden")).add(Items.STICK);
|
||||
copy(Tags.Blocks.SAND, Tags.Items.SAND);
|
||||
copy(Tags.Blocks.SAND_COLORLESS, Tags.Items.SAND_COLORLESS);
|
||||
copy(Tags.Blocks.SAND_RED, Tags.Items.SAND_RED);
|
||||
copy(forgeBlockTagKey("sandstone"), forgeItemTagKey("sandstone"));
|
||||
tag(Tags.Items.SEEDS).addTags(Tags.Items.SEEDS_BEETROOT, Tags.Items.SEEDS_MELON, Tags.Items.SEEDS_PUMPKIN, Tags.Items.SEEDS_WHEAT);
|
||||
tag(Tags.Items.SEEDS_BEETROOT).add(Items.BEETROOT_SEEDS);
|
||||
tag(Tags.Items.SEEDS_MELON).add(Items.MELON_SEEDS);
|
||||
@@ -487,24 +344,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
tag(Tags.Items.SEEDS_WHEAT).add(Items.WHEAT_SEEDS);
|
||||
tag(forgeItemTagKey("shears")).add(Items.SHEARS); // yes, it's forge:shears not forge:tools/shears
|
||||
tag(forgeItemTagKey("slimeballs")).add(Items.SLIME_BALL);
|
||||
copy(Tags.Blocks.STAINED_GLASS, Tags.Items.STAINED_GLASS);
|
||||
copy(Tags.Blocks.STAINED_GLASS_PANES, Tags.Items.STAINED_GLASS_PANES);
|
||||
copy(forgeBlockTagKey("stone"), forgeItemTagKey("stone"));
|
||||
copy(forgeBlockTagKey("storage_blocks"), forgeItemTagKey("storage_blocks"));
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_AMETHYST, Tags.Items.STORAGE_BLOCKS_AMETHYST);
|
||||
copy(forgeBlockTagKey("storage_blocks/coal"), forgeItemTagKey("storage_blocks/coal"));
|
||||
copy(forgeBlockTagKey("storage_blocks/copper"), forgeItemTagKey("storage_blocks/copper"));
|
||||
copy(forgeBlockTagKey("storage_blocks/diamond"), forgeItemTagKey("storage_blocks/diamond"));
|
||||
copy(forgeBlockTagKey("storage_blocks/emerald"), forgeItemTagKey("storage_blocks/emerald"));
|
||||
copy(forgeBlockTagKey("storage_blocks/gold"), forgeItemTagKey("storage_blocks/gold"));
|
||||
copy(forgeBlockTagKey("storage_blocks/iron"), forgeItemTagKey("storage_blocks/iron"));
|
||||
copy(forgeBlockTagKey("storage_blocks/lapis"), forgeItemTagKey("storage_blocks/lapis"));
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_QUARTZ, Tags.Items.STORAGE_BLOCKS_QUARTZ);
|
||||
copy(forgeBlockTagKey("storage_blocks/redstone"), forgeItemTagKey("storage_blocks/redstone"));
|
||||
copy(forgeBlockTagKey("storage_blocks/raw_copper"), forgeItemTagKey("storage_blocks/raw_copper"));
|
||||
copy(forgeBlockTagKey("storage_blocks/raw_gold"), forgeItemTagKey("storage_blocks/raw_gold"));
|
||||
copy(forgeBlockTagKey("storage_blocks/raw_iron"), forgeItemTagKey("storage_blocks/raw_iron"));
|
||||
copy(forgeBlockTagKey("storage_blocks/netherite"), forgeItemTagKey("storage_blocks/netherite"));
|
||||
tag(forgeItemTagKey("string")).add(Items.STRING);
|
||||
tag(forgeItemTagKey("tools/shields")).add(Items.SHIELD);
|
||||
tag(forgeItemTagKey("tools/bows")).add(Items.BOW);
|
||||
@@ -546,17 +385,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private void copyColored(TagKey<Block> blockGroup, TagKey<Item> itemGroup) {
|
||||
String blockPre = blockGroup.location().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
String itemPre = itemGroup.location().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
for (DyeColor color : DyeColor.values()) {
|
||||
TagKey<Block> from = getForgeBlockTag(blockPre + color.getName());
|
||||
TagKey<Item> to = getForgeItemTag(itemPre + color.getName());
|
||||
copy(from, to);
|
||||
}
|
||||
copy(getForgeBlockTag(blockPre + "colorless"), getForgeItemTag(itemPre + "colorless"));
|
||||
}
|
||||
|
||||
private static void addColoredTags(Consumer<TagKey<Item>> consumer, TagKey<Item> group) {
|
||||
String prefix = group.location().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
for (DyeColor color : DyeColor.values()) {
|
||||
@@ -565,16 +393,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static TagKey<Block> getForgeBlockTag(String name) {
|
||||
try {
|
||||
name = name.toUpperCase(Locale.ENGLISH);
|
||||
return (TagKey<Block>) Tags.Blocks.class.getDeclaredField(name).get(null);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
||||
throw new IllegalStateException(Tags.Blocks.class.getName() + " is missing tag name: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static TagKey<Item> getForgeItemTag(String name) {
|
||||
try {
|
||||
@@ -589,10 +407,6 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider {
|
||||
return ResourceLocation.fromNamespaceAndPath("forge", path);
|
||||
}
|
||||
|
||||
private static TagKey<Block> forgeBlockTagKey(String path) {
|
||||
return BlockTags.create(forgeRl(path));
|
||||
}
|
||||
|
||||
private static TagKey<Item> forgeItemTagKey(String path) {
|
||||
return ItemTags.create(forgeRl(path));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -15,6 +14,7 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.storage.ValueInput;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
@@ -31,15 +31,15 @@ public interface IForgeBlockEntity extends ICapabilityProvider {
|
||||
|
||||
/**
|
||||
* Called when you receive a TileEntityData packet for the location this TileEntity is currently in. On the client,
|
||||
* the NetworkManager will always be the remote server. On the server, it will be whomever is responsible for
|
||||
* the Connection will always be the remote server. On the server, it will be whomever is responsible for
|
||||
* sending the packet.
|
||||
*
|
||||
* @param connection The Connection the packet originated from
|
||||
* @param pkt The data packet
|
||||
* @param data The data from the packet, with registry access context
|
||||
* @param lookup The holder lookup provider
|
||||
*/
|
||||
default void onDataPacket(Connection connection, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider lookup) {
|
||||
this.self().loadWithComponents(pkt.getTag(), lookup);
|
||||
default void onDataPacket(Connection connection, ValueInput data, HolderLookup.Provider lookup) {
|
||||
this.self().loadWithComponents(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,8 +49,8 @@ public interface IForgeBlockEntity extends ICapabilityProvider {
|
||||
*
|
||||
* @param tag The {@link CompoundTag} sent from {@link BlockEntity#getUpdateTag()}
|
||||
*/
|
||||
default void handleUpdateTag(CompoundTag tag, HolderLookup.Provider holders) {
|
||||
self().loadWithComponents(tag, holders);
|
||||
default void handleUpdateTag(ValueInput tag, HolderLookup.Provider holders) {
|
||||
self().loadWithComponents(tag);
|
||||
}
|
||||
|
||||
default void onChunkUnloaded(){}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Collection;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.vehicle.AbstractBoat;
|
||||
@@ -22,6 +23,8 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.storage.TagValueInput;
|
||||
import net.minecraft.world.level.storage.TagValueOutput;
|
||||
import net.minecraftforge.common.SoundAction;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.entity.PartEntity;
|
||||
@@ -35,16 +38,21 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundTag> {
|
||||
|
||||
@Override
|
||||
default void deserializeNBT(HolderLookup.Provider registryAccess, CompoundTag nbt) {
|
||||
self().load(nbt);
|
||||
try (var problems = new ProblemReporter.ScopedCollector(self().problemPath(), Entity.LOGGER)) {
|
||||
self().load(TagValueInput.create(problems, registryAccess, nbt));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default CompoundTag serializeNBT(HolderLookup.Provider registryAccess) {
|
||||
var ret = new CompoundTag();
|
||||
var id = self().getEncodeId();
|
||||
if (id != null)
|
||||
ret.putString("id", self().getEncodeId());
|
||||
return self().saveWithoutId(ret);
|
||||
try (var problems = new ProblemReporter.ScopedCollector(self().problemPath(), Entity.LOGGER)) {
|
||||
var output = TagValueOutput.createWithContext(problems, registryAccess);
|
||||
var id = self().getEncodeId();
|
||||
if (id != null)
|
||||
output.putString("id", id);
|
||||
self().saveWithoutId(output);
|
||||
return output.buildResult();
|
||||
}
|
||||
}
|
||||
|
||||
boolean canUpdate();
|
||||
|
||||
@@ -43,7 +43,8 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.eventbus.api.event.InheritableEvent;
|
||||
|
||||
public interface IForgeGameTestHelper {
|
||||
private GameTestHelper self() {
|
||||
@@ -168,17 +169,17 @@ public interface IForgeGameTestHelper {
|
||||
/**
|
||||
* Registers an event listener that will be unregistered when the test is finished running.
|
||||
*/
|
||||
default <E extends Event> void addEventListener(Consumer<E> consumer) {
|
||||
MinecraftForge.EVENT_BUS.addListener(consumer);
|
||||
self().addCleanup(success -> MinecraftForge.EVENT_BUS.unregister(consumer));
|
||||
default <E extends InheritableEvent> void addEventListener(EventBus<E> bus, Consumer<E> consumer) {
|
||||
var key = bus.addListener(consumer);
|
||||
self().addCleanup(success -> bus.removeListener(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an event listener that will be unregistered when the test is finished running.
|
||||
*/
|
||||
default void registerEventListener(Object handler) {
|
||||
MinecraftForge.EVENT_BUS.register(handler);
|
||||
self().addCleanup(success -> MinecraftForge.EVENT_BUS.unregister(handler));
|
||||
var keys = MinecraftForge.EVENT_BUS.register(handler);
|
||||
self().addCleanup(success -> MinecraftForge.EVENT_BUS.unregister(keys));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
||||
public interface IForgeIntrinsicHolderTagAppender<T> extends IForgeTagAppender<T> {
|
||||
private IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> self() {
|
||||
return (IntrinsicHolderTagsProvider.IntrinsicTagAppender<T>) this;
|
||||
}
|
||||
|
||||
ResourceKey<T> getKey(T value);
|
||||
|
||||
/**
|
||||
* Adds a registry entry to the tag json's remove list. Callable during datageneration.
|
||||
*
|
||||
* @param entry The entry to remove
|
||||
* @return The builder for chaining
|
||||
*/
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> remove(final T entry) {
|
||||
return remove(this.getKey(entry));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple registry entries to the tag json's remove list. Callable during datageneration.
|
||||
*
|
||||
* @param entries The entries to remove
|
||||
* @return The builder for chaining
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> remove(final T first, final T...entries) {
|
||||
this.remove(first);
|
||||
for (T entry : entries)
|
||||
this.remove(entry);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> addTags(TagKey<T>... values) {
|
||||
IForgeTagAppender.super.addTags(values);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> replace() {
|
||||
IForgeTagAppender.super.replace();
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> replace(boolean value) {
|
||||
IForgeTagAppender.super.replace(value);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> remove(final ResourceLocation location) {
|
||||
IForgeTagAppender.super.remove(location);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> remove(final ResourceLocation first, final ResourceLocation... locations) {
|
||||
IForgeTagAppender.super.remove(first, locations);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> remove(final ResourceKey<T> resourceKey) {
|
||||
IForgeTagAppender.super.remove(resourceKey);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> remove(final ResourceKey<T> firstResourceKey, final ResourceKey<T>... resourceKeys) {
|
||||
IForgeTagAppender.super.remove(firstResourceKey, resourceKeys);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> remove(TagKey<T> tag) {
|
||||
IForgeTagAppender.super.remove(tag);
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
default IntrinsicHolderTagsProvider.IntrinsicTagAppender<T> remove(TagKey<T> first, TagKey<T>...tags) {
|
||||
IForgeTagAppender.super.remove(first, tags);
|
||||
return self();
|
||||
}
|
||||
}
|
||||
@@ -5,129 +5,140 @@
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.data.tags.TagsProvider;
|
||||
import net.minecraft.data.tags.TagAppender;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagBuilder;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
||||
public interface IForgeTagAppender<T>
|
||||
{
|
||||
private TagsProvider.TagAppender<T> self() {
|
||||
return (TagsProvider.TagAppender<T>) this;
|
||||
public interface IForgeTagAppender<E, T> {
|
||||
private TagAppender<E, T> self() {
|
||||
return (TagAppender<E, T>)this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the backing TagBuilder, will throw an exception if its not set.
|
||||
* This is only available during data generation, and if they use TagAppender.forBuilder
|
||||
*/
|
||||
default TagBuilder getInternalBuilder() {
|
||||
throw new IllegalStateException("Could not determine internal tag builder");
|
||||
}
|
||||
|
||||
default String getSourceName() {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a registry entry to the tag json's remove list. Callable during datageneration.
|
||||
*
|
||||
* @param entry The entry to remove
|
||||
* @return The builder for chaining
|
||||
*/
|
||||
default TagAppender<E, T> remove(final E entry) {
|
||||
throw new UnsupportedOperationException("TagAppender.remove is not implemented in class: " + this.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple registry entries to the tag json's remove list. Callable during datageneration.
|
||||
*
|
||||
* @param entries The entries to remove
|
||||
* @return The builder for chaining
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default TagsProvider.TagAppender<T> addTags(TagKey<T>... values) {
|
||||
TagsProvider.TagAppender<T> builder = self();
|
||||
default TagAppender<E, T> remove(final E first, final E...entries) {
|
||||
this.remove(first);
|
||||
for (E entry : entries)
|
||||
this.remove(entry);
|
||||
return self();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default TagAppender<E, T> addTags(TagKey<T>... values) {
|
||||
var builder = self();
|
||||
for (TagKey<T> value : values) {
|
||||
builder.addTag(value);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
default TagsProvider.TagAppender<T> addOptionalTag(TagKey<T> value) {
|
||||
return self().addOptionalTag(value.location());
|
||||
default TagAppender<E, T> addOptional(ResourceLocation location) {
|
||||
self().getInternalBuilder().addOptionalElement(location);
|
||||
return self();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default TagsProvider.TagAppender<T> addOptionalTags(TagKey<T>... values) {
|
||||
TagsProvider.TagAppender<T> builder = self();
|
||||
for (TagKey<T> value : values) {
|
||||
builder.addOptionalTag(value.location());
|
||||
}
|
||||
default TagAppender<E, T>addOptionalTags(TagKey<T>... values) {
|
||||
var builder = self();
|
||||
for (var value : values)
|
||||
builder.addOptionalTag(value);
|
||||
return builder;
|
||||
}
|
||||
|
||||
default TagsProvider.TagAppender<T> replace() {
|
||||
default TagAppender<E, T> replace() {
|
||||
return replace(true);
|
||||
}
|
||||
|
||||
default TagsProvider.TagAppender<T> replace(boolean value) {
|
||||
default TagAppender<E, T> replace(boolean value) {
|
||||
self().getInternalBuilder().replace(value);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single element's ID to the tag json's remove list. Callable during datageneration.
|
||||
* Adds a single element's ID to the tag json's remove list. Only available during data generation.
|
||||
* @param location The ID of the element to remove
|
||||
* @return The builder for chaining
|
||||
*/
|
||||
default TagsProvider.TagAppender<T> remove(final ResourceLocation location)
|
||||
{
|
||||
TagsProvider.TagAppender<T> builder = self();
|
||||
builder.getInternalBuilder().removeElement(location, builder.getModID());
|
||||
default TagAppender<E, T> remove(final ResourceLocation location) {
|
||||
var builder = self();
|
||||
builder.getInternalBuilder().removeElement(location, builder.getSourceName());
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple elements' IDs to the tag json's remove list. Callable during datageneration.
|
||||
* Adds multiple elements' IDs to the tag json's remove list. Only available during data generation.
|
||||
* @param locations The IDs of the elements to remove
|
||||
* @return The builder for chaining
|
||||
*/
|
||||
default TagsProvider.TagAppender<T> remove(final ResourceLocation first, final ResourceLocation... locations)
|
||||
{
|
||||
default TagAppender<E, T> remove(final ResourceLocation first, final ResourceLocation... locations) {
|
||||
this.remove(first);
|
||||
for (ResourceLocation location : locations)
|
||||
{
|
||||
for (var location : locations)
|
||||
this.remove(location);
|
||||
}
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a resource key to the tag json's remove list. Callable during datageneration.
|
||||
* Adds a resource key to the tag json's remove list. Only available during data generation.
|
||||
*
|
||||
* @param resourceKey The resource key of the element to remove
|
||||
* @return The appender for chaining
|
||||
*/
|
||||
default TagsProvider.TagAppender<T> remove(final ResourceKey<T> resourceKey)
|
||||
{
|
||||
default TagAppender<E, T> remove(final ResourceKey<T> resourceKey) {
|
||||
this.remove(resourceKey.location());
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple resource keys to the tag json's remove list. Callable during datageneration.
|
||||
*
|
||||
* @param resourceKeys The resource keys of the elements to remove
|
||||
* @return The appender for chaining
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default TagsProvider.TagAppender<T> remove(final ResourceKey<T> firstResourceKey, final ResourceKey<T>... resourceKeys)
|
||||
{
|
||||
this.remove(firstResourceKey.location());
|
||||
for (ResourceKey<T> resourceKey : resourceKeys)
|
||||
{
|
||||
this.remove(resourceKey.location());
|
||||
}
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tag to the tag json's remove list. Callable during datageneration.
|
||||
* Adds a tag to the tag json's remove list. Only available during data generation.
|
||||
* @param tag The ID of the tag to remove
|
||||
* @return The builder for chaining
|
||||
*/
|
||||
default TagsProvider.TagAppender<T> remove(TagKey<T> tag)
|
||||
{
|
||||
TagsProvider.TagAppender<T> builder = self();
|
||||
builder.getInternalBuilder().removeTag(tag.location(), builder.getModID());
|
||||
default TagAppender<E, T> remove(TagKey<T> tag) {
|
||||
var builder = self();
|
||||
builder.getInternalBuilder().removeTag(tag.location(), builder.getSourceName());
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple tags to the tag json's remove list. Callable during datageneration.
|
||||
* Adds multiple tags to the tag json's remove list. Only available during data generation.
|
||||
* @param tags The IDs of the tags to remove
|
||||
* @return The builder for chaining
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default TagsProvider.TagAppender<T> remove(TagKey<T> first, TagKey<T>...tags)
|
||||
{
|
||||
default TagAppender<E, T> remove(TagKey<T> first, TagKey<T>...tags) {
|
||||
this.remove(first);
|
||||
for (TagKey<T> tag : tags)
|
||||
{
|
||||
for (var tag : tags)
|
||||
this.remove(tag);
|
||||
}
|
||||
return self();
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,21 @@ import java.util.Objects;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.TagValueInput;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.util.ProblemReporter;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
/**
|
||||
* Represents a captured snapshot of a block which will not change
|
||||
@@ -29,6 +34,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* can exist multiple times for any given Block.
|
||||
*/
|
||||
public class BlockSnapshot {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockSnapshot", "false"));
|
||||
|
||||
private final ResourceKey<Level> dim;
|
||||
@@ -65,7 +71,7 @@ public class BlockSnapshot {
|
||||
|
||||
@Nullable
|
||||
private static CompoundTag getBlockEntityTag(@Nullable BlockEntity te, HolderLookup.Provider lookup) {
|
||||
return te == null ? null : te.saveCustomAndMetadata(lookup);
|
||||
return te == null ? null : te.saveWithFullMetadata(lookup);
|
||||
}
|
||||
|
||||
public BlockState getCurrentBlock() {
|
||||
@@ -127,7 +133,10 @@ public class BlockSnapshot {
|
||||
if (getTag() != null) {
|
||||
te = world.getBlockEntity(pos);
|
||||
if (te != null) {
|
||||
te.loadWithComponents(nbt, world.registryAccess());
|
||||
try (var problems = new ProblemReporter.ScopedCollector(te.problemPath(), LOGGER)) {
|
||||
te.loadWithComponents(TagValueInput.create(problems, world.registryAccess(), getTag()));
|
||||
}
|
||||
|
||||
te.setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.util;
|
||||
|
||||
import net.minecraftforge.eventbus.api.event.RecordEvent;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public interface HasResult {
|
||||
Result getResult();
|
||||
void setResult(Result result);
|
||||
|
||||
/**
|
||||
* A version of {@link HasResult} tailored for {@link RecordEvent}s.
|
||||
*/
|
||||
@NullMarked
|
||||
interface Record extends HasResult {
|
||||
Result.Holder resultHolder();
|
||||
|
||||
default Result getResult() {
|
||||
return resultHolder().get();
|
||||
}
|
||||
|
||||
default void setResult(Result result) {
|
||||
resultHolder().set(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.util;
|
||||
|
||||
import net.minecraftforge.eventbus.api.event.RecordEvent;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@NullMarked
|
||||
public enum Result {
|
||||
ALLOW,
|
||||
DEFAULT,
|
||||
DENY;
|
||||
|
||||
public boolean isAllowed() {
|
||||
return this == ALLOW;
|
||||
}
|
||||
|
||||
public boolean isDefault() {
|
||||
return this == DEFAULT;
|
||||
}
|
||||
|
||||
public boolean isDenied() {
|
||||
return this == DENY;
|
||||
}
|
||||
|
||||
/**
|
||||
* A mutable holder for a Result, useful for {@link RecordEvent}s combined with {@link HasResult.Record}
|
||||
*/
|
||||
@NullMarked
|
||||
public static final class Holder {
|
||||
private Result value;
|
||||
|
||||
public Holder() {
|
||||
set(DEFAULT);
|
||||
}
|
||||
|
||||
public Holder(Result value) {
|
||||
set(value);
|
||||
}
|
||||
|
||||
public Result get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void set(Result value) {
|
||||
Objects.requireNonNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Result.Holder{value=" + value + "\"}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
return this == that || (that instanceof Holder thatHolder && this.value == thatHolder.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return value.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,8 @@ import net.minecraft.DetectedVersion;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
@@ -25,15 +26,17 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class GatherDataEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public final class GatherDataEvent implements IModBusEvent {
|
||||
public static EventBus<GatherDataEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, GatherDataEvent.class);
|
||||
}
|
||||
|
||||
private final DataGenerator dataGenerator;
|
||||
private final DataGeneratorConfig config;
|
||||
private final ExistingFileHelper existingFileHelper;
|
||||
private final ModContainer modContainer;
|
||||
|
||||
public GatherDataEvent(final ModContainer mc, final DataGenerator dataGenerator, final DataGeneratorConfig dataGeneratorConfig, ExistingFileHelper existingFileHelper)
|
||||
{
|
||||
public GatherDataEvent(final ModContainer mc, final DataGenerator dataGenerator, final DataGeneratorConfig dataGeneratorConfig, ExistingFileHelper existingFileHelper) {
|
||||
this.modContainer = mc;
|
||||
this.dataGenerator = dataGenerator;
|
||||
this.config = dataGeneratorConfig;
|
||||
|
||||
@@ -8,7 +8,8 @@ package net.minecraftforge.event;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.packs.repository.RepositorySource;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.bus.BusGroup;
|
||||
import net.minecraftforge.eventbus.api.bus.EventBus;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -16,7 +17,11 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* Fired on {@link PackRepository} creation to allow mods to add new pack finders.
|
||||
*/
|
||||
public final class AddPackFindersEvent extends Event implements IModBusEvent {
|
||||
public final class AddPackFindersEvent implements IModBusEvent {
|
||||
public static EventBus<AddPackFindersEvent> getBus(BusGroup modBusGroup) {
|
||||
return IModBusEvent.getBus(modBusGroup, AddPackFindersEvent.class);
|
||||
}
|
||||
|
||||
private final PackType packType;
|
||||
private final Consumer<RepositorySource> sources;
|
||||
|
||||
|
||||
Loaded 100 of 642 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user