mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
Forge 1.20
- Creative mode tabs are now a registry; the `BuildContents` event was renamed to `BuildCreativeModeTabContentsEvent` and moved it to its own class - The pack format is now 15 for both resource packs and data packs - `ScreenUtils` was deprecated in favor of a `GuiGraphics` extension - Forge and the MDK were updated to Gradle 8 and FG6 - The Forge common config file was removed (it only contained the deprecated old fields for resource caching, which was removed in 1.19.3) - Registry dummy entries were removed - `RemappingVertexPipeline` was fixed to forward the `endVertex()` call - Forge tool tags were removed in favor of vanilla ones Co-authored-by: ChampionAsh5357 <[email protected]> Co-authored-by: coehlrich <[email protected]> Co-authored-by: Dennis C <[email protected]> Co-authored-by: Matyrobbrt <[email protected]>
This commit is contained in:
1 parent
658e614dc1
commit
d8c84e2949
568 files changed
+5114
-5807
No files matched your search
@@ -25,6 +25,7 @@ import net.minecraft.world.scores.Scoreboard;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -44,9 +45,9 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
* Sends a success message without attempting to get the server side list of admins
|
||||
*/
|
||||
@Override
|
||||
public void sendSuccess(Component message, boolean sendToAdmins)
|
||||
public void sendSuccess(Supplier<Component> message, boolean sendToAdmins)
|
||||
{
|
||||
Minecraft.getInstance().player.sendSystemMessage(message);
|
||||
Minecraft.getInstance().player.sendSystemMessage(message.get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,10 +33,6 @@ public class ClientForgeMod
|
||||
event.register("composite", CompositeModel.Loader.INSTANCE);
|
||||
event.register("item_layers", ItemLayerModel.Loader.INSTANCE);
|
||||
event.register("separate_transforms", SeparateTransformsModel.Loader.INSTANCE);
|
||||
|
||||
// TODO: Deprecated. To be removed in 1.20
|
||||
event.register("bucket", DynamicFluidContainerModel.Loader.INSTANCE_DEPRECATED);
|
||||
event.register("separate-perspective", SeparateTransformsModel.Loader.INSTANCE_DEPRECATED);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.FileUtil;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
@@ -24,13 +23,14 @@ import net.minecraft.client.Options;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraft.client.gui.components.toasts.Toast;
|
||||
import net.minecraft.client.gui.screens.ConfirmScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
||||
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.Model;
|
||||
@@ -78,6 +78,7 @@ import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
@@ -128,7 +129,6 @@ import net.minecraftforge.client.event.RenderArmEvent;
|
||||
import net.minecraftforge.client.event.RenderBlockScreenEffectEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderHighlightEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelStageEvent;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
@@ -149,7 +149,7 @@ import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.MutableHashedLinkedMap;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
@@ -157,6 +157,7 @@ import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.forge.snapshots.ForgeSnapshotsModClient;
|
||||
import net.minecraftforge.gametest.ForgeGameTestHooks;
|
||||
import net.minecraftforge.network.NetworkConstants;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
@@ -193,9 +194,6 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static net.minecraftforge.fml.VersionChecker.Status.BETA;
|
||||
import static net.minecraftforge.fml.VersionChecker.Status.BETA_OUTDATED;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class ForgeHooksClient
|
||||
{
|
||||
@@ -252,9 +250,9 @@ public class ForgeHooksClient
|
||||
public static float getGuiFarPlane()
|
||||
{
|
||||
// 1000 units for the overlay background,
|
||||
// and 2000 units for each layered Screen,
|
||||
// and 10000 units for each layered Screen,
|
||||
|
||||
return 1000.0F + 2000.0F * (1 + guiLayers.size());
|
||||
return 1000.0F + 10000.0F * (1 + guiLayers.size());
|
||||
}
|
||||
|
||||
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlot slot, String type)
|
||||
@@ -277,12 +275,6 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
public static void dispatchRenderLast(LevelRenderer context, PoseStack poseStack, float partialTick, Matrix4f projectionMatrix, long finishTimeNano)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new RenderLevelLastEvent(context, poseStack, partialTick, projectionMatrix, finishTimeNano));
|
||||
}
|
||||
|
||||
public static void dispatchRenderStage(RenderLevelStageEvent.Stage stage, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum)
|
||||
{
|
||||
var mc = Minecraft.getInstance();
|
||||
@@ -388,30 +380,19 @@ public class ForgeHooksClient
|
||||
//RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance);
|
||||
}
|
||||
|
||||
public static void renderMainMenu(TitleScreen gui, PoseStack poseStack, Font font, int width, int height, int alpha)
|
||||
public static void renderMainMenu(TitleScreen gui, GuiGraphics guiGraphics, Font font, int width, int height, int alpha)
|
||||
{
|
||||
VersionChecker.Status status = ForgeVersion.getStatus();
|
||||
if (status == BETA || status == BETA_OUTDATED)
|
||||
{
|
||||
// render a warning at the top of the screen,
|
||||
Component line = Component.translatable("forge.update.beta.1", ChatFormatting.RED, ChatFormatting.RESET).withStyle(ChatFormatting.RED);
|
||||
GuiComponent.drawCenteredString(poseStack, font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
|
||||
line = Component.translatable("forge.update.beta.2");
|
||||
GuiComponent.drawCenteredString(poseStack, font, line, width / 2, 4 + (1 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
|
||||
}
|
||||
ForgeSnapshotsModClient.renderMainMenuWarning(status, gui, guiGraphics, font, width, height, alpha);
|
||||
|
||||
String line = null;
|
||||
switch(status)
|
||||
forgeStatusLine = switch(status)
|
||||
{
|
||||
//case FAILED: line = " Version check failed"; break;
|
||||
//case UP_TO_DATE: line = "Forge up to date"}; break;
|
||||
//case AHEAD: line = "Using non-recommended Forge build, issues may arise."}; break;
|
||||
case OUTDATED:
|
||||
case BETA_OUTDATED: line = I18n.get("forge.update.newversion", ForgeVersion.getTarget()); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
forgeStatusLine = line;
|
||||
// case FAILED -> " Version check failed";
|
||||
// case UP_TO_DATE -> "Forge up to date";
|
||||
// case AHEAD -> "Using non-recommended Forge build, issues may arise.";
|
||||
case OUTDATED, BETA_OUTDATED -> I18n.get("forge.update.newversion", ForgeVersion.getTarget());
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public static String forgeStatusLine;
|
||||
@@ -423,23 +404,23 @@ public class ForgeHooksClient
|
||||
return e.getSound();
|
||||
}
|
||||
|
||||
public static void drawScreen(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public static void drawScreen(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
poseStack.pushPose();
|
||||
guiGraphics.pose().pushPose();
|
||||
guiLayers.forEach(layer -> {
|
||||
// Prevent the background layers from thinking the mouse is over their controls and showing them as highlighted.
|
||||
drawScreenInternal(layer, poseStack, Integer.MAX_VALUE, Integer.MAX_VALUE, partialTick);
|
||||
poseStack.translate(0,0,2000);
|
||||
drawScreenInternal(layer, guiGraphics, Integer.MAX_VALUE, Integer.MAX_VALUE, partialTick);
|
||||
guiGraphics.pose().translate(0,0,2000);
|
||||
});
|
||||
drawScreenInternal(screen, poseStack, mouseX, mouseY, partialTick);
|
||||
poseStack.popPose();
|
||||
drawScreenInternal(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
|
||||
private static void drawScreenInternal(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
private static void drawScreenInternal(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
if (!MinecraftForge.EVENT_BUS.post(new ScreenEvent.Render.Pre(screen, poseStack, mouseX, mouseY, partialTick)))
|
||||
screen.renderWithTooltip(poseStack, mouseX, mouseY, partialTick);
|
||||
MinecraftForge.EVENT_BUS.post(new ScreenEvent.Render.Post(screen, poseStack, mouseX, mouseY, partialTick));
|
||||
if (!MinecraftForge.EVENT_BUS.post(new ScreenEvent.Render.Pre(screen, guiGraphics, mouseX, mouseY, partialTick)))
|
||||
screen.renderWithTooltip(guiGraphics, mouseX, mouseY, partialTick);
|
||||
MinecraftForge.EVENT_BUS.post(new ScreenEvent.Render.Post(screen, guiGraphics, mouseX, mouseY, partialTick));
|
||||
}
|
||||
|
||||
public static Vector3f getFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, float fogRed, float fogGreen, float fogBlue)
|
||||
@@ -460,8 +441,8 @@ public class ForgeHooksClient
|
||||
public static void onFogRender(FogRenderer.FogMode mode, FogType type, Camera camera, float partialTick, float renderDistance, float nearDistance, float farDistance, FogShape shape)
|
||||
{
|
||||
// Modify fog rendering depending on the fluid
|
||||
FluidState state = camera.getEntity().level.getFluidState(camera.getBlockPosition());
|
||||
if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(camera.getEntity().level, camera.getBlockPosition())))
|
||||
FluidState state = camera.getEntity().level().getFluidState(camera.getBlockPosition());
|
||||
if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(camera.getEntity().level(), camera.getBlockPosition())))
|
||||
IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, nearDistance, farDistance, shape);
|
||||
|
||||
ViewportEvent.RenderFog event = new ViewportEvent.RenderFog(mode, type, camera, partialTick, nearDistance, farDistance, shape);
|
||||
@@ -595,9 +576,9 @@ public class ForgeHooksClient
|
||||
return from.getItem().shouldCauseReequipAnimation(from, to, changed);
|
||||
}
|
||||
|
||||
public static CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(PoseStack poseStack, Window window, LerpingBossEvent bossInfo, int x, int y, int increment)
|
||||
public static CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(GuiGraphics guiGraphics, Window window, LerpingBossEvent bossInfo, int x, int y, int increment)
|
||||
{
|
||||
CustomizeGuiOverlayEvent.BossEventProgress evt = new CustomizeGuiOverlayEvent.BossEventProgress(window, poseStack,
|
||||
CustomizeGuiOverlayEvent.BossEventProgress evt = new CustomizeGuiOverlayEvent.BossEventProgress(window, guiGraphics,
|
||||
Minecraft.getInstance().getPartialTick(), bossInfo, x, y, increment);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt;
|
||||
@@ -879,7 +860,7 @@ public class ForgeHooksClient
|
||||
}
|
||||
|
||||
private static final ResourceLocation ICON_SHEET = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/icons.png");
|
||||
public static void drawForgePingInfo(JoinMultiplayerScreen gui, ServerData target, PoseStack poseStack, int x, int y, int width, int relativeMouseX, int relativeMouseY) {
|
||||
public static void drawForgePingInfo(JoinMultiplayerScreen gui, ServerData target, GuiGraphics guiGraphics, int x, int y, int width, int relativeMouseX, int relativeMouseY) {
|
||||
int idx;
|
||||
String tooltip;
|
||||
if (target.forgeData == null)
|
||||
@@ -917,8 +898,7 @@ public class ForgeHooksClient
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.unknown", target.forgeData.type());
|
||||
}
|
||||
|
||||
RenderSystem.setShaderTexture(0, ICON_SHEET);
|
||||
GuiComponent.blit(poseStack, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256);
|
||||
guiGraphics.blit(ICON_SHEET, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256);
|
||||
|
||||
if(relativeMouseX > width - 15 && relativeMouseX < width && relativeMouseY > 10 && relativeMouseY < 26) {
|
||||
//this is not the most proper way to do it,
|
||||
@@ -1028,38 +1008,34 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
public static Font getTooltipFont(@Nullable Font forcedFont, @NotNull ItemStack stack, Font fallbackFont)
|
||||
public static Font getTooltipFont(@NotNull ItemStack stack, Font fallbackFont)
|
||||
{
|
||||
if (forcedFont != null)
|
||||
{
|
||||
return forcedFont;
|
||||
}
|
||||
Font stackFont = IClientItemExtensions.of(stack).getFont(stack, IClientItemExtensions.FontContext.TOOLTIP);
|
||||
return stackFont == null ? fallbackFont : stackFont;
|
||||
}
|
||||
|
||||
public static RenderTooltipEvent.Pre onRenderTooltipPre(@NotNull ItemStack stack, PoseStack poseStack, int x, int y, int screenWidth, int screenHeight, @NotNull List<ClientTooltipComponent> components, @Nullable Font forcedFont, @NotNull Font fallbackFont)
|
||||
public static RenderTooltipEvent.Pre onRenderTooltipPre(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, @NotNull List<ClientTooltipComponent> components, @NotNull Font fallbackFont, @NotNull ClientTooltipPositioner positioner)
|
||||
{
|
||||
var preEvent = new RenderTooltipEvent.Pre(stack, poseStack, x, y, screenWidth, screenHeight, getTooltipFont(forcedFont, stack, fallbackFont), components);
|
||||
var preEvent = new RenderTooltipEvent.Pre(stack, graphics, x, y, screenWidth, screenHeight, getTooltipFont(stack, fallbackFont), components, positioner);
|
||||
MinecraftForge.EVENT_BUS.post(preEvent);
|
||||
return preEvent;
|
||||
}
|
||||
|
||||
public static RenderTooltipEvent.Color onRenderTooltipColor(@NotNull ItemStack stack, PoseStack poseStack, int x, int y, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
public static RenderTooltipEvent.Color onRenderTooltipColor(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
var colorEvent = new RenderTooltipEvent.Color(stack, poseStack, x, y, font, 0xf0100010, 0x505000FF, 0x5028007f, components);
|
||||
var colorEvent = new RenderTooltipEvent.Color(stack, graphics, x, y, font, 0xf0100010, 0x505000FF, 0x5028007f, components);
|
||||
MinecraftForge.EVENT_BUS.post(colorEvent);
|
||||
return colorEvent;
|
||||
}
|
||||
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponents(ItemStack stack, List<? extends FormattedText> textElements, int mouseX, int screenWidth, int screenHeight, @Nullable Font forcedFont, Font fallbackFont)
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponents(ItemStack stack, List<? extends FormattedText> textElements, int mouseX, int screenWidth, int screenHeight, Font fallbackFont)
|
||||
{
|
||||
return gatherTooltipComponents(stack, textElements, Optional.empty(), mouseX, screenWidth, screenHeight, forcedFont, fallbackFont);
|
||||
return gatherTooltipComponents(stack, textElements, Optional.empty(), mouseX, screenWidth, screenHeight, fallbackFont);
|
||||
}
|
||||
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponents(ItemStack stack, List<? extends FormattedText> textElements, Optional<TooltipComponent> itemComponent, int mouseX, int screenWidth, int screenHeight, @Nullable Font forcedFont, Font fallbackFont)
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponents(ItemStack stack, List<? extends FormattedText> textElements, Optional<TooltipComponent> itemComponent, int mouseX, int screenWidth, int screenHeight, Font fallbackFont)
|
||||
{
|
||||
Font font = getTooltipFont(forcedFont, stack, fallbackFont);
|
||||
Font font = getTooltipFont(stack, fallbackFont);
|
||||
List<Either<FormattedText, TooltipComponent>> elements = textElements.stream()
|
||||
.map((Function<FormattedText, Either<FormattedText, TooltipComponent>>) Either::left)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
@@ -1206,7 +1182,7 @@ public class ForgeHooksClient
|
||||
return new ResourceLocation(loc.getNamespace(), normalised);
|
||||
}
|
||||
|
||||
public static void onCreativeModeTabBuildContents(CreativeModeTab tab, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output)
|
||||
public static void onCreativeModeTabBuildContents(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.DisplayItemsGenerator originalGenerator, CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output)
|
||||
{
|
||||
final var entries = new MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility>(ItemStackLinkedSet.TYPE_AND_TAG,
|
||||
(key, left, right) -> {
|
||||
@@ -1223,7 +1199,7 @@ public class ForgeHooksClient
|
||||
entries.put(stack, vis);
|
||||
});
|
||||
|
||||
ModLoader.get().postEvent(new CreativeModeTabEvent.BuildContents(tab, params, entries));
|
||||
ModLoader.get().postEvent(new BuildCreativeModeTabContentsEvent(tab, tabKey, params, entries));
|
||||
|
||||
for (var entry : entries)
|
||||
output.accept(entry.getKey(), entry.getValue());
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.client.event.RegisterItemDecorationsEvent;
|
||||
@@ -20,21 +18,13 @@ import net.minecraftforge.client.event.RegisterItemDecorationsEvent;
|
||||
public interface IItemDecorator
|
||||
{
|
||||
/**
|
||||
* Use {@linkplain IItemDecorator#render(PoseStack, Font, ItemStack, int, int)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
default boolean render(Font font, ItemStack stack, int xOffset, int yOffset, float blitOffset) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called after {@linkplain ItemRenderer#renderGuiItemDecorations(PoseStack, Font, ItemStack, int, int, String)} is done rendering.
|
||||
* Is called after {@linkplain GuiGraphics#renderItemDecorations(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
|
||||
*/
|
||||
default boolean render(PoseStack poseStack, Font font, ItemStack stack, int xOffset, int yOffset) {
|
||||
return IItemDecorator.this.render(font, stack, xOffset, yOffset, 0);
|
||||
default boolean render(GuiGraphics guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -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 com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.world.item.Item;
|
||||
@@ -54,12 +54,12 @@ public final class ItemDecoratorHandler
|
||||
return DECORATOR_LOOKUP.getOrDefault(stack.getItem(), EMPTY);
|
||||
}
|
||||
|
||||
public void render(PoseStack poseStack, Font font, ItemStack stack, int xOffset, int yOffset)
|
||||
public void render(GuiGraphics guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset)
|
||||
{
|
||||
resetRenderState();
|
||||
for (IItemDecorator itemDecorator : itemDecorators)
|
||||
{
|
||||
if (itemDecorator.render(poseStack, font, stack, xOffset, yOffset))
|
||||
if (itemDecorator.render(guiGraphics, font, stack, xOffset, yOffset))
|
||||
resetRenderState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -53,25 +53,25 @@ public abstract class ContainerScreenEvent extends Event
|
||||
*/
|
||||
public static abstract class Render extends ContainerScreenEvent
|
||||
{
|
||||
private final PoseStack poseStack;
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected Render(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
protected Render(AbstractContainerScreen<?> guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer);
|
||||
this.poseStack = poseStack;
|
||||
this.guiGraphics = guiGraphics;
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
* {@return the gui graphics used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
public GuiGraphics getGuiGraphics()
|
||||
{
|
||||
return poseStack;
|
||||
return guiGraphics;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,9 +105,9 @@ public abstract class ContainerScreenEvent extends Event
|
||||
public static class Foreground extends Render
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Foreground(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
public Foreground(AbstractContainerScreen<?> guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer, poseStack, mouseX, mouseY);
|
||||
super(guiContainer, guiGraphics, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,9 +123,9 @@ public abstract class ContainerScreenEvent extends Event
|
||||
public static class Background extends Render
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Background(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
public Background(AbstractContainerScreen<?> guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer, poseStack, mouseX, mouseY);
|
||||
super(guiContainer, guiGraphics, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -26,14 +26,14 @@ import java.util.ArrayList;
|
||||
public abstract class CustomizeGuiOverlayEvent extends Event
|
||||
{
|
||||
private final Window window;
|
||||
private final PoseStack poseStack;
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final float partialTick;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected CustomizeGuiOverlayEvent(Window window, PoseStack poseStack, float partialTick)
|
||||
protected CustomizeGuiOverlayEvent(Window window, GuiGraphics guiGraphics, float partialTick)
|
||||
{
|
||||
this.window = window;
|
||||
this.poseStack = poseStack;
|
||||
this.guiGraphics = guiGraphics;
|
||||
this.partialTick = partialTick;
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public abstract class CustomizeGuiOverlayEvent extends Event
|
||||
return window;
|
||||
}
|
||||
|
||||
public PoseStack getPoseStack()
|
||||
public GuiGraphics getGuiGraphics()
|
||||
{
|
||||
return poseStack;
|
||||
return guiGraphics;
|
||||
}
|
||||
|
||||
public float getPartialTick()
|
||||
@@ -70,9 +70,9 @@ public abstract class CustomizeGuiOverlayEvent extends Event
|
||||
private int increment;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BossEventProgress(Window window, PoseStack poseStack, float partialTick, LerpingBossEvent bossEvent, int x, int y, int increment)
|
||||
public BossEventProgress(Window window, GuiGraphics guiGraphics, float partialTick, LerpingBossEvent bossEvent, int x, int y, int increment)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
super(window, guiGraphics, partialTick);
|
||||
this.bossEvent = bossEvent;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -137,9 +137,9 @@ public abstract class CustomizeGuiOverlayEvent extends Event
|
||||
private final ArrayList<String> right;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public DebugText(Window window, PoseStack poseStack, float partialTick, ArrayList<String> left, ArrayList<String> right)
|
||||
public DebugText(Window window, GuiGraphics guiGraphics, float partialTick, ArrayList<String> left, ArrayList<String> right)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
super(window, guiGraphics, partialTick);
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
@@ -175,9 +175,9 @@ public abstract class CustomizeGuiOverlayEvent extends Event
|
||||
private int posY;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Chat(Window window, PoseStack poseStack, float partialTick, int posX, int posY)
|
||||
public Chat(Window window, GuiGraphics guiGraphics, float partialTick, int posX, int posY)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
super(window, guiGraphics, partialTick);
|
||||
this.setPosX(posX);
|
||||
this.setPosY(posY);
|
||||
}
|
||||
|
||||
@@ -55,25 +55,6 @@ public class RegisterParticleProvidersEvent extends Event implements IModBusEven
|
||||
particleEngine.register(type, provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Registers a ParticleProvider for a non-json-based ParticleType.
|
||||
* These particles do not receive a list of texture sprites to use for rendering themselves.</p>
|
||||
*
|
||||
* There must be <strong>no</strong> particle json with an ID matching the ParticleType,
|
||||
* or a redundant texture list error will occur when particle jsons load.</p>
|
||||
*
|
||||
* @param <T> ParticleOptions used by the ParticleType and ParticleProvider.
|
||||
* @param type ParticleType to register a ParticleProvider for.
|
||||
* @param provider ParticleProvider function responsible for providing that ParticleType's particles.
|
||||
* @see #registerSpecial
|
||||
* @deprecated Renamed to {@link #registerSpecial}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleProvider<T> provider)
|
||||
{
|
||||
registerSpecial(type, provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Registers a ParticleProvider for a json-based ParticleType with a single texture;
|
||||
* the resulting {@link TextureSheetParticle}s will use that texture when created.</p>
|
||||
@@ -91,25 +72,6 @@ public class RegisterParticleProvidersEvent extends Event implements IModBusEven
|
||||
particleEngine.register(type, sprite);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Registers a ParticleProvider for a json-based ParticleType with a single texture;
|
||||
* the resulting {@link TextureSheetParticle}s will use that texture when created.</p>
|
||||
*
|
||||
* <p>A particle json with an ID matching the ParticleType <strong>must exist</strong> in the <code>particles</code> asset folder,
|
||||
* or a missing texture list error will occur when particle jsons load.</p>
|
||||
*
|
||||
* @param <T> ParticleOptions used by the ParticleType and Sprite function.
|
||||
* @param type ParticleType to register a ParticleProvider for.
|
||||
* @param sprite Sprite function responsible for providing that ParticleType's particles.
|
||||
* @see #registerSprite
|
||||
* @deprecated Renamed to {@link #registerSprite}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleProvider.Sprite<T> sprite)
|
||||
{
|
||||
registerSprite(type, sprite);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Registers a ParticleProvider for a json-based ParticleType.
|
||||
* Particle jsons define a list of texture sprites which the particle can use to render itself.</p>
|
||||
@@ -127,22 +89,4 @@ public class RegisterParticleProvidersEvent extends Event implements IModBusEven
|
||||
particleEngine.register(type, registration);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Registers a ParticleProvider for a json-based ParticleType.
|
||||
* Particle jsons define a list of texture sprites which the particle can use to render itself.</p>
|
||||
*
|
||||
* <p>A particle json with an ID matching the ParticleType <strong>must exist</strong> in the <code>particles</code> asset folder,
|
||||
* or a missing texture list error will occur when particle jsons load.</p>
|
||||
*
|
||||
* @param <T> ParticleOptions used by the ParticleType and SpriteParticleRegistration function.
|
||||
* @param type ParticleType to register a particle provider for.
|
||||
* @param registration SpriteParticleRegistration function responsible for providing that ParticleType's particles.
|
||||
* @see #registerSpriteSet
|
||||
* @deprecated Renamed to {@link #registerSpriteSet}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleEngine.SpriteParticleRegistration<T> registration)
|
||||
{
|
||||
registerSpriteSet(type, registration);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -23,14 +23,14 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
public abstract class RenderGuiEvent extends Event
|
||||
{
|
||||
private final Window window;
|
||||
private final PoseStack poseStack;
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final float partialTick;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected RenderGuiEvent(Window window, PoseStack poseStack, float partialTick)
|
||||
protected RenderGuiEvent(Window window, GuiGraphics guiGraphics, float partialTick)
|
||||
{
|
||||
this.window = window;
|
||||
this.poseStack = poseStack;
|
||||
this.guiGraphics = guiGraphics;
|
||||
this.partialTick = partialTick;
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ public abstract class RenderGuiEvent extends Event
|
||||
return window;
|
||||
}
|
||||
|
||||
public PoseStack getPoseStack()
|
||||
public GuiGraphics getGuiGraphics()
|
||||
{
|
||||
return poseStack;
|
||||
return guiGraphics;
|
||||
}
|
||||
|
||||
public float getPartialTick()
|
||||
@@ -65,9 +65,9 @@ public abstract class RenderGuiEvent extends Event
|
||||
public static class Pre extends RenderGuiEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Pre(Window window, PoseStack poseStack, float partialTick)
|
||||
public Pre(Window window, GuiGraphics guiGraphics, float partialTick)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
super(window, guiGraphics, partialTick);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ public abstract class RenderGuiEvent extends Event
|
||||
public static class Post extends RenderGuiEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Post(Window window, PoseStack poseStack, float partialTick)
|
||||
public Post(Window window, GuiGraphics guiGraphics, float partialTick)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
super(window, guiGraphics, partialTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraftforge.client.gui.overlay.NamedGuiOverlay;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -26,17 +26,17 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
public abstract class RenderGuiOverlayEvent extends Event
|
||||
{
|
||||
private final Window window;
|
||||
private final PoseStack poseStack;
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final float partialTick;
|
||||
private final NamedGuiOverlay overlay;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected RenderGuiOverlayEvent(Window window, PoseStack poseStack, float partialTick, NamedGuiOverlay overlay)
|
||||
protected RenderGuiOverlayEvent(Window window, GuiGraphics guiGraphics, float partialTick, NamedGuiOverlay overlay)
|
||||
{
|
||||
this.overlay = overlay;
|
||||
this.window = window;
|
||||
this.poseStack = poseStack;
|
||||
this.guiGraphics = guiGraphics;
|
||||
this.partialTick = partialTick;
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
public Window getWindow()
|
||||
@@ -44,9 +44,9 @@ public abstract class RenderGuiOverlayEvent extends Event
|
||||
return window;
|
||||
}
|
||||
|
||||
public PoseStack getPoseStack()
|
||||
public GuiGraphics getGuiGraphics()
|
||||
{
|
||||
return poseStack;
|
||||
return guiGraphics;
|
||||
}
|
||||
|
||||
public float getPartialTick()
|
||||
@@ -75,9 +75,9 @@ public abstract class RenderGuiOverlayEvent extends Event
|
||||
public static class Pre extends RenderGuiOverlayEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Pre(Window window, PoseStack poseStack, float partialTick, NamedGuiOverlay overlay)
|
||||
public Pre(Window window, GuiGraphics guiGraphics, float partialTick, NamedGuiOverlay overlay)
|
||||
{
|
||||
super(window, poseStack, partialTick, overlay);
|
||||
super(window, guiGraphics, partialTick, overlay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ public abstract class RenderGuiOverlayEvent extends Event
|
||||
public static class Post extends RenderGuiOverlayEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Post(Window window, PoseStack poseStack, float partialTick, NamedGuiOverlay overlay)
|
||||
public Post(Window window, GuiGraphics guiGraphics, float partialTick, NamedGuiOverlay overlay)
|
||||
{
|
||||
super(window, poseStack, partialTick, overlay);
|
||||
super(window, guiGraphics, partialTick, overlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
/**
|
||||
* Fired after all level rendering.
|
||||
* This can be used for custom rendering outside of e.g. a block entity or entity renderer.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @deprecated Use {@link RenderLevelStageEvent} instead for more flexibility and improved compatibility with translucent objects.
|
||||
* There is no {@link RenderLevelStageEvent.Stage} that directly replaces this event, instead you must decide which Stage best fits your use case.
|
||||
* @see GameRenderer
|
||||
* @see LevelRenderer
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
public class RenderLevelLastEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final LevelRenderer levelRenderer;
|
||||
private final PoseStack poseStack;
|
||||
private final float partialTick;
|
||||
private final Matrix4f projectionMatrix;
|
||||
private final long startNanos;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RenderLevelLastEvent(LevelRenderer levelRenderer, PoseStack poseStack, float partialTick, Matrix4f projectionMatrix, long startNanos)
|
||||
{
|
||||
this.levelRenderer = levelRenderer;
|
||||
this.poseStack = poseStack;
|
||||
this.partialTick = partialTick;
|
||||
this.projectionMatrix = projectionMatrix;
|
||||
this.startNanos = startNanos;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the level renderer}
|
||||
*/
|
||||
public LevelRenderer getLevelRenderer()
|
||||
{
|
||||
return levelRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the projection matrix}
|
||||
*/
|
||||
public Matrix4f getProjectionMatrix()
|
||||
{
|
||||
return projectionMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the time when rendering started, in nanoseconds}
|
||||
*/
|
||||
public long getStartNanos()
|
||||
{
|
||||
return startNanos;
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,11 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -31,21 +32,21 @@ import java.util.List;
|
||||
* @see RenderTooltipEvent.Pre
|
||||
* @see RenderTooltipEvent.Color
|
||||
*/
|
||||
public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api.Event
|
||||
public abstract class RenderTooltipEvent extends Event
|
||||
{
|
||||
@NotNull
|
||||
protected final ItemStack itemStack;
|
||||
protected final PoseStack poseStack;
|
||||
protected final GuiGraphics graphics;
|
||||
protected int x;
|
||||
protected int y;
|
||||
protected Font font;
|
||||
protected final List<ClientTooltipComponent> components;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected RenderTooltipEvent(@NotNull ItemStack itemStack, PoseStack poseStack, int x, int y, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
protected RenderTooltipEvent(@NotNull ItemStack itemStack, GuiGraphics graphics, int x, int y, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
this.poseStack = poseStack;
|
||||
this.graphics = graphics;
|
||||
this.components = Collections.unmodifiableList(components);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -63,11 +64,11 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
* {@return the graphics helper for the gui}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
public GuiGraphics getGraphics()
|
||||
{
|
||||
return poseStack;
|
||||
return this.graphics;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,13 +212,15 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
{
|
||||
private final int screenWidth;
|
||||
private final int screenHeight;
|
||||
private final ClientTooltipPositioner positioner;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Pre(@NotNull ItemStack stack, PoseStack poseStack, int x, int y, int screenWidth, int screenHeight, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
public Pre(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, int screenWidth, int screenHeight, @NotNull Font font, @NotNull List<ClientTooltipComponent> components, @NotNull ClientTooltipPositioner positioner)
|
||||
{
|
||||
super(stack, poseStack, x, y, font, components);
|
||||
super(stack, graphics, x, y, font, components);
|
||||
this.screenWidth = screenWidth;
|
||||
this.screenHeight = screenHeight;
|
||||
this.positioner = positioner;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,6 +242,11 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
public ClientTooltipPositioner getTooltipPositioner()
|
||||
{
|
||||
return positioner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font to be used to render text.
|
||||
*
|
||||
@@ -290,9 +298,9 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private int borderEnd;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Color(@NotNull ItemStack stack, PoseStack poseStack, int x, int y, @NotNull Font fr, int background, int borderStart, int borderEnd, @NotNull List<ClientTooltipComponent> components)
|
||||
public Color(@NotNull ItemStack stack, GuiGraphics graphics, int x, int y, @NotNull Font fr, int background, int borderStart, int borderEnd, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
super(stack, poseStack, x, y, fr, components);
|
||||
super(stack, graphics, x, y, fr, components);
|
||||
this.originalBackground = background;
|
||||
this.originalBorderStart = borderStart;
|
||||
this.originalBorderEnd = borderEnd;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
|
||||
@@ -62,7 +62,7 @@ public abstract class ScreenEvent extends Event
|
||||
* See the two subclasses for listening before and after the initialization.
|
||||
*
|
||||
* <p>Listeners added through this event may also be marked as renderable or narratable, if they inherit from
|
||||
* {@link net.minecraft.client.gui.components.Widget} and {@link net.minecraft.client.gui.narration.NarratableEntry}
|
||||
* {@link net.minecraft.client.gui.components.Renderable} and {@link net.minecraft.client.gui.narration.NarratableEntry}
|
||||
* respectively.</p>
|
||||
*
|
||||
* @see Init.Pre
|
||||
@@ -159,27 +159,27 @@ public abstract class ScreenEvent extends Event
|
||||
*/
|
||||
public static abstract class Render extends ScreenEvent
|
||||
{
|
||||
private final PoseStack poseStack;
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
private final float partialTick;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected Render(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
protected Render(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
super(screen);
|
||||
this.poseStack = poseStack;
|
||||
this.guiGraphics = guiGraphics;
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
this.partialTick = partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
* {@return the gui graphics used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
public GuiGraphics getGuiGraphics()
|
||||
{
|
||||
return poseStack;
|
||||
return guiGraphics;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,9 +219,9 @@ public abstract class ScreenEvent extends Event
|
||||
public static class Pre extends Render
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public Pre(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
super(screen, poseStack, mouseX, mouseY, partialTick);
|
||||
super(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,9 +236,9 @@ public abstract class ScreenEvent extends Event
|
||||
public static class Post extends Render
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public Post(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
super(screen, poseStack, mouseX, mouseY, partialTick);
|
||||
super(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,21 +254,21 @@ public abstract class ScreenEvent extends Event
|
||||
*/
|
||||
public static class BackgroundRendered extends ScreenEvent
|
||||
{
|
||||
private final PoseStack poseStack;
|
||||
private final GuiGraphics guiGraphics;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BackgroundRendered(Screen screen, PoseStack poseStack)
|
||||
public BackgroundRendered(Screen screen, GuiGraphics guiGraphics)
|
||||
{
|
||||
super(screen);
|
||||
this.poseStack = poseStack;
|
||||
this.guiGraphics = guiGraphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
* {@return the gui graphics used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
public GuiGraphics getGuiGraphics()
|
||||
{
|
||||
return poseStack;
|
||||
return guiGraphics;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link GuiGraphics}.
|
||||
*/
|
||||
public interface IForgeGuiGraphics
|
||||
{
|
||||
private GuiGraphics self()
|
||||
{
|
||||
return (GuiGraphics) this;
|
||||
}
|
||||
|
||||
int DEFAULT_BACKGROUND_COLOR = 0xF0100010;
|
||||
int DEFAULT_BORDER_COLOR_START = 0x505000FF;
|
||||
int DEFAULT_BORDER_COLOR_END = (DEFAULT_BORDER_COLOR_START & 0xFEFEFE) >> 1 | DEFAULT_BORDER_COLOR_START & 0xFF000000;
|
||||
String UNDO_CHAR = "\u21B6";
|
||||
String RESET_CHAR = "\u2604";
|
||||
String VALID = "\u2714";
|
||||
String INVALID = "\u2715";
|
||||
int[] TEXT_COLOR_CODES = new int[] { 0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215,
|
||||
0, 42, 10752, 10794, 2752512, 2752554, 2763264, 2763306, 1381653, 1381695, 1392405, 1392447, 4134165, 4134207, 4144917, 4144959 };
|
||||
|
||||
default int getColorFromFormattingCharacter(char c, boolean isLighter)
|
||||
{
|
||||
return TEXT_COLOR_CODES[isLighter ? "0123456789abcdef".indexOf(c) : "0123456789abcdef".indexOf(c) + 16];
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a textured box of any size (smallest size is borderSize * 2 square)
|
||||
* based on a fixed size textured box with continuous borders and filler.
|
||||
*
|
||||
* @param texture the ResourceLocation object that contains the desired image
|
||||
* @param x x-axis offset
|
||||
* @param y y-axis offset
|
||||
* @param u bound resource location image x offset
|
||||
* @param v bound resource location image y offset
|
||||
* @param width the desired box width
|
||||
* @param height the desired box height
|
||||
* @param textureWidth the width of the box texture in the resource location image
|
||||
* @param textureHeight the height of the box texture in the resource location image
|
||||
* @param borderSize the size of the box's borders
|
||||
*/
|
||||
default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize)
|
||||
{
|
||||
this.blitWithBorder(texture, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a textured box of any size (smallest size is borderSize * 2 square)
|
||||
* based on a fixed size textured box with continuous borders and filler.
|
||||
*
|
||||
* @param texture the ResourceLocation object that contains the desired image
|
||||
* @param x x-axis offset
|
||||
* @param y y-axis offset
|
||||
* @param u bound resource location image x offset
|
||||
* @param v bound resource location image y offset
|
||||
* @param width the desired box width
|
||||
* @param height the desired box height
|
||||
* @param textureWidth the width of the box texture in the resource location image
|
||||
* @param textureHeight the height of the box texture in the resource location image
|
||||
* @param topBorder the size of the box's top border
|
||||
* @param bottomBorder the size of the box's bottom border
|
||||
* @param leftBorder the size of the box's left border
|
||||
* @param rightBorder the size of the box's right border
|
||||
*/
|
||||
default void blitWithBorder(ResourceLocation texture, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder)
|
||||
{
|
||||
int fillerWidth = textureWidth - leftBorder - rightBorder;
|
||||
int fillerHeight = textureHeight - topBorder - bottomBorder;
|
||||
int canvasWidth = width - leftBorder - rightBorder;
|
||||
int canvasHeight = height - topBorder - bottomBorder;
|
||||
int xPasses = canvasWidth / fillerWidth;
|
||||
int remainderWidth = canvasWidth % fillerWidth;
|
||||
int yPasses = canvasHeight / fillerHeight;
|
||||
int remainderHeight = canvasHeight % fillerHeight;
|
||||
|
||||
// Draw Border
|
||||
// Top Left
|
||||
self().blit(texture, x, y, u, v, leftBorder, topBorder);
|
||||
// Top Right
|
||||
self().blit(texture, x + leftBorder + canvasWidth, y, u + leftBorder + fillerWidth, v, rightBorder, topBorder);
|
||||
// Bottom Left
|
||||
self().blit(texture, x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder, bottomBorder);
|
||||
// Bottom Right
|
||||
self().blit(texture, x + leftBorder + canvasWidth, y + topBorder + canvasHeight, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder);
|
||||
|
||||
for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++)
|
||||
{
|
||||
// Top Border
|
||||
self().blit(texture, x + leftBorder + (i * fillerWidth), y, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder);
|
||||
// Bottom Border
|
||||
self().blit(texture, x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder);
|
||||
|
||||
// Throw in some filler for good measure
|
||||
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
|
||||
self().blit(texture, x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight));
|
||||
}
|
||||
|
||||
// Side Borders
|
||||
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
|
||||
{
|
||||
// Left Border
|
||||
self().blit(texture, x, y + topBorder + (j * fillerHeight), u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight));
|
||||
// Right Border
|
||||
self().blit(texture, x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight));
|
||||
}
|
||||
}
|
||||
|
||||
default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
|
||||
{
|
||||
this.blitInscribed(texture, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true);
|
||||
}
|
||||
|
||||
default void blitInscribed(ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
|
||||
{
|
||||
if (rectWidth * boundsHeight > rectHeight * boundsWidth)
|
||||
{
|
||||
int h = boundsHeight;
|
||||
boundsHeight = (int) (boundsWidth * ((double) rectHeight / rectWidth));
|
||||
if (centerY) y += (h - boundsHeight) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
int w = boundsWidth;
|
||||
boundsWidth = (int) (boundsHeight * ((double) rectWidth / rectHeight));
|
||||
if (centerX) x += (w - boundsWidth) / 2;
|
||||
}
|
||||
|
||||
self().blit(texture, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight);
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -7,6 +7,7 @@ package net.minecraftforge.client.extensions.common;
|
||||
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -15,7 +16,7 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.joml.Vector3d;
|
||||
@@ -89,7 +90,8 @@ public interface IClientBlockExtensions
|
||||
*/
|
||||
default Vector3d getFogColor(BlockState state, LevelReader level, BlockPos pos, Entity entity, Vector3d originalColor, float partialTick)
|
||||
{
|
||||
if (state.getMaterial() == Material.WATER)
|
||||
FluidState fluidState = level.getFluidState(pos);
|
||||
if (fluidState.is(FluidTags.WATER))
|
||||
{
|
||||
float f12 = 0.0F;
|
||||
|
||||
@@ -105,7 +107,7 @@ public interface IClientBlockExtensions
|
||||
}
|
||||
return new Vector3d(0.02F + f12, 0.02F + f12, 0.2F + f12);
|
||||
}
|
||||
else if (state.getMaterial() == Material.LAVA)
|
||||
else if (fluidState.is(FluidTags.LAVA))
|
||||
{
|
||||
return new Vector3d(0.6F, 0.1F, 0.0F);
|
||||
}
|
||||
|
||||
+23
-23
@@ -5,8 +5,8 @@
|
||||
|
||||
package net.minecraftforge.client.extensions.common;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
@@ -57,15 +57,15 @@ public interface IClientMobEffectExtensions
|
||||
* Renders the icon of the specified effect in the player's inventory.
|
||||
* This can be used to render icons from your own texture sheet.
|
||||
*
|
||||
* @param instance The effect instance
|
||||
* @param screen The effect-rendering screen
|
||||
* @param poseStack The pose stack
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param blitOffset The blit offset
|
||||
* @param instance The effect instance
|
||||
* @param screen The effect-rendering screen
|
||||
* @param guiGraphics 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 renderInventoryIcon(MobEffectInstance instance, EffectRenderingInventoryScreen<?> screen, PoseStack poseStack, int x, int y, int blitOffset)
|
||||
default boolean renderInventoryIcon(MobEffectInstance instance, EffectRenderingInventoryScreen<?> screen, GuiGraphics guiGraphics, int x, int y, int blitOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -73,15 +73,15 @@ public interface IClientMobEffectExtensions
|
||||
/**
|
||||
* Renders the text of the specified effect in the player's inventory.
|
||||
*
|
||||
* @param instance The effect instance
|
||||
* @param screen The effect-rendering screen
|
||||
* @param poseStack The pose stack
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param blitOffset The blit offset
|
||||
* @param instance The effect instance
|
||||
* @param screen The effect-rendering screen
|
||||
* @param guiGraphics 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 renderInventoryText(MobEffectInstance instance, EffectRenderingInventoryScreen<?> screen, PoseStack poseStack, int x, int y, int blitOffset)
|
||||
default boolean renderInventoryText(MobEffectInstance instance, EffectRenderingInventoryScreen<?> screen, GuiGraphics guiGraphics, int x, int y, int blitOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -90,16 +90,16 @@ public interface IClientMobEffectExtensions
|
||||
* Renders the icon of the specified effect on the player's HUD.
|
||||
* This can be used to render icons from your own texture sheet.
|
||||
*
|
||||
* @param instance The effect instance
|
||||
* @param gui The gui
|
||||
* @param poseStack The pose stack
|
||||
* @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
|
||||
* @param instance The effect instance
|
||||
* @param gui The gui
|
||||
* @param guiGraphics 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, PoseStack poseStack, int x, int y, float z, float alpha)
|
||||
default boolean renderGuiIcon(MobEffectInstance instance, Gui gui, GuiGraphics guiGraphics, int x, int y, float z, float alpha)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraftforge.common.CreativeModeTabRegistry;
|
||||
import net.minecraftforge.common.util.ConcatenatedListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,18 +17,18 @@ public final class CreativeTabsScreenPage
|
||||
private final List<CreativeModeTab> tabs;
|
||||
private final List<CreativeModeTab> topTabs;
|
||||
private final List<CreativeModeTab> bottomTabs;
|
||||
private final ConcatenatedListView<CreativeModeTab> visibleTabs;
|
||||
private final List<CreativeModeTab> visibleTabs;
|
||||
|
||||
public CreativeTabsScreenPage(List<CreativeModeTab> tabs)
|
||||
{
|
||||
this.tabs = tabs;
|
||||
this.topTabs = new ArrayList<>();
|
||||
this.bottomTabs = new ArrayList<>();
|
||||
this.visibleTabs = ConcatenatedListView.of(tabs, CreativeModeTabs.defaultTabs());
|
||||
this.visibleTabs = ConcatenatedListView.of(tabs, CreativeModeTabRegistry.getDefaultTabs());
|
||||
|
||||
int maxLength = 10;
|
||||
int topLength = maxLength / 2;
|
||||
int length = Math.min(10, tabs.size());
|
||||
int length = tabs.size();
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
@@ -45,15 +45,19 @@ public final class CreativeTabsScreenPage
|
||||
public boolean isTop(CreativeModeTab tab)
|
||||
{
|
||||
if (!this.tabs.contains(tab))
|
||||
return CreativeModeTabs.defaultTabs().indexOf(tab) < (CreativeModeTabs.defaultTabs().size() / 2);
|
||||
return CreativeModeTabRegistry.getDefaultTabs().indexOf(tab) < (CreativeModeTabRegistry.getDefaultTabs().size() / 2);
|
||||
|
||||
return this.topTabs.contains(tab);
|
||||
}
|
||||
|
||||
public int getColumn(CreativeModeTab tab)
|
||||
{
|
||||
// if (!this.tabs.contains(tab)) {
|
||||
// return CreativeModeTabs.tabs().indexOf(tab) % 6;
|
||||
// }
|
||||
// return this.topTabs.contains(tab) ? this.topTabs.indexOf(tab) : this.bottomTabs.indexOf(tab);
|
||||
if (!this.tabs.contains(tab))
|
||||
return (CreativeModeTabs.defaultTabs().indexOf(tab) % (CreativeModeTabs.defaultTabs().size() / 2)) + 5;
|
||||
return (CreativeModeTabRegistry.getDefaultTabs().indexOf(tab) % (CreativeModeTabRegistry.getDefaultTabs().size() / 2)) + 5;
|
||||
|
||||
return this.topTabs.contains(tab) ? this.topTabs.indexOf(tab) : this.bottomTabs.indexOf(tab);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.ErrorScreen;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
@@ -78,17 +78,17 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
this.renderBackground(poseStack);
|
||||
this.entryList.render(poseStack, mouseX, mouseY, partialTick);
|
||||
drawMultiLineCenteredString(poseStack, font, this.modLoadErrors.isEmpty() ? warningHeader : errorHeader, this.width / 2, 10);
|
||||
this.renderables.forEach(button -> button.render(poseStack, mouseX, mouseY, partialTick));
|
||||
this.renderBackground(guiGraphics);
|
||||
this.entryList.render(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));
|
||||
}
|
||||
|
||||
private void drawMultiLineCenteredString(PoseStack poseStack, Font fr, Component str, int x, int y) {
|
||||
private void drawMultiLineCenteredString(GuiGraphics guiGraphics, Font fr, Component str, int x, int y) {
|
||||
for (FormattedCharSequence s : fr.split(str, this.width)) {
|
||||
fr.drawShadow(poseStack, s, (float) (x - fr.width(s) / 2.0), y, 0xFFFFFF);
|
||||
guiGraphics.drawString(fr, s, (float) (x - fr.width(s) / 2.0), (float) y, 0xFFFFFF, true);
|
||||
y+=fr.lineHeight;
|
||||
}
|
||||
}
|
||||
@@ -142,16 +142,16 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTick) {
|
||||
public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTick) {
|
||||
Font font = Minecraft.getInstance().font;
|
||||
final List<FormattedCharSequence> strings = font.split(message, LoadingEntryList.this.width - 20);
|
||||
int y = top + 2;
|
||||
for (FormattedCharSequence string : strings)
|
||||
{
|
||||
if (center)
|
||||
font.draw(poseStack, string, left + (width) - font.width(string) / 2F, y, 0xFFFFFF);
|
||||
guiGraphics.drawString(font, string, left + (width) - font.width(string) / 2F, (float) y, 0xFFFFFF, false);
|
||||
else
|
||||
font.draw(poseStack, string, left + 5, y, 0xFFFFFF);
|
||||
guiGraphics.drawString(font, string, left + 5, y, 0xFFFFFF, false);
|
||||
y += font.lineHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,7 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.server.packs.resources.IoSupplier;
|
||||
import net.minecraftforge.client.ConfigScreenHandler;
|
||||
import net.minecraftforge.client.gui.widget.ModListWidget;
|
||||
@@ -34,6 +32,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
@@ -176,16 +175,14 @@ public class ModListScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawPanel(PoseStack poseStack, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY)
|
||||
protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY)
|
||||
{
|
||||
if (logoPath != null) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShaderTexture(0, logoPath);
|
||||
// Draw the logo image inscribed in a rectangle with width entryWidth (minus some padding) and height 50
|
||||
int headerHeight = 50;
|
||||
ScreenUtils.blitInscribed(poseStack, left + PADDING, relativeY, width - (PADDING * 2), headerHeight, logoDims.width, logoDims.height, false, true);
|
||||
guiGraphics.blitInscribed(logoPath, left + PADDING, relativeY, width - (PADDING * 2), headerHeight, logoDims.width, logoDims.height, false, true);
|
||||
relativeY += headerHeight + PADDING;
|
||||
}
|
||||
|
||||
@@ -194,7 +191,7 @@ public class ModListScreen extends Screen
|
||||
if (line != null)
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
ModListScreen.this.font.drawShadow(poseStack, line, left + PADDING, relativeY, 0xFFFFFF);
|
||||
guiGraphics.drawString(ModListScreen.this.font, line, left + PADDING, relativeY, 0xFFFFFF);
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
relativeY += font.lineHeight;
|
||||
@@ -202,7 +199,7 @@ public class ModListScreen extends Screen
|
||||
|
||||
final Style component = findTextLine(mouseX, mouseY);
|
||||
if (component!=null) {
|
||||
ModListScreen.this.renderComponentHoverEffect(poseStack, component, mouseX, mouseY);
|
||||
guiGraphics.renderComponentHoverEffect(ModListScreen.this.font, component, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,17 +359,17 @@ public class ModListScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
this.modList.render(poseStack, mouseX, mouseY, partialTick);
|
||||
this.modList.render(guiGraphics, mouseX, mouseY, partialTick);
|
||||
if (this.modInfo != null)
|
||||
this.modInfo.render(poseStack, mouseX, mouseY, partialTick);
|
||||
this.modInfo.render(guiGraphics, mouseX, mouseY, partialTick);
|
||||
|
||||
Component text = Component.translatable("fml.menu.mods.search");
|
||||
int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().width(text) / 2);
|
||||
this.search.render(poseStack, mouseX , mouseY, partialTick);
|
||||
super.render(poseStack, mouseX, mouseY, partialTick);
|
||||
getFontRenderer().draw(poseStack, text.getVisualOrderText(), x, search.getY() - getFontRenderer().lineHeight, 0xFFFFFF);
|
||||
this.search.render(guiGraphics, mouseX , mouseY, partialTick);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTick);
|
||||
guiGraphics.drawString(getFontRenderer(), text.getVisualOrderText(), x, search.getY() - getFontRenderer().lineHeight, 0xFFFFFF, false);
|
||||
}
|
||||
|
||||
public Minecraft getMinecraftInstance()
|
||||
|
||||
@@ -17,12 +17,12 @@ import java.util.stream.Collectors;
|
||||
import net.minecraftforge.client.gui.widget.ScrollPanel;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.MultiLineLabel;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
@@ -102,13 +102,13 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(stack);
|
||||
this.renderBackground(guiGraphics);
|
||||
int textYOffset = modMismatchData.containsMismatches() ? 18 : 0;
|
||||
drawCenteredString(stack, this.font, this.title, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset - 9 * 2, 0xAAAAAA);
|
||||
this.message.renderCentered(stack, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset - 9 * 2, 0xAAAAAA);
|
||||
this.message.renderCentered(guiGraphics, this.width / 2, (this.height - this.listHeight - this.textHeight) / 2 - textYOffset);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
class MismatchInfoPanel extends ScrollPanel
|
||||
@@ -217,7 +217,7 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawPanel(PoseStack stack, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY)
|
||||
protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -228,11 +228,11 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
int color = Optional.ofNullable(font.getSplitter().componentStyleAtWidth(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);
|
||||
font.draw(stack, name, nameLeft, relativeY + i * 12, color);
|
||||
guiGraphics.drawString(font, name, nameLeft, relativeY + i * 12, color, false);
|
||||
if (versions != null)
|
||||
{
|
||||
font.draw(stack, versions.getLeft(), left + border + nameIndent + nameWidth, relativeY + i * 12, color);
|
||||
font.draw(stack, versions.getRight(), left + border + nameIndent + nameWidth + versionWidth, relativeY + i * 12, color);
|
||||
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);
|
||||
}
|
||||
|
||||
i++;
|
||||
@@ -240,13 +240,13 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
Style style = getComponentStyleAt(mouseX, mouseY);
|
||||
if (style != null && style.getHoverEvent() != null)
|
||||
{
|
||||
ModMismatchDisconnectedScreen.this.renderComponentHoverEffect(stack, style, mouseX, mouseY);
|
||||
guiGraphics.renderComponentHoverEffect(font, style, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
@@ -21,7 +20,9 @@ import org.joml.Matrix4f;
|
||||
* This class provides several methods and constants used by the Config GUI classes.
|
||||
*
|
||||
* @author bspkrs
|
||||
* @deprecated Use extension methods in {@link net.minecraftforge.client.extensions.IForgeGuiGraphics} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class ScreenUtils
|
||||
{
|
||||
public static final int DEFAULT_BACKGROUND_COLOR = 0xF0100010;
|
||||
@@ -33,7 +34,7 @@ public class ScreenUtils
|
||||
public static final String INVALID = "\u2715";
|
||||
|
||||
public static int[] TEXT_COLOR_CODES = new int[] { 0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215,
|
||||
0, 42, 10752, 10794, 2752512, 2752554, 2763264, 2763306, 1381653, 1381695, 1392405, 1392447, 4134165, 4134207, 4144917, 4144959 };
|
||||
0, 42, 10752, 10794, 2752512, 2752554, 2763264, 2763306, 1381653, 1381695, 1392405, 1392447, 4134165, 4134207, 4144917, 4144959 };
|
||||
|
||||
public static int getColorFromFormattingCharacter(char c, boolean isLighter)
|
||||
{
|
||||
@@ -45,7 +46,7 @@ public class ScreenUtils
|
||||
* and filler. It is assumed that the desired texture ResourceLocation object has been bound using
|
||||
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
|
||||
*
|
||||
* @param poseStack the gui pose stack
|
||||
* @param guiGraphics the gui graphics
|
||||
* @param x x axis offset
|
||||
* @param y y axis offset
|
||||
* @param u bound resource location image x offset
|
||||
@@ -57,10 +58,10 @@ public class ScreenUtils
|
||||
* @param borderSize the size of the box's borders
|
||||
* @param zLevel the zLevel to draw at
|
||||
*/
|
||||
public static void blitWithBorder(PoseStack poseStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
public static void blitWithBorder(GuiGraphics guiGraphics, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int borderSize, float zLevel)
|
||||
{
|
||||
blitWithBorder(poseStack, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
blitWithBorder(guiGraphics, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +69,7 @@ public class ScreenUtils
|
||||
* and filler. The provided ResourceLocation object will be bound using
|
||||
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
|
||||
*
|
||||
* @param poseStack the gui pose stack
|
||||
* @param guiGraphics the gui graphics
|
||||
* @param res the ResourceLocation object that contains the desired image
|
||||
* @param x x axis offset
|
||||
* @param y y axis offset
|
||||
@@ -81,10 +82,10 @@ public class ScreenUtils
|
||||
* @param borderSize the size of the box's borders
|
||||
* @param zLevel the zLevel to draw at
|
||||
*/
|
||||
public static void blitWithBorder(PoseStack poseStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
public static void blitWithBorder(GuiGraphics guiGraphics, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int borderSize, float zLevel)
|
||||
{
|
||||
blitWithBorder(poseStack, res, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
blitWithBorder(guiGraphics, res, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +93,7 @@ public class ScreenUtils
|
||||
* and filler. The provided ResourceLocation object will be bound using
|
||||
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
|
||||
*
|
||||
* @param poseStack the gui pose stack
|
||||
* @param guiGraphics the gui graphics
|
||||
* @param res the ResourceLocation object that contains the desired image
|
||||
* @param x x axis offset
|
||||
* @param y y axis offset
|
||||
@@ -108,12 +109,12 @@ public class ScreenUtils
|
||||
* @param rightBorder the size of the box's right border
|
||||
* @param zLevel the zLevel to draw at
|
||||
*/
|
||||
public static void blitWithBorder(PoseStack poseStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
public static void blitWithBorder(GuiGraphics guiGraphics, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
|
||||
{
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, res);
|
||||
blitWithBorder(poseStack, x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel);
|
||||
blitWithBorder(guiGraphics, x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +122,7 @@ public class ScreenUtils
|
||||
* and filler. It is assumed that the desired texture ResourceLocation object has been bound using
|
||||
* Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).
|
||||
*
|
||||
* @param poseStack the gui pose stack
|
||||
* @param guiGraphics the gui graphics
|
||||
* @param x x axis offset
|
||||
* @param y y axis offset
|
||||
* @param u bound resource location image x offset
|
||||
@@ -136,7 +137,7 @@ public class ScreenUtils
|
||||
* @param rightBorder the size of the box's right border
|
||||
* @param zLevel the zLevel to draw at
|
||||
*/
|
||||
public static void blitWithBorder(PoseStack poseStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
public static void blitWithBorder(GuiGraphics guiGraphics, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
|
||||
{
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
@@ -154,37 +155,41 @@ public class ScreenUtils
|
||||
|
||||
// Draw Border
|
||||
// Top Left
|
||||
drawTexturedModalRect(poseStack, x, y, u, v, leftBorder, topBorder, zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x, y, u, v, leftBorder, topBorder, zLevel);
|
||||
// Top Right
|
||||
drawTexturedModalRect(poseStack, x + leftBorder + canvasWidth, y, u + leftBorder + fillerWidth, v, rightBorder, topBorder, zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x + leftBorder + canvasWidth, y, u + leftBorder + fillerWidth, v, rightBorder, topBorder, zLevel);
|
||||
// Bottom Left
|
||||
drawTexturedModalRect(poseStack, x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder, bottomBorder, zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x, y + topBorder + canvasHeight, u, v + topBorder + fillerHeight, leftBorder, bottomBorder, zLevel);
|
||||
// Bottom Right
|
||||
drawTexturedModalRect(poseStack, x + leftBorder + canvasWidth, y + topBorder + canvasHeight, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x + leftBorder + canvasWidth, y + topBorder + canvasHeight, u + leftBorder + fillerWidth, v + topBorder + fillerHeight, rightBorder, bottomBorder, zLevel);
|
||||
|
||||
for (int i = 0; i < xPasses + (remainderWidth > 0 ? 1 : 0); i++)
|
||||
{
|
||||
// Top Border
|
||||
drawTexturedModalRect(poseStack, x + leftBorder + (i * fillerWidth), y, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder, zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x + leftBorder + (i * fillerWidth), y, u + leftBorder, v, (i == xPasses ? remainderWidth : fillerWidth), topBorder, zLevel);
|
||||
// Bottom Border
|
||||
drawTexturedModalRect(poseStack, x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder, zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x + leftBorder + (i * fillerWidth), y + topBorder + canvasHeight, u + leftBorder, v + topBorder + fillerHeight, (i == xPasses ? remainderWidth : fillerWidth), bottomBorder, zLevel);
|
||||
|
||||
// Throw in some filler for good measure
|
||||
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
|
||||
drawTexturedModalRect(poseStack, x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight), zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x + leftBorder + (i * fillerWidth), y + topBorder + (j * fillerHeight), u + leftBorder, v + topBorder, (i == xPasses ? remainderWidth : fillerWidth), (j == yPasses ? remainderHeight : fillerHeight), zLevel);
|
||||
}
|
||||
|
||||
// Side Borders
|
||||
for (int j = 0; j < yPasses + (remainderHeight > 0 ? 1 : 0); j++)
|
||||
{
|
||||
// Left Border
|
||||
drawTexturedModalRect(poseStack, x, y + topBorder + (j * fillerHeight), u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x, y + topBorder + (j * fillerHeight), u, v + topBorder, leftBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel);
|
||||
// Right Border
|
||||
drawTexturedModalRect(poseStack, x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel);
|
||||
drawTexturedModalRect(guiGraphics, x + leftBorder + canvasWidth, y + topBorder + (j * fillerHeight), u + leftBorder + fillerWidth, v + topBorder, rightBorder, (j == yPasses ? remainderHeight : fillerHeight), zLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawTexturedModalRect(PoseStack poseStack, int x, int y, int u, int v, int width, int height, float zLevel)
|
||||
/**
|
||||
* @deprecated Use {@link GuiGraphics#blit(ResourceLocation, int, int, int, int, int, int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void drawTexturedModalRect(GuiGraphics guiGraphics, int x, int y, int u, int v, int width, int height, float zLevel)
|
||||
{
|
||||
final float uScale = 1f / 0x100;
|
||||
final float vScale = 1f / 0x100;
|
||||
@@ -192,7 +197,7 @@ public class ScreenUtils
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder wr = tessellator.getBuilder();
|
||||
wr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
|
||||
Matrix4f matrix = poseStack.last().pose();
|
||||
Matrix4f matrix = guiGraphics.pose().last().pose();
|
||||
wr.vertex(matrix, x , y + height, zLevel).uv( u * uScale, ((v + height) * vScale)).endVertex();
|
||||
wr.vertex(matrix, x + width, y + height, zLevel).uv((u + width) * uScale, ((v + height) * vScale)).endVertex();
|
||||
wr.vertex(matrix, x + width, y , zLevel).uv((u + width) * uScale, ( v * vScale)).endVertex();
|
||||
@@ -200,6 +205,10 @@ public class ScreenUtils
|
||||
tessellator.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link GuiGraphics#fillGradient(int, int, int, int, int, int, int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
|
||||
{
|
||||
float startAlpha = (float)(startColor >> 24 & 255) / 255.0F;
|
||||
@@ -228,12 +237,12 @@ public class ScreenUtils
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
public static void blitInscribed(PoseStack poseStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
|
||||
public static void blitInscribed(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
|
||||
{
|
||||
blitInscribed(poseStack, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true);
|
||||
blitInscribed(guiGraphics, texture, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true);
|
||||
}
|
||||
|
||||
public static void blitInscribed(PoseStack poseStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
|
||||
public static void blitInscribed(GuiGraphics guiGraphics, ResourceLocation texture, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
|
||||
{
|
||||
if (rectWidth * boundsHeight > rectHeight * boundsWidth) {
|
||||
int h = boundsHeight;
|
||||
@@ -245,6 +254,6 @@ public class ScreenUtils
|
||||
if (centerX) x += (w - boundsWidth) / 2;
|
||||
}
|
||||
|
||||
GuiComponent.blit(poseStack, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight);
|
||||
guiGraphics.blit(texture, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight);
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,7 @@
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@@ -50,21 +48,19 @@ public class TitleScreenModUpdateIndicator extends Screen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
if (showNotification == null || !showNotification.shouldDraw() || !FMLConfig.runVersionCheck())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RenderSystem.setShaderTexture(0, VERSION_CHECK_ICONS);
|
||||
|
||||
int x = modButton.getX();
|
||||
int y = modButton.getY();
|
||||
int w = modButton.getWidth();
|
||||
int h = modButton.getHeight();
|
||||
|
||||
blit(poseStack, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
|
||||
guiGraphics.blit(VERSION_CHECK_ICONS, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
|
||||
}
|
||||
|
||||
public static TitleScreenModUpdateIndicator init(TitleScreen guiMainMenu, Button modButton)
|
||||
|
||||
@@ -7,17 +7,15 @@ package net.minecraftforge.client.gui.overlay;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
@@ -40,7 +38,6 @@ import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -77,12 +74,7 @@ public class ForgeGui extends Gui
|
||||
return minecraft;
|
||||
}
|
||||
|
||||
public void setupOverlayRenderState(boolean blend, boolean depthText)
|
||||
{
|
||||
setupOverlayRenderState(blend, depthText, Gui.GUI_ICONS_LOCATION);
|
||||
}
|
||||
|
||||
public void setupOverlayRenderState(boolean blend, boolean depthTest, @Nullable ResourceLocation texture)
|
||||
public void setupOverlayRenderState(boolean blend, boolean depthTest)
|
||||
{
|
||||
if (blend)
|
||||
{
|
||||
@@ -103,17 +95,12 @@ public class ForgeGui extends Gui
|
||||
RenderSystem.disableDepthTest();
|
||||
}
|
||||
|
||||
if (texture != null)
|
||||
{
|
||||
bind(texture);
|
||||
}
|
||||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, float partialTick)
|
||||
public void render(GuiGraphics guiGraphics, float partialTick)
|
||||
{
|
||||
this.screenWidth = this.minecraft.getWindow().getGuiScaledWidth();
|
||||
this.screenHeight = this.minecraft.getWindow().getGuiScaledHeight();
|
||||
@@ -121,7 +108,7 @@ public class ForgeGui extends Gui
|
||||
rightHeight = 39;
|
||||
leftHeight = 39;
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Pre(minecraft.getWindow(), poseStack, partialTick)))
|
||||
if (MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Pre(minecraft.getWindow(), guiGraphics, partialTick)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -134,9 +121,9 @@ public class ForgeGui extends Gui
|
||||
try
|
||||
{
|
||||
IGuiOverlay overlay = entry.overlay();
|
||||
if (pre(entry, poseStack)) return;
|
||||
overlay.render(this, poseStack, partialTick, screenWidth, screenHeight);
|
||||
post(entry, poseStack);
|
||||
if (pre(entry, guiGraphics)) return;
|
||||
overlay.render(this, guiGraphics, partialTick, screenWidth, screenHeight);
|
||||
post(entry, guiGraphics);
|
||||
} catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Error rendering overlay '{}'", entry.id(), e);
|
||||
@@ -145,7 +132,7 @@ public class ForgeGui extends Gui
|
||||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Post(minecraft.getWindow(), poseStack, partialTick));
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Post(minecraft.getWindow(), guiGraphics, partialTick));
|
||||
}
|
||||
|
||||
public boolean shouldDrawSurvivalElements()
|
||||
@@ -153,21 +140,20 @@ public class ForgeGui extends Gui
|
||||
return minecraft.gameMode.canHurtPlayer() && minecraft.getCameraEntity() instanceof Player;
|
||||
}
|
||||
|
||||
protected void renderSubtitles(PoseStack poseStack)
|
||||
protected void renderSubtitles(GuiGraphics guiGraphics)
|
||||
{
|
||||
this.subtitleOverlay.render(poseStack);
|
||||
this.subtitleOverlay.render(guiGraphics);
|
||||
}
|
||||
|
||||
protected void renderBossHealth(PoseStack poseStack)
|
||||
protected void renderBossHealth(GuiGraphics guiGraphics)
|
||||
{
|
||||
bind(GuiComponent.GUI_ICONS_LOCATION);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
minecraft.getProfiler().push("bossHealth");
|
||||
this.bossOverlay.render(poseStack);
|
||||
this.bossOverlay.render(guiGraphics);
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
void renderSpyglassOverlay(PoseStack stack)
|
||||
void renderSpyglassOverlay(GuiGraphics guiGraphics)
|
||||
{
|
||||
float deltaFrame = this.minecraft.getDeltaFrameTime();
|
||||
this.scopeScale = Mth.lerp(0.5F * deltaFrame, this.scopeScale, 1.125F);
|
||||
@@ -175,7 +161,7 @@ public class ForgeGui extends Gui
|
||||
{
|
||||
if (this.minecraft.player.isScoping())
|
||||
{
|
||||
this.renderSpyglassOverlay(stack, this.scopeScale);
|
||||
this.renderSpyglassOverlay(guiGraphics, this.scopeScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -184,7 +170,7 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
}
|
||||
|
||||
void renderHelmet(float partialTick, PoseStack poseStack)
|
||||
void renderHelmet(float partialTick, GuiGraphics guiGraphics)
|
||||
{
|
||||
ItemStack itemstack = this.minecraft.player.getInventory().getArmor(3);
|
||||
|
||||
@@ -193,7 +179,7 @@ public class ForgeGui extends Gui
|
||||
Item item = itemstack.getItem();
|
||||
if (item == Blocks.CARVED_PUMPKIN.asItem())
|
||||
{
|
||||
renderTextureOverlay(poseStack, PUMPKIN_BLUR_LOCATION, 1.0F);
|
||||
renderTextureOverlay(guiGraphics, PUMPKIN_BLUR_LOCATION, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -202,15 +188,15 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
}
|
||||
|
||||
void renderFrostbite(PoseStack pStack)
|
||||
void renderFrostbite(GuiGraphics guiGraphics)
|
||||
{
|
||||
if (this.minecraft.player.getTicksFrozen() > 0)
|
||||
{
|
||||
this.renderTextureOverlay(pStack, POWDER_SNOW_OUTLINE_LOCATION, this.minecraft.player.getPercentFrozen());
|
||||
this.renderTextureOverlay(guiGraphics, POWDER_SNOW_OUTLINE_LOCATION, this.minecraft.player.getPercentFrozen());
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderArmor(PoseStack poseStack, int width, int height)
|
||||
protected void renderArmor(GuiGraphics guiGraphics, int width, int height)
|
||||
{
|
||||
minecraft.getProfiler().push("armor");
|
||||
|
||||
@@ -223,15 +209,15 @@ public class ForgeGui extends Gui
|
||||
{
|
||||
if (i < level)
|
||||
{
|
||||
blit(poseStack, left, top, 34, 9, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 34, 9, 9, 9);
|
||||
}
|
||||
else if (i == level)
|
||||
{
|
||||
blit(poseStack, left, top, 25, 9, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 25, 9, 9, 9);
|
||||
}
|
||||
else if (i > level)
|
||||
{
|
||||
blit(poseStack, left, top, 16, 9, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 16, 9, 9, 9);
|
||||
}
|
||||
left += 8;
|
||||
}
|
||||
@@ -242,17 +228,15 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderPortalOverlay(PoseStack stack, float partialTick)
|
||||
protected void renderPortalOverlay(GuiGraphics guiGraphics, float alpha)
|
||||
{
|
||||
float f1 = Mth.lerp(partialTick, this.minecraft.player.oPortalTime, this.minecraft.player.portalTime);
|
||||
|
||||
if (f1 > 0.0F)
|
||||
if (alpha > 0.0F)
|
||||
{
|
||||
super.renderPortalOverlay(stack, f1);
|
||||
super.renderPortalOverlay(guiGraphics, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderAir(int width, int height, PoseStack poseStack)
|
||||
protected void renderAir(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
minecraft.getProfiler().push("air");
|
||||
Player player = (Player) this.minecraft.getCameraEntity();
|
||||
@@ -268,7 +252,7 @@ public class ForgeGui extends Gui
|
||||
|
||||
for (int i = 0; i < full + partial; ++i)
|
||||
{
|
||||
blit(poseStack, left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
|
||||
}
|
||||
rightHeight += 10;
|
||||
}
|
||||
@@ -277,9 +261,8 @@ public class ForgeGui extends Gui
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
public void renderHealth(int width, int height, PoseStack pStack)
|
||||
public void renderHealth(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
bind(GUI_ICONS_LOCATION);
|
||||
minecraft.getProfiler().push("health");
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
@@ -328,13 +311,13 @@ public class ForgeGui extends Gui
|
||||
regen = this.tickCount % Mth.ceil(healthMax + 5.0F);
|
||||
}
|
||||
|
||||
this.renderHearts(pStack, player, left, top, rowHeight, regen, healthMax, health, healthLast, absorb, highlight);
|
||||
this.renderHearts(guiGraphics, player, left, top, rowHeight, regen, healthMax, health, healthLast, absorb, highlight);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
public void renderFood(int width, int height, PoseStack poseStack)
|
||||
public void renderFood(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
minecraft.getProfiler().push("food");
|
||||
|
||||
@@ -368,24 +351,22 @@ public class ForgeGui extends Gui
|
||||
y = top + (random.nextInt(3) - 1);
|
||||
}
|
||||
|
||||
blit(poseStack, x, y, 16 + background * 9, 27, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, y, 16 + background * 9, 27, 9, 9);
|
||||
|
||||
if (idx < level)
|
||||
blit(poseStack, x, y, icon + 36, 27, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, y, icon + 36, 27, 9, 9);
|
||||
else if (idx == level)
|
||||
blit(poseStack, x, y, icon + 45, 27, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, y, icon + 45, 27, 9, 9);
|
||||
}
|
||||
RenderSystem.disableBlend();
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
protected void renderSleepFade(int width, int height, PoseStack poseStack)
|
||||
protected void renderSleepFade(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
if (minecraft.player.getSleepTimer() > 0)
|
||||
{
|
||||
minecraft.getProfiler().push("sleep");
|
||||
RenderSystem.disableDepthTest();
|
||||
// RenderSystem.disableAlphaTest();
|
||||
int sleepTime = minecraft.player.getSleepTimer();
|
||||
float opacity = (float) sleepTime / 100.0F;
|
||||
|
||||
@@ -395,42 +376,38 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
|
||||
int color = (int) (220.0F * opacity) << 24 | 1052704;
|
||||
fill(poseStack, 0, 0, width, height, color);
|
||||
// RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableDepthTest();
|
||||
guiGraphics.fill(0, 0, width, height, color);
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderExperience(int x, PoseStack poseStack)
|
||||
protected void renderExperience(int x, GuiGraphics guiGraphics)
|
||||
{
|
||||
bind(GUI_ICONS_LOCATION);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableBlend();
|
||||
|
||||
if (minecraft.gameMode.hasExperience())
|
||||
{
|
||||
super.renderExperienceBar(poseStack, x);
|
||||
super.renderExperienceBar(guiGraphics, x);
|
||||
}
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, PoseStack poseStack, int x)
|
||||
public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, GuiGraphics guiGraphics, int x)
|
||||
{
|
||||
bind(GUI_ICONS_LOCATION);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableBlend();
|
||||
|
||||
super.renderJumpMeter(playerRideableJumping, poseStack, x);
|
||||
super.renderJumpMeter(playerRideableJumping, guiGraphics, x);
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
minecraft.getProfiler().pop();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
protected void renderHUDText(int width, int height, PoseStack poseStack)
|
||||
protected void renderHUDText(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
minecraft.getProfiler().push("forgeHudText");
|
||||
RenderSystem.defaultBlendFunc();
|
||||
@@ -458,7 +435,7 @@ public class ForgeGui extends Gui
|
||||
listR.addAll(debugOverlay.getRight());
|
||||
}
|
||||
|
||||
var event = new CustomizeGuiOverlayEvent.DebugText(minecraft.getWindow(), poseStack, minecraft.getFrameTime(), listL, listR);
|
||||
var event = new CustomizeGuiOverlayEvent.DebugText(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), listL, listR);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
int top = 2;
|
||||
@@ -466,8 +443,8 @@ public class ForgeGui extends Gui
|
||||
{
|
||||
if (msg != null && !msg.isEmpty())
|
||||
{
|
||||
fill(poseStack, 1, top - 1, 2 + font.width(msg) + 1, top + font.lineHeight - 1, -1873784752);
|
||||
font.draw(poseStack, msg, 2, top, 14737632);
|
||||
guiGraphics.fill(1, top - 1, 2 + font.width(msg) + 1, top + font.lineHeight - 1, -1873784752);
|
||||
guiGraphics.drawString(font, msg, 2, top, 14737632, false);
|
||||
}
|
||||
top += font.lineHeight;
|
||||
}
|
||||
@@ -479,8 +456,8 @@ public class ForgeGui extends Gui
|
||||
{
|
||||
int w = font.width(msg);
|
||||
int left = width - 2 - w;
|
||||
fill(poseStack, left - 1, top - 1, left + w + 1, top + font.lineHeight - 1, -1873784752);
|
||||
font.draw(poseStack, msg, left, top, 14737632);
|
||||
guiGraphics.fill(left - 1, top - 1, left + w + 1, top + font.lineHeight - 1, -1873784752);
|
||||
guiGraphics.drawString(font, msg, left, top, 14737632, false);
|
||||
}
|
||||
top += font.lineHeight;
|
||||
}
|
||||
@@ -488,15 +465,15 @@ public class ForgeGui extends Gui
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
protected void renderFPSGraph(PoseStack poseStack)
|
||||
protected void renderFPSGraph(GuiGraphics guiGraphics)
|
||||
{
|
||||
if (this.minecraft.options.renderDebug && this.minecraft.options.renderFpsChart)
|
||||
{
|
||||
this.debugOverlay.render(poseStack);
|
||||
this.debugOverlay.render(guiGraphics);
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderRecordOverlay(int width, int height, float partialTick, PoseStack pStack)
|
||||
protected void renderRecordOverlay(int width, int height, float partialTick, GuiGraphics guiGraphics)
|
||||
{
|
||||
if (overlayMessageTime > 0)
|
||||
{
|
||||
@@ -507,22 +484,23 @@ public class ForgeGui extends Gui
|
||||
|
||||
if (opacity > 8)
|
||||
{
|
||||
pStack.pushPose();
|
||||
pStack.translate(width / 2D, height - 68, 0.0D);
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().translate(width / 2D, height - 68, 0.0D);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
int color = (animateOverlayMessageColor ? Mth.hsvToRgb(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE);
|
||||
drawBackdrop(pStack, font, -4, font.width(overlayMessageString), 16777215 | (opacity << 24));
|
||||
font.drawShadow(pStack, overlayMessageString.getVisualOrderText(), -font.width(overlayMessageString) / 2, -4, color | (opacity << 24));
|
||||
int messageWidth = font.width(overlayMessageString);
|
||||
drawBackdrop(guiGraphics, font, -4, messageWidth, 16777215 | (opacity << 24));
|
||||
guiGraphics.drawString(font, overlayMessageString.getVisualOrderText(), -messageWidth / 2, -4, color | (opacity << 24));
|
||||
RenderSystem.disableBlend();
|
||||
pStack.popPose();
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderTitle(int width, int height, float partialTick, PoseStack pStack)
|
||||
protected void renderTitle(int width, int height, float partialTick, GuiGraphics guiGraphics)
|
||||
{
|
||||
if (title != null && titleTime > 0)
|
||||
{
|
||||
@@ -541,50 +519,50 @@ public class ForgeGui extends Gui
|
||||
|
||||
if (opacity > 8)
|
||||
{
|
||||
pStack.pushPose();
|
||||
pStack.translate(width / 2D, height / 2D, 0.0D);
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().translate(width / 2D, height / 2D, 0.0D);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
pStack.pushPose();
|
||||
pStack.scale(4.0F, 4.0F, 4.0F);
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().scale(4.0F, 4.0F, 4.0F);
|
||||
int l = opacity << 24 & -16777216;
|
||||
this.getFont().drawShadow(pStack, this.title.getVisualOrderText(), (float) (-this.getFont().width(this.title) / 2), -10.0F, 16777215 | l);
|
||||
pStack.popPose();
|
||||
guiGraphics.drawString(this.font, this.title.getVisualOrderText(), -this.getFont().width(this.title) / 2, -10, 16777215 | l, true);
|
||||
guiGraphics.pose().popPose();
|
||||
if (this.subtitle != null)
|
||||
{
|
||||
pStack.pushPose();
|
||||
pStack.scale(2.0F, 2.0F, 2.0F);
|
||||
this.getFont().drawShadow(pStack, this.subtitle.getVisualOrderText(), (float) (-this.getFont().width(this.subtitle) / 2), 5.0F, 16777215 | l);
|
||||
pStack.popPose();
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().scale(2.0F, 2.0F, 2.0F);
|
||||
guiGraphics.drawString(this.font, this.subtitle.getVisualOrderText(), -this.getFont().width(this.subtitle) / 2, 5, 16777215 | l, true);
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
RenderSystem.disableBlend();
|
||||
pStack.popPose();
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
|
||||
this.minecraft.getProfiler().pop();
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderChat(int width, int height, PoseStack pStack)
|
||||
protected void renderChat(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
minecraft.getProfiler().push("chat");
|
||||
|
||||
Window window = minecraft.getWindow();
|
||||
var event = new CustomizeGuiOverlayEvent.Chat(window, pStack, minecraft.getFrameTime(), 0, height - 40);
|
||||
var event = new CustomizeGuiOverlayEvent.Chat(window, guiGraphics, minecraft.getFrameTime(), 0, height - 40);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
pStack.pushPose();
|
||||
guiGraphics.pose().pushPose();
|
||||
// We give the absolute Y position of the chat component in the event and account for the chat component's own offsetting here.
|
||||
pStack.translate(event.getPosX(), (event.getPosY() - height + 40) / chat.getScale(), 0.0D);
|
||||
guiGraphics.pose().translate(event.getPosX(), (event.getPosY() - height + 40) / chat.getScale(), 0.0D);
|
||||
int mouseX = Mth.floor(minecraft.mouseHandler.xpos() * window.getGuiScaledWidth() / window.getScreenWidth());
|
||||
int mouseY = Mth.floor(minecraft.mouseHandler.ypos() * window.getGuiScaledHeight() / window.getScreenHeight());
|
||||
chat.render(pStack, tickCount, mouseX, mouseY);
|
||||
pStack.popPose();
|
||||
chat.render(guiGraphics, tickCount, mouseX, mouseY);
|
||||
guiGraphics.pose().popPose();
|
||||
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
protected void renderPlayerList(int width, int height, PoseStack poseStack)
|
||||
protected void renderPlayerList(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
Objective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(0);
|
||||
ClientPacketListener handler = minecraft.player.connection;
|
||||
@@ -592,7 +570,7 @@ public class ForgeGui extends Gui
|
||||
if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null))
|
||||
{
|
||||
this.tabList.setVisible(true);
|
||||
this.tabList.render(poseStack, width, this.minecraft.level.getScoreboard(), scoreobjective);
|
||||
this.tabList.render(guiGraphics, width, this.minecraft.level.getScoreboard(), scoreobjective);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -601,14 +579,12 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderHealthMount(int width, int height, PoseStack poseStack)
|
||||
protected void renderHealthMount(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
Player player = (Player) minecraft.getCameraEntity();
|
||||
Entity tmp = player.getVehicle();
|
||||
if (!(tmp instanceof LivingEntity)) return;
|
||||
|
||||
bind(GUI_ICONS_LOCATION);
|
||||
|
||||
boolean unused = false;
|
||||
int left_align = width / 2 + 91;
|
||||
|
||||
@@ -636,12 +612,12 @@ public class ForgeGui extends Gui
|
||||
for (int i = 0; i < rowCount; ++i)
|
||||
{
|
||||
int x = left_align - i * 8 - 9;
|
||||
blit(poseStack, x, top, BACKGROUND, 9, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, top, BACKGROUND, 9, 9, 9);
|
||||
|
||||
if (i * 2 + 1 + heart < health)
|
||||
blit(poseStack, x, top, FULL, 9, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, top, FULL, 9, 9, 9);
|
||||
else if (i * 2 + 1 + heart == health)
|
||||
blit(poseStack, x, top, HALF, 9, 9, 9);
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, top, HALF, 9, 9, 9);
|
||||
}
|
||||
|
||||
rightHeight += 10;
|
||||
@@ -650,19 +626,14 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
|
||||
//Helper macros
|
||||
private boolean pre(NamedGuiOverlay overlay, PoseStack poseStack)
|
||||
private boolean pre(NamedGuiOverlay overlay, GuiGraphics guiGraphics)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Pre(minecraft.getWindow(), poseStack, minecraft.getFrameTime(), overlay));
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Pre(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), overlay));
|
||||
}
|
||||
|
||||
private void post(NamedGuiOverlay overlay, PoseStack poseStack)
|
||||
private void post(NamedGuiOverlay overlay, GuiGraphics guiGraphics)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Post(minecraft.getWindow(), poseStack, minecraft.getFrameTime(), overlay));
|
||||
}
|
||||
|
||||
private void bind(ResourceLocation res)
|
||||
{
|
||||
RenderSystem.setShaderTexture(0, res);
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Post(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), overlay));
|
||||
}
|
||||
|
||||
private static class ForgeDebugScreenOverlay extends DebugScreenOverlay
|
||||
@@ -683,10 +654,10 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGameInformation(PoseStack poseStack) {}
|
||||
protected void drawGameInformation(GuiGraphics guiGraphics) {}
|
||||
|
||||
@Override
|
||||
protected void drawSystemInformation(PoseStack poseStack) {}
|
||||
protected void drawSystemInformation(GuiGraphics guiGraphics) {}
|
||||
|
||||
private List<String> getLeft()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package net.minecraftforge.client.gui.overlay;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
|
||||
|
||||
/**
|
||||
@@ -16,5 +16,5 @@ import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
|
||||
@FunctionalInterface
|
||||
public interface IGuiOverlay
|
||||
{
|
||||
void render(ForgeGui gui, PoseStack poseStack, float partialTick, int screenWidth, int screenHeight);
|
||||
void render(ForgeGui gui, GuiGraphics guiGraphics, float partialTick, int screenWidth, int screenHeight);
|
||||
}
|
||||
@@ -8,8 +8,9 @@ package net.minecraftforge.client.gui.overlay;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.PlayerRideableJumping;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
@@ -23,166 +24,165 @@ import org.lwjgl.opengl.GL11;
|
||||
*/
|
||||
public enum VanillaGuiOverlay
|
||||
{
|
||||
VIGNETTE("vignette", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
VIGNETTE("vignette", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (Minecraft.useFancyGraphics())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderVignette(poseStack, gui.getMinecraft().getCameraEntity());
|
||||
gui.renderVignette(guiGraphics, gui.getMinecraft().getCameraEntity());
|
||||
}
|
||||
}),
|
||||
SPYGLASS("spyglass", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
SPYGLASS("spyglass", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderSpyglassOverlay(poseStack);
|
||||
gui.renderSpyglassOverlay(guiGraphics);
|
||||
}),
|
||||
HELMET("helmet", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
HELMET("helmet", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHelmet(partialTick, poseStack);
|
||||
gui.renderHelmet(partialTick, guiGraphics);
|
||||
}),
|
||||
FROSTBITE("frostbite", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
FROSTBITE("frostbite", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderFrostbite(poseStack);
|
||||
gui.renderFrostbite(guiGraphics);
|
||||
}),
|
||||
PORTAL("portal", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
if (!gui.getMinecraft().player.hasEffect(MobEffects.CONFUSION))
|
||||
{
|
||||
PORTAL("portal", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
float f1 = Mth.lerp(partialTick, gui.getMinecraft().player.oSpinningEffectIntensity, gui.getMinecraft().player.spinningEffectIntensity);
|
||||
if (f1 > 0.0F && !gui.getMinecraft().player.hasEffect(MobEffects.CONFUSION)) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderPortalOverlay(poseStack, partialTick);
|
||||
gui.renderPortalOverlay(guiGraphics, partialTick);
|
||||
}
|
||||
|
||||
}),
|
||||
HOTBAR("hotbar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
HOTBAR("hotbar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
if (gui.getMinecraft().gameMode.getPlayerMode() == GameType.SPECTATOR)
|
||||
{
|
||||
gui.getSpectatorGui().renderHotbar(poseStack);
|
||||
gui.getSpectatorGui().renderHotbar(guiGraphics);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui.renderHotbar(partialTick, poseStack);
|
||||
gui.renderHotbar(partialTick, guiGraphics);
|
||||
}
|
||||
}
|
||||
}),
|
||||
CROSSHAIR("crosshair", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
CROSSHAIR("crosshair", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0, 0, -90);
|
||||
gui.renderCrosshair(poseStack);
|
||||
poseStack.popPose();
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().translate(0, 0, -90);
|
||||
gui.renderCrosshair(guiGraphics);
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
}),
|
||||
BOSS_EVENT_PROGRESS("boss_event_progress", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
BOSS_EVENT_PROGRESS("boss_event_progress", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0, 0, -90);
|
||||
gui.renderBossHealth(poseStack);
|
||||
poseStack.popPose();
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().translate(0, 0, -90);
|
||||
gui.renderBossHealth(guiGraphics);
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
}),
|
||||
PLAYER_HEALTH("player_health", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
PLAYER_HEALTH("player_health", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHealth(screenWidth, screenHeight, poseStack);
|
||||
gui.renderHealth(screenWidth, screenHeight, guiGraphics);
|
||||
}
|
||||
}),
|
||||
ARMOR_LEVEL("armor_level", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
ARMOR_LEVEL("armor_level", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderArmor(poseStack, screenWidth, screenHeight);
|
||||
gui.renderArmor(guiGraphics, screenWidth, screenHeight);
|
||||
}
|
||||
}),
|
||||
FOOD_LEVEL("food_level", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
boolean isMounted = gui.getMinecraft().player.getVehicle() instanceof LivingEntity;
|
||||
FOOD_LEVEL("food_level", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
Entity vehicle = gui.getMinecraft().player.getVehicle();
|
||||
boolean isMounted = vehicle != null && vehicle.showVehicleHealth();
|
||||
if (!isMounted && !gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderFood(screenWidth, screenHeight, poseStack);
|
||||
gui.renderFood(screenWidth, screenHeight, guiGraphics);
|
||||
}
|
||||
}),
|
||||
MOUNT_HEALTH("mount_health", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
MOUNT_HEALTH("mount_health", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHealthMount(screenWidth, screenHeight, poseStack);
|
||||
gui.renderHealthMount(screenWidth, screenHeight, guiGraphics);
|
||||
}
|
||||
}),
|
||||
AIR_LEVEL("air_level", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
AIR_LEVEL("air_level", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderAir(screenWidth, screenHeight, poseStack);
|
||||
gui.renderAir(screenWidth, screenHeight, guiGraphics);
|
||||
}
|
||||
}),
|
||||
JUMP_BAR("jump_bar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
JUMP_BAR("jump_bar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
PlayerRideableJumping playerRideableJumping = gui.getMinecraft().player.jumpableVehicle();
|
||||
if (playerRideableJumping != null && !gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderJumpMeter(playerRideableJumping, poseStack, screenWidth / 2 - 91);
|
||||
gui.renderJumpMeter(playerRideableJumping, guiGraphics, screenWidth / 2 - 91);
|
||||
}
|
||||
}),
|
||||
EXPERIENCE_BAR("experience_bar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
EXPERIENCE_BAR("experience_bar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (gui.getMinecraft().player.jumpableVehicle() == null && !gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderExperience(screenWidth / 2 - 91, poseStack);
|
||||
gui.renderExperience(screenWidth / 2 - 91, guiGraphics);
|
||||
}
|
||||
}),
|
||||
ITEM_NAME("item_name", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
ITEM_NAME("item_name", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
if (gui.getMinecraft().gameMode.getPlayerMode() != GameType.SPECTATOR)
|
||||
{
|
||||
gui.renderSelectedItemName(poseStack);
|
||||
gui.renderSelectedItemName(guiGraphics);
|
||||
}
|
||||
else if (gui.getMinecraft().player.isSpectator())
|
||||
{
|
||||
gui.getSpectatorGui().renderTooltip(poseStack);
|
||||
gui.getSpectatorGui().renderTooltip(guiGraphics);
|
||||
}
|
||||
}
|
||||
}),
|
||||
SLEEP_FADE("sleep_fade", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderSleepFade(screenWidth, screenHeight, poseStack);
|
||||
SLEEP_FADE("sleep_fade", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderSleepFade(screenWidth, screenHeight, guiGraphics);
|
||||
}),
|
||||
DEBUG_TEXT("debug_text", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderHUDText(screenWidth, screenHeight, poseStack);
|
||||
DEBUG_TEXT("debug_text", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderHUDText(screenWidth, screenHeight, guiGraphics);
|
||||
}),
|
||||
FPS_GRAPH("fps_graph", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderFPSGraph(poseStack);
|
||||
FPS_GRAPH("fps_graph", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderFPSGraph(guiGraphics);
|
||||
}),
|
||||
POTION_ICONS("potion_icons", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderEffects(poseStack);
|
||||
POTION_ICONS("potion_icons", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderEffects(guiGraphics);
|
||||
}),
|
||||
RECORD_OVERLAY("record_overlay", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
RECORD_OVERLAY("record_overlay", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderRecordOverlay(screenWidth, screenHeight, partialTick, poseStack);
|
||||
gui.renderRecordOverlay(screenWidth, screenHeight, partialTick, guiGraphics);
|
||||
}
|
||||
}),
|
||||
SUBTITLES("subtitles", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
SUBTITLES("subtitles", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderSubtitles(poseStack);
|
||||
gui.renderSubtitles(guiGraphics);
|
||||
}
|
||||
}),
|
||||
TITLE_TEXT("title_text", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
TITLE_TEXT("title_text", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderTitle(screenWidth, screenHeight, partialTick, poseStack);
|
||||
gui.renderTitle(screenWidth, screenHeight, partialTick, guiGraphics);
|
||||
}
|
||||
}),
|
||||
SCOREBOARD("scoreboard", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
SCOREBOARD("scoreboard", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
Scoreboard scoreboard = gui.getMinecraft().level.getScoreboard();
|
||||
Objective objective = null;
|
||||
@@ -195,22 +195,22 @@ public enum VanillaGuiOverlay
|
||||
Objective scoreobjective1 = objective != null ? objective : scoreboard.getDisplayObjective(1);
|
||||
if (scoreobjective1 != null)
|
||||
{
|
||||
gui.displayScoreboardSidebar(poseStack, scoreobjective1);
|
||||
gui.displayScoreboardSidebar(guiGraphics, scoreobjective1);
|
||||
}
|
||||
}),
|
||||
CHAT_PANEL("chat_panel", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
CHAT_PANEL("chat_panel", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
gui.renderChat(screenWidth, screenHeight, poseStack);
|
||||
gui.renderChat(screenWidth, screenHeight, guiGraphics);
|
||||
}),
|
||||
PLAYER_LIST("player_list", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
PLAYER_LIST("player_list", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
gui.renderPlayerList(screenWidth, screenHeight, poseStack);
|
||||
gui.renderPlayerList(screenWidth, screenHeight, guiGraphics);
|
||||
});
|
||||
|
||||
private final ResourceLocation id;
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
|
||||
package net.minecraftforge.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraftforge.client.gui.ScreenUtils;
|
||||
|
||||
/**
|
||||
* This class provides a button that fixes several bugs present in the vanilla GuiButton drawing code.
|
||||
@@ -44,13 +43,13 @@ public class ExtendedButton extends Button
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
@Override
|
||||
public void renderWidget(PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
int k = !this.active ? 0 : (this.isHoveredOrFocused() ? 2 : 1);
|
||||
ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, 0);
|
||||
guiGraphics.blitWithBorder(WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2);
|
||||
|
||||
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
|
||||
drawCenteredString(poseStack, mc.font, Language.getInstance().getVisualOrder(buttonText), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, getFGColor());
|
||||
guiGraphics.drawCenteredString(mc.font, Language.getInstance().getVisualOrder(buttonText), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, getFGColor());
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,11 @@
|
||||
|
||||
package net.minecraftforge.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.client.gui.ScreenUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
@@ -226,16 +220,13 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
protected void applyValue() {}
|
||||
|
||||
@Override
|
||||
public void renderWidget(@NotNull PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, SLIDER_LOCATION);
|
||||
|
||||
final Minecraft mc = Minecraft.getInstance();
|
||||
ScreenUtils.blitWithBorder(poseStack, this.getX(), this.getY(), 0, getTextureY(), this.width, this.height, 200, 20, 2, 3, 2, 2, 0);
|
||||
guiGraphics.blitWithBorder(SLIDER_LOCATION, this.getX(), this.getY(), 0, getTextureY(), this.width, this.height, 200, 20, 2, 3, 2, 2);
|
||||
|
||||
ScreenUtils.blitWithBorder(poseStack, this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 0, getHandleTextureY(), 8, this.height, 200, 20 , 2, 3, 2, 2, 0);
|
||||
guiGraphics.blitWithBorder(SLIDER_LOCATION, this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 0, getHandleTextureY(), 8, this.height, 200, 20 , 2, 3, 2, 2);
|
||||
|
||||
renderScrollingString(poseStack, mc.font, 2, getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24);
|
||||
renderScrollingString(guiGraphics, mc.font, 2, getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24);
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,8 @@
|
||||
|
||||
package net.minecraftforge.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -55,9 +54,9 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBackground(PoseStack poseStack)
|
||||
protected void renderBackground(GuiGraphics guiGraphics)
|
||||
{
|
||||
this.parent.renderBackground(poseStack);
|
||||
this.parent.renderBackground(guiGraphics);
|
||||
}
|
||||
|
||||
public class ModEntry extends ObjectSelectionList.Entry<ModEntry> {
|
||||
@@ -75,22 +74,21 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTick)
|
||||
public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isMouseOver, float partialTick)
|
||||
{
|
||||
Component name = Component.literal(stripControlCodes(modInfo.getDisplayName()));
|
||||
Component version = Component.literal(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
|
||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
|
||||
Font font = this.parent.getFontRenderer();
|
||||
font.draw(poseStack, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth))), left + 3, top + 2, 0xFFFFFF);
|
||||
font.draw(poseStack, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC);
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth))), left + 3, top + 2, 0xFFFFFF, false);
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC, false);
|
||||
if (vercheck.status().shouldDraw())
|
||||
{
|
||||
//TODO: Consider adding more icons for visualization
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
RenderSystem.setShaderTexture(0, VERSION_CHECK_ICONS);
|
||||
poseStack.pushPose();
|
||||
GuiComponent.blit(poseStack, getLeft() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
|
||||
poseStack.popPose();
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.blit(VERSION_CHECK_ICONS, getLeft() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,25 +5,22 @@
|
||||
|
||||
package net.minecraftforge.client.gui.widget;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraftforge.client.gui.ScreenUtils;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Abstract scroll panel class.
|
||||
@@ -160,18 +157,18 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
/**
|
||||
* Draws the background of the scroll panel. This runs AFTER Scissors are enabled.
|
||||
*/
|
||||
protected void drawBackground(PoseStack matrix, Tesselator tess, float partialTick)
|
||||
protected void drawBackground(GuiGraphics guiGraphics, Tesselator tess, float partialTick)
|
||||
{
|
||||
BufferBuilder worldr = tess.getBuilder();
|
||||
|
||||
if (this.client.level != null)
|
||||
{
|
||||
this.drawGradientRect(matrix, this.left, this.top, this.right, this.bottom, bgColorFrom, bgColorTo);
|
||||
this.drawGradientRect(guiGraphics, this.left, this.top, this.right, this.bottom, bgColorFrom, bgColorTo);
|
||||
}
|
||||
else // Draw dark dirt background
|
||||
{
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.setShaderTexture(0, GuiComponent.BACKGROUND_LOCATION);
|
||||
RenderSystem.setShaderTexture(0, Screen.BACKGROUND_LOCATION);
|
||||
final float texScale = 32.0F;
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(this.left, this.bottom, 0.0D).uv(this.left / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
@@ -186,7 +183,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(PoseStack poseStack, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY);
|
||||
protected abstract void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY);
|
||||
|
||||
protected boolean clickPanel(double mouseX, double mouseY, int button) { return false; }
|
||||
|
||||
@@ -295,7 +292,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTick)
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
Tesselator tess = Tesselator.getInstance();
|
||||
BufferBuilder worldr = tess.getBuilder();
|
||||
@@ -304,10 +301,10 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
RenderSystem.enableScissor((int)(left * scale), (int)(client.getWindow().getHeight() - (bottom * scale)),
|
||||
(int)(width * scale), (int)(height * scale));
|
||||
|
||||
this.drawBackground(matrix, tess, partialTick);
|
||||
this.drawBackground(guiGraphics, tess, partialTick);
|
||||
|
||||
int baseY = this.top + border - (int)this.scrollDistance;
|
||||
this.drawPanel(matrix, right, baseY, tess, mouseX, mouseY);
|
||||
this.drawPanel(guiGraphics, right, baseY, tess, mouseX, mouseY);
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
|
||||
@@ -364,9 +361,9 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
RenderSystem.disableScissor();
|
||||
}
|
||||
|
||||
protected void drawGradientRect(PoseStack poseStack, int left, int top, int right, int bottom, int color1, int color2)
|
||||
protected void drawGradientRect(GuiGraphics guiGraphics, int left, int top, int right, int bottom, int color1, int color2)
|
||||
{
|
||||
ScreenUtils.drawGradientRect(poseStack.last().pose(), 0, left, top, right, bottom, color1, color2);
|
||||
guiGraphics.fillGradient(left, top, right, bottom, color1, color2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,11 +5,9 @@
|
||||
|
||||
package net.minecraftforge.client.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.client.gui.ScreenUtils;
|
||||
|
||||
/**
|
||||
* This class provides a button that shows a string glyph at the beginning. The glyph can be scaled using the glyphScale parameter.
|
||||
@@ -29,14 +27,14 @@ public class UnicodeGlyphButton extends ExtendedButton
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
this.isHovered = mouseX >= this.getX() && mouseY >= this.getY() && mouseX < this.getX() + this.width && mouseY < this.getY() + this.height;
|
||||
int k = !this.active ? 0 : (this.isHoveredOrFocused() ? 2 : 1);
|
||||
ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, 0);
|
||||
guiGraphics.blitWithBorder(WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2);
|
||||
|
||||
Component buttonText = this.createNarrationMessage();
|
||||
int glyphWidth = (int) (mc.font.width(glyph) * glyphScale);
|
||||
@@ -50,14 +48,14 @@ public class UnicodeGlyphButton extends ExtendedButton
|
||||
strWidth = mc.font.width(buttonText);
|
||||
totalWidth = glyphWidth + strWidth;
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.scale(glyphScale, glyphScale, 1.0F);
|
||||
this.drawCenteredString(poseStack, mc.font, Component.literal(glyph),
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().scale(glyphScale, glyphScale, 1.0F);
|
||||
guiGraphics.drawCenteredString(mc.font, Component.literal(glyph),
|
||||
(int) (((this.getX() + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2),
|
||||
(int) (((this.getY() + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor());
|
||||
poseStack.popPose();
|
||||
guiGraphics.pose().popPose();
|
||||
|
||||
this.drawCenteredString(poseStack, mc.font, buttonText, (int) (this.getX() + (this.width / 2) + (glyphWidth / glyphScale)),
|
||||
guiGraphics.drawCenteredString(mc.font, buttonText, (int) (this.getX() + (this.width / 2) + (glyphWidth / glyphScale)),
|
||||
this.getY() + (this.height - 8) / 2, getFGColor());
|
||||
|
||||
}
|
||||
|
||||
@@ -47,8 +47,6 @@ import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.client.model.geometry.IUnbakedGeometry;
|
||||
import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper;
|
||||
import net.minecraftforge.common.util.ConcatenatedListView;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -60,30 +58,18 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final ImmutableMap<String, BlockModel> children;
|
||||
private final ImmutableList<String> itemPasses;
|
||||
private final boolean logWarning;
|
||||
|
||||
public CompositeModel(ImmutableMap<String, BlockModel> children, ImmutableList<String> itemPasses)
|
||||
{
|
||||
this(children, itemPasses, false);
|
||||
}
|
||||
|
||||
private CompositeModel(ImmutableMap<String, BlockModel> children, ImmutableList<String> itemPasses, boolean logWarning)
|
||||
{
|
||||
this.children = children;
|
||||
this.itemPasses = itemPasses;
|
||||
this.logWarning = logWarning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
if (logWarning)
|
||||
LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated \"parts\" field in its composite model instead of \"children\". This field will be removed in 1.20.");
|
||||
|
||||
Material particleLocation = context.getMaterial("particle");
|
||||
TextureAtlasSprite particle = spriteGetter.apply(particleLocation);
|
||||
|
||||
@@ -405,8 +391,7 @@ public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
{
|
||||
List<String> itemPasses = new ArrayList<>();
|
||||
ImmutableMap.Builder<String, BlockModel> childrenBuilder = ImmutableMap.builder();
|
||||
readChildren(jsonObject, "children", deserializationContext, childrenBuilder, itemPasses, false);
|
||||
boolean logWarning = readChildren(jsonObject, "parts", deserializationContext, childrenBuilder, itemPasses, true);
|
||||
readChildren(jsonObject, "children", deserializationContext, childrenBuilder, itemPasses);
|
||||
|
||||
var children = childrenBuilder.build();
|
||||
if (children.isEmpty())
|
||||
@@ -424,20 +409,19 @@ public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
}
|
||||
}
|
||||
|
||||
return new CompositeModel(children, ImmutableList.copyOf(itemPasses), logWarning);
|
||||
return new CompositeModel(children, ImmutableList.copyOf(itemPasses));
|
||||
}
|
||||
|
||||
private boolean readChildren(JsonObject jsonObject, String name, JsonDeserializationContext deserializationContext, ImmutableMap.Builder<String, BlockModel> children, List<String> itemPasses, boolean logWarning)
|
||||
private void readChildren(JsonObject jsonObject, String name, JsonDeserializationContext deserializationContext, ImmutableMap.Builder<String, BlockModel> children, List<String> itemPasses)
|
||||
{
|
||||
if (!jsonObject.has(name))
|
||||
return false;
|
||||
return;
|
||||
var childrenJsonObject = jsonObject.getAsJsonObject(name);
|
||||
for (Map.Entry<String, JsonElement> entry : childrenJsonObject.entrySet())
|
||||
{
|
||||
children.put(entry.getKey(), deserializationContext.deserialize(entry.getValue(), BlockModel.class));
|
||||
itemPasses.add(entry.getKey()); // We can do this because GSON preserves ordering during deserialization
|
||||
}
|
||||
return logWarning;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,9 @@
|
||||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -22,7 +19,6 @@ import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
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.UnbakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -40,16 +36,12 @@ import net.minecraftforge.client.model.geometry.StandaloneGeometryBakingContext;
|
||||
import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
@@ -64,8 +56,6 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class DynamicFluidContainerModel implements IUnbakedGeometry<DynamicFluidContainerModel>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
// Depth offsets to prevent Z-fighting
|
||||
private static final Transformation FLUID_TRANSFORM = new Transformation(new Vector3f(), new Quaternionf(), new Vector3f(1, 1, 1.002f), new Quaternionf());
|
||||
private static final Transformation COVER_TRANSFORM = new Transformation(new Vector3f(), new Quaternionf(), new Vector3f(1, 1, 1.004f), new Quaternionf());
|
||||
@@ -74,22 +64,13 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry<DynamicFluid
|
||||
private final boolean flipGas;
|
||||
private final boolean coverIsMask;
|
||||
private final boolean applyFluidLuminosity;
|
||||
private final boolean deprecatedLoader;
|
||||
private final Map<String, String> deprecationWarnings;
|
||||
|
||||
public DynamicFluidContainerModel(Fluid fluid, boolean flipGas, boolean coverIsMask, boolean applyFluidLuminosity)
|
||||
{
|
||||
this(fluid, flipGas, coverIsMask, applyFluidLuminosity, false, Map.of());
|
||||
}
|
||||
|
||||
private DynamicFluidContainerModel(Fluid fluid, boolean flipGas, boolean coverIsMask, boolean applyFluidLuminosity, boolean deprecatedLoader, Map<String, String> deprecationWarnings)
|
||||
private DynamicFluidContainerModel(Fluid fluid, boolean flipGas, boolean coverIsMask, boolean applyFluidLuminosity)
|
||||
{
|
||||
this.fluid = fluid;
|
||||
this.flipGas = flipGas;
|
||||
this.coverIsMask = coverIsMask;
|
||||
this.applyFluidLuminosity = applyFluidLuminosity;
|
||||
this.deprecatedLoader = deprecatedLoader;
|
||||
this.deprecationWarnings = deprecationWarnings;
|
||||
}
|
||||
|
||||
public static RenderTypeGroup getLayerRenderTypes(boolean unlit)
|
||||
@@ -103,17 +84,12 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry<DynamicFluid
|
||||
*/
|
||||
public DynamicFluidContainerModel withFluid(Fluid newFluid)
|
||||
{
|
||||
return new DynamicFluidContainerModel(newFluid, flipGas, coverIsMask, applyFluidLuminosity, false, Map.of());
|
||||
return new DynamicFluidContainerModel(newFluid, flipGas, coverIsMask, applyFluidLuminosity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
if (deprecatedLoader)
|
||||
LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated loader \"forge:bucket\" instead of \"forge:fluid_container\". This loader will be removed in 1.20.");
|
||||
for (var entry : deprecationWarnings.entrySet())
|
||||
LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated \"" + entry.getKey() + "\" field in its fluid container model instead of \"" + entry.getValue() + "\". This field will be removed in 1.20.");
|
||||
|
||||
Material particleLocation = context.hasMaterial("particle") ? context.getMaterial("particle") : null;
|
||||
Material baseLocation = context.hasMaterial("base") ? context.getMaterial("base") : null;
|
||||
Material fluidMaskLocation = context.hasMaterial("fluid") ? context.getMaterial("fluid") : null;
|
||||
@@ -189,15 +165,10 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry<DynamicFluid
|
||||
|
||||
public static final class Loader implements IGeometryLoader<DynamicFluidContainerModel>
|
||||
{
|
||||
public static final Loader INSTANCE = new Loader(false);
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
public static final Loader INSTANCE_DEPRECATED = new Loader(true);
|
||||
public static final Loader INSTANCE = new Loader();
|
||||
|
||||
private final boolean deprecated;
|
||||
|
||||
private Loader(boolean deprecated)
|
||||
private Loader()
|
||||
{
|
||||
this.deprecated = deprecated;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,26 +185,8 @@ public class DynamicFluidContainerModel implements IUnbakedGeometry<DynamicFluid
|
||||
boolean coverIsMask = GsonHelper.getAsBoolean(jsonObject, "cover_is_mask", true);
|
||||
boolean applyFluidLuminosity = GsonHelper.getAsBoolean(jsonObject, "apply_fluid_luminosity", true);
|
||||
|
||||
// TODO: Deprecated names. To be removed in 1.20
|
||||
var deprecationWarningsBuilder = ImmutableMap.<String, String>builder();
|
||||
if (jsonObject.has("flipGas"))
|
||||
{
|
||||
flip = GsonHelper.getAsBoolean(jsonObject, "flipGas");
|
||||
deprecationWarningsBuilder.put("flipGas", "flip_gas");
|
||||
}
|
||||
if (jsonObject.has("coverIsMask"))
|
||||
{
|
||||
coverIsMask = GsonHelper.getAsBoolean(jsonObject, "coverIsMask");
|
||||
deprecationWarningsBuilder.put("coverIsMask", "cover_is_mask");
|
||||
}
|
||||
if (jsonObject.has("applyFluidLuminosity"))
|
||||
{
|
||||
applyFluidLuminosity = GsonHelper.getAsBoolean(jsonObject, "applyFluidLuminosity");
|
||||
deprecationWarningsBuilder.put("applyFluidLuminosity", "apply_fluid_luminosity");
|
||||
}
|
||||
|
||||
// create new model with correct liquid
|
||||
return new DynamicFluidContainerModel(fluid, flip, coverIsMask, applyFluidLuminosity, deprecated, deprecationWarningsBuilder.build());
|
||||
return new DynamicFluidContainerModel(fluid, flip, coverIsMask, applyFluidLuminosity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,36 +25,22 @@ import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.client.model.geometry.SimpleUnbakedGeometry;
|
||||
import net.minecraftforge.client.model.geometry.UnbakedGeometryHelper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* A model composed of vanilla {@linkplain BlockElement block elements}.
|
||||
*/
|
||||
public class ElementsModel extends SimpleUnbakedGeometry<ElementsModel>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final List<BlockElement> elements;
|
||||
private final boolean deprecatedLoader;
|
||||
|
||||
public ElementsModel(List<BlockElement> elements)
|
||||
{
|
||||
this(elements, false);
|
||||
}
|
||||
|
||||
private ElementsModel(List<BlockElement> elements, boolean deprecatedLoader)
|
||||
{
|
||||
this.elements = elements;
|
||||
this.deprecatedLoader = deprecatedLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addQuads(IGeometryBakingContext context, IModelBuilder<?> modelBuilder, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation)
|
||||
{
|
||||
if (deprecatedLoader)
|
||||
LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated loader \"minecraft:elements\" instead of \"forge:elements\". This loader will be removed in 1.20.");
|
||||
|
||||
// If there is a root transform, undo the ModelState transform, apply it, then re-apply the ModelState transform.
|
||||
// This is necessary because of things like UV locking, which should only respond to the ModelState, and as such
|
||||
// that is the only transform that should be applied during face bake.
|
||||
@@ -82,15 +68,10 @@ public class ElementsModel extends SimpleUnbakedGeometry<ElementsModel>
|
||||
|
||||
public static final class Loader implements IGeometryLoader<ElementsModel>
|
||||
{
|
||||
public static final Loader INSTANCE = new Loader(false);
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
public static final Loader INSTANCE_DEPRECATED = new Loader(true);
|
||||
public static final Loader INSTANCE = new Loader();
|
||||
|
||||
private final boolean deprecated;
|
||||
|
||||
private Loader(boolean deprecated)
|
||||
private Loader()
|
||||
{
|
||||
this.deprecated = deprecated;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,7 +86,7 @@ public class ElementsModel extends SimpleUnbakedGeometry<ElementsModel>
|
||||
elements.add(deserializationContext.deserialize(element, BlockElement.class));
|
||||
}
|
||||
|
||||
return new ElementsModel(elements, deprecated);
|
||||
return new ElementsModel(elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,39 +56,6 @@ public interface IQuadTransformer
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link BakedQuad} transformer that does nothing.
|
||||
*
|
||||
* @deprecated Use {@link QuadTransformers#empty()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
static IQuadTransformer empty()
|
||||
{
|
||||
return QuadTransformers.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link BakedQuad} transformer that applies the specified {@link Transformation}.
|
||||
*
|
||||
* @deprecated Use {@link QuadTransformers#applying(Transformation)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
static IQuadTransformer applying(Transformation transform)
|
||||
{
|
||||
return QuadTransformers.applying(transform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link BakedQuad} transformer that applies the specified lightmap.
|
||||
*
|
||||
* @deprecated Use {@link QuadTransformers#applyingLightmap(int)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
static IQuadTransformer applyingLightmap(int lightmap)
|
||||
{
|
||||
return QuadTransformers.applyingLightmap(lightmap);
|
||||
}
|
||||
|
||||
private static BakedQuad copy(BakedQuad quad)
|
||||
{
|
||||
var vertices = quad.getVertices();
|
||||
|
||||
@@ -36,8 +36,6 @@ import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.client.model.geometry.IUnbakedGeometry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -46,30 +44,18 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class SeparateTransformsModel implements IUnbakedGeometry<SeparateTransformsModel>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final BlockModel baseModel;
|
||||
private final ImmutableMap<ItemDisplayContext, BlockModel> perspectives;
|
||||
private final boolean deprecatedLoader;
|
||||
|
||||
public SeparateTransformsModel(BlockModel baseModel, ImmutableMap<ItemDisplayContext, BlockModel> perspectives)
|
||||
{
|
||||
this(baseModel, perspectives, false);
|
||||
}
|
||||
|
||||
private SeparateTransformsModel(BlockModel baseModel, ImmutableMap<ItemDisplayContext, BlockModel> perspectives, boolean deprecatedLoader)
|
||||
{
|
||||
this.baseModel = baseModel;
|
||||
this.perspectives = perspectives;
|
||||
this.deprecatedLoader = deprecatedLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
if (deprecatedLoader)
|
||||
LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated loader \"forge:separate-perspective\" instead of \"forge:separate_transforms\". This loader will be removed in 1.20.");
|
||||
|
||||
return new Baked(
|
||||
context.useAmbientOcclusion(), context.isGui3d(), context.useBlockLight(),
|
||||
spriteGetter.apply(context.getMaterial("particle")), overrides,
|
||||
@@ -177,15 +163,10 @@ public class SeparateTransformsModel implements IUnbakedGeometry<SeparateTransfo
|
||||
|
||||
public static final class Loader implements IGeometryLoader<SeparateTransformsModel>
|
||||
{
|
||||
public static final Loader INSTANCE = new Loader(false);
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
public static final Loader INSTANCE_DEPRECATED = new Loader(true);
|
||||
public static final Loader INSTANCE = new Loader();
|
||||
|
||||
private final boolean deprecated;
|
||||
|
||||
private Loader(boolean deprecated)
|
||||
private Loader()
|
||||
{
|
||||
this.deprecated = deprecated;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,7 +186,7 @@ public class SeparateTransformsModel implements IUnbakedGeometry<SeparateTransfo
|
||||
}
|
||||
}
|
||||
|
||||
return new SeparateTransformsModel(baseModel, ImmutableMap.copyOf(perspectives), deprecated);
|
||||
return new SeparateTransformsModel(baseModel, ImmutableMap.copyOf(perspectives));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,8 @@
|
||||
package net.minecraftforge.client.model.generators;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.common.util.TransformationHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
* Builder for block models, does not currently provide any additional
|
||||
@@ -26,21 +19,9 @@ import org.joml.Vector3f;
|
||||
*/
|
||||
public class BlockModelBuilder extends ModelBuilder<BlockModelBuilder>
|
||||
{
|
||||
private final RootTransformBuilder rootTransform;
|
||||
|
||||
public BlockModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper)
|
||||
{
|
||||
super(outputLocation, existingFileHelper);
|
||||
this.rootTransform = new RootTransformBuilder(super.rootTransforms());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link ModelBuilder#rootTransforms()} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public RootTransformBuilder rootTransform()
|
||||
{
|
||||
return rootTransform;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,293 +29,4 @@ public class BlockModelBuilder extends ModelBuilder<BlockModelBuilder>
|
||||
{
|
||||
return super.toJson();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link ModelBuilder.RootTransformsBuilder} instead via {@link ModelBuilder#rootTransforms()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public class RootTransformBuilder
|
||||
{
|
||||
private final ModelBuilder<BlockModelBuilder>.RootTransformsBuilder rootTransforms;
|
||||
|
||||
private RootTransformBuilder(ModelBuilder<BlockModelBuilder>.RootTransformsBuilder rootTransforms)
|
||||
{
|
||||
this.rootTransforms = rootTransforms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the translation of the root transform.
|
||||
*
|
||||
* @param translation the translation
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code translation} is {@code null}
|
||||
*/
|
||||
public RootTransformBuilder translation(Vector3f translation)
|
||||
{
|
||||
rootTransforms.translation(translation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the translation of the root transform.
|
||||
*
|
||||
* @param x x translation
|
||||
* @param y y translation
|
||||
* @param z z translation
|
||||
* @return this builder
|
||||
*/
|
||||
public RootTransformBuilder translation(float x, float y, float z)
|
||||
{
|
||||
return translation(new Vector3f(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the left rotation of the root transform.
|
||||
*
|
||||
* @param rotation the left rotation
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code rotation} is {@code null}
|
||||
*/
|
||||
public RootTransformBuilder rotation(Quaternionf rotation)
|
||||
{
|
||||
rootTransforms.rotation(rotation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the left rotation of the root transform.
|
||||
*
|
||||
* @param x x rotation
|
||||
* @param y y rotation
|
||||
* @param z z rotation
|
||||
* @param isDegrees whether the rotation is in degrees or radians
|
||||
* @return this builder
|
||||
*/
|
||||
public RootTransformBuilder rotation(float x, float y, float z, boolean isDegrees)
|
||||
{
|
||||
return rotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the left rotation of the root transform.
|
||||
*
|
||||
* @param leftRotation the left rotation
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code leftRotation} is {@code null}
|
||||
*/
|
||||
public RootTransformBuilder leftRotation(Quaternionf leftRotation)
|
||||
{
|
||||
return rotation(leftRotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the left rotation of the root transform.
|
||||
*
|
||||
* @param x x rotation
|
||||
* @param y y rotation
|
||||
* @param z z rotation
|
||||
* @param isDegrees whether the rotation is in degrees or radians
|
||||
* @return this builder
|
||||
*/
|
||||
public RootTransformBuilder leftRotation(float x, float y, float z, boolean isDegrees)
|
||||
{
|
||||
return leftRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the right rotation of the root transform.
|
||||
*
|
||||
* @param rightRotation the right rotation
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code rightRotation} is {@code null}
|
||||
*/
|
||||
public RootTransformBuilder rightRotation(Quaternionf rightRotation)
|
||||
{
|
||||
rootTransforms.rightRotation(rightRotation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the right rotation of the root transform.
|
||||
*
|
||||
* @param x x rotation
|
||||
* @param y y rotation
|
||||
* @param z z rotation
|
||||
* @param isDegrees whether the rotation is in degrees or radians
|
||||
* @return this builder
|
||||
*/
|
||||
public RootTransformBuilder rightRotation(float x, float y, float z, boolean isDegrees)
|
||||
{
|
||||
return rightRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the right rotation of the root transform.
|
||||
*
|
||||
* @param postRotation the right rotation
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code rightRotation} is {@code null}
|
||||
*/
|
||||
public RootTransformBuilder postRotation(Quaternionf postRotation)
|
||||
{
|
||||
return rightRotation(postRotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the right rotation of the root transform.
|
||||
*
|
||||
* @param x x rotation
|
||||
* @param y y rotation
|
||||
* @param z z rotation
|
||||
* @param isDegrees whether the rotation is in degrees or radians
|
||||
* @return this builder
|
||||
*/
|
||||
public RootTransformBuilder postRotation(float x, float y, float z, boolean isDegrees)
|
||||
{
|
||||
return postRotation(TransformationHelper.quatFromXYZ(x, y, z, isDegrees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scale of the root transform.
|
||||
*
|
||||
* @param scale the scale
|
||||
* @return this builder
|
||||
*/
|
||||
public RootTransformBuilder scale(float scale)
|
||||
{
|
||||
return scale(new Vector3f(scale, scale, scale));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scale of the root transform.
|
||||
*
|
||||
* @param xScale x scale
|
||||
* @param yScale y scale
|
||||
* @param zScale z scale
|
||||
* @return this builder
|
||||
*/
|
||||
public RootTransformBuilder scale(float xScale, float yScale, float zScale)
|
||||
{
|
||||
return scale(new Vector3f(xScale, yScale, zScale));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scale of the root transform.
|
||||
*
|
||||
* @param scale the scale vector
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code scale} is {@code null}
|
||||
*/
|
||||
public RootTransformBuilder scale(Vector3f scale)
|
||||
{
|
||||
rootTransforms.scale(scale);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the root transform.
|
||||
*
|
||||
* @param transformation the transformation to use
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code transformation} is {@code null}
|
||||
*/
|
||||
public RootTransformBuilder transform(Transformation transformation)
|
||||
{
|
||||
rootTransforms.transform(transformation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the origin of the root transform.
|
||||
*
|
||||
* @param origin the origin vector
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code origin} is {@code null}
|
||||
*/
|
||||
public RootTransformBuilder origin(Vector3f origin)
|
||||
{
|
||||
rootTransforms.origin(origin);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the origin of the root transform.
|
||||
*
|
||||
* @param origin the origin name
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code origin} is {@code null}
|
||||
* @throws IllegalArgumentException if {@code origin} is not {@code center}, {@code corner} or {@code opposing-corner}
|
||||
*/
|
||||
public RootTransformBuilder origin(TransformOrigin origin)
|
||||
{
|
||||
rootTransforms.origin(origin.toNewOrigin());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish configuring the parent builder
|
||||
* @return the parent block model builder
|
||||
*/
|
||||
public BlockModelBuilder end()
|
||||
{
|
||||
return BlockModelBuilder.this;
|
||||
}
|
||||
|
||||
public JsonObject toJson()
|
||||
{
|
||||
return rootTransforms.toJson();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link TransformationHelper.TransformOrigin} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public enum TransformOrigin implements StringRepresentable
|
||||
{
|
||||
CENTER(TransformationHelper.TransformOrigin.CENTER),
|
||||
CORNER(TransformationHelper.TransformOrigin.CORNER),
|
||||
OPPOSING_CORNER(TransformationHelper.TransformOrigin.OPPOSING_CORNER);
|
||||
|
||||
private final TransformationHelper.TransformOrigin newOrigin;
|
||||
|
||||
TransformOrigin(TransformationHelper.TransformOrigin newOrigin)
|
||||
{
|
||||
this.newOrigin = newOrigin;
|
||||
}
|
||||
|
||||
public Vector3f getVector()
|
||||
{
|
||||
return newOrigin.getVector();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getSerializedName()
|
||||
{
|
||||
return newOrigin.getSerializedName();
|
||||
}
|
||||
|
||||
private TransformationHelper.TransformOrigin toNewOrigin()
|
||||
{
|
||||
return newOrigin;
|
||||
}
|
||||
|
||||
public static @Nullable TransformOrigin fromString(String originName)
|
||||
{
|
||||
if (CENTER.getSerializedName().equals(originName))
|
||||
{
|
||||
return CENTER;
|
||||
}
|
||||
if (CORNER.getSerializedName().equals(originName))
|
||||
{
|
||||
return CORNER;
|
||||
}
|
||||
if (OPPOSING_CORNER.getSerializedName().equals(originName))
|
||||
{
|
||||
return OPPOSING_CORNER;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package net.minecraftforge.client.model.generators;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -59,6 +58,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Data provider for blockstate files. Extends {@link BlockModelProvider} so that
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
package net.minecraftforge.client.model.generators;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
@VisibleForTesting
|
||||
public interface IGeneratedBlockState
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
@@ -38,6 +37,7 @@ import net.minecraftforge.client.model.ForgeFaceData;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.common.util.TransformationHelper;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@@ -519,7 +519,7 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
public ElementBuilder cube(String texture) {
|
||||
return allFaces(addTexture(texture).andThen((dir, f) -> f.cullface(dir)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the block and sky light of the element (0-15).
|
||||
* Traditional "emissivity" values were set both of these to the same value.
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package net.minecraftforge.client.model.generators;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -22,6 +21,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper.ResourceType;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
public abstract class ModelProvider<T extends ModelBuilder<T>> implements DataProvider {
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ public final class GeometryLoaderManager
|
||||
public static void init()
|
||||
{
|
||||
var loaders = new HashMap<ResourceLocation, IGeometryLoader<?>>();
|
||||
loaders.put(new ResourceLocation("minecraft:elements"), ElementsModel.Loader.INSTANCE_DEPRECATED); // TODO: Deprecated. To be removed in 1.20
|
||||
var event = new ModelEvent.RegisterGeometryLoaders(loaders);
|
||||
ModLoader.get().postEventWrapContainerInModOrder(event);
|
||||
LOADERS = ImmutableMap.copyOf(loaders);
|
||||
|
||||
@@ -108,18 +108,6 @@ public class UnbakedGeometryHelper
|
||||
if (blockModel.getRootModel() == ModelBakery.GENERATION_MARKER)
|
||||
return ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, blockModel).bake(modelBaker, blockModel, spriteGetter, modelState, modelLocation, guiLight3d);
|
||||
|
||||
return bakeVanilla(blockModel, modelBaker, owner, spriteGetter, modelState, modelLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for baking vanilla {@link BlockModel} instances.
|
||||
*
|
||||
* @deprecated Merge into the method above in 1.20 once the call from {@link BlockModel} is gone.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static BakedModel bakeVanilla(BlockModel blockModel, ModelBaker modelBaker, BlockModel owner, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ResourceLocation modelLocation)
|
||||
{
|
||||
if (blockModel.getRootModel() == ModelBakery.BLOCK_ENTITY_MARKER)
|
||||
{
|
||||
var particleSprite = spriteGetter.apply(blockModel.getMaterial("particle"));
|
||||
|
||||
@@ -58,49 +58,16 @@ public class ObjLoader implements IGeometryLoader<ObjModel>, ResourceManagerRelo
|
||||
boolean emissiveAmbient = GsonHelper.getAsBoolean(jsonObject, "emissive_ambient", true);
|
||||
String mtlOverride = GsonHelper.getAsString(jsonObject, "mtl_override", null);
|
||||
|
||||
// TODO: Deprecated names. To be removed in 1.20
|
||||
var deprecationWarningsBuilder = ImmutableMap.<String, String>builder();
|
||||
if (jsonObject.has("detectCullableFaces"))
|
||||
{
|
||||
automaticCulling = GsonHelper.getAsBoolean(jsonObject, "detectCullableFaces");
|
||||
deprecationWarningsBuilder.put("detectCullableFaces", "automatic_culling");
|
||||
}
|
||||
if (jsonObject.has("diffuseLighting"))
|
||||
{
|
||||
shadeQuads = GsonHelper.getAsBoolean(jsonObject, "diffuseLighting");
|
||||
deprecationWarningsBuilder.put("diffuseLighting", "shade_quads");
|
||||
}
|
||||
if (jsonObject.has("flip-v"))
|
||||
{
|
||||
flipV = GsonHelper.getAsBoolean(jsonObject, "flip-v");
|
||||
deprecationWarningsBuilder.put("flip-v", "flip_v");
|
||||
}
|
||||
if (jsonObject.has("ambientToFullbright"))
|
||||
{
|
||||
emissiveAmbient = GsonHelper.getAsBoolean(jsonObject, "ambientToFullbright");
|
||||
deprecationWarningsBuilder.put("ambientToFullbright", "emissive_ambient");
|
||||
}
|
||||
if (jsonObject.has("materialLibraryOverride"))
|
||||
{
|
||||
mtlOverride = GsonHelper.getAsString(jsonObject, "materialLibraryOverride");
|
||||
deprecationWarningsBuilder.put("materialLibraryOverride", "mtl_override");
|
||||
}
|
||||
|
||||
return loadModel(new ObjModel.ModelSettings(new ResourceLocation(modelLocation), automaticCulling, shadeQuads, flipV, emissiveAmbient, mtlOverride), deprecationWarningsBuilder.build());
|
||||
return loadModel(new ObjModel.ModelSettings(new ResourceLocation(modelLocation), automaticCulling, shadeQuads, flipV, emissiveAmbient, mtlOverride));
|
||||
}
|
||||
|
||||
public ObjModel loadModel(ObjModel.ModelSettings settings)
|
||||
{
|
||||
return loadModel(settings, Map.of());
|
||||
}
|
||||
|
||||
private ObjModel loadModel(ObjModel.ModelSettings settings, Map<String, String> deprecationWarnings)
|
||||
{
|
||||
return modelCache.computeIfAbsent(settings, (data) -> {
|
||||
Resource resource = manager.getResource(settings.modelLocation()).orElseThrow();
|
||||
try (ObjTokenizer tokenizer = new ObjTokenizer(resource.open()))
|
||||
{
|
||||
return ObjModel.parse(tokenizer, settings, deprecationWarnings);
|
||||
return ObjModel.parse(tokenizer, settings);
|
||||
} catch (FileNotFoundException e)
|
||||
{
|
||||
throw new RuntimeException("Could not find OBJ model", e);
|
||||
|
||||
@@ -29,8 +29,6 @@ import net.minecraftforge.client.model.pipeline.QuadBakingVertexConsumer;
|
||||
import net.minecraftforge.client.model.renderable.CompositeRenderable;
|
||||
import net.minecraftforge.client.textures.UnitTextureAtlasSprite;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3f;
|
||||
@@ -58,8 +56,6 @@ import java.util.stream.Stream;
|
||||
*/
|
||||
public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final Vector4f COLOR_WHITE = new Vector4f(1, 1, 1, 1);
|
||||
private static final Vec2[] DEFAULT_COORDS = {
|
||||
new Vec2(0, 0),
|
||||
@@ -86,9 +82,7 @@ public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
|
||||
public final ResourceLocation modelLocation;
|
||||
|
||||
private final Map<String, String> deprecationWarnings;
|
||||
|
||||
private ObjModel(ModelSettings settings, Map<String, String> deprecationWarnings)
|
||||
private ObjModel(ModelSettings settings)
|
||||
{
|
||||
this.modelLocation = settings.modelLocation;
|
||||
this.automaticCulling = settings.automaticCulling;
|
||||
@@ -96,19 +90,13 @@ public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
this.flipV = settings.flipV;
|
||||
this.emissiveAmbient = settings.emissiveAmbient;
|
||||
this.mtlOverride = settings.mtlOverride;
|
||||
this.deprecationWarnings = deprecationWarnings;
|
||||
}
|
||||
|
||||
public static ObjModel parse(ObjTokenizer tokenizer, ModelSettings settings) throws IOException
|
||||
{
|
||||
return parse(tokenizer, settings, Map.of());
|
||||
}
|
||||
|
||||
static ObjModel parse(ObjTokenizer tokenizer, ModelSettings settings, Map<String, String> deprecationWarnings) throws IOException
|
||||
{
|
||||
var modelLocation = settings.modelLocation;
|
||||
var materialLibraryOverrideLocation = settings.mtlOverride;
|
||||
var model = new ObjModel(settings, deprecationWarnings);
|
||||
var model = new ObjModel(settings);
|
||||
|
||||
// for relative references to material libraries
|
||||
String modelDomain = modelLocation.getNamespace();
|
||||
@@ -348,9 +336,6 @@ public class ObjModel extends SimpleUnbakedGeometry<ObjModel>
|
||||
@Override
|
||||
protected void addQuads(IGeometryBakingContext owner, IModelBuilder<?> modelBuilder, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
for (var entry : deprecationWarnings.entrySet())
|
||||
LOGGER.warn("Model \"" + modelLocation + "\" is using the deprecated \"" + entry.getKey() + "\" field in its OBJ model instead of \"" + entry.getValue() + "\". This field will be removed in 1.20.");
|
||||
|
||||
parts.values().stream().filter(part -> owner.isComponentVisible(part.name(), true))
|
||||
.forEach(part -> part.addQuads(owner, modelBuilder, baker, spriteGetter, modelTransform, modelLocation));
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ public class RemappingVertexPipeline implements VertexConsumer
|
||||
else
|
||||
parent.misc(element, misc[miscElementIds.get(element)]);
|
||||
}
|
||||
parent.endVertex();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.graph.ElementOrder;
|
||||
@@ -19,15 +17,8 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
||||
@@ -40,8 +31,6 @@ import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.CreativeModeTabSearchRegistry;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.fml.loading.toposort.TopologicalSort;
|
||||
@@ -51,12 +40,22 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class CreativeModeTabRegistry
|
||||
{
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final ResourceLocation CREATIVE_MODE_TAB_ORDERING_JSON = new ResourceLocation("forge", "creative_mode_tab_ordering.json");
|
||||
private static final List<CreativeModeTab> SORTED_TABS = new ArrayList<>();
|
||||
private static final List<CreativeModeTab> SORTED_TABS_VIEW = Collections.unmodifiableList(SORTED_TABS);
|
||||
private static final List<CreativeModeTab> DEFAULT_TABS = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* {@return an unmodifiable view of the sorted list of creative mode tabs in ascending order}
|
||||
@@ -66,6 +65,10 @@ public final class CreativeModeTabRegistry
|
||||
return SORTED_TABS_VIEW;
|
||||
}
|
||||
|
||||
public static List<CreativeModeTab> getDefaultTabs() {
|
||||
return Collections.unmodifiableList(DEFAULT_TABS);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the {@linkplain CreativeModeTab} with the given name, or null}
|
||||
*
|
||||
@@ -74,7 +77,7 @@ public final class CreativeModeTabRegistry
|
||||
@Nullable
|
||||
public static CreativeModeTab getTab(ResourceLocation name)
|
||||
{
|
||||
return creativeModeTabs.get(name);
|
||||
return BuiltInRegistries.CREATIVE_MODE_TAB.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,67 +88,10 @@ public final class CreativeModeTabRegistry
|
||||
@Nullable
|
||||
public static ResourceLocation getName(CreativeModeTab tab)
|
||||
{
|
||||
return creativeModeTabs.inverse().get(tab);
|
||||
return BuiltInRegistries.CREATIVE_MODE_TAB.getKey(tab);
|
||||
}
|
||||
|
||||
private static void processCreativeModeTab(CreativeModeTab creativeModeTab, ResourceLocation name, List<Object> afterEntries, List<Object> beforeEntries)
|
||||
{
|
||||
creativeModeTabs.put(name, creativeModeTab);
|
||||
for (Object after : afterEntries)
|
||||
{
|
||||
ResourceLocation other = getCreativeModeTabName(after);
|
||||
edges.put(other, name);
|
||||
}
|
||||
for (Object before : beforeEntries)
|
||||
{
|
||||
ResourceLocation other = getCreativeModeTabName(before);
|
||||
edges.put(name, other);
|
||||
}
|
||||
}
|
||||
|
||||
private static ResourceLocation getCreativeModeTabName(Object entry)
|
||||
{
|
||||
if (entry instanceof String s)
|
||||
return new ResourceLocation(s);
|
||||
if (entry instanceof ResourceLocation rl)
|
||||
return rl;
|
||||
if (entry instanceof CreativeModeTab t)
|
||||
return Objects.requireNonNull(getName(t), "Can't have sorting dependencies for creative mode tabs not registered in the CreativeModeTabSortingRegistry");
|
||||
throw new IllegalStateException("Invalid object type passed into the CreativeModeTab dependencies " + entry.getClass());
|
||||
}
|
||||
|
||||
private static final BiMap<ResourceLocation, CreativeModeTab> creativeModeTabs = HashBiMap.create();
|
||||
private static final BiMap<ResourceLocation, CreativeModeTab> vanillaCreativeModeTabs = HashBiMap.create();
|
||||
private static final Multimap<ResourceLocation, ResourceLocation> edges = HashMultimap.create();
|
||||
private static final Multimap<ResourceLocation, ResourceLocation> vanillaEdges = HashMultimap.create();
|
||||
|
||||
static
|
||||
{
|
||||
final ResourceLocation buildingBlocks = new ResourceLocation("building_blocks");
|
||||
final ResourceLocation coloredBlocks = new ResourceLocation("colored_blocks");
|
||||
final ResourceLocation naturalBlocks = new ResourceLocation("natural_blocks");
|
||||
final ResourceLocation functionalBlocks = new ResourceLocation("functional_blocks");
|
||||
final ResourceLocation redstoneBlocks = new ResourceLocation("redstone_blocks");
|
||||
final ResourceLocation toolsAndUtilities = new ResourceLocation("tools_and_utilities");
|
||||
final ResourceLocation combat = new ResourceLocation("combat");
|
||||
final ResourceLocation foodAndDrinks = new ResourceLocation("food_and_drinks");
|
||||
final ResourceLocation ingredients = new ResourceLocation("ingredients");
|
||||
final ResourceLocation spawnEggs = new ResourceLocation("spawn_eggs");
|
||||
|
||||
processCreativeModeTab(CreativeModeTabs.BUILDING_BLOCKS, buildingBlocks, List.of(), List.of());
|
||||
processCreativeModeTab(CreativeModeTabs.COLORED_BLOCKS, coloredBlocks, List.of(buildingBlocks), List.of(naturalBlocks));
|
||||
processCreativeModeTab(CreativeModeTabs.NATURAL_BLOCKS, naturalBlocks, List.of(coloredBlocks), List.of(functionalBlocks));
|
||||
processCreativeModeTab(CreativeModeTabs.FUNCTIONAL_BLOCKS, functionalBlocks, List.of(naturalBlocks), List.of(redstoneBlocks));
|
||||
processCreativeModeTab(CreativeModeTabs.REDSTONE_BLOCKS, redstoneBlocks, List.of(functionalBlocks), List.of(toolsAndUtilities));
|
||||
processCreativeModeTab(CreativeModeTabs.TOOLS_AND_UTILITIES, toolsAndUtilities, List.of(redstoneBlocks), List.of(combat));
|
||||
processCreativeModeTab(CreativeModeTabs.COMBAT, combat, List.of(toolsAndUtilities), List.of(foodAndDrinks));
|
||||
processCreativeModeTab(CreativeModeTabs.FOOD_AND_DRINKS, foodAndDrinks, List.of(combat), List.of(ingredients));
|
||||
processCreativeModeTab(CreativeModeTabs.INGREDIENTS, ingredients, List.of(foodAndDrinks), List.of(spawnEggs));
|
||||
processCreativeModeTab(CreativeModeTabs.SPAWN_EGGS, spawnEggs, List.of(ingredients), List.of());
|
||||
|
||||
vanillaEdges.putAll(edges);
|
||||
vanillaCreativeModeTabs.putAll(creativeModeTabs);
|
||||
}
|
||||
|
||||
static PreparableReloadListener getReloadListener()
|
||||
{
|
||||
@@ -190,7 +136,7 @@ public final class CreativeModeTabRegistry
|
||||
customOrder.add(CreativeModeTab);
|
||||
}
|
||||
|
||||
List<CreativeModeTab> missingCreativeModeTabs = creativeModeTabs.values().stream().filter(CreativeModeTab -> !customOrder.contains(CreativeModeTab)).toList();
|
||||
List<CreativeModeTab> missingCreativeModeTabs = BuiltInRegistries.CREATIVE_MODE_TAB.stream().filter(CreativeModeTab -> !customOrder.contains(CreativeModeTab)).toList();
|
||||
if (!missingCreativeModeTabs.isEmpty())
|
||||
throw new IllegalStateException("CreativeModeTabs missing from the ordered list: " + missingCreativeModeTabs.stream()
|
||||
.map(CreativeModeTab -> Objects.toString(CreativeModeTabRegistry.getName(CreativeModeTab))).collect(Collectors.joining(", ")));
|
||||
@@ -214,13 +160,17 @@ public final class CreativeModeTabRegistry
|
||||
{
|
||||
final MutableGraph<CreativeModeTab> graph = GraphBuilder.directed().nodeOrder(ElementOrder.<CreativeModeTab>insertion()).build();
|
||||
|
||||
for (CreativeModeTab CreativeModeTab : creativeModeTabs.values())
|
||||
for (CreativeModeTab tab : BuiltInRegistries.CREATIVE_MODE_TAB)
|
||||
{
|
||||
graph.addNode(CreativeModeTab);
|
||||
if (!DEFAULT_TABS.contains(tab))
|
||||
graph.addNode(tab);
|
||||
}
|
||||
edges.forEach((key, value) -> {
|
||||
if (creativeModeTabs.containsKey(key) && creativeModeTabs.containsKey(value))
|
||||
graph.putEdge(creativeModeTabs.get(key), creativeModeTabs.get(value));
|
||||
edges.forEach((key, value) ->
|
||||
{
|
||||
final CreativeModeTab keyC = getTab(key);
|
||||
final CreativeModeTab valueC = getTab(value);
|
||||
if (keyC != null && valueC != null)
|
||||
graph.putEdge(keyC, valueC);
|
||||
});
|
||||
List<CreativeModeTab> tierList = TopologicalSort.topologicalSort(graph, null);
|
||||
|
||||
@@ -229,7 +179,8 @@ public final class CreativeModeTabRegistry
|
||||
|
||||
private static void setCreativeModeTabOrder(List<CreativeModeTab> tierList)
|
||||
{
|
||||
runInServerThreadIfPossible(hasServer -> {
|
||||
runInServerThreadIfPossible(hasServer ->
|
||||
{
|
||||
SORTED_TABS.clear();
|
||||
SORTED_TABS.addAll(tierList);
|
||||
});
|
||||
@@ -245,15 +196,53 @@ public final class CreativeModeTabRegistry
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void fireCollectionEvent()
|
||||
public static void sortTabs()
|
||||
{
|
||||
edges.clear();
|
||||
edges.putAll(vanillaEdges);
|
||||
|
||||
creativeModeTabs.clear();
|
||||
creativeModeTabs.putAll(vanillaCreativeModeTabs);
|
||||
DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.HOTBAR));
|
||||
DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.SEARCH));
|
||||
DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.OP_BLOCKS));
|
||||
DEFAULT_TABS.add(BuiltInRegistries.CREATIVE_MODE_TAB.get(CreativeModeTabs.INVENTORY));
|
||||
|
||||
ModLoader.get().postEvent(new CreativeModeTabEvent.Register(CreativeModeTabRegistry::registerCreativeModeTab));
|
||||
final List<Holder<CreativeModeTab>> indexed = new ArrayList<>();
|
||||
BuiltInRegistries.CREATIVE_MODE_TAB.holders().filter(c -> !DEFAULT_TABS.contains(c.get())).forEach(indexed::add);
|
||||
for (int i = 0; i < 10; i++) // Vanilla ordering
|
||||
{
|
||||
final Holder<CreativeModeTab> value = indexed.get(i);
|
||||
final CreativeModeTab tab = value.get();
|
||||
final ResourceLocation name = value.unwrapKey().orElseThrow().location();
|
||||
|
||||
final boolean specifiesOrder = !tab.tabsBefore.isEmpty() || !tab.tabsAfter.isEmpty();
|
||||
for (final ResourceLocation after : tab.tabsAfter.isEmpty() ? (i + 1 == indexed.size() || specifiesOrder ?
|
||||
List.<ResourceLocation>of() : List.of(indexed.get(i + 1).unwrapKey().orElseThrow().location())) : tab.tabsAfter)
|
||||
{
|
||||
edges.put(name, after);
|
||||
}
|
||||
|
||||
for (final ResourceLocation before : tab.tabsBefore.isEmpty() ? (i == 0 || specifiesOrder ?
|
||||
List.<ResourceLocation>of() : List.of(indexed.get(i - 1).unwrapKey().orElseThrow().location())) : tab.tabsBefore)
|
||||
{
|
||||
edges.put(before, name);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 10; i < indexed.size(); i++)
|
||||
{
|
||||
final Holder<CreativeModeTab> value = indexed.get(i);
|
||||
final CreativeModeTab tab = value.get();
|
||||
final ResourceLocation name = value.unwrapKey().orElseThrow().location();
|
||||
|
||||
for (final ResourceLocation after : tab.tabsAfter)
|
||||
{
|
||||
edges.put(name, after);
|
||||
}
|
||||
|
||||
for (final ResourceLocation before : tab.tabsBefore)
|
||||
{
|
||||
edges.put(before, name);
|
||||
}
|
||||
}
|
||||
|
||||
recalculateItemCreativeModeTabs();
|
||||
|
||||
@@ -261,22 +250,4 @@ public final class CreativeModeTabRegistry
|
||||
CreativeModeTabSearchRegistry.createSearchTrees();
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
private static CreativeModeTab registerCreativeModeTab(Consumer<CreativeModeTab.Builder> configurator, ResourceLocation name, List<Object> afterEntries, List<Object> beforeEntries)
|
||||
{
|
||||
if (creativeModeTabs.containsKey(name))
|
||||
throw new IllegalStateException("Duplicate creative mode tab with name: " + name);
|
||||
|
||||
// The initial values for the builder do not matter
|
||||
CreativeModeTab.Builder builder = new CreativeModeTab.Builder(CreativeModeTab.Row.TOP, 0);
|
||||
configurator.accept(builder);
|
||||
CreativeModeTab creativeModeTab = builder.build();
|
||||
|
||||
if (creativeModeTab.isAlignedRight())
|
||||
throw new IllegalStateException("CreativeModeTab " + name + " is aligned right, this is not supported!");
|
||||
|
||||
processCreativeModeTab(creativeModeTab, name, afterEntries, beforeEntries);
|
||||
|
||||
return creativeModeTab;
|
||||
}
|
||||
}
|
||||
@@ -77,36 +77,11 @@ public class ForgeConfig {
|
||||
* General configuration that doesn't need to be synchronized but needs to be available before server startup
|
||||
*/
|
||||
public static class Common {
|
||||
@Deprecated(since = "1.19.2", forRemoval = true)
|
||||
public final BooleanValue cachePackAccess;
|
||||
@Deprecated(since = "1.19.2", forRemoval = true)
|
||||
public final BooleanValue indexVanillaPackCachesOnThread;
|
||||
@Deprecated(since = "1.19.2", forRemoval = true)
|
||||
public final BooleanValue indexModPackCachesOnThread;
|
||||
|
||||
Common(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("[DEPRECATED / NO EFFECT]: General configuration settings")
|
||||
.push("general");
|
||||
|
||||
cachePackAccess = builder
|
||||
.comment("[DEPRECATED / NO EFFECT] [NOW IN RESOURCE-CACHING CONFIG]: Set this to true to cache resource listings in resource and data packs")
|
||||
.translation("forge.configgui.cachePackAccess")
|
||||
.worldRestart()
|
||||
.define("cachePackAccess", true);
|
||||
|
||||
indexVanillaPackCachesOnThread = builder
|
||||
.comment("[DEPRECATED / NO EFFECT] [NOW IN RESOURCE-CACHING CONFIG]: Set this to true to index vanilla resource and data packs on thread")
|
||||
.translation("forge.configgui.indexVanillaPackCachesOnThread")
|
||||
.worldRestart()
|
||||
.define("indexVanillaPackCachesOnThread", false);
|
||||
|
||||
indexModPackCachesOnThread = builder
|
||||
.comment("[DEPRECATED / NO EFFECT] [NOW IN RESOURCE-CACHING CONFIG]: Set this to true to index mod resource and data packs on thread")
|
||||
.translation("forge.configgui.indexModPackCachesOnThread")
|
||||
.worldRestart()
|
||||
.define("indexModPackCachesOnThread", false);
|
||||
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -30,7 +28,6 @@ import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Queues;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -40,7 +37,6 @@ import com.mojang.serialization.Lifecycle;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
@@ -59,6 +55,8 @@ import net.minecraft.network.chat.contents.LiteralContents;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.TagEntry;
|
||||
import net.minecraft.tags.TagKey;
|
||||
@@ -74,8 +72,6 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
@@ -96,7 +92,6 @@ import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.WorldData;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
@@ -114,7 +109,6 @@ import net.minecraft.world.item.alchemy.Potion;
|
||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.level.BaseSpawner;
|
||||
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
@@ -158,11 +152,9 @@ import net.minecraftforge.event.entity.living.LivingChangeTargetEvent.ILivingTar
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingKnockBackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingUseTotemEvent;
|
||||
import net.minecraftforge.event.entity.living.LootingLevelEvent;
|
||||
import net.minecraftforge.event.entity.living.ShieldBlockEvent;
|
||||
import net.minecraftforge.event.entity.player.AdvancementEvent;
|
||||
import net.minecraftforge.event.entity.player.AnvilRepairEvent;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.CriticalHitEvent;
|
||||
@@ -171,7 +163,6 @@ import net.minecraftforge.event.entity.living.LivingGetProjectileEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.event.level.NoteBlockEvent;
|
||||
import net.minecraftforge.eventbus.api.Event.Result;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
@@ -182,6 +173,7 @@ import net.minecraftforge.registries.GameData;
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
import net.minecraftforge.server.permission.PermissionAPI;
|
||||
|
||||
import org.apache.commons.lang3.function.TriFunction;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
@@ -193,7 +185,6 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
@@ -236,23 +227,6 @@ public class ForgeHooks
|
||||
MinecraftForge.EVENT_BUS.post(new DifficultyChangeEvent(difficulty, oldDifficulty));
|
||||
}
|
||||
|
||||
//Optifine Helper Functions u.u, these are here specifically for Optifine
|
||||
//Note: When using Optifine, these methods are invoked using reflection, which
|
||||
//incurs a major performance penalty.
|
||||
// TODO: Remove in 1.20
|
||||
@Deprecated(since = "1.19.2", forRemoval = true)
|
||||
public static void onLivingSetAttackTarget(LivingEntity entity, LivingEntity target)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
|
||||
}
|
||||
|
||||
// TODO: Remove in 1.20
|
||||
@Deprecated(since = "1.19.2", forRemoval = true)
|
||||
public static void onLivingSetAttackTarget(LivingEntity entity, LivingEntity target, ILivingTargetType targetType)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target, targetType));
|
||||
}
|
||||
|
||||
public static LivingChangeTargetEvent onLivingChangeTarget(LivingEntity entity, LivingEntity originalTarget, ILivingTargetType targetType)
|
||||
{
|
||||
LivingChangeTargetEvent event = new LivingChangeTargetEvent(entity, originalTarget, targetType);
|
||||
@@ -392,7 +366,7 @@ public class ForgeHooks
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return null;
|
||||
|
||||
if (!player.level.isClientSide)
|
||||
if (!player.level().isClientSide)
|
||||
player.getCommandSenderWorld().addFreshEntity(event.getEntity());
|
||||
return event.getEntity();
|
||||
}
|
||||
@@ -666,7 +640,7 @@ public class ForgeHooks
|
||||
|
||||
public static int onGrindstoneChange(@NotNull ItemStack top, @NotNull ItemStack bottom, Container outputSlot, int xp)
|
||||
{
|
||||
GrindstoneEvent.OnplaceItem e = new GrindstoneEvent.OnplaceItem(top, bottom, xp);
|
||||
GrindstoneEvent.OnPlaceItem e = new GrindstoneEvent.OnPlaceItem(top, bottom, xp);
|
||||
if (MinecraftForge.EVENT_BUS.post(e))
|
||||
{
|
||||
outputSlot.setItem(0, ItemStack.EMPTY);
|
||||
@@ -804,43 +778,38 @@ public class ForgeHooks
|
||||
return newGameType;
|
||||
}
|
||||
|
||||
private static ThreadLocal<Deque<LootTableContext>> lootContext = new ThreadLocal<Deque<LootTableContext>>();
|
||||
private static LootTableContext getLootTableContext()
|
||||
public static TriFunction<ResourceLocation, JsonElement, ResourceManager, Optional<LootTable>> getLootTableDeserializer(Gson gson, String directory)
|
||||
{
|
||||
LootTableContext ctx = lootContext.get().peek();
|
||||
|
||||
if (ctx == null)
|
||||
throw new JsonParseException("Invalid call stack, could not grab json context!"); // Should I throw this? Do we care about custom deserializers outside the manager?
|
||||
|
||||
return ctx;
|
||||
return (location, data, resourceManager) -> {
|
||||
try
|
||||
{
|
||||
Resource resource = resourceManager.getResource(location.withPath(directory + "/" + location.getPath() + ".json")).orElse(null);
|
||||
boolean custom = resource == null || !resource.isBuiltin();
|
||||
return Optional.ofNullable(loadLootTable(gson, location, data, custom));
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LOGGER.error("Couldn't parse element {}:{}", directory, location, exception);
|
||||
return Optional.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LootTable loadLootTable(Gson gson, ResourceLocation name, JsonElement data, boolean custom, LootTables lootTableManager)
|
||||
public static LootTable loadLootTable(Gson gson, ResourceLocation name, JsonElement data, boolean custom)
|
||||
{
|
||||
Deque<LootTableContext> que = lootContext.get();
|
||||
if (que == null)
|
||||
{
|
||||
que = Queues.newArrayDeque();
|
||||
lootContext.set(que);
|
||||
}
|
||||
|
||||
LootTable ret = null;
|
||||
LootTable ret;
|
||||
try
|
||||
{
|
||||
que.push(new LootTableContext(name, custom));
|
||||
ret = gson.fromJson(data, LootTable.class);
|
||||
ret.setLootTableId(name);
|
||||
que.pop();
|
||||
}
|
||||
catch (JsonParseException e)
|
||||
{
|
||||
que.pop();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (!custom)
|
||||
ret = ForgeEventFactory.loadLootTable(name, ret, lootTableManager);
|
||||
ret = ForgeEventFactory.loadLootTable(name, ret);
|
||||
|
||||
if (ret != null)
|
||||
ret.freeze();
|
||||
@@ -892,91 +861,6 @@ public class ForgeHooks
|
||||
Biome apply(final Biome.ClimateSettings climate, final BiomeSpecialEffects effects, final BiomeGenerationSettings gen, final MobSpawnSettings spawns);
|
||||
}
|
||||
|
||||
private static class LootTableContext
|
||||
{
|
||||
public final ResourceLocation name;
|
||||
private final boolean vanilla;
|
||||
public final boolean custom;
|
||||
public int poolCount = 0;
|
||||
public int entryCount = 0;
|
||||
private HashSet<String> entryNames = Sets.newHashSet();
|
||||
|
||||
private LootTableContext(ResourceLocation name, boolean custom)
|
||||
{
|
||||
this.name = name;
|
||||
this.custom = custom;
|
||||
this.vanilla = "minecraft".equals(this.name.getNamespace());
|
||||
}
|
||||
|
||||
private void resetPoolCtx()
|
||||
{
|
||||
this.entryCount = 0;
|
||||
this.entryNames.clear();
|
||||
}
|
||||
|
||||
public String validateEntryName(@Nullable String name)
|
||||
{
|
||||
if (name != null && !this.entryNames.contains(name))
|
||||
{
|
||||
this.entryNames.add(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
if (!this.vanilla)
|
||||
throw new JsonParseException("Loot Table \"" + this.name.toString() + "\" Duplicate entry name \"" + name + "\" for pool #" + (this.poolCount - 1) + " entry #" + (this.entryCount-1));
|
||||
|
||||
int x = 0;
|
||||
while (this.entryNames.contains(name + "#" + x))
|
||||
x++;
|
||||
|
||||
name = name + "#" + x;
|
||||
this.entryNames.add(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static String readPoolName(JsonObject json)
|
||||
{
|
||||
LootTableContext ctx = ForgeHooks.getLootTableContext();
|
||||
ctx.resetPoolCtx();
|
||||
|
||||
if (json.has("name"))
|
||||
return GsonHelper.getAsString(json, "name");
|
||||
|
||||
if (ctx.custom)
|
||||
return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!
|
||||
|
||||
ctx.poolCount++;
|
||||
|
||||
if (!ctx.vanilla)
|
||||
throw new JsonParseException("Loot Table \"" + ctx.name.toString() + "\" Missing `name` entry for pool #" + (ctx.poolCount - 1));
|
||||
|
||||
return ctx.poolCount == 1 ? "main" : "pool" + (ctx.poolCount - 1);
|
||||
}
|
||||
|
||||
public static String readLootEntryName(JsonObject json, String type)
|
||||
{
|
||||
LootTableContext ctx = ForgeHooks.getLootTableContext();
|
||||
ctx.entryCount++;
|
||||
|
||||
if (json.has("entryName"))
|
||||
return ctx.validateEntryName(GsonHelper.getAsString(json, "entryName"));
|
||||
|
||||
if (ctx.custom)
|
||||
return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!
|
||||
|
||||
String name = null;
|
||||
if ("item".equals(type))
|
||||
name = GsonHelper.getAsString(json, "name");
|
||||
else if ("loot_table".equals(type))
|
||||
name = GsonHelper.getAsString(json, "name");
|
||||
else if ("empty".equals(type))
|
||||
name = "empty";
|
||||
|
||||
return ctx.validateEntryName(name);
|
||||
}
|
||||
|
||||
public static boolean onCropsGrowPre(Level level, BlockPos pos, BlockState state, boolean def)
|
||||
{
|
||||
BlockEvent ev = new BlockEvent.CropGrowEvent.Pre(level,pos,state);
|
||||
@@ -1001,15 +885,6 @@ public class ForgeHooks
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated See {@link ForgeEventFactory#onAdvancementEarnedEvent} and {@link ForgeEventFactory#onAdvancementProgressedEvent}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static void onAdvancement(ServerPlayer player, Advancement advancement)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new AdvancementEvent(player, advancement));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to fire {@link ItemAttributeModifierEvent}. Modders should use {@link ItemStack#getAttributeModifiers(EquipmentSlot)} instead.
|
||||
*/
|
||||
@@ -1306,21 +1181,12 @@ public class ForgeHooks
|
||||
levelTag.put("fml", fmlData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated To be removed in 1.20.
|
||||
* Use {@link #readAdditionalLevelSaveData(CompoundTag, LevelStorageSource.LevelDirectory)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static void readAdditionalLevelSaveData(CompoundTag rootTag) {
|
||||
readAdditionalLevelSaveData(rootTag, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rootTag Level data file contents.
|
||||
* @param levelDirectory Level currently being loaded. TODO 1.20 - Remove nullable annotation
|
||||
* @param levelDirectory Level currently being loaded.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static void readAdditionalLevelSaveData(CompoundTag rootTag, @Nullable LevelStorageSource.LevelDirectory levelDirectory)
|
||||
public static void readAdditionalLevelSaveData(CompoundTag rootTag, LevelStorageSource.LevelDirectory levelDirectory)
|
||||
{
|
||||
CompoundTag tag = rootTag.getCompound("fml");
|
||||
if (tag.contains("LoadingModList"))
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.commands.Commands;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
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.Ingredient;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
@@ -68,6 +69,7 @@ import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||
import net.minecraftforge.fml.*;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.*;
|
||||
import net.minecraftforge.forge.snapshots.ForgeSnapshotsMod;
|
||||
import net.minecraftforge.registries.*;
|
||||
import net.minecraftforge.registries.holdersets.AndHolderSet;
|
||||
import net.minecraftforge.registries.holdersets.AnyHolderSet;
|
||||
@@ -123,6 +125,7 @@ import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mod("forge")
|
||||
@@ -156,13 +159,6 @@ public class ForgeMod
|
||||
*/
|
||||
public static final RegistryObject<Attribute> BLOCK_REACH = ATTRIBUTES.register("block_reach", () -> new RangedAttribute("forge.block_reach", 4.5D, 0.0D, 1024.0D).setSyncable(true));
|
||||
|
||||
/**
|
||||
* TODO: Remove
|
||||
* @deprecated - use {@link #BLOCK_REACH}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public static final RegistryObject<Attribute> REACH_DISTANCE = BLOCK_REACH;
|
||||
|
||||
/**
|
||||
* Attack Range represents the distance at which a player may attack an entity. The default is 3 blocks. Players in creative mode have an additional 3 blocks of entity reach.
|
||||
* The default of 3.0 is technically considered a bug by Mojang - see MC-172289 and MC-92484. However, updating this value would allow for longer-range attacks on vanilla servers, which makes some people mad.
|
||||
@@ -172,13 +168,6 @@ public class ForgeMod
|
||||
*/
|
||||
public static final RegistryObject<Attribute> ENTITY_REACH = ATTRIBUTES.register("entity_reach", () -> new RangedAttribute("forge.entity_reach", 3.0D, 0.0D, 1024.0D).setSyncable(true));
|
||||
|
||||
/**
|
||||
* TODO: Remove
|
||||
* @deprecated - use {@link #ENTITY_REACH}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public static final RegistryObject<Attribute> ATTACK_RANGE = ENTITY_REACH;
|
||||
|
||||
/**
|
||||
* Step Height Addition modifies the amount of blocks an entity may walk up without jumping.
|
||||
* @see IForgeEntity#getStepHeight()
|
||||
@@ -371,7 +360,7 @@ public class ForgeMod
|
||||
@Override
|
||||
public double motionScale(Entity entity)
|
||||
{
|
||||
return entity.level.dimensionType().ultraWarm() ? 0.007D : 0.0023333333333333335D;
|
||||
return entity.level().dimensionType().ultraWarm() ? 0.007D : 0.0023333333333333335D;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -428,6 +417,7 @@ public class ForgeMod
|
||||
public ForgeMod()
|
||||
{
|
||||
LOGGER.info(FORGEMOD,"Forge mod loading, version {}, for MC {} with MCP {}", ForgeVersion.getVersion(), MCPVersion.getMCVersion(), MCPVersion.getMCPVersion());
|
||||
ForgeSnapshotsMod.logStartupWarning();
|
||||
INSTANCE = this;
|
||||
MinecraftForge.initialize();
|
||||
CrashReportCallables.registerCrashCallable("Crash Report UUID", ()-> {
|
||||
@@ -450,6 +440,7 @@ public class ForgeMod
|
||||
modEventBus.addListener(this::gatherData);
|
||||
modEventBus.addListener(this::loadComplete);
|
||||
modEventBus.addListener(this::registerFluids);
|
||||
modEventBus.addListener(this::registerVanillaDisplayContexts);
|
||||
modEventBus.addListener(this::registerRecipeSerializers);
|
||||
modEventBus.addListener(this::registerLootData);
|
||||
modEventBus.register(this);
|
||||
@@ -603,6 +594,20 @@ public class ForgeMod
|
||||
}
|
||||
}
|
||||
|
||||
public void registerVanillaDisplayContexts(RegisterEvent event)
|
||||
{
|
||||
if (event.getRegistryKey().equals(ForgeRegistries.Keys.DISPLAY_CONTEXTS))
|
||||
{
|
||||
IForgeRegistryInternal<ItemDisplayContext> forgeRegistry = (IForgeRegistryInternal<ItemDisplayContext>) event.<ItemDisplayContext>getForgeRegistry();
|
||||
if (forgeRegistry == null)
|
||||
throw new IllegalStateException("Item display context was not a forge registry, wtf???");
|
||||
|
||||
Arrays.stream(ItemDisplayContext.values())
|
||||
.filter(Predicate.not(ItemDisplayContext::isModded))
|
||||
.forEach(ctx -> forgeRegistry.register(ctx.getId(), new ResourceLocation("minecraft", ctx.getSerializedName()), ctx));
|
||||
}
|
||||
}
|
||||
|
||||
public void registerRecipeSerializers(RegisterEvent event)
|
||||
{
|
||||
if (event.getRegistryKey().equals(ForgeRegistries.Keys.RECIPE_SERIALIZERS))
|
||||
@@ -647,7 +652,7 @@ public class ForgeMod
|
||||
/**
|
||||
* TODO: Remove when {@link ForgeRegistry#addAlias(ResourceLocation, ResourceLocation)} is elevated to {@link IForgeRegistry}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.3")
|
||||
@Deprecated(forRemoval = true, since = "1.20")
|
||||
private static <T> void addAlias(IForgeRegistry<T> registry, ResourceLocation from, ResourceLocation to)
|
||||
{
|
||||
ForgeRegistry<T> fReg = (ForgeRegistry<T>) registry;
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
public interface IPlantable
|
||||
{
|
||||
default PlantType getPlantType(BlockGetter level, BlockPos pos) {
|
||||
if (this instanceof CropBlock) return PlantType.CROP;
|
||||
if (this instanceof CropBlock || this == Blocks.PITCHER_CROP) return PlantType.CROP;
|
||||
if (this instanceof SaplingBlock) return PlantType.PLAINS;
|
||||
if (this instanceof FlowerBlock) return PlantType.PLAINS;
|
||||
if (this == Blocks.DEAD_BUSH) return PlantType.DESERT;
|
||||
@@ -24,7 +24,7 @@ public interface IPlantable
|
||||
if (this == Blocks.RED_MUSHROOM) return PlantType.CAVE;
|
||||
if (this == Blocks.BROWN_MUSHROOM) return PlantType.CAVE;
|
||||
if (this == Blocks.NETHER_WART) return PlantType.NETHER;
|
||||
if (this == Blocks.TALL_GRASS) return PlantType.PLAINS;
|
||||
if (this == Blocks.TALL_GRASS) return PlantType.PLAINS;
|
||||
return net.minecraftforge.common.PlantType.PLAINS;
|
||||
}
|
||||
|
||||
|
||||
@@ -419,61 +419,6 @@ public class Tags
|
||||
* @see net.minecraftforge.common.ToolActions
|
||||
*/
|
||||
public static final TagKey<Item> TOOLS = tag("tools");
|
||||
/**
|
||||
* A tag containing all existing swords.
|
||||
*
|
||||
* Note: This tag is not an alternative or a substitute to {@link net.minecraftforge.common.ToolActions}.
|
||||
*
|
||||
* @see net.minecraftforge.common.ToolAction
|
||||
* @see net.minecraftforge.common.ToolActions
|
||||
* @deprecated Replaced by net.minecraft.tags.ItemTags#SWORDS
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
public static final TagKey<Item> TOOLS_SWORDS = tag("tools/swords");
|
||||
/**
|
||||
* A tag containing all existing axes.
|
||||
*
|
||||
* Note: This tag is not an alternative or a substitute to {@link net.minecraftforge.common.ToolActions}.
|
||||
*
|
||||
* @see net.minecraftforge.common.ToolAction
|
||||
* @see net.minecraftforge.common.ToolActions
|
||||
* @deprecated Replaced by net.minecraft.tags.ItemTags#AXES
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
public static final TagKey<Item> TOOLS_AXES = tag("tools/axes");
|
||||
/**
|
||||
* A tag containing all existing pickaxes.
|
||||
*
|
||||
* Note: This tag is not an alternative or a substitute to {@link net.minecraftforge.common.ToolActions}.
|
||||
*
|
||||
* @see net.minecraftforge.common.ToolAction
|
||||
* @see net.minecraftforge.common.ToolActions
|
||||
* @deprecated Replaced by net.minecraft.tags.ItemTags#PICKAXES
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
public static final TagKey<Item> TOOLS_PICKAXES = tag("tools/pickaxes");
|
||||
/**
|
||||
* A tag containing all existing shovels.
|
||||
*
|
||||
* Note: This tag is not an alternative or a substitute to {@link net.minecraftforge.common.ToolActions}.
|
||||
*
|
||||
* @see net.minecraftforge.common.ToolAction
|
||||
* @see net.minecraftforge.common.ToolActions
|
||||
* @deprecated Replaced by net.minecraft.tags.ItemTags#SHOVELS
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
public static final TagKey<Item> TOOLS_SHOVELS = tag("tools/shovels");
|
||||
/**
|
||||
* A tag containing all existing hoes.
|
||||
*
|
||||
* Note: This tag is not an alternative or a substitute to {@link net.minecraftforge.common.ToolActions}.
|
||||
*
|
||||
* @see net.minecraftforge.common.ToolAction
|
||||
* @see net.minecraftforge.common.ToolActions
|
||||
* @deprecated Replaced by net.minecraft.tags.ItemTags#HOES
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
public static final TagKey<Item> TOOLS_HOES = tag("tools/hoes");
|
||||
/**
|
||||
* A tag containing all existing shields.
|
||||
*
|
||||
|
||||
@@ -7,7 +7,6 @@ package net.minecraftforge.common.capabilities;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -16,6 +15,7 @@ import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class CraftingHelper
|
||||
return serializer.parse(buffer);
|
||||
}
|
||||
|
||||
public static Ingredient getIngredient(JsonElement json)
|
||||
public static Ingredient getIngredient(JsonElement json, boolean allowEmpty)
|
||||
{
|
||||
if (json == null || json.isJsonNull())
|
||||
throw new JsonSyntaxException("Json cannot be null");
|
||||
@@ -106,7 +106,7 @@ public class CraftingHelper
|
||||
List<Ingredient> vanilla = Lists.newArrayList();
|
||||
json.getAsJsonArray().forEach((ele) ->
|
||||
{
|
||||
Ingredient ing = CraftingHelper.getIngredient(ele);
|
||||
Ingredient ing = CraftingHelper.getIngredient(ele, allowEmpty);
|
||||
|
||||
if (ing.getClass() == Ingredient.class) //Vanilla, Due to how we read it splits each itemstack, so we pull out to re-merge later
|
||||
vanilla.add(ing);
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
@@ -36,6 +35,7 @@ import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
import net.minecraftforge.resource.ResourcePackLoader;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Enables data providers to check if other data files currently exist. The
|
||||
@@ -226,13 +226,18 @@ public class ExistingFileHelper {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public Resource getResource(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) throws IOException {
|
||||
public Resource getResource(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) throws FileNotFoundException {
|
||||
return getResource(getLocation(loc, pathSuffix, pathPrefix), packType);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public Resource getResource(ResourceLocation loc, PackType packType) throws IOException {
|
||||
return getManager(packType).getResource(loc).orElseThrow();
|
||||
public Resource getResource(ResourceLocation loc, PackType packType) throws FileNotFoundException {
|
||||
return getManager(packType).getResourceOrThrow(loc);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public List<Resource> getResourceStack(ResourceLocation loc, PackType packType) {
|
||||
return getManager(packType).getResourceStack(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class ForgeBlockTagsProvider extends BlockTagsProvider
|
||||
tag(END_STONES).add(Blocks.END_STONE);
|
||||
tag(ENDERMAN_PLACE_ON_BLACKLIST);
|
||||
tag(FENCE_GATES).addTags(FENCE_GATES_WOODEN);
|
||||
tag(FENCE_GATES_WOODEN).add(Blocks.OAK_FENCE_GATE, Blocks.SPRUCE_FENCE_GATE, Blocks.BIRCH_FENCE_GATE, Blocks.JUNGLE_FENCE_GATE, Blocks.ACACIA_FENCE_GATE, Blocks.DARK_OAK_FENCE_GATE, Blocks.CRIMSON_FENCE_GATE, Blocks.WARPED_FENCE_GATE, Blocks.MANGROVE_FENCE_GATE);
|
||||
tag(FENCE_GATES_WOODEN).add(Blocks.OAK_FENCE_GATE, Blocks.SPRUCE_FENCE_GATE, Blocks.BIRCH_FENCE_GATE, Blocks.JUNGLE_FENCE_GATE, Blocks.ACACIA_FENCE_GATE, Blocks.DARK_OAK_FENCE_GATE, Blocks.CRIMSON_FENCE_GATE, Blocks.WARPED_FENCE_GATE, Blocks.MANGROVE_FENCE_GATE, Blocks.BAMBOO_FENCE_GATE, Blocks.CHERRY_FENCE_GATE);
|
||||
tag(FENCES).addTags(FENCES_NETHER_BRICK, FENCES_WOODEN);
|
||||
tag(FENCES_NETHER_BRICK).add(Blocks.NETHER_BRICK_FENCE);
|
||||
tag(FENCES_WOODEN).addTag(BlockTags.WOODEN_FENCES);
|
||||
|
||||
@@ -156,18 +156,12 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_RAW_IRON, Tags.Items.STORAGE_BLOCKS_RAW_IRON);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_NETHERITE, Tags.Items.STORAGE_BLOCKS_NETHERITE);
|
||||
tag(Tags.Items.STRING).add(Items.STRING);
|
||||
tag(Tags.Items.TOOLS_SWORDS).add(Items.WOODEN_SWORD, Items.STONE_SWORD, Items.IRON_SWORD, Items.GOLDEN_SWORD, Items.DIAMOND_SWORD, Items.NETHERITE_SWORD).addTags(ItemTags.SWORDS);
|
||||
tag(Tags.Items.TOOLS_AXES).add(Items.WOODEN_AXE, Items.STONE_AXE, Items.IRON_AXE, Items.GOLDEN_AXE, Items.DIAMOND_AXE, Items.NETHERITE_AXE).addTags(ItemTags.AXES);
|
||||
tag(Tags.Items.TOOLS_PICKAXES).add(Items.WOODEN_PICKAXE, Items.STONE_PICKAXE, Items.IRON_PICKAXE, Items.GOLDEN_PICKAXE, Items.DIAMOND_PICKAXE, Items.NETHERITE_PICKAXE).addTags(ItemTags.PICKAXES);
|
||||
tag(Tags.Items.TOOLS_SHOVELS).add(Items.WOODEN_SHOVEL, Items.STONE_SHOVEL, Items.IRON_SHOVEL, Items.GOLDEN_SHOVEL, Items.DIAMOND_SHOVEL, Items.NETHERITE_SHOVEL).addTags(ItemTags.SHOVELS);
|
||||
tag(Tags.Items.TOOLS_HOES).add(Items.WOODEN_HOE, Items.STONE_HOE, Items.IRON_HOE, Items.GOLDEN_HOE, Items.DIAMOND_HOE, Items.NETHERITE_HOE).addTags(ItemTags.HOES);
|
||||
tag(Tags.Items.TOOLS_SHIELDS).add(Items.SHIELD);
|
||||
tag(Tags.Items.TOOLS_BOWS).add(Items.BOW);
|
||||
tag(Tags.Items.TOOLS_CROSSBOWS).add(Items.CROSSBOW);
|
||||
tag(Tags.Items.TOOLS_FISHING_RODS).add(Items.FISHING_ROD);
|
||||
tag(Tags.Items.TOOLS_TRIDENTS).add(Items.TRIDENT);
|
||||
tag(Tags.Items.TOOLS)
|
||||
.addTags(Tags.Items.TOOLS_SWORDS, Tags.Items.TOOLS_AXES, Tags.Items.TOOLS_PICKAXES, Tags.Items.TOOLS_SHOVELS, Tags.Items.TOOLS_HOES) // TODO: Since: 1.20, remove this line vanilla added these tags in 1.19.4
|
||||
.addTags(ItemTags.SWORDS, ItemTags.AXES, ItemTags.PICKAXES, ItemTags.SHOVELS, ItemTags.HOES)
|
||||
.addTags(Tags.Items.TOOLS_SHIELDS, Tags.Items.TOOLS_BOWS, Tags.Items.TOOLS_CROSSBOWS, Tags.Items.TOOLS_FISHING_RODS, Tags.Items.TOOLS_TRIDENTS);
|
||||
tag(Tags.Items.ARMORS_HELMETS).add(Items.LEATHER_HELMET, Items.TURTLE_HELMET, Items.CHAINMAIL_HELMET, Items.IRON_HELMET, Items.GOLDEN_HELMET, Items.DIAMOND_HELMET, Items.NETHERITE_HELMET);
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.data.loot.packs.VanillaLootTableProvider;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.storage.loot.predicates.AlternativeLootItemCondition;
|
||||
import net.minecraft.world.level.storage.loot.predicates.CompositeLootItemCondition;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition;
|
||||
import net.minecraft.world.level.storage.loot.predicates.MatchTool;
|
||||
@@ -114,7 +114,7 @@ public final class ForgeLootTableProvider extends LootTableProvider {
|
||||
if (invLootCondition instanceof MatchTool && checkMatchTool((MatchTool) invLootCondition, from)) {
|
||||
lootConditions[i] = InvertedLootItemCondition.invert(CanToolPerformAction.canToolPerformAction(toolAction)).build();
|
||||
found = true;
|
||||
} else if (invLootCondition instanceof AlternativeLootItemCondition && findAndReplaceInAlternative((AlternativeLootItemCondition) invLootCondition, from, toolAction)) {
|
||||
} else if (invLootCondition instanceof CompositeLootItemCondition compositeLootItemCondition && findAndReplaceInComposite(compositeLootItemCondition, from, toolAction)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public final class ForgeLootTableProvider extends LootTableProvider {
|
||||
}
|
||||
|
||||
for (int i = 0; i < lootConditions.length; i++) {
|
||||
if (lootConditions[i] instanceof AlternativeLootItemCondition && findAndReplaceInAlternative((AlternativeLootItemCondition) lootConditions[i], from, toolAction)) {
|
||||
if (lootConditions[i] instanceof CompositeLootItemCondition composite && findAndReplaceInComposite(composite, from, toolAction)) {
|
||||
found = true;
|
||||
} else if (lootConditions[i] instanceof MatchTool && checkMatchTool((MatchTool) lootConditions[i], from)) {
|
||||
lootConditions[i] = CanToolPerformAction.canToolPerformAction(toolAction).build();
|
||||
@@ -160,12 +160,12 @@ public final class ForgeLootTableProvider extends LootTableProvider {
|
||||
return found;
|
||||
}
|
||||
|
||||
private boolean findAndReplaceInAlternative(AlternativeLootItemCondition alternative, Item from, ToolAction toolAction) {
|
||||
LootItemCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(AlternativeLootItemCondition.class, alternative, "f_8146" + "8_");
|
||||
private boolean findAndReplaceInComposite(CompositeLootItemCondition alternative, Item from, ToolAction toolAction) {
|
||||
LootItemCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(CompositeLootItemCondition.class, alternative, "f_28560" + "9_");
|
||||
boolean found = false;
|
||||
|
||||
if (lootConditions == null) {
|
||||
throw new IllegalStateException(AlternativeLootItemCondition.class.getName() + " is missing field f_8146" + "8_");
|
||||
throw new IllegalStateException(CompositeLootItemCondition.class.getName() + " is missing field f_28560" + "9_");
|
||||
}
|
||||
|
||||
for (int i = 0; i < lootConditions.length; i++) {
|
||||
|
||||
@@ -5,12 +5,10 @@
|
||||
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
|
||||
public class VanillaSoundDefinitionsProvider extends SoundDefinitionsProvider {
|
||||
|
||||
public VanillaSoundDefinitionsProvider(PackOutput output, ExistingFileHelper helper) {
|
||||
super(output, "minecraft", helper);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface IForgeAbstractMinecart
|
||||
int y = Mth.floor(self().getY());
|
||||
int z = Mth.floor(self().getZ());
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
if (self().level.getBlockState(pos.below()).is(BlockTags.RAILS)) pos = pos.below();
|
||||
if (self().level().getBlockState(pos.below()).is(BlockTags.RAILS)) pos = pos.below();
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public interface IForgeAdvancementBuilder
|
||||
{
|
||||
if (fileHelper.exists(advancementId, PackType.SERVER_DATA, ".json", "advancements"))
|
||||
{
|
||||
return new Advancement(advancementId, null, null, AdvancementRewards.EMPTY, Maps.newHashMap(), null);
|
||||
return new Advancement(advancementId, null, null, AdvancementRewards.EMPTY, Maps.newHashMap(), new String[0][0], false);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -23,12 +23,13 @@ import net.minecraft.world.entity.projectile.FishingHook;
|
||||
import net.minecraft.world.entity.projectile.WitherSkull;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.SignalGetter;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -430,7 +431,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default float getEnchantPowerBonus(BlockState state, LevelReader level, BlockPos pos)
|
||||
{
|
||||
return state.is(Blocks.BOOKSHELF) ? 1: 0;
|
||||
return state.is(BlockTags.ENCHANTMENT_POWER_PROVIDER) ? 1: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,13 +443,13 @@ public interface IForgeBlock
|
||||
default void onNeighborChange(BlockState state, LevelReader level, BlockPos pos, BlockPos neighbor){}
|
||||
|
||||
/**
|
||||
* Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules.
|
||||
* Called to determine whether to allow the block to handle its own indirect power rather than using the default rules.
|
||||
* @param level The level
|
||||
* @param pos Block position in level
|
||||
* @param side The INPUT side of the block to be powered - ie the opposite of this block's output side
|
||||
* @return Whether Block#isProvidingWeakPower should be called when determining indirect power
|
||||
*/
|
||||
default boolean shouldCheckWeakPower(BlockState state, LevelReader level, BlockPos pos, Direction side)
|
||||
default boolean shouldCheckWeakPower(BlockState state, SignalGetter level, BlockPos pos, Direction side)
|
||||
{
|
||||
return state.isRedstoneConductor(level, pos);
|
||||
}
|
||||
@@ -606,7 +607,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Direction direction)
|
||||
{
|
||||
return state.getFlammability(level, pos, direction) > 0;
|
||||
return state.ignitedByLava() || state.getFlammability(level, pos, direction) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -911,14 +912,14 @@ public interface IForgeBlock
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link MaterialColor} shown on the map.
|
||||
* Returns the {@link MapColor} shown on the map.
|
||||
*
|
||||
* @param state The state of this block
|
||||
* @param level The level this block is in
|
||||
* @param pos The blocks position in the level
|
||||
* @param defaultColor The {@code MaterialColor} configured for the given {@code BlockState} in the {@link BlockBehaviour.Properties}
|
||||
* @param defaultColor The {@code MapColor} configured for the given {@code BlockState} in the {@link BlockBehaviour.Properties}
|
||||
*/
|
||||
default MaterialColor getMapColor(BlockState state, BlockGetter level, BlockPos pos, MaterialColor defaultColor)
|
||||
default MapColor getMapColor(BlockState state, BlockGetter level, BlockPos pos, MapColor defaultColor)
|
||||
{
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.FishingHook;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.SignalGetter;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -382,13 +383,13 @@ public interface IForgeBlockState
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules.
|
||||
* Called to determine whether to allow the block to handle its own indirect power rather than using the default rules.
|
||||
* @param level The level
|
||||
* @param pos Block position in level
|
||||
* @param side The INPUT side of the block to be powered - ie the opposite of this block's output side
|
||||
* @return Whether Block#isProvidingWeakPower should be called when determining indirect power
|
||||
*/
|
||||
default boolean shouldCheckWeakPower(LevelReader level, BlockPos pos, Direction side)
|
||||
default boolean shouldCheckWeakPower(SignalGetter level, BlockPos pos, Direction side)
|
||||
{
|
||||
return self().getBlock().shouldCheckWeakPower(self(), level, pos, side);
|
||||
}
|
||||
@@ -669,7 +670,7 @@ public interface IForgeBlockState
|
||||
*/
|
||||
default boolean isScaffolding(LivingEntity entity)
|
||||
{
|
||||
return self().getBlock().isScaffolding(self(), entity.level, entity.blockPosition(), entity);
|
||||
return self().getBlock().isScaffolding(self(), entity.level(), entity.blockPosition(), entity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -189,20 +189,6 @@ public interface IForgeItem
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each tick while using an item.
|
||||
*
|
||||
* @param stack The Item being used
|
||||
* @param player The Player using the item
|
||||
* @param count The amount of time in tick the item has been used for
|
||||
* continuously
|
||||
* @deprecated {@link net.minecraft.world.item.Item#onUseTick(Level, LivingEntity, ItemStack, int) Implement Vanilla's Version}
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
default void onUsingTick(ItemStack stack, LivingEntity player, int count)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an entity stops using an item for any reason, notably when selecting another item without releasing or finishing.
|
||||
* This method is called in addition to any other hooks called when an item is finished using; when another hook is also called it will be called before this method.
|
||||
@@ -595,7 +581,7 @@ public interface IForgeItem
|
||||
return true;
|
||||
|
||||
if (!newStack.isDamageableItem() || !oldStack.isDamageableItem())
|
||||
return !ItemStack.tagMatches(newStack, oldStack);
|
||||
return !ItemStack.isSameItemSameTags(newStack, oldStack);
|
||||
|
||||
CompoundTag newTag = newStack.getTag();
|
||||
CompoundTag oldTag = oldStack.getTag();
|
||||
@@ -628,7 +614,11 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean canContinueUsing(ItemStack oldStack, ItemStack newStack)
|
||||
{
|
||||
return ItemStack.isSame(oldStack, newStack);
|
||||
if (oldStack == newStack) {
|
||||
return true;
|
||||
} else {
|
||||
return !oldStack.isEmpty() && !newStack.isEmpty() && ItemStack.isSameItem(newStack, oldStack);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -862,7 +852,6 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean canGrindstoneRepair(ItemStack stack)
|
||||
{
|
||||
// TODO 1.20: Change to return false; this changes the default behavior for all items from opt-out to opt-in.
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/*
|
||||
* Extension added to ItemStack that bounces to ItemSack sensitive Item methods. Typically this is just for convince.
|
||||
@@ -86,7 +87,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundTag>
|
||||
Player entityplayer = context.getPlayer();
|
||||
BlockPos blockpos = context.getClickedPos();
|
||||
BlockInWorld blockworldstate = new BlockInWorld(context.getLevel(), blockpos, false);
|
||||
Registry<Block> registry = entityplayer.level.registryAccess().registryOrThrow(Registries.BLOCK);
|
||||
Registry<Block> registry = entityplayer.level().registryAccess().registryOrThrow(Registries.BLOCK);
|
||||
if (entityplayer != null && !entityplayer.getAbilities().mayBuild && !self().hasAdventureModePlaceTagForBlock(registry, blockworldstate)) {
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
@@ -243,21 +244,6 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundTag>
|
||||
return self().getItem().onEntitySwing(self(), entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each tick while using an item.
|
||||
*
|
||||
* @param player The Player using the item
|
||||
* @param count The amount of time in tick the item has been used for
|
||||
* continuously
|
||||
*
|
||||
* @deprecated {@link net.minecraft.world.item.ItemStack#onUseTick(Level, LivingEntity, int) Use Vanilla's Version}
|
||||
*/
|
||||
@Deprecated(since = "1.19.4", forRemoval = true)
|
||||
default void onUsingTick(LivingEntity player, int count)
|
||||
{
|
||||
self().getItem().onUsingTick(self(), player, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an entity stops using an item item for any reason.
|
||||
*
|
||||
@@ -444,7 +430,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundTag>
|
||||
return other.isEmpty();
|
||||
else
|
||||
return !other.isEmpty() && self().getCount() == other.getCount() && self().getItem() == other.getItem() &&
|
||||
(limitTags ? self().areShareTagsEqual(other) : ItemStack.tagMatches(self(), other));
|
||||
(limitTags ? self().areShareTagsEqual(other) : Objects.equals(self().getTag(), other.getTag()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface IForgeMobEffectInstance
|
||||
* @return true if the given ItemStack is in the list of curative items for this PotionEffect, false otherwise
|
||||
*/
|
||||
default boolean isCurativeItem(ItemStack stack) {
|
||||
return this.getCurativeItems().stream().anyMatch(e -> e.sameItem(stack));
|
||||
return this.getCurativeItems().stream().anyMatch(e -> ItemStack.isSameItem(e, stack));
|
||||
}
|
||||
|
||||
/***
|
||||
|
||||
@@ -32,15 +32,6 @@ public interface IForgePlayer
|
||||
return range == 0 ? 0 : range + (self().isCreative() ? 3 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getEntityReach()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
default double getAttackRange()
|
||||
{
|
||||
return this.getEntityReach();
|
||||
}
|
||||
|
||||
/**
|
||||
* The reach distance is increased by 0.5 for creative players, unless it is currently zero, which disables interactions.
|
||||
* @return The reach distance of this player.
|
||||
@@ -51,19 +42,10 @@ public interface IForgePlayer
|
||||
return reach == 0 ? 0 : reach + (self().isCreative() ? 0.5 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getBlockReach()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
default double getReachDistance()
|
||||
{
|
||||
return this.getBlockReach();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player can reach an entity by targeting the passed vector.<br>
|
||||
* On the server, additional padding is added to account for movement/lag.
|
||||
* @param vec The vector being range-checked.
|
||||
* @param entityHitVec The vector being range-checked.
|
||||
* @param padding Extra validation distance.
|
||||
* @return If the player can attack the entity.
|
||||
* @apiNote Do not use for block checks, as this method uses {@link #getEntityReach()}
|
||||
@@ -86,24 +68,6 @@ public interface IForgePlayer
|
||||
return isCloseEnough(entity, getEntityReach() + padding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #canReach(Entity, double)}h
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
default boolean canHit(Entity entity, double padding)
|
||||
{
|
||||
return canReach(entity, padding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #canReach(Entity, double)}h
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
default boolean canInteractWith(Entity entity, double padding)
|
||||
{
|
||||
return canReach(entity, padding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player can reach a block.<br>
|
||||
* On the server, additional padding is added to account for movement/lag.
|
||||
@@ -117,15 +81,6 @@ public interface IForgePlayer
|
||||
return self().getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) < reach * reach;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #canReach(BlockPos, double)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
default boolean canInteractWith(BlockPos pos, double padding)
|
||||
{
|
||||
return canReach(pos, padding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility check to see if the player is close enough to a target entity. Uses "eye-to-closest-corner" checks.
|
||||
* @param entity The entity being checked against
|
||||
|
||||
+1
-20
@@ -3,14 +3,11 @@
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.core.Direction;
|
||||
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
@@ -18,7 +15,6 @@ import org.joml.Vector4f;
|
||||
/**
|
||||
* Extension interface for {@link Transformation}.
|
||||
*/
|
||||
// TODO - 1.20: Transformation is not client-only, move this extension outside the client package
|
||||
public interface IForgeTransformation
|
||||
{
|
||||
private Transformation self()
|
||||
@@ -36,21 +32,6 @@ public interface IForgeTransformation
|
||||
return self().equals(Transformation.identity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes and applies this transformation to the pose stack. The effects of this method can be reversed by a
|
||||
* corresponding {@link PoseStack#popPose()}.
|
||||
*
|
||||
* @deprecated Use {@linkplain PoseStack#pushTransformation(Transformation)}, as {@linkplain Transformation} can be present in common code.
|
||||
*
|
||||
* @param stack the pose stack to modify
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT) // TODO - 1.20: Remove in favour of client-only PoseStack extension
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
default void push(PoseStack stack)
|
||||
{
|
||||
stack.pushTransformation(self());
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the position according to this transformation.
|
||||
*
|
||||
@@ -40,6 +40,6 @@ public class FakePlayerFactory
|
||||
|
||||
public static void unloadLevel(ServerLevel level)
|
||||
{
|
||||
fakePlayers.entrySet().removeIf(entry -> entry.getValue().level == level);
|
||||
fakePlayers.entrySet().removeIf(entry -> entry.getValue().level() == level);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package net.minecraftforge.common.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
@@ -44,7 +45,7 @@ public class SortedProperties extends Properties
|
||||
return Collections.enumeration(new TreeSet<>(super.keySet()));
|
||||
}
|
||||
|
||||
public static void store(Properties props, OutputStream stream, String comment) throws IOException
|
||||
public static void store(Properties props, Writer stream, String comment) throws IOException
|
||||
{
|
||||
SortedProperties sorted = new SortedProperties();
|
||||
sorted.putAll(props);
|
||||
|
||||
@@ -111,7 +111,7 @@ public class ModifiableBiomeInfo
|
||||
private MobSpawnSettingsBuilder mobSpawnSettings;
|
||||
|
||||
/**
|
||||
* @param biome A biome that has not had its modified biome data generated yet
|
||||
* @param original the biome to copy
|
||||
* @return A ModifiedBiomeInfo.Builder with a copy of the biome's data
|
||||
*/
|
||||
public static Builder copyOf(final BiomeInfo original)
|
||||
@@ -126,7 +126,7 @@ public class ModifiableBiomeInfo
|
||||
effectsBuilder,
|
||||
generationBuilder,
|
||||
mobSpawnBuilder
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
private Builder(final ClimateSettingsBuilder climateSettings, final BiomeSpecialEffectsBuilder effects, final BiomeGenerationSettingsBuilder generationSettings, final MobSpawnSettingsBuilder mobSpawnSettings)
|
||||
@@ -147,17 +147,6 @@ public class ModifiableBiomeInfo
|
||||
return climateSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return Builder for client special effects}
|
||||
*
|
||||
* @deprecated Use {@link #getSpecialEffects()} as it provides read access. TODO remove this by 1.20
|
||||
*/
|
||||
@Deprecated(forRemoval=true, since="1.19")
|
||||
public BiomeSpecialEffects.Builder getEffects()
|
||||
{
|
||||
return effects;
|
||||
}
|
||||
|
||||
public BiomeSpecialEffectsBuilder getSpecialEffects()
|
||||
{
|
||||
return effects;
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.energy;
|
||||
|
||||
import net.minecraftforge.common.capabilities.*;
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public class CapabilityEnergy
|
||||
{
|
||||
/**
|
||||
* @deprecated Create your own reference using {@link CapabilityManager#get(CapabilityToken)}, or use {@link ForgeCapabilities#ENERGY}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static final Capability<IEnergyStorage> ENERGY = ForgeCapabilities.ENERGY;
|
||||
public static void register(RegisterCapabilitiesEvent event){}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public abstract class PartEntity<T extends Entity> extends Entity {
|
||||
private final T parent;
|
||||
|
||||
public PartEntity(T parent) {
|
||||
super(parent.getType(), parent.level);
|
||||
super(parent.getType(), parent.level());
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.event;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.common.util.MutableHashedLinkedMap;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fired when the contents of a specific creative mode tab are being populated.
|
||||
* This event may be fired multiple times if the operator status of the local player or enabled feature flags changes.
|
||||
* <p>
|
||||
* This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* <p>
|
||||
* This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.
|
||||
*/
|
||||
public final class BuildCreativeModeTabContentsEvent extends Event implements IModBusEvent, CreativeModeTab.Output {
|
||||
private final CreativeModeTab tab;
|
||||
private final CreativeModeTab.ItemDisplayParameters parameters;
|
||||
private final MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> entries;
|
||||
private final ResourceKey<CreativeModeTab> tabKey;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BuildCreativeModeTabContentsEvent(CreativeModeTab tab, ResourceKey<CreativeModeTab> tabKey, CreativeModeTab.ItemDisplayParameters parameters, MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> entries) {
|
||||
this.tab = tab;
|
||||
this.tabKey = tabKey;
|
||||
this.parameters = parameters;
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the creative mode tab currently populating its contents}
|
||||
*/
|
||||
public CreativeModeTab getTab() {
|
||||
return this.tab;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the key of the creative mode tab currently populating its contents}
|
||||
*/
|
||||
public ResourceKey<CreativeModeTab> getTabKey() {
|
||||
return this.tabKey;
|
||||
}
|
||||
|
||||
public FeatureFlagSet getFlags() {
|
||||
return this.parameters.enabledFeatures();
|
||||
}
|
||||
|
||||
public CreativeModeTab.ItemDisplayParameters getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public boolean hasPermissions() {
|
||||
return this.parameters.hasPermissions();
|
||||
}
|
||||
|
||||
public MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> getEntries() {
|
||||
return this.entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ItemStack stack, CreativeModeTab.TabVisibility visibility) {
|
||||
getEntries().put(stack, visibility);
|
||||
}
|
||||
|
||||
public void accept(Supplier<? extends ItemLike> item, CreativeModeTab.TabVisibility visibility) {
|
||||
this.accept(item.get(), visibility);
|
||||
}
|
||||
|
||||
public void accept(Supplier<? extends ItemLike> item) {
|
||||
this.accept(item.get());
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.event;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTab.Output;
|
||||
import net.minecraft.world.item.CreativeModeTab.TabVisibility;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.common.util.MutableHashedLinkedMap;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CreativeModeTabEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private static final List<Object> DEFAULT_AFTER_ENTRIES = List.of(CreativeModeTabs.SPAWN_EGGS);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public CreativeModeTabEvent() {}
|
||||
|
||||
/**
|
||||
* A registrar which is capable of registering new tabs.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface Registrar {
|
||||
|
||||
/**
|
||||
* Register a new tab.
|
||||
*
|
||||
* @param configurator The tab configurator to register
|
||||
* @param name The name of the tab.
|
||||
* @param afters A list of tab names (String, ResourceLocations) or tabs that need to appear before this tab in the creative mode menu.
|
||||
* @param befores A list of tab names (String, ResourceLocations) or tabs that need to appear after this tab in the creative mode menu.
|
||||
* @return The configured tab.
|
||||
*/
|
||||
@NotNull
|
||||
CreativeModeTab registerCreativeModeTab(@NotNull final Consumer<CreativeModeTab.Builder> configurator, @NotNull final ResourceLocation name, @NotNull final List<Object> afters, @NotNull final List<Object> befores);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when creative mode tabs can be registered.
|
||||
* <p>
|
||||
* This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* <p>
|
||||
* This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* on both {@linkplain LogicalSide logical sides}.
|
||||
*/
|
||||
public static final class Register extends CreativeModeTabEvent
|
||||
{
|
||||
private final Registrar registrar;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Register(Registrar registrar) {
|
||||
this.registrar = registrar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers and configures a creative mode tab with the given name and returns the built instance.
|
||||
*
|
||||
* @param name the name of the tab. Must be unique.
|
||||
* @param beforeEntries the list of {@linkplain ResourceLocation tab names} or {@linkplain CreativeModeTab tabs} that should appear before this tab in the creative mode inventory screen
|
||||
* @param afterEntries the list of {@linkplain ResourceLocation tab names} or {@linkplain CreativeModeTab tabs} that should appear after this tab in the creative mode inventory screen
|
||||
* @param configurator the configurator which configures the builder
|
||||
* @return the configured creative mode tab
|
||||
* @see #registerCreativeModeTab(ResourceLocation, Consumer)
|
||||
*/
|
||||
public CreativeModeTab registerCreativeModeTab(ResourceLocation name, List<Object> beforeEntries, List<Object> afterEntries, Consumer<CreativeModeTab.Builder> configurator)
|
||||
{
|
||||
return registrar.registerCreativeModeTab(configurator, name, afterEntries, beforeEntries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers and configures a creative mode tab with the given name and returns the built instance.
|
||||
* The tab is sorted by default to be after {@link CreativeModeTabs#SPAWN_EGGS}.
|
||||
*
|
||||
* @param name the name of the tab. Must be unique.
|
||||
* @param configurator the configurator which configures the builder
|
||||
* @return the configured creative mode tab
|
||||
* @see #registerCreativeModeTab(ResourceLocation, List, List, Consumer)
|
||||
*/
|
||||
public CreativeModeTab registerCreativeModeTab(ResourceLocation name, Consumer<CreativeModeTab.Builder> configurator)
|
||||
{
|
||||
return registrar.registerCreativeModeTab(configurator, name, DEFAULT_AFTER_ENTRIES, List.of());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the contents of a specific creative mode tab are being populated.
|
||||
* This event may be fired multiple times if the operator status of the local player or enabled feature flags changes.
|
||||
* <p>
|
||||
* This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* <p>
|
||||
* This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.
|
||||
*/
|
||||
public static final class BuildContents extends CreativeModeTabEvent implements Output
|
||||
{
|
||||
private final CreativeModeTab tab;
|
||||
private final CreativeModeTab.ItemDisplayParameters parameters;
|
||||
private final MutableHashedLinkedMap<ItemStack, TabVisibility> entries;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BuildContents(CreativeModeTab tab, CreativeModeTab.ItemDisplayParameters parameters, MutableHashedLinkedMap<ItemStack, TabVisibility> entries)
|
||||
{
|
||||
this.tab = tab;
|
||||
this.parameters = parameters;
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the creative mode tab currently populating its contents}
|
||||
*/
|
||||
public CreativeModeTab getTab()
|
||||
{
|
||||
return this.tab;
|
||||
}
|
||||
|
||||
public FeatureFlagSet getFlags()
|
||||
{
|
||||
return this.parameters.enabledFeatures();
|
||||
}
|
||||
|
||||
public CreativeModeTab.ItemDisplayParameters getParameters()
|
||||
{
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public boolean hasPermissions()
|
||||
{
|
||||
return this.parameters.hasPermissions();
|
||||
}
|
||||
|
||||
public MutableHashedLinkedMap<ItemStack, TabVisibility> getEntries()
|
||||
{
|
||||
return this.entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ItemStack stack, TabVisibility visibility)
|
||||
{
|
||||
getEntries().put(stack, visibility);
|
||||
}
|
||||
|
||||
public void accept(Supplier<? extends ItemLike> item, CreativeModeTab.TabVisibility visibility)
|
||||
{
|
||||
this.accept(item.get(), visibility);
|
||||
}
|
||||
|
||||
public void accept(Supplier<? extends ItemLike> item)
|
||||
{
|
||||
this.accept(item.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,6 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
||||
import net.minecraft.world.level.BaseSpawner;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
@@ -75,7 +74,6 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -429,7 +427,7 @@ public class ForgeEventFactory
|
||||
public static int onItemExpire(ItemEntity entity, @NotNull ItemStack item)
|
||||
{
|
||||
if (item.isEmpty()) return -1;
|
||||
ItemExpireEvent event = new ItemExpireEvent(entity, (item.isEmpty() ? 6000 : item.getItem().getEntityLifespan(item, entity.level)));
|
||||
ItemExpireEvent event = new ItemExpireEvent(entity, (item.isEmpty() ? 6000 : item.getItem().getEntityLifespan(item, entity.level())));
|
||||
if (!MinecraftForge.EVENT_BUS.post(event)) return -1;
|
||||
return event.getExtraLife();
|
||||
}
|
||||
@@ -443,7 +441,7 @@ public class ForgeEventFactory
|
||||
|
||||
public static boolean canMountEntity(Entity entityMounting, Entity entityBeingMounted, boolean isMounting)
|
||||
{
|
||||
boolean isCanceled = MinecraftForge.EVENT_BUS.post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.level, isMounting));
|
||||
boolean isCanceled = MinecraftForge.EVENT_BUS.post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.level(), isMounting));
|
||||
|
||||
if(isCanceled)
|
||||
{
|
||||
@@ -579,8 +577,8 @@ public class ForgeEventFactory
|
||||
if (canContinueSleep == Result.DEFAULT)
|
||||
{
|
||||
return player.getSleepingPos().map(pos-> {
|
||||
BlockState state = player.level.getBlockState(pos);
|
||||
return state.getBlock().isBed(state, player.level, pos, player);
|
||||
BlockState state = player.level().getBlockState(pos);
|
||||
return state.getBlock().isBed(state, player.level(), pos, player);
|
||||
}).orElse(false);
|
||||
}
|
||||
else
|
||||
@@ -594,7 +592,7 @@ public class ForgeEventFactory
|
||||
|
||||
Result canContinueSleep = evt.getResult();
|
||||
if (canContinueSleep == Result.DEFAULT)
|
||||
return !player.level.isDay();
|
||||
return !player.level().isDay();
|
||||
else
|
||||
return canContinueSleep == Result.ALLOW;
|
||||
}
|
||||
@@ -620,9 +618,9 @@ public class ForgeEventFactory
|
||||
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent(projectile, ray));
|
||||
}
|
||||
|
||||
public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTables lootTableManager)
|
||||
public static LootTable loadLootTable(ResourceLocation name, LootTable table)
|
||||
{
|
||||
LootTableLoadEvent event = new LootTableLoadEvent(name, table, lootTableManager);
|
||||
LootTableLoadEvent event = new LootTableLoadEvent(name, table);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return LootTable.EMPTY;
|
||||
return event.getTable();
|
||||
@@ -667,12 +665,6 @@ public class ForgeEventFactory
|
||||
return result == Result.DEFAULT ? level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) : result == Result.ALLOW;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static boolean saplingGrowTree(LevelAccessor level, RandomSource randomSource, BlockPos pos)
|
||||
{
|
||||
return !blockGrowFeature(level, randomSource, pos, null).getResult().equals(Result.DENY);
|
||||
}
|
||||
|
||||
public static SaplingGrowTreeEvent blockGrowFeature(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder<ConfiguredFeature<?, ?>> holder)
|
||||
{
|
||||
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(level, randomSource, pos, holder);
|
||||
@@ -771,18 +763,8 @@ public class ForgeEventFactory
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@linkplain #onEnderPearlLand(ServerPlayer, double, double, double, ThrownEnderpearl, float, HitResult) the hit result-sensitive version}.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage)
|
||||
{
|
||||
return onEnderPearlLand(entity, targetX, targetY, targetZ, pearlEntity, attackDamage, null);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal // TODO - 1.20: remove the nullable
|
||||
public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, @Nullable HitResult hitResult)
|
||||
public static EntityTeleportEvent.EnderPearl onEnderPearlLand(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, HitResult hitResult)
|
||||
{
|
||||
EntityTeleportEvent.EnderPearl event = new EntityTeleportEvent.EnderPearl(entity, targetX, targetY, targetZ, pearlEntity, attackDamage, hitResult);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
@@ -60,7 +60,7 @@ public abstract class GrindstoneEvent extends Event
|
||||
|
||||
/**
|
||||
* This event is {@link Cancelable} <br>
|
||||
* {@link OnplaceItem} is fired when the inputs to a grindstone are changed. <br>
|
||||
* {@link OnPlaceItem} is fired when the inputs to a grindstone are changed. <br>
|
||||
*
|
||||
* The following rules apply:
|
||||
* <ul>
|
||||
@@ -79,11 +79,11 @@ public abstract class GrindstoneEvent extends Event
|
||||
* </ul>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class OnplaceItem extends GrindstoneEvent
|
||||
public static class OnPlaceItem extends GrindstoneEvent
|
||||
{
|
||||
private ItemStack output;
|
||||
|
||||
public OnplaceItem(ItemStack top, ItemStack bottom, int xp)
|
||||
public OnPlaceItem(ItemStack top, ItemStack bottom, int xp)
|
||||
{
|
||||
super(top, bottom, xp);
|
||||
this.output = ItemStack.EMPTY;
|
||||
|
||||
@@ -7,31 +7,32 @@ package net.minecraftforge.event;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Event fired when a LootTable json is loaded from json.
|
||||
* This event is fired whenever resources are loaded, or when the server starts.
|
||||
* This event will NOT be fired for LootTables loaded from the world folder, these are
|
||||
* considered configurations files and should not be modified by mods.
|
||||
* Fired when a {@link LootTable} is loaded from JSON.
|
||||
* Loot tables loaded from world save datapacks will not fire this event as they are considered user configuration files.
|
||||
* This event is fired whenever server resources are loaded or reloaded.
|
||||
*
|
||||
* Canceling the event will make it load a empty loot table.
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the loot table will be made empty.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#SERVER logical server}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public class LootTableLoadEvent extends Event
|
||||
{
|
||||
private final ResourceLocation name;
|
||||
private LootTable table;
|
||||
private LootTables lootTableManager;
|
||||
|
||||
public LootTableLoadEvent(ResourceLocation name, LootTable table, LootTables lootTableManager)
|
||||
public LootTableLoadEvent(ResourceLocation name, LootTable table)
|
||||
{
|
||||
this.name = name;
|
||||
this.table = table;
|
||||
this.lootTableManager = lootTableManager;
|
||||
}
|
||||
|
||||
public ResourceLocation getName()
|
||||
@@ -44,11 +45,6 @@ public class LootTableLoadEvent extends Event
|
||||
return this.table;
|
||||
}
|
||||
|
||||
public LootTables getLootTableManager()
|
||||
{
|
||||
return this.lootTableManager;
|
||||
}
|
||||
|
||||
public void setTable(LootTable table)
|
||||
{
|
||||
this.table = table;
|
||||
|
||||
@@ -45,7 +45,6 @@ public class ModMismatchEvent extends Event implements IModBusEvent
|
||||
* The level being loaded. Useful for things like {@link net.minecraft.world.level.storage.DimensionDataStorage}
|
||||
* to manage multiple files changing between mod versions.
|
||||
*/
|
||||
@Nullable
|
||||
private final LevelStorageSource.LevelDirectory levelDirectory;
|
||||
|
||||
/**
|
||||
@@ -59,7 +58,7 @@ public class ModMismatchEvent extends Event implements IModBusEvent
|
||||
private final HashMap<String, ModContainer> resolved;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ModMismatchEvent(@Nullable LevelStorageSource.LevelDirectory levelDirectory, Map<String, ArtifactVersion> previousVersions, Map<String, ArtifactVersion> missingVersions)
|
||||
public ModMismatchEvent(LevelStorageSource.LevelDirectory levelDirectory, Map<String, ArtifactVersion> previousVersions, Map<String, ArtifactVersion> missingVersions)
|
||||
{
|
||||
this.levelDirectory = levelDirectory;
|
||||
this.resolved = new HashMap<>(previousVersions.size());
|
||||
@@ -77,7 +76,6 @@ public class ModMismatchEvent extends Event implements IModBusEvent
|
||||
* Gets the current level directory for the world being loaded.
|
||||
* Can be used for file operations and manual modification of mod files before world load.
|
||||
*/
|
||||
@Nullable
|
||||
public LevelStorageSource.LevelDirectory getLevelDirectory()
|
||||
{
|
||||
return this.levelDirectory;
|
||||
|
||||
@@ -168,7 +168,7 @@ public class PlayLevelSoundEvent extends Event
|
||||
|
||||
public AtEntity(Entity entity, Holder<SoundEvent> sound, SoundSource source, float volume, float pitch)
|
||||
{
|
||||
super(entity.level, sound, source, volume, pitch);
|
||||
super(entity.level(), sound, source, volume, pitch);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -153,11 +153,10 @@ public class EntityTeleportEvent extends EntityEvent
|
||||
private final ServerPlayer player;
|
||||
private final ThrownEnderpearl pearlEntity;
|
||||
private float attackDamage;
|
||||
@Nullable
|
||||
private final HitResult hitResult; // TODO - 1.20: make the hit result nonnull, remove the other constructor
|
||||
private final HitResult hitResult;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EnderPearl(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, @Nullable HitResult hitResult)
|
||||
public EnderPearl(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage, HitResult hitResult)
|
||||
{
|
||||
super(entity, targetX, targetY, targetZ);
|
||||
this.pearlEntity = pearlEntity;
|
||||
@@ -166,16 +165,6 @@ public class EntityTeleportEvent extends EntityEvent
|
||||
this.hitResult = hitResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@linkplain #EnderPearl(ServerPlayer, double, double, double, ThrownEnderpearl, float, HitResult)} the hit result-sensitive version}.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public EnderPearl(ServerPlayer entity, double targetX, double targetY, double targetZ, ThrownEnderpearl pearlEntity, float attackDamage)
|
||||
{
|
||||
this(entity, targetX, targetY, targetZ, pearlEntity, attackDamage, null);
|
||||
}
|
||||
|
||||
public ThrownEnderpearl getPearlEntity()
|
||||
{
|
||||
return pearlEntity;
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.event.entity.living;
|
||||
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.behavior.StartAttacking;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent.ILivingTargetType;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType;
|
||||
|
||||
/**
|
||||
* This event is deprecated. Use {@link LivingChangeTargetEvent} instead.<br>
|
||||
* <br>
|
||||
* LivingSetAttackTargetEvent is fired when an Entity sets a target to attack.<br>
|
||||
* This event is fired whenever an Entity sets a target to attack in
|
||||
* {@link Mob#setTarget(LivingEntity)} or {@link StartAttacking#setAttackTarget(Mob, LivingEntity)}<br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#onLivingSetAttackTarget(LivingEntity, LivingEntity)}.<br>
|
||||
* <br>
|
||||
* {@link #getTarget} returns the newly targeted Entity.<br>
|
||||
* {@link #getTargetType()} returns the target type that caused the change of targets.<br>
|
||||
* <br>
|
||||
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult}<br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
**/
|
||||
// TODO: Remove in 1.20
|
||||
@Deprecated(since = "1.19.2", forRemoval = true)
|
||||
public class LivingSetAttackTargetEvent extends LivingEvent
|
||||
{
|
||||
private final ILivingTargetType targetType;
|
||||
private final LivingEntity originalTarget;
|
||||
|
||||
public LivingSetAttackTargetEvent(LivingEntity entity, LivingEntity target)
|
||||
{
|
||||
super(entity);
|
||||
this.targetType = LivingTargetType.MOB_TARGET;
|
||||
this.originalTarget = target;
|
||||
}
|
||||
|
||||
public LivingSetAttackTargetEvent(LivingEntity entity, LivingEntity target, ILivingTargetType targetType)
|
||||
{
|
||||
super(entity);
|
||||
this.targetType = targetType;
|
||||
this.originalTarget = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the target this living entity had after changing its target to a new
|
||||
* target, but before posting this event.}
|
||||
*/
|
||||
public LivingEntity getTarget()
|
||||
{
|
||||
return originalTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the target type of this event.}
|
||||
*/
|
||||
public ILivingTargetType getTargetType()
|
||||
{
|
||||
return targetType;
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,10 @@ import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* This event is fired when a player gets an advancement.
|
||||
* <br>
|
||||
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult}<br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
* @deprecated Use {@link net.minecraftforge.event.entity.player.AdvancementEvent.AdvancementEarnEvent} and {@link net.minecraftforge.event.entity.player.AdvancementEvent.AdvancementProgressEvent} instead
|
||||
* Base class used for advancement-related events. Should not be used directly.
|
||||
* @see AdvancementEarnEvent
|
||||
* @see AdvancementProgressEvent
|
||||
*/
|
||||
@Deprecated(since = "1.19.2")
|
||||
public class AdvancementEvent extends PlayerEvent
|
||||
{
|
||||
private final Advancement advancement;
|
||||
@@ -49,24 +43,22 @@ public class AdvancementEvent extends PlayerEvent
|
||||
*
|
||||
* @see AdvancementProgress#isDone()
|
||||
*/
|
||||
//todo: should extend AdvancementEvent in 1.20
|
||||
public static class AdvancementEarnEvent extends PlayerEvent
|
||||
public static class AdvancementEarnEvent extends AdvancementEvent
|
||||
{
|
||||
private final Advancement advancement;
|
||||
|
||||
public AdvancementEarnEvent(Player player, Advancement earned)
|
||||
{
|
||||
super(player);
|
||||
this.advancement = earned;
|
||||
super(player, earned);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@return the advancement that was earned}
|
||||
*/
|
||||
@Override
|
||||
public Advancement getAdvancement()
|
||||
{
|
||||
return advancement;
|
||||
return super.getAdvancement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,18 +74,15 @@ public class AdvancementEvent extends PlayerEvent
|
||||
* @see net.minecraft.server.PlayerAdvancements#award(Advancement, String)
|
||||
* @see net.minecraft.server.PlayerAdvancements#revoke(Advancement, String)
|
||||
*/
|
||||
//todo: should extend AdvancementEvent in 1.20
|
||||
public static class AdvancementProgressEvent extends PlayerEvent
|
||||
public static class AdvancementProgressEvent extends AdvancementEvent
|
||||
{
|
||||
private final Advancement advancement;
|
||||
private final AdvancementProgress advancementProgress;
|
||||
private final String criterionName;
|
||||
private final AdvancementEvent.AdvancementProgressEvent.ProgressType progressType;
|
||||
|
||||
public AdvancementProgressEvent(Player player, Advancement progressed, AdvancementProgress advancementProgress, String criterionName, AdvancementEvent.AdvancementProgressEvent.ProgressType progressType)
|
||||
{
|
||||
super(player);
|
||||
this.advancement = progressed;
|
||||
super(player, progressed);
|
||||
this.advancementProgress = advancementProgress;
|
||||
this.criterionName = criterionName;
|
||||
this.progressType = progressType;
|
||||
@@ -103,9 +92,10 @@ public class AdvancementEvent extends PlayerEvent
|
||||
*
|
||||
* {@return The advancement that was progressed}
|
||||
*/
|
||||
@Override
|
||||
public Advancement getAdvancement()
|
||||
{
|
||||
return advancement;
|
||||
return super.getAdvancement();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -125,7 +125,6 @@ public class PlayerEvent extends LivingEvent
|
||||
public float getNewSpeed() { return newSpeed; }
|
||||
public void setNewSpeed(float newSpeed) { this.newSpeed = newSpeed; }
|
||||
public Optional<BlockPos> getPosition() { return this.pos; }
|
||||
@Deprecated(forRemoval = true, since ="1.19") public BlockPos getPos() { return pos.orElse(LEGACY_UNKNOWN); }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -352,7 +352,7 @@ public class PlayerInteractEvent extends PlayerEvent
|
||||
*/
|
||||
public Level getLevel()
|
||||
{
|
||||
return getEntity().level;
|
||||
return getEntity().level();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,13 +61,6 @@ public class ChunkEvent extends LevelEvent
|
||||
{
|
||||
private final boolean newChunk;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@Deprecated(forRemoval = true, since = "1.19.3")
|
||||
public Load(ChunkAccess chunk)
|
||||
{
|
||||
this(chunk, false);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Load(ChunkAccess chunk, boolean newChunk)
|
||||
{
|
||||
|
||||
@@ -9,11 +9,8 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.SaplingBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -22,8 +19,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This event is fired whenever a sapling, fungus, mushroom or azalea grows into a tree.
|
||||
* This event is fired during sapling growth in
|
||||
* {@link SaplingBlock#advanceTree(ServerLevel, BlockPos, BlockState, RandomSource)}.
|
||||
* <p>
|
||||
* This event is not {@linkplain Cancelable cancellable} but does {@linkplain HasResult have a result}.
|
||||
* {@linkplain Result#ALLOW ALLOW} and {@linkplain Result#DEFAULT DEFAULT} will allow the sapling to grow
|
||||
@@ -32,8 +27,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
* <p>
|
||||
* This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}
|
||||
* only on the {@linkplain net.minecraftforge.fml.LogicalSide#SERVER logical server}.
|
||||
* TODO 1.20 rename event
|
||||
*/
|
||||
// TODO: Rename to BlockFeatureGrowEvent in 1.20
|
||||
@HasResult
|
||||
public class SaplingGrowTreeEvent extends LevelEvent
|
||||
{
|
||||
@@ -42,12 +37,6 @@ public class SaplingGrowTreeEvent extends LevelEvent
|
||||
@Nullable
|
||||
private Holder<ConfiguredFeature<?, ?>> feature;
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos)
|
||||
{
|
||||
this(level, randomSource, pos, null);
|
||||
}
|
||||
|
||||
public SaplingGrowTreeEvent(LevelAccessor level, RandomSource randomSource, BlockPos pos, @Nullable Holder<ConfiguredFeature<?, ?>> feature)
|
||||
{
|
||||
super(level);
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
@@ -30,7 +31,6 @@ import net.minecraft.world.level.LevelReader;
|
||||
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.Material;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -825,8 +825,7 @@ public class FluidType
|
||||
{
|
||||
if (level.dimensionType().ultraWarm())
|
||||
{
|
||||
BlockState state = this.getBlockForFluidState(level, pos, this.getStateForPlacement(level, pos, stack));
|
||||
return state != null && state.getMaterial() == Material.WATER;
|
||||
return this == ForgeMod.WATER_TYPE.get() || this.getStateForPlacement(level, pos, stack).is(FluidTags.WATER);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.BucketPickup;
|
||||
import net.minecraft.world.level.block.LiquidBlockContainer;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
@@ -141,7 +140,7 @@ public class FluidUtil
|
||||
|
||||
if (soundevent != null)
|
||||
{
|
||||
player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
player.level().playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,7 +192,7 @@ public class FluidUtil
|
||||
|
||||
if (soundevent != null)
|
||||
{
|
||||
player.level.playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
player.level().playSound(null, player.getX(), player.getY() + 0.5, player.getZ(), soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,8 +569,7 @@ public class FluidUtil
|
||||
|
||||
// check that we can place the fluid at the destination
|
||||
BlockState destBlockState = level.getBlockState(pos);
|
||||
Material destMaterial = destBlockState.getMaterial();
|
||||
boolean isDestNonSolid = !destMaterial.isSolid();
|
||||
boolean isDestNonSolid = !destBlockState.isSolid();
|
||||
boolean isDestReplaceable = destBlockState.canBeReplaced(context);
|
||||
boolean canDestContainFluid = destBlockState.getBlock() instanceof LiquidBlockContainer && ((LiquidBlockContainer) destBlockState.getBlock()).canPlaceLiquid(level, pos, destBlockState, fluid);
|
||||
if (!level.isEmptyBlock(pos) && !isDestNonSolid && !isDestReplaceable && !canDestContainFluid)
|
||||
@@ -642,10 +640,9 @@ public class FluidUtil
|
||||
if (!level.isClientSide)
|
||||
{
|
||||
BlockState destBlockState = level.getBlockState(pos);
|
||||
Material destMaterial = destBlockState.getMaterial();
|
||||
boolean isDestNonSolid = !destMaterial.isSolid();
|
||||
boolean isDestNonSolid = !destBlockState.isSolid();
|
||||
boolean isDestReplaceable = false; //TODO: Needs BlockItemUseContext destBlockState.getBlock().isReplaceable(level, pos);
|
||||
if ((isDestNonSolid || isDestReplaceable) && !destMaterial.isLiquid())
|
||||
if ((isDestNonSolid || isDestReplaceable) && !destBlockState.liquid())
|
||||
{
|
||||
level.destroyBlock(pos, true);
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fluids.capability;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.CapabilityToken;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public class CapabilityFluidHandler
|
||||
{
|
||||
/**
|
||||
* @deprecated Create your own reference using {@link CapabilityManager#get(CapabilityToken)}, or use
|
||||
* {@link ForgeCapabilities#FLUID_HANDLER}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static Capability<IFluidHandler> FLUID_HANDLER_CAPABILITY = ForgeCapabilities.FLUID_HANDLER;
|
||||
/**
|
||||
* @deprecated Create your own reference using {@link CapabilityManager#get(CapabilityToken)}, or use
|
||||
* {@link ForgeCapabilities#FLUID_HANDLER_ITEM}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static Capability<IFluidHandlerItem> FLUID_HANDLER_ITEM_CAPABILITY = ForgeCapabilities.FLUID_HANDLER_ITEM;
|
||||
|
||||
public static void register(RegisterCapabilitiesEvent event){}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.forge.snapshots.ForgeSnapshotsMod;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.versions.mcp.MCPVersion;
|
||||
|
||||
@@ -31,7 +32,7 @@ public class BrandingControl
|
||||
if (brandings == null)
|
||||
{
|
||||
ImmutableList.Builder<String> brd = ImmutableList.builder();
|
||||
brd.add("Forge " + ForgeVersion.getVersion());
|
||||
brd.add(ForgeSnapshotsMod.BRANDING_NAME + ' ' + ForgeVersion.getVersion());
|
||||
brd.add("Minecraft " + MCPVersion.getMCVersion());
|
||||
brd.add("MCP " + MCPVersion.getMCPVersion());
|
||||
int tModCount = ModList.get().size();
|
||||
@@ -70,11 +71,11 @@ public class BrandingControl
|
||||
}
|
||||
|
||||
public static String getClientBranding() {
|
||||
return "forge";
|
||||
return ForgeSnapshotsMod.BRANDING_ID;
|
||||
}
|
||||
|
||||
public static String getServerBranding() {
|
||||
return "forge";
|
||||
return ForgeSnapshotsMod.BRANDING_ID;
|
||||
}
|
||||
|
||||
public static ResourceManagerReloadListener resourceManagerReloadListener() {
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.items;
|
||||
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.CapabilityToken;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public class CapabilityItemHandler
|
||||
{
|
||||
/**
|
||||
* @deprecated Create your own reference using {@link CapabilityManager#get(CapabilityToken)}, or use {@link ForgeCapabilities#ITEM_HANDLER}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
public static final Capability<IItemHandler> ITEM_HANDLER_CAPABILITY = ForgeCapabilities.ITEM_HANDLER;
|
||||
|
||||
public static void register(RegisterCapabilitiesEvent event){}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class ItemHandlerHelper
|
||||
|
||||
public static boolean canItemStacksStack(@NotNull ItemStack a, @NotNull ItemStack b)
|
||||
{
|
||||
if (a.isEmpty() || !a.sameItem(b) || a.hasTag() != b.hasTag())
|
||||
if (a.isEmpty() || !ItemStack.isSameItem(a, b) || a.hasTag() != b.hasTag())
|
||||
return false;
|
||||
|
||||
return (!a.hasTag() || a.getTag().equals(b.getTag())) && a.areCapsCompatible(b);
|
||||
@@ -150,7 +150,7 @@ public class ItemHandlerHelper
|
||||
if (stack.isEmpty()) return;
|
||||
|
||||
IItemHandler inventory = new PlayerMainInvWrapper(player.getInventory());
|
||||
Level level = player.level;
|
||||
Level level = player.level();
|
||||
|
||||
// try adding it into the inventory
|
||||
ItemStack remainder = stack;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PlayerMainInvWrapper extends RangedWrapper
|
||||
ItemStack inSlot = getStackInSlot(slot);
|
||||
if(!inSlot.isEmpty())
|
||||
{
|
||||
if (getInventoryPlayer().player.level.isClientSide)
|
||||
if (getInventoryPlayer().player.level().isClientSide)
|
||||
{
|
||||
inSlot.setPopTime(5);
|
||||
}
|
||||
|
||||
@@ -16,13 +16,12 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -233,6 +232,6 @@ public class ShulkerItemStackInvWrapper implements IItemHandlerModifiable, ICapa
|
||||
@NotNull
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side)
|
||||
{
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(cap, this.holder);
|
||||
return ForgeCapabilities.ITEM_HANDLER.orEmpty(cap, this.holder);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,9 @@ public class CrashReportExtender
|
||||
|
||||
public static void addCrashReportHeader(StringBuilder stringbuilder, CrashReport crashReport)
|
||||
{
|
||||
net.minecraftforge.forge.snapshots.ForgeSnapshotsMod.addCrashReportHeader(stringbuilder, crashReport);
|
||||
}
|
||||
|
||||
public static String generateEnhancedStackTrace(final Throwable throwable) {
|
||||
return generateEnhancedStackTrace(throwable, true);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class NetworkHooks
|
||||
*/
|
||||
public static void openScreen(ServerPlayer player, MenuProvider containerSupplier, Consumer<FriendlyByteBuf> extraDataWriter)
|
||||
{
|
||||
if (player.level.isClientSide) return;
|
||||
if (player.level().isClientSide) return;
|
||||
player.doCloseContainer();
|
||||
player.nextContainerCounter();
|
||||
int openContainerId = player.containerCounter;
|
||||
|
||||
@@ -237,18 +237,6 @@ public class SimpleChannel
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message consumer, which is called once a message has been decoded.
|
||||
* @param consumer The message consumer.
|
||||
* @return The message builder, for chaining.
|
||||
* @deprecated Use {@link #consumerMainThread(BiConsumer)} or {@link #consumerNetworkThread(BiConsumer)}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
public MessageBuilder<MSG> consumer(BiConsumer<MSG, Supplier<NetworkEvent.Context>> consumer) {
|
||||
consumerMainThread(consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message consumer, which is called once a message has been decoded. This accepts the decoded message
|
||||
* object and the message's context.
|
||||
@@ -305,18 +293,6 @@ public class SimpleChannel
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message consumer, which is called once a message has been decoded.
|
||||
* @param handler The message consumer.
|
||||
* @return The message builder, for chaining.
|
||||
* @deprecated Use {@link #consumerMainThread(BiConsumer)} or {@link #consumerNetworkThread(BiConsumer)}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19")
|
||||
public MessageBuilder<MSG> consumer(ToBooleanBiFunction<MSG, Supplier<NetworkEvent.Context>> handler) {
|
||||
consumerMainThread(handler::applyAsBool);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void add() {
|
||||
final IndexedMessageCodec.MessageHandler<MSG> message = this.channel.registerMessage(this.id, this.type, this.encoder, this.decoder, this.consumer, this.networkDirection);
|
||||
if (this.loginIndexSetter != null) {
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
package net.minecraftforge.registries;
|
||||
|
||||
import net.minecraftforge.common.world.BiomeModifier;
|
||||
import net.minecraftforge.common.world.StructureModifier;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
||||
public class ForgeDeferredRegistriesSetup
|
||||
@@ -18,8 +16,13 @@ public class ForgeDeferredRegistriesSetup
|
||||
*/
|
||||
public static void setup(IEventBus modEventBus)
|
||||
{
|
||||
if (setup)
|
||||
throw new IllegalStateException("Setup has already been called!");
|
||||
synchronized (ForgeDeferredRegistriesSetup.class)
|
||||
{
|
||||
if (setup)
|
||||
throw new IllegalStateException("Setup has already been called!");
|
||||
|
||||
setup = true;
|
||||
}
|
||||
|
||||
ForgeRegistries.DEFERRED_ENTITY_DATA_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
@@ -28,7 +31,5 @@ public class ForgeDeferredRegistriesSetup
|
||||
ForgeRegistries.DEFERRED_STRUCTURE_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_HOLDER_SET_TYPES.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_DISPLAY_CONTEXTS.register(modEventBus);
|
||||
|
||||
setup = true;
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ import org.apache.logging.log4j.MarkerManager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegistryModifiable<V>
|
||||
@@ -70,16 +71,12 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
private final BakeCallback<V> bake;
|
||||
private final MissingFactory<V> missing;
|
||||
private final BitSet availabilityMap;
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
private final Set<ResourceLocation> dummies = Sets.newHashSet();
|
||||
private final Set<Integer> blocked = Sets.newHashSet();
|
||||
private final Multimap<ResourceLocation, V> overrides = ArrayListMultimap.create();
|
||||
private final Map<ResourceLocation, Holder.Reference<V>> delegatesByName = Maps.newHashMap();
|
||||
private final Map<V, Holder.Reference<V>> delegatesByValue = Maps.newHashMap();
|
||||
private final BiMap<OverrideOwner<V>, V> owners = HashBiMap.create();
|
||||
private final ForgeRegistryTagManager<V> tagManager;
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
private final DummyFactory<V> dummyFactory;
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final boolean allowOverrides;
|
||||
@@ -113,7 +110,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
this.validate = builder.getValidate();
|
||||
this.bake = builder.getBake();
|
||||
this.missing = builder.getMissingFactory();
|
||||
this.dummyFactory = builder.getDummyFactory();
|
||||
this.allowOverrides = builder.getAllowOverrides();
|
||||
this.isModifiable = builder.getAllowModifications();
|
||||
this.hasWrapper = builder.getHasWrapper();
|
||||
@@ -464,9 +460,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
if (this.add != null)
|
||||
this.add.onAdd(this, this.stage, idToUse, rkey, value, oldEntry);
|
||||
|
||||
if (this.dummies.remove(key))
|
||||
LOGGER.debug(REGISTRIES,"Registry {} Dummy Remove: {}", this.name, key);
|
||||
|
||||
LOGGER.trace(REGISTRIES,"Registry {} add: {} {} {} (req. id {})", this.name, key, idToUse, value, id);
|
||||
|
||||
return idToUse;
|
||||
@@ -489,7 +482,7 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
* Any registry lookups that target the first name will resolve as the second name, if the first name is not present.
|
||||
* @param src The source registry name to alias from.
|
||||
* @param dst The target registry name to alias to.
|
||||
*
|
||||
*
|
||||
* TODO: Add as public API in IForgeRegistry and DeferredRegister.
|
||||
*/
|
||||
public void addAlias(ResourceLocation src, ResourceLocation dst)
|
||||
@@ -507,15 +500,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
LOGGER.trace(REGISTRIES,"Registry {} alias: {} -> {}", this.name, src, dst);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
void addDummy(ResourceLocation key)
|
||||
{
|
||||
if (this.isLocked())
|
||||
throw new IllegalStateException(String.format(Locale.ENGLISH, "Attempted to register the dummy %s too late", key));
|
||||
this.dummies.add(key);
|
||||
LOGGER.trace(REGISTRIES,"Registry {} dummy: {}", this.name, key);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Optional<Holder.Reference<V>> getDelegate(ResourceKey<V> rkey)
|
||||
@@ -584,12 +568,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
boolean isDummied(ResourceLocation key)
|
||||
{
|
||||
return this.dummies.contains(key);
|
||||
}
|
||||
|
||||
|
||||
void validateContent(ResourceLocation registryName)
|
||||
{
|
||||
@@ -715,10 +693,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
}
|
||||
}
|
||||
|
||||
//Needs to be below add so that dummies are persisted
|
||||
this.dummies.clear();
|
||||
from.dummies.forEach(this::addDummy);
|
||||
|
||||
if (errored)
|
||||
throw new RuntimeException("One of more entry values did not copy to the correct id. Check log for details!");
|
||||
}
|
||||
@@ -737,7 +711,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
|
||||
|
||||
this.aliases.clear();
|
||||
this.dummies.clear();
|
||||
|
||||
this.ids.clear();
|
||||
this.names.clear();
|
||||
@@ -804,7 +777,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
{
|
||||
TablePrinter<DumpRow> tab = new TablePrinter<DumpRow>()
|
||||
.header("ID", r -> r.id)
|
||||
.header("Dummy", r -> r.dummied)
|
||||
.header("Key", r -> r.key)
|
||||
.header("Value", r -> r.value);
|
||||
|
||||
@@ -815,14 +787,14 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
getKeys().stream().map(this::getID).sorted().map(id -> {
|
||||
V val = getValue(id);
|
||||
ResourceLocation key = getKey(val);
|
||||
return new DumpRow(Integer.toString(id), getKey(val).toString(), val.toString(), Boolean.toString(this.dummies.contains(key)));
|
||||
return new DumpRow(Integer.toString(id), getKey(val).toString(), val.toString());
|
||||
}).forEach(tab::add);
|
||||
tab.build(sb);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private record DumpRow(String id, String key, String value, @Deprecated(forRemoval = true, since = "1.19.4") String dummied) {}
|
||||
private record DumpRow(String id, String key, String value) {}
|
||||
|
||||
public void loadIds(Map<ResourceLocation, Integer> ids, Map<ResourceLocation, String> overrides, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, IdMappingEvent.IdRemapping> remapped, ForgeRegistry<V> old, ResourceLocation name)
|
||||
{
|
||||
@@ -830,20 +802,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
for (Map.Entry<ResourceLocation, Integer> entry : ids.entrySet())
|
||||
{
|
||||
ResourceLocation itemName = entry.getKey();
|
||||
/*
|
||||
* Due to the way that Mojang wrote the world loading and validation code.
|
||||
* Single player gets loaded twice and the 'active' registry is one we have loaded from
|
||||
* from the world and potentially injected dummies into.
|
||||
* The real fix would be to figure out how to revert the registries to the frozen state
|
||||
* after validating data packs, but before injecting world data.
|
||||
* But this should work for now, as we never want to inject dummies, this would be done
|
||||
* further down the load stack.
|
||||
*/
|
||||
if (old.isDummied(itemName))
|
||||
{
|
||||
LOGGER.info(REGISTRIES, "Registry {}: Skipping injection of dummied object {}", this.name, itemName);
|
||||
continue;
|
||||
}
|
||||
|
||||
int newId = entry.getValue();
|
||||
int currId = old.getIDRaw(itemName);
|
||||
@@ -924,68 +882,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
boolean markDummy(ResourceLocation key, int id)
|
||||
{
|
||||
if (this.dummyFactory == null)
|
||||
return false;
|
||||
|
||||
ForgeRegistry<V> active = RegistryManager.ACTIVE.getRegistry(getRegistryKey());
|
||||
NamespacedWrapper<V> wrapper = active.getWrapper();
|
||||
if (wrapper != null && wrapper.isIntrusive() && wrapper.isFrozen())
|
||||
{
|
||||
try
|
||||
{
|
||||
// We have to unfreeze the ACTIVE registry because a lot of vanilla objects use intrusive handlers in object init.
|
||||
wrapper.unfreeze();
|
||||
createAndAddDummy(key, id);
|
||||
}
|
||||
finally
|
||||
{
|
||||
wrapper.freeze();
|
||||
}
|
||||
}
|
||||
else
|
||||
createAndAddDummy(key, id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
private void createAndAddDummy(ResourceLocation key, int id)
|
||||
{
|
||||
V dummy = this.dummyFactory.createDummy(key);
|
||||
LOGGER.debug(REGISTRIES,"Registry {} Dummy Add: {} {} -> {}", this.name, key, id, dummy);
|
||||
|
||||
//It was blocked before so we need to unset the blocking map
|
||||
this.availabilityMap.clear(id);
|
||||
if (this.containsKey(key))
|
||||
{
|
||||
//If the entry already exists, we need to delete it so we can add a dummy...
|
||||
V value = this.names.remove(key);
|
||||
if (value == null)
|
||||
throw new IllegalStateException("ContainsKey for " + key + " was true, but removing by name returned no value.. This should never happen unless hackery!");
|
||||
|
||||
ResourceKey<V> rkey = this.keys.inverse().remove(value); // Remove from the RegistryKey -> Value map
|
||||
if (rkey == null)
|
||||
throw new IllegalStateException("Removed a entry that did not have an associated RegistryKey: " + key + " " + value.toString() + " This should never happen unless hackery!");
|
||||
|
||||
Integer oldid = this.ids.inverse().remove(value);
|
||||
if (oldid == null)
|
||||
throw new IllegalStateException("Removed a entry that did not have an associated id: " + key + " " + value.toString() + " This should never happen unless hackery!");
|
||||
|
||||
if (oldid != id)
|
||||
LOGGER.debug(REGISTRIES,"Registry {}: Dummy ID mismatch {} {} -> {}", this.name, key, oldid, id);
|
||||
|
||||
LOGGER.debug(REGISTRIES,"Registry {} remove: {} {}", this.name, key, oldid);
|
||||
}
|
||||
|
||||
int realId = this.add(id, key, dummy);
|
||||
if (realId != id)
|
||||
LOGGER.warn(REGISTRIES,"Registry {}: Object did not get ID it asked for. Name: {} Expected: {} Got: {}", this.name, key, id, realId);
|
||||
this.dummies.add(key);
|
||||
}
|
||||
|
||||
//Public for tests
|
||||
public Snapshot makeSnapshot()
|
||||
{
|
||||
@@ -993,7 +889,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
this.ids.forEach((id, value) -> ret.ids.put(getKey(value), id));
|
||||
ret.aliases.putAll(this.aliases);
|
||||
ret.blocked.addAll(this.blocked);
|
||||
ret.dummied.addAll(this.dummies);
|
||||
ret.overrides.putAll(getOverrideOwners());
|
||||
return ret;
|
||||
}
|
||||
@@ -1057,8 +952,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
public final Map<ResourceLocation, Integer> ids = Maps.newTreeMap(sorter);
|
||||
public final Map<ResourceLocation, ResourceLocation> aliases = Maps.newTreeMap(sorter);
|
||||
public final Set<Integer> blocked = Sets.newTreeSet();
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public final Set<ResourceLocation> dummied = Sets.newTreeSet(sorter);
|
||||
public final Map<ResourceLocation, String> overrides = Maps.newTreeMap(sorter);
|
||||
private FriendlyByteBuf binary = null;
|
||||
|
||||
@@ -1099,10 +992,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
int[] blocked = this.blocked.stream().mapToInt(x->x).sorted().toArray();
|
||||
data.putIntArray("blocked", blocked);
|
||||
|
||||
ListTag dummied = new ListTag();
|
||||
this.dummied.stream().sorted().forEach(e -> dummied.add(StringTag.valueOf(e.toString())));
|
||||
data.put("dummied", dummied);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1141,9 +1030,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
ret.blocked.add(i);
|
||||
}
|
||||
|
||||
list = nbt.getList("dummied", 8);
|
||||
list.forEach(e -> ret.dummied.add(new ResourceLocation(((StringTag)e).getAsString())));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1173,9 +1059,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
pkt.writeVarInt(this.blocked.size());
|
||||
this.blocked.forEach(pkt::writeVarInt);
|
||||
|
||||
pkt.writeVarInt(this.dummied.size());
|
||||
this.dummied.forEach(pkt::writeResourceLocation);
|
||||
|
||||
this.binary = pkt;
|
||||
}
|
||||
|
||||
@@ -1205,10 +1088,6 @@ public class ForgeRegistry<V> implements IForgeRegistryInternal<V>, IForgeRegist
|
||||
for (int x = 0; x < len; x++)
|
||||
ret.blocked.add(buff.readVarInt());
|
||||
|
||||
len = buff.readVarInt();
|
||||
for (int x = 0; x < len; x++)
|
||||
ret.dummied.add(buff.readResourceLocation());
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,13 +40,11 @@ import net.minecraft.world.entity.ai.village.poi.PoiType;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
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.levelgen.DebugLevelSource;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.common.CreativeModeTabRegistry;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -209,9 +207,6 @@ public class GameData
|
||||
return new RegistryBuilder<ItemDisplayContext>()
|
||||
.setMaxID(128 * 2) /* 0 -> 127 gets positive ID, 128 -> 256 gets negative ID */.disableOverrides().disableSaving()
|
||||
.setDefaultKey(new ResourceLocation("minecraft:none"))
|
||||
.onCreate((owner, stage) -> Arrays.stream(ItemDisplayContext.values())
|
||||
.filter(Predicate.not(ItemDisplayContext::isModded))
|
||||
.forEach(ctx -> owner.register(ctx.getId(), new ResourceLocation("minecraft", ctx.getSerializedName()), ctx)))
|
||||
.onAdd(ItemDisplayContext.ADD_CALLBACK);
|
||||
}
|
||||
|
||||
@@ -403,7 +398,7 @@ public class GameData
|
||||
{
|
||||
ForgeHooks.modifyAttributes();
|
||||
SpawnPlacements.fireSpawnPlacementEvent();
|
||||
CreativeModeTabRegistry.fireCollectionEvent();
|
||||
CreativeModeTabRegistry.sortTabs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +422,7 @@ public class GameData
|
||||
}
|
||||
}
|
||||
|
||||
private static class BlockCallbacks implements IForgeRegistry.AddCallback<Block>, IForgeRegistry.ClearCallback<Block>, IForgeRegistry.BakeCallback<Block>, IForgeRegistry.CreateCallback<Block>, IForgeRegistry.DummyFactory<Block>
|
||||
private static class BlockCallbacks implements IForgeRegistry.AddCallback<Block>, IForgeRegistry.ClearCallback<Block>, IForgeRegistry.BakeCallback<Block>, IForgeRegistry.CreateCallback<Block>
|
||||
{
|
||||
static final BlockCallbacks INSTANCE = new BlockCallbacks();
|
||||
|
||||
@@ -488,14 +483,6 @@ public class GameData
|
||||
owner.setSlaveMap(BLOCK_TO_ITEM, Maps.newHashMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public Block createDummy(ResourceLocation key)
|
||||
{
|
||||
Block ret = new DummyAirBlock(Block.Properties.of(Material.AIR).noCollission().noLootTable().air());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBake(IForgeRegistryInternal<Block> owner, RegistryManager stage)
|
||||
{
|
||||
@@ -514,21 +501,6 @@ public class GameData
|
||||
}
|
||||
DebugLevelSource.initValidStates();
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
private static class DummyAirBlock extends AirBlock
|
||||
{
|
||||
private DummyAirBlock(Block.Properties properties)
|
||||
{
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionId()
|
||||
{
|
||||
return "block.minecraft.air";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ItemCallbacks implements IForgeRegistry.AddCallback<Item>, IForgeRegistry.ClearCallback<Item>, IForgeRegistry.CreateCallback<Item>
|
||||
@@ -699,34 +671,6 @@ public class GameData
|
||||
loadPersistentDataToStagingRegistry(RegistryManager.ACTIVE, STAGING, remaps.get(key), missing.get(key), key, value);
|
||||
});
|
||||
|
||||
snapshot.forEach((key, value) ->
|
||||
{
|
||||
value.dummied.forEach(dummy ->
|
||||
{
|
||||
Map<ResourceLocation, Integer> m = missing.get(key);
|
||||
ForgeRegistry<?> reg = STAGING.getRegistry(key);
|
||||
|
||||
// Currently missing locally, we just inject and carry on
|
||||
if (m.containsKey(dummy))
|
||||
{
|
||||
if (reg.markDummy(dummy, m.get(dummy)))
|
||||
m.remove(dummy);
|
||||
}
|
||||
else if (isLocalWorld)
|
||||
{
|
||||
LOGGER.debug(REGISTRIES,"Registry {}: Resuscitating dummy entry {}", key, dummy);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The server believes this is a dummy block identity, but we seem to have one locally. This is likely a conflict
|
||||
// in mod setup - Mark this entry as a dummy
|
||||
int id = reg.getID(dummy);
|
||||
LOGGER.warn(REGISTRIES, "Registry {}: The ID {} @ {} is currently locally mapped - it will be replaced with a dummy for this session", dummy, key, id);
|
||||
reg.markDummy(dummy, id);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
int count = missing.values().stream().mapToInt(Map::size).sum();
|
||||
if (count > 0)
|
||||
{
|
||||
@@ -791,17 +735,6 @@ public class GameData
|
||||
|
||||
if (injectFrozenData)
|
||||
{
|
||||
// If we're loading from disk, we can actually substitute air in the block map for anything that is otherwise "missing". This keeps the reference in the map, in case
|
||||
// the block comes back later
|
||||
missing.forEach((name, m) ->
|
||||
{
|
||||
if (m.isEmpty())
|
||||
return;
|
||||
ForgeRegistry<?> reg = STAGING.getRegistry(name);
|
||||
m.forEach((rl, id) -> reg.markDummy(rl, id));
|
||||
});
|
||||
|
||||
|
||||
// If we're loading up the world from disk, we want to add in the new data that might have been provisioned by mods
|
||||
// So we load it from the frozen persistent registry
|
||||
RegistryManager.ACTIVE.registries.forEach((name, reg) ->
|
||||
@@ -852,8 +785,6 @@ public class GameData
|
||||
ForgeRegistry<T> _new = to.getRegistry(name, RegistryManager.ACTIVE);
|
||||
snap.aliases.forEach(_new::addAlias);
|
||||
snap.blocked.forEach(_new::block);
|
||||
// Load current dummies BEFORE the snapshot is loaded so that add() will remove from the list.
|
||||
snap.dummied.forEach(_new::addDummy);
|
||||
_new.loadIds(snap.ids, snap.overrides, missing, remaps, active, name);
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 568 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user