26.1 Update

Minecraft is now Unobfuscated and requires Java 25
Lots of changes/code cleanup.
See https://github.com/MinecraftForge/MinecraftForge-Experimental/tree/26.1-dev for non-squashed commits.

Co-authored-by: Paint_Ninja <[email protected]>
This commit is contained in:
LexManosandPaint_Ninja committed 2026-03-24 14:07:41 -07:00
1 parent 5ac2675f87
commit 047e5fe252
1558 files changed
+11117 -16291

No files matched your search

@@ -109,7 +109,7 @@ public class ClientCommandHandler {
new CommandSource() {
@Override
public void sendSystemMessage(Component message) {
mc.gui.getChat().addMessage(message);
mc.gui.getChat().addClientSystemMessage(message);
}
@Override
@@ -188,7 +188,7 @@ public class ClientCommandHandler {
// in case of unknown command, let the server try and handle it
return false;
}
mc.gui.getChat().addMessage(
mc.gui.getChat().addClientSystemMessage(
Component.literal("").append(ComponentUtils.fromMessage(syntax.getRawMessage())).withStyle(ChatFormatting.RED)
);
if (syntax.getInput() != null && syntax.getCursor() >= 0) {
@@ -205,11 +205,11 @@ public class ClientCommandHandler {
details.append(Component.literal(syntax.getInput().substring(position)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE));
details.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
mc.gui.getChat().addMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED));
mc.gui.getChat().addClientSystemMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED));
}
} catch (Exception generic) { // Probably thrown by the command{
MutableComponent message = Component.literal(generic.getMessage() == null ? generic.getClass().getName() : generic.getMessage());
mc.gui.getChat().addMessage(
mc.gui.getChat().addClientSystemMessage(
Component.translatable("command.failed")
.withStyle(ChatFormatting.RED)
.withStyle(style -> style.withHoverEvent(new HoverEvent.ShowText(message)))
@@ -41,7 +41,7 @@ public class ClientCommandSourceStack extends CommandSourceStack {
@SuppressWarnings("resource")
@Override
public void sendSuccess(Supplier<Component> message, boolean sendToAdmins) {
Minecraft.getInstance().gui.getChat().addMessage(message.get());
Minecraft.getInstance().gui.getChat().addClientSystemMessage(message.get());
}
/**
@@ -6,14 +6,13 @@
package net.minecraftforge.client;
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
import net.minecraft.client.resources.model.UnbakedGeometry;
import net.minecraft.client.resources.model.geometry.UnbakedGeometry;
import net.minecraft.resources.Identifier;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
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.listener.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@@ -25,7 +24,6 @@ public class ClientForgeMod {
event.register(forgeRL("empty"), (json, ctx) -> UnbakedGeometry.EMPTY);
event.register(forgeRL("obj"), ObjLoader.INSTANCE);
event.register(forgeRL("fluid_container"), DynamicFluidContainerModel.Loader.INSTANCE);
event.register(forgeRL("item_layers"), ItemLayerGeometry.Loader.INSTANCE);
}
@SubscribeEvent
@@ -39,7 +39,7 @@ public class ConfigScreenHandler
public static Optional<BiFunction<Minecraft, Screen, Screen>> getScreenFactoryFor(IModInfo selectedMod)
{
return ModList.get().getModContainerById(selectedMod.getModId()).
return ModList.getModContainerById(selectedMod.getModId()).
flatMap(mc -> mc.getCustomExtension(ConfigScreenFactory.class).map(ConfigScreenFactory::screenFunction));
}
}
@@ -23,11 +23,10 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.ChatComponent;
import net.minecraft.client.gui.components.LerpingBossEvent;
import net.minecraft.client.gui.render.pip.PictureInPictureRenderer;
import net.minecraft.client.gui.render.state.pip.PictureInPictureRenderState;
import net.minecraft.client.gui.screens.ConfirmScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
@@ -51,11 +50,18 @@ import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.block.model.BlockModelPart;
import net.minecraft.client.renderer.block.BlockAndTintGetter;
import net.minecraft.client.renderer.block.FluidModel;
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
import net.minecraft.client.renderer.block.dispatch.BlockStateModelPart;
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.state.EntityRenderState;
import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
import net.minecraft.client.renderer.fog.FogData;
import net.minecraft.client.renderer.state.LevelRenderState;
import net.minecraft.client.renderer.state.gui.pip.PictureInPictureRenderState;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.client.renderer.state.level.LevelRenderState;
import net.minecraft.client.renderer.texture.SpriteContents;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -64,11 +70,12 @@ import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.ResolvedModel;
import net.minecraft.client.resources.model.SpriteGetter;
import net.minecraft.client.resources.model.UnbakedGeometry;
import net.minecraft.client.resources.model.geometry.UnbakedGeometry;
import net.minecraft.client.resources.model.sprite.MaterialBaker;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.client.sounds.SoundEngine;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.data.AtlasIds;
import net.minecraft.locale.Language;
import net.minecraft.network.Connection;
@@ -94,10 +101,10 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.FogType;
import net.minecraft.world.phys.BlockHitResult;
@@ -277,6 +284,7 @@ public class ForgeHooksClient {
RegisterColorHandlersEvent.Block.BUS.post(new RegisterColorHandlersEvent.Block(blockColors));
}
@SuppressWarnings("rawtypes")
public static Model getArmorModel(HumanoidRenderState state, ItemStack itemStack, EquipmentSlot slot, HumanoidModel<?> _default) {
return IClientItemExtensions.of(itemStack).getGenericArmorModel(state, itemStack, slot, _default);
}
@@ -319,7 +327,7 @@ public class ForgeHooksClient {
return PlaySoundEvent.BUS.fire(new PlaySoundEvent(manager, sound)).getSound();
}
public static void drawScreen(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
public static void drawScreen(Screen screen, GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTick) {
guiGraphics.pose().pushMatrix();
for (Screen layer : guiLayers) {
// Prevent the background layers from thinking the mouse is over their controls and showing them as highlighted.
@@ -330,9 +338,9 @@ public class ForgeHooksClient {
guiGraphics.pose().popMatrix();
}
private static void drawScreenInternal(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
private static void drawScreenInternal(Screen screen, GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTick) {
if (!ScreenEvent.Render.Pre.BUS.post(new ScreenEvent.Render.Pre(screen, guiGraphics, mouseX, mouseY, partialTick)))
screen.renderWithTooltipAndSubtitles(guiGraphics, mouseX, mouseY, partialTick);
screen.extractRenderStateWithTooltipAndSubtitles(guiGraphics, mouseX, mouseY, partialTick);
ScreenEvent.Render.Post.BUS.post(new ScreenEvent.Render.Post(screen, guiGraphics, mouseX, mouseY, partialTick));
}
@@ -367,15 +375,13 @@ public class ForgeHooksClient {
ModelEvent.BakingCompleted.BUS.post(new ModelEvent.BakingCompleted(modelManager, modelBakery));
}
public static TextureAtlasSprite[] getFluidSprites(BlockAndTintGetter level, BlockPos pos, FluidState fluidStateIn) {
IClientFluidTypeExtensions props = IClientFluidTypeExtensions.of(fluidStateIn);
Identifier overlayTexture = props.getOverlayTexture(fluidStateIn, level, pos);
var atlas = Minecraft.getInstance().getAtlasManager().getAtlasOrThrow(AtlasIds.BLOCKS);
return new TextureAtlasSprite[] {
atlas.getSprite(props.getStillTexture(fluidStateIn, level, pos)),
atlas.getSprite(props.getFlowingTexture(fluidStateIn, level, pos)),
overlayTexture == null ? null : atlas.getSprite(overlayTexture),
};
public static Map<Fluid, FluidModel> onFluidModelBake(ModelBakery bakery, MaterialBaker materials, Map<Fluid, FluidModel> vanilla) {
var ret = new HashMap<Fluid, FluidModel>();
ModelEvent.BakeFluidModels.BUS.post(new ModelEvent.BakeFluidModels(bakery, materials, ret));
if (ret.isEmpty())
return vanilla;
ret.putAll(vanilla);
return Map.copyOf(ret);
}
private static int slotMainHand = 0;
@@ -395,24 +401,24 @@ public class ForgeHooksClient {
return from.getItem().shouldCauseReequipAnimation(from, to, changed);
}
public static @Nullable CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(GuiGraphics guiGraphics, Window window, LerpingBossEvent bossInfo, int x, int y, int increment) {
public static @Nullable CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(GuiGraphicsExtractor 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);
return CustomizeGuiOverlayEvent.BossEventProgress.BUS.post(evt) ? null : evt;
}
public static void onCustomizeChatEvent(GuiGraphics guiGraphics, ChatComponent chat, Window window, int mouseX, int mouseY, int tickCount, Font font) {
public static void onCustomizeChatEvent(GuiGraphicsExtractor guiGraphics, ChatComponent chat, Window window, int mouseX, int mouseY, int tickCount, Font font) {
var minecraft = Minecraft.getInstance();
var evt = new CustomizeGuiOverlayEvent.Chat(window, guiGraphics, minecraft.getDeltaTracker().getRealtimeDeltaTicks(), 0, chat.getHeight() - 40);
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(), (float) ((evt.getPosY() - chat.getHeight() + 40) / chat.getScale()));
chat.render(guiGraphics, font, tickCount, mouseX, mouseY, false, false);
chat.extractRenderState(guiGraphics, font, tickCount, mouseX, mouseY, ChatComponent.DisplayMode.BACKGROUND, false);
guiGraphics.pose().popMatrix();
}
public static void onCustomizeDebugEvent(GuiGraphics guiGraphics, Window window, float partialTick, List<String> text, boolean isLeft) {
public static void onCustomizeDebugEvent(GuiGraphicsExtractor 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);
CustomizeGuiOverlayEvent.DebugText.BUS.post(evt);
@@ -483,13 +489,12 @@ public class ForgeHooksClient {
return null;
}
@Nullable
public static TextureAtlasSprite loadTextureAtlasSprite(Identifier atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int padding, int mipmapLevel) {
public static TextureAtlasSprite loadTextureAtlasSprite(Identifier atlasName, SpriteContents contents, int atlasWidth, int atlasHeight, int x, int y, int padding) {
TextureAtlasSprite ret = null;
var forgeMeta = contents.getAdditionalMetadata(ForgeTextureMetadata.TYPE).orElse(null);
if (forgeMeta == null || forgeMeta.loader() == null)
return null;
return forgeMeta.loader().makeSprite(atlasName, contents, atlasWidth, atlasHeight, spriteX, spriteY, padding, mipmapLevel);
if (forgeMeta != null && forgeMeta.loader() != null)
ret = forgeMeta.loader().makeSprite(atlasName, contents, atlasWidth, atlasHeight, x, y, padding, contents.getMipLevel());
return ret != null ? ret : new TextureAtlasSprite(atlasName, contents, atlasWidth, atlasHeight, x, y, padding);
}
private static final Map<ModelLayerLocation, Supplier<LayerDefinition>> layerDefinitions = new HashMap<>();
@@ -515,7 +520,7 @@ public class ForgeHooksClient {
boolean channelsMatch = NetworkRegistry.checkListPingCompatibilityForClient(remoteChannels);
AtomicBoolean result = new AtomicBoolean(true);
final List<String> extraClientMods = new ArrayList<>();
ModList.get().forEachModContainer((modid, mc) ->
ModList.forEachModContainer((modid, mc) ->
mc.getCustomExtension(IExtensionPoint.DisplayTest.class).ifPresent(ext-> {
boolean foundModOnServer = ext.remoteVersionTest().test(mods.get(modid), true);
result.compareAndSet(true, foundModOnServer);
@@ -526,8 +531,8 @@ public class ForgeHooksClient {
boolean modsMatch = result.get();
final Map<String, String> extraServerMods = mods.entrySet().stream().
filter(e -> !Objects.equals(IExtensionPoint.DisplayTest.IGNORESERVERONLY, e.getValue())).
filter(e -> !ModList.get().isLoaded(e.getKey())).
filter(e -> !IExtensionPoint.DisplayTest.IGNORESERVERONLY.equals(e.getValue())).
filter(e -> !ModList.isLoaded(e.getKey())).
collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
LOGGER.debug(CLIENTHOOKS, "Received FML ping data from server at {}: FMLNETVER={}, mod list is compatible : {}, channel list is compatible: {}, extra server mods: {}", target.ip, fmlver, modsMatch, channelsMatch, extraServerMods);
@@ -558,7 +563,7 @@ public class ForgeHooksClient {
}
private static final Identifier ICON_SHEET = Identifier.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/icons.png");
public static void drawForgePingInfo(JoinMultiplayerScreen gui, ServerData target, GuiGraphics guiGraphics, int x, int y, int width, int relativeMouseX, int relativeMouseY) {
public static void drawForgePingInfo(JoinMultiplayerScreen gui, ServerData target, GuiGraphicsExtractor guiGraphics, int x, int y, int width, int relativeMouseX, int relativeMouseY) {
int idx;
String tooltip;
if (target.forgeData == null)
@@ -659,7 +664,7 @@ public class ForgeHooksClient {
return stackFont == null ? fallbackFont : stackFont;
}
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, @Nullable Identifier background) {
public static @Nullable RenderTooltipEvent.Pre onRenderTooltipPre(@NotNull ItemStack stack, GuiGraphicsExtractor graphics, int x, int y, int screenWidth, int screenHeight, @NotNull List<ClientTooltipComponent> components, @NotNull Font fallbackFont, @NotNull ClientTooltipPositioner positioner, @Nullable Identifier background) {
var preEvent = new RenderTooltipEvent.Pre(stack, graphics, x, y, screenWidth, screenHeight, getTooltipFont(stack, fallbackFont), components, positioner, background);
return RenderTooltipEvent.Pre.BUS.post(preEvent) ? null : preEvent;
}
@@ -730,11 +735,6 @@ public class ForgeHooksClient {
return font.split(text, maxWidth).stream().map(ClientTooltipComponent::create);
}
public static boolean isBlockInSolidLayer(BlockState state) {
var model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state);
return model.getRenderTypes(state, RandomSource.create(), ModelData.EMPTY).contains(ChunkSectionLayer.SOLID);
}
public static void createWorldConfirmationScreen(Runnable doConfirmedWorldLoad) {
Component title = Component.translatable("selectWorld.backupQuestion.experimental");
Component msg = Component.translatable("selectWorld.backupWarning.experimental")
@@ -855,55 +855,6 @@ public class ForgeHooksClient {
return new ForgeBlockModelData(transform, renderType, renderTypeFast, visibility);
}
/** This is a dirty fucking hack, but it needs to send in the top most render type. */
public static ModelBaker wrapRenderType(ModelBaker parent, RenderTypeGroup group) {
if (group == null || group == RenderTypeGroup.EMPTY || parent.renderType() != null)
return parent;
return new WrapedModelBaker(parent, group);
}
public static ModelBaker wrapRenderType(ModelBaker parent, RenderTypeGroup group, RenderTypeGroup groupFast) {
if (group == null || group == RenderTypeGroup.EMPTY || parent.renderType() != null)
return parent;
return new WrapedModelBaker(parent, group, groupFast);
}
// a record for performance reasons
private record WrapedModelBaker(ModelBaker parent, RenderTypeGroup group, RenderTypeGroup renderTypeFast) implements ModelBaker {
private WrapedModelBaker(ModelBaker parent, RenderTypeGroup group) {
this(parent, group, RenderTypeGroup.EMPTY);
}
@Override
public RenderTypeGroup renderType() {
return group;
}
@Override public ResolvedModel getModel(Identifier p_397309_) {
return parent.getModel(p_397309_);
}
@Override
public SpriteGetter sprites() {
return parent.sprites();
}
@Override
public <T> T compute(SharedOperationKey<T> p_395456_) {
return parent.compute(p_395456_);
}
@Override
public BlockModelPart missingBlockModelPart() {
return parent.missingBlockModelPart();
}
@Override
public PartCache parts() {
return parent.parts();
}
}
public static void addFramePass(Identifier rl, FramePassManager.PassDefinition definition) {
FramePassManager.addPass(rl, definition);
}
@@ -6,8 +6,8 @@
package net.minecraftforge.client;
import com.mojang.blaze3d.pipeline.BlendFunction;
import com.mojang.blaze3d.pipeline.ColorTargetState;
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.RenderSystem;
@@ -32,8 +32,6 @@ import org.jetbrains.annotations.ApiStatus;
public enum ForgeRenderTypes {
ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(blockAtlas())),
ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(blockAtlas())),
ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(blockAtlas())),
ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(blockAtlas())),
ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(blockAtlas())),
ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(blockAtlas())),
ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(blockAtlas(), false));
@@ -69,20 +67,6 @@ public enum ForgeRenderTypes {
return Internal.LAYERED_ITEM_CUTOUT.apply(textureLocation);
}
/**
* @return A RenderType fit for multi-layer cutout-mipped item rendering.
*/
public static RenderType getItemLayeredCutoutMipped(Identifier textureLocation) {
return Internal.LAYERED_ITEM_CUTOUT_MIPPED.apply(textureLocation);
}
/**
* @return A RenderType fit for multi-layer translucent item rendering.
*/
public static RenderType getItemLayeredTranslucent(Identifier textureLocation) {
return Internal.LAYERED_ITEM_TRANSLUCENT.apply(textureLocation);
}
/**
* @return A RenderType fit for translucent item/entity rendering, but with depth sorting disabled.
*/
@@ -107,13 +91,6 @@ public enum ForgeRenderTypes {
return (sortingEnabled ? Internal.UNLIT_TRANSLUCENT_SORTED : Internal.UNLIT_TRANSLUCENT_UNSORTED).apply(textureLocation);
}
/**
* @return Same as {@link RenderType#entityCutout(Identifier)}, but with mipmapping enabled.
*/
public static RenderType getEntityCutoutMipped(Identifier textureLocation) {
return Internal.LAYERED_ITEM_CUTOUT_MIPPED.apply(textureLocation);
}
/**
* @see #enableTextTextureLinearFiltering
*
@@ -268,35 +245,6 @@ public enum ForgeRenderTypes {
);
}
public static Function<Identifier, RenderType> LAYERED_ITEM_CUTOUT_MIPPED = Util.memoize(Internal::layeredItemCutoutMipped);
private static RenderType layeredItemCutoutMipped(Identifier texture) {
return RenderType.create("forge_layered_item_cutout_mipped",
RenderSetup.builder(RenderPipelines.ENTITY_SMOOTH_CUTOUT)
.bufferSize(RenderType.TRANSIENT_BUFFER_SIZE)
.affectsCrumbling()
.withTexture("Sampler0", texture) // Used to have mipmap = true
.useLightmap()
.useOverlay()
.setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE)
.createRenderSetup()
);
}
public static Function<Identifier, RenderType> LAYERED_ITEM_TRANSLUCENT = Util.memoize(Internal::layeredItemTranslucent);
private static RenderType layeredItemTranslucent(Identifier texture) {
return RenderType.create("forge_layered_item_translucent",
RenderSetup.builder(RenderPipelines.ITEM_ENTITY_TRANSLUCENT_CULL)
.bufferSize(RenderType.TRANSIENT_BUFFER_SIZE)
.affectsCrumbling()
.sortOnUpload()
.withTexture("Sampler0", texture)
.useLightmap()
.useOverlay()
.setOutline(RenderSetup.OutlineProperty.AFFECTS_OUTLINE)
.createRenderSetup()
);
}
public static Function<Identifier, RenderType> TEXT = Util.memoize(Internal::getText);
private static RenderType getText(Identifier texture) {
return RenderType.create(
@@ -371,9 +319,7 @@ public enum ForgeRenderTypes {
private static final RenderPipeline LOADING_PIPELINE = RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET)
.withLocation("pipeline/forge/loading_overlay")
.withBlend(new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE))
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.withDepthWrite(false)
.withColorTargetState(new ColorTargetState(new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE)))
.build();
private static final GpuSampler LOADING_SAMPLER = RenderSystem.getSamplerCache().getSampler(AddressMode.REPEAT, AddressMode.REPEAT, FilterMode.NEAREST, FilterMode.NEAREST, false);
@@ -7,13 +7,10 @@ package net.minecraftforge.client;
import com.mojang.blaze3d.framegraph.FrameGraphBuilder;
import com.mojang.blaze3d.framegraph.FramePass;
import com.mojang.blaze3d.resource.ResourceHandle;
import net.minecraft.client.renderer.LevelTargetBundle;
import net.minecraft.client.renderer.state.LevelRenderState;
import net.minecraft.client.renderer.state.level.LevelRenderState;
import net.minecraft.resources.Identifier;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -45,28 +42,12 @@ public class FramePassManager {
* A FramePass must bind to at least ONE target. Otherwise, you get freaky issues with >1 modded passes.
* Additionally, this method should be used for extracting render states into instance variables if desired.
*/
default void extracts(LevelTargetBundle bundle, FramePass pass) {
targets(bundle, pass);
}
/**
* Prefer {@link PassDefinition#extracts}
*/
@Deprecated(forRemoval = true, since = "1.21.10")
default void targets(LevelTargetBundle bundle, FramePass pass) {}
void extracts(LevelTargetBundle bundle, FramePass pass);
/**
* Use to define what your pass does during the render stage.
*/
default void executes(LevelRenderState state) {
executes();
};
/**
* Use to define what your pass does during the render stage, prefer {@link PassDefinition#executes(LevelRenderState)}.
*/
@Deprecated(forRemoval = true, since = "1.21.10")
default void executes(){};
void executes(LevelRenderState state);
}
private record PassInfo(String name, PassDefinition pass){}
@@ -6,7 +6,7 @@
package net.minecraftforge.client;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.client.event.RegisterItemDecorationsEvent;
@@ -15,14 +15,13 @@ import net.minecraftforge.client.event.RegisterItemDecorationsEvent;
* An ItemDecorator that is used to render something on specific items, when the DurabilityBar and StackCount is rendered.
* Add it to an item using {@linkplain RegisterItemDecorationsEvent#register(ItemLike, IItemDecorator)}.
*/
public interface IItemDecorator
{
public interface IItemDecorator {
/**
* Is called after {@linkplain GuiGraphics#renderItemDecorations(Font, ItemStack, int, int, String)} is done rendering.
* Is called after {@linkplain GuiGraphicsExtractor#itemDecorations(Font, ItemStack, int, int, String)} is done rendering.
* The StackCount is rendered at blitOffset+200 so use the blitOffset with caution.
* <p>
* The RenderState during this call will be: enableTexture, enableDepthTest, enableBlend and defaultBlendFunc
* @return true if you have modified the RenderState and it has to be reset for other ItemDecorators
*/
boolean render(GuiGraphics guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset);
boolean render(GuiGraphicsExtractor guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset);
}
@@ -9,12 +9,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.client.gui.GuiGraphics;
import org.jetbrains.annotations.ApiStatus;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.event.RegisterItemDecorationsEvent;
@@ -49,7 +49,7 @@ public final class ItemDecoratorHandler {
return DECORATOR_LOOKUP.getOrDefault(stack.getItem(), EMPTY);
}
public void render(GuiGraphics guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset) {
public void render(GuiGraphicsExtractor guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset) {
resetRenderState();
for (IItemDecorator itemDecorator : itemDecorators) {
if (itemDecorator.render(guiGraphics, font, stack, xOffset, yOffset))
@@ -42,8 +42,6 @@ public final class NamedRenderTypeManager {
private static void preRegisterVanillaRenderTypes(Map<Identifier, RenderTypeGroup> blockRenderTypes) {
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()));
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 Identifier rl(String path) {
@@ -1,74 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.client;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.block.model.BlockStateModel;
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
import net.minecraft.client.renderer.rendertype.RenderType;
import net.minecraft.client.renderer.rendertype.RenderTypes;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelData;
import org.jetbrains.annotations.NotNull;
/**
* Provides helper functions replacing those in {@link ItemBlockRenderTypes}.
*/
public final class RenderTypeHelper {
/**
* Provides a {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} for the given {@link DefaultVertexFormat#BLOCK} format.
* This should be called for each {@link RenderType} returned by {@link BakedModel#getRenderTypes(BlockState, RandomSource, ModelData)}.
* <p>
* Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(BlockState)}.
*/
@NotNull
public static RenderType getEntityRenderType(ChunkSectionLayer layer) {
return layer == ChunkSectionLayer.TRANSLUCENT ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet();
}
/**
* Provides a {@link RenderType} fit for rendering moving blocks given the specified chunk render type.
* This should be called for each {@link RenderType} returned by {@link BakedModel#getRenderTypes(BlockState, RandomSource, ModelData)}.
* <p>
* Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getMovingBlockRenderType(BlockState)}.
*/
@NotNull
public static RenderType getMovingBlockRenderType(ChunkSectionLayer layer) {
if (layer == null)
return RenderTypes.solidMovingBlock();
return switch (layer) {
case SOLID -> RenderTypes.solidMovingBlock();
case CUTOUT -> RenderTypes.cutoutMovingBlock();
case TRANSLUCENT -> RenderTypes.translucentMovingBlock();
case TRIPWIRE -> RenderTypes.tripwireMovingBlock();
};
}
/**
* Provides a fallback {@link RenderType} for the given {@link ItemStack} in the case that none is explicitly specified.
* <p>
* Mimics the behavior of vanilla's {@link ItemBlockRenderTypes#getRenderType(ItemStack, boolean)}
* but removes the need to query the model again if the item is a {@link BlockItem}.
*/
@NotNull
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(ChunkSectionLayer.TRANSLUCENT))
return getEntityRenderType(ChunkSectionLayer.TRANSLUCENT);
return Sheets.cutoutBlockSheet();
}
return Sheets.translucentItemSheet();
}
private RenderTypeHelper() {}
}
@@ -6,11 +6,9 @@
package net.minecraftforge.client.event;
import net.minecraftforge.client.gui.overlay.ForgeLayeredDraw;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -28,10 +26,4 @@ public record AddGuiOverlayLayersEvent(ForgeLayeredDraw getLayeredDraw) implemen
@ApiStatus.Internal
public AddGuiOverlayLayersEvent {}
/** @deprecated {@link AddGuiOverlayLayersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<AddGuiOverlayLayersEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
}
@@ -5,7 +5,6 @@
package net.minecraftforge.client.event;
import net.minecraft.util.Util;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.PlayerChatMessage;
@@ -75,17 +74,6 @@ public sealed class ClientChatReceivedEvent extends MutableEvent implements Canc
return this.sender;
}
/**
* {@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.
* So moved to it's own event. {@link SystemMessageReceivedEvent}
*/
@Deprecated(forRemoval = true, since = "1.21.1")
public boolean isSystem() {
return this.sender.equals(Util.NIL_UUID);
}
/**
* Fired when a player chat message is received on the client.
*
@@ -116,30 +104,4 @@ public sealed class ClientChatReceivedEvent extends MutableEvent implements Canc
return this.playerChatMessage;
}
}
/**
* Fired when a system message is received on the client.
*
* @deprecated Mojang made ChatType a registry, which isn't always accessible when the System messages are sent.
* So moved to its own event. {@link SystemMessageReceivedEvent}
*/
@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
public System(ChatType.Bound boundChatType, Component message, boolean overlay) {
super(boundChatType, message, Util.NIL_UUID);
this.overlay = overlay;
}
/**
* {@return whether the message goes to the overlay}
*/
public boolean isOverlay() {
return this.overlay;
}
}
}
@@ -5,7 +5,7 @@
package net.minecraftforge.client.event;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.bus.EventBus;
@@ -43,7 +43,7 @@ public sealed interface ContainerScreenEvent {
/**
* {@return the gui graphics used for rendering}
*/
GuiGraphics getGuiGraphics();
GuiGraphicsExtractor getGuiGraphics();
/**
* {@return the X coordinate of the mouse pointer}
@@ -67,7 +67,7 @@ public sealed interface ContainerScreenEvent {
*/
record Foreground(
AbstractContainerScreen<?> getContainerScreen,
GuiGraphics getGuiGraphics,
GuiGraphicsExtractor getGuiGraphics,
int getMouseX,
int getMouseY
) implements RecordEvent, Render {
@@ -86,7 +86,7 @@ public sealed interface ContainerScreenEvent {
*/
record Background(
AbstractContainerScreen<?> getContainerScreen,
GuiGraphics getGuiGraphics,
GuiGraphicsExtractor getGuiGraphics,
int getMouseX,
int getMouseY
) implements RecordEvent, Render {
@@ -1,27 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.client.event;
import java.util.Map;
import net.minecraft.client.renderer.special.SpecialModelRenderer;
import net.minecraft.world.level.block.Block;
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);
private final Map<Block, SpecialModelRenderer.Unbaked> map;
public CreateSpecialBlockRendererEvent(Map<Block, SpecialModelRenderer.Unbaked> map) {
this.map = map;
}
public void register(Block block, SpecialModelRenderer.Unbaked renderer) {
this.map.put(block, renderer);
}
}
@@ -6,7 +6,7 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.platform.Window;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.LerpingBossEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
@@ -29,7 +29,7 @@ import java.util.List;
public sealed interface CustomizeGuiOverlayEvent {
Window getWindow();
GuiGraphics getGuiGraphics();
GuiGraphicsExtractor getGuiGraphics();
float getPartialTick();
@@ -46,7 +46,7 @@ public sealed interface CustomizeGuiOverlayEvent {
public static final CancellableEventBus<BossEventProgress> BUS = CancellableEventBus.create(BossEventProgress.class);
private final Window window;
private final GuiGraphics guiGraphics;
private final GuiGraphicsExtractor guiGraphics;
private final float partialTick;
private final LerpingBossEvent bossEvent;
private final int x;
@@ -54,7 +54,7 @@ public sealed interface CustomizeGuiOverlayEvent {
private int increment;
@ApiStatus.Internal
public BossEventProgress(Window window, GuiGraphics guiGraphics, float partialTick, LerpingBossEvent bossEvent, int x, int y, int increment) {
public BossEventProgress(Window window, GuiGraphicsExtractor guiGraphics, float partialTick, LerpingBossEvent bossEvent, int x, int y, int increment) {
this.window = window;
this.guiGraphics = guiGraphics;
this.partialTick = partialTick;
@@ -70,7 +70,7 @@ public sealed interface CustomizeGuiOverlayEvent {
}
@Override
public GuiGraphics getGuiGraphics() {
public GuiGraphicsExtractor getGuiGraphics() {
return guiGraphics;
}
@@ -129,7 +129,7 @@ public sealed interface CustomizeGuiOverlayEvent {
*/
record DebugText(
Window getWindow,
GuiGraphics getGuiGraphics,
GuiGraphicsExtractor getGuiGraphics,
float getPartialTick,
List<String> getText,
Side getSide
@@ -155,13 +155,13 @@ public sealed interface CustomizeGuiOverlayEvent {
public static final EventBus<Chat> BUS = EventBus.create(Chat.class);
private final Window window;
private final GuiGraphics guiGraphics;
private final GuiGraphicsExtractor guiGraphics;
private final float partialTick;
private int posX;
private int posY;
@ApiStatus.Internal
public Chat(Window window, GuiGraphics guiGraphics, float partialTick, int posX, int posY) {
public Chat(Window window, GuiGraphicsExtractor guiGraphics, float partialTick, int posX, int posY) {
this.window = window;
this.guiGraphics = guiGraphics;
this.partialTick = partialTick;
@@ -175,7 +175,7 @@ public sealed interface CustomizeGuiOverlayEvent {
}
@Override
public GuiGraphics getGuiGraphics() {
public GuiGraphicsExtractor getGuiGraphics() {
return guiGraphics;
}
@@ -32,13 +32,11 @@ 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.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
@@ -69,12 +67,6 @@ public sealed interface EntityRenderersEvent {
record RegisterLayerDefinitions() implements SelfDestructing, RecordEvent, EntityRenderersEvent {
public static final EventBus<RegisterLayerDefinitions> BUS = EventBus.create(RegisterLayerDefinitions.class);
/** @deprecated {@link EntityRenderersEvent.RegisterLayerDefinitions} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterLayerDefinitions> getBus(BusGroup modBusGroup) {
return BUS;
}
@ApiStatus.Internal
public RegisterLayerDefinitions {}
@@ -103,12 +95,6 @@ public sealed interface EntityRenderersEvent {
record RegisterRenderers() implements SelfDestructing, RecordEvent, EntityRenderersEvent {
public static final EventBus<RegisterRenderers> BUS = EventBus.create(RegisterRenderers.class);
/** @deprecated {@link RegisterRenderers} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterRenderers> getBus(BusGroup modBusGroup) {
return BUS;
}
@ApiStatus.Internal
public RegisterRenderers {}
@@ -142,12 +128,6 @@ public sealed interface EntityRenderersEvent {
final class AddLayers extends MutableEvent implements EntityRenderersEvent {
public static final EventBus<AddLayers> BUS = EventBus.create(AddLayers.class);
/** @deprecated {@link EntityRenderersEvent.AddLayers} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<AddLayers> getBus(BusGroup modBusGroup) {
return BUS;
}
private final Map<EntityType<?>, EntityRenderer<?, ?>> renderers;
private final Map<PlayerModelType, AvatarRenderer<AbstractClientPlayer>> playerRenderers;
private final Map<PlayerModelType, AvatarRenderer<ClientMannequin>> mannequinRenderers;
@@ -234,12 +214,6 @@ public sealed interface EntityRenderersEvent {
final class CreateSkullModels extends MutableEvent implements EntityRenderersEvent {
public static final EventBus<CreateSkullModels> BUS = EventBus.create(CreateSkullModels.class);
/** @deprecated {@link EntityRenderersEvent.CreateSkullModels} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<CreateSkullModels> getBus(BusGroup modBusGroup) {
return BUS;
}
private final ImmutableMap.Builder<Type, Function<EntityModelSet, SkullModelBase>> builder;
@ApiStatus.Internal
@@ -24,7 +24,7 @@ import net.minecraft.client.KeyMapping;
import net.minecraft.client.MouseHandler;
import net.minecraft.client.entity.ClientAvatarEntity;
import net.minecraft.client.entity.ClientMannequin;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
@@ -50,7 +50,7 @@ import net.minecraft.client.renderer.entity.state.EntityRenderState;
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.client.renderer.special.SpecialModelRenderer;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.client.sounds.SoundEngine;
import net.minecraft.network.Connection;
@@ -169,11 +169,11 @@ public final class ForgeEventFactoryClient {
return InputEvent.InteractionKeyMappingTriggered.BUS.post(event);
}
public static void onContainerRenderBackground(AbstractContainerScreen<?> screen, GuiGraphics graphics, int mouseX, int mouseY) {
public static void onContainerRenderBackground(AbstractContainerScreen<?> screen, GuiGraphicsExtractor graphics, int mouseX, int 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) {
public static void onContainerRenderForeground(AbstractContainerScreen<?> screen, GuiGraphicsExtractor graphics, int mouseX, int mouseY) {
ContainerScreenEvent.Render.Foreground.BUS.post(new ContainerScreenEvent.Render.Foreground(screen, graphics, mouseX, mouseY));
}
@@ -221,11 +221,11 @@ public final class ForgeEventFactoryClient {
return RenderItemInFrameEvent.BUS.post(new RenderItemInFrameEvent(state, renderItemFrame, poseStack, nodeCollector, packedLight));
}
public static RenderNameTagEvent fireRenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer<?, ?> entityRenderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) {
return RenderNameTagEvent.BUS.fire(new RenderNameTagEvent(state, content, entityRenderer, poseStack, nodeCollector, cameraState));
public static RenderNameTagEvent fireRenderNameTagEvent(EntityRenderState state, EntityRenderer<?, ?> entityRenderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) {
return RenderNameTagEvent.BUS.fire(new RenderNameTagEvent(state, entityRenderer, poseStack, nodeCollector, cameraState));
}
public static void onRenderScreenBackground(Screen screen, GuiGraphics guiGraphics) {
public static void onRenderScreenBackground(Screen screen, GuiGraphicsExtractor guiGraphics) {
ScreenEvent.BackgroundRendered.BUS.post(new ScreenEvent.BackgroundRendered(screen, guiGraphics));
}
@@ -254,10 +254,6 @@ public final class ForgeEventFactoryClient {
return ComputeFovModifierEvent.BUS.fire(new ComputeFovModifierEvent(entity, modifier, scale));
}
public static void onCreateSpecialBlockRenderers(Map<Block, SpecialModelRenderer.Unbaked> map) {
CreateSpecialBlockRendererEvent.BUS.post(new CreateSpecialBlockRendererEvent(map));
}
public static Map<Type, Function<EntityModelSet, SkullModelBase>> onCreateSkullModels() {
var builder = ImmutableMap.<Type, Function<EntityModelSet, SkullModelBase>>builder();
EntityRenderersEvent.CreateSkullModels.BUS.post(new EntityRenderersEvent.CreateSkullModels(builder));
@@ -6,19 +6,21 @@
package net.minecraftforge.client.event;
import com.google.common.base.Preconditions;
import net.minecraft.client.renderer.block.FluidModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.sprite.MaterialBaker;
import net.minecraft.resources.Identifier;
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.minecraft.world.level.material.Fluid;
import net.minecraftforge.client.model.geometry.IGeometryLoader;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -50,12 +52,6 @@ public sealed interface ModelEvent {
implements RecordEvent, ModelEvent {
public static final EventBus<ModifyBakingResult> BUS = EventBus.create(ModifyBakingResult.class);
/** @deprecated {@link ModelEvent.ModifyBakingResult} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<ModifyBakingResult> getBus(BusGroup modBusGroup) {
return BUS;
}
@ApiStatus.Internal
public ModifyBakingResult {}
}
@@ -75,12 +71,6 @@ public sealed interface ModelEvent {
implements RecordEvent, ModelEvent {
public static final EventBus<BakingCompleted> BUS = EventBus.create(BakingCompleted.class);
/** @deprecated {@link ModelEvent.BakingCompleted} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<BakingCompleted> getBus(BusGroup modBusGroup) {
return BUS;
}
@ApiStatus.Internal
public BakingCompleted {}
}
@@ -96,12 +86,6 @@ public sealed interface ModelEvent {
final class RegisterModelStateDefinitions extends MutableEvent implements ModelEvent {
public static final EventBus<RegisterModelStateDefinitions> BUS = EventBus.create(RegisterModelStateDefinitions.class);
/** @deprecated {@link ModelEvent.RegisterModelStateDefinitions} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterModelStateDefinitions> getBus(BusGroup modBusGroup) {
return BUS;
}
private final Map<Identifier, StateDefinition<Block, BlockState>> states = new HashMap<>();
private final Map<Identifier, StateDefinition<Block, BlockState>> view = Collections.unmodifiableMap(states);
@@ -132,12 +116,6 @@ public sealed interface ModelEvent {
final class RegisterGeometryLoaders extends MutableEvent implements ModelEvent {
public static final EventBus<RegisterGeometryLoaders> BUS = EventBus.create(RegisterGeometryLoaders.class);
/** @deprecated {@link ModelEvent.RegisterGeometryLoaders} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterGeometryLoaders> getBus(BusGroup modBusGroup) {
return BUS;
}
private final Map<Identifier, IGeometryLoader> loaders;
@ApiStatus.Internal
@@ -154,4 +132,37 @@ public sealed interface ModelEvent {
loaders.put(Identifier, loader);
}
}
/**
* Allows users to register their own {@link FluidModel fluid models}.
*
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@NullMarked
final class BakeFluidModels extends MutableEvent implements ModelEvent {
public static final EventBus<BakeFluidModels> BUS = EventBus.create(BakeFluidModels.class);
private final ModelBakery bakery;
private final MaterialBaker materials;
private final Map<Fluid, FluidModel> models;
@ApiStatus.Internal
public BakeFluidModels(ModelBakery bakery, MaterialBaker materials, Map<Fluid, FluidModel> models) {
this.bakery = bakery;
this.materials = materials;
this.models = models;
}
public ModelBakery bakery() {
return this.bakery;
}
public MaterialBaker materials() {
return this.materials;
}
public void register(Fluid fluid, FluidModel model) {
models.put(fluid, model);
}
}
}
@@ -9,12 +9,10 @@ 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.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -30,12 +28,6 @@ import org.jspecify.annotations.NullMarked;
public final class RegisterClientReloadListenersEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterClientReloadListenersEvent> BUS = EventBus.create(RegisterClientReloadListenersEvent.class);
/** @deprecated {@link RegisterClientReloadListenersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterClientReloadListenersEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
private final ReloadableResourceManager resourceManager;
@ApiStatus.Internal
@@ -7,12 +7,10 @@ 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.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -29,12 +27,6 @@ import java.util.function.Function;
public final class RegisterClientTooltipComponentFactoriesEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterClientTooltipComponentFactoriesEvent> BUS = EventBus.create(RegisterClientTooltipComponentFactoriesEvent.class);
/** @deprecated {@link RegisterClientTooltipComponentFactoriesEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterClientTooltipComponentFactoriesEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
private final Map<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> factories;
@ApiStatus.Internal
@@ -5,21 +5,20 @@
package net.minecraftforge.client.event;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.block.BlockTintSource;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ColorResolver;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
import java.util.ArrayList;
import java.util.List;
/**
* Fired for registering block and item color handlers at the appropriate time.
@@ -39,12 +38,6 @@ public sealed interface RegisterColorHandlersEvent {
record Block(BlockColors getBlockColors) implements RecordEvent, RegisterColorHandlersEvent {
public static final EventBus<Block> BUS = EventBus.create(Block.class);
/** @deprecated {@link RegisterColorHandlersEvent.Block} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<Block> getBus(BusGroup modBusGroup) {
return BUS;
}
@ApiStatus.Internal
public Block {}
@@ -58,14 +51,14 @@ public sealed interface RegisterColorHandlersEvent {
}
/**
* Registers a {@link BlockColor} instance for a set of blocks.
* Registers {@link BlockTintSource} instances for a set of blocks.
*
* @param blockColor The color provider
* @param blocks The blocks
* @param sources The tint sources
* @param blocks The blocks
*/
@SuppressWarnings("deprecation")
public void register(BlockColor blockColor, net.minecraft.world.level.block.Block... blocks) {
getBlockColors.register(blockColor, blocks);
public void register(List<BlockTintSource> sources, net.minecraft.world.level.block.Block... blocks) {
getBlockColors.register(sources, blocks);
}
}
@@ -77,12 +70,6 @@ public sealed interface RegisterColorHandlersEvent {
final class ColorResolvers extends MutableEvent implements SelfDestructing, RegisterColorHandlersEvent {
public static final EventBus<ColorResolvers> BUS = EventBus.create(ColorResolvers.class);
/** @deprecated {@link RegisterColorHandlersEvent.ColorResolvers} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<ColorResolvers> getBus(BusGroup modBusGroup) {
return BUS;
}
private final ArrayList<ColorResolver> builder;
@ApiStatus.Internal
@@ -7,12 +7,10 @@ package net.minecraftforge.client.event;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -28,12 +26,6 @@ import java.util.Map;
public final class RegisterEntitySpectatorShadersEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterEntitySpectatorShadersEvent> BUS = EventBus.create(RegisterEntitySpectatorShadersEvent.class);
/** @deprecated {@link RegisterEntitySpectatorShadersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterEntitySpectatorShadersEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
private final Map<EntityType<?>, Identifier> shaders;
@ApiStatus.Internal
@@ -9,12 +9,10 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.client.IItemDecorator;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -31,12 +29,6 @@ import java.util.Map;
public final class RegisterItemDecorationsEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterItemDecorationsEvent> BUS = EventBus.create(RegisterItemDecorationsEvent.class);
/** @deprecated {@link RegisterItemDecorationsEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterItemDecorationsEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
private final Map<Item, List<IItemDecorator>> decorators;
@ApiStatus.Internal
@@ -7,12 +7,10 @@ package net.minecraftforge.client.event;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Options;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -26,12 +24,6 @@ import org.jspecify.annotations.NullMarked;
public final class RegisterKeyMappingsEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterKeyMappingsEvent> BUS = EventBus.create(RegisterKeyMappingsEvent.class);
/** @deprecated {@link RegisterKeyMappingsEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterKeyMappingsEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
private final Options options;
@ApiStatus.Internal
@@ -50,14 +50,14 @@ public final class RegisterNamedRenderTypesEvent extends MutableEvent implements
*
* @param key The namespace should match your mod's namespace, such as your mod ID
* @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
* @param entityRenderType A {@link RenderType} using {@link DefaultVertexFormat#ENTITY}
* @param fabulousEntityRenderType A {@link RenderType} using {@link DefaultVertexFormat#ENTITY} for use when
* "fabulous" rendering is enabled
*/
public void register(Identifier key, ChunkSectionLayer blockRenderType, RenderType entityRenderType, RenderType fabulousEntityRenderType) {
Preconditions.checkArgument(!renderTypes.containsKey(key), "Render type already registered: " + key);
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.");
Preconditions.checkArgument(entityRenderType.format() == DefaultVertexFormat.ENTITY, "The entity render type must use the ENTITY vertex format.");
Preconditions.checkArgument(fabulousEntityRenderType.format() == DefaultVertexFormat.ENTITY, "The fabulous entity render type must use the ENTITY vertex format.");
renderTypes.put(key, new RenderTypeGroup(blockRenderType, entityRenderType, fabulousEntityRenderType));
}
}
@@ -9,11 +9,9 @@ import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.ParticleResources;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import net.minecraftforge.registries.RegisterEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -28,13 +26,7 @@ import org.jspecify.annotations.NullMarked;
*/
@NullMarked
public final class RegisterParticleProvidersEvent extends MutableEvent {
public static EventBus<RegisterParticleProvidersEvent> BUS = EventBus.create(RegisterParticleProvidersEvent.class);
/** @deprecated {@link RegisterParticleProvidersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterParticleProvidersEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
public static final EventBus<RegisterParticleProvidersEvent> BUS = EventBus.create(RegisterParticleProvidersEvent.class);
private final ParticleResources particles;
@@ -7,8 +7,8 @@ package net.minecraftforge.client.event;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.gui.render.pip.PictureInPictureRenderer;
import net.minecraft.client.gui.render.state.pip.PictureInPictureRenderState;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.state.gui.pip.PictureInPictureRenderState;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
@@ -10,12 +10,10 @@ import com.google.common.collect.BiMap;
import net.minecraft.resources.Identifier;
import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.MutableEvent;
import net.minecraftforge.eventbus.api.event.characteristic.SelfDestructing;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
/**
@@ -26,12 +24,6 @@ import org.jetbrains.annotations.ApiStatus;
public final class RegisterTextureAtlasSpriteLoadersEvent extends MutableEvent implements SelfDestructing {
public static final EventBus<RegisterTextureAtlasSpriteLoadersEvent> BUS = EventBus.create(RegisterTextureAtlasSpriteLoadersEvent.class);
/** {@link RegisterTextureAtlasSpriteLoadersEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterTextureAtlasSpriteLoadersEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
private final BiMap<Identifier, ITextureAtlasSpriteLoader> loaders;
@ApiStatus.Internal
@@ -6,7 +6,6 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
@@ -11,7 +11,7 @@ import net.minecraft.client.entity.ClientAvatarEntity;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.entity.player.AvatarRenderer;
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.world.entity.Avatar;
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
import net.minecraftforge.eventbus.api.bus.EventBus;
@@ -6,7 +6,6 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
@@ -9,7 +9,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
import net.minecraft.client.renderer.state.LevelRenderState;
import net.minecraft.client.renderer.state.level.LevelRenderState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
@@ -6,7 +6,6 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
@@ -7,11 +7,10 @@ package net.minecraftforge.client.event;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.bus.CancellableEventBus;
@@ -9,45 +9,45 @@ import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.state.EntityRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import net.minecraft.network.chat.Component;
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;
/**
* Fired before an entity renderer renders the nameplate of an entity.
*
* <p>This event {@linkplain HasResult has a result}:</p>
* <ul>
* <li>{@link Result#ALLOW} - the nameplate will be forcibly rendered.</li>
* <li>{@link Result#DEFAULT} - the vanilla logic will be used.</li>
* <li>{@link Result#DENY} - the nameplate will not be rendered.</li>
* </ul>
*
* <p>This event is fired only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*
* Setting any of the content to null will prevent that content from being rendered.
* If you wish to cancel both score and name tag, you can cancel the entire event.
*
* @see EntityRenderer
*/
public final class RenderNameTagEvent extends MutableEvent implements HasResult {
public static final EventBus<RenderNameTagEvent> BUS = EventBus.create(RenderNameTagEvent.class);
public final class RenderNameTagEvent extends MutableEvent implements Cancellable {
public static final EventBus<RenderNameTagEvent> BUS = CancellableEventBus.create(RenderNameTagEvent.class);
private Component nameplateContent;
private Component scoreContent;
private final EntityRenderState state;
private final Component originalContent;
private final Component originalScoreContent;
private final EntityRenderer<?, ?> entityRenderer;
private final PoseStack poseStack;
private final SubmitNodeCollector nodeCollector;
private final CameraRenderState cameraState;
private Result result = Result.DEFAULT;
@ApiStatus.Internal
public RenderNameTagEvent(EntityRenderState state, Component content, EntityRenderer<?, ?> entityRenderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) {
public RenderNameTagEvent(EntityRenderState state, EntityRenderer<?, ?> entityRenderer, PoseStack poseStack, SubmitNodeCollector nodeCollector, CameraRenderState cameraState) {
this.state = state;
this.originalContent = content;
this.originalContent = this.nameplateContent = state.nameTag;
this.originalScoreContent = this.scoreContent = state.scoreText;
this.setContent(this.originalContent);
this.entityRenderer = entityRenderer;
this.poseStack = poseStack;
@@ -65,24 +65,48 @@ public final class RenderNameTagEvent extends MutableEvent implements HasResult
*
* @param contents the new text
*/
public void setContent(Component contents) {
public void setContent(@Nullable Component contents) {
this.nameplateContent = contents;
}
/**
* {@return the text on the nameplate that will be rendered, if the event is not {@link Result#DENY DENIED}}
*/
public Component getContent() {
public @Nullable Component getContent() {
return this.nameplateContent;
}
/**
* Sets the new text for the score part of the nameplate.
*
* @param contents the new text
*/
public void setScoreContent(@Nullable Component contents) {
this.scoreContent = contents;
}
/**
* {@return the text on the score part of the nameplate that will be rendered, if the event is not {@link Result#DENY DENIED}}
*/
public @Nullable Component getScoreContent() {
return this.scoreContent;
}
/**
* {@return the original text on the nameplate}
*/
public Component getOriginalContent() {
public @Nullable Component getOriginalContent() {
return this.originalContent;
}
/**
* {@return the original text of the score part of this nameplate}
*/
public @Nullable Component getOriginalScore() {
return this.originalScoreContent;
}
/**
* {@return the entity renderer rendering the nameplate}
*/
@@ -110,14 +134,4 @@ public final class RenderNameTagEvent extends MutableEvent implements HasResult
public CameraRenderState getCameraState() {
return this.cameraState;
}
@Override
public Result getResult() {
return this.result;
}
@Override
public void setResult(Result result) {
this.result = result;
}
}
@@ -7,7 +7,7 @@ package net.minecraftforge.client.event;
import com.mojang.datafixers.util.Either;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
import net.minecraft.network.chat.FormattedText;
@@ -41,14 +41,14 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements
public static final EventBus<RenderTooltipEvent> BUS = EventBus.create(RenderTooltipEvent.class);
protected final ItemStack itemStack;
protected final GuiGraphics graphics;
protected final GuiGraphicsExtractor graphics;
protected int x;
protected int y;
protected Font font;
protected final List<ClientTooltipComponent> components;
@ApiStatus.Internal
protected RenderTooltipEvent(ItemStack itemStack, GuiGraphics graphics, int x, int y, Font font, List<ClientTooltipComponent> components) {
protected RenderTooltipEvent(ItemStack itemStack, GuiGraphicsExtractor graphics, int x, int y, Font font, List<ClientTooltipComponent> components) {
this.itemStack = itemStack;
this.graphics = graphics;
this.components = Collections.unmodifiableList(components);
@@ -61,22 +61,15 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements
* {@return the item stack which the tooltip is being rendered for, or an {@linkplain ItemStack#isEmpty() empty
* item stack} if there is no associated item stack}
*/
public ItemStack getItemStack() {
return itemStack;
}
/**
* {@return the gui graphics helper for the gui}
*/
public GuiGraphics getGuiGraphics() {
return graphics;
}
/**
* {@return the graphics helper for the gui}
*/
public GuiGraphics getGraphics() {
public GuiGraphicsExtractor getGraphics() {
return graphics;
}
@@ -214,7 +207,7 @@ public abstract sealed class RenderTooltipEvent extends MutableEvent implements
private Identifier originalBackground;
@ApiStatus.Internal
public Pre(ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, Font font, List<ClientTooltipComponent> components, ClientTooltipPositioner positioner, @Nullable Identifier background) {
public Pre(ItemStack stack, GuiGraphicsExtractor graphics, int x, int y, int screenWidth, int screenHeight, Font font, List<ClientTooltipComponent> components, ClientTooltipPositioner positioner, @Nullable Identifier background) {
super(stack, graphics, x, y, font, components);
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
@@ -6,7 +6,7 @@
package net.minecraftforge.client.event;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.input.CharacterEvent;
@@ -154,7 +154,7 @@ public sealed interface ScreenEvent {
/**
* {@return the gui graphics used for rendering}
*/
GuiGraphics getGuiGraphics();
GuiGraphicsExtractor getGuiGraphics();
/**
* {@return the X coordinate of the mouse pointer}
@@ -180,7 +180,7 @@ public sealed interface ScreenEvent {
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
record Pre(Screen getScreen, GuiGraphics getGuiGraphics, int getMouseX, int getMouseY, float getPartialTick)
record Pre(Screen getScreen, GuiGraphicsExtractor getGuiGraphics, int getMouseX, int getMouseY, float getPartialTick)
implements Cancellable, Render, RecordEvent {
public static final CancellableEventBus<Pre> BUS = CancellableEventBus.create(Pre.class);
@@ -194,7 +194,7 @@ public sealed interface ScreenEvent {
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
record Post(Screen getScreen, GuiGraphics getGuiGraphics, int getMouseX, int getMouseY, float getPartialTick)
record Post(Screen getScreen, GuiGraphicsExtractor getGuiGraphics, int getMouseX, int getMouseY, float getPartialTick)
implements Render, RecordEvent {
public static final EventBus<Post> BUS = EventBus.create(Post.class);
@@ -212,7 +212,7 @@ public sealed interface ScreenEvent {
*
* @param getGuiGraphics the gui graphics used for rendering
*/
record BackgroundRendered(Screen getScreen, GuiGraphics getGuiGraphics) implements RecordEvent, ScreenEvent {
record BackgroundRendered(Screen getScreen, GuiGraphicsExtractor getGuiGraphics) implements RecordEvent, ScreenEvent {
public static final EventBus<BackgroundRendered> BUS = EventBus.create(BackgroundRendered.class);
@ApiStatus.Internal
@@ -762,21 +762,6 @@ public sealed interface ScreenEvent {
return (char)getInfo().codepoint();
}
/**
* {@return a bit field representing the active modifier keys}
*
* @see InputConstants#MOD_CONTROL CTRL modifier key bit
* @see GLFW#GLFW_MOD_SHIFT SHIFT modifier key bit
* @see GLFW#GLFW_MOD_ALT ALT modifier key bit
* @see GLFW#GLFW_MOD_SUPER SUPER modifier key bit
* @see GLFW#GLFW_KEY_CAPS_LOCK CAPS LOCK modifier key bit
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
*/
default int getModifiers() {
return getInfo().modifiers();
}
/**
* Fired <b>before</b> the character input is handled by the screen.
*
@@ -6,11 +6,9 @@
package net.minecraftforge.client.event;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -64,12 +62,6 @@ public sealed interface TextureStitchEvent {
record Post(TextureAtlas getAtlas) implements RecordEvent, TextureStitchEvent {
public static final EventBus<Post> BUS = EventBus.create(Post.class);
/** @deprecated {@link TextureStitchEvent.Post} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<Post> getBus(BusGroup modBusGroup) {
return BUS;
}
@ApiStatus.Internal
public Post {}
}
@@ -6,11 +6,9 @@
package net.minecraftforge.client.event.sound;
import net.minecraft.client.sounds.SoundEngine;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
@@ -24,12 +22,6 @@ import org.jspecify.annotations.NullMarked;
public record SoundEngineLoadEvent(SoundEngine getEngine) implements RecordEvent, SoundEvent {
public static final EventBus<SoundEngineLoadEvent> BUS = EventBus.create(SoundEngineLoadEvent.class);
/** @deprecated {@link SoundEngineLoadEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<SoundEngineLoadEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
@ApiStatus.Internal
public SoundEngineLoadEvent {}
}
@@ -1,24 +0,0 @@
/*
* 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;
}
}
@@ -5,23 +5,15 @@
package net.minecraftforge.client.extensions;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.rendertype.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.client.renderer.block.BlockAndTintGetter;
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
import net.minecraft.client.renderer.block.dispatch.BlockStateModelPart;
import net.minecraft.client.resources.model.sprite.Material;
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.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")
@@ -34,37 +26,16 @@ public interface IForgeBlockStateModel {
return modelData;
}
default TextureAtlasSprite particleIcon(@NotNull ModelData data) {
return self().particleIcon();
default Material.Baked particleMaterial(@NotNull ModelData data) {
return self().particleMaterial();
}
/**
* Gets the set of {@link RenderType render types} to use when drawing this block in the level.
* Supported types are those returned by {@link RenderType#chunkBufferLayers()}.
* <p>
* By default, defers query to {@link ItemBlockRenderTypes}.
*/
default Collection<ChunkSectionLayer> getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data) {
return ItemBlockRenderTypes.getRenderLayers(state);
}
/**
* Collects the parts of this model to render for the specified render type.
* Not all paths call this, or use a valid render type. So it is recommended to also implement a sane default in
* Collects the parts of this model with the specified ModelData.
* Not all paths call this, or pass in empty data. 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 ChunkSectionLayer renderType) {
List<BlockModelPart> list = new ObjectArrayList<>();
this.collectParts(random, list, data, renderType);
return list;
}
/**
* Collects the parts of this model to render for the specified render type.
* 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 ChunkSectionLayer renderType) {
self().collectParts(random, dest);
default void collectParts(RandomSource random, List<BlockStateModelPart> output, ModelData data) {
self().collectParts(random, output);
}
}
@@ -5,16 +5,16 @@
package net.minecraftforge.client.extensions;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.resources.Identifier;
/**
* Extension interface for {@link GuiGraphics}.
*/
public interface IForgeGuiGraphics {
private GuiGraphics self() {
return (GuiGraphics)this;
public interface IForgeGuiGraphicsExtractor {
private GuiGraphicsExtractor self() {
return (GuiGraphicsExtractor)this;
}
int DEFAULT_BACKGROUND_COLOR = 0xF0100010;
@@ -26,14 +26,14 @@ public interface IForgePoseStack {
final PoseStack self = self();
self.pushPose();
var trans = transformation.getTranslation();
var trans = transformation.translation();
self.translate(trans.x(), trans.y(), trans.z());
self.mulPose(transformation.getLeftRotation());
self.mulPose(transformation.leftRotation());
var scale = transformation.getScale();
var scale = transformation.scale();
self.scale(scale.x(), scale.y(), scale.z());
self.mulPose(transformation.getRightRotation());
self.mulPose(transformation.rightRotation());
}
}
@@ -1,26 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.client.extensions;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.block.model.BakedQuad;
/**
* Extension interface for {@link VertexConsumer}.
*/
public interface IForgeVertexConsumer {
private VertexConsumer self() {
return (VertexConsumer)this;
}
/**
* Variant with no per-vertex shading.
*/
default void putBulkData(PoseStack.Pose pose, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int packedLight, int packedOverlay) {
self().putBulkData(pose, bakedQuad, new float[] { 1.0F, 1.0F, 1.0F, 1.0F }, red, green, blue, alpha, new int[] { packedLight, packedLight, packedLight, packedLight }, packedOverlay);
}
}
@@ -1,39 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.client.extensions;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.blaze3d.vertex.VertexFormatElement;
import java.util.List;
/**
* Extension interface for {@link VertexFormat}.
*/
public interface IForgeVertexFormat {
List<VertexFormatElement> getElements();
default boolean hasPosition() {
return getElements().stream().anyMatch(e -> e.usage() == VertexFormatElement.Usage.POSITION);
}
default boolean hasNormal() {
return getElements().stream().anyMatch(e -> e.usage() == VertexFormatElement.Usage.NORMAL);
}
default boolean hasColor() {
return getElements().stream().anyMatch(e -> e.usage() == VertexFormatElement.Usage.COLOR);
}
default boolean hasUV(int which) {
for (var e : getElements()) {
if (e.usage() == VertexFormatElement.Usage.UV && e.index() == which) {
return true;
}
}
return false;
}
}
@@ -12,10 +12,12 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.ScreenEffectRenderer;
import net.minecraft.client.renderer.block.BlockAndTintGetter;
import net.minecraft.client.renderer.block.FluidModel;
import net.minecraft.client.renderer.block.FluidRenderer;
import net.minecraft.client.renderer.fog.FogData;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.Identifier;
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;
@@ -171,76 +173,18 @@ public interface IClientFluidTypeExtensions {
/* Level-Based Accessors */
/**
* Returns the reference of the texture to apply to a source fluid.
* Returns the location dependent FluidModel.
*
* <p>This should return a reference to the texture and not the actual
* texture itself (e.g. {@code minecraft:block/water_still} will point to
* {@code assets/minecraft/textures/block/water_still.png}).
*
* <p>Important: This method should only return {@code null} for {@link Fluids#EMPTY}.
* All other implementations must define this property.
*
* @param state the state of the fluid
* @param getter the getter the fluid can be obtained from
* @param pos the position of the fluid
* @return the reference of the texture to apply to a source fluid
*/
default Identifier getStillTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
return this.getStillTexture();
}
/**
* Returns the reference of the texture to apply to a flowing fluid.
*
* <p>This should return a reference to the texture and not the actual
* texture itself (e.g. {@code minecraft:block/water_flow} will point to
* {@code assets/minecraft/textures/block/water_flow.png}).
*
* <p>Important: This method should only return {@code null} for {@link Fluids#EMPTY}.
* All other implementations must define this property.
*
* @param state the state of the fluid
* @param getter the getter the fluid can be obtained from
* @param pos the position of the fluid
* @return the reference of the texture to apply to a flowing fluid
*/
default Identifier getFlowingTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
return this.getFlowingTexture();
}
/**
* Returns the reference of the texture to apply to a fluid directly touching
* a non-opaque block other than air. If no reference is specified, either
* {@code #getStillTexture} or {@code #getFlowingTexture} will be applied
* instead.
*
* <p>This should return a reference to the texture and not the actual
* texture itself (e.g. {@code minecraft:block/water_overlay} will point to
* {@code assets/minecraft/textures/block/water_overlay.png}).
*
* @param state the state of the fluid
* @param getter the getter the fluid can be obtained from
* @param pos the position of the fluid
* @return the reference of the texture to apply to a fluid directly touching
* a non-opaque block
*/
default Identifier getOverlayTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
return this.getOverlayTexture();
}
/**
* Returns the tint applied to the fluid's textures.
*
* <p>The result represents a 32-bit integer where each 8-bits represent
* the alpha, red, green, and blue channel respectively.
* <p>The result will be queried for its textures and tinting.
* See {@link FluidRenderer#tesselate(BlockAndTintGetter,BlockPos,net.minecraft.client.renderer.block.FluidRenderer.Output,net.minecraft.world.level.block.state.BlockState,FluidState) FluidRenderer.tesselate}
*
* @param state the state of the fluid
* @param getter the getter the fluid can be obtained from
* @param pos the position of the fluid
* @return the tint applied to the fluid's textures in ARGB format
*/
default int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
return this.getTintColor();
default FluidModel getModel(FluidState state, BlockAndTintGetter getter, BlockPos pos, FluidModel vanilla) {
return vanilla;
}
/* Stack-Based Accessors */
@@ -6,7 +6,7 @@
package net.minecraftforge.client.extensions.common;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.inventory.EffectsInInventory;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
@@ -52,14 +52,14 @@ public interface IClientMobEffectExtensions {
* Renders the text and icon of the specified effect in the player's inventory.
*
* @param instance The effect instance
* @param effects The effect-rendering screen
* @param guiGraphics The gui graphics
* @param effects The effect-rendering screen
* @param graphics The gui graphics
* @param x The x coordinate
* @param y The y coordinate
* @param blitOffset The blit offset
* @return true to prevent default rendering, false otherwise
*/
default boolean renderInventory(MobEffectInstance instance, EffectsInInventory effects, GuiGraphics guiGraphics, int x, int y, int blitOffset) {
default boolean extractInventory(MobEffectInstance instance, EffectsInInventory effects, GuiGraphicsExtractor graphics, int x, int y, int blitOffset) {
return false;
}
@@ -69,14 +69,14 @@ public interface IClientMobEffectExtensions {
*
* @param instance The effect instance
* @param gui The gui
* @param guiGraphics The gui graphics
* @param graphics The gui graphics
* @param x The x coordinate
* @param y The y coordinate
* @param z The z depth
* @param alpha The alpha value. Blinks when the effect is about to run out
* @return true to prevent default rendering, false otherwise
*/
default boolean renderGuiIcon(MobEffectInstance instance, Gui gui, GuiGraphics guiGraphics, int x, int y, float z, float alpha) {
default boolean extractGuiIcon(MobEffectInstance instance, Gui gui, GuiGraphicsExtractor graphics, int x, int y, float z, float alpha) {
return false;
}
}
@@ -8,7 +8,7 @@ package net.minecraftforge.client.gui;
import com.google.common.base.Strings;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.ErrorScreen;
import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.util.FormattedCharSequence;
@@ -69,16 +69,16 @@ public class LoadingErrorScreen extends ErrorScreen {
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
this.renderBackground(guiGraphics, mouseX, mouseY, partialTick);
this.entryList.render(guiGraphics, mouseX, mouseY, partialTick);
public void extractRenderState(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTick) {
this.extractRenderState(guiGraphics, mouseX, mouseY, partialTick);
this.entryList.extractRenderState(guiGraphics, mouseX, mouseY, partialTick);
drawMultiLineCenteredString(guiGraphics, font, this.modLoadErrors.isEmpty() ? warningHeader : errorHeader, this.width / 2, 10);
this.renderables.forEach(button -> button.render(guiGraphics, mouseX, mouseY, partialTick));
this.renderables.forEach(button -> button.extractRenderState(guiGraphics, mouseX, mouseY, partialTick));
}
private void drawMultiLineCenteredString(GuiGraphics guiGraphics, Font fr, Component str, int x, int y) {
private void drawMultiLineCenteredString(GuiGraphicsExtractor guiGraphics, Font fr, Component str, int x, int y) {
for (FormattedCharSequence s : fr.split(str, this.width)) {
guiGraphics.drawString(fr, s, x - fr.width(s) / 2, y, 0xFFFFFFFF);
guiGraphics.text(fr, s, x - fr.width(s) / 2, y, 0xFFFFFFFF);
y += fr.lineHeight;
}
}
@@ -127,7 +127,7 @@ public class LoadingErrorScreen extends ErrorScreen {
}
@Override
public void renderContent(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean isMouseOver, float partialTick) {
public void extractContent(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, boolean isMouseOver, float partialTick) {
int top = this.getContentY();
int left = this.getContentX();
var mc = Minecraft.getInstance();
@@ -136,9 +136,9 @@ public class LoadingErrorScreen extends ErrorScreen {
int y = top + 2;
for (var string : strings) {
if (center)
guiGraphics.drawString(font, string, left + (width / 2) - (font.width(string) / 2), y, 0xFFFFFFFF, false);
guiGraphics.text(font, string, left + (width / 2) - (font.width(string) / 2), y, 0xFFFFFFFF, false);
else
guiGraphics.drawString(font, string, left + 5, y, 0xFFFFFFFF, false);
guiGraphics.text(font, string, left + 5, y, 0xFFFFFFFF, false);
y += font.lineHeight;
}
}
@@ -27,7 +27,7 @@ import org.apache.maven.artifact.versioning.ComparableVersion;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ActiveTextCollector;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Button;
@@ -103,7 +103,7 @@ public class ModListScreen extends Screen {
public ModListScreen(Screen parentScreen) {
super(Component.translatable("fml.menu.mods.title"));
this.parentScreen = parentScreen;
this.mods = ModList.get().getMods();
this.mods = ModList.getMods();
this.unsortedMods = List.copyOf(this.mods);
}
@@ -159,7 +159,7 @@ public class ModListScreen extends Screen {
}
@Override
protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY) {
protected void drawPanel(GuiGraphicsExtractor guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY) {
if (logoPath != null) {
//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
@@ -168,7 +168,7 @@ public class ModListScreen extends Screen {
relativeY += headerHeight + PADDING;
}
visitText(guiGraphics.textRenderer(GuiGraphics.HoveredTextEffects.TOOLTIP_AND_CURSOR), relativeY);
visitText(guiGraphics.textRenderer(GuiGraphicsExtractor.HoveredTextEffects.TOOLTIP_AND_CURSOR), relativeY);
}
private void visitText(ActiveTextCollector collector, int header) {
@@ -349,11 +349,11 @@ public class ModListScreen extends Screen {
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
public void extractRenderState(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTick) {
if (this.modInfo != null)
this.modInfo.render(guiGraphics, mouseX, mouseY, partialTick);
this.modInfo.extractRenderState(guiGraphics, mouseX, mouseY, partialTick);
super.render(guiGraphics, mouseX, mouseY, partialTick);
super.extractRenderState(guiGraphics, mouseX, mouseY, partialTick);
}
public Minecraft getMinecraftInstance() {
@@ -391,7 +391,7 @@ public class ModListScreen extends Screen {
try {
NativeImage logo = null;
var modfile = ModList.get().getModFileById(selectedMod.getModId());
var modfile = ModList.getModFileById(selectedMod.getModId());
if (modfile != null) {
var path = modfile.getFile().findResource(logoFile);
if (Files.exists(path))
@@ -423,7 +423,7 @@ public class ModListScreen extends Screen {
lines.add(selectedMod.getDisplayName());
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.version", MavenVersionStringHelper.artifactVersionToString(selectedMod.getVersion())));
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.idstate", selectedMod.getModId(), ModList.get().getModContainerById(selectedMod.getModId()).
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.idstate", selectedMod.getModId(), ModList.getModContainerById(selectedMod.getModId()).
map(ModContainer::getCurrentState).map(Object::toString).orElse("NONE")));
selectedMod.getConfig().getConfigElement("credits").ifPresent(credits->
@@ -20,7 +20,7 @@ import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.ChatFormatting;
import net.minecraft.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.TextAlignment;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.MultiLineLabel;
@@ -67,7 +67,7 @@ public class ModMismatchDisconnectedScreen extends Screen {
this.listHeight = hasMismatches ? 140 : 0;
this.allModIds = data.mods().keySet().stream().distinct().collect(Collectors.toList());
this.presentModUrls = ModList.get().getMods().stream()
this.presentModUrls = ModList.getMods().stream()
.filter(info -> allModIds.contains(info.getModId()))
.map(info -> Pair.of(info.getModId(), (String)info.getConfig().getConfigElement("displayURL").orElse("")))
.collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
@@ -98,13 +98,12 @@ public class ModMismatchDisconnectedScreen extends Screen {
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
public void extractRenderState(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTicks) {
int textYOffset = hasMismatches ? 18 : 0;
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset - 9 * 2, 0xAAAAAA);
var lineCollector = guiGraphics.textRenderer(GuiGraphics.HoveredTextEffects.notClickable(false));
guiGraphics.centeredText(this.font, this.title, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset - 9 * 2, 0xAAAAAA);
var lineCollector = guiGraphics.textRenderer(GuiGraphicsExtractor.HoveredTextEffects.notClickable(false), null);
this.message.visitLines(TextAlignment.CENTER, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset, 9, lineCollector);
super.render(guiGraphics, mouseX, mouseY, partialTicks);
super.extractRenderState(guiGraphics, mouseX, mouseY, partialTicks);
}
class MismatchInfoPanel extends ScrollPanel {
@@ -251,7 +250,7 @@ public class ModMismatchDisconnectedScreen extends Screen {
}
@Override
protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY) {
protected void drawPanel(GuiGraphicsExtractor guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY) {
int i = 0;
for (Pair<FormattedCharSequence, Pair<FormattedCharSequence, FormattedCharSequence>> line : lineTable) {
@@ -261,10 +260,10 @@ public class ModMismatchDisconnectedScreen extends Screen {
int color = 0xFFFFFF; //Optional.ofNullable(font.substrByWidth(name, 0)).map(Style::getColor).map(TextColor::getValue).orElse(0xFFFFFF);
//Only indent the given name if a version string is present. This makes it easier to distinguish table section headers and mod entries
int nameLeft = left + border + (versions == null ? 0 : nameIndent);
guiGraphics.drawString(font, name, nameLeft, relativeY + i * 12, color, false);
guiGraphics.text(font, name, nameLeft, relativeY + i * 12, color, false);
if (versions != null) {
guiGraphics.drawString(font, versions.getLeft(), left + border + nameIndent + nameWidth, relativeY + i * 12, color, false);
guiGraphics.drawString(font, versions.getRight(), left + border + nameIndent + nameWidth + versionWidth, relativeY + i * 12, color, false);
guiGraphics.text(font, versions.getLeft(), left + border + nameIndent + nameWidth, relativeY + i * 12, color, false);
guiGraphics.text(font, versions.getRight(), left + border + nameIndent + nameWidth + versionWidth, relativeY + i * 12, color, false);
}
i++;
@@ -272,11 +271,11 @@ public class ModMismatchDisconnectedScreen extends Screen {
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
super.render(guiGraphics, mouseX, mouseY, partialTicks);
public void extractRenderState(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTicks) {
super.extractRenderState(guiGraphics, mouseX, mouseY, partialTicks);
Style style = getComponentStyleAt(mouseX, mouseY);
if (style != null && style.getHoverEvent() != null)
guiGraphics.renderComponentHoverEffect(font, style, mouseX, mouseY);
guiGraphics.componentHoverEffect(font, style, mouseX, mouseY);
}
public Style getComponentStyleAt(double x, double y) {
@@ -5,7 +5,7 @@
package net.minecraftforge.client.gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.renderer.RenderPipelines;
@@ -40,7 +40,7 @@ public class TitleScreenModUpdateIndicator extends Screen {
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
public void extractRenderState(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTick) {
if (showNotification == null || !showNotification.shouldDraw() || !FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.VERSION_CHECK))
return;
@@ -6,8 +6,8 @@
package net.minecraftforge.client.gui.overlay;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
public interface ForgeLayer {
void render(GuiGraphics gg, DeltaTracker dt);
void extract(GuiGraphicsExtractor gg, DeltaTracker dt);
}
@@ -9,7 +9,7 @@ import com.mojang.logging.LogUtils;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.resources.Identifier;
import net.minecraftforge.client.event.ForgeEventFactoryClient;
import net.minecraftforge.client.event.AddGuiOverlayLayersEvent;
@@ -270,7 +270,7 @@ public final class ForgeLayeredDraw implements ForgeLayer {
var result = namedLayers.computeIfPresent(targetLayer,
(name, layer) -> (guiGraphics, deltaTracker) -> {
if (condition.getAsBoolean()) {
layer.render(guiGraphics, deltaTracker);
layer.extract(guiGraphics, deltaTracker);
}
});
if (result == null) {
@@ -304,7 +304,7 @@ public final class ForgeLayeredDraw implements ForgeLayer {
var entry = subLayerStacks.get(layerName);
entry.getKey().resolveNested();
bakedLayers.add((gg, tr) -> {
if (entry.getValue().getAsBoolean()) entry.getKey().render(gg,tr);
if (entry.getValue().getAsBoolean()) entry.getKey().extract(gg,tr);
});
} else {
bakedLayers.add(namedLayers.get(layerName));
@@ -368,41 +368,41 @@ public final class ForgeLayeredDraw implements ForgeLayer {
}
@ApiStatus.Internal
public static void beginRender(GuiGraphics gg, DeltaTracker dt) {
instance.render(gg,dt);
public static void extractRenderState(GuiGraphicsExtractor gg, DeltaTracker dt) {
instance.extract(gg, dt);
}
@ApiStatus.Internal
public void render(GuiGraphics gg, DeltaTracker dt) {
public void extract(GuiGraphicsExtractor gg, DeltaTracker dt) {
for (ForgeLayer bakedLayer : bakedLayers) {
bakedLayer.render(gg, dt);
bakedLayer.extract(gg, dt);
}
}
@ApiStatus.Internal
public static void init(Gui gui, Minecraft minecraft) {
var preSleepDraw = new ForgeLayeredDraw(PRE_SLEEP_STACK)
.add(CAMERA_OVERLAY, gui::renderCameraOverlays)
.add(CROSSHAIR, gui::renderCrosshair)
.add(CAMERA_OVERLAY, gui::extractCameraOverlays)
.add(CROSSHAIR, gui::extractCrosshair)
.add(CHANGE_STRATUM, (gg, dt) -> gg.nextStratum())
.add(HOTBAR_AND_DECOS, gui::renderHotbarAndDecorations)
.add(POTION_EFFECTS, gui::renderEffects)
.add(BOSS_OVERLAY, gui::renderBossOverlay);
.add(HOTBAR_AND_DECOS, gui::extractHotbarAndDecorations)
.add(POTION_EFFECTS, gui::extractEffects)
.add(BOSS_OVERLAY, gui::extractBossOverlay);
var postSleepDraw = new ForgeLayeredDraw(POST_SLEEP_STACK)
.add(DEMO_OVERLAY, gui::renderDemoOverlay)
.add(SCOREBOARD, gui::renderScoreboardSidebar)
.add(HOTBAR_MESSAGE, gui::renderOverlayMessage)
.add(TITLE_OVERLAY, gui::renderTitle)
.add(CHAT_OVERLAY, gui::renderChat)
.add(TAB_LIST, gui::renderTabList)
.add(SUBTITLE_OVERLAY, (gfx, delta) -> gui.renderSubtitleOverlay(gfx, minecraft.screen != null && minecraft.screen.isInGameUi()));
.add(DEMO_OVERLAY, gui::extractDemoOverlay)
.add(SCOREBOARD, gui::extractScoreboardSidebar)
.add(HOTBAR_MESSAGE, gui::extractOverlayMessage)
.add(TITLE_OVERLAY, gui::extractTitle)
.add(CHAT_OVERLAY, gui::extractChat)
.add(TAB_LIST, gui::extractTabList)
.add(SUBTITLE_OVERLAY, (gfx, delta) -> gui.extractSubtitleOverlay(gfx, minecraft.screen != null && minecraft.screen.isInGameUi()));
instance
.add(PRE_SLEEP_STACK, preSleepDraw, () -> !minecraft.options.hideGui)
.add(SLEEP_OVERLAY, gui::renderSleepOverlay)
.add(SLEEP_OVERLAY, gui::extractSleepOverlay)
.add(POST_SLEEP_STACK, postSleepDraw, () -> !minecraft.options.hideGui)
.add(SUBTITLE_OVERLAY, (gfx, delta) -> {
if (minecraft.options.hideGui && minecraft.screen != null && minecraft.screen.isInGameUi())
gui.renderSubtitleOverlay(gfx, true);
gui.extractSubtitleOverlay(gfx, true);
});
instance.resolveLayers();
}
@@ -6,7 +6,7 @@
package net.minecraftforge.client.gui.widget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.locale.Language;
@@ -38,11 +38,11 @@ public class ExtendedButton extends Button {
* Draws this button to the screen.
*/
@Override
public void renderContents(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
public void extractContents(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTick) {
Minecraft mc = Minecraft.getInstance();
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());
guiGraphics.centeredText(mc.font, Language.getInstance().getVisualOrder(buttonText), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, getFGColor());
}
}
@@ -5,8 +5,7 @@
package net.minecraftforge.client.gui.widget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.AbstractSliderButton;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.client.input.MouseButtonEvent;
@@ -197,10 +196,10 @@ public class ForgeSlider extends AbstractSliderButton {
protected void applyValue() {}
@Override
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
public void extractWidgetRenderState(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTick) {
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());
renderScrollingStringOverContents(guiGraphics.textRendererForWidget(this, GuiGraphics.HoveredTextEffects.NONE), this.getMessage(), 2);
extractScrollingStringOverContents(guiGraphics.textRendererForWidget(this, GuiGraphicsExtractor.HoveredTextEffects.NONE), this.getMessage(), 2);
}
}
@@ -6,7 +6,7 @@
package net.minecraftforge.client.gui.widget;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.client.renderer.RenderPipelines;
@@ -45,8 +45,8 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry> {
}
@Override
protected void renderSelection(GuiGraphics gui, ModListWidget.ModEntry entry, int color) {
int widthOffset = this.scrollbarVisible() ? 11 : 4;
protected void extractSelection(GuiGraphicsExtractor gui, ModListWidget.ModEntry entry, int color) {
int widthOffset = this.scrollable() ? 11 : 4;
int top = entry.getContentY();
int left = entry.getContentX();
int right = left + entry.getWidth() - widthOffset;
@@ -75,7 +75,7 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry> {
}
@Override
public void renderContent(GuiGraphics guiGraphics, int mouseX, int mouseY, boolean isMouseOver, float partialTick) {
public void extractContent(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, boolean isMouseOver, float partialTick) {
int top = this.getContentY();
int left = this.getContentX();
int entryHeight = this.getContentBottom();
@@ -84,9 +84,9 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry> {
Component version = Component.literal(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
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, 0xFFFFFFFF, false);
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth - 6 - barOffset))), left + 3, top + 2 + font.lineHeight, 0xFFCCCCCC, false);
var barOffset = ModListWidget.this.scrollable() ? 6 : 0;
guiGraphics.text(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth - 6 - barOffset))), left + 3, top + 2, 0xFFFFFFFF, false);
guiGraphics.text(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
guiGraphics.pose().pushMatrix();
@@ -6,7 +6,7 @@
package net.minecraftforge.client.gui.widget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
import net.minecraft.client.gui.components.events.GuiEventListener;
@@ -143,7 +143,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
/**
* Draws the background of the scroll panel. This runs AFTER Scissors are enabled.
*/
protected void drawBackground(GuiGraphics guiGraphics, float partialTick) {
protected void drawBackground(GuiGraphicsExtractor guiGraphics, float partialTick) {
if (this.client.level != null)
this.drawGradientRect(guiGraphics, this.left, this.top, this.right, this.bottom, bgColorFrom, bgColorTo);
}
@@ -152,7 +152,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
* Draw anything special on the screen. Scissor (RenderSystem.enableScissor) is enabled
* for anything that is rendered outside the view box. Do not mess with Scissor unless you support this.
*/
protected abstract void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY);
protected abstract void drawPanel(GuiGraphicsExtractor guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY);
protected boolean clickPanel(double mouseX, double mouseY, int button) {
return false;
@@ -245,7 +245,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
}
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
public void extractRenderState(GuiGraphicsExtractor guiGraphics, int mouseX, int mouseY, float partialTick) {
guiGraphics.enableScissor(left, top, left + width, top + height);
this.drawBackground(guiGraphics, partialTick);
@@ -289,7 +289,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
}
}
protected void drawGradientRect(GuiGraphics guiGraphics, int left, int top, int right, int bottom, int color1, int color2) {
protected void drawGradientRect(GuiGraphicsExtractor guiGraphics, int left, int top, int right, int bottom, int color1, int color2) {
guiGraphics.fillGradient(left, top, right, bottom, color1, color2);
}
@@ -30,7 +30,7 @@ import net.minecraftforge.client.gui.LoadingErrorScreen;
import net.minecraftforge.resource.ResourcePackLoader;
import net.minecraftforge.server.LanguageHook;
public class ClientModLoader {
public final class ClientModLoader {
private static final Logger LOGGER = LogManager.getLogger();
private static boolean loading;
private static Minecraft mc;
@@ -45,7 +45,7 @@ public class ClientModLoader {
ClientModLoader.mc = minecraft;
LogicalSidedProvider.setClient(()->minecraft);
LanguageHook.loadForgeAndMCLangs();
createRunnableWithCatch(()->ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ImmediateWindowHandler::renderTick)).run();
createRunnableWithCatch(() -> ModLoader.gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ImmediateWindowHandler::renderTick)).run();
if (error == null) {
ResourcePackLoader.loadResourcePacks(defaultResourcePacks, true);
net.minecraftforge.event.AddPackFindersEvent.BUS.post(new AddPackFindersEvent(PackType.CLIENT_RESOURCES, defaultResourcePacks::addPackFinder));
@@ -73,11 +73,11 @@ public class ClientModLoader {
}
private static void startModLoading(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor) {
createRunnableWithCatch(() -> ModLoader.get().loadMods(syncExecutor, parallelExecutor, ImmediateWindowHandler::renderTick)).run();
createRunnableWithCatch(() -> ModLoader.loadMods(syncExecutor, parallelExecutor, ImmediateWindowHandler::renderTick)).run();
}
private static void finishModLoading(ModWorkManager.DrivenExecutor syncExecutor, Executor parallelExecutor) {
createRunnableWithCatch(() -> ModLoader.get().finishMods(syncExecutor, parallelExecutor, ImmediateWindowHandler::renderTick)).run();
createRunnableWithCatch(() -> ModLoader.finishMods(syncExecutor, parallelExecutor, ImmediateWindowHandler::renderTick)).run();
loading = false;
loadingComplete = true;
// reload game settings on main thread
@@ -85,7 +85,7 @@ public class ClientModLoader {
}
public static VersionChecker.Status checkForUpdates() {
boolean anyOutdated = ModList.get().getMods().stream()
boolean anyOutdated = ModList.getMods().stream()
.map(VersionChecker::getResult)
.map(VersionChecker.CheckResult::status)
.anyMatch(VersionChecker.Status::isOutdated);
@@ -93,7 +93,7 @@ public class ClientModLoader {
}
public static boolean completeModLoading() {
var warnings = ModLoader.get().getWarnings();
var warnings = ModLoader.getWarnings();
boolean showWarnings = ForgeConfig.CLIENT.showLoadWarnings();
if (!showWarnings) {
@@ -8,7 +8,7 @@ package net.minecraftforge.client.loading;
import com.mojang.blaze3d.opengl.GlTexture;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.LoadingOverlay;
import net.minecraft.client.renderer.rendertype.RenderType;
import net.minecraft.server.packs.resources.ReloadInstance;
@@ -59,7 +59,7 @@ public class ForgeLoadingOverlay extends LoadingOverlay {
}
@Override
protected boolean renderContents(GuiGraphics gui, float fade) {
protected boolean extractContentRenderState(final GuiGraphicsExtractor graphics, float fade) {
if (!ENABLE)
return true;
/* This should render the framebuffer but it doesnt work in 1.21.6's rendering changes.
@@ -6,6 +6,9 @@
package net.minecraftforge.client.loading;
import com.mojang.blaze3d.platform.Monitor;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.GpuBackend;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.LoadingOverlay;
import net.minecraft.server.packs.resources.ReloadInstance;
@@ -13,7 +16,6 @@ import net.minecraft.server.packs.resources.ReloadInstance;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
import java.util.function.LongSupplier;
import java.util.function.Supplier;
@@ -21,8 +23,20 @@ import org.lwjgl.glfw.GLFW;
public final class NoVizFallback {
private static long WINDOW;
public static LongSupplier windowHandoff(IntSupplier width, IntSupplier height, Supplier<String> title, LongSupplier monitor) {
return () -> WINDOW = GLFW.glfwCreateWindow(width.getAsInt(), height.getAsInt(), title.get(), monitor.getAsLong(), 0L);
public static LongSupplier windowHandoff(int width, int height, String title, long monitor, Supplier<Object> backend) {
return () -> {
try {
return WINDOW = Window.createGlfwWindow(width, height, title, monitor, (GpuBackend)backend.get());
} catch (Throwable e) {
return sneak(e);
}
};
}
@SuppressWarnings("unchecked")
private static <R, E extends Throwable> R sneak(Throwable t) throws E {
throw (E)t;
}
public static Supplier<LoadingOverlay> loadingOverlay(Supplier<Minecraft> mc, Supplier<ReloadInstance> ri, Consumer<Optional<Throwable>> ex, boolean fadein) {
@@ -8,16 +8,17 @@ 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.block.model.TextureSlots;
import net.minecraft.client.renderer.block.dispatch.ModelState;
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;
import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelDebugName;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.QuadCollection;
import net.minecraft.client.resources.model.UnbakedGeometry;
import net.minecraft.client.resources.model.cuboid.ItemModelGenerator;
import net.minecraft.client.resources.model.geometry.BakedQuad.MaterialInfo;
import net.minecraft.client.resources.model.geometry.QuadCollection;
import net.minecraft.client.resources.model.geometry.UnbakedGeometry;
import net.minecraft.client.resources.model.sprite.Material;
import net.minecraft.client.resources.model.sprite.TextureSlots;
import net.minecraft.resources.Identifier;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.level.material.Fluid;
@@ -64,11 +65,6 @@ public class DynamicFluidContainerModel implements UnbakedGeometry {
return new RenderTypeGroup(ChunkSectionLayer.TRANSLUCENT, unlit ? ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get() : ForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get());
}
@SuppressWarnings("deprecation")
private static Material getMaterial(Identifier texture) {
return new Material(TextureAtlas.LOCATION_BLOCKS, texture);
}
/**
* Returns a new ModelDynBucket representing the given fluid, but with the same
* other properties (flipGas, tint, coverIsMask).
@@ -89,13 +85,13 @@ public class DynamicFluidContainerModel implements UnbakedGeometry {
if (fluid != Fluids.EMPTY) {
var stillTexture = IClientFluidTypeExtensions.of(fluid).getStillTexture();
stillMaterial = getMaterial(stillTexture);
stillMaterial = new Material(stillTexture);
}
var sprites = baker.sprites();
var baseSprite = sprites.resolveSlot(textures, "base", name);
var fluidSprite = stillMaterial == null ? null : sprites.get(stillMaterial, name);
var coverSprite = sprites.resolveSlot(textures, "cover", name);
var materials = baker.materials();
var baseMaterial = materials.resolveSlot(textures, "base", name);
var fluidMaterial = stillMaterial == null ? null : materials.get(stillMaterial, name);
var coverMaterial = materials.resolveSlot(textures, "cover", name);
/*
var particleSprite = sprites.resolveSlot(textures, "particle", name);
@@ -113,34 +109,24 @@ public class DynamicFluidContainerModel implements UnbakedGeometry {
var buf = new QuadCollection.Builder();
if (baseSprite != null) {
// Base texture
var unbaked = UnbakedGeometryHelper.createUnbakedItemElements(0, baseSprite.contents());
UnbakedGeometryHelper.bakeElements(baker.parts(), unbaked, $ -> baseSprite, state, buf);
}
if (baseMaterial != null)
ItemModelGenerator.bakeExtrudedSprite(buf, baker.interner(), state, info(baker, baseMaterial, 0));
if (fluidMaskLocation != null && fluidSprite != null) {
TextureAtlasSprite templateSprite = sprites.get(fluidMaskLocation, name);
if (templateSprite != null) {
// Fluid layer
// Fluid layer
if (fluidMaskLocation != null && fluidMaterial != null) {
var templateMaterial = materials.get(fluidMaskLocation, name);
if (templateMaterial != null) {
var transformedState = new SimpleModelState(transformation.compose(FLUID_TRANSFORM));
var unbaked = UnbakedGeometryHelper.createUnbakedItemMaskElements(1, templateSprite.contents()); // Use template as mask
//var emissive = applyFluidLuminosity && fluid.getFluidType().getLightLevel() > 0;
//var transformer = emissive ? QuadTransformers.settingMaxEmissivity() : QuadTransformers.empty();
// TODO: [Forge][Rendering] Emissive fluid models
UnbakedGeometryHelper.bakeElements(baker.parts(), unbaked, $ -> fluidSprite, transformedState, buf); // Bake with fluid texture
UnbakedGeometryHelper.bakeMaskedSprite(buf, baker.interner(), transformedState, info(baker, templateMaterial, 1), info(baker, fluidMaterial, 1));
}
}
if (coverSprite != null) {
var sprite = coverIsMask ? baseSprite : coverSprite;
// Cover/overlay
if (coverMaterial != null) {
var sprite = coverIsMask ? baseMaterial : coverMaterial;
if (sprite != null) {
// Cover/overlay
var transformedState = new SimpleModelState(transformation.compose(COVER_TRANSFORM));
var unbaked = UnbakedGeometryHelper.createUnbakedItemMaskElements(2, coverSprite.contents()); // Use cover as mask
UnbakedGeometryHelper.bakeElements(baker.parts(), unbaked, $ -> sprite, transformedState, buf); // Bake with selected texture
UnbakedGeometryHelper.bakeMaskedSprite(buf, baker.interner(), transformedState, info(baker, coverMaterial, 2), info(baker, sprite, 2));
}
}
@@ -148,6 +134,12 @@ public class DynamicFluidContainerModel implements UnbakedGeometry {
return buf.build();
}
private static MaterialInfo info(final ModelBaker baker, final Material.Baked material, final int tintIndex) {
return baker.interner().materialInfo(
MaterialInfo.of(material, material.sprite().transparency(), tintIndex, true, 0)
);
}
public static final class Loader implements IGeometryLoader {
public static final Loader INSTANCE = new Loader();
@@ -13,12 +13,9 @@ import com.mojang.serialization.Codec;
import com.mojang.serialization.JsonOps;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.client.renderer.block.model.BlockElement;
import net.minecraft.client.renderer.block.model.BlockElementFace;
/**
* Holds extra data that may be injected into a face.<p>
* Used by {@link ItemLayerGeometry}, {@link BlockElement} and {@link BlockElementFace}
* Used by {@link BlockElement} and {@link BlockElementFace}
*
* @param ambientOcclusion If this face has AO
* @param calculateNormals If we should manually calculate the normals for this block or inherit facing normals like vanilla
@@ -5,9 +5,10 @@
package net.minecraftforge.client.model;
import net.minecraft.client.renderer.block.model.BakedQuad;
import java.util.List;
import net.minecraft.client.resources.model.geometry.BakedQuad;
/**
* Transformer for {@link BakedQuad baked quads}.
*
@@ -1,125 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.client.model;
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.minecraft.client.renderer.rendertype.RenderType;
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
import net.minecraft.client.renderer.block.model.SimpleUnbakedGeometry;
import net.minecraft.client.renderer.block.model.TextureSlots;
import net.minecraft.client.renderer.block.model.BlockElement;
import net.minecraft.client.renderer.block.model.BlockModelPart;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelDebugName;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.QuadCollection;
import net.minecraft.client.resources.model.UnbakedGeometry;
import net.minecraft.resources.Identifier;
import net.minecraftforge.client.ForgeRenderTypes;
import net.minecraftforge.client.RenderTypeGroup;
import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
import net.minecraftforge.client.model.geometry.IGeometryLoader;
import net.minecraftforge.client.model.geometry.IUnbakedGeometry;
import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.Nullable;
/**
* Forge version of vanilla's {@link ItemModelGenerator}, i.e. builtin/generated models with some tweaks:
* - Represented as {@link UnbakedGeometry} so it can be used in multiple root models
* - Not limited to an arbitrary number of layers (5)
//* - Support for per-layer render types - Currently Doesn't work. TODO: [Forge][Model] Make a Model loader for this
*/
@SuppressWarnings("unused")
public class ItemLayerGeometry implements UnbakedGeometry {
private static final ItemLayerGeometry INSTANCE = new ItemLayerGeometry(Int2ObjectMaps.emptyMap(), Int2ObjectMaps.emptyMap());
private final Int2ObjectMap<Identifier> renderTypeNames;
private final Int2ObjectMap<Identifier> renderTypeFastNames;
private ItemLayerGeometry(Int2ObjectMap<Identifier> renderTypeNames, Int2ObjectMap<Identifier> renderTypeFastNames) {
this.renderTypeNames = renderTypeNames;
this.renderTypeFastNames = renderTypeFastNames;
}
@Override
public QuadCollection bake(TextureSlots textures, ModelBaker baker, ModelState state, ModelDebugName name) {
List<BlockElement> elements = new ArrayList<>();
int i = 0;
while (true) {
var layer = "layer" + i++;
var material = textures.getMaterial(layer);
if (material == null)
break;
var contents = baker.sprites().get(material, name).contents();
elements.addAll(ItemModelGenerator.processFrames(i, layer, contents));
}
return SimpleUnbakedGeometry.bake(elements, textures, baker, state, name);
/*
Material particleMaterial = spriteGetter.getMaterial("particle");
var particle = baker.sprites().get(particleMaterial == null ? textures.get(0) : particleMaterial, name);
var rootTransform = context.getRootTransform();
if (!rootTransform.isIdentity())
modelState = UnbakedGeometryHelper.composeRootTransformIntoModelState(modelState, rootTransform);
var normalRenderTypes = new RenderTypeGroup(RenderType.translucent(), ForgeRenderTypes.ITEM_UNSORTED_TRANSLUCENT.get());
var builder = CompositeModel.Baked.builder(context, particle, context.getTransforms());
for (int i = 0; i < textures.size(); i++) {
var sprite = baker.sprites().get(textures.get(i), name);
var unbaked = UnbakedGeometryHelper.createUnbakedItemElements(i, sprite.contents());
var quads = UnbakedGeometryHelper.bakeElements(unbaked, $ -> sprite, modelState);
var renderTypeName = renderTypeNames.get(i);
var renderTypes = renderTypeName != null ? context.getRenderType(renderTypeName) : null;
var renderTypeFastName = renderTypeFastNames.get(i);
var renderTypesFast = renderTypeFastName != null ? context.getRenderType(renderTypeFastName) : null;
builder.addQuads(renderTypes != null ? renderTypes : normalRenderTypes, renderTypesFast != null ? renderTypesFast : RenderTypeGroup.EMPTY, quads);
}
return builder.build();
*/
}
public static final class Loader implements IGeometryLoader {
public static final Loader INSTANCE = new Loader();
@Override
public UnbakedGeometry read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) {
return ItemLayerGeometry.INSTANCE;
/*
var renderTypeNames = readRenderTypeNames(jsonObject, "render_types");
var renderTypeFastNames = readRenderTypeNames(jsonObject, "render_types_fast");
return new ItemLayerModel(renderTypeNames, renderTypeFastNames);
*/
}
private static Int2ObjectMap<Identifier> readRenderTypeNames(JsonObject jsonObject, String key) {
var renderTypeNames = new Int2ObjectOpenHashMap<Identifier>();
if (jsonObject.has(key)) {
var renderTypes = jsonObject.getAsJsonObject(key);
for (var entry : renderTypes.entrySet()) {
var renderType = Identifier.parse(entry.getKey());
for (var layer : entry.getValue().getAsJsonArray())
if (renderTypeNames.put(layer.getAsInt(), renderType) != null)
throw new JsonParseException("Registered duplicate " + key + " for layer " + layer);
}
}
return renderTypeNames;
}
}
}
@@ -6,7 +6,9 @@
package net.minecraftforge.client.model;
import com.mojang.math.Transformation;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.resources.model.geometry.BakedQuad;
import org.joml.Vector3f;
import org.joml.Vector3fc;
import org.joml.Vector4f;
@@ -44,7 +46,7 @@ public final class QuadTransformers {
return new BakedQuad(positions[0], positions[1], positions[2], positions[3],
quad.packedUV0(), quad.packedUV1(), quad.packedUV2(), quad.packedUV3(),
quad.tintIndex(), quad.direction(), quad.sprite(), quad.shade(), quad.lightEmission(), quad.ambientOcclusion());
quad.direction(), quad.materialInfo());
};
}
/**
@@ -6,7 +6,8 @@
package net.minecraftforge.client.model;
import com.mojang.math.Transformation;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.renderer.block.dispatch.ModelState;
/**
* Simple implementation of {@link ModelState}.
@@ -6,7 +6,6 @@
package net.minecraftforge.client.model.data;
import com.google.common.base.Preconditions;
import net.minecraft.client.renderer.block.model.BlockModelPart;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.Contract;
@@ -44,7 +44,7 @@ public class ModelDataManager {
public void requestRefresh(@NotNull BlockEntity blockEntity) {
Preconditions.checkNotNull(blockEntity, "Block entity must not be null");
needModelDataRefresh.computeIfAbsent(new ChunkPos(blockEntity.getBlockPos()), $ -> Collections.synchronizedSet(new HashSet<>()))
needModelDataRefresh.computeIfAbsent(ChunkPos.containing(blockEntity.getBlockPos()), $ -> Collections.synchronizedSet(new HashSet<>()))
.add(blockEntity.getBlockPos());
}
@@ -64,7 +64,12 @@ public class ModelDataManager {
}
public @Nullable ModelData getAt(BlockPos pos) {
return getAt(new ChunkPos(pos)).get(pos);
return getAt(ChunkPos.containing(pos)).get(pos);
}
public ModelData getAtOrEmpty(double x, double y, double z) {
var ret = getAt(BlockPos.containing(x, y, z));
return ret == null ? ModelData.EMPTY : ret;
}
public ModelData getAtOrEmpty(BlockPos pos) {
@@ -5,26 +5,24 @@
package net.minecraftforge.client.model.data;
import net.minecraft.client.renderer.block.model.BlockModelPart;
import org.jetbrains.annotations.Nullable;
import net.minecraft.client.renderer.block.dispatch.BlockStateModelPart;
import java.util.IdentityHashMap;
import java.util.Map;
public class MultipartModelData
{
public class MultipartModelData {
public static final ModelProperty<MultipartModelData> PROPERTY = new ModelProperty<>();
private final Map<BlockModelPart, ModelData> partData;
private final Map<BlockStateModelPart, ModelData> partData;
private MultipartModelData(Map<BlockModelPart, ModelData> partData)
{
private MultipartModelData(Map<BlockStateModelPart, ModelData> partData) {
this.partData = partData;
}
@Nullable
public ModelData get(BlockModelPart model)
{
public ModelData get(BlockStateModelPart model) {
return partData.get(model);
}
@@ -35,8 +33,7 @@ public class MultipartModelData
* @param model The model to get data for
* @return The data for the part, or the one passed in if not found
*/
public static ModelData resolve(ModelData modelData, BlockModelPart model)
{
public static ModelData resolve(ModelData modelData, BlockStateModelPart model) {
var multipartData = modelData.get(PROPERTY);
if (multipartData == null)
return modelData;
@@ -44,23 +41,19 @@ public class MultipartModelData
return partData != null ? partData : modelData;
}
public static Builder builder()
{
public static Builder builder() {
return new Builder();
}
public static final class Builder
{
private final Map<BlockModelPart, ModelData> partData = new IdentityHashMap<>();
public static final class Builder {
private final Map<BlockStateModelPart, ModelData> partData = new IdentityHashMap<>();
public Builder with(BlockModelPart model, ModelData data)
{
public Builder with(BlockStateModelPart model, ModelData data) {
partData.put(model, data);
return this;
}
public MultipartModelData build()
{
public MultipartModelData build() {
return new MultipartModelData(partData);
}
}
@@ -6,8 +6,8 @@
package net.minecraftforge.client.model.geometry;
import com.mojang.math.Transformation;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.cuboid.ItemTransforms;
import net.minecraft.resources.Identifier;
import net.minecraftforge.client.NamedRenderTypeManager;
import net.minecraftforge.client.RenderTypeGroup;
@@ -9,7 +9,7 @@ import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import net.minecraft.client.resources.model.UnbakedGeometry;
import net.minecraft.client.resources.model.geometry.UnbakedGeometry;
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
import net.minecraftforge.client.event.ModelEvent.RegisterGeometryLoaders;
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
@@ -1,42 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.client.model.geometry;
import java.util.Set;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.TextureSlots;
import net.minecraft.client.renderer.block.model.BlockModelPart;
import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.ResolvableModel;
import net.minecraft.client.resources.model.UnbakedModel;
/**
* General interface for any model that can be baked, superset of vanilla {@link UnbakedModel}.
* <p>
* Instances of this class are usually created via {@link IGeometryLoader}.
*
* @see IGeometryLoader
* @see IGeometryBakingContext
*/
public interface IUnbakedGeometry<T extends IUnbakedGeometry<T>> {
BlockModelPart bake(IGeometryBakingContext context, ModelBaker baker, TextureSlots spriteGetter, ModelState modelState);
/**
* Resolve parents of nested {@link BlockModel}s which are later used in
* {@link IUnbakedGeometry#bake(IGeometryBakingContext, ModelBaker, TextureSlots, ModelState)}
* via {@link BlockModel#resolveParents(Function)}
*/
default void resolveDependencies(ResolvableModel.Resolver resolver, IGeometryBakingContext context) { }
/**
* {@return a set of all the components whose visibility may be configured via {@link IGeometryBakingContext}}
*/
default Set<String> getConfigurableComponentNames() {
return Set.of();
}
}
@@ -10,10 +10,10 @@ import org.jetbrains.annotations.Nullable;
import com.mojang.math.Transformation;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.resources.model.ModelDiscovery.ModelWrapper;
import net.minecraft.client.resources.model.ResolvedModel;
import net.minecraft.client.resources.model.cuboid.CuboidModel;
import net.minecraft.client.resources.model.cuboid.ItemTransforms;
import net.minecraft.resources.Identifier;
import net.minecraftforge.client.model.ForgeBlockModelData;
@@ -29,11 +29,11 @@ public record ModelContext(
}
private static ForgeBlockModelData makeData(ResolvedModel self, ResolvedModel parent) {
var data = self.wrapped() instanceof BlockModel block ? block.forgeData() : null;
var data = self.wrapped() instanceof CuboidModel block ? block.forgeData() : null;
var p = parent;
while (p != null && (data == null || !data.full())) {
if (p.wrapped() instanceof BlockModel block) {
if (p.wrapped() instanceof CuboidModel block) {
if (data == null)
data = block.forgeData();
else
@@ -72,7 +72,7 @@ public record ModelContext(
@Override
public Transformation getRootTransform() {
return data == null ? Transformation.identity() : data.transform().orElse(Transformation.identity());
return data == null ? Transformation.IDENTITY : data.transform().orElse(Transformation.IDENTITY);
}
@Override
@@ -7,7 +7,7 @@ package net.minecraftforge.client.model.geometry;
import com.mojang.math.Transformation;
import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.resources.model.cuboid.ItemTransforms;
import net.minecraft.resources.Identifier;
import org.jetbrains.annotations.Nullable;
@@ -115,7 +115,7 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext {
private boolean useBlockLight = true;
private boolean useAmbientOcclusion = true;
private ItemTransforms transforms = ItemTransforms.NO_TRANSFORMS;
private Transformation rootTransform = Transformation.identity();
private Transformation rootTransform = Transformation.IDENTITY;
@Nullable
private Identifier renderTypeHint;
@Nullable
@@ -7,21 +7,16 @@ package net.minecraftforge.client.model.geometry;
import com.mojang.math.Quadrant;
import com.mojang.math.Transformation;
import net.minecraft.util.Util;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BlockElement;
import net.minecraft.client.renderer.block.model.BlockElementFace;
import net.minecraft.client.renderer.block.model.FaceBakery;
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
import net.minecraft.client.renderer.block.model.TextureSlots;
import net.minecraft.client.renderer.block.dispatch.ModelState;
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
import net.minecraft.client.renderer.texture.SpriteContents;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.QuadCollection;
import net.minecraft.client.resources.model.cuboid.FaceBakery;
import net.minecraft.client.resources.model.cuboid.ItemModelGenerator;
import net.minecraft.client.resources.model.geometry.BakedQuad;
import net.minecraft.client.resources.model.geometry.QuadCollection;
import net.minecraft.client.resources.model.sprite.Material;
import net.minecraft.client.resources.model.sprite.TextureSlots;
import net.minecraft.core.Direction;
import net.minecraft.resources.Identifier;
import net.minecraftforge.client.model.SimpleModelState;
@@ -31,8 +26,6 @@ import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;
import java.util.BitSet;
import java.util.List;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -85,25 +78,20 @@ public class UnbakedGeometryHelper {
}
/**
* Creates a list of {@linkplain BlockElement block elements} in the shape of the specified sprite contents.
* These can later be baked using the same, or another texture.
* <p>
* The {@link Direction#NORTH} and {@link Direction#SOUTH} faces take up the whole surface.
* Builds the model who's {@link Direction#NORTH} and {@link Direction#SOUTH} faces take up only the pixels the texture uses.
*
* This is basically ItemModelGenrator#bakeExtrudedSprite except for the front faces are not spread across the entire side
*
* Takes in a template MaterialInfo for the geometry, and a separate one to actually apply the texture from
*/
public static List<BlockElement> createUnbakedItemElements(int layerIndex, SpriteContents spriteContents) {
return ItemModelGenerator.processFrames(layerIndex, "layer" + layerIndex, spriteContents);
}
/**
* Creates a list of {@linkplain BlockElement block elements} in the shape of the specified sprite contents.
* These can later be baked using the same, or another texture.
* <p>
* The {@link Direction#NORTH} and {@link Direction#SOUTH} faces take up only the pixels the texture uses.
*/
public static List<BlockElement> createUnbakedItemMaskElements(int layerIndex, SpriteContents spriteContents) {
var elements = createUnbakedItemElements(layerIndex, spriteContents);
elements.remove(0); // Remove north and south faces
public static void bakeMaskedSprite(
final QuadCollection.Builder builder,
final ModelBaker.Interner interner,
final ModelState state,
final BakedQuad.MaterialInfo texture,
final BakedQuad.MaterialInfo template
) {
var spriteContents = template.sprite().contents();
int width = spriteContents.width(), height = spriteContents.height();
var bits = new BitSet(width * height);
@@ -140,56 +128,26 @@ public class UnbakedGeometryHelper {
for (int j = y; j < yEnd; j++)
bits.clear(i + j * width);
var from = new Vector3f(16 * xStart / (float) width, 16 - 16 * yEnd / (float) height, 7.5F);
var to = new Vector3f(16 * x / (float) width, 16 - 16 * y / (float) height, 8.5F);
// Create element
elements.add(new BlockElement(
new Vector3f(16 * xStart / (float) width, 16 - 16 * yEnd / (float) height, 7.5F),
new Vector3f(16 * x / (float) width, 16 - 16 * y / (float) height, 8.5F),
Util.makeEnumMap(Direction.class, dir -> new BlockElementFace(dir, layerIndex, "layer" + layerIndex, new BlockElementFace.UVs(0F, 0F, 16F, 16F), Quadrant.R0))
));
builder.addUnculledFace(FaceBakery.bakeQuad(interner, from, to, ItemModelGenerator.SOUTH_FACE_UVS, Quadrant.R0, texture, Direction.SOUTH, state, null));
builder.addUnculledFace(FaceBakery.bakeQuad(interner, from, to, ItemModelGenerator.NORTH_FACE_UVS, Quadrant.R0, texture, Direction.NORTH, state, null));
// Reset xStart
xStart = -1;
}
}
}
return elements;
}
/**
* Bakes a list of {@linkplain BlockElement block elements} and returns a {@link QuadCollection}.
*/
public static QuadCollection bakeElements(ModelBaker.PartCache cache, List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState) {
var builder = new QuadCollection.Builder();
bakeElements(cache, elements, spriteGetter, modelState, builder);
return builder.build();
}
/**
* Adds a list of {@linkplain BlockElement block elements} int a {@link QuadCollection.Builder}.
*/
public static void bakeElements(ModelBaker.PartCache cache, List<BlockElement> elements, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, QuadCollection.Builder builder) {
for (var element : elements) {
element.faces().forEach((side, face) -> {
var sprite = spriteGetter.apply(getMaterial(face.texture()));
var quad = bakeElementFace(cache, element, face, sprite, side, modelState, element.lightEmission());
if (face.cullForDirection() == null)
builder.addUnculledFace(quad);
else
builder.addCulledFace(Direction.rotate(modelState.transformation().getMatrix(), face.cullForDirection()), quad);
});
}
// Re-use vanilla code to create the side geometry
ItemModelGenerator.bakeSideFaces(builder, interner, state, texture, template);
}
@SuppressWarnings("deprecation")
private static Material getMaterial(String texture) {
return new Material(TextureAtlas.LOCATION_BLOCKS, Identifier.parse(texture));
}
/**
* Turns a single {@link BlockElementFace} into a {@link BakedQuad}.
*/
public static BakedQuad bakeElementFace(ModelBaker.PartCache cache, BlockElement element, BlockElementFace face, TextureAtlasSprite sprite, Direction direction, ModelState state, int lightEmission) {
return FaceBakery.bakeQuad(cache, element.from(), element.to(), face, sprite, direction, state, element.rotation(), element.shade(), lightEmission);
return new Material(Identifier.parse(texture));
}
/**
@@ -9,12 +9,12 @@ import com.google.common.collect.Maps;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.TextureSlots;
import net.minecraft.client.renderer.block.dispatch.ModelState;
import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelDebugName;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.QuadCollection;
import net.minecraft.client.resources.model.UnbakedGeometry;
import net.minecraft.client.resources.model.geometry.QuadCollection;
import net.minecraft.client.resources.model.geometry.UnbakedGeometry;
import net.minecraft.client.resources.model.sprite.TextureSlots;
import net.minecraft.resources.Identifier;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
@@ -9,17 +9,18 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.mojang.math.Transformation;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.TextureSlots;
import net.minecraft.client.renderer.block.dispatch.ModelState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelDebugName;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.QuadCollection;
import net.minecraft.client.resources.model.geometry.BakedQuad;
import net.minecraft.client.resources.model.geometry.QuadCollection;
import net.minecraft.client.resources.model.sprite.Material;
import net.minecraft.client.resources.model.sprite.TextureSlots;
import net.minecraft.core.Direction;
import net.minecraft.resources.Identifier;
import net.minecraft.util.LightCoordsUtil;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec2;
import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
@@ -314,7 +315,7 @@ public class ObjModel {
int uv2 = 0;
if (emissiveAmbient) {
int fakeLight = (int) ((ambientColor.x() + ambientColor.y() + ambientColor.z()) * 15 / 3.0f);
uv2 = LightTexture.pack(fakeLight, fakeLight);
uv2 = LightCoordsUtil.pack(fakeLight, fakeLight);
quadBaker.setShade(fakeLight == 0 && shadeQuads);
} else
quadBaker.setShade(shadeQuads);
@@ -523,16 +524,16 @@ public class ObjModel {
return;
var material = UnbakedGeometryHelper.resolveDirtyMaterial(mat.diffuseColorMap, slots);
var texture = baker.sprites().get(material, name);
var texture = baker.materials().get(material, name);
int tintIndex = mat.diffuseTintIndex;
Vector4f colorTint = mat.diffuseColor;
// TODO: [Forge][Rendering] Models contains the transforms so we shouldnt care about them here.
// TODO: [Forge][Rendering] Models contains the transforms so we shouldn't care about them here.
//var rootTransform = context.getRootTransform();
//var transform = rootTransform.isIdentity() ? modelTransform.transformation() : modelTransform.transformation().compose(rootTransform);
var transform = Transformation.identity();
var transform = Transformation.IDENTITY;
for (int[][] face : faces) {
Pair<BakedQuad, Direction> quad = makeQuad(face, tintIndex, colorTint, mat.ambientColor, texture, transform);
Pair<BakedQuad, Direction> quad = makeQuad(face, tintIndex, colorTint, mat.ambientColor, texture.sprite(), transform);
if (quad.getRight() == null)
builder.addUnculledFace(quad.getLeft());
else
@@ -550,11 +551,11 @@ public class ObjModel {
final List<BakedQuad> quads = new ArrayList<>();
for (var face : this.faces) {
var pair = makeQuad(face, tintIndex, colorTint, mat.ambientColor, UnitTextureAtlasSprite.INSTANCE, Transformation.identity());
var pair = makeQuad(face, tintIndex, colorTint, mat.ambientColor, UnitTextureAtlasSprite.INSTANCE, Transformation.IDENTITY);
quads.add(pair.getLeft());
}
Identifier textureLocation = UnbakedGeometryHelper.resolveDirtyMaterial(mat.diffuseColorMap, textures).texture();
Identifier textureLocation = UnbakedGeometryHelper.resolveDirtyMaterial(mat.diffuseColorMap, textures).sprite();
Identifier texturePath = textureLocation.withPath(p -> "textures/" + p + ".png");
builder.addMesh(texturePath, quads);
@@ -8,8 +8,10 @@ package net.minecraftforge.client.model.pipeline;
import com.google.common.base.Preconditions;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.model.geom.builders.UVPair;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.geometry.BakedQuad;
import net.minecraft.client.resources.model.geometry.BakedQuad.MaterialInfo;
import net.minecraft.client.resources.model.sprite.Material;
import net.minecraft.core.Direction;
import net.minecraftforge.client.textures.UnitTextureAtlasSprite;
@@ -35,7 +37,6 @@ public class BakedQuadBuilder implements VertexConsumer {
private Direction direction = Direction.DOWN;
private TextureAtlasSprite sprite = UnitTextureAtlasSprite.INSTANCE;
private boolean shade;
private boolean hasAmbientOcclusion;
private int lightEmission;
public BakedQuadBuilder(Consumer<BakedQuad> quadConsumer) {
@@ -113,7 +114,12 @@ public class BakedQuadBuilder implements VertexConsumer {
BakedQuad quad = new BakedQuad(
this.positions[0], this.positions[1], this.positions[2], this.positions[3],
this.uvs[0], this.uvs[1], this.uvs[2], this.uvs[3],
tintIndex, direction, sprite, shade, lightEmission, hasAmbientOcclusion
direction,
MaterialInfo.of(
new Material.Baked(sprite, false),
sprite.transparency(),
tintIndex, shade, lightEmission
)
);
setup();
// We have a full quad, pass it to the consumer and reset
@@ -137,10 +143,6 @@ public class BakedQuadBuilder implements VertexConsumer {
this.shade = shade;
}
public void setHasAmbientOcclusion(boolean hasAmbientOcclusion) {
this.hasAmbientOcclusion = hasAmbientOcclusion;
}
public void setLightEmission(int value) {
this.lightEmission = value;
}
@@ -6,10 +6,12 @@
package net.minecraftforge.client.model.renderable;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.QuadInstance;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.BlockModelPart;
import net.minecraft.client.renderer.block.model.BlockStateModel;
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
import net.minecraft.client.renderer.block.dispatch.BlockStateModelPart;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
@@ -38,7 +40,7 @@ public class BakedModelRenderable implements IRenderable<BakedModelRenderable.Co
* @see net.minecraftforge.client.event.ModelEvent.RegisterModelStateDefinitions
*/
public static BakedModelRenderable of(BlockState state) {
return of(Minecraft.getInstance().getModelManager().getBlockModelShaper().getBlockModel(state));
return of(Minecraft.getInstance().getModelManager().getBlockStateModelSet().get(state));
}
/**
@@ -62,12 +64,19 @@ public class BakedModelRenderable implements IRenderable<BakedModelRenderable.Co
var randomSource = context.randomSource();
randomSource.setSeed(context.seed());
// Given the lack of context, the requested render type has to be null to ensure the model renders all of its geometry
var parts = new ArrayList<BlockModelPart>();
model.collectParts(randomSource, parts, context.data(), null);
var parts = new ArrayList<BlockStateModelPart>();
model.collectParts(randomSource, parts, context.data());
// Not sure how we're suppoed to put the tint index, that comes from the Material
var quadInstance = new QuadInstance();
quadInstance.setLightCoords(lightmap);
quadInstance.setOverlayCoords(overlay);
for (var part : parts) {
for (var direction : Direction.valuesView()) {
for (var quad : part.getQuads(direction)) {
buffer.putBulkData(poseStack.last(), quad, tint.x(), tint.y(), tint.z(), tint.w(), lightmap, overlay);
buffer.putBakedQuad(poseStack.last(), quad, quadInstance);
//buffer.putBulkData(poseStack.last(), quad, tint.x(), tint.y(), tint.z(), tint.w(), lightmap, overlay);
}
}
}
@@ -7,8 +7,10 @@ package net.minecraftforge.client.model.renderable;
import com.google.common.collect.ImmutableMap;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.QuadInstance;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.resources.model.geometry.BakedQuad;
import net.minecraft.resources.Identifier;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
@@ -68,6 +70,7 @@ public class CompositeRenderable implements IRenderable<CompositeRenderable.Tran
private static class Mesh {
private final Identifier texture;
private final List<BakedQuad> quads = new ArrayList<>();
private final QuadInstance quadInstance = new QuadInstance();
public Mesh(Identifier texture) {
this.texture = texture;
@@ -75,8 +78,11 @@ public class CompositeRenderable implements IRenderable<CompositeRenderable.Tran
public void render(PoseStack poseStack, MultiBufferSource bufferSource, ITextureRenderTypeLookup textureRenderTypeLookup, int lightmap, int overlay) {
var consumer = bufferSource.getBuffer(textureRenderTypeLookup.get(texture));
quadInstance.setLightCoords(lightmap);
quadInstance.setOverlayCoords(overlay);
for (var quad : quads)
consumer.putBulkData(poseStack.last(), quad, 1, 1, 1, 1, lightmap, overlay);
consumer.putBakedQuad(poseStack.last(), quad, quadInstance);
}
}
@@ -25,8 +25,7 @@ import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
public class FarmlandWaterManager
{
public class FarmlandWaterManager {
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugFarmlandWaterManager", "false"));
private static final Map<LevelReader, Map<ChunkPos, ChunkTicketManager<Vec3>>> customWaterHandler = new WeakHashMap<>();
private static final Logger LOGGER = LogManager.getLogger();
@@ -44,8 +43,7 @@ public class FarmlandWaterManager
* @return The ticket for your requested region.
*/
@SuppressWarnings("unchecked")
public static<T extends SimpleTicket<Vec3>> T addCustomTicket(Level level, T ticket, ChunkPos masterChunk, ChunkPos... additionalChunks)
{
public static<T extends SimpleTicket<Vec3>> T addCustomTicket(Level level, T ticket, ChunkPos masterChunk, ChunkPos... additionalChunks) {
Preconditions.checkArgument(!level.isClientSide(), "Water region is only determined server-side");
Map<ChunkPos, ChunkTicketManager<Vec3>> ticketMap = customWaterHandler.computeIfAbsent(level, id -> new MapMaker().weakValues().makeMap());
ChunkTicketManager<Vec3>[] additionalTickets = new ChunkTicketManager[additionalChunks.length];
@@ -67,28 +65,23 @@ public class FarmlandWaterManager
* @param aabb The region where blocks should be watered
* @return The ticket for your requested region.
*/
public static AABBTicket addAABBTicket(Level level, AABB aabb)
{
public static AABBTicket addAABBTicket(Level level, AABB aabb) {
if (DEBUG)
LOGGER.info("FarmlandWaterManager: New AABBTicket, aabb={}", aabb);
//First calculate all chunks the aabb is in
ChunkPos leftUp = new ChunkPos(((int) aabb.minX) >> 4, ((int) aabb.minZ) >> 4);
ChunkPos rightDown = new ChunkPos(((int) aabb.maxX) >> 4, ((int) aabb.maxZ) >> 4);
Set<ChunkPos> posSet = new HashSet<>();
for (int x = leftUp.x; x <= rightDown.x; x++)
{
for (int z = leftUp.z; z <= rightDown.z; z++)
{
for (int x = leftUp.x(); x <= rightDown.x(); x++) {
for (int z = leftUp.z(); z <= rightDown.z(); z++) {
posSet.add(new ChunkPos(x, z));
}
}
ChunkPos masterPos = null;
double masterDistance = Double.MAX_VALUE;
for (ChunkPos pos : posSet) //Find the chunkPos with the lowest distance to the center and choose it as the master pos
{
for (var pos : posSet) { //Find the chunkPos with the lowest distance to the center and choose it as the master pos
double distToCenter = getDistanceSq(pos, aabb.getCenter());
if (distToCenter < masterDistance)
{
if (distToCenter < masterDistance) {
if (DEBUG)
LOGGER.info("FarmlandWaterManager: New better pos then {}: {}, prev dist {}, new dist {}", masterPos, pos, masterDistance, distToCenter);
masterPos = pos;
@@ -101,11 +94,10 @@ public class FarmlandWaterManager
return addCustomTicket(level, new AABBTicket(aabb), masterPos, posSet.toArray(new ChunkPos[0]));
}
private static double getDistanceSq(ChunkPos pos, Vec3 vec3d)
{
private static double getDistanceSq(ChunkPos pos, Vec3 vec3d) {
//See ChunkPos#getDistanceSq
double d0 = (double)(pos.x * 16 + 8);
double d1 = (double)(pos.z * 16 + 8);
double d0 = (double)(pos.x() * 16 + 8);
double d1 = (double)(pos.z() * 16 + 8);
double d2 = d0 - vec3d.x;
double d3 = d1 - vec3d.z;
return d2 * d2 + d3 * d3;
@@ -115,11 +107,9 @@ public class FarmlandWaterManager
* Tests if a block is in a region that is watered by blocks. This does not check vanilla water, see {@code net.minecraft.level.level.block.FarmBlock#isNearWater(LevelReader, BlockPos)}
* @return true if there is a ticket with an AABB that includes your block
*/
public static boolean hasBlockWaterTicket(LevelReader level, BlockPos pos)
{
public static boolean hasBlockWaterTicket(LevelReader level, BlockPos pos) {
ChunkTicketManager<Vec3> ticketManager = getTicketManager(new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4), level);
if (ticketManager != null)
{
if (ticketManager != null) {
Vec3 posAsVec3d = new Vec3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
for (SimpleTicket<Vec3> ticket : ticketManager.getTickets()) {
if (ticket.matches(posAsVec3d))
@@ -129,11 +119,9 @@ public class FarmlandWaterManager
return false;
}
static void removeTickets(ChunkAccess chunk)
{
static void removeTickets(ChunkAccess chunk) {
ChunkTicketManager<Vec3> ticketManager = getTicketManager(chunk.getPos(), chunk.getWorldForge());
if (ticketManager != null)
{
if (ticketManager != null) {
if (DEBUG)
LOGGER.info("FarmlandWaterManager: got tickets {} at {} before", ticketManager.getTickets().size(), ticketManager.pos);
ticketManager.getTickets().removeIf(next -> next.unload(ticketManager)); //remove if this is the master manager of the ticket
@@ -146,9 +134,7 @@ public class FarmlandWaterManager
Preconditions.checkArgument(!level.isClientSide(), "Water region is only determined server-side");
Map<ChunkPos, ChunkTicketManager<Vec3>> ticketMap = customWaterHandler.get(level);
if (ticketMap == null)
{
return null;
}
return ticketMap.get(pos);
}
}
@@ -51,6 +51,7 @@ import net.minecraft.core.HolderSet.Named;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.Connection;
import net.minecraft.network.FriendlyByteBuf;
@@ -191,6 +192,7 @@ import net.minecraft.world.level.block.state.pattern.BlockInWorld;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.structure.templatesystem.loader.TemplateSource;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
@@ -226,13 +228,14 @@ public final class ForgeHooks {
return player.hasCorrectToolForDrops(state);
}
public static Brain<?> onLivingMakeBrain(LivingEntity entity, Brain<?> originalBrain, Dynamic<?> dynamic) {
public static Brain<?> onLivingMakeBrain(final LivingEntity entity, final Brain<?> originalBrain, final Brain.Packed packedBrain) {
if (!LivingMakeBrainEvent.BUS.hasListeners())
return originalBrain;
BrainBuilder<?> brainBuilder = originalBrain.createBuilder();
@SuppressWarnings("unchecked")
var brainBuilder = (BrainBuilder<LivingEntity>)originalBrain.createBuilder();
LivingMakeBrainEvent.BUS.post(new LivingMakeBrainEvent(entity, brainBuilder));
return brainBuilder.makeBrain(dynamic);
return brainBuilder.makeBrain(entity, packedBrain);
}
public static boolean onLivingAttack(LivingEntity entity, DamageSource src, float amount) {
@@ -257,13 +260,6 @@ public final class ForgeHooks {
return LivingDamageEvent.BUS.post(event) ? 0 : event.getAmount();
}
public static InteractionResult onInteractEntityAt(Entity entity, Player player, Vec3 vec3d, InteractionHand hand) {
var ret = new PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, vec3d);
if (PlayerInteractEvent.EntityInteractSpecific.BUS.post(ret))
return ret.getCancellationResult();
return entity.interactAt(player, vec3d, hand);
}
public static int getLootingLevel(Entity target, @Nullable Entity killer, @Nullable DamageSource cause) {
int looting = 0;
if (killer instanceof LivingEntity living)
@@ -412,7 +408,7 @@ public final class ForgeHooks {
var lookup = level.holderLookup(Registries.ENCHANTMENT);
int fortuneLevel = EnchantmentHelper.getItemEnchantmentLevel(lookup.getOrThrow(Enchantments.FORTUNE), stack);
int silkTouchLevel = EnchantmentHelper.getItemEnchantmentLevel(lookup.getOrThrow(Enchantments.SILK_TOUCH), stack);
int exp = state.getExpDrop(level, level.random, pos, fortuneLevel, silkTouchLevel);
int exp = state.getExpDrop(level, level.getRandom(), pos, fortuneLevel, silkTouchLevel);
if (exp > 0)
state.getBlock().popExperience(level, pos, exp);
}
@@ -563,8 +559,8 @@ public final class ForgeHooks {
@NotNull
public static ItemStack getCraftingRemainingItem(@NotNull ItemStack stack) {
var remainder = stack.getCraftingRemainder();
if (!remainder.isEmpty()) {
stack = remainder;
if (remainder != null) {
stack = remainder.create();
if (!stack.isEmpty() && stack.isDamageableItem() && stack.getDamageValue() > stack.getMaxDamage()) {
ForgeEventFactory.onPlayerDestroyItem(CRAFTING_PLAYER.get(), stack, (EquipmentSlot)null);
return ItemStack.EMPTY;
@@ -809,7 +805,7 @@ public final class ForgeHooks {
public static void writeAdditionalLevelSaveData(WorldData worldData, CompoundTag levelTag) {
CompoundTag fmlData = new CompoundTag();
ListTag modList = new ListTag();
ModList.get().getMods().forEach(mi -> {
ModList.getMods().forEach(mi -> {
final CompoundTag mod = new CompoundTag();
mod.putString("ModId", mi.getModId());
mod.putString("ModVersion", MavenVersionStringHelper.artifactVersionToString(mi.getVersion()));
@@ -854,7 +850,7 @@ public final class ForgeHooks {
String modVersion = mod.getStringOr("ModVersion", null);
final var previousVersion = new DefaultArtifactVersion(modVersion);
ModList.get().getModContainerById(modId).ifPresentOrElse(container -> {
ModList.getModContainerById(modId).ifPresentOrElse(container -> {
final var loadingVersion = container.getModInfo().getVersion();
if (!loadingVersion.equals(previousVersion)) {
// Enqueue mismatched versions for bulk event
@@ -1019,9 +1015,10 @@ public final class ForgeHooks {
@SuppressWarnings("deprecation")
public static void onLivingBreathe(LivingEntity entity, int consumeAirAmount, int refillAirAmount) {
// Check things that vanilla considers to be air - these will cause the air supply to be increased.
boolean isAir = entity.getEyeInFluidType().isAir() || entity.level().getBlockState(BlockPos.containing(entity.getX(), entity.getEyeY(), entity.getZ())).is(Blocks.BUBBLE_COLUMN);
var eyeFluid = entity.getEyeInFluidType();
boolean isAir = eyeFluid == null || entity.level().getBlockState(BlockPos.containing(entity.getX(), entity.getEyeY(), entity.getZ())).is(Blocks.BUBBLE_COLUMN);
// The following effects cause the entity to not drown, but do not cause the air supply to be increased.
boolean canBreathe = !entity.canDrownInFluidType(entity.getEyeInFluidType()) || MobEffectUtil.hasWaterBreathing(entity) || (entity instanceof Player player && player.getAbilities().invulnerable);
boolean canBreathe = !entity.canDrownInFluidType(eyeFluid) || MobEffectUtil.hasWaterBreathing(entity) || (entity instanceof Player player && player.getAbilities().invulnerable);
var breatheEvent = ForgeEventFactory.onLivingBreathe(entity, isAir || canBreathe, consumeAirAmount, refillAirAmount, isAir);
if (breatheEvent.canBreathe()) {
if (breatheEvent.canRefillAir()) {
@@ -1054,7 +1051,12 @@ public final class ForgeHooks {
}
}
public static void onCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) {
public static void onCreativeModeTabBuildContents(CreativeModeTab tab, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) {
if (!BuildCreativeModeTabContentsEvent.BUS.hasListeners()) {
originalGenerator.accept(params, output);
return;
}
final var entries = new MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility>(ItemStackLinkedSet.TYPE_AND_TAG,
(key, left, right) -> {
//throw new IllegalStateException("Accidentally adding the same item stack twice " + key.getDisplayName().getString() + " to a Creative Mode Tab: " + tab.getDisplayName().getString());
@@ -1070,7 +1072,11 @@ public final class ForgeHooks {
entries.put(stack, vis);
});
BuildCreativeModeTabContentsEvent.BUS.post(new BuildCreativeModeTabContentsEvent(tab, tabKey, params, entries));
var key = BuiltInRegistries.CREATIVE_MODE_TAB
.getResourceKey(tab)
.orElseThrow(() -> new IllegalStateException("Unregistered creative tab: " + tab));
BuildCreativeModeTabContentsEvent.BUS.post(new BuildCreativeModeTabContentsEvent(tab, key, params, entries));
for (var entry : entries)
output.accept(entry.getKey(), entry.getValue());
@@ -1132,7 +1138,7 @@ public final class ForgeHooks {
public static void handleClientConfigurationComplete(Connection connection) {
if (NetworkContext.get(connection).getType() == ConnectionType.VANILLA) {
LOGGER.info("Connected to a vanilla server. Catching up missing behaviour.");
ConfigTracker.INSTANCE.loadDefaultServerConfigs();
ConfigTracker.loadDefaultServerConfigs();
} else
LOGGER.info("Connected to a modded server.");
}
@@ -1236,8 +1242,9 @@ public final class ForgeHooks {
@Nullable
public static DyeColor getDyeColorFromItemStack(ItemStack stack) {
if (stack.getItem() instanceof DyeItem dye)
return dye.getDyeColor();
var comp = stack.getComponents().get(DataComponents.DYE);
if (comp != null)
return comp;
for (int x = 0; x < DyeColor.BLACK.getId(); x++) {
var color = DyeColor.byId(x);
@@ -1271,8 +1278,22 @@ public final class ForgeHooks {
*
* This is useful for game tests that need a structure, but want to create the contents in code.
*/
public static Optional<StructureTemplate> createEmptyStructure(Identifier name) {
if (name== null || !"forge".equals(name.getNamespace()))
public static TemplateSource emptyStructureSource() {
return new TemplateSource(null, null) {
@Override
public Optional<StructureTemplate> load(Identifier id) {
return createEmptyStructure(id);
}
@Override
public Stream<Identifier> list() {
return Stream.empty();
}
};
}
private static Optional<StructureTemplate> createEmptyStructure(Identifier name) {
if (name == null || !"forge".equals(name.getNamespace()))
return Optional.empty();
var match = EMPTY_SIZE_PATTERN.matcher(name.getPath());
@@ -7,7 +7,6 @@ package net.minecraftforge.common;
import net.minecraft.DetectedVersion;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.commands.synchronization.ArgumentTypeInfo;
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
import net.minecraft.commands.synchronization.SingletonArgumentInfo;
@@ -30,14 +29,13 @@ import net.minecraft.world.entity.ai.attributes.RangedAttribute;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.item.Items;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
import net.minecraftforge.common.data.ExistingFileHelper;
@@ -63,7 +61,6 @@ import net.minecraftforge.common.world.NoneBiomeModifier;
import net.minecraftforge.common.world.NoneStructureModifier;
import net.minecraftforge.common.world.StructureModifier;
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;
@@ -110,16 +107,12 @@ import net.minecraftforge.common.crafting.ingredients.CompoundIngredient;
import net.minecraftforge.common.crafting.ingredients.DifferenceIngredient;
import net.minecraftforge.common.crafting.ingredients.IIngredientSerializer;
import net.minecraftforge.common.crafting.ingredients.IntersectionIngredient;
import net.minecraftforge.common.crafting.ingredients.PartialNBTIngredient;
import net.minecraftforge.common.crafting.ingredients.StrictNBTIngredient;
import net.minecraftforge.common.crafting.ingredients.NBTIngredient;
import net.minecraftforge.fml.common.Mod;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import com.mojang.serialization.MapCodec;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@@ -262,11 +255,6 @@ public class ForgeMod {
public int getTintColor() {
return 0xFF3F76E4;
}
@Override
public int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
return BiomeColors.getAverageWaterColor(getter, pos) | 0xFF000000;
}
});
}
});
@@ -315,10 +303,10 @@ public class ForgeMod {
}
});
private static final DeferredRegister<LootItemConditionType> LOOT_CONDITION_TYPES = deferred(Registries.LOOT_CONDITION_TYPE);
private static final DeferredRegister<MapCodec<? extends LootItemCondition>> LOOT_CONDITION_TYPES = deferred(Registries.LOOT_CONDITION_TYPE);
static {
LOOT_CONDITION_TYPES.register("loot_table_id", () -> LootTableIdCondition.TYPE);
LOOT_CONDITION_TYPES.register("can_tool_perform_action", () -> CanToolPerformAction.TYPE);
LOOT_CONDITION_TYPES.register("loot_table_id", () -> LootTableIdCondition.CODEC);
LOOT_CONDITION_TYPES.register("can_tool_perform_action", () -> CanToolPerformAction.CODEC);
}
private static final DeferredRegister<MapCodec<? extends ICondition>> CONDITION_SERIALIZERS = deferred(ForgeRegistries.Keys.CONDITION_SERIALIZERS);
@@ -341,8 +329,7 @@ public class ForgeMod {
private static final DeferredRegister<IIngredientSerializer<?>> INGREDIENT_SERIALIZERS = deferred(ForgeRegistries.Keys.INGREDIENT_SERIALIZERS);
static {
INGREDIENT_SERIALIZERS.register("compound", () -> CompoundIngredient.SERIALIZER);
INGREDIENT_SERIALIZERS.register("nbt", () -> StrictNBTIngredient.SERIALIZER);
INGREDIENT_SERIALIZERS.register("partial_nbt", () -> PartialNBTIngredient.SERIALIZER);
INGREDIENT_SERIALIZERS.register("nbt", () -> NBTIngredient.SERIALIZER);
INGREDIENT_SERIALIZERS.register("difference", () -> DifferenceIngredient.SERIALIZER);
INGREDIENT_SERIALIZERS.register("intersection", () -> IntersectionIngredient.SERIALIZER);
}
@@ -412,7 +399,6 @@ public class ForgeMod {
context.registerDisplayTest(IExtensionPoint.DisplayTest.IGNORE_ALL_VERSION);
StartupMessageManager.addModMessage("Forge version "+ForgeVersion.getVersion());
ServerAboutToStartEvent.BUS.addListener(VillagerTradingManager::loadTrades);
ForgeInternalHandler.register();
GatherLoginConfigurationTasksEvent.BUS.addListener(ForgeNetworkConfigurationHandler::gatherInit);
@@ -29,7 +29,7 @@ public class ForgeStatesProvider implements IModStateProvider {
}
private static ModLoadingState gather(String name, ModLoadingState after, Runnable inline) {
return gather(name, after).withInline(ml -> inline.run());
return gather(name, after).withInline(inline);
}
private static ModLoadingState.Builder complete(String name, ModLoadingState after) {
@@ -37,7 +37,7 @@ public class ForgeStatesProvider implements IModStateProvider {
}
private static ModLoadingState complete(String name, ModLoadingState after, Runnable inline) {
return complete(name, after).withInline(ml -> inline.run());
return complete(name, after).withInline(inline);
}
@Override
File diff suppressed because it is too large. Load diff
@@ -95,14 +95,6 @@ public class ToolActions
*/
public static final ToolAction HOE_TILL = ToolAction.get("till");
/**
* A tool action corresponding to the 'block' action of shields.
*
* @deprecated Completely overshadowed by {@link net.minecraft.core.component.DataComponents#BLOCKS_ATTACKS}
*/
@Deprecated(forRemoval = true, since = "1.21.5")
public static final ToolAction SHIELD_BLOCK = ToolAction.get("shield_block");
/**
* This action corresponds to right-clicking the fishing rod.
*/
@@ -117,8 +109,6 @@ public class ToolActions
@Deprecated(since = "1.21.5")
public static final Set<ToolAction> DEFAULT_SWORD_ACTIONS = of(SWORD_DIG, SWORD_SWEEP);
public static final Set<ToolAction> DEFAULT_SHEARS_ACTIONS = of(SHEARS_DIG, SHEARS_HARVEST, SHEARS_CARVE, SHEARS_DISARM);
@Deprecated(since = "1.21.5")
public static final Set<ToolAction> DEFAULT_SHIELD_ACTIONS = of(SHIELD_BLOCK);
public static final Set<ToolAction> DEFAULT_FISHING_ROD_ACTIONS = of(FISHING_ROD_CAST);
private static Set<ToolAction> of(ToolAction... actions) {
@@ -1,84 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.common;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.npc.villager.VillagerProfession;
import net.minecraft.world.entity.npc.villager.VillagerTrades;
import net.minecraft.world.entity.npc.villager.VillagerTrades.ItemListing;
import net.minecraft.core.NonNullList;
import net.minecraftforge.event.village.VillagerTradesEvent;
import net.minecraftforge.event.village.WandererTradesEvent;
import net.minecraftforge.common.util.Lazy;
import net.minecraftforge.event.server.ServerAboutToStartEvent;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.commons.lang3.tuple.Pair;
public class VillagerTradingManager {
private static final Lazy<Map<ResourceKey<VillagerProfession>, Int2ObjectMap<ItemListing[]>>> VANILLA_TRADES = Lazy.of(VillagerTradingManager::copyVanillaTrades);
private static final Lazy<List<Pair<ItemListing[], Integer>>> WANDERER_TRADES = Lazy.of(() -> new ArrayList<Pair<ItemListing[], Integer>>(VillagerTrades.WANDERING_TRADER_TRADES));
private static Map<ResourceKey<VillagerProfession>, Int2ObjectMap<ItemListing[]>> copyVanillaTrades() {
var ret = new HashMap<ResourceKey<VillagerProfession>, Int2ObjectMap<ItemListing[]>>();
VillagerTrades.TRADES.forEach((key, value) -> {
Int2ObjectMap<ItemListing[]> copy = new Int2ObjectOpenHashMap<>();
for (var ent : value.int2ObjectEntrySet()) {
copy.put(ent.getIntKey(), Arrays.copyOf(ent.getValue(), ent.getValue().length));
}
ret.put(key, copy);
});
return ret;
}
static void loadTrades(ServerAboutToStartEvent e) {
postWandererEvent();
postVillagerEvents();
}
/** Posts the WandererTradesEvent. */
private static void postWandererEvent() {
if (!WandererTradesEvent.BUS.hasListeners())
return;
var event = WandererTradesEvent.BUS.fire(new WandererTradesEvent(WANDERER_TRADES.get()));
VillagerTrades.WANDERING_TRADER_TRADES.clear();
for (var pool : event.getPools())
VillagerTrades.WANDERING_TRADER_TRADES.add(Pair.of(pool.getEntries().toArray(ItemListing[]::new), pool.getRolls()));
}
/** Posts a VillagerTradesEvent for each registered profession. */
private static void postVillagerEvents() {
if (!VillagerTradesEvent.BUS.hasListeners())
return;
// TODO [VillagerType][1.21.5] Villager Professions are stored as keys in vanilla now? Re-evaluate this.
var vanilla = VANILLA_TRADES.get();
for (VillagerProfession value : ForgeRegistries.VILLAGER_PROFESSIONS) {
var prof = ForgeRegistries.VILLAGER_PROFESSIONS.getResourceKey(value).orElseThrow();
Int2ObjectMap<ItemListing[]> trades = vanilla.getOrDefault(prof, new Int2ObjectOpenHashMap<>());
Int2ObjectMap<List<ItemListing>> mutableTrades = new Int2ObjectOpenHashMap<>();
for (int i = 1; i < 6; i++)
mutableTrades.put(i, NonNullList.create());
for (var entry : trades.int2ObjectEntrySet())
Arrays.stream(entry.getValue()).forEach(mutableTrades.get(entry.getIntKey())::add);
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]));
VillagerTrades.TRADES.put(prof, newTrades);
}
}
}
@@ -10,7 +10,7 @@ import net.minecraftforge.eventbus.api.listener.EventListener;
import java.util.ArrayList;
public class WorldWorkerManager {
public final class WorldWorkerManager {
private static final ArrayList<IWorker> workers = new ArrayList<>();
private static long startTime = -1;
private static int index = 0;
@@ -46,17 +46,11 @@ public class WorldWorkerManager {
}
}
@Deprecated(forRemoval = true, since = "1.21.8")
public static void tick(boolean start) {
if (start) startTick();
else endTick();
}
public static synchronized void addWorker(IWorker worker) {
workers.add(worker);
if (tickStartListener == null) {
tickStartListener = TickEvent.ServerTickEvent.Pre.BUS.addListener(event -> startTick());
tickEndListener = TickEvent.ServerTickEvent.Post.BUS.addListener(event -> endTick());
tickStartListener = TickEvent.ServerTickEvent.Pre.BUS.addListener(_ -> startTick());
tickEndListener = TickEvent.ServerTickEvent.Post.BUS.addListener(_ -> endTick());
}
}
@@ -8,7 +8,6 @@ package net.minecraftforge.common.capabilities;
import net.minecraft.resources.Identifier;
import net.minecraftforge.fml.Logging;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -20,9 +19,6 @@ import java.util.HashMap;
import java.util.Map;
public final class CapabilityManager {
@Deprecated(forRemoval = true, since = "1.21")
public static final CapabilityManager INSTANCE = new CapabilityManager();
private static final Logger LOGGER = LogManager.getLogger();
/**
@@ -88,8 +84,8 @@ public final class CapabilityManager {
private static final Map<Key, Capability<?>> providers = new HashMap<>();
@ApiStatus.Internal
public static void injectCapabilities(ModList modlist) {
var autos = modlist.getAllScanData().stream()
public static void injectCapabilities() {
var autos = ModList.getAllScanData().stream()
.flatMap(e -> e.getAnnotations().stream())
.filter(a -> AUTO_REGISTER.equals(a.annotationType()))
.map(ModFileScanData.AnnotationData::clazz)
@@ -101,9 +97,6 @@ public final class CapabilityManager {
LOGGER.debug(Logging.CAPABILITIES, "Attempting to automatically register: " + auto);
get(auto.getInternalName(), null, true);
}
@SuppressWarnings("removal")
var event = RegisterCapabilitiesEvent.BUS.fire(new RegisterCapabilitiesEvent());
}
private static void error(String message) {
@@ -1,46 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.common.capabilities;
import java.util.Objects;
import net.minecraftforge.eventbus.api.bus.BusGroup;
import net.minecraftforge.eventbus.api.bus.EventBus;
import net.minecraftforge.eventbus.api.event.RecordEvent;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jspecify.annotations.NullMarked;
import org.objectweb.asm.Type;
/**
* This event fires when it is time to register your capabilities.
* @see Capability
*
* @deprecated Use {@link AutoRegisterCapability} annotation on your class.
*/
@Deprecated(forRemoval = true, since = "1.21")
@NullMarked
public record RegisterCapabilitiesEvent() implements RecordEvent {
public static final EventBus<RegisterCapabilitiesEvent> BUS = EventBus.create(RegisterCapabilitiesEvent.class);
/** @deprecated {@link RegisterCapabilitiesEvent} is no longer an {@link IModBusEvent}, so use {@link #BUS} directly. */
@Deprecated(forRemoval = true, since = "1.21.9")
public static EventBus<RegisterCapabilitiesEvent> getBus(BusGroup modBusGroup) {
return BUS;
}
/**
* Registers a capability to be consumed by others.<br>
* APIs who define the capability should call this.<br>
* This is meant to allow Capability consumers to have soft dependencies on the Capability type.<br>
* But be automatically notified when the Class actually exists. Meaning it's safe to create their implementations.<br>
* <br>
* To retrieve the Capability instance, use the {@link CapabilityManager} gets functions.
*/
public <T> void register(Class<T> type) {
Objects.requireNonNull(type, "Attempted to register a capability with invalid type");
CapabilityManager.get(Type.getInternalName(type), null, true);
}
}
@@ -26,7 +26,6 @@ import com.mojang.serialization.RecordBuilder;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.HolderLookup.Provider;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.recipes.RecipeBuilder;
@@ -40,7 +39,6 @@ import net.minecraft.world.item.crafting.RecipeBookCategory;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.Identifier;
@@ -180,7 +178,9 @@ public class ConditionalRecipe {
private static class Wrapper implements Recipe<CraftingInput> {
@Override public boolean matches(CraftingInput inv, Level level) { return false; }
@Override public ItemStack assemble(CraftingInput inv, HolderLookup.Provider reg) { return null; }
@Override public ItemStack assemble(CraftingInput inv) { return null; }
@Override public boolean showNotification() { return false; }
@Override public String group() { return "ungrouped wrapper"; }
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@@ -284,17 +284,12 @@ public class ConditionalRecipe {
}
});
public static final RecipeSerializer<Recipe<?>> SERIALZIER = new RecipeSerializer<Recipe<?>>() {
@Override
public MapCodec<Recipe<?>> codec() {
return CODEC;
}
@Override
public StreamCodec<RegistryFriendlyByteBuf, Recipe<?>> streamCodec() {
throw new UnsupportedOperationException("ConditionaRecipe.SERIALIZER does not support encoding to network");
}
};
public static final RecipeSerializer<Recipe<?>> SERIALZIER = new RecipeSerializer<Recipe<?>>(CODEC,
StreamCodec.of(
(o, v) -> new UnsupportedOperationException("ConditionaRecipe.SERIALIZER does not support encoding to network"),
i -> { throw new UnsupportedOperationException("ConditionaRecipe.SERIALIZER does not support encoding to network"); }
)
);
private static final class Holder<T> {
private T value;
@@ -19,7 +19,7 @@ public record ModLoadedCondition(String modid) implements ICondition {
@Override
public boolean test(IContext context, DynamicOps<?> ops) {
return ModList.get().isLoaded(modid);
return ModList.isLoaded(modid);
}
@Override
@@ -11,16 +11,11 @@ import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderSet;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
public interface IIngredientBuilder {
default PartialNBTIngredient.Builder partialNbt() {
return PartialNBTIngredient.builder();
}
default Ingredient strictNbt(ItemStack value) {
return StrictNBTIngredient.of(value);
default NBTIngredient.Builder nbtIngredient() {
return NBTIngredient.builder();
}
default Ingredient compound(Ingredient... values) {
@@ -5,10 +5,10 @@
package net.minecraftforge.common.crafting.ingredients;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.advancements.criterion.NbtPredicate;
import net.minecraft.core.HolderSet;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.Registries;
@@ -28,28 +28,28 @@ import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/** Ingredient that matches the given items, performing a partial NBT match. Use {@link StrictNBTIngredient} if you want exact match on NBT */
public class PartialNBTIngredient extends AbstractIngredient {
/** Ingredient that matches the given items, performing a partial NBT match unless strict is set. */
public class NBTIngredient extends AbstractIngredient {
public static Builder builder() {
return new Builder();
}
private final CompoundTag nbt;
private final NbtPredicate predicate;
private final boolean strict;
private PartialNBTIngredient(HolderSet<Item> items, CompoundTag nbt) {
private NBTIngredient(HolderSet<Item> items, CompoundTag nbt, boolean strict) {
super(items);
if (items.size() == 0)
throw new IllegalArgumentException("Cannot create a PartialNBTIngredient with no items");
this.nbt = nbt;
this.predicate = new NbtPredicate(nbt);
this.strict = strict;
}
/** Creates a new ingredient matching any item from the list, containing the given NBT */
@SuppressWarnings("deprecation")
public static PartialNBTIngredient of(CompoundTag nbt, ItemLike... items) {
public static NBTIngredient of(CompoundTag nbt, ItemLike... items) {
return of(
HolderSet.direct(
Arrays.stream(items)
@@ -61,14 +61,20 @@ public class PartialNBTIngredient extends AbstractIngredient {
}
/** Creates a new ingredient matching the given item, containing the given NBT */
public static NBTIngredient of(ItemLike item, CompoundTag nbt) {
return of(item, nbt, false);
}
@SuppressWarnings("deprecation")
public static PartialNBTIngredient of(ItemLike item, CompoundTag nbt) {
return of(HolderSet.direct(item.asItem().builtInRegistryHolder()), nbt);
public static NBTIngredient of(ItemLike item, CompoundTag nbt, boolean strict) {
return of(HolderSet.direct(item.asItem().builtInRegistryHolder()), nbt, strict);
}
/** Creates a new ingredient matching the given item, containing the given NBT */
public static PartialNBTIngredient of(HolderSet<Item> items, CompoundTag nbt) {
return new PartialNBTIngredient(items, nbt);
public static NBTIngredient of(HolderSet<Item> items, CompoundTag nbt) {
return of(items, nbt, false);
}
public static NBTIngredient of(HolderSet<Item> items, CompoundTag nbt, boolean strict) {
return new NBTIngredient(items, nbt, strict);
}
@Override
@@ -76,7 +82,8 @@ public class PartialNBTIngredient extends AbstractIngredient {
if (input == null)
return false;
var nbt = input.get(DataComponents.CUSTOM_DATA);
return nbt != null && input.is(this.values) && predicate.matches(nbt.copyTag());
if (nbt == null || !input.is(this.values)) return false;
return strict ? nbt.strictMatchedBy(this.nbt) : nbt.matchedBy(this.nbt);
}
@Override
@@ -89,38 +96,42 @@ public class PartialNBTIngredient extends AbstractIngredient {
return SERIALIZER;
}
public static final MapCodec<PartialNBTIngredient> CODEC = RecordCodecBuilder.mapCodec(builder ->
public static final MapCodec<NBTIngredient> CODEC = RecordCodecBuilder.mapCodec(builder ->
builder.group(
Ingredient.NON_AIR_HOLDER_SET_CODEC.fieldOf("items").forGetter(i -> i.values),
TagParser.FLATTENED_CODEC.fieldOf("nbt").forGetter(i -> i.nbt)
).apply(builder, PartialNBTIngredient::new)
TagParser.FLATTENED_CODEC.fieldOf("nbt").forGetter(i -> i.nbt),
Codec.BOOL.fieldOf("strict").forGetter(i -> i.strict)
).apply(builder, NBTIngredient::new)
);
public static final IIngredientSerializer<PartialNBTIngredient> SERIALIZER = new IIngredientSerializer<>() {
public static final IIngredientSerializer<NBTIngredient> SERIALIZER = new IIngredientSerializer<>() {
private final StreamCodec<RegistryFriendlyByteBuf, HolderSet<Item>> HOLDER_SET = ByteBufCodecs.holderSet(Registries.ITEM);
@Override
public MapCodec<? extends PartialNBTIngredient> codec() {
public MapCodec<? extends NBTIngredient> codec() {
return CODEC;
}
@Override
public PartialNBTIngredient read(RegistryFriendlyByteBuf buffer) {
public NBTIngredient read(RegistryFriendlyByteBuf buffer) {
var items = HOLDER_SET.decode(buffer);
var nbt = buffer.readNbt();
return new PartialNBTIngredient(items, Objects.requireNonNull(nbt));
var strict = buffer.readBoolean();
return new NBTIngredient(items, Objects.requireNonNull(nbt), strict);
}
@Override
public void write(RegistryFriendlyByteBuf buffer, PartialNBTIngredient value) {
public void write(RegistryFriendlyByteBuf buffer, NBTIngredient value) {
HOLDER_SET.encode(buffer, value.values);
buffer.writeNbt(value.nbt);
buffer.writeBoolean(value.strict);
}
};
public static class Builder {
private final List<ItemLike> items = new ArrayList<>();
private CompoundTag nbt;
private boolean strict = false;
public Builder nbt(CompoundTag value) {
if (this.nbt != null)
@@ -129,6 +140,11 @@ public class PartialNBTIngredient extends AbstractIngredient {
return this;
}
public Builder strict() {
this.strict = true;
return this;
}
public Builder item(ItemLike item) {
this.items.add(item);
return this;
@@ -140,13 +156,21 @@ public class PartialNBTIngredient extends AbstractIngredient {
return this;
}
public PartialNBTIngredient build() {
public NBTIngredient build() {
if (nbt == null)
throw new IllegalStateException("NBT Data not set");
if (items.isEmpty())
throw new IllegalStateException("No items added");
return PartialNBTIngredient.of(nbt, items.stream().toArray(ItemLike[]::new));
@SuppressWarnings("deprecation")
var holders = HolderSet.direct(
items.stream()
.map(ItemLike::asItem)
.map(Item::builtInRegistryHolder)
.toList()
);
return NBTIngredient.of(holders, nbt, strict);
}
}
}
@@ -1,75 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.common.crafting.ingredients;
import net.minecraft.core.HolderSet;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import org.jetbrains.annotations.Nullable;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
/** Ingredient that matches the given stack, performing an exact NBT match. Use {@link PartialNBTIngredient} if you need partial match. */
public class StrictNBTIngredient extends AbstractIngredient {
public static StrictNBTIngredient of(ItemStack stack) {
return new StrictNBTIngredient(stack);
}
private final ItemStack stack;
private StrictNBTIngredient(ItemStack stack) {
super(HolderSet.direct(stack.getItemHolder()));
this.stack = stack;
}
@Override
public boolean test(@Nullable ItemStack input) {
if (input == null)
return false;
//Can't use areItemStacksEqualUsingNBTShareTag because it compares stack size as well
var inbt = input.get(DataComponents.CUSTOM_DATA);
var tnbt = this.stack.get(DataComponents.CUSTOM_DATA);
if(inbt == null || tnbt == null)
return false;
return this.stack.getItem() == input.getItem() && tnbt.matchedBy(inbt.copyTag());
}
@Override
public boolean isSimple() {
return false;
}
@Override
public IIngredientSerializer<? extends Ingredient> serializer() {
return SERIALIZER;
}
public static final MapCodec<StrictNBTIngredient> CODEC = RecordCodecBuilder.mapCodec(b -> b.group(
ItemStack.CODEC.fieldOf("stack").forGetter(i -> i.stack)
).apply(b, StrictNBTIngredient::new));
public static final IIngredientSerializer<StrictNBTIngredient> SERIALIZER = new IIngredientSerializer<>() {
@Override
public MapCodec<? extends StrictNBTIngredient> codec() {
return CODEC;
}
@Override
public void write(RegistryFriendlyByteBuf buffer, StrictNBTIngredient value) {
ItemStack.STREAM_CODEC.encode(buffer, value.stack);
}
@Override
public StrictNBTIngredient read(RegistryFriendlyByteBuf buffer) {
var stack = ItemStack.STREAM_CODEC.decode(buffer);
return new StrictNBTIngredient(stack);
}
};
}
@@ -1,20 +0,0 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.common.data;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
/** 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, lookupProvider, modId, existingFileHelper);
}
}
@@ -81,7 +81,6 @@ public class ExistingFileHelper {
}
private final MultiPackResourceManager clientResources, serverData;
private final boolean enable;
private final Multimap<PackType, Identifier> generated = HashMultimap.create();
/**
@@ -93,11 +92,10 @@ public class ExistingFileHelper {
* other generated files.
* @param existingPacks a collection of paths to existing packs
* @param existingMods a set of mod IDs for existing mods
* @param enable {@code true} if validation is enabled
* @param assetIndex the identifier for the asset index, generally Minecraft's current major version
* @param assetsDir the directory in which to find vanilla assets and indexes
*/
public ExistingFileHelper(Collection<Path> existingPacks, final Set<String> existingMods, boolean enable, @Nullable final String assetIndex, @Nullable final File assetsDir) {
public ExistingFileHelper(Collection<Path> existingPacks, final Set<String> existingMods, @Nullable final String assetIndex, @Nullable final File assetsDir) {
List<PackResources> candidateClientResources = new ArrayList<>();
List<PackResources> candidateServerResources = new ArrayList<>();
@@ -123,7 +121,7 @@ public class ExistingFileHelper {
}
for (String existingMod : existingMods) {
IModFileInfo modFileInfo = ModList.get().getModFileById(existingMod);
IModFileInfo modFileInfo = ModList.getModFileById(existingMod);
if (modFileInfo != null) {
var root = modFileInfo.getFile().findResource("/");
var supplier = new PathResourcesSupplier(root);
@@ -136,8 +134,6 @@ public class ExistingFileHelper {
this.clientResources = new MultiPackResourceManager(PackType.CLIENT_RESOURCES, candidateClientResources);
this.serverData = new MultiPackResourceManager(PackType.SERVER_DATA, candidateServerResources);
this.enable = enable;
}
private ResourceManager getManager(PackType packType) {
@@ -254,13 +250,4 @@ public class ExistingFileHelper {
public List<Resource> getResourceStack(Identifier loc, PackType packType) {
return getManager(packType).getResourceStack(loc);
}
/**
* @return {@code true} if validation is enabled, {@code false} otherwise
* @deprecated Validation is always enabled, check things as you deem fit.
*/
@Deprecated(forRemoval = true, since = "1.21.5")
public boolean isEnabled() {
return enable;
}
}
@@ -39,8 +39,7 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
tag(IS_OVERWORLD).addTag(BiomeTags.IS_OVERWORLD);
tag(IS_HOT_OVERWORLD)
.add(Biomes.SWAMP)
.add(Biomes.MANGROVE_SWAMP)
.add(Biomes.MUSHROOM_FIELDS)
.add(Biomes.JUNGLE)
.add(Biomes.BAMBOO_JUNGLE)
.add(Biomes.SPARSE_JUNGLE)
@@ -52,17 +51,15 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
.add(Biomes.SAVANNA_PLATEAU)
.add(Biomes.WINDSWEPT_SAVANNA)
.add(Biomes.STONY_PEAKS)
.add(Biomes.WARM_OCEAN)
.addOptionalTag(forgeTagKey("is_hot/overworld"));
.add(Biomes.WARM_OCEAN);
tag(IS_HOT_NETHER)
.add(Biomes.NETHER_WASTES)
.add(Biomes.CRIMSON_FOREST)
.add(Biomes.WARPED_FOREST)
.add(Biomes.SOUL_SAND_VALLEY)
.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);
.add(Biomes.BASALT_DELTAS);
tag(IS_HOT_END);
tag(IS_HOT).addTags(IS_HOT_OVERWORLD, IS_HOT_NETHER, IS_HOT_END);
tag(IS_COLD_OVERWORLD)
.add(Biomes.TAIGA)
@@ -84,20 +81,20 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
.add(Biomes.COLD_OCEAN)
.add(Biomes.FROZEN_OCEAN)
.add(Biomes.DEEP_COLD_OCEAN)
.add(Biomes.DEEP_FROZEN_OCEAN)
.addOptionalTag(forgeTagKey("is_cold/overworld"));
tag(IS_COLD_NETHER); // forge:is_cold/nether
.add(Biomes.DEEP_FROZEN_OCEAN);
tag(IS_COLD_NETHER);
tag(IS_COLD_END)
.add(Biomes.THE_END)
.add(Biomes.SMALL_END_ISLANDS)
.add(Biomes.END_MIDLANDS)
.add(Biomes.END_HIGHLANDS)
.add(Biomes.END_BARRENS)
.addOptionalTag(forgeTagKey("is_cold/end"));
tag(IS_COLD).addTag(IS_COLD_OVERWORLD).addOptionalTag(IS_COLD_NETHER).addTag(IS_COLD_END);
.add(Biomes.END_BARRENS);
tag(IS_COLD).addTags(IS_COLD_OVERWORLD, IS_COLD_NETHER, IS_COLD_END);
tag(IS_DEAD)
.addOptionalTag(forgeTagKey("is_dead"));
tag(IS_DARK_FOREST)
.add(Biomes.DARK_FOREST)
.add(Biomes.PALE_GARDEN);
tag(IS_DEAD);
tag(IS_SPARSE_VEGETATION_OVERWORLD)
.add(Biomes.WOODED_BADLANDS)
@@ -111,10 +108,9 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
.add(Biomes.SNOWY_SLOPES)
.add(Biomes.JAGGED_PEAKS)
.add(Biomes.FROZEN_PEAKS);
//.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).addOptionalTag(IS_SPARSE_END);
tag(IS_SPARSE_VEGETATION_NETHER);
tag(IS_SPARSE_VEGETATION_END);
tag(IS_SPARSE_VEGETATION).addTags(IS_SPARSE_VEGETATION_OVERWORLD, IS_SPARSE_VEGETATION_NETHER, IS_SPARSE_VEGETATION_END);
tag(IS_DENSE_VEGETATION_OVERWORLD)
.add(Biomes.DARK_FOREST)
@@ -122,11 +118,10 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
.add(Biomes.OLD_GROWTH_SPRUCE_TAIGA)
.add(Biomes.JUNGLE)
.add(Biomes.BAMBOO_JUNGLE)
.add(Biomes.MANGROVE_SWAMP)
.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).addOptionalTag(IS_DENSE_END);
.add(Biomes.MANGROVE_SWAMP);
tag(IS_DENSE_VEGETATION_NETHER);
tag(IS_DENSE_VEGETATION_END);
tag(IS_DENSE_VEGETATION).addTags(IS_DENSE_VEGETATION_OVERWORLD, IS_DENSE_VEGETATION_NETHER, IS_DENSE_VEGETATION_END);
tag(IS_WET_OVERWORLD)
.add(Biomes.SWAMP)
@@ -136,11 +131,10 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
.add(Biomes.SPARSE_JUNGLE)
.add(Biomes.BEACH)
.add(Biomes.LUSH_CAVES)
.add(Biomes.DRIPSTONE_CAVES)
.addOptionalTag(forgeTagKey("is_wet/overworld"));
.add(Biomes.DRIPSTONE_CAVES);
tag(IS_WET_NETHER);
tag(IS_WET_END);
tag(IS_WET).addTag(IS_WET_OVERWORLD).addOptionalTag(IS_WET_NETHER).addOptionalTag(IS_WET_END);
tag(IS_WET).addTags(IS_WET_OVERWORLD, IS_WET_NETHER, IS_WET_END);
tag(IS_DRY_OVERWORLD)
.add(Biomes.DESERT)
@@ -149,41 +143,84 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
.add(Biomes.ERODED_BADLANDS)
.add(Biomes.SAVANNA)
.add(Biomes.SAVANNA_PLATEAU)
.add(Biomes.WINDSWEPT_SAVANNA)
.addOptionalTag(forgeTagKey("is_dry/overworld"));
.add(Biomes.WINDSWEPT_SAVANNA);
tag(IS_DRY_NETHER)
.add(Biomes.NETHER_WASTES)
.add(Biomes.CRIMSON_FOREST)
.add(Biomes.WARPED_FOREST)
.add(Biomes.SOUL_SAND_VALLEY)
.add(Biomes.BASALT_DELTAS)
.addOptionalTag(forgeTagKey("is_dry/nether"));
.add(Biomes.BASALT_DELTAS);
tag(IS_DRY_END)
.add(Biomes.THE_END)
.add(Biomes.SMALL_END_ISLANDS)
.add(Biomes.END_MIDLANDS)
.add(Biomes.END_HIGHLANDS)
.add(Biomes.END_BARRENS)
.addOptionalTag(forgeTagKey("is_dry/end"));
.add(Biomes.END_BARRENS);
tag(IS_DRY)
.addTag(IS_DRY_OVERWORLD).addTag(IS_DRY_NETHER).addTag(IS_DRY_END)
.addOptionalTag(forgeTagKey("is_dry"));
.addTags(IS_DRY_OVERWORLD, IS_DRY_NETHER, IS_DRY_END);
tag(IS_TEMPERATE_OVERWORLD)
.add(Biomes.BEACH)
.add(Biomes.BIRCH_FOREST)
.add(Biomes.CHERRY_GROVE)
.add(Biomes.DARK_FOREST)
.add(Biomes.DEEP_OCEAN)
.add(Biomes.FLOWER_FOREST)
.add(Biomes.FOREST)
.add(Biomes.MANGROVE_SWAMP)
.add(Biomes.MEADOW)
.add(Biomes.OCEAN)
.add(Biomes.OLD_GROWTH_BIRCH_FOREST)
.add(Biomes.PLAINS)
.add(Biomes.SUNFLOWER_PLAINS)
.add(Biomes.SWAMP);
tag(IS_TEMPERATE_NETHER);
tag(IS_TEMPERATE_END);
tag(IS_TEMPERATE)
.addTag(IS_TEMPERATE_OVERWORLD)
.addTag(IS_TEMPERATE_NETHER)
.addTag(IS_TEMPERATE_END);
tag(PRIMARY_WOOD_TYPE_ACACIA).add(Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.WINDSWEPT_SAVANNA);
tag(PRIMARY_WOOD_TYPE_BAMBOO).add(Biomes.BAMBOO_JUNGLE);
tag(PRIMARY_WOOD_TYPE_BIRCH).add(Biomes.BIRCH_FOREST, Biomes.OLD_GROWTH_BIRCH_FOREST);
tag(PRIMARY_WOOD_TYPE_CHERRY).add(Biomes.CHERRY_GROVE);
tag(PRIMARY_WOOD_TYPE_CRIMSON).add(Biomes.CRIMSON_FOREST);
tag(PRIMARY_WOOD_TYPE_DARK_OAK).add(Biomes.DARK_FOREST);
tag(PRIMARY_WOOD_TYPE_JUNGLE).add(Biomes.JUNGLE, Biomes.SPARSE_JUNGLE);
tag(PRIMARY_WOOD_TYPE_MANGROVE).add(Biomes.MANGROVE_SWAMP);
tag(PRIMARY_WOOD_TYPE_OAK).add(Biomes.FLOWER_FOREST, Biomes.FOREST, Biomes.SWAMP, Biomes.WOODED_BADLANDS);
tag(PRIMARY_WOOD_TYPE_PALE_OAK).add(Biomes.PALE_GARDEN);
tag(PRIMARY_WOOD_TYPE_SPRUCE).add(Biomes.GROVE, Biomes.OLD_GROWTH_PINE_TAIGA, Biomes.OLD_GROWTH_SPRUCE_TAIGA, Biomes.SNOWY_TAIGA, Biomes.TAIGA);
tag(PRIMARY_WOOD_TYPE_WARPED).add(Biomes.WARPED_FOREST);
tag(PRIMARY_WOOD_TYPE)
.addTags(
PRIMARY_WOOD_TYPE_ACACIA,
PRIMARY_WOOD_TYPE_BAMBOO,
PRIMARY_WOOD_TYPE_BIRCH,
PRIMARY_WOOD_TYPE_CHERRY,
PRIMARY_WOOD_TYPE_CRIMSON,
PRIMARY_WOOD_TYPE_DARK_OAK,
PRIMARY_WOOD_TYPE_JUNGLE,
PRIMARY_WOOD_TYPE_MANGROVE,
PRIMARY_WOOD_TYPE_OAK,
PRIMARY_WOOD_TYPE_PALE_OAK,
PRIMARY_WOOD_TYPE_SPRUCE,
PRIMARY_WOOD_TYPE_WARPED
);
tag(IS_CONIFEROUS_TREE)
.addTag(IS_TAIGA)
.add(Biomes.GROVE)
.addOptionalTag(forgeTagKey("is_coniferous"));
.add(Biomes.GROVE);
tag(IS_SAVANNA_TREE).addTag(IS_SAVANNA);
tag(IS_JUNGLE_TREE).addTag(IS_JUNGLE);
tag(IS_DECIDUOUS_TREE).add(Biomes.FOREST).add(Biomes.FLOWER_FOREST).add(Biomes.BIRCH_FOREST).add(Biomes.DARK_FOREST).add(Biomes.OLD_GROWTH_BIRCH_FOREST).add(Biomes.WINDSWEPT_FOREST);
tag(IS_DECIDUOUS_TREE).add(Biomes.FOREST, Biomes.FLOWER_FOREST, Biomes.BIRCH_FOREST, Biomes.DARK_FOREST, Biomes.OLD_GROWTH_BIRCH_FOREST, Biomes.PALE_GARDEN, Biomes.WINDSWEPT_FOREST);
tag(IS_MOUNTAIN_SLOPE).add(Biomes.SNOWY_SLOPES).add(Biomes.MEADOW).add(Biomes.GROVE).add(Biomes.CHERRY_GROVE);
tag(IS_MOUNTAIN_PEAK)
.add(Biomes.JAGGED_PEAKS).add(Biomes.FROZEN_PEAKS).add(Biomes.STONY_PEAKS)
.addOptionalTag(forgeTagKey("is_peak"));
.add(Biomes.JAGGED_PEAKS).add(Biomes.FROZEN_PEAKS).add(Biomes.STONY_PEAKS);
tag(IS_MOUNTAIN)
.addTag(BiomeTags.IS_MOUNTAIN).addTag(IS_MOUNTAIN_PEAK).addTag(IS_MOUNTAIN_SLOPE);
//.addOptionalTag(forgeTagKey("is_mountain")); // can't because forge:is_mountain contains savanna plateau, while c:is_mountain does not
tag(IS_FOREST).addTag(BiomeTags.IS_FOREST);
tag(IS_BIRCH_FOREST).add(Biomes.BIRCH_FOREST).add(Biomes.OLD_GROWTH_BIRCH_FOREST);
@@ -209,19 +246,31 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
.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);
tag(IS_OLD_GROWTH).add(Biomes.OLD_GROWTH_BIRCH_FOREST).add(Biomes.OLD_GROWTH_PINE_TAIGA).add(Biomes.OLD_GROWTH_SPRUCE_TAIGA);
tag(IS_LUSH).add(Biomes.LUSH_CAVES);
tag(IS_MAGICAL);
tag(IS_MODIFIED);
tag(IS_SANDY).add(Biomes.DESERT).add(Biomes.BADLANDS).add(Biomes.WOODED_BADLANDS).add(Biomes.ERODED_BADLANDS).add(Biomes.BEACH);
tag(IS_MUSHROOM).add(Biomes.MUSHROOM_FIELDS);
tag(IS_PLATEAU).add(Biomes.WOODED_BADLANDS).add(Biomes.SAVANNA_PLATEAU).add(Biomes.CHERRY_GROVE).add(Biomes.MEADOW);
tag(IS_SPOOKY).add(Biomes.DARK_FOREST).add(Biomes.DEEP_DARK);
tag(IS_SPOOKY).add(Biomes.DARK_FOREST).add(Biomes.DEEP_DARK).add(Biomes.PALE_GARDEN);
tag(IS_WASTELAND);
tag(IS_RARE).add(Biomes.SUNFLOWER_PLAINS).add(Biomes.FLOWER_FOREST).add(Biomes.OLD_GROWTH_BIRCH_FOREST).add(Biomes.OLD_GROWTH_SPRUCE_TAIGA).add(Biomes.BAMBOO_JUNGLE).add(Biomes.SPARSE_JUNGLE).add(Biomes.ERODED_BADLANDS).add(Biomes.SAVANNA_PLATEAU).add(Biomes.WINDSWEPT_SAVANNA).add(Biomes.ICE_SPIKES).add(Biomes.WINDSWEPT_GRAVELLY_HILLS).add(Biomes.MUSHROOM_FIELDS).add(Biomes.DEEP_DARK);
tag(IS_RARE)
.add(Biomes.SUNFLOWER_PLAINS)
.add(Biomes.FLOWER_FOREST)
.add(Biomes.OLD_GROWTH_BIRCH_FOREST)
.add(Biomes.OLD_GROWTH_SPRUCE_TAIGA)
.add(Biomes.BAMBOO_JUNGLE)
.add(Biomes.SPARSE_JUNGLE)
.add(Biomes.ERODED_BADLANDS)
.add(Biomes.SAVANNA_PLATEAU)
.add(Biomes.WINDSWEPT_SAVANNA)
.add(Biomes.ICE_SPIKES)
.add(Biomes.WINDSWEPT_GRAVELLY_HILLS)
.add(Biomes.MUSHROOM_FIELDS)
.add(Biomes.DEEP_DARK)
.add(Biomes.PALE_GARDEN);
tag(IS_RIVER).addTag(BiomeTags.IS_RIVER);
tag(IS_SHALLOW_OCEAN).add(Biomes.OCEAN).add(Biomes.LUKEWARM_OCEAN).add(Biomes.WARM_OCEAN).add(Biomes.COLD_OCEAN).add(Biomes.FROZEN_OCEAN);
@@ -231,81 +280,11 @@ public final class ForgeBiomeTagsProvider extends BiomeTagsProvider {
tag(IS_AQUATIC).addTag(IS_OCEAN).addTag(IS_RIVER);
tag(IS_CAVE)
.add(Biomes.LUSH_CAVES).add(Biomes.DRIPSTONE_CAVES).add(Biomes.DEEP_DARK)
.addOptionalTag(forgeTagKey("is_cave"));
.add(Biomes.LUSH_CAVES).add(Biomes.DRIPSTONE_CAVES).add(Biomes.DEEP_DARK);
tag(IS_UNDERGROUND).addTag(IS_CAVE);
tag(IS_NETHER_FOREST).add(Biomes.CRIMSON_FOREST).add(Biomes.WARPED_FOREST);
tag(IS_OUTER_END_ISLAND).add(Biomes.END_HIGHLANDS).add(Biomes.END_MIDLANDS).add(Biomes.END_BARRENS);
// Backwards compat definitions for pre-1.21 legacy `forge:` tags.
// TODO: Remove backwards compat tag entries in 1.22
tag(Biomes.PLAINS, forgeTagKey("is_plains"));
tag(Biomes.DESERT, forgeTagKey("is_hot/overworld"), forgeTagKey("is_dry/overworld"), forgeTagKey("is_sandy"), forgeTagKey("is_desert"));
tag(Biomes.TAIGA, forgeTagKey("is_cold/overworld"), forgeTagKey("is_coniferous"));
tag(Biomes.SWAMP, forgeTagKey("is_wet/overworld"), forgeTagKey("is_swamp"));
tag(Biomes.NETHER_WASTES, forgeTagKey("is_hot/nether"), forgeTagKey("is_dry/nether"));
tag(Biomes.THE_END, forgeTagKey("is_cold/end"), forgeTagKey("is_dry/end"));
tag(Biomes.FROZEN_OCEAN, forgeTagKey("is_cold/overworld"), forgeTagKey("is_snowy"));
tag(Biomes.FROZEN_RIVER, forgeTagKey("is_cold/overworld"), forgeTagKey("is_snowy"));
tag(Biomes.SNOWY_PLAINS, forgeTagKey("is_cold/overworld"), forgeTagKey("is_snowy"), forgeTagKey("is_wasteland"), forgeTagKey("is_plains"));
tag(Biomes.MUSHROOM_FIELDS, forgeTagKey("is_mushroom"), forgeTagKey("is_rare"));
tag(Biomes.JUNGLE, forgeTagKey("is_hot/overworld"), forgeTagKey("is_wet/overworld"), forgeTagKey("is_dense/overworld"));
tag(Biomes.SPARSE_JUNGLE, forgeTagKey("is_hot/overworld"), forgeTagKey("is_wet/overworld"), forgeTagKey("is_rare"));
tag(Biomes.BEACH, forgeTagKey("is_wet/overworld"), forgeTagKey("is_sandy"));
tag(Biomes.SNOWY_BEACH, forgeTagKey("is_cold/overworld"), forgeTagKey("is_snowy"));
tag(Biomes.DARK_FOREST, forgeTagKey("is_spooky"), forgeTagKey("is_dense/overworld"));
tag(Biomes.SNOWY_TAIGA, forgeTagKey("is_cold/overworld"), forgeTagKey("is_coniferous"), forgeTagKey("is_snowy"));
tag(Biomes.OLD_GROWTH_PINE_TAIGA, forgeTagKey("is_cold/overworld"), forgeTagKey("is_coniferous"));
tag(Biomes.WINDSWEPT_FOREST, forgeTagKey("is_sparse/overworld"));
tag(Biomes.SAVANNA, forgeTagKey("is_hot/overworld"), forgeTagKey("is_sparse/overworld"));
tag(Biomes.SAVANNA_PLATEAU, forgeTagKey("is_hot/overworld"), forgeTagKey("is_sparse/overworld"), forgeTagKey("is_rare"), forgeTagKey("is_slope"), Tags.Biomes.IS_PLATEAU);
tag(Biomes.BADLANDS, forgeTagKey("is_sandy"), forgeTagKey("is_dry/overworld"));
tag(Biomes.WOODED_BADLANDS, forgeTagKey("is_sandy"), forgeTagKey("is_dry/overworld"), forgeTagKey("is_sparse/overworld"), forgeTagKey("is_slope"), Tags.Biomes.IS_PLATEAU);
tag(Biomes.MEADOW, forgeTagKey("is_plains"), Tags.Biomes.IS_PLATEAU, forgeTagKey("is_slope"));
tag(Biomes.GROVE, forgeTagKey("is_cold/overworld"), forgeTagKey("is_coniferous"), forgeTagKey("is_snowy"), forgeTagKey("is_slope"));
tag(Biomes.SNOWY_SLOPES, forgeTagKey("is_cold/overworld"), forgeTagKey("is_sparse/overworld"), forgeTagKey("is_snowy"), forgeTagKey("is_slope"));
tag(Biomes.JAGGED_PEAKS, forgeTagKey("is_cold/overworld"), forgeTagKey("is_sparse/overworld"), forgeTagKey("is_snowy"), forgeTagKey("is_peak"));
tag(Biomes.FROZEN_PEAKS, forgeTagKey("is_cold/overworld"), forgeTagKey("is_sparse/overworld"), forgeTagKey("is_snowy"), forgeTagKey("is_peak"));
tag(Biomes.STONY_PEAKS, forgeTagKey("is_hot/overworld"), forgeTagKey("is_peak"));
tag(Biomes.SMALL_END_ISLANDS, forgeTagKey("is_cold/end"), forgeTagKey("is_dry/end"));
tag(Biomes.END_MIDLANDS, forgeTagKey("is_cold/end"), forgeTagKey("is_dry/end"));
tag(Biomes.END_HIGHLANDS, forgeTagKey("is_cold/end"), forgeTagKey("is_dry/end"));
tag(Biomes.END_BARRENS, forgeTagKey("is_cold/end"), forgeTagKey("is_dry/end"));
tag(Biomes.WARM_OCEAN, forgeTagKey("is_hot/overworld"));
tag(Biomes.COLD_OCEAN, forgeTagKey("is_cold/overworld"));
tag(Biomes.DEEP_COLD_OCEAN, forgeTagKey("is_cold/overworld"));
tag(Biomes.DEEP_FROZEN_OCEAN, forgeTagKey("is_cold/overworld"));
tag(Biomes.THE_VOID, forgeTagKey("is_void"));
tag(Biomes.SUNFLOWER_PLAINS, forgeTagKey("is_plains"), forgeTagKey("is_rare"));
tag(Biomes.WINDSWEPT_GRAVELLY_HILLS, forgeTagKey("is_sparse/overworld"), forgeTagKey("is_rare"));
tag(Biomes.FLOWER_FOREST, forgeTagKey("is_rare"));
tag(Biomes.ICE_SPIKES, forgeTagKey("is_cold/overworld"), forgeTagKey("is_snowy"), forgeTagKey("is_rare"));
tag(Biomes.OLD_GROWTH_BIRCH_FOREST, forgeTagKey("is_dense/overworld"), forgeTagKey("is_rare"));
tag(Biomes.OLD_GROWTH_SPRUCE_TAIGA, forgeTagKey("is_dense/overworld"), forgeTagKey("is_rare"));
tag(Biomes.WINDSWEPT_SAVANNA, forgeTagKey("is_hot/overworld"), forgeTagKey("is_dry/overworld"), forgeTagKey("is_sparse/overworld"), forgeTagKey("is_rare"));
tag(Biomes.ERODED_BADLANDS, forgeTagKey("is_hot/overworld"), forgeTagKey("is_dry/overworld"), forgeTagKey("is_sparse/overworld"), forgeTagKey("is_rare"));
tag(Biomes.BAMBOO_JUNGLE, forgeTagKey("is_hot/overworld"), forgeTagKey("is_wet/overworld"), forgeTagKey("is_rare"));
tag(Biomes.LUSH_CAVES, forgeTagKey("is_cave"), forgeTagKey("is_lush"), forgeTagKey("is_wet/overworld"));
tag(Biomes.DRIPSTONE_CAVES, forgeTagKey("is_cave"), forgeTagKey("is_sparse/overworld"));
tag(Biomes.SOUL_SAND_VALLEY, forgeTagKey("is_hot/nether"), forgeTagKey("is_dry/nether"));
tag(Biomes.CRIMSON_FOREST, forgeTagKey("is_hot/nether"), forgeTagKey("is_dry/nether"));
tag(Biomes.WARPED_FOREST, forgeTagKey("is_hot/nether"), forgeTagKey("is_dry/nether"));
tag(Biomes.BASALT_DELTAS, forgeTagKey("is_hot/nether"), forgeTagKey("is_dry/nether"));
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);
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"));
tag(forgeTagKey("is_water")).addTag(BiomeTags.IS_OCEAN).addTag(BiomeTags.IS_RIVER);
tag(forgeTagKey("is_mountain")).addTag(forgeTagKey("is_peak")).addTag(forgeTagKey("is_slope"));
tag(forgeTagKey("is_underground")).addTag(forgeTagKey("is_cave"));
}
@SafeVarargs
@@ -12,7 +12,6 @@ import net.minecraft.data.tags.BlockItemTagsProvider;
import net.minecraft.data.tags.TagAppender;
import net.minecraft.resources.Identifier;
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;
@@ -26,14 +25,11 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
@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);
.addTag(Tags.Blocks.BARRELS_WOODEN);
tag(Tags.Blocks.BARRELS_WOODEN, Tags.Items.BARRELS_WOODEN)
.add(Blocks.BARREL);
tag(Tags.Blocks.BOOKSHELVES, Tags.Items.BOOKSHELVES)
.add(Blocks.BOOKSHELF);
tag(Tags.Blocks.BUDDING_BLOCKS, Tags.Items.BUDDING_BLOCKS)
.add(Blocks.BUDDING_AMETHYST);
tag(Tags.Blocks.BUDS, Tags.Items.BUDS)
@@ -43,47 +39,36 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
tag(Tags.Blocks.CHAINS, Tags.Items.CHAINS)
.add(Blocks.IRON_CHAIN)
.addAll(Blocks.COPPER_CHAIN.asList());
tag(Tags.Blocks.CHESTS_ENDER, Tags.Items.CHESTS_ENDER)
.add(Blocks.ENDER_CHEST);
tag(Tags.Blocks.CHESTS_TRAPPED, Tags.Items.CHESTS_TRAPPED)
.add(Blocks.TRAPPED_CHEST);
tag(Tags.Blocks.CHESTS_WOODEN, Tags.Items.CHESTS_WOODEN)
.add(Blocks.CHEST, Blocks.TRAPPED_CHEST);
tag(Tags.Blocks.CHESTS, Tags.Items.CHESTS)
.add(Blocks.COPPER_CHEST)
.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)
tag(Tags.Blocks.COBBLESTONES_NORMAL, Tags.Items.COBBLESTONES_NORMAL)
.add(Blocks.COBBLESTONE);
tag(Tags.Blocks.COBBLESTONES_INFESTED, Tags.Items.COBBLESTONES_INFESTED)
.add(Blocks.INFESTED_COBBLESTONE);
tag(Tags.Blocks.COBBLESTONES_MOSSY, Tags.Items.COBBLESTONES_MOSSY)
.add(Blocks.MOSSY_COBBLESTONE);
tag(Tags.Blocks.COBBLESTONES_DEEPSLATE, Tags.Items.COBBLESTONES_DEEPSLATE)
.add(Blocks.COBBLED_DEEPSLATE);
tag(Tags.Blocks.COBBLESTONES, Tags.Items.COBBLESTONES)
.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
Tags.Blocks.COBBLESTONES_NORMAL,
Tags.Blocks.COBBLESTONES_INFESTED,
Tags.Blocks.COBBLESTONES_MOSSY,
Tags.Blocks.COBBLESTONES_DEEPSLATE
);
tag(Tags.Blocks.CONCRETES, Tags.Items.CONCRETES)
.add(
Blocks.WHITE_CONCRETE,
@@ -103,13 +88,10 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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"));
.add(Blocks.END_STONE);
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"));
.addTags(Tags.Blocks.FENCE_GATES_WOODEN);
tag(Tags.Blocks.FENCE_GATES_WOODEN, Tags.Items.FENCE_GATES_WOODEN)
.add(
Blocks.OAK_FENCE_GATE,
@@ -124,18 +106,15 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
Blocks.BAMBOO_FENCE_GATE,
Blocks.CHERRY_FENCE_GATE
);
//copy(forgeBlockTagKey("fences"), forgeItemTagKey("fences"));
tag(Tags.Blocks.FENCES_NETHER_BRICK, Tags.Items.FENCES_NETHER_BRICK)
.add(Blocks.NETHER_BRICK_FENCE);
tag(Tags.Blocks.FENCES_WOODEN, Tags.Items.FENCES_WOODEN)
.addTag(BlockTags.WOODEN_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,
@@ -154,8 +133,7 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
Blocks.TORCHFLOWER,
Blocks.OPEN_EYEBLOSSOM,
Blocks.CLOSED_EYEBLOSSOM
)
.addOptionalTag(BlockTags.SMALL_FLOWERS);
);
tag(Tags.Blocks.FLOWERS_TALL, Tags.Items.FLOWERS_TALL)
.add(
Blocks.SUNFLOWER,
@@ -163,8 +141,7 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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,
@@ -184,16 +161,13 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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);
.add(Blocks.GLASS);
tag(Tags.Blocks.GLASS_BLOCKS_TINTED, Tags.Items.GLASS_BLOCKS_TINTED)
.add(Blocks.TINTED_GLASS)
.addOptionalTag(Legacy.Blocks.GLASS_TINTED);
.add(Blocks.TINTED_GLASS);
tag(Tags.Blocks.GLASS_BLOCKS_CHEAP, Tags.Items.GLASS_BLOCKS_CHEAP, Legacy.Blocks.GLASS_SILICA, Legacy.Items.GLASS_SILICA)
tag(Tags.Blocks.GLASS_BLOCKS_CHEAP, Tags.Items.GLASS_BLOCKS_CHEAP)
.add(
Blocks.GLASS,
Blocks.WHITE_STAINED_GLASS,
@@ -212,8 +186,7 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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(
@@ -233,11 +206,9 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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"));
.add(Blocks.GLASS_PANE);
tag(Tags.Blocks.GLAZED_TERRACOTTAS, Tags.Items.GLAZED_TERRACOTTAS)
.add(
Blocks.WHITE_GLAZED_TERRACOTTA,
@@ -257,28 +228,55 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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.GRAVELS, Tags.Items.GRAVELS)
.add(Blocks.GRAVEL);
tag(Tags.Blocks.NATURAL_LOGS_NETHER, Tags.Items.NATURAL_LOGS_NETHER)
.add(Blocks.CRIMSON_STEM, Blocks.WARPED_STEM);
tag(Tags.Blocks.NATURAL_LOGS_OVERWORLD, Tags.Items.NATURAL_LOGS_OVERWORLD)
.add(
Blocks.ACACIA_LOG,
Blocks.BIRCH_LOG,
Blocks.CHERRY_LOG,
Blocks.DARK_OAK_LOG,
Blocks.JUNGLE_LOG,
Blocks.MANGROVE_LOG,
Blocks.OAK_LOG,
Blocks.PALE_OAK_LOG,
Blocks.SPRUCE_LOG
);
tag(Tags.Blocks.NATURAL_LOGS, Tags.Items.NATURAL_LOGS)
.addTags(Tags.Blocks.NATURAL_LOGS_NETHER, Tags.Blocks.NATURAL_LOGS_OVERWORLD);
tag(Tags.Blocks.NATURAL_WOODS, Tags.Items.NATURAL_WOODS)
.add(
Blocks.ACACIA_WOOD,
Blocks.BIRCH_WOOD,
Blocks.CHERRY_WOOD,
Blocks.CRIMSON_HYPHAE,
Blocks.DARK_OAK_WOOD,
Blocks.JUNGLE_WOOD,
Blocks.MANGROVE_WOOD,
Blocks.OAK_WOOD,
Blocks.PALE_OAK_WOOD,
Blocks.SPRUCE_WOOD,
Blocks.WARPED_HYPHAE
);
tag(Tags.Blocks.NETHERRACKS, Tags.Items.NETHERRACKS)
.add(Blocks.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
.add(Blocks.DEEPSLATE);
tag(Tags.Blocks.ORE_BEARING_GROUND_NETHERRACK, Tags.Items.ORE_BEARING_GROUND_NETHERRACK)
.add(Blocks.NETHERRACK); // forge:ore_bearing_ground/netherrack
.add(Blocks.NETHERRACK);
tag(Tags.Blocks.ORE_BEARING_GROUND_STONE, Tags.Items.ORE_BEARING_GROUND_STONE)
.add(Blocks.STONE); // forge:ore_bearing_ground/stone
.add(Blocks.STONE);
tag(Tags.Blocks.ORE_RATES_DENSE, Tags.Items.ORE_RATES_DENSE)
.add(
Blocks.COPPER_ORE,
@@ -305,6 +303,26 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
);
tag(Tags.Blocks.ORE_RATES_SPARSE, Tags.Items.ORE_RATES_SPARSE)
.add(Blocks.NETHER_GOLD_ORE);
tag(Tags.Blocks.ORES_COAL, Tags.Items.ORES_COAL)
.addTag(BlockTags.COAL_ORES);
tag(Tags.Blocks.ORES_COPPER, Tags.Items.ORES_COPPER)
.addTag(BlockTags.COPPER_ORES);
tag(Tags.Blocks.ORES_DIAMOND, Tags.Items.ORES_DIAMOND)
.addTag(BlockTags.DIAMOND_ORES);
tag(Tags.Blocks.ORES_EMERALD, Tags.Items.ORES_EMERALD)
.addTag(BlockTags.EMERALD_ORES);
tag(Tags.Blocks.ORES_GOLD, Tags.Items.ORES_GOLD)
.addTag(BlockTags.GOLD_ORES);
tag(Tags.Blocks.ORES_IRON, Tags.Items.ORES_IRON)
.addTag(BlockTags.IRON_ORES);
tag(Tags.Blocks.ORES_LAPIS, Tags.Items.ORES_LAPIS)
.addTag(BlockTags.LAPIS_ORES);
tag(Tags.Blocks.ORES_QUARTZ, Tags.Items.ORES_QUARTZ)
.add(Blocks.NETHER_QUARTZ_ORE);
tag(Tags.Blocks.ORES_REDSTONE, Tags.Items.ORES_REDSTONE)
.addTag(BlockTags.REDSTONE_ORES);
tag(Tags.Blocks.ORES_NETHERITE_SCRAP, Tags.Items.ORES_NETHERITE_SCRAP)
.add(Blocks.ANCIENT_DEBRIS);
tag(Tags.Blocks.ORES, Tags.Items.ORES)
.addTags(
Tags.Blocks.ORES_COAL,
@@ -317,30 +335,7 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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,
@@ -385,21 +380,20 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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
tag(Tags.Blocks.SANDS, Tags.Items.SANDS)
.addTags(
Tags.Blocks.SAND_COLORLESS,
Tags.Blocks.SAND_RED
Tags.Blocks.SANDS_COLORLESS,
Tags.Blocks.SANDS_RED
);
tag(Tags.Blocks.SAND_COLORLESS, Tags.Items.SAND_COLORLESS) // forge:sand/colorless
tag(Tags.Blocks.SANDS_COLORLESS, Tags.Items.SANDS_COLORLESS)
.add(Blocks.SAND);
tag(Tags.Blocks.SAND_RED, Tags.Items.SAND_RED) // forge:sand/red
tag(Tags.Blocks.SANDS_RED, Tags.Items.SANDS_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,
@@ -455,7 +449,6 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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,
@@ -473,67 +466,43 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
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
Tags.Blocks.STORAGE_BLOCKS_WHEAT,
Tags.Blocks.STORAGE_BLOCKS_RESIN
);
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_COAL, Tags.Items.STORAGE_BLOCKS_COAL)
.add(Blocks.COAL_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_COPPER, Tags.Items.STORAGE_BLOCKS_COPPER)
.add(Blocks.COPPER_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_DIAMOND, Tags.Items.STORAGE_BLOCKS_DIAMOND)
.add(Blocks.DIAMOND_BLOCK);
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_EMERALD, Tags.Items.STORAGE_BLOCKS_EMERALD)
.add(Blocks.EMERALD_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_GOLD, Tags.Items.STORAGE_BLOCKS_GOLD)
.add(Blocks.GOLD_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_IRON, Tags.Items.STORAGE_BLOCKS_IRON)
.add(Blocks.IRON_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_LAPIS, Tags.Items.STORAGE_BLOCKS_LAPIS)
.add(Blocks.LAPIS_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_NETHERITE, Tags.Items.STORAGE_BLOCKS_NETHERITE)
.add(Blocks.NETHERITE_BLOCK);
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_RAW_COPPER, Tags.Items.STORAGE_BLOCKS_RAW_COPPER)
.add(Blocks.RAW_COPPER_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_RAW_GOLD, Tags.Items.STORAGE_BLOCKS_RAW_GOLD)
.add(Blocks.RAW_GOLD_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_RAW_IRON, Tags.Items.STORAGE_BLOCKS_RAW_IRON)
.add(Blocks.RAW_IRON_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_RESIN, Tags.Items.STORAGE_BLOCKS_RESIN)
.add(Blocks.RESIN_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, Tags.Items.STORAGE_BLOCKS_REDSTONE)
.add(Blocks.REDSTONE_BLOCK);
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)
@@ -544,116 +513,28 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
Blocks.STRIPPED_BAMBOO_BLOCK,
Blocks.STRIPPED_BIRCH_LOG,
Blocks.STRIPPED_CHERRY_LOG,
Blocks.STRIPPED_CRIMSON_STEM,
Blocks.STRIPPED_DARK_OAK_LOG,
Blocks.STRIPPED_JUNGLE_LOG,
Blocks.STRIPPED_MANGROVE_LOG,
Blocks.STRIPPED_OAK_LOG,
Blocks.STRIPPED_SPRUCE_LOG
Blocks.STRIPPED_PALE_OAK_LOG,
Blocks.STRIPPED_SPRUCE_LOG,
Blocks.STRIPPED_WARPED_STEM
);
tag(Tags.Blocks.STRIPPED_WOODS, Tags.Items.STRIPPED_WOODS)
.add(
Blocks.STRIPPED_ACACIA_WOOD,
Blocks.STRIPPED_BIRCH_WOOD,
Blocks.STRIPPED_CHERRY_WOOD,
Blocks.STRIPPED_CRIMSON_HYPHAE,
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
Blocks.STRIPPED_PALE_OAK_WOOD,
Blocks.STRIPPED_SPRUCE_WOOD,
Blocks.STRIPPED_WARPED_HYPHAE
);
}
@@ -764,80 +645,4 @@ public abstract class ForgeBlockItemTagsProvider extends BlockItemTagsProvider {
}
};
}
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");
}
}
}
Loaded 100 of 1558 files, more files were not shown because too many files have changed in this diff. Show more