1.21 Update

Co-authored-by: RealMangoRage <[email protected]>
Co-authored-by: Daniel Norris <[email protected]>
Co-authored-by: Ven <[email protected]>
This commit is contained in:
committed 2024-06-13 10:42:32 -07:00
1 parent 3d9e12a71d
commit 4a2db246e0
941 files changed
+3119 -4266

No files matched your search

@@ -14,7 +14,6 @@ import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.ApiStatus;
import java.util.ArrayList;
import java.util.List;
/**
@@ -24,32 +23,27 @@ import java.util.List;
* @see DebugText
* @see Chat
*/
public abstract class CustomizeGuiOverlayEvent extends Event
{
public abstract class CustomizeGuiOverlayEvent extends Event {
private final Window window;
private final GuiGraphics guiGraphics;
private final float partialTick;
@ApiStatus.Internal
protected CustomizeGuiOverlayEvent(Window window, GuiGraphics guiGraphics, float partialTick)
{
protected CustomizeGuiOverlayEvent(Window window, GuiGraphics guiGraphics, float partialTick) {
this.window = window;
this.guiGraphics = guiGraphics;
this.partialTick = partialTick;
}
public Window getWindow()
{
public Window getWindow() {
return window;
}
public GuiGraphics getGuiGraphics()
{
public GuiGraphics getGuiGraphics() {
return guiGraphics;
}
public float getPartialTick()
{
public float getPartialTick() {
return partialTick;
}
@@ -63,16 +57,14 @@ public abstract class CustomizeGuiOverlayEvent extends Event
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
@Cancelable
public static class BossEventProgress extends CustomizeGuiOverlayEvent
{
public static class BossEventProgress extends CustomizeGuiOverlayEvent {
private final LerpingBossEvent bossEvent;
private final int x;
private final int y;
private int increment;
@ApiStatus.Internal
public BossEventProgress(Window window, GuiGraphics guiGraphics, float partialTick, LerpingBossEvent bossEvent, int x, int y, int increment)
{
public BossEventProgress(Window window, GuiGraphics guiGraphics, float partialTick, LerpingBossEvent bossEvent, int x, int y, int increment) {
super(window, guiGraphics, partialTick);
this.bossEvent = bossEvent;
this.x = x;
@@ -83,32 +75,28 @@ public abstract class CustomizeGuiOverlayEvent extends Event
/**
* @return the boss health bar currently being rendered
*/
public LerpingBossEvent getBossEvent()
{
public LerpingBossEvent getBossEvent() {
return bossEvent;
}
/**
* {@return the X position of the boss health bar}
*/
public int getX()
{
public int getX() {
return x;
}
/**
* {@return the Y position of the boss health bar}
*/
public int getY()
{
public int getY() {
return y;
}
/**
* {@return the Y position increment before rendering the next boss health bar}
*/
public int getIncrement()
{
public int getIncrement() {
return increment;
}
@@ -117,8 +105,7 @@ public abstract class CustomizeGuiOverlayEvent extends Event
*
* @param increment the new Y position increment
*/
public void setIncrement(int increment)
{
public void setIncrement(int increment) {
this.increment = increment;
}
}
@@ -132,15 +119,13 @@ public abstract class CustomizeGuiOverlayEvent extends Event
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
public static class DebugText extends CustomizeGuiOverlayEvent
{
public static class DebugText extends CustomizeGuiOverlayEvent {
private final List<String> text;
private final Side side;
@ApiStatus.Internal
public DebugText(Window window, GuiGraphics guiGraphics, float partialTick, List<String> text, Side side)
{
public DebugText(Window window, GuiGraphics guiGraphics, float partialTick, List<String> text, Side side) {
super(window, guiGraphics, partialTick);
this.text = text;
this.side = side;
@@ -149,21 +134,10 @@ public abstract class CustomizeGuiOverlayEvent extends Event
/**
* @return the modifiable list of text to render on the side
*/
public List<String> getText()
{
public List<String> getText() {
return this.text;
}
@Deprecated(forRemoval = true, since = "1.20.6")
public List<String> getLeft() {
return Side.Left.equals(this.side) ? this.text : new ArrayList<>();
}
@Deprecated(forRemoval = true, since = "1.20.6")
public List<String> getRight() {
return Side.Right.equals(this.side) ? this.text : new ArrayList<>();
}
/**
* @return the side of the text getting rendered.
*/
@@ -185,14 +159,12 @@ public abstract class CustomizeGuiOverlayEvent extends Event
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
public static class Chat extends CustomizeGuiOverlayEvent
{
public static class Chat extends CustomizeGuiOverlayEvent {
private int posX;
private int posY;
@ApiStatus.Internal
public Chat(Window window, GuiGraphics guiGraphics, float partialTick, int posX, int posY)
{
public Chat(Window window, GuiGraphics guiGraphics, float partialTick, int posX, int posY) {
super(window, guiGraphics, partialTick);
this.setPosX(posX);
this.setPosY(posY);
@@ -201,8 +173,7 @@ public abstract class CustomizeGuiOverlayEvent extends Event
/**
* @return the X position of the chat messages overlay
*/
public int getPosX()
{
public int getPosX() {
return posX;
}
@@ -211,16 +182,14 @@ public abstract class CustomizeGuiOverlayEvent extends Event
*
* @param posX the new X position
*/
public void setPosX(int posX)
{
public void setPosX(int posX) {
this.posX = posX;
}
/**
* @return the Y position of the chat messages overlay
*/
public int getPosY()
{
public int getPosY() {
return posY;
}
@@ -229,8 +198,7 @@ public abstract class CustomizeGuiOverlayEvent extends Event
*
* @param posY the new y position
*/
public void setPosY(int posY)
{
public void setPosY(int posY) {
this.posY = posY;
}
}
@@ -164,16 +164,6 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
return (R)skinMap.get(skinName);
}
/**
* @deprecated Use getEntitySkin, return type down graded to EntityRenderer instead of LivingEntityRenderer
*/
@Nullable
@SuppressWarnings("unchecked")
@Deprecated(forRemoval = true, since = "1.20.2")
public <R extends LivingEntityRenderer<? extends Player, ? extends EntityModel<? extends Player>>> R getSkin(PlayerSkin.Model skinName) {
return (R)skinMap.get(skinName);
}
/**
* Returns an entity renderer for the given entity type.
*
@@ -188,16 +178,6 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
return (R)renderers.get(entityType);
}
/**
* @deprecated Use getEntityRenderer, return type down graded to EntityRenderer instead of LivingEntityRenderer
*/
@Nullable
@SuppressWarnings("unchecked")
@Deprecated(forRemoval = true, since = "1.20.2")
public <T extends LivingEntity, R extends LivingEntityRenderer<T, ? extends EntityModel<T>>> R getRenderer(EntityType<? extends T> entityType) {
return (R) renderers.get(entityType);
}
/**
* {@return the set of entity models}
*/
@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.function.Consumer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.fml.event.IModBusEvent;
@@ -23,6 +24,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.Camera;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.MouseHandler;
import net.minecraft.client.gui.GuiGraphics;
@@ -254,4 +256,12 @@ public final class ForgeEventFactoryClient {
public static void onRenderScreenBackground(Screen screen, GuiGraphics guiGraphics) {
fire(new ScreenEvent.BackgroundRendered(screen, guiGraphics));
}
public static void onRenderTickStart(DeltaTracker timer) {
post(new TickEvent.RenderTickEvent.Start(timer));
}
public static void onRenderTickEnd(DeltaTracker timer) {
post(new TickEvent.RenderTickEvent.End(timer));
}
}
@@ -9,6 +9,7 @@ import com.google.common.base.Preconditions;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.model.geometry.IGeometryLoader;
import net.minecraftforge.eventbus.api.Cancelable;
@@ -25,12 +26,9 @@ import java.util.Set;
/**
* Houses events related to models.
*/
public abstract class ModelEvent extends Event
{
public abstract class ModelEvent extends Event {
@ApiStatus.Internal
protected ModelEvent()
{
}
protected ModelEvent() { }
/**
* Fired while the {@link ModelManager} is reloading models, after the model registry is set up, but before it's
@@ -48,14 +46,12 @@ public abstract class ModelEvent 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 ModifyBakingResult extends ModelEvent implements IModBusEvent
{
private final Map<ResourceLocation, BakedModel> models;
public static class ModifyBakingResult extends ModelEvent implements IModBusEvent {
private final Map<ModelResourceLocation, BakedModel> models;
private final ModelBakery modelBakery;
@ApiStatus.Internal
public ModifyBakingResult(Map<ResourceLocation, BakedModel> models, ModelBakery modelBakery)
{
public ModifyBakingResult(Map<ModelResourceLocation, BakedModel> models, ModelBakery modelBakery) {
this.models = models;
this.modelBakery = modelBakery;
}
@@ -63,16 +59,14 @@ public abstract class ModelEvent extends Event
/**
* @return the modifiable registry map of models and their model names
*/
public Map<ResourceLocation, BakedModel> getModels()
{
public Map<ModelResourceLocation, BakedModel> getModels() {
return models;
}
/**
* @return the model loader
*/
public ModelBakery getModelBakery()
{
public ModelBakery getModelBakery() {
return modelBakery;
}
}
@@ -88,15 +82,13 @@ public abstract class ModelEvent 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 BakingCompleted extends ModelEvent implements IModBusEvent
{
public static class BakingCompleted extends ModelEvent implements IModBusEvent {
private final ModelManager modelManager;
private final Map<ResourceLocation, BakedModel> models;
private final Map<ModelResourceLocation, BakedModel> models;
private final ModelBakery modelBakery;
@ApiStatus.Internal
public BakingCompleted(ModelManager modelManager, Map<ResourceLocation, BakedModel> models, ModelBakery modelBakery)
{
public BakingCompleted(ModelManager modelManager, Map<ModelResourceLocation, BakedModel> models, ModelBakery modelBakery) {
this.modelManager = modelManager;
this.models = models;
this.modelBakery = modelBakery;
@@ -105,24 +97,21 @@ public abstract class ModelEvent extends Event
/**
* @return the model manager
*/
public ModelManager getModelManager()
{
public ModelManager getModelManager() {
return modelManager;
}
/**
* @return an unmodifiable view of the registry map of models and their model names
*/
public Map<ResourceLocation, BakedModel> getModels()
{
public Map<ModelResourceLocation, BakedModel> getModels() {
return models;
}
/**
* @return the model loader
*/
public ModelBakery getModelBakery()
{
public ModelBakery getModelBakery() {
return modelBakery;
}
}
@@ -136,21 +125,18 @@ public abstract class ModelEvent 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 RegisterAdditional extends ModelEvent implements IModBusEvent
{
private final Set<ResourceLocation> models;
public static class RegisterAdditional extends ModelEvent implements IModBusEvent {
private final Set<ModelResourceLocation> models;
@ApiStatus.Internal
public RegisterAdditional(Set<ResourceLocation> models)
{
public RegisterAdditional(Set<ModelResourceLocation> models) {
this.models = models;
}
/**
* Registers a model to be loaded, along with its dependencies.
*/
public void register(ResourceLocation model)
{
public void register(ModelResourceLocation model) {
models.add(model);
}
}
@@ -163,22 +149,19 @@ public abstract class ModelEvent 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 RegisterGeometryLoaders extends ModelEvent implements IModBusEvent
{
public static class RegisterGeometryLoaders extends ModelEvent implements IModBusEvent {
private final Map<ResourceLocation, IGeometryLoader<?>> loaders;
@ApiStatus.Internal
public RegisterGeometryLoaders(Map<ResourceLocation, IGeometryLoader<?>> loaders)
{
public RegisterGeometryLoaders(Map<ResourceLocation, IGeometryLoader<?>> loaders) {
this.loaders = loaders;
}
/**
* Registers a new geometry loader.
*/
public void register(String name, IGeometryLoader<?> loader)
{
var key = new ResourceLocation(ModLoadingContext.get().getActiveNamespace(), name);
public void register(String name, IGeometryLoader<?> loader) {
var key = ResourceLocation.fromNamespaceAndPath(ModLoadingContext.get().getActiveNamespace(), name);
Preconditions.checkArgument(!loaders.containsKey(key), "Geometry loader already registered: " + key);
loaders.put(key, loader);
}
@@ -61,7 +61,7 @@ public class RegisterNamedRenderTypesEvent extends Event implements IModBusEvent
*/
public void register(String name, RenderType blockRenderType, RenderType entityRenderType, RenderType fabulousEntityRenderType)
{
var key = new ResourceLocation(ModLoadingContext.get().getActiveNamespace(), name);
var key = ResourceLocation.fromNamespaceAndPath(ModLoadingContext.get().getActiveNamespace(), name);
Preconditions.checkArgument(!renderTypes.containsKey(key), "Render type already registered: " + key);
Preconditions.checkArgument(blockRenderType.format() == DefaultVertexFormat.BLOCK, "The block render type must use the BLOCK vertex format.");
Preconditions.checkArgument(blockRenderType.getChunkLayerId() >= 0, "Only chunk render types can be used for block rendering. Query RenderType#chunkBufferLayers() for a list.");
@@ -26,22 +26,19 @@ import java.util.Map;
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
*/
public class RegisterTextureAtlasSpriteLoadersEvent extends Event implements IModBusEvent
{
public class RegisterTextureAtlasSpriteLoadersEvent extends Event implements IModBusEvent {
private final Map<ResourceLocation, ITextureAtlasSpriteLoader> loaders;
@ApiStatus.Internal
public RegisterTextureAtlasSpriteLoadersEvent(Map<ResourceLocation, ITextureAtlasSpriteLoader> loaders)
{
public RegisterTextureAtlasSpriteLoadersEvent(Map<ResourceLocation, ITextureAtlasSpriteLoader> loaders) {
this.loaders = loaders;
}
/**
* Registers a custom {@link ITextureAtlasSpriteLoader sprite loader}.
*/
public void register(String name, ITextureAtlasSpriteLoader loader)
{
var key = new ResourceLocation(ModLoadingContext.get().getActiveNamespace(), name);
public void register(String name, ITextureAtlasSpriteLoader loader) {
var key = ResourceLocation.fromNamespaceAndPath(ModLoadingContext.get().getActiveNamespace(), name);
Preconditions.checkArgument(!loaders.containsKey(key), "Sprite loader already registered: " + key);
loaders.put(key, loader);
}
@@ -217,7 +217,7 @@ public class RenderLevelStageEvent extends Event {
}
private static Stage register(String name, @Nullable RenderType renderType) throws IllegalArgumentException {
return register(new ResourceLocation(name), renderType);
return register(ResourceLocation.parse(name), renderType);
}
@Override
@@ -239,7 +239,7 @@ public class RenderLevelStageEvent extends Event {
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));
MinecraftForge.EVENT_BUS.post(new RenderLevelStageEvent(this, levelRenderer, poseStack, projectionMatrix, renderTick, mc.getTimer().getRealtimeDeltaTicks(), camera, frustum));
profiler.pop();
}
}