mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
1.20.2-pre1
This commit is contained in:
368 files changed
+3555
-6356
No files matched your search
@@ -5,8 +5,7 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
@@ -32,30 +31,26 @@ import java.util.stream.Stream;
|
||||
/**
|
||||
* overrides for {@link CommandSourceStack} so that the methods will run successfully client side
|
||||
*/
|
||||
public class ClientCommandSourceStack extends CommandSourceStack
|
||||
{
|
||||
|
||||
public ClientCommandSourceStack(CommandSource source, Vec3 position, Vec2 rotation, int permission, String plainTextName, Component displayName,
|
||||
Entity executing)
|
||||
{
|
||||
public class ClientCommandSourceStack extends CommandSourceStack {
|
||||
public ClientCommandSourceStack(CommandSource source, Vec3 position, Vec2 rotation, int permission, String plainTextName, Component displayName, Entity executing) {
|
||||
super(source, position, rotation, null, permission, plainTextName, displayName, null, executing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a success message without attempting to get the server side list of admins
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public void sendSuccess(Supplier<Component> message, boolean sendToAdmins)
|
||||
{
|
||||
public void sendSuccess(Supplier<Component> message, boolean sendToAdmins) {
|
||||
Minecraft.getInstance().player.sendSystemMessage(message.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the list of teams from the client side}
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public Collection<String> getAllTeams()
|
||||
{
|
||||
public Collection<String> getAllTeams() {
|
||||
return Minecraft.getInstance().level.getScoreboard().getTeamNames();
|
||||
}
|
||||
|
||||
@@ -63,8 +58,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
* {@return the list of online player names from the client side}
|
||||
*/
|
||||
@Override
|
||||
public Collection<String> getOnlinePlayerNames()
|
||||
{
|
||||
public Collection<String> getOnlinePlayerNames() {
|
||||
return Minecraft.getInstance().getConnection().getOnlinePlayers().stream().map((player) -> player.getProfile().getName()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -72,8 +66,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
* {@return a {@link Stream} of recipe ids that are available on the client}
|
||||
*/
|
||||
@Override
|
||||
public Stream<ResourceLocation> getRecipeNames()
|
||||
{
|
||||
public Stream<ResourceLocation> getRecipeNames() {
|
||||
return Minecraft.getInstance().getConnection().getRecipeManager().getRecipeIds();
|
||||
}
|
||||
|
||||
@@ -81,8 +74,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
* {@return a set of {@link ResourceKey} for levels from the client side}
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourceKey<Level>> levels()
|
||||
{
|
||||
public Set<ResourceKey<Level>> levels() {
|
||||
return Minecraft.getInstance().getConnection().levels();
|
||||
}
|
||||
|
||||
@@ -90,17 +82,16 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
* {@return the {@link RegistryAccess} from the client side}
|
||||
*/
|
||||
@Override
|
||||
public RegistryAccess registryAccess()
|
||||
{
|
||||
public RegistryAccess registryAccess() {
|
||||
return Minecraft.getInstance().getConnection().registryAccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the scoreboard from the client side}
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public Scoreboard getScoreboard()
|
||||
{
|
||||
public Scoreboard getScoreboard() {
|
||||
return Minecraft.getInstance().level.getScoreboard();
|
||||
}
|
||||
|
||||
@@ -108,26 +99,24 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
* {@return the advancement from the id from the client side where the advancement needs to be visible to the player}
|
||||
*/
|
||||
@Override
|
||||
public Advancement getAdvancement(ResourceLocation id)
|
||||
{
|
||||
return Minecraft.getInstance().getConnection().getAdvancements().getAdvancements().get(id);
|
||||
public AdvancementHolder getAdvancement(ResourceLocation id) {
|
||||
return Minecraft.getInstance().getConnection().getAdvancements().get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the {@link RecipeManager} from the client side}
|
||||
*/
|
||||
@Override
|
||||
public RecipeManager getRecipeManager()
|
||||
{
|
||||
public RecipeManager getRecipeManager() {
|
||||
return Minecraft.getInstance().getConnection().getRecipeManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the level from the client side}
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public Level getUnsidedLevel()
|
||||
{
|
||||
public Level getUnsidedLevel() {
|
||||
return Minecraft.getInstance().level;
|
||||
}
|
||||
|
||||
@@ -136,8 +125,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
* because the server isn't available on the client
|
||||
*/
|
||||
@Override
|
||||
public MinecraftServer getServer()
|
||||
{
|
||||
public MinecraftServer getServer() {
|
||||
throw new UnsupportedOperationException("Attempted to get server in client command");
|
||||
}
|
||||
|
||||
@@ -146,9 +134,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
* because the server side level isn't available on the client side
|
||||
*/
|
||||
@Override
|
||||
public ServerLevel getLevel()
|
||||
{
|
||||
public ServerLevel getLevel() {
|
||||
throw new UnsupportedOperationException("Attempted to get server level in client command");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -85,6 +85,7 @@ import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceMetadata;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -280,20 +281,10 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
public static void dispatchRenderStage(RenderLevelStageEvent.Stage stage, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum)
|
||||
{
|
||||
var mc = Minecraft.getInstance();
|
||||
var profiler = mc.getProfiler();
|
||||
profiler.push(stage.toString());
|
||||
MinecraftForge.EVENT_BUS.post(new RenderLevelStageEvent(stage, levelRenderer, poseStack, projectionMatrix, renderTick, mc.getPartialTick(), camera, frustum));
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
public static void dispatchRenderStage(RenderType renderType, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum)
|
||||
{
|
||||
public static void dispatchRenderStage(RenderType renderType, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) {
|
||||
RenderLevelStageEvent.Stage stage = RenderLevelStageEvent.Stage.fromRenderType(renderType);
|
||||
if (stage != null)
|
||||
dispatchRenderStage(stage, levelRenderer, poseStack, projectionMatrix, renderTick, camera, frustum);
|
||||
stage.dispatch(levelRenderer, poseStack, projectionMatrix, renderTick, camera, frustum);
|
||||
}
|
||||
|
||||
public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, float partialTick, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
||||
@@ -619,62 +610,6 @@ public class ForgeHooksClient
|
||||
MinecraftForge.EVENT_BUS.post(new MovementInputUpdateEvent(player, movementInput));
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
Event event = new ScreenEvent.MouseButtonPressed.Pre(guiScreen, mouseX, mouseY, button);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseClickedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled)
|
||||
{
|
||||
Event event = new ScreenEvent.MouseButtonPressed.Post(guiScreen, mouseX, mouseY, button, handled);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getResult() == Event.Result.DEFAULT ? handled : event.getResult() == Event.Result.ALLOW;
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseReleasedPre(Screen guiScreen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
Event event = new ScreenEvent.MouseButtonReleased.Pre(guiScreen, mouseX, mouseY, button);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseReleasedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled)
|
||||
{
|
||||
Event event = new ScreenEvent.MouseButtonReleased.Post(guiScreen, mouseX, mouseY, button, handled);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getResult() == Event.Result.DEFAULT ? handled : event.getResult() == Event.Result.ALLOW;
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseDragPre(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
Event event = new ScreenEvent.MouseDragged.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
Event event = new ScreenEvent.MouseDragged.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseScrollPre(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
{
|
||||
Window mainWindow = guiScreen.getMinecraft().getWindow();
|
||||
double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth();
|
||||
double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight();
|
||||
Event event = new ScreenEvent.MouseScrolled.Pre(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScreenMouseScrollPost(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
{
|
||||
Window mainWindow = guiScreen.getMinecraft().getWindow();
|
||||
double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth();
|
||||
double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight();
|
||||
Event event = new ScreenEvent.MouseScrolled.Post(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyPressedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
Event event = new ScreenEvent.KeyPressed.Pre(guiScreen, keyCode, scanCode, modifiers);
|
||||
@@ -717,22 +652,6 @@ public class ForgeHooksClient
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onMouseButtonPre(int button, int action, int mods)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new InputEvent.MouseButton.Pre(button, action, mods));
|
||||
}
|
||||
|
||||
public static void onMouseButtonPost(int button, int action, int mods)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.MouseButton.Post(button, action, mods));
|
||||
}
|
||||
|
||||
public static boolean onMouseScroll(MouseHandler mouseHelper, double scrollDelta)
|
||||
{
|
||||
Event event = new InputEvent.MouseScrollingEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos());
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onKeyInput(int key, int scanCode, int action, int modifiers)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.Key(key, scanCode, action, modifiers));
|
||||
@@ -770,21 +689,11 @@ public class ForgeHooksClient
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SpriteContents loadSpriteContents(
|
||||
ResourceLocation name,
|
||||
Resource resource,
|
||||
FrameSize frameSize,
|
||||
NativeImage image,
|
||||
AnimationMetadataSection animationMeta
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static SpriteContents loadSpriteContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, ResourceMetadata animationMeta) {
|
||||
try {
|
||||
ForgeTextureMetadata forgeMeta = ForgeTextureMetadata.forResource(resource);
|
||||
return forgeMeta.getLoader() == null ? null : forgeMeta.getLoader().loadContents(name, resource, frameSize, image, animationMeta, forgeMeta);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Unable to get Forge metadata for {}, falling back to vanilla loading", name);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.RecipeBookCategories;
|
||||
import net.minecraft.world.inventory.RecipeBookType;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
@@ -39,10 +40,10 @@ public final class RecipeBookManager
|
||||
* Finds the category the specified recipe should display in, or null if none.
|
||||
*/
|
||||
@Nullable
|
||||
public static <T extends Recipe<?>> RecipeBookCategories findCategories(RecipeType<T> type, T recipe)
|
||||
public static <T extends Recipe<?>> RecipeBookCategories findCategories(RecipeType<T> type, RecipeHolder<T> recipe)
|
||||
{
|
||||
var lookup = RECIPE_CATEGORY_LOOKUPS.get(type);
|
||||
return lookup != null ? lookup.apply(recipe) : null;
|
||||
return lookup != null ? lookup.apply(recipe.value()) : null;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||
import net.minecraft.client.resources.PlayerSkin;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -141,11 +142,11 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
public static class AddLayers extends EntityRenderersEvent
|
||||
{
|
||||
private final Map<EntityType<?>, EntityRenderer<?>> renderers;
|
||||
private final Map<String, EntityRenderer<? extends Player>> skinMap;
|
||||
private final Map<PlayerSkin.Model, EntityRenderer<? extends Player>> skinMap;
|
||||
private final EntityRendererProvider.Context context;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public AddLayers(Map<EntityType<?>, EntityRenderer<?>> renderers, Map<String, EntityRenderer<? extends Player>> playerRenderers, EntityRendererProvider.Context context)
|
||||
public AddLayers(Map<EntityType<?>, EntityRenderer<?>> renderers, Map<PlayerSkin.Model, EntityRenderer<? extends Player>> playerRenderers, EntityRendererProvider.Context context)
|
||||
{
|
||||
this.renderers = renderers;
|
||||
this.skinMap = playerRenderers;
|
||||
@@ -159,7 +160,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* {@linkplain ModelLayers#PLAYER regular player model} and {@code slim} for the
|
||||
* {@linkplain ModelLayers#PLAYER_SLIM slim player model}.
|
||||
*/
|
||||
public Set<String> getSkins()
|
||||
public Set<PlayerSkin.Model> getSkins()
|
||||
{
|
||||
return skinMap.keySet();
|
||||
}
|
||||
@@ -174,7 +175,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public <R extends LivingEntityRenderer<? extends Player, ? extends EntityModel<? extends Player>>> R getSkin(String skinName)
|
||||
public <R extends LivingEntityRenderer<? extends Player, ? extends EntityModel<? extends Player>>> R getSkin(PlayerSkin.Model skinName)
|
||||
{
|
||||
return (R) skinMap.get(skinName);
|
||||
}
|
||||
|
||||
@@ -24,12 +24,9 @@ import org.lwjgl.glfw.GLFW;
|
||||
* @see Key
|
||||
* @see InteractionKeyMappingTriggered
|
||||
*/
|
||||
public abstract class InputEvent extends Event
|
||||
{
|
||||
public abstract class InputEvent extends Event {
|
||||
@ApiStatus.Internal
|
||||
protected InputEvent()
|
||||
{
|
||||
}
|
||||
protected InputEvent() {}
|
||||
|
||||
/**
|
||||
* Fired when a mouse button is pressed/released. Sub-events get fired {@link Pre before} and {@link Post after} this happens.
|
||||
@@ -41,15 +38,13 @@ public abstract class InputEvent extends Event
|
||||
* @see Pre
|
||||
* @see Post
|
||||
*/
|
||||
public static abstract class MouseButton extends InputEvent
|
||||
{
|
||||
public static abstract class MouseButton extends InputEvent {
|
||||
private final int button;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected MouseButton(int button, int action, int modifiers)
|
||||
{
|
||||
protected MouseButton(int button, int action, int modifiers) {
|
||||
this.button = button;
|
||||
this.action = action;
|
||||
this.modifiers = modifiers;
|
||||
@@ -61,8 +56,7 @@ public abstract class InputEvent extends Event
|
||||
* @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_'
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__buttons.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getButton()
|
||||
{
|
||||
public int getButton() {
|
||||
return this.button;
|
||||
}
|
||||
|
||||
@@ -72,8 +66,7 @@ public abstract class InputEvent extends Event
|
||||
* @see InputConstants#PRESS
|
||||
* @see InputConstants#RELEASE
|
||||
*/
|
||||
public int getAction()
|
||||
{
|
||||
public int getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
@@ -88,8 +81,7 @@ public abstract class InputEvent extends Event
|
||||
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getModifiers()
|
||||
{
|
||||
public int getModifiers() {
|
||||
return this.modifiers;
|
||||
}
|
||||
|
||||
@@ -105,11 +97,9 @@ public abstract class InputEvent extends Event
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseButton
|
||||
{
|
||||
public static class Pre extends MouseButton {
|
||||
@ApiStatus.Internal
|
||||
public Pre(int button, int action, int modifiers)
|
||||
{
|
||||
public Pre(int button, int action, int modifiers) {
|
||||
super(button, action, modifiers);
|
||||
}
|
||||
}
|
||||
@@ -124,11 +114,9 @@ public abstract class InputEvent extends Event
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public static class Post extends MouseButton
|
||||
{
|
||||
public static class Post extends MouseButton {
|
||||
@ApiStatus.Internal
|
||||
public Post(int button, int action, int modifiers)
|
||||
{
|
||||
public Post(int button, int action, int modifiers) {
|
||||
super(button, action, modifiers);
|
||||
}
|
||||
}
|
||||
@@ -147,9 +135,9 @@ public abstract class InputEvent extends Event
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class MouseScrollingEvent extends InputEvent
|
||||
{
|
||||
private final double scrollDelta;
|
||||
public static class MouseScrollingEvent extends InputEvent {
|
||||
private final double deltaX;
|
||||
private final double deltaY;
|
||||
private final double mouseX;
|
||||
private final double mouseY;
|
||||
private final boolean leftDown;
|
||||
@@ -157,9 +145,9 @@ public abstract class InputEvent extends Event
|
||||
private final boolean rightDown;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public MouseScrollingEvent(double scrollDelta, boolean leftDown, boolean middleDown, boolean rightDown, double mouseX, double mouseY)
|
||||
{
|
||||
this.scrollDelta = scrollDelta;
|
||||
public MouseScrollingEvent(double deltaX, double deltaY, boolean leftDown, boolean middleDown, boolean rightDown, double mouseX, double mouseY) {
|
||||
this.deltaX = deltaX;
|
||||
this.deltaY = deltaY;
|
||||
this.leftDown = leftDown;
|
||||
this.middleDown = middleDown;
|
||||
this.rightDown = rightDown;
|
||||
@@ -168,50 +156,51 @@ public abstract class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of change / delta of the mouse scroll}
|
||||
* {@return the amount of change / delta of the mouse scroll in the vertical direction}
|
||||
*/
|
||||
public double getScrollDelta()
|
||||
{
|
||||
return this.scrollDelta;
|
||||
public double getDeltaX() {
|
||||
return this.deltaX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of change / delta of the mouse scroll in the horizontal direction}
|
||||
*/
|
||||
public double getDeltaY() {
|
||||
return this.deltaY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the left mouse button is pressed}
|
||||
*/
|
||||
public boolean isLeftDown()
|
||||
{
|
||||
public boolean isLeftDown() {
|
||||
return this.leftDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the right mouse button is pressed}
|
||||
*/
|
||||
public boolean isRightDown()
|
||||
{
|
||||
public boolean isRightDown() {
|
||||
return this.rightDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the middle mouse button is pressed}
|
||||
*/
|
||||
public boolean isMiddleDown()
|
||||
{
|
||||
public boolean isMiddleDown() {
|
||||
return this.middleDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X position of the mouse cursor}
|
||||
*/
|
||||
public double getMouseX()
|
||||
{
|
||||
public double getMouseX() {
|
||||
return this.mouseX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position of the mouse cursor}
|
||||
*/
|
||||
public double getMouseY()
|
||||
{
|
||||
public double getMouseY() {
|
||||
return this.mouseY;
|
||||
}
|
||||
}
|
||||
@@ -224,16 +213,14 @@ public abstract class InputEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Key extends InputEvent
|
||||
{
|
||||
public static class Key extends InputEvent {
|
||||
private final int key;
|
||||
private final int scanCode;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Key(int key, int scanCode, int action, int modifiers)
|
||||
{
|
||||
public Key(int key, int scanCode, int action, int modifiers) {
|
||||
this.key = key;
|
||||
this.scanCode = scanCode;
|
||||
this.action = action;
|
||||
@@ -247,8 +234,7 @@ public abstract class InputEvent extends Event
|
||||
* @see GLFW key constants starting with {@code GLFW_KEY_}
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__keys.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getKey()
|
||||
{
|
||||
public int getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@@ -261,8 +247,7 @@ public abstract class InputEvent extends Event
|
||||
*
|
||||
* @see InputConstants#getKey(int, int)
|
||||
*/
|
||||
public int getScanCode()
|
||||
{
|
||||
public int getScanCode() {
|
||||
return this.scanCode;
|
||||
}
|
||||
|
||||
@@ -273,8 +258,7 @@ public abstract class InputEvent extends Event
|
||||
* @see InputConstants#RELEASE
|
||||
* @see InputConstants#REPEAT
|
||||
*/
|
||||
public int getAction()
|
||||
{
|
||||
public int getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
@@ -289,8 +273,7 @@ public abstract class InputEvent extends Event
|
||||
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getModifiers()
|
||||
{
|
||||
public int getModifiers() {
|
||||
return this.modifiers;
|
||||
}
|
||||
}
|
||||
@@ -313,16 +296,14 @@ public abstract class InputEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class InteractionKeyMappingTriggered extends InputEvent
|
||||
{
|
||||
public static class InteractionKeyMappingTriggered extends InputEvent {
|
||||
private final int button;
|
||||
private final KeyMapping keyMapping;
|
||||
private final InteractionHand hand;
|
||||
private boolean handSwing = true;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public InteractionKeyMappingTriggered(int button, KeyMapping keyMapping, InteractionHand hand)
|
||||
{
|
||||
public InteractionKeyMappingTriggered(int button, KeyMapping keyMapping, InteractionHand hand) {
|
||||
this.button = button;
|
||||
this.keyMapping = keyMapping;
|
||||
this.hand = hand;
|
||||
@@ -333,16 +314,14 @@ public abstract class InputEvent extends Event
|
||||
*
|
||||
* @param value whether to swing the hand
|
||||
*/
|
||||
public void setSwingHand(boolean value)
|
||||
{
|
||||
public void setSwingHand(boolean value) {
|
||||
handSwing = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return whether to swing the hand; always takes effect, regardless of cancellation}
|
||||
*/
|
||||
public boolean shouldSwingHand()
|
||||
{
|
||||
public boolean shouldSwingHand() {
|
||||
return handSwing;
|
||||
}
|
||||
|
||||
@@ -353,40 +332,35 @@ public abstract class InputEvent extends Event
|
||||
* of both event's cancellation.
|
||||
* Will always be {@link InteractionHand#MAIN_HAND} if this is an attack or pick block input.
|
||||
*/
|
||||
public InteractionHand getHand()
|
||||
{
|
||||
public InteractionHand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the mouse button is the left mouse button}
|
||||
*/
|
||||
public boolean isAttack()
|
||||
{
|
||||
public boolean isAttack() {
|
||||
return button == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the mouse button is the right mouse button}
|
||||
*/
|
||||
public boolean isUseItem()
|
||||
{
|
||||
public boolean isUseItem() {
|
||||
return button == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the mouse button is the middle mouse button}
|
||||
*/
|
||||
public boolean isPickBlock()
|
||||
{
|
||||
public boolean isPickBlock() {
|
||||
return button == 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the key mapping which triggered this event}
|
||||
*/
|
||||
public KeyMapping getKeyMapping()
|
||||
{
|
||||
public KeyMapping getKeyMapping() {
|
||||
return keyMapping;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import javax.annotation.Nullable;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
@@ -26,6 +27,8 @@ 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.joml.Matrix4f;
|
||||
|
||||
/**
|
||||
@@ -37,8 +40,7 @@ import org.joml.Matrix4f;
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public class RenderLevelStageEvent extends Event
|
||||
{
|
||||
public class RenderLevelStageEvent extends Event {
|
||||
private final Stage stage;
|
||||
private final LevelRenderer levelRenderer;
|
||||
private final PoseStack poseStack;
|
||||
@@ -48,8 +50,7 @@ public class RenderLevelStageEvent extends Event
|
||||
private final Camera camera;
|
||||
private final Frustum frustum;
|
||||
|
||||
public RenderLevelStageEvent(Stage stage, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, float partialTick, Camera camera, Frustum frustum)
|
||||
{
|
||||
public RenderLevelStageEvent(Stage stage, LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, float partialTick, Camera camera, Frustum frustum) {
|
||||
this.stage = stage;
|
||||
this.levelRenderer = levelRenderer;
|
||||
this.poseStack = poseStack;
|
||||
@@ -64,64 +65,56 @@ public class RenderLevelStageEvent extends Event
|
||||
* {@return the current {@linkplain Stage stage} that is being rendered. Check this before doing rendering to ensure
|
||||
* that rendering happens at the appropriate time.}
|
||||
*/
|
||||
public Stage getStage()
|
||||
{
|
||||
public Stage getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the level renderer}
|
||||
*/
|
||||
public LevelRenderer getLevelRenderer()
|
||||
{
|
||||
public LevelRenderer getLevelRenderer() {
|
||||
return levelRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
public PoseStack getPoseStack() {
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the projection matrix}
|
||||
*/
|
||||
public Matrix4f getProjectionMatrix()
|
||||
{
|
||||
public Matrix4f getProjectionMatrix() {
|
||||
return projectionMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the current "ticks" value in the {@linkplain LevelRenderer level renderer}}
|
||||
*/
|
||||
public int getRenderTick()
|
||||
{
|
||||
public int getRenderTick() {
|
||||
return renderTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the current partialTick value used for rendering}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
public float getPartialTick() {
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the camera}
|
||||
*/
|
||||
public Camera getCamera()
|
||||
{
|
||||
public Camera getCamera() {
|
||||
return camera;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the frustum}
|
||||
*/
|
||||
public Frustum getFrustum()
|
||||
{
|
||||
public Frustum getFrustum() {
|
||||
return frustum;
|
||||
}
|
||||
|
||||
@@ -134,8 +127,7 @@ public class RenderLevelStageEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class RegisterStageEvent extends Event implements IModBusEvent
|
||||
{
|
||||
public static class RegisterStageEvent extends Event implements IModBusEvent {
|
||||
/**
|
||||
* @param name The name of your Stage.
|
||||
* @param renderType
|
||||
@@ -144,8 +136,7 @@ public class RenderLevelStageEvent extends Event
|
||||
*
|
||||
* @throws IllegalArgumentException if the RenderType passed is already mapped to a Stage.
|
||||
*/
|
||||
public Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException
|
||||
{
|
||||
public Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException {
|
||||
return Stage.register(name, renderType);
|
||||
}
|
||||
}
|
||||
@@ -154,8 +145,7 @@ public class RenderLevelStageEvent extends Event
|
||||
* A time during level rendering for you to render custom things into the world.
|
||||
* @see RegisterStageEvent
|
||||
*/
|
||||
public static class Stage
|
||||
{
|
||||
public static class Stage {
|
||||
private static final Map<RenderType, Stage> RENDER_TYPE_STAGES = new HashMap<>();
|
||||
|
||||
/**
|
||||
@@ -215,27 +205,23 @@ public class RenderLevelStageEvent extends Event
|
||||
|
||||
private final String name;
|
||||
|
||||
private Stage(String name)
|
||||
{
|
||||
private Stage(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private static Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException
|
||||
{
|
||||
private static Stage register(ResourceLocation name, @Nullable RenderType renderType) throws IllegalArgumentException {
|
||||
Stage stage = new Stage(name.toString());
|
||||
if (renderType != null && RENDER_TYPE_STAGES.putIfAbsent(renderType, stage) != null)
|
||||
throw new IllegalArgumentException("Attempted to replace an existing RenderLevelStageEvent.Stage for a RenderType: Stage = " + stage + ", RenderType = " + renderType);
|
||||
return stage;
|
||||
}
|
||||
|
||||
private static Stage register(String name, @Nullable RenderType renderType) throws IllegalArgumentException
|
||||
{
|
||||
private static Stage register(String name, @Nullable RenderType renderType) throws IllegalArgumentException {
|
||||
return register(new ResourceLocation(name), renderType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -243,9 +229,18 @@ public class RenderLevelStageEvent extends Event
|
||||
* {@return the {@linkplain Stage stage} bound to the {@linkplain RenderType render type}, or null if no value is present}
|
||||
*/
|
||||
@Nullable
|
||||
public static Stage fromRenderType(RenderType renderType)
|
||||
{
|
||||
public static Stage fromRenderType(RenderType renderType) {
|
||||
return RENDER_TYPE_STAGES.get(renderType);
|
||||
}
|
||||
|
||||
/** Internal just to make our patch smaller, it just fires the event. If you have good reason for this to be external, ask. */
|
||||
@ApiStatus.Internal
|
||||
public void dispatch(LevelRenderer levelRenderer, PoseStack poseStack, Matrix4f projectionMatrix, int renderTick, Camera camera, Frustum frustum) {
|
||||
var mc = Minecraft.getInstance();
|
||||
var profiler = mc.getProfiler();
|
||||
profiler.push(this.toString());
|
||||
MinecraftForge.EVENT_BUS.post(new RenderLevelStageEvent(this, levelRenderer, poseStack, projectionMatrix, renderTick, mc.getPartialTick(), camera, frustum));
|
||||
profiler.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,21 +39,18 @@ import java.util.function.Consumer;
|
||||
* @see KeyInput
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class ScreenEvent extends Event
|
||||
{
|
||||
public abstract class ScreenEvent extends Event {
|
||||
private final Screen screen;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected ScreenEvent(Screen screen)
|
||||
{
|
||||
protected ScreenEvent(Screen screen) {
|
||||
this.screen = Objects.requireNonNull(screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the screen that caused this event}
|
||||
*/
|
||||
public Screen getScreen()
|
||||
{
|
||||
public Screen getScreen() {
|
||||
return screen;
|
||||
}
|
||||
|
||||
@@ -68,16 +65,14 @@ public abstract class ScreenEvent extends Event
|
||||
* @see Init.Pre
|
||||
* @see Init.Post
|
||||
*/
|
||||
public static abstract class Init extends ScreenEvent
|
||||
{
|
||||
public static abstract class Init extends ScreenEvent {
|
||||
private final Consumer<GuiEventListener> add;
|
||||
private final Consumer<GuiEventListener> remove;
|
||||
|
||||
private final List<GuiEventListener> listenerList;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected Init(Screen screen, List<GuiEventListener> listenerList, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
protected Init(Screen screen, List<GuiEventListener> listenerList, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
|
||||
super(screen);
|
||||
this.listenerList = Collections.unmodifiableList(listenerList);
|
||||
this.add = add;
|
||||
@@ -87,8 +82,7 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* {@return unmodifiable view of list of event listeners on the screen}
|
||||
*/
|
||||
public List<GuiEventListener> getListenersList()
|
||||
{
|
||||
public List<GuiEventListener> getListenersList() {
|
||||
return listenerList;
|
||||
}
|
||||
|
||||
@@ -97,8 +91,7 @@ public abstract class ScreenEvent extends Event
|
||||
*
|
||||
* @param listener the listener to add
|
||||
*/
|
||||
public void addListener(GuiEventListener listener)
|
||||
{
|
||||
public void addListener(GuiEventListener listener) {
|
||||
add.accept(listener);
|
||||
}
|
||||
|
||||
@@ -107,8 +100,7 @@ public abstract class ScreenEvent extends Event
|
||||
*
|
||||
* @param listener the listener to remove
|
||||
*/
|
||||
public void removeListener(GuiEventListener listener)
|
||||
{
|
||||
public void removeListener(GuiEventListener listener) {
|
||||
remove.accept(listener);
|
||||
}
|
||||
|
||||
@@ -123,11 +115,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends Init
|
||||
{
|
||||
public static class Pre extends Init {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
public Pre(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
|
||||
super(screen, list, add, remove);
|
||||
}
|
||||
}
|
||||
@@ -140,11 +130,9 @@ public abstract class ScreenEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends Init
|
||||
{
|
||||
public static class Post extends Init {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
public Post(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
|
||||
super(screen, list, add, remove);
|
||||
}
|
||||
}
|
||||
@@ -157,16 +145,14 @@ public abstract class ScreenEvent extends Event
|
||||
* @see Render.Pre
|
||||
* @see Render.Post
|
||||
*/
|
||||
public static abstract class Render extends ScreenEvent
|
||||
{
|
||||
public static abstract class Render extends ScreenEvent {
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
private final float partialTick;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected Render(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
protected Render(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
super(screen);
|
||||
this.guiGraphics = guiGraphics;
|
||||
this.mouseX = mouseX;
|
||||
@@ -177,32 +163,28 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* {@return the gui graphics used for rendering}
|
||||
*/
|
||||
public GuiGraphics getGuiGraphics()
|
||||
{
|
||||
public GuiGraphics getGuiGraphics() {
|
||||
return guiGraphics;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X coordinate of the mouse pointer}
|
||||
*/
|
||||
public int getMouseX()
|
||||
{
|
||||
public int getMouseX() {
|
||||
return mouseX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y coordinate of the mouse pointer}
|
||||
*/
|
||||
public int getMouseY()
|
||||
{
|
||||
public int getMouseY() {
|
||||
return mouseY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
public float getPartialTick() {
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
@@ -216,11 +198,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends Render
|
||||
{
|
||||
public static class Pre extends Render {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
public Pre(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
super(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
}
|
||||
}
|
||||
@@ -233,11 +213,9 @@ public abstract class ScreenEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends Render
|
||||
{
|
||||
public static class Post extends Render {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
public Post(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
super(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
}
|
||||
}
|
||||
@@ -252,13 +230,11 @@ public abstract class ScreenEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class BackgroundRendered extends ScreenEvent
|
||||
{
|
||||
public static class BackgroundRendered extends ScreenEvent {
|
||||
private final GuiGraphics guiGraphics;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BackgroundRendered(Screen screen, GuiGraphics guiGraphics)
|
||||
{
|
||||
public BackgroundRendered(Screen screen, GuiGraphics guiGraphics) {
|
||||
super(screen);
|
||||
this.guiGraphics = guiGraphics;
|
||||
}
|
||||
@@ -266,8 +242,7 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* {@return the gui graphics used for rendering}
|
||||
*/
|
||||
public GuiGraphics getGuiGraphics()
|
||||
{
|
||||
public GuiGraphics getGuiGraphics() {
|
||||
return guiGraphics;
|
||||
}
|
||||
}
|
||||
@@ -284,15 +259,13 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RenderInventoryMobEffects extends ScreenEvent
|
||||
{
|
||||
public static class RenderInventoryMobEffects extends ScreenEvent {
|
||||
private final int availableSpace;
|
||||
private boolean compact;
|
||||
private int horizontalOffset;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RenderInventoryMobEffects(Screen screen, int availableSpace, boolean compact, int horizontalOffset)
|
||||
{
|
||||
public RenderInventoryMobEffects(Screen screen, int availableSpace, boolean compact, int horizontalOffset) {
|
||||
super(screen);
|
||||
this.availableSpace = availableSpace;
|
||||
this.compact = compact;
|
||||
@@ -302,48 +275,42 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* The available space to the right of the inventory.
|
||||
*/
|
||||
public int getAvailableSpace()
|
||||
{
|
||||
public int getAvailableSpace() {
|
||||
return availableSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the effects should be rendered in compact mode (only icons, no text), or the default full size.
|
||||
*/
|
||||
public boolean isCompact()
|
||||
{
|
||||
public boolean isCompact() {
|
||||
return compact;
|
||||
}
|
||||
|
||||
/**
|
||||
* The distance from the left side of the screen that the effect stack is rendered. Positive values shift this more to the right.
|
||||
*/
|
||||
public int getHorizontalOffset()
|
||||
{
|
||||
public int getHorizontalOffset() {
|
||||
return horizontalOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the horizontal offset of the effect stack
|
||||
*/
|
||||
public void setHorizontalOffset(int offset)
|
||||
{
|
||||
public void setHorizontalOffset(int offset) {
|
||||
horizontalOffset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the horizontal offset of the effect stack. Negative values are acceptable.
|
||||
*/
|
||||
public void addHorizontalOffset(int offset)
|
||||
{
|
||||
public void addHorizontalOffset(int offset) {
|
||||
horizontalOffset += offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the effects should be rendered in compact mode (only icons, no text), or the default full size.
|
||||
*/
|
||||
public void setCompact(boolean compact)
|
||||
{
|
||||
public void setCompact(boolean compact) {
|
||||
this.compact = compact;
|
||||
}
|
||||
}
|
||||
@@ -357,14 +324,12 @@ public abstract class ScreenEvent extends Event
|
||||
* @see MouseDragged
|
||||
* @see MouseScrolled
|
||||
*/
|
||||
private static abstract class MouseInput extends ScreenEvent
|
||||
{
|
||||
private static abstract class MouseInput extends ScreenEvent {
|
||||
private final double mouseX;
|
||||
private final double mouseY;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected MouseInput(Screen screen, double mouseX, double mouseY)
|
||||
{
|
||||
protected MouseInput(Screen screen, double mouseX, double mouseY) {
|
||||
super(screen);
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
@@ -373,16 +338,14 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* {@return the X position of the mouse cursor, relative to the screen}
|
||||
*/
|
||||
public double getMouseX()
|
||||
{
|
||||
public double getMouseX() {
|
||||
return mouseX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position of the mouse cursor, relative to the screen}
|
||||
*/
|
||||
public double getMouseY()
|
||||
{
|
||||
public double getMouseY() {
|
||||
return mouseY;
|
||||
}
|
||||
}
|
||||
@@ -394,13 +357,11 @@ public abstract class ScreenEvent extends Event
|
||||
* @see MouseButtonPressed.Pre
|
||||
* @see MouseButtonPressed.Post
|
||||
*/
|
||||
public static abstract class MouseButtonPressed extends MouseInput
|
||||
{
|
||||
public static abstract class MouseButtonPressed extends MouseInput {
|
||||
private final int button;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public MouseButtonPressed(Screen screen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
public MouseButtonPressed(Screen screen, double mouseX, double mouseY, int button) {
|
||||
super(screen, mouseX, mouseY);
|
||||
this.button = button;
|
||||
}
|
||||
@@ -411,8 +372,7 @@ public abstract class ScreenEvent extends Event
|
||||
* @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_'
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__buttons.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getButton()
|
||||
{
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -427,11 +387,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseButtonPressed
|
||||
{
|
||||
public static class Pre extends MouseButtonPressed {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button) {
|
||||
super(screen, mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
@@ -452,13 +410,11 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static class Post extends MouseButtonPressed
|
||||
{
|
||||
public static class Post extends MouseButtonPressed {
|
||||
private final boolean handled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled)
|
||||
{
|
||||
public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) {
|
||||
super(screen, mouseX, mouseY, button);
|
||||
this.handled = handled;
|
||||
}
|
||||
@@ -466,8 +422,7 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* {@return {@code true} if the mouse click was already handled by its screen}
|
||||
*/
|
||||
public boolean wasHandled()
|
||||
{
|
||||
public boolean wasHandled() {
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
@@ -480,13 +435,11 @@ public abstract class ScreenEvent extends Event
|
||||
* @see MouseButtonReleased.Pre
|
||||
* @see MouseButtonReleased.Post
|
||||
*/
|
||||
public static abstract class MouseButtonReleased extends MouseInput
|
||||
{
|
||||
public static abstract class MouseButtonReleased extends MouseInput {
|
||||
private final int button;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public MouseButtonReleased(Screen screen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
public MouseButtonReleased(Screen screen, double mouseX, double mouseY, int button) {
|
||||
super(screen, mouseX, mouseY);
|
||||
this.button = button;
|
||||
}
|
||||
@@ -497,8 +450,7 @@ public abstract class ScreenEvent extends Event
|
||||
* @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_'
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__buttons.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getButton()
|
||||
{
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -513,11 +465,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseButtonReleased
|
||||
{
|
||||
public static class Pre extends MouseButtonReleased {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button) {
|
||||
super(screen, mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
@@ -538,13 +488,11 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static class Post extends MouseButtonReleased
|
||||
{
|
||||
public static class Post extends MouseButtonReleased {
|
||||
private final boolean handled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled)
|
||||
{
|
||||
public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) {
|
||||
super(screen, mouseX, mouseY, button);
|
||||
this.handled = handled;
|
||||
}
|
||||
@@ -552,8 +500,7 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* @return {@code true} if the mouse release was already handled by its screen
|
||||
*/
|
||||
public boolean wasHandled()
|
||||
{
|
||||
public boolean wasHandled() {
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
@@ -566,15 +513,13 @@ public abstract class ScreenEvent extends Event
|
||||
* @see MouseDragged.Pre
|
||||
* @see MouseDragged.Post
|
||||
*/
|
||||
public static abstract class MouseDragged extends MouseInput
|
||||
{
|
||||
public static abstract class MouseDragged extends MouseInput {
|
||||
private final int mouseButton;
|
||||
private final double dragX;
|
||||
private final double dragY;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public MouseDragged(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
public MouseDragged(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
super(screen, mouseX, mouseY);
|
||||
this.mouseButton = mouseButton;
|
||||
this.dragX = dragX;
|
||||
@@ -587,24 +532,21 @@ public abstract class ScreenEvent extends Event
|
||||
* @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_'
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__buttons.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getMouseButton()
|
||||
{
|
||||
public int getMouseButton() {
|
||||
return mouseButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return amount of mouse drag along the X axis}
|
||||
*/
|
||||
public double getDragX()
|
||||
{
|
||||
public double getDragX() {
|
||||
return dragX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return amount of mouse drag along the Y axis}
|
||||
*/
|
||||
public double getDragY()
|
||||
{
|
||||
public double getDragY() {
|
||||
return dragY;
|
||||
}
|
||||
|
||||
@@ -619,11 +561,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseDragged
|
||||
{
|
||||
public static class Pre extends MouseDragged {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
}
|
||||
}
|
||||
@@ -638,11 +578,9 @@ public abstract class ScreenEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends MouseDragged
|
||||
{
|
||||
public static class Post extends MouseDragged {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
}
|
||||
}
|
||||
@@ -655,23 +593,29 @@ public abstract class ScreenEvent extends Event
|
||||
* @see MouseScrolled.Pre
|
||||
* @see MouseScrolled.Post
|
||||
*/
|
||||
public static abstract class MouseScrolled extends MouseInput
|
||||
{
|
||||
private final double scrollDelta;
|
||||
public static abstract class MouseScrolled extends MouseInput {
|
||||
private final double deltaX;
|
||||
private final double deltaY;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public MouseScrolled(Screen screen, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
public MouseScrolled(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
super(screen, mouseX, mouseY);
|
||||
this.scrollDelta = scrollDelta;
|
||||
this.deltaX = deltaX;
|
||||
this.deltaY = deltaY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of change / delta of the mouse scroll}
|
||||
* {@return the amount of change / delta of the mouse scroll in the vertical direction}
|
||||
*/
|
||||
public double getScrollDelta()
|
||||
{
|
||||
return scrollDelta;
|
||||
public double getDeltaX() {
|
||||
return deltaX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of change / delta of the mouse scroll in the horizontal direction}
|
||||
*/
|
||||
public double getDeltaY() {
|
||||
return deltaY;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -685,12 +629,10 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseScrolled
|
||||
{
|
||||
public static class Pre extends MouseScrolled {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
super(screen, mouseX, mouseY, scrollDelta);
|
||||
public Pre(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
super(screen, mouseX, mouseY, deltaX, deltaY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,12 +646,10 @@ public abstract class ScreenEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends MouseScrolled
|
||||
{
|
||||
public static class Post extends MouseScrolled {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
super(screen, mouseX, mouseY, scrollDelta);
|
||||
public Post(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
super(screen, mouseX, mouseY, deltaX, deltaY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -723,15 +663,13 @@ public abstract class ScreenEvent extends Event
|
||||
* @see InputConstants
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_key" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
private static abstract class KeyInput extends ScreenEvent
|
||||
{
|
||||
private static abstract class KeyInput extends ScreenEvent {
|
||||
private final int keyCode;
|
||||
private final int scanCode;
|
||||
private final int modifiers;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected KeyInput(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
protected KeyInput(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen);
|
||||
this.keyCode = keyCode;
|
||||
this.scanCode = scanCode;
|
||||
@@ -745,8 +683,7 @@ public abstract class ScreenEvent extends Event
|
||||
* @see GLFW key constants starting with {@code GLFW_KEY_}
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__keys.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getKeyCode()
|
||||
{
|
||||
public int getKeyCode() {
|
||||
return keyCode;
|
||||
}
|
||||
|
||||
@@ -759,8 +696,7 @@ public abstract class ScreenEvent extends Event
|
||||
*
|
||||
* @see InputConstants#getKey(int, int)
|
||||
*/
|
||||
public int getScanCode()
|
||||
{
|
||||
public int getScanCode() {
|
||||
return scanCode;
|
||||
}
|
||||
|
||||
@@ -775,8 +711,7 @@ public abstract class ScreenEvent extends Event
|
||||
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getModifiers()
|
||||
{
|
||||
public int getModifiers() {
|
||||
return modifiers;
|
||||
}
|
||||
}
|
||||
@@ -788,11 +723,9 @@ public abstract class ScreenEvent extends Event
|
||||
* @see KeyPressed.Pre
|
||||
* @see KeyPressed.Post
|
||||
*/
|
||||
public static abstract class KeyPressed extends KeyInput
|
||||
{
|
||||
public static abstract class KeyPressed extends KeyInput {
|
||||
@ApiStatus.Internal
|
||||
public KeyPressed(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
public KeyPressed(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
@@ -807,11 +740,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends KeyPressed
|
||||
{
|
||||
public static class Pre extends KeyPressed {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
}
|
||||
}
|
||||
@@ -827,11 +758,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends KeyPressed
|
||||
{
|
||||
public static class Post extends KeyPressed {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
}
|
||||
}
|
||||
@@ -844,11 +773,9 @@ public abstract class ScreenEvent extends Event
|
||||
* @see KeyReleased.Pre
|
||||
* @see KeyReleased.Post
|
||||
*/
|
||||
public static abstract class KeyReleased extends KeyInput
|
||||
{
|
||||
public static abstract class KeyReleased extends KeyInput {
|
||||
@ApiStatus.Internal
|
||||
public KeyReleased(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
public KeyReleased(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
@@ -863,11 +790,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends KeyReleased
|
||||
{
|
||||
public static class Pre extends KeyReleased {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
}
|
||||
}
|
||||
@@ -883,11 +808,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends KeyReleased
|
||||
{
|
||||
public static class Post extends KeyReleased {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
}
|
||||
}
|
||||
@@ -901,14 +824,12 @@ public abstract class ScreenEvent extends Event
|
||||
* @see CharacterTyped.Post
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_char" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public static class CharacterTyped extends ScreenEvent
|
||||
{
|
||||
public static class CharacterTyped extends ScreenEvent {
|
||||
private final char codePoint;
|
||||
private final int modifiers;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public CharacterTyped(Screen screen, char codePoint, int modifiers)
|
||||
{
|
||||
public CharacterTyped(Screen screen, char codePoint, int modifiers) {
|
||||
super(screen);
|
||||
this.codePoint = codePoint;
|
||||
this.modifiers = modifiers;
|
||||
@@ -917,8 +838,7 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* {@return the character code point}
|
||||
*/
|
||||
public char getCodePoint()
|
||||
{
|
||||
public char getCodePoint() {
|
||||
return codePoint;
|
||||
}
|
||||
|
||||
@@ -933,8 +853,7 @@ public abstract class ScreenEvent extends Event
|
||||
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getModifiers()
|
||||
{
|
||||
public int getModifiers() {
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
@@ -949,11 +868,9 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends CharacterTyped
|
||||
{
|
||||
public static class Pre extends CharacterTyped {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, char codePoint, int modifiers)
|
||||
{
|
||||
public Pre(Screen screen, char codePoint, int modifiers) {
|
||||
super(screen, codePoint, modifiers);
|
||||
}
|
||||
}
|
||||
@@ -968,11 +885,9 @@ public abstract class ScreenEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends CharacterTyped
|
||||
{
|
||||
public static class Post extends CharacterTyped {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, char codePoint, int modifiers)
|
||||
{
|
||||
public Post(Screen screen, char codePoint, int modifiers) {
|
||||
super(screen, codePoint, modifiers);
|
||||
}
|
||||
}
|
||||
@@ -991,15 +906,13 @@ public abstract class ScreenEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Opening extends ScreenEvent
|
||||
{
|
||||
public static class Opening extends ScreenEvent {
|
||||
@Nullable
|
||||
private final Screen currentScreen;
|
||||
private Screen newScreen;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Opening(@Nullable Screen currentScreen, Screen screen)
|
||||
{
|
||||
public Opening(@Nullable Screen currentScreen, Screen screen) {
|
||||
super(screen);
|
||||
this.currentScreen = currentScreen;
|
||||
this.newScreen = screen;
|
||||
@@ -1011,8 +924,7 @@ public abstract class ScreenEvent extends Event
|
||||
* May be null if no screen was open.
|
||||
*/
|
||||
@Nullable
|
||||
public Screen getCurrentScreen()
|
||||
{
|
||||
public Screen getCurrentScreen() {
|
||||
return currentScreen;
|
||||
}
|
||||
|
||||
@@ -1020,16 +932,14 @@ public abstract class ScreenEvent extends Event
|
||||
* @return The screen that will be opened if the event is not cancelled. May be null.
|
||||
*/
|
||||
@Nullable
|
||||
public Screen getNewScreen()
|
||||
{
|
||||
public Screen getNewScreen() {
|
||||
return newScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new screen to be opened if the event is not cancelled. May be null.
|
||||
*/
|
||||
public void setNewScreen(Screen newScreen)
|
||||
{
|
||||
public void setNewScreen(Screen newScreen) {
|
||||
this.newScreen = newScreen;
|
||||
}
|
||||
}
|
||||
@@ -1043,11 +953,9 @@ public abstract class ScreenEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Closing extends ScreenEvent
|
||||
{
|
||||
public static class Closing extends ScreenEvent {
|
||||
@ApiStatus.Internal
|
||||
public Closing(Screen screen)
|
||||
{
|
||||
public Closing(Screen screen) {
|
||||
super(screen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,63 +136,4 @@ public interface IForgeGuiGraphics
|
||||
|
||||
self().blit(texture, x, y, boundsWidth, boundsHeight, 0.0f,0.0f, rectWidth, rectHeight, rectWidth, rectHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of {@link GuiGraphics#blitNineSliced(ResourceLocation, int, int, int, int, int, int, int, int, int)} that supports specifying the texture's size.
|
||||
*/
|
||||
default void blitNineSlicedSized(ResourceLocation texture, int x, int y, int width, int height, int sliceSize, int uWidth, int vHeight, int uOffset, int vOffset,
|
||||
int textureWidth, int textureHeight)
|
||||
{
|
||||
blitNineSlicedSized(texture, x, y, width, height, sliceSize, sliceSize, uWidth, vHeight, uOffset, vOffset, textureWidth, textureHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of {@link GuiGraphics#blitNineSliced(ResourceLocation, int, int, int, int, int, int, int, int, int, int)} that supports specifying the texture's size.
|
||||
*/
|
||||
default void blitNineSlicedSized(ResourceLocation texture, int x, int y, int width, int height, int sliceWidth, int sliceHeight, int uWidth, int vHeight,
|
||||
int uOffset, int vOffset, int textureWidth, int textureHeight)
|
||||
{
|
||||
blitNineSlicedSized(texture, x, y, width, height, sliceWidth, sliceHeight, sliceWidth, sliceHeight, uWidth, vHeight, uOffset, vOffset, textureWidth, textureHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of {@link GuiGraphics#blitNineSliced(ResourceLocation, int, int, int, int, int, int, int, int, int, int, int, int)} that supports specifying the texture's size.
|
||||
*/
|
||||
default void blitNineSlicedSized(ResourceLocation texture, int x, int y, int width, int height, int cornerWidth, int cornerHeight, int edgeWidth, int edgeHeight,
|
||||
int uWidth, int vHeight, int uOffset, int vOffset, int textureWidth, int textureHeight)
|
||||
{
|
||||
cornerWidth = Math.min(cornerWidth, width / 2);
|
||||
edgeWidth = Math.min(edgeWidth, width / 2);
|
||||
cornerHeight = Math.min(cornerHeight, height / 2);
|
||||
edgeHeight = Math.min(edgeHeight, height / 2);
|
||||
GuiGraphics self = self();
|
||||
if (width == uWidth && height == vHeight)
|
||||
{
|
||||
self.blit(texture, x, y, uOffset, vOffset, width, height, textureWidth, textureHeight);
|
||||
}
|
||||
else if (height == vHeight)
|
||||
{
|
||||
self.blit(texture, x, y, uOffset, vOffset, cornerWidth, height, textureWidth, textureHeight);
|
||||
self.blitRepeating(texture, x + cornerWidth, y, width - edgeWidth - cornerWidth, height, uOffset + cornerWidth, vOffset, uWidth - edgeWidth - cornerWidth, vHeight, textureWidth, textureHeight);
|
||||
self.blit(texture, x + width - edgeWidth, y, uOffset + uWidth - edgeWidth, vOffset, edgeWidth, height, textureWidth, textureHeight);
|
||||
}
|
||||
else if (width == uWidth)
|
||||
{
|
||||
self.blit(texture, x, y, uOffset, vOffset, width, cornerHeight, textureWidth, textureHeight);
|
||||
self.blitRepeating(texture, x, y + cornerHeight, width, height - edgeHeight - cornerHeight, uOffset, vOffset + cornerHeight, uWidth, vHeight - edgeHeight - cornerHeight, textureWidth, textureHeight);
|
||||
self.blit(texture, x, y + height - edgeHeight, uOffset, vOffset + vHeight - edgeHeight, width, edgeHeight, textureWidth, textureHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.blit(texture, x, y, uOffset, vOffset, cornerWidth, cornerHeight, textureWidth, textureHeight);
|
||||
self.blitRepeating(texture, x + cornerWidth, y, width - edgeWidth - cornerWidth, cornerHeight, uOffset + cornerWidth, vOffset, uWidth - edgeWidth - cornerWidth, cornerHeight, textureWidth, textureHeight);
|
||||
self.blit(texture, x + width - edgeWidth, y, uOffset + uWidth - edgeWidth, vOffset, edgeWidth, cornerHeight, textureWidth, textureHeight);
|
||||
self.blit(texture, x, y + height - edgeHeight, uOffset, vOffset + vHeight - edgeHeight, cornerWidth, edgeHeight, textureWidth, textureHeight);
|
||||
self.blitRepeating(texture, x + cornerWidth, y + height - edgeHeight, width - edgeWidth - cornerWidth, edgeHeight, uOffset + cornerWidth, vOffset + vHeight - edgeHeight, uWidth - edgeWidth - cornerWidth, edgeHeight, textureWidth, textureHeight);
|
||||
self.blit(texture, x + width - edgeWidth, y + height - edgeHeight, uOffset + uWidth - edgeWidth, vOffset + vHeight - edgeHeight, edgeWidth, edgeHeight, textureWidth, textureHeight);
|
||||
self.blitRepeating(texture, x, y + cornerHeight, cornerWidth, height - edgeHeight - cornerHeight, uOffset, vOffset + cornerHeight, cornerWidth, vHeight - edgeHeight - cornerHeight, textureWidth, textureHeight);
|
||||
self.blitRepeating(texture, x + cornerWidth, y + cornerHeight, width - edgeWidth - cornerWidth, height - edgeHeight - cornerHeight, uOffset + cornerWidth, vOffset + cornerHeight, uWidth - edgeWidth - cornerWidth, vHeight - edgeHeight - cornerHeight, textureWidth, textureHeight);
|
||||
self.blitRepeating(texture, x + width - edgeWidth, y + cornerHeight, cornerWidth, height - edgeHeight - cornerHeight, uOffset + uWidth - edgeWidth, vOffset + cornerHeight, edgeWidth, vHeight - edgeHeight - cornerHeight, textureWidth, textureHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -74,7 +74,7 @@ public interface IClientBlockExtensions
|
||||
*/
|
||||
default boolean addDestroyEffects(BlockState state, Level Level, BlockPos pos, ParticleEngine manager)
|
||||
{
|
||||
return !state.shouldSpawnParticlesOnBreak();
|
||||
return !state.shouldSpawnTerrainParticles();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,8 +117,8 @@ public interface IClientBlockExtensions
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the breaking particles created from the {@link BlockState} passed should be tinted with biome colors.
|
||||
*
|
||||
* Returns true if the breaking particles created from the {@link BlockState} passed should be tinted with biome colors.
|
||||
*
|
||||
* @param state The state of this block
|
||||
* @param level The level the particles are spawning in
|
||||
* @param pos The position of the block
|
||||
|
||||
@@ -80,7 +80,7 @@ public class LoadingErrorScreen extends ErrorScreen {
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
this.renderBackground(guiGraphics);
|
||||
this.renderBackground(guiGraphics, mouseX, mouseY, partialTick);
|
||||
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));
|
||||
|
||||
@@ -311,7 +311,6 @@ public class ModListScreen extends Screen
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
search.tick();
|
||||
modList.setSelected(selected);
|
||||
|
||||
if (!search.getValue().equals(lastFilterText))
|
||||
|
||||
@@ -104,7 +104,7 @@ public class ModMismatchDisconnectedScreen extends Screen
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(guiGraphics);
|
||||
this.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
int textYOffset = modMismatchData.containsMismatches() ? 18 : 0;
|
||||
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);
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
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;
|
||||
@@ -30,6 +31,7 @@ import net.minecraft.world.food.FoodData;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.scores.DisplaySlot;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGuiEvent;
|
||||
@@ -46,8 +48,7 @@ import java.util.List;
|
||||
/**
|
||||
* Forge wrapper around {@link Gui} to be able to render {@link IGuiOverlay HUD overlays}.
|
||||
*/
|
||||
public class ForgeGui extends Gui
|
||||
{
|
||||
public class ForgeGui extends Gui {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final int WHITE = 0xFFFFFF;
|
||||
@@ -64,45 +65,33 @@ public class ForgeGui extends Gui
|
||||
|
||||
private final ForgeDebugScreenOverlay debugOverlay;
|
||||
|
||||
public ForgeGui(Minecraft mc)
|
||||
{
|
||||
public ForgeGui(Minecraft mc) {
|
||||
super(mc, mc.getItemRenderer());
|
||||
debugOverlay = new ForgeDebugScreenOverlay(mc);
|
||||
}
|
||||
|
||||
public Minecraft getMinecraft()
|
||||
{
|
||||
public Minecraft getMinecraft() {
|
||||
return minecraft;
|
||||
}
|
||||
|
||||
public void setupOverlayRenderState(boolean blend, boolean depthTest)
|
||||
{
|
||||
if (blend)
|
||||
{
|
||||
public void setupOverlayRenderState(boolean blend, boolean depthTest) {
|
||||
if (blend) {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
if (depthTest)
|
||||
{
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.disableDepthTest();
|
||||
}
|
||||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, float partialTick)
|
||||
{
|
||||
public void render(GuiGraphics guiGraphics, float partialTick) {
|
||||
this.screenWidth = this.minecraft.getWindow().getGuiScaledWidth();
|
||||
this.screenHeight = this.minecraft.getWindow().getGuiScaledHeight();
|
||||
|
||||
@@ -110,23 +99,19 @@ public class ForgeGui extends Gui
|
||||
leftHeight = 39;
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Pre(minecraft.getWindow(), guiGraphics, partialTick)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
font = minecraft.font;
|
||||
|
||||
this.random.setSeed(tickCount * 312871L);
|
||||
|
||||
GuiOverlayManager.getOverlays().forEach(entry -> {
|
||||
try
|
||||
{
|
||||
try {
|
||||
IGuiOverlay overlay = entry.overlay();
|
||||
if (pre(entry, guiGraphics)) return;
|
||||
overlay.render(this, guiGraphics, partialTick, screenWidth, screenHeight);
|
||||
post(entry, guiGraphics);
|
||||
} catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error rendering overlay '{}'", entry.id(), e);
|
||||
}
|
||||
});
|
||||
@@ -136,69 +121,50 @@ public class ForgeGui extends Gui
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Post(minecraft.getWindow(), guiGraphics, partialTick));
|
||||
}
|
||||
|
||||
public boolean shouldDrawSurvivalElements()
|
||||
{
|
||||
public boolean shouldDrawSurvivalElements() {
|
||||
return minecraft.gameMode.canHurtPlayer() && minecraft.getCameraEntity() instanceof Player;
|
||||
}
|
||||
|
||||
protected void renderSubtitles(GuiGraphics guiGraphics)
|
||||
{
|
||||
protected void renderSubtitles(GuiGraphics guiGraphics) {
|
||||
this.subtitleOverlay.render(guiGraphics);
|
||||
}
|
||||
|
||||
protected void renderBossHealth(GuiGraphics guiGraphics)
|
||||
{
|
||||
protected void renderBossHealth(GuiGraphics guiGraphics) {
|
||||
RenderSystem.defaultBlendFunc();
|
||||
minecraft.getProfiler().push("bossHealth");
|
||||
this.bossOverlay.render(guiGraphics);
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
void renderSpyglassOverlay(GuiGraphics guiGraphics)
|
||||
{
|
||||
void renderSpyglassOverlay(GuiGraphics guiGraphics) {
|
||||
float deltaFrame = this.minecraft.getDeltaFrameTime();
|
||||
this.scopeScale = Mth.lerp(0.5F * deltaFrame, this.scopeScale, 1.125F);
|
||||
if (this.minecraft.options.getCameraType().isFirstPerson())
|
||||
{
|
||||
if (this.minecraft.options.getCameraType().isFirstPerson()) {
|
||||
if (this.minecraft.player.isScoping())
|
||||
{
|
||||
this.renderSpyglassOverlay(guiGraphics, this.scopeScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.scopeScale = 0.5F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void renderHelmet(float partialTick, GuiGraphics guiGraphics)
|
||||
{
|
||||
void renderHelmet(float partialTick, GuiGraphics guiGraphics) {
|
||||
ItemStack itemstack = this.minecraft.player.getInventory().getArmor(3);
|
||||
|
||||
if (this.minecraft.options.getCameraType().isFirstPerson() && !itemstack.isEmpty())
|
||||
{
|
||||
if (this.minecraft.options.getCameraType().isFirstPerson() && !itemstack.isEmpty()) {
|
||||
Item item = itemstack.getItem();
|
||||
if (item == Blocks.CARVED_PUMPKIN.asItem())
|
||||
{
|
||||
renderTextureOverlay(guiGraphics, PUMPKIN_BLUR_LOCATION, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
IClientItemExtensions.of(item).renderHelmetOverlay(itemstack, minecraft.player, this.screenWidth, this.screenHeight, partialTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void renderFrostbite(GuiGraphics guiGraphics)
|
||||
{
|
||||
void renderFrostbite(GuiGraphics guiGraphics) {
|
||||
if (this.minecraft.player.getTicksFrozen() > 0)
|
||||
{
|
||||
this.renderTextureOverlay(guiGraphics, POWDER_SNOW_OUTLINE_LOCATION, this.minecraft.player.getPercentFrozen());
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderArmor(GuiGraphics guiGraphics, int width, int height)
|
||||
{
|
||||
protected void renderArmor(GuiGraphics guiGraphics, int width, int height) {
|
||||
minecraft.getProfiler().push("armor");
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
@@ -206,20 +172,13 @@ public class ForgeGui extends Gui
|
||||
int top = height - leftHeight;
|
||||
|
||||
int level = minecraft.player.getArmorValue();
|
||||
for (int i = 1; level > 0 && i < 20; i += 2)
|
||||
{
|
||||
for (int i = 1; level > 0 && i < 20; i += 2) {
|
||||
if (i < level)
|
||||
{
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 34, 9, 9, 9);
|
||||
}
|
||||
guiGraphics.blitSprite(ARMOR_FULL_SPRITE, left, top, 9, 9);
|
||||
else if (i == level)
|
||||
{
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 25, 9, 9, 9);
|
||||
}
|
||||
guiGraphics.blitSprite(ARMOR_HALF_SPRITE, left, top, 9, 9);
|
||||
else if (i > level)
|
||||
{
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, left, top, 16, 9, 9, 9);
|
||||
}
|
||||
guiGraphics.blitSprite(ARMOR_EMPTY_SPRITE, left, top, 9, 9);
|
||||
left += 8;
|
||||
}
|
||||
leftHeight += 10;
|
||||
@@ -229,16 +188,12 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderPortalOverlay(GuiGraphics guiGraphics, float alpha)
|
||||
{
|
||||
protected void renderPortalOverlay(GuiGraphics guiGraphics, float alpha) {
|
||||
if (alpha > 0.0F)
|
||||
{
|
||||
super.renderPortalOverlay(guiGraphics, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderAir(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
protected void renderAir(int width, int height, GuiGraphics guiGraphics) {
|
||||
minecraft.getProfiler().push("air");
|
||||
Player player = (Player) this.minecraft.getCameraEntity();
|
||||
RenderSystem.enableBlend();
|
||||
@@ -246,14 +201,15 @@ public class ForgeGui extends Gui
|
||||
int top = height - rightHeight;
|
||||
|
||||
int air = player.getAirSupply();
|
||||
if (player.isEyeInFluidType(ForgeMod.WATER_TYPE.get()) || air < 300)
|
||||
{
|
||||
if (player.isEyeInFluidType(ForgeMod.WATER_TYPE.get()) || air < 300) {
|
||||
int full = Mth.ceil((double) (air - 2) * 10.0D / 300.0D);
|
||||
int partial = Mth.ceil((double) air * 10.0D / 300.0D) - full;
|
||||
|
||||
for (int i = 0; i < full + partial; ++i)
|
||||
{
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
|
||||
for (int i = 0; i < full + partial; ++i) {
|
||||
if (i < full)
|
||||
guiGraphics.blitSprite(AIR_SPRITE, left - i * 8 - 9, top, 9, 9);
|
||||
else
|
||||
guiGraphics.blitSprite(AIR_BURSTING_SPRITE, left - i * 8 - 9, top, 9, 9);
|
||||
}
|
||||
rightHeight += 10;
|
||||
}
|
||||
@@ -262,8 +218,7 @@ public class ForgeGui extends Gui
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
public void renderHealth(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
public void renderHealth(int width, int height, GuiGraphics guiGraphics) {
|
||||
minecraft.getProfiler().push("health");
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
@@ -271,19 +226,15 @@ public class ForgeGui extends Gui
|
||||
int health = Mth.ceil(player.getHealth());
|
||||
boolean highlight = healthBlinkTime > (long) tickCount && (healthBlinkTime - (long) tickCount) / 3L % 2L == 1L;
|
||||
|
||||
if (health < this.lastHealth && player.invulnerableTime > 0)
|
||||
{
|
||||
if (health < this.lastHealth && player.invulnerableTime > 0) {
|
||||
this.lastHealthTime = Util.getMillis();
|
||||
this.healthBlinkTime = (long) (this.tickCount + 20);
|
||||
}
|
||||
else if (health > this.lastHealth && player.invulnerableTime > 0)
|
||||
{
|
||||
} else if (health > this.lastHealth && player.invulnerableTime > 0) {
|
||||
this.lastHealthTime = Util.getMillis();
|
||||
this.healthBlinkTime = (long) (this.tickCount + 10);
|
||||
}
|
||||
|
||||
if (Util.getMillis() - this.lastHealthTime > 1000L)
|
||||
{
|
||||
if (Util.getMillis() - this.lastHealthTime > 1000L) {
|
||||
this.lastHealth = health;
|
||||
this.displayHealth = health;
|
||||
this.lastHealthTime = Util.getMillis();
|
||||
@@ -308,9 +259,7 @@ public class ForgeGui extends Gui
|
||||
|
||||
int regen = -1;
|
||||
if (player.hasEffect(MobEffects.REGENERATION))
|
||||
{
|
||||
regen = this.tickCount % Mth.ceil(healthMax + 5.0F);
|
||||
}
|
||||
|
||||
this.renderHearts(guiGraphics, player, left, top, rowHeight, regen, healthMax, health, healthLast, absorb, highlight);
|
||||
|
||||
@@ -318,8 +267,7 @@ public class ForgeGui extends Gui
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
public void renderFood(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
public void renderFood(int width, int height, GuiGraphics guiGraphics) {
|
||||
minecraft.getProfiler().push("food");
|
||||
|
||||
Player player = (Player) this.minecraft.getCameraEntity();
|
||||
@@ -327,54 +275,47 @@ public class ForgeGui extends Gui
|
||||
int left = width / 2 + 91;
|
||||
int top = height - rightHeight;
|
||||
rightHeight += 10;
|
||||
boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic
|
||||
|
||||
FoodData stats = minecraft.player.getFoodData();
|
||||
int level = stats.getFoodLevel();
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
ResourceLocation empty = FOOD_EMPTY_SPRITE;
|
||||
ResourceLocation half = FOOD_HALF_SPRITE;
|
||||
ResourceLocation full = FOOD_FULL_SPRITE;
|
||||
|
||||
if (player.hasEffect(MobEffects.HUNGER)) {
|
||||
empty = FOOD_EMPTY_HUNGER_SPRITE;
|
||||
half = FOOD_HALF_HUNGER_SPRITE;
|
||||
full = FOOD_FULL_HUNGER_SPRITE;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
int idx = i * 2 + 1;
|
||||
int x = left - i * 8 - 9;
|
||||
int y = top;
|
||||
int icon = 16;
|
||||
byte background = 0;
|
||||
|
||||
if (minecraft.player.hasEffect(MobEffects.HUNGER))
|
||||
{
|
||||
icon += 36;
|
||||
background = 13;
|
||||
}
|
||||
if (unused) background = 1; //Probably should be a += 1 but vanilla never uses this
|
||||
|
||||
if (player.getFoodData().getSaturationLevel() <= 0.0F && tickCount % (level * 3 + 1) == 0)
|
||||
{
|
||||
y = top + (random.nextInt(3) - 1);
|
||||
}
|
||||
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, y, 16 + background * 9, 27, 9, 9);
|
||||
guiGraphics.blitSprite(empty, x, y, 9, 9);
|
||||
|
||||
if (idx < level)
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, y, icon + 36, 27, 9, 9);
|
||||
guiGraphics.blitSprite(half, x, y, 9, 9);
|
||||
else if (idx == level)
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, y, icon + 45, 27, 9, 9);
|
||||
guiGraphics.blitSprite(full, x, y, 9, 9);
|
||||
}
|
||||
RenderSystem.disableBlend();
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
protected void renderSleepFade(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
if (minecraft.player.getSleepTimer() > 0)
|
||||
{
|
||||
protected void renderSleepFade(int width, int height, GuiGraphics guiGraphics) {
|
||||
if (minecraft.player.getSleepTimer() > 0) {
|
||||
minecraft.getProfiler().push("sleep");
|
||||
int sleepTime = minecraft.player.getSleepTimer();
|
||||
float opacity = (float) sleepTime / 100.0F;
|
||||
|
||||
if (opacity > 1.0F)
|
||||
{
|
||||
opacity = 1.0F - (float) (sleepTime - 100) / 10.0F;
|
||||
}
|
||||
|
||||
int color = (int) (220.0F * opacity) << 24 | 1052704;
|
||||
guiGraphics.fill(RenderType.guiOverlay(), 0, 0, width, height, color);
|
||||
@@ -382,22 +323,19 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderExperience(int x, GuiGraphics guiGraphics)
|
||||
{
|
||||
protected void renderExperience(int x, GuiGraphics guiGraphics) {
|
||||
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableBlend();
|
||||
|
||||
if (minecraft.gameMode.hasExperience())
|
||||
{
|
||||
super.renderExperienceBar(guiGraphics, x);
|
||||
}
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, GuiGraphics guiGraphics, int x)
|
||||
{
|
||||
public void renderJumpMeter(PlayerRideableJumping playerRideableJumping, GuiGraphics guiGraphics, int x) {
|
||||
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.disableBlend();
|
||||
|
||||
@@ -408,29 +346,22 @@ public class ForgeGui extends Gui
|
||||
guiGraphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
protected void renderHUDText(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
protected void renderHUDText(int width, int height, GuiGraphics guiGraphics) {
|
||||
minecraft.getProfiler().push("forgeHudText");
|
||||
RenderSystem.defaultBlendFunc();
|
||||
|
||||
var listL = new ArrayList<String>();
|
||||
var listR = new ArrayList<String>();
|
||||
|
||||
if (minecraft.isDemo())
|
||||
{
|
||||
if (minecraft.isDemo()) {
|
||||
long time = minecraft.level.getGameTime();
|
||||
if (time >= 120500L)
|
||||
{
|
||||
listR.add(I18n.get("demo.demoExpired"));
|
||||
}
|
||||
else
|
||||
{
|
||||
listR.add(I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int) (120500L - time))));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.minecraft.options.renderDebug)
|
||||
{
|
||||
if (debugOverlay.showDebugScreen()) {
|
||||
debugOverlay.update();
|
||||
listL.addAll(debugOverlay.getLeft());
|
||||
listR.addAll(debugOverlay.getRight());
|
||||
@@ -440,10 +371,8 @@ public class ForgeGui extends Gui
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
int top = 2;
|
||||
for (String msg : listL)
|
||||
{
|
||||
if (msg != null && !msg.isEmpty())
|
||||
{
|
||||
for (String msg : listL) {
|
||||
if (msg != null && !msg.isEmpty()) {
|
||||
guiGraphics.fill(1, top - 1, 2 + font.width(msg) + 1, top + font.lineHeight - 1, -1873784752);
|
||||
guiGraphics.drawString(font, msg, 2, top, 14737632, false);
|
||||
}
|
||||
@@ -451,10 +380,8 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
|
||||
top = 2;
|
||||
for (String msg : listR)
|
||||
{
|
||||
if (msg != null && !msg.isEmpty())
|
||||
{
|
||||
for (String msg : listR) {
|
||||
if (msg != null && !msg.isEmpty()) {
|
||||
int w = font.width(msg);
|
||||
int left = width - 2 - w;
|
||||
guiGraphics.fill(left - 1, top - 1, left + w + 1, top + font.lineHeight - 1, -1873784752);
|
||||
@@ -466,32 +393,25 @@ public class ForgeGui extends Gui
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
protected void renderFPSGraph(GuiGraphics guiGraphics)
|
||||
{
|
||||
if (this.minecraft.options.renderDebug && this.minecraft.options.renderFpsChart)
|
||||
{
|
||||
protected void renderFPSGraph(GuiGraphics guiGraphics) {
|
||||
if (debugOverlay.showDebugScreen())
|
||||
this.debugOverlay.render(guiGraphics);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCache()
|
||||
{
|
||||
public void clearCache() {
|
||||
super.clearCache();
|
||||
this.debugOverlay.clearChunkCache();
|
||||
}
|
||||
|
||||
protected void renderRecordOverlay(int width, int height, float partialTick, GuiGraphics guiGraphics)
|
||||
{
|
||||
if (overlayMessageTime > 0)
|
||||
{
|
||||
protected void renderRecordOverlay(int width, int height, float partialTick, GuiGraphics guiGraphics) {
|
||||
if (overlayMessageTime > 0) {
|
||||
minecraft.getProfiler().push("overlayMessage");
|
||||
float hue = (float) overlayMessageTime - partialTick;
|
||||
int opacity = (int) (hue * 255.0F / 20.0F);
|
||||
if (opacity > 255) opacity = 255;
|
||||
|
||||
if (opacity > 8)
|
||||
{
|
||||
if (opacity > 8) {
|
||||
//Include a shift based on the bar height plus the difference between the height that renderSelectedItemName
|
||||
// renders at (59) and the height that the overlay/status bar renders at (68) by default
|
||||
int yShift = Math.max(leftHeight, rightHeight) + (68 - 59);
|
||||
@@ -512,16 +432,13 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderTitle(int width, int height, float partialTick, GuiGraphics guiGraphics)
|
||||
{
|
||||
if (title != null && titleTime > 0)
|
||||
{
|
||||
protected void renderTitle(int width, int height, float partialTick, GuiGraphics guiGraphics) {
|
||||
if (title != null && titleTime > 0) {
|
||||
minecraft.getProfiler().push("titleAndSubtitle");
|
||||
float age = (float) this.titleTime - partialTick;
|
||||
int opacity = 255;
|
||||
|
||||
if (titleTime > titleFadeOutTime + titleStayTime)
|
||||
{
|
||||
if (titleTime > titleFadeOutTime + titleStayTime) {
|
||||
float f3 = (float) (titleFadeInTime + titleStayTime + titleFadeOutTime) - age;
|
||||
opacity = (int) (f3 * 255.0F / (float) titleFadeInTime);
|
||||
}
|
||||
@@ -529,8 +446,7 @@ public class ForgeGui extends Gui
|
||||
|
||||
opacity = Mth.clamp(opacity, 0, 255);
|
||||
|
||||
if (opacity > 8)
|
||||
{
|
||||
if (opacity > 8) {
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().translate(width / 2D, height / 2D, 0.0D);
|
||||
RenderSystem.enableBlend();
|
||||
@@ -540,8 +456,7 @@ public class ForgeGui extends Gui
|
||||
int l = opacity << 24 & -16777216;
|
||||
guiGraphics.drawString(this.font, this.title.getVisualOrderText(), -this.getFont().width(this.title) / 2, -10, 16777215 | l, true);
|
||||
guiGraphics.pose().popPose();
|
||||
if (this.subtitle != null)
|
||||
{
|
||||
if (this.subtitle != null) {
|
||||
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);
|
||||
@@ -555,8 +470,7 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderChat(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
protected void renderChat(int width, int height, GuiGraphics guiGraphics) {
|
||||
minecraft.getProfiler().push("chat");
|
||||
|
||||
Window window = minecraft.getWindow();
|
||||
@@ -574,30 +488,22 @@ public class ForgeGui extends Gui
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
protected void renderPlayerList(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
Objective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(0);
|
||||
protected void renderPlayerList(int width, int height, GuiGraphics guiGraphics) {
|
||||
Objective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(DisplaySlot.LIST);
|
||||
ClientPacketListener handler = minecraft.player.connection;
|
||||
|
||||
if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null))
|
||||
{
|
||||
if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null)) {
|
||||
this.tabList.setVisible(true);
|
||||
this.tabList.render(guiGraphics, width, this.minecraft.level.getScoreboard(), scoreobjective);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else
|
||||
this.tabList.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderHealthMount(int width, int height, GuiGraphics guiGraphics)
|
||||
{
|
||||
protected void renderHealthMount(int width, int height, GuiGraphics guiGraphics) {
|
||||
Player player = (Player) minecraft.getCameraEntity();
|
||||
Entity tmp = player.getVehicle();
|
||||
if (!(tmp instanceof LivingEntity)) return;
|
||||
|
||||
boolean unused = false;
|
||||
int left_align = width / 2 + 91;
|
||||
|
||||
minecraft.getProfiler().popPush("mountHealth");
|
||||
@@ -609,27 +515,21 @@ public class ForgeGui extends Gui
|
||||
|
||||
if (hearts > 30) hearts = 30;
|
||||
|
||||
final int MARGIN = 52;
|
||||
final int BACKGROUND = MARGIN + (unused ? 1 : 0);
|
||||
final int HALF = MARGIN + 45;
|
||||
final int FULL = MARGIN + 36;
|
||||
|
||||
for (int heart = 0; hearts > 0; heart += 20)
|
||||
{
|
||||
for (int heart = 0; hearts > 0; heart += 20) {
|
||||
int top = height - rightHeight;
|
||||
|
||||
int rowCount = Math.min(hearts, 10);
|
||||
hearts -= rowCount;
|
||||
|
||||
for (int i = 0; i < rowCount; ++i)
|
||||
{
|
||||
for (int i = 0; i < rowCount; ++i) {
|
||||
int x = left_align - i * 8 - 9;
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, top, BACKGROUND, 9, 9, 9);
|
||||
guiGraphics.blitSprite(HEART_VEHICLE_CONTAINER_SPRITE, x, top, 9, 9);
|
||||
|
||||
if (i * 2 + 1 + heart < health)
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, top, FULL, 9, 9, 9);
|
||||
guiGraphics.blitSprite(HEART_VEHICLE_FULL_SPRITE, x, top, 9, 9);
|
||||
else if (i * 2 + 1 + heart == health)
|
||||
guiGraphics.blit(GUI_ICONS_LOCATION, x, top, HALF, 9, 9, 9);
|
||||
guiGraphics.blitSprite(HEART_VEHICLE_HALF_SPRITE, x, top, 9, 9);
|
||||
}
|
||||
|
||||
rightHeight += 10;
|
||||
@@ -638,36 +538,30 @@ public class ForgeGui extends Gui
|
||||
}
|
||||
|
||||
//Helper macros
|
||||
private boolean pre(NamedGuiOverlay overlay, GuiGraphics guiGraphics)
|
||||
{
|
||||
private boolean pre(NamedGuiOverlay overlay, GuiGraphics guiGraphics) {
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Pre(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), overlay));
|
||||
}
|
||||
|
||||
private void post(NamedGuiOverlay overlay, GuiGraphics guiGraphics)
|
||||
{
|
||||
private void post(NamedGuiOverlay overlay, GuiGraphics guiGraphics) {
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Post(minecraft.getWindow(), guiGraphics, minecraft.getFrameTime(), overlay));
|
||||
}
|
||||
|
||||
private static class ForgeDebugScreenOverlay extends DebugScreenOverlay
|
||||
{
|
||||
private static class ForgeDebugScreenOverlay extends DebugScreenOverlay {
|
||||
private final Minecraft mc;
|
||||
|
||||
private ForgeDebugScreenOverlay(Minecraft mc)
|
||||
{
|
||||
private ForgeDebugScreenOverlay(Minecraft mc) {
|
||||
super(mc);
|
||||
this.mc = mc;
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
public void update() {
|
||||
Entity entity = this.mc.getCameraEntity();
|
||||
this.block = entity.pick(rayTraceDistance, 0.0F, false);
|
||||
this.liquid = entity.pick(rayTraceDistance, 0.0F, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGameInformation(GuiGraphics guiGraphics)
|
||||
{
|
||||
protected void drawGameInformation(GuiGraphics guiGraphics) {
|
||||
// Replicate the depth test state "leak" caused by the text that is rendered here in vanilla
|
||||
// being flushed when the graphs start drawing (PR #9539)
|
||||
RenderSystem.disableDepthTest();
|
||||
@@ -676,18 +570,16 @@ public class ForgeGui extends Gui
|
||||
@Override
|
||||
protected void drawSystemInformation(GuiGraphics guiGraphics) {}
|
||||
|
||||
private List<String> getLeft()
|
||||
{
|
||||
private List<String> getLeft() {
|
||||
List<String> ret = this.getGameInformation();
|
||||
ret.add("");
|
||||
boolean flag = this.mc.getSingleplayerServer() != null;
|
||||
ret.add("Debug: Pie [shift]: " + (this.mc.options.renderDebugCharts ? "visible" : "hidden") + (flag ? " FPS + TPS" : " FPS") + " [alt]: " + (this.mc.options.renderFpsChart ? "visible" : "hidden"));
|
||||
ret.add("Debug: Pie [shift]: " + (this.renderProfilerChart ? "visible" : "hidden") + (flag ? " FPS + TPS" : " FPS") + " [alt]: " + (this.renderFpsCharts ? "visible" : "hidden"));
|
||||
ret.add("For help: press F3 + Q");
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<String> getRight()
|
||||
{
|
||||
private List<String> getRight() {
|
||||
return this.getSystemInformation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.PlayerRideableJumping;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.scores.DisplaySlot;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
@@ -22,27 +23,29 @@ import org.lwjgl.opengl.GL11;
|
||||
/**
|
||||
* All the vanilla {@linkplain IGuiOverlay HUD overlays} in the order that they render.
|
||||
*/
|
||||
public enum VanillaGuiOverlay
|
||||
{
|
||||
public enum VanillaGuiOverlay {
|
||||
VIGNETTE("vignette", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (Minecraft.useFancyGraphics())
|
||||
{
|
||||
if (Minecraft.useFancyGraphics()) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderVignette(guiGraphics, gui.getMinecraft().getCameraEntity());
|
||||
}
|
||||
}),
|
||||
|
||||
SPYGLASS("spyglass", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderSpyglassOverlay(guiGraphics);
|
||||
}),
|
||||
|
||||
HELMET("helmet", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHelmet(partialTick, guiGraphics);
|
||||
}),
|
||||
|
||||
FROSTBITE("frostbite", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderFrostbite(guiGraphics);
|
||||
}),
|
||||
|
||||
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)) {
|
||||
@@ -50,23 +53,19 @@ public enum VanillaGuiOverlay
|
||||
gui.renderPortalOverlay(guiGraphics, f1);
|
||||
}
|
||||
}),
|
||||
|
||||
HOTBAR("hotbar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
if (!gui.getMinecraft().options.hideGui) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
if (gui.getMinecraft().gameMode.getPlayerMode() == GameType.SPECTATOR)
|
||||
{
|
||||
gui.getSpectatorGui().renderHotbar(guiGraphics);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui.renderHotbar(partialTick, guiGraphics);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
CROSSHAIR("crosshair", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
if (!gui.getMinecraft().options.hideGui) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
|
||||
guiGraphics.pose().pushPose();
|
||||
@@ -75,9 +74,9 @@ public enum VanillaGuiOverlay
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
}),
|
||||
|
||||
BOSS_EVENT_PROGRESS("boss_event_progress", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
if (!gui.getMinecraft().options.hideGui) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
|
||||
guiGraphics.pose().pushPose();
|
||||
@@ -86,127 +85,125 @@ public enum VanillaGuiOverlay
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
}),
|
||||
|
||||
PLAYER_HEALTH("player_health", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHealth(screenWidth, screenHeight, guiGraphics);
|
||||
}
|
||||
}),
|
||||
|
||||
ARMOR_LEVEL("armor_level", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderArmor(guiGraphics, screenWidth, screenHeight);
|
||||
}
|
||||
}),
|
||||
|
||||
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())
|
||||
{
|
||||
if (!isMounted && !gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderFood(screenWidth, screenHeight, guiGraphics);
|
||||
}
|
||||
}),
|
||||
|
||||
AIR_LEVEL("air_level", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderAir(screenWidth, screenHeight, guiGraphics);
|
||||
}
|
||||
}),
|
||||
|
||||
MOUNT_HEALTH("mount_health", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements()) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHealthMount(screenWidth, screenHeight, guiGraphics);
|
||||
}
|
||||
}),
|
||||
|
||||
JUMP_BAR("jump_bar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
PlayerRideableJumping playerRideableJumping = gui.getMinecraft().player.jumpableVehicle();
|
||||
if (playerRideableJumping != null && !gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
if (playerRideableJumping != null && !gui.getMinecraft().options.hideGui) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderJumpMeter(playerRideableJumping, guiGraphics, screenWidth / 2 - 91);
|
||||
}
|
||||
}),
|
||||
|
||||
EXPERIENCE_BAR("experience_bar", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (gui.getMinecraft().player.jumpableVehicle() == null && !gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
if (gui.getMinecraft().player.jumpableVehicle() == null && !gui.getMinecraft().options.hideGui) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderExperience(screenWidth / 2 - 91, guiGraphics);
|
||||
}
|
||||
}),
|
||||
|
||||
ITEM_NAME("item_name", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
if (!gui.getMinecraft().options.hideGui) {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
if (gui.getMinecraft().gameMode.getPlayerMode() != GameType.SPECTATOR)
|
||||
{
|
||||
gui.renderSelectedItemName(guiGraphics, Math.max(gui.leftHeight, gui.rightHeight));
|
||||
}
|
||||
else if (gui.getMinecraft().player.isSpectator())
|
||||
{
|
||||
gui.getSpectatorGui().renderTooltip(guiGraphics);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
SLEEP_FADE("sleep_fade", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderSleepFade(screenWidth, screenHeight, guiGraphics);
|
||||
}),
|
||||
|
||||
POTION_ICONS("potion_icons", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderEffects(guiGraphics);
|
||||
}),
|
||||
|
||||
DEBUG_TEXT("debug_text", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderHUDText(screenWidth, screenHeight, guiGraphics);
|
||||
}),
|
||||
|
||||
FPS_GRAPH("fps_graph", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderFPSGraph(guiGraphics);
|
||||
}),
|
||||
|
||||
RECORD_OVERLAY("record_overlay", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderRecordOverlay(screenWidth, screenHeight, partialTick, guiGraphics);
|
||||
}
|
||||
}),
|
||||
|
||||
TITLE_TEXT("title_text", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderTitle(screenWidth, screenHeight, partialTick, guiGraphics);
|
||||
}
|
||||
}),
|
||||
|
||||
SUBTITLES("subtitles", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderSubtitles(guiGraphics);
|
||||
}
|
||||
}),
|
||||
SCOREBOARD("scoreboard", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
SCOREBOARD("scoreboard", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
Scoreboard scoreboard = gui.getMinecraft().level.getScoreboard();
|
||||
Objective objective = null;
|
||||
PlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(gui.getMinecraft().player.getScoreboardName());
|
||||
if (scoreplayerteam != null)
|
||||
{
|
||||
int slot = scoreplayerteam.getColor().getId();
|
||||
if (slot >= 0) objective = scoreboard.getDisplayObjective(3 + slot);
|
||||
if (scoreplayerteam != null) {
|
||||
var slot = DisplaySlot.teamColorToSlot(scoreplayerteam.getColor());
|
||||
if (slot != null)
|
||||
objective = scoreboard.getDisplayObjective(slot);
|
||||
}
|
||||
Objective scoreobjective1 = objective != null ? objective : scoreboard.getDisplayObjective(1);
|
||||
if (scoreobjective1 != null)
|
||||
{
|
||||
gui.displayScoreboardSidebar(guiGraphics, scoreobjective1);
|
||||
}
|
||||
}),
|
||||
CHAT_PANEL("chat_panel", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
if (objective == null)
|
||||
objective = scoreboard.getDisplayObjective(DisplaySlot.SIDEBAR);
|
||||
|
||||
if (objective != null)
|
||||
gui.displayScoreboardSidebar(guiGraphics, objective);
|
||||
}),
|
||||
|
||||
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, guiGraphics);
|
||||
}),
|
||||
PLAYER_LIST("player_list", (gui, guiGraphics, 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);
|
||||
|
||||
@@ -217,20 +214,17 @@ public enum VanillaGuiOverlay
|
||||
final IGuiOverlay overlay;
|
||||
NamedGuiOverlay type;
|
||||
|
||||
VanillaGuiOverlay(String id, IGuiOverlay overlay)
|
||||
{
|
||||
VanillaGuiOverlay(String id, IGuiOverlay overlay) {
|
||||
this.id = new ResourceLocation("minecraft", id);
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ResourceLocation id()
|
||||
{
|
||||
public ResourceLocation id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public NamedGuiOverlay type()
|
||||
{
|
||||
public NamedGuiOverlay type() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class ExtendedButton extends Button
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
int k = !this.active ? 0 : (this.isHoveredOrFocused() ? 2 : 1);
|
||||
guiGraphics.blitWithBorder(WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2);
|
||||
guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
|
||||
|
||||
final FormattedText buttonText = mc.font.ellipsize(this.getMessage(), this.width - 6); // Remove 6 pixels so that the text is always contained within the button's borders
|
||||
guiGraphics.drawCenteredString(mc.font, Language.getInstance().getVisualOrder(buttonText), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, getFGColor());
|
||||
|
||||
@@ -17,8 +17,7 @@ import java.text.DecimalFormat;
|
||||
/**
|
||||
* Slider widget implementation which allows inputting values in a certain range with optional step size.
|
||||
*/
|
||||
public class ForgeSlider extends AbstractSliderButton
|
||||
{
|
||||
public class ForgeSlider extends AbstractSliderButton {
|
||||
protected Component prefix;
|
||||
protected Component suffix;
|
||||
|
||||
@@ -46,8 +45,7 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
* @param precision Only used when {@code stepSize} is 0. Limited to a maximum of 4 (inclusive).
|
||||
* @param drawString Should text be displayed on the widget
|
||||
*/
|
||||
public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString)
|
||||
{
|
||||
public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) {
|
||||
super(x, y, width, height, Component.empty(), 0D);
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
@@ -57,8 +55,7 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
this.value = this.snapToNearest((currentValue - minValue) / (maxValue - minValue));
|
||||
this.drawString = drawString;
|
||||
|
||||
if (stepSize == 0D)
|
||||
{
|
||||
if (stepSize == 0D) {
|
||||
precision = Math.min(precision, 4);
|
||||
|
||||
StringBuilder builder = new StringBuilder("0");
|
||||
@@ -70,13 +67,9 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
builder.append('0');
|
||||
|
||||
this.format = new DecimalFormat(builder.toString());
|
||||
}
|
||||
else if (Mth.equal(this.stepSize, Math.floor(this.stepSize)))
|
||||
{
|
||||
} else if (Mth.equal(this.stepSize, Math.floor(this.stepSize))) {
|
||||
this.format = new DecimalFormat("0");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.format = new DecimalFormat(Double.toString(this.stepSize).replaceAll("\\d", "0"));
|
||||
}
|
||||
|
||||
@@ -86,68 +79,58 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
/**
|
||||
* Overload with {@code stepSize} set to 1, useful for sliders with whole number values.
|
||||
*/
|
||||
public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, boolean drawString)
|
||||
{
|
||||
public ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) {
|
||||
this(x, y, width, height, prefix, suffix, minValue, maxValue, currentValue, 1D, 0, drawString);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Current slider value as a double
|
||||
*/
|
||||
public double getValue()
|
||||
{
|
||||
public double getValue() {
|
||||
return this.value * (maxValue - minValue) + minValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Current slider value as an long
|
||||
*/
|
||||
public long getValueLong()
|
||||
{
|
||||
public long getValueLong() {
|
||||
return Math.round(this.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Current slider value as an int
|
||||
*/
|
||||
public int getValueInt()
|
||||
{
|
||||
public int getValueInt() {
|
||||
return (int) this.getValueLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The new slider value
|
||||
*/
|
||||
public void setValue(double value)
|
||||
{
|
||||
public void setValue(double value) {
|
||||
this.value = this.snapToNearest((value - this.minValue) / (this.maxValue - this.minValue));
|
||||
this.updateMessage();
|
||||
}
|
||||
|
||||
public String getValueString()
|
||||
{
|
||||
public String getValueString() {
|
||||
return this.format.format(this.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY)
|
||||
{
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
this.setValueFromMouse(mouseX);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDrag(double mouseX, double mouseY, double dragX, double dragY)
|
||||
{
|
||||
protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) {
|
||||
super.onDrag(mouseX, mouseY, dragX, dragY);
|
||||
this.setValueFromMouse(mouseX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||
boolean flag = keyCode == GLFW.GLFW_KEY_LEFT;
|
||||
if (flag || keyCode == GLFW.GLFW_KEY_RIGHT)
|
||||
{
|
||||
if (flag || keyCode == GLFW.GLFW_KEY_RIGHT) {
|
||||
if (this.minValue > this.maxValue)
|
||||
flag = !flag;
|
||||
float f = flag ? -1F : 1F;
|
||||
@@ -160,16 +143,14 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setValueFromMouse(double mouseX)
|
||||
{
|
||||
private void setValueFromMouse(double mouseX) {
|
||||
this.setSliderValue((mouseX - (this.getX() + 4)) / (this.width - 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value Percentage of slider range
|
||||
*/
|
||||
private void setSliderValue(double value)
|
||||
{
|
||||
private void setSliderValue(double value) {
|
||||
double oldValue = this.value;
|
||||
this.value = this.snapToNearest(value);
|
||||
if (!Mth.equal(oldValue, this.value))
|
||||
@@ -182,8 +163,7 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
* Snaps the value, so that the displayed value is the nearest multiple of {@code stepSize}.
|
||||
* If {@code stepSize} is 0, no snapping occurs.
|
||||
*/
|
||||
private double snapToNearest(double value)
|
||||
{
|
||||
private double snapToNearest(double value) {
|
||||
if(stepSize <= 0D)
|
||||
return Mth.clamp(value, 0D, 1D);
|
||||
|
||||
@@ -192,40 +172,29 @@ public class ForgeSlider extends AbstractSliderButton
|
||||
value = (stepSize * Math.round(value / stepSize));
|
||||
|
||||
if (this.minValue > this.maxValue)
|
||||
{
|
||||
value = Mth.clamp(value, this.maxValue, this.minValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Mth.clamp(value, this.minValue, this.maxValue);
|
||||
}
|
||||
|
||||
return Mth.map(value, this.minValue, this.maxValue, 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateMessage()
|
||||
{
|
||||
protected void updateMessage() {
|
||||
if (this.drawString)
|
||||
{
|
||||
this.setMessage(Component.literal("").append(prefix).append(this.getValueString()).append(suffix));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setMessage(Component.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyValue() {}
|
||||
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
final Minecraft mc = Minecraft.getInstance();
|
||||
guiGraphics.blitWithBorder(SLIDER_LOCATION, this.getX(), this.getY(), 0, getTextureY(), this.width, this.height, 200, 20, 2, 3, 2, 2);
|
||||
|
||||
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);
|
||||
guiGraphics.blitSprite(this.getSprite(), this.getX(), this.getY(), this.getWidth(), this.getHeight());
|
||||
guiGraphics.blitSprite(this.getHandleSprite(), this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 8, this.getHeight());
|
||||
|
||||
renderScrollingString(guiGraphics, mc.font, 2, getFGColor() | Mth.ceil(this.alpha * 255.0F) << 24);
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBackground(GuiGraphics guiGraphics)
|
||||
{
|
||||
this.parent.renderBackground(guiGraphics);
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.parent.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
public class ModEntry extends ObjectSelectionList.Entry<ModEntry> {
|
||||
|
||||
@@ -25,8 +25,7 @@ import java.util.List;
|
||||
/**
|
||||
* Abstract scroll panel class.
|
||||
*/
|
||||
public abstract class ScrollPanel extends AbstractContainerEventHandler implements Renderable, NarratableEntry
|
||||
{
|
||||
public abstract class ScrollPanel extends AbstractContainerEventHandler implements Renderable, NarratableEntry {
|
||||
private final Minecraft client;
|
||||
protected final int width;
|
||||
protected final int height;
|
||||
@@ -54,8 +53,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
* @param top the offset from the top (y coord)
|
||||
* @param left the offset from the left (x coord)
|
||||
*/
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left)
|
||||
{
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left) {
|
||||
this(client, width, height, top, left, 4);
|
||||
}
|
||||
|
||||
@@ -67,8 +65,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
* @param left the offset from the left (x coord)
|
||||
* @param border the size of the border
|
||||
*/
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border)
|
||||
{
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border) {
|
||||
this(client, width, height, top, left, border, 6);
|
||||
}
|
||||
|
||||
@@ -81,8 +78,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
* @param border the size of the border
|
||||
* @param barWidth the width of the scroll bar
|
||||
*/
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth)
|
||||
{
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth) {
|
||||
this(client, width, height, top, left, border, barWidth, 0xC0101010, 0xD0101010);
|
||||
}
|
||||
|
||||
@@ -96,8 +92,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
* @param barWidth the width of the scroll bar
|
||||
* @param bgColor the color for the background
|
||||
*/
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColor)
|
||||
{
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColor) {
|
||||
this(client, width, height, top, left, border, barWidth, bgColor, bgColor);
|
||||
}
|
||||
|
||||
@@ -112,8 +107,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
* @param bgColorFrom the start color for the background gradient
|
||||
* @param bgColorTo the end color for the background gradient
|
||||
*/
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColorFrom, int bgColorTo)
|
||||
{
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColorFrom, int bgColorTo) {
|
||||
this(client, width, height, top, left, border, barWidth, bgColorFrom, bgColorTo, 0xFF000000, 0xFF808080, 0xFFC0C0C0);
|
||||
}
|
||||
|
||||
@@ -133,8 +127,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
* @param barColor the color for the scroll bar handle
|
||||
* @param barBorderColor the border color for the scroll bar handle
|
||||
*/
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColorFrom, int bgColorTo, int barBgColor, int barColor, int barBorderColor)
|
||||
{
|
||||
public ScrollPanel(Minecraft client, int width, int height, int top, int left, int border, int barWidth, int bgColorFrom, int bgColorTo, int barBgColor, int barColor, int barBorderColor) {
|
||||
this.client = client;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
@@ -157,16 +150,12 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
/**
|
||||
* Draws the background of the scroll panel. This runs AFTER Scissors are enabled.
|
||||
*/
|
||||
protected void drawBackground(GuiGraphics guiGraphics, Tesselator tess, float partialTick)
|
||||
{
|
||||
protected void drawBackground(GuiGraphics guiGraphics, Tesselator tess, float partialTick) {
|
||||
BufferBuilder worldr = tess.getBuilder();
|
||||
|
||||
if (this.client.level != null)
|
||||
{
|
||||
if (this.client.level != null) {
|
||||
this.drawGradientRect(guiGraphics, this.left, this.top, this.right, this.bottom, bgColorFrom, bgColorTo);
|
||||
}
|
||||
else // Draw dark dirt background
|
||||
{
|
||||
} else { // Draw dark dirt background
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.setShaderTexture(0, Screen.BACKGROUND_LOCATION);
|
||||
final float texScale = 32.0F;
|
||||
@@ -185,38 +174,31 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
*/
|
||||
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; }
|
||||
protected boolean clickPanel(double mouseX, double mouseY, int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private int getMaxScroll()
|
||||
{
|
||||
private int getMaxScroll() {
|
||||
return this.getContentHeight() - (this.height - this.border);
|
||||
}
|
||||
|
||||
private void applyScrollLimits()
|
||||
{
|
||||
private void applyScrollLimits() {
|
||||
int max = getMaxScroll();
|
||||
|
||||
if (max < 0)
|
||||
{
|
||||
max /= 2;
|
||||
}
|
||||
|
||||
if (this.scrollDistance < 0.0F)
|
||||
{
|
||||
this.scrollDistance = 0.0F;
|
||||
}
|
||||
|
||||
if (this.scrollDistance > max)
|
||||
{
|
||||
this.scrollDistance = max;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double scroll)
|
||||
{
|
||||
if (scroll != 0)
|
||||
{
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
double scroll = deltaX == 0 ? deltaY : deltaX;
|
||||
if (scroll != 0) {
|
||||
this.scrollDistance += -scroll * getScrollAmount();
|
||||
applyScrollLimits();
|
||||
return true;
|
||||
@@ -224,49 +206,42 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getScrollAmount()
|
||||
{
|
||||
protected int getScrollAmount() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(double mouseX, double mouseY)
|
||||
{
|
||||
public boolean isMouseOver(double mouseX, double mouseY) {
|
||||
return mouseX >= this.left && mouseX <= this.left + this.width &&
|
||||
mouseY >= this.top && mouseY <= this.bottom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (super.mouseClicked(mouseX, mouseY, button))
|
||||
return true;
|
||||
|
||||
this.scrolling = button == 0 && mouseX >= barLeft && mouseX < barLeft + barWidth;
|
||||
if (this.scrolling)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int mouseListY = ((int)mouseY) - this.top - this.getContentHeight() + (int)this.scrollDistance - border;
|
||||
if (mouseX >= left && mouseX <= right && mouseListY < 0)
|
||||
{
|
||||
return this.clickPanel(mouseX - left, mouseY - this.top + (int)this.scrollDistance - border, button);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button)
|
||||
{
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
if (super.mouseReleased(mouseX, mouseY, button))
|
||||
return true;
|
||||
|
||||
boolean ret = this.scrolling;
|
||||
this.scrolling = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getBarHeight()
|
||||
{
|
||||
private int getBarHeight() {
|
||||
int barHeight = (height * height) / this.getContentHeight();
|
||||
|
||||
if (barHeight < 32) barHeight = 32;
|
||||
@@ -278,10 +253,8 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY)
|
||||
{
|
||||
if (this.scrolling)
|
||||
{
|
||||
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||
if (this.scrolling) {
|
||||
int maxScroll = height - getBarHeight();
|
||||
double moved = deltaY / maxScroll;
|
||||
this.scrollDistance += getMaxScroll() * moved;
|
||||
@@ -292,8 +265,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, 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();
|
||||
|
||||
@@ -309,15 +281,12 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
RenderSystem.disableDepthTest();
|
||||
|
||||
int extraHeight = (this.getContentHeight() + border) - height;
|
||||
if (extraHeight > 0)
|
||||
{
|
||||
if (extraHeight > 0) {
|
||||
int barHeight = getBarHeight();
|
||||
|
||||
int barTop = (int)this.scrollDistance * (height - barHeight) / extraHeight + this.top;
|
||||
if (barTop < this.top)
|
||||
{
|
||||
barTop = this.top;
|
||||
}
|
||||
|
||||
int barBgAlpha = this.barBgColor >> 24 & 0xff;
|
||||
int barBgRed = this.barBgColor >> 16 & 0xff;
|
||||
@@ -361,14 +330,12 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
RenderSystem.disableScissor();
|
||||
}
|
||||
|
||||
protected void drawGradientRect(GuiGraphics guiGraphics, 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) {
|
||||
guiGraphics.fillGradient(left, top, right, bottom, color1, color2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends GuiEventListener> children()
|
||||
{
|
||||
public List<? extends GuiEventListener> children() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,7 @@ public class UnicodeGlyphButton extends ExtendedButton
|
||||
{
|
||||
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);
|
||||
guiGraphics.blitWithBorder(WIDGETS_LOCATION, this.getX(), this.getY(), 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2);
|
||||
guiGraphics.blitSprite(SPRITES.get(this.active, this.isHoveredOrFocused()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
|
||||
|
||||
Component buttonText = this.createNarrationMessage();
|
||||
int glyphWidth = (int) (mc.font.width(glyph) * glyphScale);
|
||||
|
||||
@@ -11,11 +11,13 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.packs.repository.RepositorySource;
|
||||
import net.minecraft.server.packs.repository.Pack.Info;
|
||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
||||
import net.minecraft.server.packs.repository.PackSource;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
@@ -37,6 +39,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.server.packs.PackResources;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -163,9 +166,23 @@ public class ClientModLoader
|
||||
var hiddenPacks = new ArrayList<PathPackResources>();
|
||||
for (Entry<IModFile, ? extends PathPackResources> e : modResourcePacks.entrySet())
|
||||
{
|
||||
|
||||
var supplier = new Pack.ResourcesSupplier() {
|
||||
@Override
|
||||
public PackResources openPrimary(String path) {
|
||||
return e.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources openFull(String path, Info info) {
|
||||
return e.getValue(); // TODO: composite
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
IModInfo mod = e.getKey().getModInfos().get(0);
|
||||
final String name = "mod:" + mod.getModId();
|
||||
final Pack modPack = Pack.readMetaAndCreate(name, Component.literal(e.getValue().packId()), false, id -> e.getValue(), PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.DEFAULT);
|
||||
final Pack modPack = Pack.readMetaAndCreate(name, Component.literal(e.getValue().packId()), false, supplier, PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.DEFAULT);
|
||||
if (modPack == null) {
|
||||
// Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
|
||||
ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
|
||||
@@ -178,11 +195,30 @@ public class ClientModLoader
|
||||
hiddenPacks.add(e.getValue());
|
||||
}
|
||||
}
|
||||
var delegating = new DelegatingPackResources("mod_resources", false,
|
||||
new PackMetadataSection(
|
||||
Component.translatable("fml.resources.modresources", hiddenPacks.size()),
|
||||
SharedConstants.getCurrentVersion().getPackVersion(PackType.CLIENT_RESOURCES),
|
||||
Optional.empty()
|
||||
),
|
||||
hiddenPacks
|
||||
);
|
||||
|
||||
var supplier = new Pack.ResourcesSupplier() {
|
||||
@Override
|
||||
public PackResources openPrimary(String path) {
|
||||
return delegating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources openFull(String path, Info info) {
|
||||
return delegating; // TODO: composite
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Create a resource pack merging all mod resources that should be hidden
|
||||
final Pack modResourcesPack = Pack.readMetaAndCreate("mod_resources", Component.literal("Mod Resources"), true,
|
||||
id -> new DelegatingPackResources(id, false, new PackMetadataSection(Component.translatable("fml.resources.modresources", hiddenPacks.size()),
|
||||
SharedConstants.getCurrentVersion().getPackVersion(PackType.CLIENT_RESOURCES)), hiddenPacks),
|
||||
final Pack modResourcesPack = Pack.readMetaAndCreate("mod_resources", Component.literal("Mod Resources"), true, supplier,
|
||||
PackType.CLIENT_RESOURCES, Pack.Position.BOTTOM, PackSource.DEFAULT);
|
||||
packAcceptor.accept(modResourcesPack);
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ package net.minecraftforge.client.textures;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.SpriteContents;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection;
|
||||
import net.minecraft.client.resources.metadata.animation.FrameSize;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceMetadata;
|
||||
import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -29,10 +29,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
*
|
||||
* @see RegisterTextureAtlasSpriteLoadersEvent
|
||||
*/
|
||||
public interface ITextureAtlasSpriteLoader
|
||||
{
|
||||
SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image,
|
||||
AnimationMetadataSection animationMeta, ForgeTextureMetadata forgeMeta);
|
||||
public interface ITextureAtlasSpriteLoader {
|
||||
SpriteContents loadContents(ResourceLocation name, Resource resource, FrameSize frameSize, NativeImage image, ResourceMetadata animationMeta, ForgeTextureMetadata forgeMeta);
|
||||
|
||||
/**
|
||||
* Creates a {@link TextureAtlasSprite} from the given {@link SpriteContents}.
|
||||
|
||||
@@ -7,36 +7,31 @@ package net.minecraftforge.client.textures;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.SpriteContents;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection;
|
||||
import net.minecraft.client.resources.metadata.animation.FrameSize;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceMetadata;
|
||||
|
||||
/**
|
||||
* A helper sprite with UVs spanning the entire texture.
|
||||
* <p>
|
||||
* Useful for baking quads that won't be used with an atlas.
|
||||
*/
|
||||
public class UnitTextureAtlasSprite extends TextureAtlasSprite
|
||||
{
|
||||
public class UnitTextureAtlasSprite extends TextureAtlasSprite {
|
||||
public static final ResourceLocation LOCATION = new ResourceLocation("forge", "unit");
|
||||
public static final UnitTextureAtlasSprite INSTANCE = new UnitTextureAtlasSprite();
|
||||
|
||||
private UnitTextureAtlasSprite()
|
||||
{
|
||||
super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false), AnimationMetadataSection.EMPTY, null), 1, 1, 0, 0);
|
||||
private UnitTextureAtlasSprite() {
|
||||
super(LOCATION, new SpriteContents(LOCATION, new FrameSize(1, 1), new NativeImage(1, 1, false), ResourceMetadata.EMPTY, null), 1, 1, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getU(double u)
|
||||
{
|
||||
return (float) u / 16;
|
||||
public float getU(float u) {
|
||||
return u / 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getV(double v)
|
||||
{
|
||||
return (float) v / 16;
|
||||
public float getV(float v) {
|
||||
return v / 16;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user