mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Modify ScreenEvent.RenderInventoryMobEffects to allow moving the effect stack left or right (#8951)
This commit is contained in:
1 parent
b8b3201372
commit
a4f52f4057
4 files changed
+44
-9
No files matched your search
@@ -1091,10 +1091,11 @@ public class ForgeHooksClient
|
||||
};
|
||||
}
|
||||
|
||||
public static int onScreenPotionSize(Screen screen, int availableSpace, boolean compact)
|
||||
public static ScreenEvent.RenderInventoryMobEffects onScreenPotionSize(Screen screen, int availableSpace, boolean compact, int horizontalOffset)
|
||||
{
|
||||
final ScreenEvent.RenderInventoryMobEffects event = new ScreenEvent.RenderInventoryMobEffects(screen, availableSpace, compact);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? 0 : (event.isCompact() ? 1 : 2);
|
||||
final ScreenEvent.RenderInventoryMobEffects event = new ScreenEvent.RenderInventoryMobEffects(screen, availableSpace, compact, horizontalOffset);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static boolean isBlockInSolidLayer(BlockState state)
|
||||
|
||||
@@ -275,6 +275,7 @@ public abstract class ScreenEvent extends Event
|
||||
/**
|
||||
* Fired ahead of rendering any active mob effects in the {@link EffectRenderingInventoryScreen inventory screen}.
|
||||
* Can be used to select the size of the effects display (full or compact) or even hide or replace vanilla's rendering entirely.
|
||||
* This event can also be used to modify the horizontal position of the stack of effects being rendered.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
|
||||
* Cancelling this event will prevent vanilla rendering.</p>
|
||||
@@ -287,13 +288,15 @@ public abstract class ScreenEvent extends Event
|
||||
{
|
||||
private final int availableSpace;
|
||||
private boolean compact;
|
||||
private int horizontalOffset;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RenderInventoryMobEffects(Screen screen, int availableSpace, boolean compact)
|
||||
public RenderInventoryMobEffects(Screen screen, int availableSpace, boolean compact, int horizontalOffset)
|
||||
{
|
||||
super(screen);
|
||||
this.availableSpace = availableSpace;
|
||||
this.compact = compact;
|
||||
this.horizontalOffset = horizontalOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,6 +315,30 @@ public abstract class ScreenEvent extends Event
|
||||
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()
|
||||
{
|
||||
return horizontalOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the horizontal offset of the effect stack
|
||||
*/
|
||||
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)
|
||||
{
|
||||
horizontalOffset += offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the effects should be rendered in compact mode (only icons, no text), or the default full size.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user