mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
[1.19.X] Client code cleanup, updates, and other refactors (#8786)
* Revert "Allow safely registering RenderType predicates at any time (#8685)"
This reverts commit be7275443f.
* Renderable API refactors
- Rename "render values" to "context"
- Rename SimpleRenderable to CompositeRenderable to better reflect its use
- Remove IMultipartRenderValues since it doesn't have any real use
- Add extensive customization options to BakedModelRenderable
* ClientRegistry and MinecraftForgeClient refactors
- Add sprite loader manager and registration event
- Add spectator shader manager and registration event
- Add client tooltip factory manager and registration event
- Add recipe book manager and registration event
- Add key mapping registration event
- Remove ClientRegistry, as everything has been moved out of it
- Remove registration methods from MinecraftForgeClient, as they have dedicated events now
* Dimension special effects refactors
- Fold handlers into an extension class and remove public mutable fields
- Add dimension special effects manager and registration event
* HUD overlay refactors
- Rename to IGuiOverlay match vanilla (instead of Ingame)
- Add overlay manager and registration event
- Move vanilla overlays to a standalone enum
* Model loader refactors
- Rename IModelLoader to IGeometryLoader
- Add loader manager and registration event
- Fold all model events into one
- Move registration of additionally loaded models to an event
- Remove ForgeModelBakery and related classes as they served no purpose anymore
* Render properties refactors
- Rename all render properties to client extensions and relocate accordingly
- Move lookups to the respective interfaces
* Model data refactors
- Convert model data to a final class backed by an immutable map and document mutability requirements. This addresses several thread-safety issues in the current implementation which could result in race conditions
- Transfer ownership of the data manager to the client level. This addresses several issues that arise when multiple levels are used at once
* GUI and widget refactors
- Move all widgets to the correct package
- Rename GuiUtils and children to match vanilla naming
* New vertex pipeline API
- Move to vanilla's VertexConsumer
- Roll back recent PR making VertexConsumer format-aware. This is the opposite of what vanilla does, and should not be relevant with the updated lighting pipeline
* Lighting pipeline refactors
- Move to dedicated lighting package
- Separate flat and smooth lighters
- Convert from a vertex pipeline transformer to a pure vertex source (input is baked quads)
* Model geometry API refactors
- Rename IModelGeometry to IUnbakedGeometry
- Rename IModelConfiguration to IGeometryBakingContext
- Rename other elements to match vanilla naming
- Remove current changes to ModelState, as they do not belong there. Transforms should be specified through vanilla's system. ModelState is intended to transfer state from the blockstate JSON
- Remove multipart geometries and geometry parts. After some discussion, these should not be exposed. Instead, geometries should be baked with only the necessary parts enabled
* Make render types a first-class citizen in baked models
- Add named render types (block + entity + fabulous entity)
- Add named render type manager + registration event
- Make BakedModel aware of render types and transfer control over which ones are used to it instead of ItemBlockRenderTypes (fallback)
- (additional) Add concatenated list view. A wrapper for multiple lists that iterates through them in order without the cost of merging them. Useful for merging lists of baked quads
* General event refactors
- Several renames to either match vanilla or improve clarity
- Relocate client chat event dispatching out of common code
* Forge model type refactors
- Rename SeparatePerspectiveModel to SeparateTransformsModel
- Rename ItemModelMesherForge to ForgeItemModelShaper
- Rename DynamicBucketModel to DynamicFluidContainerModel
- Prefix all OBJ-related classes with "Obj" and decouple parsing from construction
- Extract ElementsModel from model loader registry
- Add EmptyModel (baked, unbaked and loader)
- Refactor CompositeModel to take over ItemMultiLayerBakedModel
- Remove FluidModel as it's not used and isn't compatible with the new fluid rendering in modern versions
- Move model loader registration to a proper event handler
- Update names of several JSON fields (backwards-compatible)
- Update datagens to match
* Miscellaneous changes and overlapping patches
- Dispatch all new registration events
- Convert ExtendedServerListData to a record
- Add/remove hooks from ForgeHooksClient as necessary
* Update test mods
* Fix VertexConsumerWrapper returning parent instead of itself
* Additional event cleanup pass
As discussed on Discord:
- Remove "@hidden" and "@see <callsite>" javadoc annotations from all client events and replace them with @ApiStatus.Internal annotation
- Make all events that shouldn't be fired directly into abstract classes with protected constructors
- Another styling pass, just in case (caught some missed classes)
* Add proper deprecation javadocs and de-dupe some vertex consumer code
* Replace sets of chunk render types with a faster BitSet-backed collection
This largely addresses potential performance concerns that using a plain HashSet might involve by making lookups and iteration as linear as they can likely be (aside from using a plain byte/int/long for bit storage). Further performance concerns related to the implementation may be addressed separately, as all the implementation details are hidden from the end user
* Requested changes
- Remove MinecraftForgeClient and move members to Minecraft, IForgeMinecraft and StencilManager
- Allow non-default elements to be passed into VertexConsumer and add support to derived classes
- Move array instantiation out of quad processing in lighting pipeline
- Fix flipped fluid container model
- Set default UV1 to the correct values in the remapping pipeline
- Minor documentation changes
* Add/update EXC entries and fix AT comment
* Add test mod as per Orion's request
* Additional requested changes
* Allow custom model types to request the particle texture to be loaded
* Even more requested changes
* Improve generics in ConcatenatedListView and add missing fallbacks
* Fix fluid render types being bound to the fluid and not its holder
* Remove non-contractual nullability in ChunkRenderTypeSet and add isEmpty
Additionally, introduce chunk render type checks in ItemBlockRenderTypes
Co-authored-by: Dennis C <[email protected]>
This commit is contained in:
1 parent
c2225ab1da
commit
4d074f0a1e
295 files changed
+9929
-11604
No files matched your search
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An immutable ordered set (not implementing {@link java.util.Set}) of chunk {@linkplain RenderType render types}.
|
||||
* <p>
|
||||
* Considerably speeds up lookups and merges of sets of chunk {@linkplain RenderType render types}.
|
||||
* Users should cache their instances of this class whenever possible, as instantiating it is cheap, but not free.
|
||||
*/
|
||||
public sealed class ChunkRenderTypeSet implements Iterable<RenderType>
|
||||
{
|
||||
private static final List<RenderType> CHUNK_RENDER_TYPES_LIST = RenderType.chunkBufferLayers();
|
||||
private static final RenderType[] CHUNK_RENDER_TYPES = CHUNK_RENDER_TYPES_LIST.toArray(new RenderType[0]);
|
||||
|
||||
private static final ChunkRenderTypeSet NONE = new None();
|
||||
private static final ChunkRenderTypeSet ALL = new All();
|
||||
|
||||
public static ChunkRenderTypeSet none()
|
||||
{
|
||||
return NONE;
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet all()
|
||||
{
|
||||
return ALL;
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet of(RenderType... renderTypes)
|
||||
{
|
||||
return of(Arrays.asList(renderTypes));
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet of(Collection<RenderType> renderTypes)
|
||||
{
|
||||
if (renderTypes.isEmpty())
|
||||
return none();
|
||||
return of((Iterable<RenderType>) renderTypes);
|
||||
}
|
||||
|
||||
private static ChunkRenderTypeSet of(Iterable<RenderType> renderTypes)
|
||||
{
|
||||
var bits = new BitSet();
|
||||
for (RenderType renderType : renderTypes)
|
||||
{
|
||||
int index = renderType.getChunkLayerId();
|
||||
Preconditions.checkArgument(index >= 0, "Attempted to create chunk render type set with a non-chunk render type: " + renderType);
|
||||
bits.set(index);
|
||||
}
|
||||
return new ChunkRenderTypeSet(bits);
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet union(ChunkRenderTypeSet... sets)
|
||||
{
|
||||
return union(Arrays.asList(sets));
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet union(Collection<ChunkRenderTypeSet> sets)
|
||||
{
|
||||
if (sets.isEmpty())
|
||||
return none();
|
||||
return union((Iterable<ChunkRenderTypeSet>) sets);
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet union(Iterable<ChunkRenderTypeSet> sets)
|
||||
{
|
||||
var bits = new BitSet();
|
||||
for (var set : sets)
|
||||
bits.or(set.bits);
|
||||
return new ChunkRenderTypeSet(bits);
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet intersection(ChunkRenderTypeSet... sets)
|
||||
{
|
||||
return intersection(Arrays.asList(sets));
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet intersection(Collection<ChunkRenderTypeSet> sets)
|
||||
{
|
||||
if (sets.isEmpty())
|
||||
return all();
|
||||
return intersection((Iterable<ChunkRenderTypeSet>) sets);
|
||||
}
|
||||
|
||||
public static ChunkRenderTypeSet intersection(Iterable<ChunkRenderTypeSet> sets)
|
||||
{
|
||||
var bits = new BitSet();
|
||||
bits.set(0, CHUNK_RENDER_TYPES.length);
|
||||
for (var set : sets)
|
||||
bits.and(set.bits);
|
||||
return new ChunkRenderTypeSet(bits);
|
||||
}
|
||||
|
||||
private final BitSet bits;
|
||||
|
||||
private ChunkRenderTypeSet(BitSet bits)
|
||||
{
|
||||
this.bits = bits;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return bits.isEmpty();
|
||||
}
|
||||
|
||||
public boolean contains(RenderType renderType)
|
||||
{
|
||||
int id = renderType.getChunkLayerId();
|
||||
return id >= 0 && bits.get(id);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<RenderType> iterator()
|
||||
{
|
||||
return new IteratorImpl();
|
||||
}
|
||||
|
||||
public List<RenderType> asList()
|
||||
{
|
||||
return ImmutableList.copyOf(this);
|
||||
}
|
||||
|
||||
private final class IteratorImpl implements Iterator<RenderType>
|
||||
{
|
||||
private int index = bits.nextSetBit(0);
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return index >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType next()
|
||||
{
|
||||
var renderType = CHUNK_RENDER_TYPES[index];
|
||||
index = bits.nextSetBit(index + 1);
|
||||
return renderType;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class None extends ChunkRenderTypeSet
|
||||
{
|
||||
private None()
|
||||
{
|
||||
super(new BitSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(RenderType renderType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<RenderType> iterator()
|
||||
{
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RenderType> asList()
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class All extends ChunkRenderTypeSet
|
||||
{
|
||||
private All()
|
||||
{
|
||||
super(Util.make(new BitSet(), bits -> bits.set(0, CHUNK_RENDER_TYPES.length)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(RenderType renderType)
|
||||
{
|
||||
return renderType.getChunkLayerId() >= 0; // Could just return true for efficiency purposes, but checking is near-free
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<RenderType> iterator()
|
||||
{
|
||||
return CHUNK_RENDER_TYPES_LIST.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RenderType> asList()
|
||||
{
|
||||
return CHUNK_RENDER_TYPES_LIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class ClientCommandHandler
|
||||
MinecraftForge.EVENT_BUS.addListener(ClientCommandHandler::handleClientPlayerLogin);
|
||||
}
|
||||
|
||||
private static void handleClientPlayerLogin(ClientPlayerNetworkEvent.LoggedInEvent event)
|
||||
private static void handleClientPlayerLogin(ClientPlayerNetworkEvent.LoggingIn event)
|
||||
{
|
||||
// some custom server implementations do not send ClientboundCommandsPacket, provide a fallback
|
||||
var suggestionDispatcher = mergeServerCommands(new CommandDispatcher<>(), new CommandBuildContext(event.getPlayer().connection.registryAccess()));
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of teams from the client side
|
||||
* {@return the list of teams from the client side}
|
||||
*/
|
||||
@Override
|
||||
public Collection<String> getAllTeams()
|
||||
@@ -59,7 +59,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of online player names from the client side
|
||||
* {@return the list of online player names from the client side}
|
||||
*/
|
||||
@Override
|
||||
public Collection<String> getOnlinePlayerNames()
|
||||
@@ -68,7 +68,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link Stream} of recipe ids that are available on the client
|
||||
* {@return a {@link Stream} of recipe ids that are available on the client}
|
||||
*/
|
||||
@Override
|
||||
public Stream<ResourceLocation> getRecipeNames()
|
||||
@@ -77,7 +77,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a set of {@link ResourceKey} for levels from the client side
|
||||
* {@return a set of {@link ResourceKey} for levels from the client side}
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourceKey<Level>> levels()
|
||||
@@ -86,7 +86,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link RegistryAccess} from the client side
|
||||
* {@return the {@link RegistryAccess} from the client side}
|
||||
*/
|
||||
@Override
|
||||
public RegistryAccess registryAccess()
|
||||
@@ -95,7 +95,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scoreboard from the client side
|
||||
* {@return the scoreboard from the client side}
|
||||
*/
|
||||
@Override
|
||||
public Scoreboard getScoreboard()
|
||||
@@ -104,7 +104,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the advancement from the id from the client side where the advancement needs to be visible to the player
|
||||
* {@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)
|
||||
@@ -113,7 +113,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link RecipeManager} from the client side
|
||||
* {@return the {@link RecipeManager} from the client side}
|
||||
*/
|
||||
@Override
|
||||
public RecipeManager getRecipeManager()
|
||||
@@ -122,7 +122,7 @@ public class ClientCommandSourceStack extends CommandSourceStack
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the level from the client side
|
||||
* {@return the level from the client side}
|
||||
*/
|
||||
@Override
|
||||
public Level getUnsidedLevel()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.minecraftforge.client.event.RegisterNamedRenderTypesEvent;
|
||||
import net.minecraftforge.client.model.CompositeModel;
|
||||
import net.minecraftforge.client.model.DynamicFluidContainerModel;
|
||||
import net.minecraftforge.client.model.ElementsModel;
|
||||
import net.minecraftforge.client.model.EmptyModel;
|
||||
import net.minecraftforge.client.model.ItemLayerModel;
|
||||
import net.minecraftforge.client.model.SeparateTransformsModel;
|
||||
import net.minecraftforge.client.model.obj.ObjLoader;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD, modid = "forge")
|
||||
public class ClientForgeMod
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onRegisterGeometryLoaders(ModelEvent.RegisterGeometryLoaders event)
|
||||
{
|
||||
event.register("empty", EmptyModel.LOADER);
|
||||
event.register("elements", ElementsModel.Loader.INSTANCE);
|
||||
event.register("obj", ObjLoader.INSTANCE);
|
||||
event.register("fluid_container", DynamicFluidContainerModel.Loader.INSTANCE);
|
||||
event.register("composite", CompositeModel.Loader.INSTANCE);
|
||||
event.register("item_layers", ItemLayerModel.Loader.INSTANCE);
|
||||
event.register("separate_transforms", SeparateTransformsModel.Loader.INSTANCE);
|
||||
|
||||
// TODO: Deprecated. To be removed in 1.20
|
||||
event.register("bucket", DynamicFluidContainerModel.Loader.INSTANCE_DEPRECATED);
|
||||
event.register("item-layers", ItemLayerModel.Loader.INSTANCE_DEPRECATED);
|
||||
event.register("separate-perspective", SeparateTransformsModel.Loader.INSTANCE_DEPRECATED);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterReloadListeners(RegisterClientReloadListenersEvent event)
|
||||
{
|
||||
event.registerReloadListener(ObjLoader.INSTANCE);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterNamedRenderTypes(RegisterNamedRenderTypesEvent event)
|
||||
{
|
||||
event.register("item_unlit", RenderType.translucent(), ForgeRenderTypes.ITEM_UNSORTED_UNLIT_TRANSLUCENT.get());
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ClientRegistry
|
||||
{
|
||||
private static Map<Class<? extends Entity>, ResourceLocation> entityShaderMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Registers a KeyBinding.
|
||||
* Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}.
|
||||
* This method is safe to call during parallel mod loading.
|
||||
*/
|
||||
public static synchronized void registerKeyBinding(KeyMapping key)
|
||||
{
|
||||
Minecraft.getInstance().options.keyMappings = ArrayUtils.add(Minecraft.getInstance().options.keyMappings, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a shader for an entity. This shader gets activated when a spectator begins spectating an entity.
|
||||
* Vanilla examples of this are the green effect for creepers and the invert effect for endermen.
|
||||
* Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}.
|
||||
* This method is safe to call during parallel mod loading.
|
||||
*/
|
||||
public static void registerEntityShader(Class<? extends Entity> entityClass, ResourceLocation shader)
|
||||
{
|
||||
entityShaderMap.put(entityClass, shader);
|
||||
}
|
||||
|
||||
public static ResourceLocation getEntityShader(Class<? extends Entity> entityClass)
|
||||
{
|
||||
return entityShaderMap.get(entityClass);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||
import net.minecraftforge.client.event.RegisterDimensionSpecialEffectsEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Manager for {@link DimensionSpecialEffects} instances.
|
||||
* <p>
|
||||
* Provides a lookup by dimension type.
|
||||
*/
|
||||
public final class DimensionSpecialEffectsManager
|
||||
{
|
||||
private static ImmutableMap<ResourceLocation, DimensionSpecialEffects> EFFECTS;
|
||||
private static DimensionSpecialEffects DEFAULT_EFFECTS;
|
||||
|
||||
/**
|
||||
* Finds the {@link DimensionSpecialEffects} for a given dimension type, or the default if none is registered.
|
||||
*/
|
||||
public static DimensionSpecialEffects getForType(ResourceLocation type)
|
||||
{
|
||||
return EFFECTS.getOrDefault(type, DEFAULT_EFFECTS);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void init()
|
||||
{
|
||||
var effects = new HashMap<ResourceLocation, DimensionSpecialEffects>();
|
||||
DEFAULT_EFFECTS = preRegisterVanillaEffects(effects);
|
||||
var event = new RegisterDimensionSpecialEffectsEvent(effects);
|
||||
ModLoader.get().postEventWithWrapInModOrder(event, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null));
|
||||
EFFECTS = ImmutableMap.copyOf(effects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-registers vanilla dimension effects and returns the default fallback effects instance.
|
||||
* <p>
|
||||
* Borrowed from {@link DimensionSpecialEffects#EFFECTS}.
|
||||
*/
|
||||
private static DimensionSpecialEffects preRegisterVanillaEffects(Map<ResourceLocation, DimensionSpecialEffects> effects)
|
||||
{
|
||||
var overworldEffects = new DimensionSpecialEffects.OverworldEffects();
|
||||
effects.put(BuiltinDimensionTypes.OVERWORLD_EFFECTS, overworldEffects);
|
||||
effects.put(BuiltinDimensionTypes.NETHER_EFFECTS, new DimensionSpecialEffects.NetherEffects());
|
||||
effects.put(BuiltinDimensionTypes.END_EFFECTS, new DimensionSpecialEffects.EndEffects());
|
||||
return overworldEffects;
|
||||
}
|
||||
|
||||
private DimensionSpecialEffectsManager()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
|
||||
|
||||
public abstract class EffectRenderer
|
||||
{
|
||||
public static final EffectRenderer DUMMY = new EffectRenderer()
|
||||
{
|
||||
@Override
|
||||
public void renderInventoryEffect(MobEffectInstance effectInstance, EffectRenderingInventoryScreen<?> gui, PoseStack poseStack, int x, int y, float z)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderHUDEffect(MobEffectInstance effectInstance, GuiComponent gui, PoseStack poseStack, int x, int y, float z, float alpha)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* If the Potion effect should be displayed in the players inventory
|
||||
*
|
||||
* @param effect the active PotionEffect
|
||||
* @return true to display it (default), false to hide it.
|
||||
*/
|
||||
public boolean shouldRender(MobEffectInstance effect)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the standard PotionEffect text (name and duration) should be drawn when this potion is active.
|
||||
*
|
||||
* @param effect the active PotionEffect
|
||||
* @return true to draw the standard text
|
||||
*/
|
||||
public boolean shouldRenderInvText(MobEffectInstance effect)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Potion effect should be displayed in the player's ingame HUD
|
||||
*
|
||||
* @param effect the active PotionEffect
|
||||
* @return true to display it (default), false to hide it.
|
||||
*/
|
||||
public boolean shouldRenderHUD(MobEffectInstance effect)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to draw the this Potion onto the player's inventory when it's active.
|
||||
* This can be used to e.g. render Potion icons from your own texture.
|
||||
*
|
||||
* @param effectInstance the effect instance
|
||||
* @param gui the gui instance
|
||||
* @param poseStack the pose stack
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z level
|
||||
*/
|
||||
public abstract void renderInventoryEffect(MobEffectInstance effectInstance, EffectRenderingInventoryScreen<?> gui, PoseStack poseStack, int x, int y, float z);
|
||||
|
||||
/**
|
||||
* Called to draw the this Potion onto the player's ingame HUD when it's active.
|
||||
* This can be used to e.g. render Potion icons from your own texture.
|
||||
*
|
||||
* @param effectInstance the active PotionEffect
|
||||
* @param gui the gui instance
|
||||
* @param poseStack the pose stack
|
||||
* @param x the x coordinate
|
||||
* @param y the y coordinate
|
||||
* @param z the z level
|
||||
* @param alpha the alpha value, blinks when the potion is about to run out
|
||||
*/
|
||||
public abstract void renderHUDEffect(MobEffectInstance effectInstance, GuiComponent gui, PoseStack poseStack, int x, int y, float z, float alpha);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraftforge.client.event.RegisterEntitySpectatorShadersEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Manager for entity spectator mode shaders.
|
||||
* <p>
|
||||
* Provides a lookup.
|
||||
*/
|
||||
public final class EntitySpectatorShaderManager
|
||||
{
|
||||
private static Map<EntityType<?>, ResourceLocation> SHADERS;
|
||||
|
||||
/**
|
||||
* Finds the path to the spectator mode shader used for the specified entity type, or null if none is registered.
|
||||
*/
|
||||
@Nullable
|
||||
public static ResourceLocation get(EntityType<?> entityType)
|
||||
{
|
||||
return SHADERS.get(entityType);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void init()
|
||||
{
|
||||
var shaders = new HashMap<EntityType<?>, ResourceLocation>();
|
||||
var event = new RegisterEntitySpectatorShadersEvent(shaders);
|
||||
ModLoader.get().postEventWithWrapInModOrder(event, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null));
|
||||
SHADERS = ImmutableMap.copyOf(shaders);
|
||||
}
|
||||
|
||||
private EntitySpectatorShaderManager()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -5,24 +5,10 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
public class ExtendedServerListData {
|
||||
public final String type;
|
||||
public final boolean isCompatible;
|
||||
public int numberOfMods;
|
||||
public String extraReason;
|
||||
public final boolean truncated;
|
||||
|
||||
public ExtendedServerListData(String type, boolean isCompatible, int num, String extraReason)
|
||||
public record ExtendedServerListData(String type, boolean isCompatible, int numberOfMods, String extraReason, boolean truncated)
|
||||
{
|
||||
public ExtendedServerListData(String type, boolean isCompatible, int numberOfMods, String extraReason)
|
||||
{
|
||||
this(type, isCompatible, num, extraReason, false);
|
||||
}
|
||||
|
||||
public ExtendedServerListData(String type, boolean isCompatible, int num, String extraReason, boolean truncated)
|
||||
{
|
||||
this.type = type;
|
||||
this.isCompatible = isCompatible;
|
||||
this.numberOfMods = num;
|
||||
this.extraReason = extraReason;
|
||||
this.truncated = truncated;
|
||||
this(type, isCompatible, numberOfMods, extraReason, false);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FluidContainerColorer implements ItemColor
|
||||
{
|
||||
@Override
|
||||
public int getColor(@NotNull ItemStack stack, int tintIndex)
|
||||
{
|
||||
if (tintIndex != 1) return 0xFFFFFFFF;
|
||||
return FluidUtil.getFluidContained(stack)
|
||||
.map(fstack -> RenderProperties.get(fstack.getFluid()).getColorTint(fstack))
|
||||
.orElse(0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
@@ -6,100 +6,143 @@
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.shaders.FogShape;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.chat.NarratorChatListener;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraft.client.gui.screens.ConfirmScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.client.particle.ParticleRenderType;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.Input;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.ChatSender;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.client.player.Input;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||
import net.minecraftforge.client.event.ClientPlayerChangeGameTypeEvent;
|
||||
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
|
||||
import net.minecraftforge.client.event.ComputeFovModifierEvent;
|
||||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.event.MovementInputUpdateEvent;
|
||||
import net.minecraftforge.client.event.RecipesUpdatedEvent;
|
||||
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
|
||||
import net.minecraftforge.client.event.RegisterShadersEvent;
|
||||
import net.minecraftforge.client.event.RenderArmEvent;
|
||||
import net.minecraftforge.client.event.RenderBlockScreenEffectEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderHighlightEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.client.event.ScreenshotEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.event.ViewportEvent;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundEvent;
|
||||
import net.minecraftforge.client.model.ForgeModelBakery;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||
import net.minecraftforge.client.extensions.common.IClientMobEffectExtensions;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.textures.ForgeTextureMetadata;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.*;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.StartupMessageManager;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.network.NetworkConstants;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@@ -110,6 +153,9 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -129,16 +175,10 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.BOSSINFO;
|
||||
import static net.minecraftforge.fml.VersionChecker.Status.BETA;
|
||||
import static net.minecraftforge.fml.VersionChecker.Status.BETA_OUTDATED;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class ForgeHooksClient
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -210,12 +250,12 @@ public class ForgeHooksClient
|
||||
switch (target.getType()) {
|
||||
case BLOCK:
|
||||
if (!(target instanceof BlockHitResult blockTarget)) return false;
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent.HighlightBlock(context, camera, blockTarget, partialTick, poseStack, bufferSource));
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHighlightEvent.Block(context, camera, blockTarget, partialTick, poseStack, bufferSource));
|
||||
case ENTITY:
|
||||
if (!(target instanceof EntityHitResult entityTarget)) return false;
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent.HighlightEntity(context, camera, entityTarget, partialTick, poseStack, bufferSource));
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderHighlightEvent.Entity(context, camera, entityTarget, partialTick, poseStack, bufferSource));
|
||||
default:
|
||||
return MinecraftForge.EVENT_BUS.post(new DrawSelectionEvent(context, camera, target, partialTick, poseStack, bufferSource));
|
||||
return false; // NO-OP - This doesn't even get called for anything other than blocks and entities
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,24 +291,17 @@ public class ForgeHooksClient
|
||||
|
||||
public static void onBlockColorsInit(BlockColors blockColors)
|
||||
{
|
||||
ModLoader.get().postEvent(new ColorHandlerEvent.Block(blockColors));
|
||||
ModLoader.get().postEvent(new RegisterColorHandlersEvent.Block(blockColors));
|
||||
}
|
||||
|
||||
public static void onItemColorsInit(ItemColors itemColors, BlockColors blockColors)
|
||||
{
|
||||
ModLoader.get().postEvent(new ColorHandlerEvent.Item(itemColors, blockColors));
|
||||
}
|
||||
|
||||
static final ThreadLocal<RenderType> renderType = new ThreadLocal<RenderType>();
|
||||
|
||||
public static void setRenderType(RenderType layer)
|
||||
{
|
||||
renderType.set(layer);
|
||||
ModLoader.get().postEvent(new RegisterColorHandlersEvent.Item(itemColors, blockColors));
|
||||
}
|
||||
|
||||
public static Model getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot slot, HumanoidModel<?> _default)
|
||||
{
|
||||
return RenderProperties.get(itemStack).getBaseArmorModel(entityLiving, itemStack, slot, _default);
|
||||
return IClientItemExtensions.of(itemStack).getGenericArmorModel(entityLiving, itemStack, slot, _default);
|
||||
}
|
||||
|
||||
/** Copies humanoid model properties from the original model to another, used for armor models */
|
||||
@@ -307,15 +340,15 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
public static float getFieldOfView(Player entity, float fov)
|
||||
public static float getFieldOfViewModifier(Player entity, float fovModifier)
|
||||
{
|
||||
FOVModifierEvent fovModifierEvent = new FOVModifierEvent(entity, fov);
|
||||
ComputeFovModifierEvent fovModifierEvent = new ComputeFovModifierEvent(entity, fovModifier);
|
||||
MinecraftForge.EVENT_BUS.post(fovModifierEvent);
|
||||
return fovModifierEvent.getNewFov();
|
||||
return fovModifierEvent.getNewFovModifier();
|
||||
}
|
||||
|
||||
public static double getFieldOfView(GameRenderer renderer, Camera camera, double partialTick, double fov) {
|
||||
EntityViewRenderEvent.FieldOfView event = new EntityViewRenderEvent.FieldOfView(renderer, camera, partialTick, fov);
|
||||
ViewportEvent.ComputeFov event = new ViewportEvent.ComputeFov(renderer, camera, partialTick, fov);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getFOV();
|
||||
}
|
||||
@@ -378,9 +411,9 @@ public class ForgeHooksClient
|
||||
|
||||
private static void drawScreenInternal(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
if (!MinecraftForge.EVENT_BUS.post(new ScreenEvent.DrawScreenEvent.Pre(screen, poseStack, mouseX, mouseY, partialTick)))
|
||||
if (!MinecraftForge.EVENT_BUS.post(new ScreenEvent.Render.Pre(screen, poseStack, mouseX, mouseY, partialTick)))
|
||||
screen.render(poseStack, mouseX, mouseY, partialTick);
|
||||
MinecraftForge.EVENT_BUS.post(new ScreenEvent.DrawScreenEvent.Post(screen, poseStack, mouseX, mouseY, partialTick));
|
||||
MinecraftForge.EVENT_BUS.post(new ScreenEvent.Render.Post(screen, poseStack, mouseX, mouseY, partialTick));
|
||||
}
|
||||
|
||||
public static Vector3f getFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, float fogRed, float fogGreen, float fogBlue)
|
||||
@@ -389,9 +422,9 @@ public class ForgeHooksClient
|
||||
FluidState state = level.getFluidState(camera.getBlockPosition());
|
||||
Vector3f fluidFogColor = new Vector3f(fogRed, fogGreen, fogBlue);
|
||||
if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(level, camera.getBlockPosition())))
|
||||
fluidFogColor = RenderProperties.get(state).modifyFogColor(camera, partialTick, level, renderDistance, darkenWorldAmount, fluidFogColor);
|
||||
fluidFogColor = IClientFluidTypeExtensions.of(state).modifyFogColor(camera, partialTick, level, renderDistance, darkenWorldAmount, fluidFogColor);
|
||||
|
||||
EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(camera, partialTick, fluidFogColor.x(), fluidFogColor.y(), fluidFogColor.z());
|
||||
ViewportEvent.ComputeFogColor event = new ViewportEvent.ComputeFogColor(camera, partialTick, fluidFogColor.x(), fluidFogColor.y(), fluidFogColor.z());
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
fluidFogColor.set(event.getRed(), event.getGreen(), event.getBlue());
|
||||
@@ -403,9 +436,9 @@ public class ForgeHooksClient
|
||||
// Modify fog rendering depending on the fluid
|
||||
FluidState state = camera.getEntity().level.getFluidState(camera.getBlockPosition());
|
||||
if (camera.getPosition().y < (double)((float)camera.getBlockPosition().getY() + state.getHeight(camera.getEntity().level, camera.getBlockPosition())))
|
||||
RenderProperties.get(state).modifyFogRender(camera, mode, renderDistance, partialTick, nearDistance, farDistance, shape);
|
||||
IClientFluidTypeExtensions.of(state).modifyFogRender(camera, mode, renderDistance, partialTick, nearDistance, farDistance, shape);
|
||||
|
||||
EntityViewRenderEvent.RenderFogEvent event = new EntityViewRenderEvent.RenderFogEvent(type, camera, partialTick, nearDistance, farDistance, shape);
|
||||
ViewportEvent.RenderFog event = new ViewportEvent.RenderFog(type, camera, partialTick, nearDistance, farDistance, shape);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
RenderSystem.setShaderFogStart(event.getNearPlaneDistance());
|
||||
@@ -414,54 +447,28 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityViewRenderEvent.CameraSetup onCameraSetup(GameRenderer renderer, Camera camera, float partial)
|
||||
public static ViewportEvent.ComputeCameraAngles onCameraSetup(GameRenderer renderer, Camera camera, float partial)
|
||||
{
|
||||
EntityViewRenderEvent.CameraSetup event = new EntityViewRenderEvent.CameraSetup(renderer, camera, partial, camera.getYRot(), camera.getXRot(), 0);
|
||||
ViewportEvent.ComputeCameraAngles event = new ViewportEvent.ComputeCameraAngles(renderer, camera, partial, camera.getYRot(), camera.getXRot(), 0);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void onModelBake(ModelManager modelManager, Map<ResourceLocation, BakedModel> modelRegistry, ForgeModelBakery modelLoader)
|
||||
public static void onModelBake(ModelManager modelManager, Map<ResourceLocation, BakedModel> models, ModelBakery modelBakery)
|
||||
{
|
||||
ModLoader.get().postEvent(new ModelBakeEvent(modelManager, modelRegistry, modelLoader));
|
||||
modelLoader.onPostBakeEvent(modelRegistry);
|
||||
ModLoader.get().postEvent(new ModelEvent.BakingCompleted(modelManager, models, modelBakery));
|
||||
}
|
||||
|
||||
private static final Matrix4f flipX;
|
||||
private static final Matrix3f flipXNormal;
|
||||
static {
|
||||
flipX = Matrix4f.createScaleMatrix(-1,1,1);
|
||||
flipXNormal = new Matrix3f(flipX);
|
||||
}
|
||||
|
||||
public static BakedModel handleCameraTransforms(PoseStack poseStack, BakedModel model, ItemTransforms.TransformType cameraTransformType, boolean leftHandHackery)
|
||||
public static BakedModel handleCameraTransforms(PoseStack poseStack, BakedModel model, ItemTransforms.TransformType cameraTransformType, boolean applyLeftHandTransform)
|
||||
{
|
||||
PoseStack stack = new PoseStack();
|
||||
model = model.handlePerspective(cameraTransformType, stack);
|
||||
|
||||
// If the stack is not empty, the code has added a matrix for us to use.
|
||||
if (!stack.clear())
|
||||
{
|
||||
// Apply the transformation to the real matrix stack, flipping for left hand
|
||||
Matrix4f tMat = stack.last().pose();
|
||||
Matrix3f nMat = stack.last().normal();
|
||||
if (leftHandHackery)
|
||||
{
|
||||
tMat.multiplyBackward(flipX);
|
||||
tMat.multiply(flipX);
|
||||
nMat.multiplyBackward(flipXNormal);
|
||||
nMat.mul(flipXNormal);
|
||||
}
|
||||
poseStack.last().pose().multiply(tMat);
|
||||
poseStack.last().normal().mul(nMat);
|
||||
}
|
||||
model = model.applyTransform(cameraTransformType, poseStack, applyLeftHandTransform);
|
||||
return model;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static TextureAtlasSprite[] getFluidSprites(BlockAndTintGetter level, BlockPos pos, FluidState fluidStateIn)
|
||||
{
|
||||
IFluidTypeRenderProperties props = RenderProperties.get(fluidStateIn);
|
||||
IClientFluidTypeExtensions props = IClientFluidTypeExtensions.of(fluidStateIn);
|
||||
ResourceLocation overlayTexture = props.getOverlayTexture(fluidStateIn, level, pos);
|
||||
return new TextureAtlasSprite[] {
|
||||
Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(props.getStillTexture(fluidStateIn, level, pos)),
|
||||
@@ -481,9 +488,9 @@ public class ForgeHooksClient
|
||||
|
||||
public static Stream<Material> getFluidMaterials(Fluid fluid)
|
||||
{
|
||||
return RenderProperties.get(fluid).getTextures()
|
||||
.filter(Objects::nonNull)
|
||||
.map(ForgeHooksClient::getBlockMaterial);
|
||||
return IClientFluidTypeExtensions.of(fluid).getTextures()
|
||||
.filter(Objects::nonNull)
|
||||
.map(ForgeHooksClient::getBlockMaterial);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -534,7 +541,7 @@ public class ForgeHooksClient
|
||||
{
|
||||
if (entity != null)
|
||||
{
|
||||
ResourceLocation shader = ClientRegistry.getEntityShader(entity.getClass());
|
||||
ResourceLocation shader = EntitySpectatorShaderManager.get(entity.getType());
|
||||
if (shader != null)
|
||||
{
|
||||
entityRenderer.loadEffect(shader);
|
||||
@@ -561,19 +568,14 @@ public class ForgeHooksClient
|
||||
return from.getItem().shouldCauseReequipAnimation(from, to, changed);
|
||||
}
|
||||
|
||||
public static RenderGameOverlayEvent.BossInfo renderBossEventPre(PoseStack poseStack, Window res, LerpingBossEvent bossInfo, int x, int y, int increment)
|
||||
public static CustomizeGuiOverlayEvent.BossEventProgress onCustomizeBossEventProgress(PoseStack poseStack, Window window, LerpingBossEvent bossInfo, int x, int y, int increment)
|
||||
{
|
||||
RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(poseStack, new RenderGameOverlayEvent(poseStack, MinecraftForgeClient.getPartialTick(), res),
|
||||
BOSSINFO, bossInfo, x, y, increment);
|
||||
CustomizeGuiOverlayEvent.BossEventProgress evt = new CustomizeGuiOverlayEvent.BossEventProgress(window, poseStack,
|
||||
Minecraft.getInstance().getPartialTick(), bossInfo, x, y, increment);
|
||||
MinecraftForge.EVENT_BUS.post(evt);
|
||||
return evt;
|
||||
}
|
||||
|
||||
public static void renderBossEventPost(PoseStack poseStack, Window res)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(poseStack, new RenderGameOverlayEvent(poseStack, MinecraftForgeClient.getPartialTick(), res), BOSSINFO));
|
||||
}
|
||||
|
||||
public static ScreenshotEvent onScreenshot(NativeImage image, File screenshotFile)
|
||||
{
|
||||
ScreenshotEvent event = new ScreenshotEvent(image, screenshotFile);
|
||||
@@ -590,16 +592,6 @@ public class ForgeHooksClient
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static BakedModel handlePerspective(BakedModel model, ItemTransforms.TransformType type, PoseStack stack)
|
||||
{
|
||||
Transformation tr = TransformationHelper.toTransformation(model.getTransforms().getTransform(type));
|
||||
if(!tr.isIdentity()) {
|
||||
tr.push(stack);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public static void onMovementInputUpdate(Player player, Input movementInput)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new MovementInputUpdateEvent(player, movementInput));
|
||||
@@ -607,40 +599,40 @@ public class ForgeHooksClient
|
||||
|
||||
public static boolean onScreenMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
Event event = new ScreenEvent.MouseClickedEvent.Pre(guiScreen, mouseX, mouseY, 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.MouseClickedEvent.Post(guiScreen, mouseX, mouseY, button, 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.MouseReleasedEvent.Pre(guiScreen, mouseX, mouseY, 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.MouseReleasedEvent.Post(guiScreen, mouseX, mouseY, button, 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.MouseDragEvent.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
Event event = new ScreenEvent.MouseDragged.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
public static void onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
Event event = new ScreenEvent.MouseDragEvent.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
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)
|
||||
@@ -648,53 +640,53 @@ public class ForgeHooksClient
|
||||
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.MouseScrollEvent.Pre(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
Event event = new ScreenEvent.MouseScrolled.Pre(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenMouseScrollPost(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta)
|
||||
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.MouseScrollEvent.Post(guiScreen, mouseX, mouseY, scrollDelta);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
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.KeyboardKeyPressedEvent.Pre(guiScreen, keyCode, scanCode, modifiers);
|
||||
Event event = new ScreenEvent.KeyPressed.Pre(guiScreen, keyCode, scanCode, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyPressedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
Event event = new ScreenEvent.KeyboardKeyPressedEvent.Post(guiScreen, keyCode, scanCode, modifiers);
|
||||
Event event = new ScreenEvent.KeyPressed.Post(guiScreen, keyCode, scanCode, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyReleasedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
Event event = new ScreenEvent.KeyboardKeyReleasedEvent.Pre(guiScreen, keyCode, scanCode, modifiers);
|
||||
Event event = new ScreenEvent.KeyReleased.Pre(guiScreen, keyCode, scanCode, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenKeyReleasedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
Event event = new ScreenEvent.KeyboardKeyReleasedEvent.Post(guiScreen, keyCode, scanCode, modifiers);
|
||||
Event event = new ScreenEvent.KeyReleased.Post(guiScreen, keyCode, scanCode, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenCharTypedPre(Screen guiScreen, char codePoint, int modifiers)
|
||||
{
|
||||
Event event = new ScreenEvent.KeyboardCharTypedEvent.Pre(guiScreen, codePoint, modifiers);
|
||||
Event event = new ScreenEvent.CharacterTyped.Pre(guiScreen, codePoint, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScreenCharTypedPost(Screen guiScreen, char codePoint, int modifiers)
|
||||
public static void onScreenCharTypedPost(Screen guiScreen, char codePoint, int modifiers)
|
||||
{
|
||||
Event event = new ScreenEvent.KeyboardCharTypedEvent.Post(guiScreen, codePoint, modifiers);
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
Event event = new ScreenEvent.CharacterTyped.Post(guiScreen, codePoint, modifiers);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onRecipesUpdated(RecipeManager mgr)
|
||||
@@ -703,54 +695,34 @@ public class ForgeHooksClient
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void fireMouseInput(int button, int action, int mods)
|
||||
public static boolean onMouseButtonPre(int button, int action, int mods)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.MouseInputEvent(button, action, mods));
|
||||
return MinecraftForge.EVENT_BUS.post(new InputEvent.MouseButton.Pre(button, action, mods));
|
||||
}
|
||||
|
||||
public static void fireKeyInput(int key, int scanCode, int action, int modifiers)
|
||||
public static void onMouseButtonPost(int button, int action, int mods)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.KeyInputEvent(key, scanCode, action, modifiers));
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.MouseButton.Post(button, action, mods));
|
||||
}
|
||||
|
||||
public static boolean onMouseScroll(MouseHandler mouseHelper, double scrollDelta)
|
||||
{
|
||||
Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos());
|
||||
Event event = new InputEvent.MouseScrollingEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddlePressed(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos());
|
||||
return MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onRawMouseClicked(int button, int action, int mods)
|
||||
public static void onKeyInput(int key, int scanCode, int action, int modifiers)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new InputEvent.RawMouseEvent(button, action, mods));
|
||||
MinecraftForge.EVENT_BUS.post(new InputEvent.Key(key, scanCode, action, modifiers));
|
||||
}
|
||||
|
||||
public static InputEvent.ClickInputEvent onClickInput(int button, KeyMapping keyBinding, InteractionHand hand)
|
||||
public static InputEvent.InteractionKeyMappingTriggered onClickInput(int button, KeyMapping keyBinding, InteractionHand hand)
|
||||
{
|
||||
InputEvent.ClickInputEvent event = new InputEvent.ClickInputEvent(button, keyBinding, hand);
|
||||
InputEvent.InteractionKeyMappingTriggered event = new InputEvent.InteractionKeyMappingTriggered(button, keyBinding, hand);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void drawItemLayered(ItemRenderer renderer, BakedModel modelIn, ItemStack itemStackIn, PoseStack poseStack,
|
||||
MultiBufferSource bufferSource, int packedLight, int packedOverlay, boolean fabulous)
|
||||
{
|
||||
for(com.mojang.datafixers.util.Pair<BakedModel,RenderType> layerModel : modelIn.getLayerModels(itemStackIn, fabulous))
|
||||
{
|
||||
BakedModel layer = layerModel.getFirst();
|
||||
RenderType rendertype = layerModel.getSecond();
|
||||
net.minecraftforge.client.ForgeHooksClient.setRenderType(rendertype); // neded for compatibility with MultiLayerModels
|
||||
VertexConsumer ivertexbuilder;
|
||||
if (fabulous)
|
||||
{
|
||||
ivertexbuilder = ItemRenderer.getFoilBufferDirect(bufferSource, rendertype, true, itemStackIn.hasFoil());
|
||||
} else {
|
||||
ivertexbuilder = ItemRenderer.getFoilBuffer(bufferSource, rendertype, true, itemStackIn.hasFoil());
|
||||
}
|
||||
renderer.renderModelLists(layer, itemStackIn, packedLight, packedOverlay, poseStack, ivertexbuilder);
|
||||
}
|
||||
net.minecraftforge.client.ForgeHooksClient.setRenderType(null);
|
||||
}
|
||||
|
||||
public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
final AttributeInstance attribute = ((LivingEntity) entity).getAttribute(ForgeMod.NAMETAG_DISTANCE.get());
|
||||
@@ -762,20 +734,17 @@ public class ForgeHooksClient
|
||||
}
|
||||
|
||||
public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, PoseStack stack, MultiBufferSource bufferSource, Level level, boolean checkSides, int packedOverlay, BlockRenderDispatcher blockRenderer) {
|
||||
RenderType.chunkBufferLayers().stream()
|
||||
.filter(t -> ItemBlockRenderTypes.canRenderInLayer(state, t))
|
||||
.forEach(rendertype ->
|
||||
{
|
||||
setRenderType(rendertype);
|
||||
VertexConsumer ivertexbuilder = bufferSource.getBuffer(rendertype == RenderType.translucent() ? RenderType.translucentMovingBlock() : rendertype);
|
||||
blockRenderer.getModelRenderer().tesselateBlock(level, blockRenderer.getBlockModel(state), state, pos, stack, ivertexbuilder, checkSides, RandomSource.create(), state.getSeed(pos), packedOverlay);
|
||||
});
|
||||
setRenderType(null);
|
||||
var model = blockRenderer.getBlockModel(state);
|
||||
for (var renderType : model.getRenderTypes(state, RandomSource.create(state.getSeed(pos)), ModelData.EMPTY))
|
||||
{
|
||||
VertexConsumer vertexConsumer = bufferSource.getBuffer(renderType == RenderType.translucent() ? RenderType.translucentMovingBlock() : renderType);
|
||||
blockRenderer.getModelRenderer().tesselateBlock(level, model, state, pos, stack, vertexConsumer, checkSides, RandomSource.create(), state.getSeed(pos), packedOverlay, ModelData.EMPTY, renderType);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldRenderEffect(MobEffectInstance effectInstance)
|
||||
{
|
||||
return RenderProperties.getEffectRenderer(effectInstance).shouldRender(effectInstance);
|
||||
return IClientMobEffectExtensions.of(effectInstance).isVisibleInInventory(effectInstance);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -868,27 +837,27 @@ public class ForgeHooksClient
|
||||
String tooltip;
|
||||
if (target.forgeData == null)
|
||||
return;
|
||||
switch (target.forgeData.type) {
|
||||
switch (target.forgeData.type()) {
|
||||
case "FML":
|
||||
if (target.forgeData.isCompatible) {
|
||||
if (target.forgeData.isCompatible()) {
|
||||
idx = 0;
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.compatible", target.forgeData.numberOfMods);
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.compatible", target.forgeData.numberOfMods());
|
||||
} else {
|
||||
idx = 16;
|
||||
if(target.forgeData.extraReason != null) {
|
||||
String extraReason = ForgeI18n.parseMessage(target.forgeData.extraReason);
|
||||
if(target.forgeData.extraReason() != null) {
|
||||
String extraReason = ForgeI18n.parseMessage(target.forgeData.extraReason());
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.incompatible.extra", extraReason);
|
||||
} else {
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.incompatible");
|
||||
}
|
||||
}
|
||||
if (target.forgeData.truncated)
|
||||
if (target.forgeData.truncated())
|
||||
{
|
||||
tooltip += "\n" + ForgeI18n.parseMessage("fml.menu.multiplayer.truncated");
|
||||
}
|
||||
break;
|
||||
case "VANILLA":
|
||||
if (target.forgeData.isCompatible) {
|
||||
if (target.forgeData.isCompatible()) {
|
||||
idx = 48;
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.vanilla");
|
||||
} else {
|
||||
@@ -898,7 +867,7 @@ public class ForgeHooksClient
|
||||
break;
|
||||
default:
|
||||
idx = 64;
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.unknown", target.forgeData.type);
|
||||
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.unknown", target.forgeData.type());
|
||||
}
|
||||
|
||||
RenderSystem.setShaderTexture(0, ICON_SHEET);
|
||||
@@ -927,17 +896,42 @@ public class ForgeHooksClient
|
||||
}
|
||||
|
||||
public static void firePlayerLogin(MultiPlayerGameMode pc, LocalPlayer player, Connection networkManager) {
|
||||
MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.LoggedInEvent(pc, player, networkManager));
|
||||
MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.LoggingIn(pc, player, networkManager));
|
||||
}
|
||||
|
||||
public static void firePlayerLogout(@Nullable MultiPlayerGameMode pc, @Nullable LocalPlayer player) {
|
||||
MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.LoggedOutEvent(pc, player, player != null ? player.connection != null ? player.connection.getConnection() : null : null));
|
||||
MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.LoggingOut(pc, player, player != null ? player.connection != null ? player.connection.getConnection() : null : null));
|
||||
}
|
||||
|
||||
public static void firePlayerRespawn(MultiPlayerGameMode pc, LocalPlayer oldPlayer, LocalPlayer newPlayer, Connection networkManager) {
|
||||
MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.RespawnEvent(pc, oldPlayer, newPlayer, networkManager));
|
||||
MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.Clone(pc, oldPlayer, newPlayer, networkManager));
|
||||
}
|
||||
|
||||
public static void onRegisterParticleProviders(ParticleEngine particleEngine) {
|
||||
ModLoader.get().postEvent(new RegisterParticleProvidersEvent(particleEngine));
|
||||
}
|
||||
|
||||
public static void onRegisterKeyMappings(Options options) {
|
||||
ModLoader.get().postEvent(new RegisterKeyMappingsEvent(options));
|
||||
}
|
||||
|
||||
public static void onRegisterAdditionalModels(Set<ResourceLocation> additionalModels) {
|
||||
ModLoader.get().postEvent(new ModelEvent.RegisterAdditional(additionalModels));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Component onClientChat(ChatType type, Component message, ChatSender chatSender)
|
||||
{
|
||||
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message, chatSender);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String onClientSendMessage(String message)
|
||||
{
|
||||
ClientChatEvent event = new ClientChatEvent(message);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? "" : event.getMessage();
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid="forge", bus= Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class ClientEvents
|
||||
@@ -965,7 +959,7 @@ public class ForgeHooksClient
|
||||
{
|
||||
return forcedFont;
|
||||
}
|
||||
Font stackFont = RenderProperties.get(stack).getFont(stack);
|
||||
Font stackFont = IClientItemExtensions.of(stack).getFont(stack, IClientItemExtensions.FontContext.TOOLTIP);
|
||||
return stackFont == null ? fallbackFont : stackFont;
|
||||
}
|
||||
|
||||
@@ -1066,16 +1060,16 @@ public class ForgeHooksClient
|
||||
};
|
||||
}
|
||||
|
||||
public static Event.Result onScreenPotionSize(Screen screen)
|
||||
public static int onScreenPotionSize(Screen screen, int availableSpace, boolean compact)
|
||||
{
|
||||
final ScreenEvent.PotionSizeEvent event = new ScreenEvent.PotionSizeEvent(screen);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getResult();
|
||||
final ScreenEvent.RenderInventoryMobEffects event = new ScreenEvent.RenderInventoryMobEffects(screen, availableSpace, compact);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? 0 : (event.isCompact() ? 1 : 2);
|
||||
}
|
||||
|
||||
public static boolean isBlockInSolidLayer(BlockState state)
|
||||
{
|
||||
return ItemBlockRenderTypes.canRenderInLayer(state, RenderType.solid());
|
||||
var model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state);
|
||||
return model.getRenderTypes(state, RandomSource.create(), ModelData.EMPTY).contains(RenderType.solid());
|
||||
}
|
||||
|
||||
public static void createWorldConfirmationScreen(Runnable doConfirmedWorldLoad)
|
||||
@@ -1102,17 +1096,17 @@ public class ForgeHooksClient
|
||||
|
||||
public static boolean renderFireOverlay(Player player, PoseStack mat)
|
||||
{
|
||||
return renderBlockOverlay(player, mat, RenderBlockOverlayEvent.OverlayType.FIRE, Blocks.FIRE.defaultBlockState(), player.blockPosition());
|
||||
return renderBlockOverlay(player, mat, RenderBlockScreenEffectEvent.OverlayType.FIRE, Blocks.FIRE.defaultBlockState(), player.blockPosition());
|
||||
}
|
||||
|
||||
public static boolean renderWaterOverlay(Player player, PoseStack mat)
|
||||
{
|
||||
return renderBlockOverlay(player, mat, RenderBlockOverlayEvent.OverlayType.WATER, Blocks.WATER.defaultBlockState(), player.blockPosition());
|
||||
return renderBlockOverlay(player, mat, RenderBlockScreenEffectEvent.OverlayType.WATER, Blocks.WATER.defaultBlockState(), player.blockPosition());
|
||||
}
|
||||
|
||||
public static boolean renderBlockOverlay(Player player, PoseStack mat, RenderBlockOverlayEvent.OverlayType type, BlockState block, BlockPos pos)
|
||||
public static boolean renderBlockOverlay(Player player, PoseStack mat, RenderBlockScreenEffectEvent.OverlayType type, BlockState block, BlockPos pos)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderBlockOverlayEvent(player, mat, type, block, pos));
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderBlockScreenEffectEvent(player, mat, type, block, pos));
|
||||
}
|
||||
|
||||
public static int getMaxMipmapLevel(int width, int height)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
/**
|
||||
* Call {@link net.minecraft.client.renderer.DimensionSpecialEffects#setCloudRenderHandler(ICloudRenderHandler)},
|
||||
* obtained from a {@link ClientLevel} with an implementation of this to override all cloud rendering with your own.
|
||||
* This is only responsible for rendering clouds.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ICloudRenderHandler {
|
||||
void render(int ticks, float partialTick, PoseStack poseStack, ClientLevel level, Minecraft minecraft, double camX, double camY, double camZ);
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface IItemRenderProperties
|
||||
{
|
||||
IItemRenderProperties DUMMY = new IItemRenderProperties()
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the font renderer used to render tooltips and overlays for this item.
|
||||
* Returning null will use the standard font renderer.
|
||||
*
|
||||
* @param stack The current item stack
|
||||
* @return A instance of FontRenderer or null to use default
|
||||
*/
|
||||
default Font getFont(ItemStack stack)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to have an item handle its own armor rendering.
|
||||
*
|
||||
* @param entityLiving The entity wearing the armor
|
||||
* @param itemStack The itemStack to render the model of
|
||||
* @param armorSlot The slot the armor is in
|
||||
* @param _default Original armor model. Will have attributes set.
|
||||
* @return A HumanoidModel to render instead of the default, will have the relevant properties copied in {@link #getBaseArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)}.
|
||||
* Returning null will cause the default to render.
|
||||
* @see #getBaseArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)
|
||||
*/
|
||||
@Nullable
|
||||
default HumanoidModel<?> getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to return a generic model rather than a {@link HumanoidModel}. More ideal for wrapping the original model or returning non-standard models like elytra wings.
|
||||
* By default, this hook copies in the model properties from the default into the model returned by {@link #getArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)},
|
||||
* so if you override this method you are responsible for copying properties you care about
|
||||
*
|
||||
* @param entityLiving The entity wearing the armor
|
||||
* @param itemStack The itemStack to render the model of
|
||||
* @param armorSlot The slot the armor is in
|
||||
* @param _default Original armor model. Will have attributes set.
|
||||
* @return A Model to render instead of the default
|
||||
* @see #getArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)
|
||||
*/
|
||||
@NotNull
|
||||
default Model getBaseArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
{
|
||||
HumanoidModel<?> replacement = getArmorModel(entityLiving, itemStack, armorSlot, _default);
|
||||
if (replacement != null && replacement != _default)
|
||||
{
|
||||
ForgeHooksClient.copyModelProperties(_default, replacement);
|
||||
return replacement;
|
||||
}
|
||||
return _default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the client starts rendering the HUD, for whatever item the player
|
||||
* currently has as a helmet. This is where pumpkins would render there overlay.
|
||||
*
|
||||
* @param stack The ItemStack that is equipped
|
||||
* @param player Reference to the current client entity
|
||||
* @param width Viewport width
|
||||
* @param height Viewport height
|
||||
* @param partialTick Partial tick for the renderer, useful for interpolation
|
||||
*/
|
||||
default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTick)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return This Item's renderer, or the default instance if it does not have
|
||||
* one.
|
||||
*/
|
||||
default BlockEntityWithoutLevelRenderer getItemStackRenderer()
|
||||
{
|
||||
return Minecraft.getInstance().getItemRenderer().getBlockEntityRenderer();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
/**
|
||||
* Call {@link net.minecraft.client.renderer.DimensionSpecialEffects#setSkyRenderHandler(ISkyRenderHandler)}, obtained
|
||||
* from a {@link ClientLevel} with an implementation of this to override all sky rendering with your own.
|
||||
* This includes the sun, moon, stars, and sky-coloring.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ISkyRenderHandler {
|
||||
void render(int ticks, float partialTick, PoseStack poseStack, ClientLevel level, Minecraft minecraft);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
/**
|
||||
* Call {@link net.minecraft.client.renderer.DimensionSpecialEffects#setWeatherParticleRenderHandler(IWeatherParticleRenderHandler)},
|
||||
* obtained from a {@link ClientLevel} with an implementation of this to override all weather particle rendering with your own.
|
||||
* This handles ground particles that can be seen when it's raining (splash/smoke particles).
|
||||
* This also includes playing rain sounds.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IWeatherParticleRenderHandler {
|
||||
void render(int ticks, ClientLevel level, Minecraft minecraft, Camera camera);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
||||
/**
|
||||
* Call {@link net.minecraft.client.renderer.DimensionSpecialEffects#setWeatherRenderHandler(IWeatherRenderHandler)},
|
||||
* obtained from a {@link ClientLevel} with an implementation of this to override all weather rendering with your own.
|
||||
* This includes rain and snow.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IWeatherRenderHandler {
|
||||
void render(int ticks, float partialTick, ClientLevel level, Minecraft minecraft, LightTexture lightTexture, double camX, double camY, double camZ);
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MinecraftForgeClient
|
||||
{
|
||||
public static RenderType getRenderType()
|
||||
{
|
||||
return ForgeHooksClient.renderType.get();
|
||||
}
|
||||
|
||||
private static float partialTick;
|
||||
|
||||
public static float getPartialTick() {
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
public static void setPartialTick(float partialTick) {
|
||||
MinecraftForgeClient.partialTick = partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the Locale set by the player in Minecraft.
|
||||
* Useful for creating string and number formatters.
|
||||
*/
|
||||
public static Locale getLocale()
|
||||
{
|
||||
return Minecraft.getInstance().getLanguageManager().getSelected().getJavaLocale();
|
||||
}
|
||||
|
||||
private static BitSet stencilBits = new BitSet(8);
|
||||
static
|
||||
{
|
||||
stencilBits.set(0,8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reserve a stencil bit for use in rendering
|
||||
*
|
||||
* Note: you must check the Framebuffer you are working with to
|
||||
* determine if stencil bits are enabled on it before use.
|
||||
*
|
||||
* @return A bit or -1 if no further stencil bits are available
|
||||
*/
|
||||
public static int reserveStencilBit()
|
||||
{
|
||||
int bit = stencilBits.nextSetBit(0);
|
||||
if (bit >= 0)
|
||||
{
|
||||
stencilBits.clear(bit);
|
||||
}
|
||||
return bit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the stencil bit for other use
|
||||
*
|
||||
* @param bit The bit from {@link #reserveStencilBit()}
|
||||
*/
|
||||
public static void releaseStencilBit(int bit)
|
||||
{
|
||||
if (bit >= 0 && bit < stencilBits.length())
|
||||
{
|
||||
stencilBits.set(bit);
|
||||
}
|
||||
}
|
||||
|
||||
private static HashMap<ResourceLocation, Supplier<NativeImage>> bufferedImageSuppliers = new HashMap<ResourceLocation, Supplier<NativeImage>>();
|
||||
public static void registerImageLayerSupplier(ResourceLocation resourceLocation, Supplier<NativeImage> supplier)
|
||||
{
|
||||
bufferedImageSuppliers.put(resourceLocation, supplier);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static NativeImage getImageLayer(ResourceLocation resourceLocation, ResourceManager resourceManager) throws IOException
|
||||
{
|
||||
Supplier<NativeImage> supplier = bufferedImageSuppliers.get(resourceLocation);
|
||||
if (supplier != null)
|
||||
return supplier.get();
|
||||
|
||||
Resource iresource1 = resourceManager.getResource(resourceLocation).orElseThrow();
|
||||
return NativeImage.read(iresource1.open());
|
||||
}
|
||||
|
||||
private static final Map<ResourceLocation, ITextureAtlasSpriteLoader> textureAtlasSpriteLoaders = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Register a custom ITextureAtlasSprite loader. Call this method during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}.
|
||||
*/
|
||||
public static void registerTextureAtlasSpriteLoader(ResourceLocation name, ITextureAtlasSpriteLoader loader)
|
||||
{
|
||||
textureAtlasSpriteLoaders.put(name, loader);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ITextureAtlasSpriteLoader getTextureAtlasSpriteLoader(ResourceLocation name)
|
||||
{
|
||||
return textureAtlasSpriteLoaders.get(name);
|
||||
}
|
||||
|
||||
private static final Map<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> tooltipComponentFactories = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Register a factory for ClientTooltipComponents.
|
||||
* @param cls the class for the component
|
||||
* @param factory the factory for the ClientTooltipComponent
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends TooltipComponent> void registerTooltipComponentFactory(Class<T> cls, Function<? super T, ? extends ClientTooltipComponent> factory)
|
||||
{
|
||||
tooltipComponentFactories.put(cls, (Function<TooltipComponent, ClientTooltipComponent>) factory);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ClientTooltipComponent getClientTooltipComponent(TooltipComponent component)
|
||||
{
|
||||
var factory = tooltipComponentFactories.get(component.getClass());
|
||||
return factory == null ? null : factory.apply(component);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RegisterNamedRenderTypesEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Manager for named {@link RenderType render types}.
|
||||
* <p>
|
||||
* Provides a lookup.
|
||||
*/
|
||||
public final class NamedRenderTypeManager
|
||||
{
|
||||
private static ImmutableMap<ResourceLocation, RenderTypeGroup> RENDER_TYPES;
|
||||
|
||||
/**
|
||||
* Finds the {@link RenderTypeGroup} for a given name, or the {@link RenderTypeGroup#EMPTY empty group} if not found.
|
||||
*/
|
||||
public static RenderTypeGroup get(ResourceLocation name)
|
||||
{
|
||||
return RENDER_TYPES.getOrDefault(name, RenderTypeGroup.EMPTY);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void init()
|
||||
{
|
||||
var renderTypes = new HashMap<ResourceLocation, RenderTypeGroup>();
|
||||
preRegisterVanillaRenderTypes(renderTypes);
|
||||
var event = new RegisterNamedRenderTypesEvent(renderTypes);
|
||||
ModLoader.get().postEventWithWrapInModOrder(event, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null));
|
||||
RENDER_TYPES = ImmutableMap.copyOf(renderTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-registers vanilla render types.
|
||||
*/
|
||||
private static void preRegisterVanillaRenderTypes(Map<ResourceLocation, RenderTypeGroup> blockRenderTypes)
|
||||
{
|
||||
blockRenderTypes.put(new ResourceLocation("solid"), new RenderTypeGroup(RenderType.solid(), ForgeRenderTypes.ITEM_LAYERED_SOLID.get()));
|
||||
blockRenderTypes.put(new ResourceLocation("cutout"), new RenderTypeGroup(RenderType.cutout(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get()));
|
||||
blockRenderTypes.put(new ResourceLocation("cutout_mipped"), new RenderTypeGroup(RenderType.cutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get()));
|
||||
blockRenderTypes.put(new ResourceLocation("translucent"), new RenderTypeGroup(RenderType.translucent(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get()));
|
||||
blockRenderTypes.put(new ResourceLocation("tripwire"), new RenderTypeGroup(RenderType.tripwire(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get()));
|
||||
}
|
||||
|
||||
private NamedRenderTypeManager()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.RecipeType;
|
||||
import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static net.minecraft.client.RecipeBookCategories.*;
|
||||
|
||||
/**
|
||||
* Manager for {@link RecipeBookType recipe book types} and {@link RecipeBookCategories categories}.
|
||||
* <p>
|
||||
* Provides a recipe category lookup.
|
||||
*/
|
||||
public final class RecipeBookManager
|
||||
{
|
||||
// Not using ConcurrentHashMap here because it's slower for lookups, so we only use it during init
|
||||
private static final Map<RecipeBookCategories, List<RecipeBookCategories>> AGGREGATE_CATEGORIES = new HashMap<>();
|
||||
private static final Map<RecipeBookType, List<RecipeBookCategories>> TYPE_CATEGORIES = new HashMap<>();
|
||||
private static final Map<RecipeType<?>, Function<Recipe<?>, RecipeBookCategories>> RECIPE_CATEGORY_LOOKUPS = new HashMap<>();
|
||||
private static final Map<RecipeBookCategories, List<RecipeBookCategories>> AGGREGATE_CATEGORIES_VIEW = Collections.unmodifiableMap(AGGREGATE_CATEGORIES);
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
var lookup = RECIPE_CATEGORY_LOOKUPS.get(type);
|
||||
return lookup != null ? lookup.apply(recipe) : null;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Map<RecipeBookCategories, List<RecipeBookCategories>> getAggregateCategories()
|
||||
{
|
||||
return AGGREGATE_CATEGORIES_VIEW;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static List<RecipeBookCategories> getCustomCategoriesOrEmpty(RecipeBookType recipeBookType)
|
||||
{
|
||||
return TYPE_CATEGORIES.getOrDefault(recipeBookType, List.of());
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void init()
|
||||
{
|
||||
// The ImmutableMap is the patched out value of AGGREGATE_CATEGORIES
|
||||
var aggregateCategories = new HashMap<>(ImmutableMap.of(CRAFTING_SEARCH, ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), FURNACE_SEARCH, ImmutableList.of(FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC), BLAST_FURNACE_SEARCH, ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), SMOKER_SEARCH, ImmutableList.of(SMOKER_FOOD)));
|
||||
var typeCategories = new HashMap<RecipeBookType, ImmutableList<RecipeBookCategories>>();
|
||||
var recipeCategoryLookups = new HashMap<RecipeType<?>, Function<Recipe<?>, RecipeBookCategories>>();
|
||||
var event = new RegisterRecipeBookCategoriesEvent(aggregateCategories, typeCategories, recipeCategoryLookups);
|
||||
ModLoader.get().postEventWithWrapInModOrder(event, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null));
|
||||
AGGREGATE_CATEGORIES.putAll(aggregateCategories);
|
||||
TYPE_CATEGORIES.putAll(typeCategories);
|
||||
RECIPE_CATEGORY_LOOKUPS.putAll(recipeCategoryLookups);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.RecipeType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static net.minecraft.client.RecipeBookCategories.*;
|
||||
|
||||
public class RecipeBookRegistry
|
||||
{
|
||||
// The ImmutableMap is the patched out value of AGGREGATE_CATEGORIES
|
||||
private static final Map<RecipeBookCategories, List<RecipeBookCategories>> MUTABLE_AGGREGATE_CATEGORIES = new HashMap<>(ImmutableMap.of(CRAFTING_SEARCH, ImmutableList.of(CRAFTING_EQUIPMENT, CRAFTING_BUILDING_BLOCKS, CRAFTING_MISC, CRAFTING_REDSTONE), FURNACE_SEARCH, ImmutableList.of(FURNACE_FOOD, FURNACE_BLOCKS, FURNACE_MISC), BLAST_FURNACE_SEARCH, ImmutableList.of(BLAST_FURNACE_BLOCKS, BLAST_FURNACE_MISC), SMOKER_SEARCH, ImmutableList.of(SMOKER_FOOD)));
|
||||
|
||||
private static final Map<RecipeBookType, List<RecipeBookCategories>> TYPE_TO_CATEGORIES = new HashMap<>();
|
||||
private static final Map<RecipeType<?>, Function<Recipe<?>, RecipeBookCategories>> FIND_CATEGORIES_FOR_TYPE = new HashMap<>();
|
||||
|
||||
//Unmodifiable view, the nested lists are immutable
|
||||
public static final Map<RecipeBookCategories, List<RecipeBookCategories>> AGGREGATE_CATEGORIES_VIEW = Collections.unmodifiableMap(MUTABLE_AGGREGATE_CATEGORIES);
|
||||
public static final Map<RecipeBookType, List<RecipeBookCategories>> TYPE_TO_CATEGORIES_VIEW = Collections.unmodifiableMap(TYPE_TO_CATEGORIES);
|
||||
|
||||
public static void addCategoriesToType(RecipeBookType type, List<RecipeBookCategories> categories)
|
||||
{
|
||||
TYPE_TO_CATEGORIES.put(type, categories instanceof ImmutableList ? categories : Collections.unmodifiableList(categories));
|
||||
}
|
||||
|
||||
public static void addAggregateCategories(RecipeBookCategories search, List<RecipeBookCategories> aggregate)
|
||||
{
|
||||
MUTABLE_AGGREGATE_CATEGORIES.put(search, aggregate instanceof ImmutableList ? aggregate : Collections.unmodifiableList(aggregate));
|
||||
}
|
||||
|
||||
public static void addCategoriesFinder(RecipeType<?> type, Function<Recipe<?>, RecipeBookCategories> finder)
|
||||
{
|
||||
FIND_CATEGORIES_FOR_TYPE.put(type, finder);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static RecipeBookCategories findCategories(RecipeType<?> type, Recipe<?> recipe)
|
||||
{
|
||||
return Optional.ofNullable(FIND_CATEGORIES_FOR_TYPE.get(type)).map(f -> f.apply(recipe)).orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
|
||||
public class RenderProperties
|
||||
{
|
||||
public static EffectRenderer getEffectRenderer(MobEffectInstance effectInstance)
|
||||
{
|
||||
return getEffectRenderer(effectInstance.getEffect());
|
||||
}
|
||||
|
||||
public static EffectRenderer getEffectRenderer(MobEffect effect)
|
||||
{
|
||||
return effect.getEffectRendererInternal() instanceof EffectRenderer r ? r : EffectRenderer.DUMMY;
|
||||
}
|
||||
|
||||
public static IItemRenderProperties get(ItemStack stack)
|
||||
{
|
||||
return get(stack.getItem());
|
||||
}
|
||||
|
||||
public static IItemRenderProperties get(Item item)
|
||||
{
|
||||
return item.getRenderPropertiesInternal() instanceof IItemRenderProperties props ? props : IItemRenderProperties.DUMMY;
|
||||
}
|
||||
|
||||
public static IBlockRenderProperties get(BlockState state)
|
||||
{
|
||||
return get(state.getBlock());
|
||||
}
|
||||
|
||||
public static IBlockRenderProperties get(Block block)
|
||||
{
|
||||
return block.getRenderPropertiesInternal() instanceof IBlockRenderProperties props ? props : IBlockRenderProperties.DUMMY;
|
||||
}
|
||||
|
||||
public static IFluidTypeRenderProperties get(FluidState state)
|
||||
{
|
||||
return get(state.getFluidType());
|
||||
}
|
||||
|
||||
public static IFluidTypeRenderProperties get(Fluid fluid)
|
||||
{
|
||||
return get(fluid.getFluidType());
|
||||
}
|
||||
|
||||
public static IFluidTypeRenderProperties get(FluidType type)
|
||||
{
|
||||
return type.getRenderPropertiesInternal() instanceof IFluidTypeRenderProperties props ? props : IFluidTypeRenderProperties.DUMMY;
|
||||
}
|
||||
|
||||
private RenderProperties()
|
||||
{
|
||||
// Not instantiable.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
/**
|
||||
* A set of functionally equivalent shaders. One using {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#BLOCK},
|
||||
* and the other two using {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#NEW_ENTITY}.
|
||||
* {@code entityFabulous} may support custom render targets and other aspects of the fabulous pipeline, or can otherwise
|
||||
* be the same as {@code entity}.
|
||||
*/
|
||||
public record RenderTypeGroup(RenderType block, RenderType entity, RenderType entityFabulous)
|
||||
{
|
||||
public static RenderTypeGroup EMPTY = new RenderTypeGroup(null, null, null);
|
||||
|
||||
public RenderTypeGroup
|
||||
{
|
||||
if ((block == null) != (entity == null) || (block == null) != (entityFabulous == null))
|
||||
throw new IllegalArgumentException("The render types in a group must either be all null, or all non-null.");
|
||||
}
|
||||
|
||||
public RenderTypeGroup(RenderType block, RenderType entity)
|
||||
{
|
||||
this(block, entity, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return true if this group has render types or not. It either has all, or none}
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
// We throw an exception in the constructor if nullability doesn't match, so checking this is enough
|
||||
return block == null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
public final class StencilManager
|
||||
{
|
||||
private static final BitSet BITS = new BitSet(8);
|
||||
|
||||
/**
|
||||
* Reserve a stencil bit for use in rendering
|
||||
* <p>
|
||||
* Note: you must check the {@link com.mojang.blaze3d.pipeline.RenderTarget} you are working with to
|
||||
* determine if stencil bits are enabled on it before use.
|
||||
*
|
||||
* @return A bit, or -1 if no further stencil bits are available
|
||||
*/
|
||||
public static int reserveBit()
|
||||
{
|
||||
int bit = BITS.nextClearBit(0);
|
||||
if (bit >= 0)
|
||||
BITS.set(bit);
|
||||
return bit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the stencil bit for other use
|
||||
*
|
||||
* @param bit The bit obtained from {@link #reserveBit()}
|
||||
*/
|
||||
public static void releaseBit(int bit)
|
||||
{
|
||||
if (bit >= 0 && bit < BITS.length())
|
||||
BITS.clear(bit);
|
||||
}
|
||||
|
||||
private StencilManager()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -7,19 +7,19 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when the client is about to send a chat message to the server.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the chat message or command will not be sent to the server. </p>
|
||||
* If the event is cancelled, the chat message or command will not be sent to the server.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
**/
|
||||
@Cancelable
|
||||
public class ClientChatEvent extends Event
|
||||
@@ -27,10 +27,7 @@ public class ClientChatEvent extends Event
|
||||
private String message;
|
||||
private final String originalMessage;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeEventFactory#onClientSendMessage(String)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public ClientChatEvent(String message)
|
||||
{
|
||||
this.setMessage(message);
|
||||
|
||||
@@ -5,25 +5,25 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.network.chat.ChatSender;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.ChatSender;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when a chat message is received on the client.
|
||||
* This can be used for filtering and detecting messages with specific words or phrases, and suppressing them.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the message is not displayed in the chat message window. </p>
|
||||
* If the event is cancelled, the message is not displayed in the chat message window.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see ChatType
|
||||
*/
|
||||
@@ -34,10 +34,7 @@ public class ClientChatReceivedEvent extends Event
|
||||
private final ChatType type;
|
||||
private final ChatSender chatSender;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeEventFactory#onClientChat(ChatType, Component, ChatSender)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public ClientChatReceivedEvent(ChatType type, Component message, ChatSender chatSender)
|
||||
{
|
||||
this.type = type;
|
||||
|
||||
@@ -7,19 +7,19 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when the client player is notified of a change of {@link GameType} from the server.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class ClientPlayerChangeGameTypeEvent extends Event
|
||||
{
|
||||
@@ -27,10 +27,7 @@ public class ClientPlayerChangeGameTypeEvent extends Event
|
||||
private final GameType currentGameType;
|
||||
private final GameType newGameType;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onClientChangeGameType(PlayerInfo, GameType, GameType)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public ClientPlayerChangeGameTypeEvent(PlayerInfo info, GameType currentGameType, GameType newGameType)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -20,62 +20,63 @@ import org.jetbrains.annotations.Nullable;
|
||||
* See the various subclasses to listen for specific events.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see ClientPlayerNetworkEvent.LoggedInEvent
|
||||
* @see ClientPlayerNetworkEvent.LoggedOutEvent
|
||||
* @see ClientPlayerNetworkEvent.RespawnEvent
|
||||
* @see LoggingIn
|
||||
* @see LoggingOut
|
||||
* @see Clone
|
||||
**/
|
||||
public class ClientPlayerNetworkEvent extends Event {
|
||||
public abstract class ClientPlayerNetworkEvent extends Event
|
||||
{
|
||||
private final MultiPlayerGameMode multiPlayerGameMode;
|
||||
private final LocalPlayer player;
|
||||
private final Connection connection;
|
||||
|
||||
/**
|
||||
* {@return the multiplayer game mode controller for the player}
|
||||
*/
|
||||
public MultiPlayerGameMode getMultiPlayerGameMode() {
|
||||
return multiPlayerGameMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the player instance}
|
||||
*/
|
||||
public LocalPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the network connection for the player}
|
||||
*/
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
ClientPlayerNetworkEvent(final MultiPlayerGameMode multiPlayerGameMode, final LocalPlayer player, final Connection connection) {
|
||||
@ApiStatus.Internal
|
||||
protected ClientPlayerNetworkEvent(final MultiPlayerGameMode multiPlayerGameMode, final LocalPlayer player, final Connection connection)
|
||||
{
|
||||
this.multiPlayerGameMode = multiPlayerGameMode;
|
||||
this.player = player;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the multiplayer game mode controller for the player}
|
||||
*/
|
||||
public MultiPlayerGameMode getMultiPlayerGameMode()
|
||||
{
|
||||
return multiPlayerGameMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the player instance}
|
||||
*/
|
||||
public LocalPlayer getPlayer()
|
||||
{
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the network connection for the player}
|
||||
*/
|
||||
public Connection getConnection()
|
||||
{
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the client player logs in to the server. The player should be initialized.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class LoggedInEvent extends ClientPlayerNetworkEvent {
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#firePlayerLogin(MultiPlayerGameMode, LocalPlayer, Connection)
|
||||
*/
|
||||
public LoggedInEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) {
|
||||
public static class LoggingIn extends ClientPlayerNetworkEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public LoggingIn(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager)
|
||||
{
|
||||
super(controller, player, networkManager);
|
||||
}
|
||||
}
|
||||
@@ -83,19 +84,18 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
/**
|
||||
* Fired when the client player logs out. This event may also fire when a new integrated server is being created.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems") // Shush IntelliJ, we override non-nullables as nullables in this specific event; see later comment
|
||||
public static class LoggedOutEvent extends ClientPlayerNetworkEvent {
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#firePlayerLogout(MultiPlayerGameMode, LocalPlayer)
|
||||
*/
|
||||
public LoggedOutEvent(@Nullable final MultiPlayerGameMode controller, @Nullable final LocalPlayer player, @Nullable final Connection networkManager) {
|
||||
@SuppressWarnings("NullableProblems")
|
||||
// Shush IntelliJ, we override non-nullables as nullables in this specific event; see later comment
|
||||
public static class LoggingOut extends ClientPlayerNetworkEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public LoggingOut(@Nullable final MultiPlayerGameMode controller, @Nullable final LocalPlayer player, @Nullable final Connection networkManager)
|
||||
{
|
||||
//noinspection ConstantConditions we know these are nullable, but we don't want to annotate the super as nullable since this is the only event with nullables
|
||||
super(controller, player, networkManager);
|
||||
}
|
||||
@@ -140,19 +140,18 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
/**
|
||||
* Fired when the client player respawns, creating a new player instance to replace the old player instance.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class RespawnEvent extends ClientPlayerNetworkEvent {
|
||||
public static class Clone extends ClientPlayerNetworkEvent
|
||||
{
|
||||
private final LocalPlayer oldPlayer;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#firePlayerRespawn(MultiPlayerGameMode, LocalPlayer, LocalPlayer, Connection)
|
||||
*/
|
||||
public RespawnEvent(final MultiPlayerGameMode pc, final LocalPlayer oldPlayer, final LocalPlayer newPlayer, final Connection networkManager) {
|
||||
@ApiStatus.Internal
|
||||
public Clone(final MultiPlayerGameMode pc, final LocalPlayer oldPlayer, final LocalPlayer newPlayer, final Connection networkManager)
|
||||
{
|
||||
super(pc, newPlayer, networkManager);
|
||||
this.oldPlayer = oldPlayer;
|
||||
}
|
||||
@@ -160,23 +159,27 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
/**
|
||||
* {@return the previous player instance}
|
||||
*/
|
||||
public LocalPlayer getOldPlayer() {
|
||||
public LocalPlayer getOldPlayer()
|
||||
{
|
||||
return oldPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the newly created player instance}
|
||||
*/
|
||||
public LocalPlayer getNewPlayer() {
|
||||
public LocalPlayer getNewPlayer()
|
||||
{
|
||||
return super.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the newly created player instance}
|
||||
*
|
||||
* @see #getNewPlayer()
|
||||
*/
|
||||
@Override
|
||||
public LocalPlayer getPlayer() {
|
||||
public LocalPlayer getPlayer()
|
||||
{
|
||||
return super.getPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
+20
-24
@@ -6,40 +6,36 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired after the field of vision (FOV) modifier for the player is calculated.
|
||||
* This can be used to modify the FOV before the FOV settings are applied.
|
||||
* Fired after the field of vision (FOV) modifier for the player is calculated to allow developers to adjust it further.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see EntityViewRenderEvent.FieldOfView
|
||||
* @see ViewportEvent.ComputeFov
|
||||
*/
|
||||
public class FOVModifierEvent extends Event
|
||||
public class ComputeFovModifierEvent extends Event
|
||||
{
|
||||
private final Player player;
|
||||
private final float fov;
|
||||
private float newFov;
|
||||
private final float fovModifier;
|
||||
private float newFovModifier;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#getFieldOfView(Player, float)
|
||||
*/
|
||||
public FOVModifierEvent(Player player, float fov)
|
||||
@ApiStatus.Internal
|
||||
public ComputeFovModifierEvent(Player player, float fovModifier)
|
||||
{
|
||||
this.player = player;
|
||||
this.fov = fov;
|
||||
this.setNewFov((float) Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get(), 1.0F, fov));
|
||||
this.fovModifier = fovModifier;
|
||||
this.setNewFovModifier((float) Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get(), 1.0F, fovModifier));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,26 +49,26 @@ public class FOVModifierEvent extends Event
|
||||
/**
|
||||
* {@return the original field of vision (FOV) of the player, before any modifications or interpolation}
|
||||
*/
|
||||
public float getFov()
|
||||
public float getFovModifier()
|
||||
{
|
||||
return fov;
|
||||
return fovModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the current field of vision (FOV) of the player}
|
||||
*/
|
||||
public float getNewFov()
|
||||
public float getNewFovModifier()
|
||||
{
|
||||
return newFov;
|
||||
return newFovModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new field of vision (FOV) of the player.
|
||||
*
|
||||
* @param newFov the new field of vision (FOV)
|
||||
* @param newFovModifier the new field of vision (FOV)
|
||||
*/
|
||||
public void setNewFov(float newFov)
|
||||
public void setNewFovModifier(float newFovModifier)
|
||||
{
|
||||
this.newFov = newFov;
|
||||
this.newFovModifier = newFovModifier;
|
||||
}
|
||||
}
|
||||
@@ -11,26 +11,24 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired for hooking into {@link AbstractContainerScreen} rendering.
|
||||
* See the two subclasses to listen for foreground or background rendering.
|
||||
* Fired for hooking into {@link AbstractContainerScreen} events.
|
||||
* See the subclasses to listen for specific events.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see ContainerScreenEvent.DrawForeground
|
||||
* @see ContainerScreenEvent.DrawBackground
|
||||
* @see Render.Foreground
|
||||
* @see Render.Background
|
||||
*/
|
||||
public class ContainerScreenEvent extends Event
|
||||
public abstract class ContainerScreenEvent extends Event
|
||||
{
|
||||
|
||||
private final AbstractContainerScreen<?> containerScreen;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public ContainerScreenEvent(AbstractContainerScreen<?> containerScreen)
|
||||
@ApiStatus.Internal
|
||||
protected ContainerScreenEvent(AbstractContainerScreen<?> containerScreen)
|
||||
{
|
||||
this.containerScreen = containerScreen;
|
||||
}
|
||||
@@ -44,27 +42,23 @@ public class ContainerScreenEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired after the container screen's foreground layer and elements are drawn, but
|
||||
* before rendering the tooltips and the item stack being dragged by the player.
|
||||
* Fired every time an {@link AbstractContainerScreen} renders.
|
||||
* See the two subclasses to listen for foreground or background rendering.
|
||||
*
|
||||
* <p>This can be used for rendering elements that must be above other screen elements, but
|
||||
* below tooltips and the dragged stack, such as slot or item stack specific overlays. </p>
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* @see Foreground
|
||||
* @see Background
|
||||
*/
|
||||
public static class DrawForeground extends ContainerScreenEvent
|
||||
public static abstract class Render extends ContainerScreenEvent
|
||||
{
|
||||
private final PoseStack poseStack;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public DrawForeground(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
@ApiStatus.Internal
|
||||
protected Render(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer);
|
||||
this.poseStack = poseStack;
|
||||
@@ -95,56 +89,44 @@ public class ContainerScreenEvent extends Event
|
||||
{
|
||||
return mouseY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired after the container screen's background layer and elements are drawn.
|
||||
* This can be used for rendering new background elements.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class DrawBackground extends ContainerScreenEvent
|
||||
{
|
||||
private final PoseStack poseStack;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* Fired after the container screen's foreground layer and elements are drawn, but
|
||||
* before rendering the tooltips and the item stack being dragged by the player.
|
||||
*
|
||||
* <p>This can be used for rendering elements that must be above other screen elements, but
|
||||
* below tooltips and the dragged stack, such as slot or item stack specific overlays.</p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public DrawBackground(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
public static class Foreground extends Render
|
||||
{
|
||||
super(guiContainer);
|
||||
this.poseStack = poseStack;
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
@ApiStatus.Internal
|
||||
public Foreground(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer, poseStack, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
* Fired after the container screen's background layer and elements are drawn.
|
||||
* This can be used for rendering new background elements.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
public static class Background extends Render
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X coordinate of the mouse pointer}
|
||||
*/
|
||||
public int getMouseX()
|
||||
{
|
||||
return mouseX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y coordinate of the mouse pointer}
|
||||
*/
|
||||
public int getMouseY()
|
||||
{
|
||||
return mouseY;
|
||||
@ApiStatus.Internal
|
||||
public Background(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
super(guiContainer, poseStack, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Fired when an overlay is about to be rendered to the screen to allow the user to modify it.
|
||||
*
|
||||
* @see BossEventProgress
|
||||
* @see DebugText
|
||||
* @see Chat
|
||||
*/
|
||||
public abstract class CustomizeGuiOverlayEvent extends Event
|
||||
{
|
||||
private final Window window;
|
||||
private final PoseStack poseStack;
|
||||
private final float partialTick;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected CustomizeGuiOverlayEvent(Window window, PoseStack poseStack, float partialTick)
|
||||
{
|
||||
this.window = window;
|
||||
this.poseStack = poseStack;
|
||||
this.partialTick = partialTick;
|
||||
}
|
||||
|
||||
public Window getWindow()
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> a boss health bar is rendered to the screen.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <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 BossEventProgress extends CustomizeGuiOverlayEvent
|
||||
{
|
||||
private final LerpingBossEvent bossEvent;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private int increment;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BossEventProgress(Window window, PoseStack poseStack, float partialTick, LerpingBossEvent bossEvent, int x, int y, int increment)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
this.bossEvent = bossEvent;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.increment = increment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the boss health bar currently being rendered
|
||||
*/
|
||||
public LerpingBossEvent getBossEvent()
|
||||
{
|
||||
return bossEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X position of the boss health bar}
|
||||
*/
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position of the boss health bar}
|
||||
*/
|
||||
public int getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position increment before rendering the next boss health bar}
|
||||
*/
|
||||
public int getIncrement()
|
||||
{
|
||||
return increment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Y position increment before rendering the next boss health bar.
|
||||
*
|
||||
* @param increment the new Y position increment
|
||||
*/
|
||||
public void setIncrement(int increment)
|
||||
{
|
||||
this.increment = increment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> textual information is rendered to the debug screen.
|
||||
* This can be used to add or remove text information.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <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
|
||||
{
|
||||
private final ArrayList<String> left;
|
||||
private final ArrayList<String> right;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public DebugText(Window window, PoseStack poseStack, float partialTick, ArrayList<String> left, ArrayList<String> right)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modifiable list of text to render on the left side
|
||||
*/
|
||||
public ArrayList<String> getLeft()
|
||||
{
|
||||
return left;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modifiable list of text to render on the right side
|
||||
*/
|
||||
public ArrayList<String> getRight()
|
||||
{
|
||||
return right;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> the chat messages overlay is rendered to the screen.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <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
|
||||
{
|
||||
private int posX;
|
||||
private int posY;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Chat(Window window, PoseStack poseStack, float partialTick, int posX, int posY)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
this.setPosX(posX);
|
||||
this.setPosY(posY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the X position of the chat messages overlay
|
||||
*/
|
||||
public int getPosX()
|
||||
{
|
||||
return posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new X position for rendering the chat messages overlay
|
||||
*
|
||||
* @param posX the new X position
|
||||
*/
|
||||
public void setPosX(int posX)
|
||||
{
|
||||
this.posX = posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Y position of the chat messages overlay
|
||||
*/
|
||||
public int getPosY()
|
||||
{
|
||||
return posY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new Y position for rendering the chat messages overlay
|
||||
*
|
||||
* @param posY the new y position
|
||||
*/
|
||||
public void setPosY(int posY)
|
||||
{
|
||||
this.posY = posY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -46,34 +47,30 @@ import java.util.function.Supplier;
|
||||
* See the various subclasses for listening to different events.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see EntityRenderersEvent.RegisterLayerDefinitions
|
||||
* @see EntityRenderersEvent.RegisterRenderers
|
||||
* @see EntityRenderersEvent.AddLayers
|
||||
*/
|
||||
public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public EntityRenderersEvent()
|
||||
@ApiStatus.Internal
|
||||
protected EntityRenderersEvent()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired for registering layer definitions at the appropriate time.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class RegisterLayerDefinitions extends EntityRenderersEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RegisterLayerDefinitions()
|
||||
{
|
||||
}
|
||||
@@ -98,16 +95,14 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* For registering entity renderer layers to existing entity renderers (whether vanilla or registered through this
|
||||
* event), listen for the {@link AddLayers} event instead.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class RegisterRenderers extends EntityRenderersEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RegisterRenderers()
|
||||
{
|
||||
}
|
||||
@@ -139,10 +134,10 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* Fired for registering entity renderer layers at the appropriate time, after the entity and player renderers maps
|
||||
* have been created.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class AddLayers extends EntityRenderersEvent
|
||||
{
|
||||
@@ -150,9 +145,7 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
private final Map<String, EntityRenderer<? extends Player>> skinMap;
|
||||
private final EntityModelSet entityModels = Minecraft.getInstance().getEntityModels();
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public AddLayers(Map<EntityType<?>, EntityRenderer<?>> renderers, Map<String, EntityRenderer<? extends Player>> playerRenderers)
|
||||
{
|
||||
this.renderers = renderers;
|
||||
@@ -161,7 +154,7 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
|
||||
/**
|
||||
* {@return the set of player skin names which have a renderer}
|
||||
*
|
||||
* <p>
|
||||
* Minecraft provides two default skin names: {@code default} for the
|
||||
* {@linkplain ModelLayers#PLAYER regular player model} and {@code slim} for the
|
||||
* {@linkplain ModelLayers#PLAYER_SLIM slim player model}.
|
||||
@@ -196,7 +189,8 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends LivingEntity, R extends LivingEntityRenderer<T, ? extends EntityModel<T>>> R getRenderer(EntityType<? extends T> entityType) {
|
||||
public <T extends LivingEntity, R extends LivingEntityRenderer<T, ? extends EntityModel<T>>> R getRenderer(EntityType<? extends T> entityType)
|
||||
{
|
||||
return (R) renderers.get(entityType);
|
||||
}
|
||||
|
||||
@@ -212,16 +206,17 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
/**
|
||||
* Fired for registering additional {@linkplain net.minecraft.client.model.SkullModelBase skull models} at the appropriate time.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class CreateSkullModels extends EntityRenderersEvent
|
||||
{
|
||||
private final ImmutableMap.Builder<Type, SkullModelBase> builder;
|
||||
private final EntityModelSet entityModelSet;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public CreateSkullModels(ImmutableMap.Builder<Type, SkullModelBase> builder, EntityModelSet entityModelSet)
|
||||
{
|
||||
this.builder = builder;
|
||||
|
||||
@@ -7,117 +7,48 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* Fired when an input is detected from the user's input devices.
|
||||
* See the various subclasses to listen for specific devices and inputs.
|
||||
*
|
||||
* @see InputEvent.RawMouseEvent
|
||||
* @see InputEvent.MouseInputEvent
|
||||
* @see InputEvent.MouseScrollEvent
|
||||
* @see InputEvent.KeyInputEvent
|
||||
* @see InputEvent.ClickInputEvent
|
||||
* @see InputEvent.MouseButton
|
||||
* @see MouseScrollingEvent
|
||||
* @see Key
|
||||
* @see InteractionKeyMappingTriggered
|
||||
*/
|
||||
public class InputEvent extends Event
|
||||
public abstract class InputEvent extends Event
|
||||
{
|
||||
/**
|
||||
* Fired when a mouse button is clicked, <b>before</b> being processed by vanilla.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the mouse event will not be processed by vanilla (e.g. keymappings and screens) </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @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 RawMouseEvent extends InputEvent
|
||||
@ApiStatus.Internal
|
||||
protected InputEvent()
|
||||
{
|
||||
private final int button;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onRawMouseClicked(int, int, int)
|
||||
*/
|
||||
public RawMouseEvent(int button, int action, int modifiers)
|
||||
{
|
||||
this.button = button;
|
||||
this.action = action;
|
||||
this.modifiers = modifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the mouse button's input code}
|
||||
*
|
||||
* @see InputConstants input constants starting with {@code MOUSE_BUTTON_}
|
||||
* @see GLFW mouse constants starting with {@code 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()
|
||||
{
|
||||
return this.button;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the mouse button's action}
|
||||
*
|
||||
* @see InputConstants#PRESS
|
||||
* @see InputConstants#RELEASE
|
||||
*/
|
||||
public int getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a bit field representing the active modifier keys}
|
||||
*
|
||||
* @see InputConstants#MOD_CONTROL CTRL modifier key bit
|
||||
* @see GLFW#GLFW_MOD_SHIFT SHIFT modifier key bit
|
||||
* @see GLFW#GLFW_MOD_ALT ALT modifier key bit
|
||||
* @see GLFW#GLFW_MOD_SUPER SUPER modifier key bit
|
||||
* @see GLFW#GLFW_KEY_CAPS_LOCK CAPS LOCK modifier key bit
|
||||
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getModifiers()
|
||||
{
|
||||
return this.modifiers;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a mouse button is clicked, <b>after</b> processing.
|
||||
* Fired when a mouse button is pressed/released. Sub-events get fired {@link Pre before} and {@link Post after} this happens.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
* @see Pre
|
||||
* @see Post
|
||||
*/
|
||||
public static class MouseInputEvent extends InputEvent
|
||||
public static abstract class MouseButton extends InputEvent
|
||||
{
|
||||
private final int button;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onRawMouseClicked(int, int, int)
|
||||
*/
|
||||
public MouseInputEvent(int button, int action, int modifiers)
|
||||
@ApiStatus.Internal
|
||||
protected MouseButton(int button, int action, int modifiers)
|
||||
{
|
||||
this.button = button;
|
||||
this.action = action;
|
||||
@@ -161,6 +92,46 @@ public class InputEvent extends Event
|
||||
{
|
||||
return this.modifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a mouse button is pressed/released, <b>before</b> being processed by vanilla.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the mouse event will not be processed by vanilla (e.g. keymappings and screens) </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Pre(int button, int action, int modifiers)
|
||||
{
|
||||
super(button, action, modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a mouse button is pressed/released, <b>after</b> processing.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Post(int button, int action, int modifiers)
|
||||
{
|
||||
super(button, action, modifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,15 +139,15 @@ public class InputEvent extends Event
|
||||
* processed by vanilla.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the mouse scroll event will not be processed further. </p>
|
||||
* If the event is cancelled, then the mouse scroll event will not be processed further.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @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 MouseScrollEvent extends InputEvent
|
||||
public static class MouseScrollingEvent extends InputEvent
|
||||
{
|
||||
private final double scrollDelta;
|
||||
private final double mouseX;
|
||||
@@ -185,11 +156,8 @@ public class InputEvent extends Event
|
||||
private final boolean middleDown;
|
||||
private final boolean rightDown;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onMouseScroll(MouseHandler, double)
|
||||
*/
|
||||
public MouseScrollEvent(double scrollDelta, boolean leftDown, boolean middleDown, boolean rightDown, double mouseX, double mouseY)
|
||||
@ApiStatus.Internal
|
||||
public MouseScrollingEvent(double scrollDelta, boolean leftDown, boolean middleDown, boolean rightDown, double mouseX, double mouseY)
|
||||
{
|
||||
this.scrollDelta = scrollDelta;
|
||||
this.leftDown = leftDown;
|
||||
@@ -251,23 +219,20 @@ public class InputEvent extends Event
|
||||
/**
|
||||
* Fired when a keyboard key input occurs, such as pressing, releasing, or repeating a key.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class KeyInputEvent extends InputEvent
|
||||
public static class Key extends InputEvent
|
||||
{
|
||||
private final int key;
|
||||
private final int scanCode;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#fireKeyInput(int, int, int, int)
|
||||
*/
|
||||
public KeyInputEvent(int key, int scanCode, int action, int modifiers)
|
||||
@ApiStatus.Internal
|
||||
public Key(int key, int scanCode, int action, int modifiers)
|
||||
{
|
||||
this.key = key;
|
||||
this.scanCode = scanCode;
|
||||
@@ -289,7 +254,7 @@ public class InputEvent extends Event
|
||||
|
||||
/**
|
||||
* {@return the platform-specific scan code}
|
||||
*
|
||||
* <p>
|
||||
* The scan code is unique for every key, regardless of whether it has a key code.
|
||||
* Scan codes are platform-specific but consistent over time, so keys will have different scan codes depending
|
||||
* on the platform but they are safe to save to disk as custom key bindings.
|
||||
@@ -342,24 +307,21 @@ public class InputEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the keymapping's action is not processed further, and the hand will be swung
|
||||
* according to {@link #shouldSwingHand()}. </p>
|
||||
* according to {@link #shouldSwingHand()}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class ClickInputEvent extends InputEvent
|
||||
public static class InteractionKeyMappingTriggered extends InputEvent
|
||||
{
|
||||
private final int button;
|
||||
private final KeyMapping keyMapping;
|
||||
private final InteractionHand hand;
|
||||
private boolean handSwing = true;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onClickInput(int, KeyMapping, InteractionHand)
|
||||
*/
|
||||
public ClickInputEvent(int button, KeyMapping keyMapping, InteractionHand hand)
|
||||
@ApiStatus.Internal
|
||||
public InteractionKeyMappingTriggered(int button, KeyMapping keyMapping, InteractionHand hand)
|
||||
{
|
||||
this.button = button;
|
||||
this.keyMapping = keyMapping;
|
||||
@@ -386,7 +348,7 @@ public class InputEvent extends Event
|
||||
|
||||
/**
|
||||
* {@return the hand that caused the input}
|
||||
*
|
||||
* <p>
|
||||
* The event will be called for both hands if this is a use item input regardless
|
||||
* of both event's cancellation.
|
||||
* Will always be {@link InteractionHand#MAIN_HAND} if this is an attack or pick block input.
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.ForgeModelBakery;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
/**
|
||||
* Fired when the ModelManager is notified of the resource manager reloading.
|
||||
* Called after model registry is setup, but before it's passed to BlockModelShapes.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
// TODO: try to merge with ICustomModelLoader
|
||||
public class ModelBakeEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ModelManager modelManager;
|
||||
private final Map<ResourceLocation, BakedModel> modelRegistry;
|
||||
private final ForgeModelBakery modelLoader;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onModelBake(ModelManager, Map, ForgeModelBakery)
|
||||
*/
|
||||
public ModelBakeEvent(ModelManager modelManager, Map<ResourceLocation, BakedModel> modelRegistry, ForgeModelBakery modelLoader)
|
||||
{
|
||||
this.modelManager = modelManager;
|
||||
this.modelRegistry = modelRegistry;
|
||||
this.modelLoader = modelLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the model manager}
|
||||
*/
|
||||
public ModelManager getModelManager()
|
||||
{
|
||||
return modelManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the modifiable registry map of models and their model names}
|
||||
*/
|
||||
public Map<ResourceLocation, BakedModel> getModelRegistry()
|
||||
{
|
||||
return modelRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the model loader}
|
||||
*/
|
||||
public ForgeModelBakery getModelLoader()
|
||||
{
|
||||
return modelLoader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
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.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Houses events related to models.
|
||||
*/
|
||||
public abstract class ModelEvent extends Event
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
protected ModelEvent()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the {@link ModelManager} is notified of the resource manager reloading.
|
||||
* Called after model registry is set up, but before it's passed to {@link net.minecraft.client.renderer.block.BlockModelShaper}.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class BakingCompleted extends ModelEvent implements IModBusEvent
|
||||
{
|
||||
private final ModelManager modelManager;
|
||||
private final Map<ResourceLocation, BakedModel> models;
|
||||
private final ModelBakery modelBakery;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BakingCompleted(ModelManager modelManager, Map<ResourceLocation, BakedModel> models, ModelBakery modelBakery)
|
||||
{
|
||||
this.modelManager = modelManager;
|
||||
this.models = models;
|
||||
this.modelBakery = modelBakery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the model manager
|
||||
*/
|
||||
public ModelManager getModelManager()
|
||||
{
|
||||
return modelManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modifiable registry map of models and their model names
|
||||
*/
|
||||
public Map<ResourceLocation, BakedModel> getModels()
|
||||
{
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the model loader
|
||||
*/
|
||||
public ModelBakery getModelBakery()
|
||||
{
|
||||
return modelBakery;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the {@link net.minecraft.client.resources.model.ModelBakery} is notified of the resource manager reloading.
|
||||
* Allows developers to register models to be loaded, along with their dependencies.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain 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;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterAdditional(Set<ResourceLocation> models)
|
||||
{
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a model to be loaded, along with its dependencies.
|
||||
*/
|
||||
public void register(ResourceLocation model)
|
||||
{
|
||||
models.add(model);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows users to register their own {@link IGeometryLoader geometry loaders} for use in block/item models.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class RegisterGeometryLoaders extends ModelEvent implements IModBusEvent
|
||||
{
|
||||
private final Map<ResourceLocation, IGeometryLoader<?>> loaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
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);
|
||||
Preconditions.checkArgument(!loaders.containsKey(key), "Geometry loader already registered: " + key);
|
||||
loaders.put(key, loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
/**
|
||||
* Fired when the {@link ModelLoaderRegistry} is ready for model loader registrations.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ModelLoaderRegistry#registerLoader(ResourceLocation, IModelLoader)
|
||||
*/
|
||||
public class ModelRegistryEvent extends Event implements IModBusEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ModelLoaderRegistry#onModelLoadingStart()
|
||||
*/
|
||||
public ModelRegistryEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -5,30 +5,27 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.client.player.Input;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* <p>Fired after the player's movement inputs are updated.</p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class MovementInputUpdateEvent extends PlayerEvent
|
||||
{
|
||||
private final Input input;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onMovementInputUpdate(Player, Input)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public MovementInputUpdateEvent(Player player, Input input)
|
||||
{
|
||||
super(player);
|
||||
@@ -42,5 +39,4 @@ public class MovementInputUpdateEvent extends PlayerEvent
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,32 +6,28 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when the {@link RecipeManager} has received and synced the recipes from the server to the client.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RecipesUpdatedEvent extends Event
|
||||
{
|
||||
private final RecipeManager recipeManager;
|
||||
|
||||
private final RecipeManager mgr;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onRecipesUpdated(RecipeManager)
|
||||
*/
|
||||
public RecipesUpdatedEvent(RecipeManager mgr)
|
||||
@ApiStatus.Internal
|
||||
public RecipesUpdatedEvent(RecipeManager recipeManager)
|
||||
{
|
||||
this.mgr = mgr;
|
||||
this.recipeManager = recipeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +35,6 @@ public class RecipesUpdatedEvent extends Event
|
||||
*/
|
||||
public RecipeManager getRecipeManager()
|
||||
{
|
||||
return mgr;
|
||||
return recipeManager;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired to allow mods to register client commands.
|
||||
@@ -26,23 +27,19 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
* objectives that are displayed to the player.
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see net.minecraftforge.event.RegisterCommandsEvent
|
||||
*/
|
||||
public class RegisterClientCommandsEvent extends Event
|
||||
{
|
||||
|
||||
private final CommandDispatcher<CommandSourceStack> dispatcher;
|
||||
private final CommandBuildContext context;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ClientCommandHandler#mergeServerCommands(CommandDispatcher, CommandBuildContext)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RegisterClientCommandsEvent(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext context)
|
||||
{
|
||||
this.dispatcher = dispatcher;
|
||||
|
||||
+5
-6
@@ -14,25 +14,24 @@ 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;
|
||||
|
||||
/**
|
||||
* Fired to allow mods to register their reload listeners on the client-side resource manager.
|
||||
* This event is fired once during the construction of the {@link Minecraft} instance.
|
||||
*
|
||||
* <p>For registering reload listeners on the server-side resource manager, see {@link AddReloadListenerEvent}. </p>
|
||||
* <p>For registering reload listeners on the server-side resource manager, see {@link AddReloadListenerEvent}.</p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterClientReloadListenersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ReloadableResourceManager resourceManager;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RegisterClientReloadListenersEvent(ReloadableResourceManager resourceManager)
|
||||
{
|
||||
this.resourceManager = resourceManager;
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Allows users to register custom {@link net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent}
|
||||
* factories for their {@link net.minecraft.world.inventory.tooltip.TooltipComponent} types.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterClientTooltipComponentFactoriesEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> factories;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterClientTooltipComponentFactoriesEvent(Map<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> factories)
|
||||
{
|
||||
this.factories = factories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link ClientTooltipComponent} factory for a {@link TooltipComponent}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends TooltipComponent> void register(Class<T> type, Function<? super T, ? extends ClientTooltipComponent> factory)
|
||||
{
|
||||
factories.put(type, (Function<TooltipComponent, ClientTooltipComponent>) factory);
|
||||
}
|
||||
}
|
||||
+40
-24
@@ -10,48 +10,43 @@ import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired for registering block and item color handlers at the appropriate time.
|
||||
* See the two subclasses for registering block or item color handlers.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see ColorHandlerEvent.Block
|
||||
* @see ColorHandlerEvent.Item
|
||||
* @see RegisterColorHandlersEvent.Block
|
||||
* @see RegisterColorHandlersEvent.Item
|
||||
*/
|
||||
public abstract class ColorHandlerEvent extends Event implements IModBusEvent
|
||||
public abstract class RegisterColorHandlersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
/**
|
||||
* @hidden This should only be invoked by subclasses.
|
||||
*/
|
||||
public ColorHandlerEvent()
|
||||
@ApiStatus.Internal
|
||||
protected RegisterColorHandlersEvent()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired for registering block color handlers.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Block extends ColorHandlerEvent
|
||||
public static class Block extends RegisterColorHandlersEvent
|
||||
{
|
||||
private final BlockColors blockColors;
|
||||
|
||||
/**
|
||||
* @hidden This should only be invoked by the client hook.
|
||||
* @see ForgeHooksClient#onBlockColorsInit(BlockColors)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Block(BlockColors blockColors)
|
||||
{
|
||||
this.blockColors = blockColors;
|
||||
@@ -59,34 +54,43 @@ public abstract class ColorHandlerEvent extends Event implements IModBusEvent
|
||||
|
||||
/**
|
||||
* {@return the block colors registry}
|
||||
*
|
||||
* @see BlockColors#register(BlockColor, net.minecraft.world.level.block.Block...)
|
||||
*/
|
||||
public BlockColors getBlockColors()
|
||||
{
|
||||
return blockColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link BlockColor} instance for a set of blocks.
|
||||
*
|
||||
* @param blockColor The color provider
|
||||
* @param blocks The blocks
|
||||
*/
|
||||
public void register(BlockColor blockColor, net.minecraft.world.level.block.Block... blocks)
|
||||
{
|
||||
blockColors.register(blockColor, blocks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired for registering item color handlers.
|
||||
*
|
||||
* <p>The block colors should only be used for referencing or delegating item colors to their respective block
|
||||
* colors. Use {@link ColorHandlerEvent.Block} for registering your block color handlers. </p>
|
||||
* colors. Use {@link RegisterColorHandlersEvent.Block} for registering your block color handlers.</p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Item extends ColorHandlerEvent
|
||||
public static class Item extends RegisterColorHandlersEvent
|
||||
{
|
||||
private final ItemColors itemColors;
|
||||
private final BlockColors blockColors;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onItemColorsInit(ItemColors, BlockColors)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Item(ItemColors itemColors, BlockColors blockColors)
|
||||
{
|
||||
this.itemColors = itemColors;
|
||||
@@ -95,6 +99,7 @@ public abstract class ColorHandlerEvent extends Event implements IModBusEvent
|
||||
|
||||
/**
|
||||
* {@return the item colors registry}
|
||||
*
|
||||
* @see ItemColors#register(ItemColor, ItemLike...)
|
||||
*/
|
||||
public ItemColors getItemColors()
|
||||
@@ -110,5 +115,16 @@ public abstract class ColorHandlerEvent extends Event implements IModBusEvent
|
||||
{
|
||||
return blockColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link ItemColor} instance for a set of blocks.
|
||||
*
|
||||
* @param itemColor The color provider
|
||||
* @param items The items
|
||||
*/
|
||||
public void register(ItemColor itemColor, ItemLike... items)
|
||||
{
|
||||
itemColors.register(itemColor, items);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Allows users to register custom {@link DimensionSpecialEffects} for their dimensions.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterDimensionSpecialEffectsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<ResourceLocation, DimensionSpecialEffects> effects;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterDimensionSpecialEffectsEvent(Map<ResourceLocation, DimensionSpecialEffects> effects)
|
||||
{
|
||||
this.effects = effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the effects for a given dimension type.
|
||||
*/
|
||||
public void register(ResourceLocation dimensionType, DimensionSpecialEffects effects)
|
||||
{
|
||||
this.effects.put(dimensionType, effects);
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Allows users to register custom shaders to be used when the player spectates a certain kind of entity.
|
||||
* Vanilla examples of this are the green effect for creepers and the invert effect for endermen.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterEntitySpectatorShadersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<EntityType<?>, ResourceLocation> shaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterEntitySpectatorShadersEvent(Map<EntityType<?>, ResourceLocation> shaders)
|
||||
{
|
||||
this.shaders = shaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a spectator shader for a given entity type.
|
||||
*/
|
||||
public void register(EntityType<?> entityType, ResourceLocation shader)
|
||||
{
|
||||
shaders.put(entityType, shader);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.gui.overlay.IGuiOverlay;
|
||||
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Allows users to register custom {@link IGuiOverlay GUI overlays}.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterGuiOverlaysEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<ResourceLocation, IGuiOverlay> overlays;
|
||||
private final List<ResourceLocation> orderedOverlays;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterGuiOverlaysEvent(Map<ResourceLocation, IGuiOverlay> overlays, List<ResourceLocation> orderedOverlays)
|
||||
{
|
||||
this.overlays = overlays;
|
||||
this.orderedOverlays = orderedOverlays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an overlay that renders below all others.
|
||||
*
|
||||
* @param id A unique resource id for this overlay
|
||||
* @param overlay The overlay
|
||||
*/
|
||||
public void registerBelowAll(@NotNull String id, @NotNull IGuiOverlay overlay)
|
||||
{
|
||||
register(Ordering.BEFORE, null, id, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an overlay that renders below another.
|
||||
*
|
||||
* @param other The id of the overlay to render below. This must be an overlay you have already registered or a
|
||||
* {@link VanillaGuiOverlay vanilla overlay}. Do not use other mods' overlays.
|
||||
* @param id A unique resource id for this overlay
|
||||
* @param overlay The overlay
|
||||
*/
|
||||
public void registerBelow(@NotNull ResourceLocation other, @NotNull String id, @NotNull IGuiOverlay overlay)
|
||||
{
|
||||
register(Ordering.BEFORE, other, id, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an overlay that renders above another.
|
||||
*
|
||||
* @param other The id of the overlay to render above. This must be an overlay you have already registered or a
|
||||
* {@link VanillaGuiOverlay vanilla overlay}. Do not use other mods' overlays.
|
||||
* @param id A unique resource id for this overlay
|
||||
* @param overlay The overlay
|
||||
*/
|
||||
public void registerAbove(@NotNull ResourceLocation other, @NotNull String id, @NotNull IGuiOverlay overlay)
|
||||
{
|
||||
register(Ordering.AFTER, other, id, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an overlay that renders above all others.
|
||||
*
|
||||
* @param id A unique resource id for this overlay
|
||||
* @param overlay The overlay
|
||||
*/
|
||||
public void registerAboveAll(@NotNull String id, @NotNull IGuiOverlay overlay)
|
||||
{
|
||||
register(Ordering.AFTER, null, id, overlay);
|
||||
}
|
||||
|
||||
private void register(@NotNull Ordering ordering, @Nullable ResourceLocation other, @NotNull String id, @NotNull IGuiOverlay overlay)
|
||||
{
|
||||
var key = new ResourceLocation(ModLoadingContext.get().getActiveNamespace(), id);
|
||||
Preconditions.checkArgument(!overlays.containsKey(key), "Overlay already registered: " + key);
|
||||
|
||||
int insertPosition;
|
||||
if (other == null)
|
||||
{
|
||||
insertPosition = ordering == Ordering.BEFORE ? 0 : overlays.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
int otherIndex = orderedOverlays.indexOf(other);
|
||||
Preconditions.checkState(otherIndex >= 0, "Attempted to order against an unregistered overlay. Only order against vanilla's and your own.");
|
||||
insertPosition = otherIndex + (ordering == Ordering.BEFORE ? 0 : 1);
|
||||
}
|
||||
|
||||
overlays.put(key, overlay);
|
||||
orderedOverlays.add(insertPosition, key);
|
||||
}
|
||||
|
||||
private enum Ordering
|
||||
{
|
||||
BEFORE, AFTER
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Allows users to register custom {@link net.minecraft.client.KeyMapping key mappings}.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterKeyMappingsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Options options;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterKeyMappingsEvent(Options options)
|
||||
{
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new key mapping.
|
||||
*/
|
||||
public void register(KeyMapping key)
|
||||
{
|
||||
options.keyMappings = ArrayUtils.add(options.keyMappings, key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.RenderTypeGroup;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Allows users to register custom named {@link RenderType render types}.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterNamedRenderTypesEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<ResourceLocation, RenderTypeGroup> renderTypes;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterNamedRenderTypesEvent(Map<ResourceLocation, RenderTypeGroup> renderTypes)
|
||||
{
|
||||
this.renderTypes = renderTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a named {@link RenderTypeGroup}.
|
||||
*
|
||||
* @param name The name
|
||||
* @param blockRenderType One of the values returned by {@link RenderType#chunkBufferLayers()}
|
||||
* @param entityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY}
|
||||
*/
|
||||
public void register(String name, RenderType blockRenderType, RenderType entityRenderType)
|
||||
{
|
||||
register(name, blockRenderType, entityRenderType, entityRenderType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a named {@link RenderTypeGroup}.
|
||||
*
|
||||
* @param name The name
|
||||
* @param blockRenderType One of the values returned by {@link RenderType#chunkBufferLayers()}
|
||||
* @param entityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY}
|
||||
* @param fabulousEntityRenderType A {@link RenderType} using {@link DefaultVertexFormat#NEW_ENTITY} for use when
|
||||
* "fabulous" rendering is enabled
|
||||
*/
|
||||
public void register(String name, RenderType blockRenderType, RenderType entityRenderType, RenderType fabulousEntityRenderType)
|
||||
{
|
||||
var key = new ResourceLocation(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.");
|
||||
Preconditions.checkArgument(entityRenderType.format() == DefaultVertexFormat.NEW_ENTITY, "The entity render type must use the NEW_ENTITY vertex format.");
|
||||
Preconditions.checkArgument(fabulousEntityRenderType.format() == DefaultVertexFormat.NEW_ENTITY, "The fabulous entity render type must use the NEW_ENTITY vertex format.");
|
||||
renderTypes.put(key, new RenderTypeGroup(blockRenderType, entityRenderType, fabulousEntityRenderType));
|
||||
}
|
||||
}
|
||||
+22
-10
@@ -7,6 +7,7 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.client.particle.ParticleProvider;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -14,25 +15,36 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired for registering particle providers at the appropriate time.
|
||||
*
|
||||
* <p>{@link ParticleType}s must be registered during {@link RegisterEvent} as usual;
|
||||
* this event is only for the {@link ParticleProvider}s. </p>
|
||||
* this event is only for the {@link ParticleProvider}s.</p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ParticleEngine#register(ParticleType, ParticleProvider)
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class ParticleFactoryRegisterEvent extends Event implements IModBusEvent {
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public ParticleFactoryRegisterEvent()
|
||||
public class RegisterParticleProvidersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ParticleEngine particleEngine;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterParticleProvidersEvent(ParticleEngine particleEngine)
|
||||
{
|
||||
this.particleEngine = particleEngine;
|
||||
}
|
||||
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleProvider<T> provider)
|
||||
{
|
||||
particleEngine.register(type, provider);
|
||||
}
|
||||
|
||||
public <T extends ParticleOptions> void register(ParticleType<T> type, ParticleEngine.SpriteParticleRegistration<T> registration)
|
||||
{
|
||||
particleEngine.register(type, registration);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.client.RecipeBookCategories;
|
||||
import net.minecraft.world.inventory.RecipeBookType;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Allows users to register custom categories for the vanilla recipe book, making it usable in modded GUIs.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterRecipeBookCategoriesEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<RecipeBookCategories, ImmutableList<RecipeBookCategories>> aggregateCategories;
|
||||
private final Map<RecipeBookType, ImmutableList<RecipeBookCategories>> typeCategories;
|
||||
private final Map<RecipeType<?>, Function<Recipe<?>, RecipeBookCategories>> recipeCategoryLookups;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterRecipeBookCategoriesEvent(
|
||||
Map<RecipeBookCategories, ImmutableList<RecipeBookCategories>> aggregateCategories,
|
||||
Map<RecipeBookType, ImmutableList<RecipeBookCategories>> typeCategories,
|
||||
Map<RecipeType<?>, Function<Recipe<?>, RecipeBookCategories>> recipeCategoryLookups)
|
||||
{
|
||||
this.aggregateCategories = aggregateCategories;
|
||||
this.typeCategories = typeCategories;
|
||||
this.recipeCategoryLookups = recipeCategoryLookups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the list of categories that compose an aggregate category.
|
||||
*/
|
||||
public void registerAggregateCategory(RecipeBookCategories category, List<RecipeBookCategories> others)
|
||||
{
|
||||
aggregateCategories.put(category, ImmutableList.copyOf(others));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the list of categories that compose a recipe book.
|
||||
*/
|
||||
public void registerBookCategories(RecipeBookType type, List<RecipeBookCategories> categories)
|
||||
{
|
||||
typeCategories.put(type, ImmutableList.copyOf(categories));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a category lookup for a certain recipe type.
|
||||
*/
|
||||
public void registerRecipeCategoryFinder(RecipeType<?> type, Function<Recipe<?>, RecipeBookCategories> lookup)
|
||||
{
|
||||
recipeCategoryLookups.put(type, lookup);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -21,19 +22,17 @@ import java.util.function.Consumer;
|
||||
* Fired to allow mods to register custom {@linkplain ShaderInstance shaders}.
|
||||
* This event is fired after the default Minecraft shaders have been registered.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterShadersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ResourceManager resourceManager;
|
||||
private final List<Pair<ShaderInstance, Consumer<ShaderInstance>>> shaderList;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RegisterShadersEvent(ResourceManager resourceManager, List<Pair<ShaderInstance, Consumer<ShaderInstance>>> shaderList)
|
||||
{
|
||||
this.resourceManager = resourceManager;
|
||||
@@ -52,10 +51,10 @@ public class RegisterShadersEvent extends Event implements IModBusEvent
|
||||
* Registers a shader, and a callback for when the shader is loaded.
|
||||
*
|
||||
* <p>When creating a {@link ShaderInstance}, pass in the {@linkplain #getResourceManager()
|
||||
* client-side resource manager} as the resource provider. </p>
|
||||
* client-side resource manager} as the resource provider.</p>
|
||||
*
|
||||
* <p>Mods should not store the shader instance passed into this method. Instead, mods should store the shader
|
||||
* passed into the registered load callback. </p>
|
||||
* passed into the registered load callback.</p>
|
||||
*
|
||||
* @param shaderInstance a shader
|
||||
* @param onLoaded a callback for when the shader is loaded
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Allows users to register custom {@link ITextureAtlasSpriteLoader texture atlas sprite loaders}.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterTextureAtlasSpriteLoadersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<ResourceLocation, ITextureAtlasSpriteLoader> loaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
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);
|
||||
Preconditions.checkArgument(!loaders.containsKey(key), "Sprite loader already registered: " + key);
|
||||
loaders.put(key, loader);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired before the player's arm is rendered in first person. This is a more targeted version of {@link RenderHandEvent},
|
||||
@@ -21,10 +22,10 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
* replacing the arm with armor.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the arm will not be rendered. </p>
|
||||
* If this event is cancelled, then the arm will not be rendered.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderArmEvent extends Event
|
||||
@@ -35,10 +36,7 @@ public class RenderArmEvent extends Event
|
||||
private final AbstractClientPlayer player;
|
||||
private final HumanoidArm arm;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#renderSpecificFirstPersonArm(PoseStack, MultiBufferSource, int, AbstractClientPlayer, HumanoidArm)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RenderArmEvent(PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, AbstractClientPlayer player, HumanoidArm arm)
|
||||
{
|
||||
this.poseStack = poseStack;
|
||||
|
||||
+35
-20
@@ -6,35 +6,34 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired before a block texture will be overlaid on the player's view.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the overlay will not be rendered. </p>
|
||||
* If this event is cancelled, then the overlay will not be rendered.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderBlockOverlayEvent extends Event
|
||||
public class RenderBlockScreenEffectEvent extends Event
|
||||
{
|
||||
|
||||
/**
|
||||
* The type of the block overlay to be rendered.
|
||||
*
|
||||
* @see RenderBlockOverlayEvent
|
||||
* @see RenderBlockScreenEffectEvent
|
||||
*/
|
||||
public enum OverlayType {
|
||||
public enum OverlayType
|
||||
{
|
||||
/**
|
||||
* The type of the overlay when the player is burning / on fire.
|
||||
*/
|
||||
@@ -55,37 +54,53 @@ public class RenderBlockOverlayEvent extends Event
|
||||
private final BlockState blockState;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderBlockOverlayEvent(Player player, PoseStack poseStack, OverlayType type, BlockState block, BlockPos blockPos)
|
||||
@ApiStatus.Internal
|
||||
public RenderBlockScreenEffectEvent(Player player, PoseStack poseStack, OverlayType type, BlockState block, BlockPos blockPos)
|
||||
{
|
||||
this.player = player;
|
||||
this.poseStack = poseStack;
|
||||
this.overlayType = type;
|
||||
this.blockState = block;
|
||||
this.blockPos = blockPos;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the player which the overlay will apply to}
|
||||
*/
|
||||
public Player getPlayer() { return player; }
|
||||
public Player getPlayer()
|
||||
{
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the type of the overlay}
|
||||
*/
|
||||
public OverlayType getOverlayType() { return overlayType; }
|
||||
public OverlayType getOverlayType()
|
||||
{
|
||||
return overlayType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the block which the overlay is gotten from}
|
||||
*/
|
||||
public BlockState getBlockState() { return blockState; }
|
||||
public BlockState getBlockState()
|
||||
{
|
||||
return blockState;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the position of the block which the overlay is gotten from}
|
||||
*/
|
||||
public BlockPos getBlockPos() { return blockPos; }
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
return blockPos;
|
||||
}
|
||||
}
|
||||
@@ -1,436 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
import net.minecraftforge.client.gui.IIngameOverlay;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired when an overlay element is rendered to the game window.
|
||||
* See the two subclasses for listening to before and after rendering.
|
||||
*
|
||||
* <p>An overlay that is not normally active cannot be forced to render, and this event will not fire. </p>
|
||||
*
|
||||
* @see RenderGameOverlayEvent.Pre
|
||||
* @see RenderGameOverlayEvent.Post
|
||||
* @see ForgeIngameGui
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderGameOverlayEvent extends Event
|
||||
{
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the game window}
|
||||
*/
|
||||
public Window getWindow()
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the type of the overlay element being rendered}
|
||||
*/
|
||||
public ElementType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The types of the different overlay elements that can be rendered
|
||||
*/
|
||||
public enum ElementType
|
||||
{
|
||||
/**
|
||||
* Represents all of the overlay elements; cancelling the {@link RenderGameOverlayEvent.Pre} with this type
|
||||
* will suppress rendering of all overlay elements.
|
||||
*/
|
||||
ALL,
|
||||
/**
|
||||
* An in-game overlay layer.
|
||||
*
|
||||
* @see IIngameOverlay
|
||||
* @see RenderGameOverlayEvent.PreLayer
|
||||
* @see RenderGameOverlayEvent.PostLayer
|
||||
*/
|
||||
LAYER,
|
||||
/**
|
||||
* An individual boss event bar.
|
||||
*
|
||||
* @see RenderGameOverlayEvent.BossInfo
|
||||
*/
|
||||
BOSSINFO,
|
||||
/**
|
||||
* For adding text to be rendered on the screen (after the debug screen text, if visible).
|
||||
*
|
||||
* @see RenderGameOverlayEvent.Text
|
||||
*/
|
||||
TEXT,
|
||||
/**
|
||||
* The chat message window overlay.
|
||||
*
|
||||
* @see RenderGameOverlayEvent.Chat
|
||||
*/
|
||||
CHAT,
|
||||
/**
|
||||
* The player list overlay, shown when the <kbd>TAB</kbd> key (or other keybind) is pressed.
|
||||
*
|
||||
* <em>See {@code ForgeIngameGui#renderPlayerList}</em>
|
||||
*/
|
||||
PLAYER_LIST,
|
||||
/**
|
||||
* The debug overlay.
|
||||
*
|
||||
* <em>See {@code ForgeIngameGui#renderHUDText.}</em>
|
||||
*/
|
||||
DEBUG
|
||||
}
|
||||
|
||||
private final PoseStack poseStack;
|
||||
private final float partialTick;
|
||||
private final Window window;
|
||||
private final ElementType type;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderGameOverlayEvent(PoseStack poseStack, float partialTick, Window window)
|
||||
{
|
||||
this.poseStack = poseStack;
|
||||
this.partialTick = partialTick;
|
||||
this.window = window;
|
||||
this.type = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
private RenderGameOverlayEvent(PoseStack poseStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
this.poseStack = poseStack;
|
||||
this.partialTick = parent.getPartialTick();
|
||||
this.window = parent.getWindow();
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> an active overlay element is rendered to the screen.
|
||||
* <em>See the three sub-classes for specific special overlay elements. </em>
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the overlay corresponding to this event will not be rendered, and the
|
||||
* corresponding {@link RenderGameOverlayEvent.Post} event is not fired. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see RenderGameOverlayEvent.PreLayer
|
||||
* @see RenderGameOverlayEvent.BossInfo
|
||||
* @see RenderGameOverlayEvent.Text
|
||||
* @see RenderGameOverlayEvent.Chat
|
||||
*/
|
||||
public static class Pre extends RenderGameOverlayEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Pre(PoseStack poseStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
super(poseStack, parent, type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> an active overlay element is rendered to the screen, if the corresponding
|
||||
* {@link RenderGameOverlayEvent.Pre} is not cancelled.
|
||||
* <em>See the specialized {@link RenderGameOverlayEvent.PostLayer} for individual overlay layer.</em>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class Post extends RenderGameOverlayEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Post(PoseStack poseStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
super(poseStack, parent, type);
|
||||
}
|
||||
@Override public boolean isCancelable(){ return false; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> an in-game overlay layer is rendered to the screen.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the overlay layer in this event will not be rendered, and the
|
||||
* corresponding {@link RenderGameOverlayEvent.PostLayer} event is not fired. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see RenderGameOverlayEvent.PostLayer
|
||||
*/
|
||||
public static class PreLayer extends Pre
|
||||
{
|
||||
private final IIngameOverlay overlay;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public PreLayer(PoseStack mStack, RenderGameOverlayEvent parent, IIngameOverlay overlay)
|
||||
{
|
||||
super(mStack, parent, ElementType.LAYER);
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the in-game overlay layer being rendered}
|
||||
*/
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> an in-game overlay layer is rendered to the screen, if the corresponding
|
||||
* {@link RenderGameOverlayEvent.PreLayer} is not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class PostLayer extends Post
|
||||
{
|
||||
private final IIngameOverlay overlay;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public PostLayer(PoseStack mStack, RenderGameOverlayEvent parent, IIngameOverlay overlay)
|
||||
{
|
||||
super(mStack, parent, ElementType.LAYER);
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the in-game overlay layer being rendered}
|
||||
*/
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> a boss health bar is rendered to the screen.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the boss health bar corresponding to this event will not be rendered, and the
|
||||
* corresponding {@link RenderGameOverlayEvent.Post} is not fired. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ElementType#BOSSINFO
|
||||
*/
|
||||
public static class BossInfo extends Pre
|
||||
{
|
||||
private final LerpingBossEvent bossEvent;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private int increment;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public BossInfo(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type, LerpingBossEvent bossEvent, int x, int y, int increment)
|
||||
{
|
||||
super(mStack, parent, type);
|
||||
this.bossEvent = bossEvent;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.increment = increment;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the boss health bar currently being rendered}
|
||||
*/
|
||||
public LerpingBossEvent getBossEvent()
|
||||
{
|
||||
return bossEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X position of the boss health bar}
|
||||
*/
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position of the boss health bar}
|
||||
*/
|
||||
public int getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position increment before rendering the next boss health bar}
|
||||
*/
|
||||
public int getIncrement()
|
||||
{
|
||||
return increment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Y position increment before rendering the next boss health bar.
|
||||
*
|
||||
* @param increment the new Y position increment
|
||||
*/
|
||||
public void setIncrement(int increment)
|
||||
{
|
||||
this.increment = increment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> textual information is rendered to the debug screen.
|
||||
* This can be used to add or remove text information.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the text will not be rendered; <em>this includes the debug overlay text</em>. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ElementType#TEXT
|
||||
*/
|
||||
public static class Text extends Pre
|
||||
{
|
||||
private final ArrayList<String> left;
|
||||
private final ArrayList<String> right;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Text(PoseStack mStack, RenderGameOverlayEvent parent, ArrayList<String> left, ArrayList<String> right)
|
||||
{
|
||||
super(mStack, parent, ElementType.TEXT);
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the modifiable list of text to render on the left side}
|
||||
*/
|
||||
public ArrayList<String> getLeft()
|
||||
{
|
||||
return left;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the modifiable list of text to render on the right side}
|
||||
*/
|
||||
public ArrayList<String> getRight()
|
||||
{
|
||||
return right;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> the chat messages overlay is rendered to the screen.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the chat messages overlay will not be rendered. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ElementType#CHAT
|
||||
*/
|
||||
public static class Chat extends Pre
|
||||
{
|
||||
private int posX;
|
||||
private int posY;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Chat(PoseStack mStack, RenderGameOverlayEvent parent, int posX, int posY)
|
||||
{
|
||||
super(mStack, parent, ElementType.CHAT);
|
||||
this.setPosX(posX);
|
||||
this.setPosY(posY);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X position of the chat messages overlay}
|
||||
*/
|
||||
public int getPosX()
|
||||
{
|
||||
return posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new X position for rendering the chat messages overlay
|
||||
*
|
||||
* @param posX the new X position
|
||||
*/
|
||||
public void setPosX(int posX)
|
||||
{
|
||||
this.posX = posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position of the chat messages overlay}
|
||||
*/
|
||||
public int getPosY()
|
||||
{
|
||||
return posY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new Y position for rendering the chat messages overlay
|
||||
*
|
||||
* @param posY the new y position
|
||||
*/
|
||||
public void setPosY(int posY)
|
||||
{
|
||||
this.posY = posY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when the HUD is rendered to the screen.
|
||||
* See the two subclasses for listening to the two possible phases.
|
||||
*
|
||||
* @see Pre
|
||||
* @see Post
|
||||
*/
|
||||
public abstract class RenderGuiEvent extends Event
|
||||
{
|
||||
private final Window window;
|
||||
private final PoseStack poseStack;
|
||||
private final float partialTick;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected RenderGuiEvent(Window window, PoseStack poseStack, float partialTick)
|
||||
{
|
||||
this.window = window;
|
||||
this.poseStack = poseStack;
|
||||
this.partialTick = partialTick;
|
||||
}
|
||||
|
||||
public Window getWindow()
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> the HUD is rendered to the screen.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the overlay will not be rendered, and the corresponding {@link Post} event will
|
||||
* not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see Post
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends RenderGuiEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Pre(Window window, PoseStack poseStack, float partialTick)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the HUD is rendered to the screen, if the corresponding {@link Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends RenderGuiEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Post(Window window, PoseStack poseStack, float partialTick)
|
||||
{
|
||||
super(window, poseStack, partialTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraftforge.client.gui.overlay.NamedGuiOverlay;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when an overlay is rendered to the screen.
|
||||
* See the two subclasses for listening to the two possible phases.
|
||||
*
|
||||
* <p>An overlay that is not normally active cannot be forced to render. In such cases, this event will not fire.</p>
|
||||
*
|
||||
* @see Pre
|
||||
* @see Post
|
||||
*/
|
||||
public abstract class RenderGuiOverlayEvent extends Event
|
||||
{
|
||||
private final Window window;
|
||||
private final PoseStack poseStack;
|
||||
private final float partialTick;
|
||||
private final NamedGuiOverlay overlay;
|
||||
|
||||
@ApiStatus.Internal
|
||||
protected RenderGuiOverlayEvent(Window window, PoseStack poseStack, float partialTick, NamedGuiOverlay overlay)
|
||||
{
|
||||
this.overlay = overlay;
|
||||
this.window = window;
|
||||
this.poseStack = poseStack;
|
||||
this.partialTick = partialTick;
|
||||
}
|
||||
|
||||
public Window getWindow()
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
public NamedGuiOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> a GUI overlay is rendered to the screen.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the overlay will not be rendered, and the corresponding {@link Post} event will
|
||||
* not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see Post
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends RenderGuiOverlayEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Pre(Window window, PoseStack poseStack, float partialTick, NamedGuiOverlay overlay)
|
||||
{
|
||||
super(window, poseStack, partialTick, overlay);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> an GUI overlay is rendered to the screen, if the corresponding {@link Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends RenderGuiOverlayEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Post(Window window, PoseStack poseStack, float partialTick, NamedGuiOverlay overlay)
|
||||
{
|
||||
super(window, poseStack, partialTick, overlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,24 +6,24 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired before a hand is rendered in the first person view.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the hand will not be rendered. </p>
|
||||
* If this event is cancelled, then the hand will not be rendered.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see RenderArmEvent
|
||||
*/
|
||||
@@ -40,10 +40,7 @@ public class RenderHandEvent extends Event
|
||||
private final float equipProgress;
|
||||
private final ItemStack stack;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#renderSpecificFirstPersonHand(InteractionHand, PoseStack, MultiBufferSource, int, float, float, float, float, ItemStack)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RenderHandEvent(InteractionHand hand, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight,
|
||||
float partialTick, float interpolatedPitch,
|
||||
float swingProgress, float equipProgress, ItemStack stack)
|
||||
@@ -78,7 +75,8 @@ public class RenderHandEvent extends Event
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() {
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
@@ -87,7 +85,8 @@ public class RenderHandEvent extends Event
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight() {
|
||||
public int getPackedLight()
|
||||
{
|
||||
return packedLight;
|
||||
}
|
||||
|
||||
|
||||
+49
-32
@@ -6,26 +6,27 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired before a selection highlight is rendered.
|
||||
* See the two subclasses to listen for blocks or entities.
|
||||
*
|
||||
* @see DrawSelectionEvent.HighlightBlock
|
||||
* @see DrawSelectionEvent.HighlightEntity
|
||||
* @see Block
|
||||
* @see Entity
|
||||
*/
|
||||
@Cancelable
|
||||
public class DrawSelectionEvent extends Event
|
||||
public abstract class RenderHighlightEvent extends Event
|
||||
{
|
||||
private final LevelRenderer levelRenderer;
|
||||
private final Camera camera;
|
||||
@@ -34,11 +35,8 @@ public class DrawSelectionEvent extends Event
|
||||
private final PoseStack poseStack;
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#onDrawHighlight(LevelRenderer, Camera, HitResult, float, PoseStack, MultiBufferSource)
|
||||
*/
|
||||
public DrawSelectionEvent(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource)
|
||||
@ApiStatus.Internal
|
||||
protected RenderHighlightEvent(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource)
|
||||
{
|
||||
this.levelRenderer = levelRenderer;
|
||||
this.camera = camera;
|
||||
@@ -51,44 +49,65 @@ public class DrawSelectionEvent extends Event
|
||||
/**
|
||||
* {@return the level renderer}
|
||||
*/
|
||||
public LevelRenderer getLevelRenderer() { return levelRenderer; }
|
||||
public LevelRenderer getLevelRenderer()
|
||||
{
|
||||
return levelRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the camera information}
|
||||
*/
|
||||
public Camera getCamera() { return camera; }
|
||||
public Camera getCamera()
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the hit result which triggered the selection highlight}
|
||||
*/
|
||||
public HitResult getTarget() { return target; }
|
||||
public HitResult getTarget()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick() { return partialTick; }
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() { return multiBufferSource; }
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired before a block's selection highlight is rendered.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the selection highlight will not be rendered. </p>
|
||||
* If the event is cancelled, then the selection highlight will not be rendered.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class HighlightBlock extends DrawSelectionEvent
|
||||
public static class Block extends RenderHighlightEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public HighlightBlock(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
@ApiStatus.Internal
|
||||
public Block(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
{
|
||||
super(levelRenderer, camera, target, partialTick, poseStack, bufferSource);
|
||||
}
|
||||
@@ -104,19 +123,17 @@ public class DrawSelectionEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired before a block's selection highlight is rendered.
|
||||
* Fired before an entity's selection highlight is rendered.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class HighlightEntity extends DrawSelectionEvent
|
||||
public static class Entity extends RenderHighlightEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public HighlightEntity(LevelRenderer levelRenderer, Camera camera, EntityHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
@ApiStatus.Internal
|
||||
public Entity(LevelRenderer levelRenderer, Camera camera, EntityHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
{
|
||||
super(levelRenderer, camera, target, partialTick, poseStack, bufferSource);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired before an item stack is rendered in an item frame.
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* If the event is cancelled, then the item stack will not be rendered</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see ItemFrameRenderer
|
||||
*/
|
||||
@@ -39,9 +39,7 @@ public class RenderItemInFrameEvent extends Event
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer<?> renderItemFrame, PoseStack poseStack,
|
||||
MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
@@ -80,14 +78,16 @@ public class RenderItemInFrameEvent extends Event
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() {
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() {
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,8 @@ public class RenderItemInFrameEvent extends Event
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight() {
|
||||
public int getPackedLight()
|
||||
{
|
||||
return packedLight;
|
||||
}
|
||||
}
|
||||
@@ -6,23 +6,22 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired after all level rendering.
|
||||
* This can be used for custom rendering outside of e.g. a block entity or entity renderer.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see GameRenderer
|
||||
* @see LevelRenderer
|
||||
@@ -35,10 +34,7 @@ public class RenderLevelLastEvent extends net.minecraftforge.eventbus.api.Event
|
||||
private final Matrix4f projectionMatrix;
|
||||
private final long startNanos;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#dispatchRenderLast(LevelRenderer, PoseStack, float, Matrix4f, long)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public RenderLevelLastEvent(LevelRenderer levelRenderer, PoseStack poseStack, float partialTick, Matrix4f projectionMatrix, long startNanos)
|
||||
{
|
||||
this.levelRenderer = levelRenderer;
|
||||
|
||||
@@ -6,15 +6,16 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when a {@link LivingEntity} is rendered.
|
||||
@@ -25,7 +26,6 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
*
|
||||
* @param <T> the living entity that is being rendered
|
||||
* @param <M> the model for the living entity
|
||||
*
|
||||
* @see RenderLivingEvent.Pre
|
||||
* @see RenderLivingEvent.Post
|
||||
* @see RenderPlayerEvent
|
||||
@@ -33,7 +33,6 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
*/
|
||||
public abstract class RenderLivingEvent<T extends LivingEntity, M extends EntityModel<T>> extends Event
|
||||
{
|
||||
|
||||
private final LivingEntity entity;
|
||||
private final LivingEntityRenderer<T, M> renderer;
|
||||
private final float partialTick;
|
||||
@@ -41,11 +40,9 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderLivingEvent(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack,
|
||||
MultiBufferSource multiBufferSource, int packedLight)
|
||||
@ApiStatus.Internal
|
||||
protected RenderLivingEvent(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack,
|
||||
MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.renderer = renderer;
|
||||
@@ -58,29 +55,52 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
/**
|
||||
* @return the living entity being rendered
|
||||
*/
|
||||
public LivingEntity getEntity() { return entity; }
|
||||
public LivingEntity getEntity()
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the renderer for the living entity
|
||||
*/
|
||||
public LivingEntityRenderer<T, M> getRenderer() { return renderer; }
|
||||
public LivingEntityRenderer<T, M> getRenderer()
|
||||
{
|
||||
return renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick() { return partialTick; }
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() { return multiBufferSource; }
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of packed (sky and block) light for rendering}
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight() { return packedLight; }
|
||||
public int getPackedLight()
|
||||
{
|
||||
return packedLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> an entity is rendered.
|
||||
@@ -88,10 +108,10 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the entity will not be rendered and the corresponding
|
||||
* {@link RenderLivingEvent.Post} will not be fired. </p>
|
||||
* {@link RenderLivingEvent.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @param <T> the living entity that is being rendered
|
||||
* @param <M> the model for the living entity
|
||||
@@ -99,10 +119,9 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
@Cancelable
|
||||
public static class Pre<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Pre(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
@ApiStatus.Internal
|
||||
public Pre(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
super(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight);
|
||||
}
|
||||
}
|
||||
@@ -110,20 +129,19 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
/**
|
||||
* Fired <b>after</b> an entity is rendered, if the corresponding {@link RenderLivingEvent.Post} is not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @param <T> the living entity that was rendered
|
||||
* @param <M> the model for the living entity
|
||||
*/
|
||||
public static class Post<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Post(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
@ApiStatus.Internal
|
||||
public Post(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
super(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-9
@@ -8,18 +8,19 @@ package net.minecraftforge.client.event;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired before an entity renderer renders the nameplate of an entity.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and {@linkplain HasResult has a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and {@linkplain HasResult has a result}.</p>
|
||||
* <ul>
|
||||
* <li>{@link Result#ALLOW} - the nameplate will be forcibly rendered.</li>
|
||||
* <li>{@link Result#DEFAULT} - the vanilla logic will be used.</li>
|
||||
@@ -27,14 +28,13 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see EntityRenderer
|
||||
*/
|
||||
@Event.HasResult
|
||||
public class RenderNameplateEvent extends EntityEvent
|
||||
public class RenderNameTagEvent extends EntityEvent
|
||||
{
|
||||
|
||||
private Component nameplateContent;
|
||||
private final Component originalContent;
|
||||
private final EntityRenderer<?> entityRenderer;
|
||||
@@ -43,10 +43,8 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
private final int packedLight;
|
||||
private final float partialTick;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderNameplateEvent(Entity entity, Component content, EntityRenderer<?> entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTick)
|
||||
@ApiStatus.Internal
|
||||
public RenderNameTagEvent(Entity entity, Component content, EntityRenderer<?> entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTick)
|
||||
{
|
||||
super(entity);
|
||||
this.originalContent = content;
|
||||
@@ -8,12 +8,13 @@ package net.minecraftforge.client.event;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when a player is being rendered.
|
||||
@@ -31,10 +32,8 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight)
|
||||
@ApiStatus.Internal
|
||||
protected RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
super(player);
|
||||
this.renderer = renderer;
|
||||
@@ -47,25 +46,44 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
/**
|
||||
* {@return the player entity renderer}
|
||||
*/
|
||||
public PlayerRenderer getRenderer() { return renderer; }
|
||||
public PlayerRenderer getRenderer()
|
||||
{
|
||||
return renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick() { return partialTick; }
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() { return multiBufferSource; }
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of packed (sky and block) light for rendering}
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight() { return packedLight; }
|
||||
public int getPackedLight()
|
||||
{
|
||||
return packedLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> the player is rendered.
|
||||
@@ -73,18 +91,17 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the player will not be rendered and the corresponding
|
||||
* {@link RenderPlayerEvent.Post} will not be fired. </p>
|
||||
* {@link RenderPlayerEvent.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends RenderPlayerEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Pre(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight);
|
||||
}
|
||||
}
|
||||
@@ -92,19 +109,17 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
/**
|
||||
* Fired <b>after</b> the player is rendered, if the corresponding {@link RenderPlayerEvent.Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends RenderPlayerEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Post(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
@ApiStatus.Internal
|
||||
public Post(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,23 +5,24 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Fired during tooltip rendering.
|
||||
* See the various subclasses for listening to specific events.
|
||||
@@ -40,11 +41,8 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
protected Font font;
|
||||
protected final List<ClientTooltipComponent> components;
|
||||
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderTooltipEvent(@NotNull ItemStack itemStack, PoseStack poseStack, int x, int y, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
@ApiStatus.Internal
|
||||
protected RenderTooltipEvent(@NotNull ItemStack itemStack, PoseStack poseStack, int x, int y, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
this.poseStack = poseStack;
|
||||
@@ -64,16 +62,18 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the unmodifiable list of tooltip components}
|
||||
*
|
||||
* <p>Use {@link ItemTooltipEvent} or {@link GatherComponents} to modify tooltip contents or components. </p>
|
||||
* <p>Use {@link ItemTooltipEvent} or {@link GatherComponents} to modify tooltip contents or components.</p>
|
||||
*/
|
||||
@NotNull
|
||||
public List<ClientTooltipComponent> getComponents()
|
||||
@@ -82,7 +82,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
*{@return the X position of the tooltip box} By default, this is the mouse X position.
|
||||
* {@return the X position of the tooltip box} By default, this is the mouse X position.
|
||||
*/
|
||||
public int getX()
|
||||
{
|
||||
@@ -112,10 +112,10 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the list of components will be empty, causing the tooltip to not be rendered and
|
||||
* the corresponding {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Color} to not be fired. </p>
|
||||
* the corresponding {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Color} to not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class GatherComponents extends Event
|
||||
@@ -126,9 +126,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private final List<Either<FormattedText, TooltipComponent>> tooltipElements;
|
||||
private int maxWidth;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public GatherComponents(ItemStack itemStack, int screenWidth, int screenHeight, List<Either<FormattedText, TooltipComponent>> tooltipElements, int maxWidth)
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
@@ -203,10 +201,10 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the tooltip will not be rendered and the corresponding
|
||||
* {@link RenderTooltipEvent.Color} will not be fired. </p>
|
||||
* {@link RenderTooltipEvent.Color} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends RenderTooltipEvent
|
||||
@@ -214,9 +212,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private final int screenWidth;
|
||||
private final int screenHeight;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(@NotNull ItemStack stack, PoseStack poseStack, int x, int y, int screenWidth, int screenHeight, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
super(stack, poseStack, x, y, font, components);
|
||||
@@ -278,10 +274,10 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
* Fired when the colours for the tooltip background are determined.
|
||||
* This can be used to modify the background color and the border's gradient colors.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Color extends RenderTooltipEvent
|
||||
{
|
||||
@@ -293,9 +289,7 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private int borderStart;
|
||||
private int borderEnd;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Color(@NotNull ItemStack stack, PoseStack poseStack, int x, int y, @NotNull Font fr, int background, int borderStart, int borderEnd, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
super(stack, poseStack, x, y, fr, components);
|
||||
@@ -324,7 +318,6 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
return backgroundEnd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the new color for the tooltip background. This sets both the gradient start and end color for the
|
||||
* background to this color.
|
||||
|
||||
@@ -5,49 +5,46 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Fired on different events/actions when a {@link Screen} is active and visible.
|
||||
* See the various subclasses for listening to different events.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see ScreenEvent.InitScreenEvent
|
||||
* @see ScreenEvent.DrawScreenEvent
|
||||
* @see ScreenEvent.BackgroundDrawnEvent
|
||||
* @see ScreenEvent.MouseInputEvent
|
||||
* @see ScreenEvent.KeyboardKeyEvent
|
||||
* @see Init
|
||||
* @see Render
|
||||
* @see BackgroundRendered
|
||||
* @see MouseInput
|
||||
* @see KeyInput
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ScreenEvent extends Event
|
||||
public abstract class ScreenEvent extends Event
|
||||
{
|
||||
private final Screen screen;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public ScreenEvent(Screen screen)
|
||||
@ApiStatus.Internal
|
||||
protected ScreenEvent(Screen screen)
|
||||
{
|
||||
this.screen = Objects.requireNonNull(screen);
|
||||
}
|
||||
@@ -68,26 +65,25 @@ public class ScreenEvent extends Event
|
||||
* {@link net.minecraft.client.gui.components.Widget} and {@link net.minecraft.client.gui.narration.NarratableEntry}
|
||||
* respectively.</p>
|
||||
*
|
||||
* @see InitScreenEvent.Pre
|
||||
* @see InitScreenEvent.Post
|
||||
* @see Init.Pre
|
||||
* @see Init.Post
|
||||
*/
|
||||
public static class InitScreenEvent extends ScreenEvent
|
||||
public static abstract class Init extends ScreenEvent
|
||||
{
|
||||
private final Consumer<GuiEventListener> add;
|
||||
private final Consumer<GuiEventListener> remove;
|
||||
|
||||
private final List<GuiEventListener> listenerList;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public InitScreenEvent(Screen screen, List<GuiEventListener> listenerList, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
@ApiStatus.Internal
|
||||
protected Init(Screen screen, List<GuiEventListener> listenerList, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
super(screen);
|
||||
this.listenerList = Collections.unmodifiableList(listenerList);
|
||||
this.add = add;
|
||||
this.remove = remove;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return unmodifiable view of list of event listeners on the screen}
|
||||
*/
|
||||
@@ -121,17 +117,15 @@ public class ScreenEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the initialization method will not be called, and the widgets and children lists
|
||||
* will not be cleared. </p>
|
||||
* will not be cleared.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends InitScreenEvent
|
||||
public static class Pre extends Init
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
super(screen, list, add, remove);
|
||||
@@ -141,16 +135,14 @@ public class ScreenEvent extends Event
|
||||
/**
|
||||
* Fired <b>after</b> the screen's overridable initialization method is called.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends InitScreenEvent
|
||||
public static class Post extends Init
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove)
|
||||
{
|
||||
super(screen, list, add, remove);
|
||||
@@ -162,21 +154,18 @@ public class ScreenEvent extends Event
|
||||
* Fired when a screen is being drawn.
|
||||
* See the two subclasses for listening before and after drawing.
|
||||
*
|
||||
* @see DrawScreenEvent.Pre
|
||||
* @see DrawScreenEvent.Post
|
||||
* @see Render.Pre
|
||||
* @see Render.Post
|
||||
*/
|
||||
public static class DrawScreenEvent extends ScreenEvent
|
||||
public static abstract class Render extends ScreenEvent
|
||||
{
|
||||
private final PoseStack poseStack;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
private final float partialTick;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#drawScreen(Screen, PoseStack, int, int, float)
|
||||
*/
|
||||
public DrawScreenEvent(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
@ApiStatus.Internal
|
||||
protected Render(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
super(screen);
|
||||
this.poseStack = poseStack;
|
||||
@@ -221,17 +210,15 @@ public class ScreenEvent extends Event
|
||||
* Fired <b>before</b> the screen is drawn.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the screen will not be drawn. </p>
|
||||
* If the event is cancelled, the screen will not be drawn.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends DrawScreenEvent
|
||||
public static class Pre extends Render
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
super(screen, poseStack, mouseX, mouseY, partialTick);
|
||||
@@ -241,16 +228,14 @@ public class ScreenEvent extends Event
|
||||
/**
|
||||
* Fired <b>after</b> the screen is drawn.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends DrawScreenEvent
|
||||
public static class Post extends Render
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
super(screen, poseStack, mouseX, mouseY, partialTick);
|
||||
@@ -262,19 +247,17 @@ public class ScreenEvent extends Event
|
||||
* Fired directly after the background of the screen is drawn.
|
||||
* Can be used for drawing above the background but below the tooltips.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class BackgroundDrawnEvent extends ScreenEvent
|
||||
public static class BackgroundRendered extends ScreenEvent
|
||||
{
|
||||
private final PoseStack poseStack;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public BackgroundDrawnEvent(Screen screen, PoseStack poseStack)
|
||||
@ApiStatus.Internal
|
||||
public BackgroundRendered(Screen screen, PoseStack poseStack)
|
||||
{
|
||||
super(screen);
|
||||
this.poseStack = poseStack;
|
||||
@@ -290,29 +273,51 @@ public class ScreenEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired to determine whether to render the potion indicators in the {@link EffectRenderingInventoryScreen inventory
|
||||
* screen} in compact or classic mode.
|
||||
* 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.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable} and {@linkplain HasResult has a result}. </p>
|
||||
* <ul>
|
||||
* <li>{@link Result#ALLOW} - forcibly renders the potion indicators in <em>compact</em> mode.</li>
|
||||
* <li>{@link Result#DEFAULT} - defaults to vanilla behavior to using compact mode if the the screen width is too
|
||||
* small for classic rendering of potion indicators.</li>
|
||||
* <li>{@link Result#DENY} - forcibly renders the potion indicators in <em>classic</em> mode.</li>
|
||||
* </ul>
|
||||
* <p>This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
|
||||
* Cancelling this event will prevent vanilla rendering.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static class PotionSizeEvent extends ScreenEvent
|
||||
@Cancelable
|
||||
public static class RenderInventoryMobEffects extends ScreenEvent
|
||||
{
|
||||
/**
|
||||
* @hidden For internal use only.
|
||||
*/
|
||||
public PotionSizeEvent(Screen screen)
|
||||
private final int availableSpace;
|
||||
private boolean compact;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RenderInventoryMobEffects(Screen screen, int availableSpace, boolean compact)
|
||||
{
|
||||
super(screen);
|
||||
this.availableSpace = availableSpace;
|
||||
this.compact = compact;
|
||||
}
|
||||
|
||||
/**
|
||||
* The available space to the right of the inventory.
|
||||
*/
|
||||
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()
|
||||
{
|
||||
return compact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the effects should be rendered in compact mode (only icons, no text), or the default full size.
|
||||
*/
|
||||
public void setCompact(boolean compact)
|
||||
{
|
||||
this.compact = compact;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,20 +325,18 @@ public class ScreenEvent extends Event
|
||||
* Fired whenever an action is performed by the mouse.
|
||||
* See the various subclasses to listen for different actions.
|
||||
*
|
||||
* @see ScreenEvent.MouseClickedEvent
|
||||
* @see ScreenEvent.MouseReleasedEvent
|
||||
* @see ScreenEvent.MouseDragEvent
|
||||
* @see ScreenEvent.MouseScrollEvent
|
||||
* @see MouseButtonPressed
|
||||
* @see MouseButtonReleased
|
||||
* @see MouseDragged
|
||||
* @see MouseScrolled
|
||||
*/
|
||||
public static abstract class MouseInputEvent extends ScreenEvent
|
||||
private static abstract class MouseInput extends ScreenEvent
|
||||
{
|
||||
private final double mouseX;
|
||||
private final double mouseY;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public MouseInputEvent(Screen screen, double mouseX, double mouseY)
|
||||
@ApiStatus.Internal
|
||||
protected MouseInput(Screen screen, double mouseX, double mouseY)
|
||||
{
|
||||
super(screen);
|
||||
this.mouseX = mouseX;
|
||||
@@ -358,20 +361,18 @@ public class ScreenEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a mouse button is clicked.
|
||||
* Fired when a mouse button is pressed.
|
||||
* See the two subclasses for listening before and after the normal handling.
|
||||
*
|
||||
* @see MouseClickedEvent.Pre
|
||||
* @see MouseClickedEvent.Post
|
||||
* @see MouseButtonPressed.Pre
|
||||
* @see MouseButtonPressed.Post
|
||||
*/
|
||||
public static abstract class MouseClickedEvent extends MouseInputEvent
|
||||
public static abstract class MouseButtonPressed extends MouseInput
|
||||
{
|
||||
private final int button;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public MouseClickedEvent(Screen screen, double mouseX, double mouseY, int button)
|
||||
@ApiStatus.Internal
|
||||
public MouseButtonPressed(Screen screen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(screen, mouseX, mouseY);
|
||||
this.button = button;
|
||||
@@ -393,18 +394,15 @@ public class ScreenEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the screen's mouse click handler will be bypassed
|
||||
* and the corresponding {@link MouseClickedEvent.Post} will not be fired. </p>
|
||||
* and the corresponding {@link MouseButtonPressed.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseClickedEvent
|
||||
public static class Pre extends MouseButtonPressed
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenMouseClickedPre(Screen, double, double, int)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(screen, mouseX, mouseY, button);
|
||||
@@ -412,10 +410,10 @@ public class ScreenEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the mouse click is handled, if the corresponding {@link MouseClickedEvent.Pre} was not
|
||||
* Fired <b>after</b> the mouse click is handled, if the corresponding {@link MouseButtonPressed.Pre} was not
|
||||
* cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, {@linkplain HasResult has a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, {@linkplain HasResult has a result}.</p>
|
||||
* <ul>
|
||||
* <li>{@link Result#ALLOW} - forcibly sets the mouse click as handled</li>
|
||||
* <li>{@link Result#DEFAULT} - defaults to the return value of
|
||||
@@ -424,17 +422,14 @@ public class ScreenEvent extends Event
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static class Post extends MouseClickedEvent
|
||||
public static class Post extends MouseButtonPressed
|
||||
{
|
||||
private final boolean handled;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenMouseClickedPost(Screen, double, double, int, boolean)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled)
|
||||
{
|
||||
super(screen, mouseX, mouseY, button);
|
||||
@@ -455,17 +450,15 @@ public class ScreenEvent extends Event
|
||||
* Fired when a mouse button is released.
|
||||
* See the two subclasses for listening before and after the normal handling.
|
||||
*
|
||||
* @see MouseReleasedEvent.Pre
|
||||
* @see MouseReleasedEvent.Post
|
||||
* @see MouseButtonReleased.Pre
|
||||
* @see MouseButtonReleased.Post
|
||||
*/
|
||||
public static abstract class MouseReleasedEvent extends MouseInputEvent
|
||||
public static abstract class MouseButtonReleased extends MouseInput
|
||||
{
|
||||
private final int button;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public MouseReleasedEvent(Screen screen, double mouseX, double mouseY, int button)
|
||||
@ApiStatus.Internal
|
||||
public MouseButtonReleased(Screen screen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(screen, mouseX, mouseY);
|
||||
this.button = button;
|
||||
@@ -487,18 +480,15 @@ public class ScreenEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the screen's mouse release handler will be bypassed
|
||||
* and the corresponding {@link MouseReleasedEvent.Post} will not be fired. </p>
|
||||
* and the corresponding {@link MouseButtonReleased.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseReleasedEvent
|
||||
public static class Pre extends MouseButtonReleased
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenMouseReleasedPre(Screen, double, double, int)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button)
|
||||
{
|
||||
super(screen, mouseX, mouseY, button);
|
||||
@@ -506,10 +496,10 @@ public class ScreenEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the mouse release is handled, if the corresponding {@link MouseReleasedEvent.Pre} was
|
||||
* Fired <b>after</b> the mouse release is handled, if the corresponding {@link MouseButtonReleased.Pre} was
|
||||
* not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, {@linkplain HasResult has a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, {@linkplain HasResult has a result}.</p>
|
||||
* <ul>
|
||||
* <li>{@link Result#ALLOW} - forcibly sets the mouse release as handled</li>
|
||||
* <li>{@link Result#DEFAULT} - defaults to the return value of
|
||||
@@ -518,17 +508,14 @@ public class ScreenEvent extends Event
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static class Post extends MouseReleasedEvent
|
||||
public static class Post extends MouseButtonReleased
|
||||
{
|
||||
private final boolean handled;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenMouseReleasedPost(Screen, double, double, int, boolean)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled)
|
||||
{
|
||||
super(screen, mouseX, mouseY, button);
|
||||
@@ -549,19 +536,17 @@ public class ScreenEvent extends Event
|
||||
* Fired when the mouse was dragged while a button is being held down.
|
||||
* See the two subclasses for listening before and after the normal handling.
|
||||
*
|
||||
* @see MouseDragEvent.Pre
|
||||
* @see MouseDragEvent.Post
|
||||
* @see MouseDragged.Pre
|
||||
* @see MouseDragged.Post
|
||||
*/
|
||||
public static abstract class MouseDragEvent extends MouseInputEvent
|
||||
public static abstract class MouseDragged extends MouseInput
|
||||
{
|
||||
private final int mouseButton;
|
||||
private final double dragX;
|
||||
private final double dragY;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public MouseDragEvent(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
@ApiStatus.Internal
|
||||
public MouseDragged(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
super(screen, mouseX, mouseY);
|
||||
this.mouseButton = mouseButton;
|
||||
@@ -601,18 +586,15 @@ public class ScreenEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the screen's mouse drag handler will be bypassed
|
||||
* and the corresponding {@link MouseDragEvent.Post} will not be fired. </p>
|
||||
* and the corresponding {@link MouseDragged.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseDragEvent
|
||||
public static class Pre extends MouseDragged
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenMouseDragPre(Screen, double, double, int, double, double)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
@@ -621,21 +603,17 @@ public class ScreenEvent extends Event
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the mouse drag is handled, if not handled by the screen
|
||||
* and the corresponding {@link MouseDragEvent.Pre} is not cancelled.
|
||||
* and the corresponding {@link MouseDragged.Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the mouse drag will be set as handled. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the mouse drag will be set as handled.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends MouseDragEvent
|
||||
public static class Post extends MouseDragged
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenMouseDragPost(Screen, double, double, int, double, double)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
||||
{
|
||||
super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
@@ -647,17 +625,15 @@ public class ScreenEvent extends Event
|
||||
* Fired when the mouse was dragged while a button is being held down.
|
||||
* See the two subclasses for listening before and after the normal handling.
|
||||
*
|
||||
* @see MouseScrollEvent.Pre
|
||||
* @see MouseScrollEvent.Post
|
||||
* @see MouseScrolled.Pre
|
||||
* @see MouseScrolled.Post
|
||||
*/
|
||||
public static abstract class MouseScrollEvent extends MouseInputEvent
|
||||
public static abstract class MouseScrolled extends MouseInput
|
||||
{
|
||||
private final double scrollDelta;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public MouseScrollEvent(Screen screen, double mouseX, double mouseY, double scrollDelta)
|
||||
@ApiStatus.Internal
|
||||
public MouseScrolled(Screen screen, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
super(screen, mouseX, mouseY);
|
||||
this.scrollDelta = scrollDelta;
|
||||
@@ -676,18 +652,15 @@ public class ScreenEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the screen's mouse scroll handler will be bypassed
|
||||
* and the corresponding {@link MouseScrollEvent.Post} will not be fired. </p>
|
||||
* and the corresponding {@link MouseScrolled.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseScrollEvent
|
||||
public static class Pre extends MouseScrolled
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenMouseScrollPre(MouseHandler, Screen, double)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
super(screen, mouseX, mouseY, scrollDelta);
|
||||
@@ -696,21 +669,17 @@ public class ScreenEvent extends Event
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the mouse scroll is handled, if not handled by the screen
|
||||
* and the corresponding {@link MouseScrollEvent.Pre} is not cancelled.
|
||||
* and the corresponding {@link MouseScrolled.Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the mouse scroll will be set as handled. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the mouse scroll will be set as handled.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends MouseScrollEvent
|
||||
public static class Post extends MouseScrolled
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenMouseScrollPost(MouseHandler, Screen, double)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, double scrollDelta)
|
||||
{
|
||||
super(screen, mouseX, mouseY, scrollDelta);
|
||||
@@ -720,23 +689,21 @@ public class ScreenEvent extends Event
|
||||
|
||||
/**
|
||||
* <p>Fired whenever a keyboard key is pressed or released.
|
||||
* See the various subclasses to listen for key pressing or releasing. </p>
|
||||
* See the various subclasses to listen for key pressing or releasing.</p>
|
||||
*
|
||||
* @see ScreenEvent.KeyboardKeyPressedEvent
|
||||
* @see ScreenEvent.KeyboardKeyReleasedEvent
|
||||
* @see KeyPressed
|
||||
* @see KeyReleased
|
||||
* @see InputConstants
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_key" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public static abstract class KeyboardKeyEvent extends ScreenEvent
|
||||
private static abstract class KeyInput extends ScreenEvent
|
||||
{
|
||||
private final int keyCode;
|
||||
private final int scanCode;
|
||||
private final int modifiers;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public KeyboardKeyEvent(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
@ApiStatus.Internal
|
||||
protected KeyInput(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(screen);
|
||||
this.keyCode = keyCode;
|
||||
@@ -758,7 +725,7 @@ public class ScreenEvent extends Event
|
||||
|
||||
/**
|
||||
* {@return the platform-specific scan code}
|
||||
*
|
||||
* <p>
|
||||
* The scan code is unique for every key, regardless of whether it has a key code.
|
||||
* Scan codes are platform-specific but consistent over time, so keys will have different scan codes depending
|
||||
* on the platform but they are safe to save to disk as custom key bindings.
|
||||
@@ -791,17 +758,15 @@ public class ScreenEvent extends Event
|
||||
* Fired when a keyboard key is pressed.
|
||||
* See the two subclasses for listening before and after the normal handling.
|
||||
*
|
||||
* @see KeyboardKeyPressedEvent.Pre
|
||||
* @see KeyboardKeyPressedEvent.Post
|
||||
* @see KeyPressed.Pre
|
||||
* @see KeyPressed.Post
|
||||
*/
|
||||
public static abstract class KeyboardKeyPressedEvent extends KeyboardKeyEvent
|
||||
public static abstract class KeyPressed extends KeyInput
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public KeyboardKeyPressedEvent(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
@ApiStatus.Internal
|
||||
public KeyPressed(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -809,18 +774,15 @@ public class ScreenEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable} and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the screen's key press handler will be bypassed
|
||||
* and the corresponding {@link KeyboardKeyPressedEvent.Post} will not be fired. </p>
|
||||
* and the corresponding {@link KeyPressed.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends KeyboardKeyPressedEvent
|
||||
public static class Pre extends KeyPressed
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenKeyPressedPre(Screen, int, int, int)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -829,21 +791,18 @@ public class ScreenEvent extends Event
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the key press is handled, if not handled by the screen
|
||||
* and the corresponding {@link KeyboardKeyPressedEvent.Pre} is not cancelled.
|
||||
* and the corresponding {@link KeyPressed.Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the key press will be set as handled. </p>
|
||||
* If the event is cancelled, the key press will be set as handled.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends KeyboardKeyPressedEvent
|
||||
public static class Post extends KeyPressed
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenKeyPressedPost(Screen, int, int, int)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -855,15 +814,13 @@ public class ScreenEvent extends Event
|
||||
* Fired when a keyboard key is released.
|
||||
* See the two subclasses for listening before and after the normal handling.
|
||||
*
|
||||
* @see KeyboardKeyReleasedEvent.Pre
|
||||
* @see KeyboardKeyReleasedEvent.Post
|
||||
* @see KeyReleased.Pre
|
||||
* @see KeyReleased.Post
|
||||
*/
|
||||
public static abstract class KeyboardKeyReleasedEvent extends KeyboardKeyEvent
|
||||
public static abstract class KeyReleased extends KeyInput
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public KeyboardKeyReleasedEvent(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
@ApiStatus.Internal
|
||||
public KeyReleased(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
}
|
||||
@@ -873,18 +830,15 @@ public class ScreenEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the screen's key release handler will be bypassed
|
||||
* and the corresponding {@link KeyboardKeyReleasedEvent.Post} will not be fired. </p>
|
||||
* and the corresponding {@link KeyReleased.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends KeyboardKeyReleasedEvent
|
||||
public static class Pre extends KeyReleased
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenKeyReleasedPre(Screen, int, int, int)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -893,21 +847,18 @@ public class ScreenEvent extends Event
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the key release is handled, if not handled by the screen
|
||||
* and the corresponding {@link KeyboardKeyReleasedEvent.Pre} is not cancelled.
|
||||
* and the corresponding {@link KeyReleased.Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the key release will be set as handled. </p>
|
||||
* If the event is cancelled, the key release will be set as handled.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends KeyboardKeyReleasedEvent
|
||||
public static class Post extends KeyReleased
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenKeyReleasedPost(Screen, int, int, int)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers)
|
||||
{
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -919,19 +870,17 @@ public class ScreenEvent extends Event
|
||||
* Fired when a keyboard key corresponding to a character is typed.
|
||||
* See the two subclasses for listening before and after the normal handling.
|
||||
*
|
||||
* @see KeyboardCharTypedEvent.Pre
|
||||
* @see KeyboardCharTypedEvent.Post
|
||||
* @see CharacterTyped.Pre
|
||||
* @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 KeyboardCharTypedEvent extends ScreenEvent
|
||||
public static class CharacterTyped extends ScreenEvent
|
||||
{
|
||||
private final char codePoint;
|
||||
private final int modifiers;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public KeyboardCharTypedEvent(Screen screen, char codePoint, int modifiers)
|
||||
@ApiStatus.Internal
|
||||
public CharacterTyped(Screen screen, char codePoint, int modifiers)
|
||||
{
|
||||
super(screen);
|
||||
this.codePoint = codePoint;
|
||||
@@ -967,18 +916,15 @@ public class ScreenEvent extends Event
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the screen's character input handler will be bypassed
|
||||
* and the corresponding {@link KeyboardCharTypedEvent.Post} will not be fired. </p>
|
||||
* and the corresponding {@link CharacterTyped.Post} will not be fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends KeyboardCharTypedEvent
|
||||
public static class Pre extends CharacterTyped
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenCharTypedPre(Screen, char, int)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, char codePoint, int modifiers)
|
||||
{
|
||||
super(screen, codePoint, modifiers);
|
||||
@@ -987,25 +933,95 @@ public class ScreenEvent extends Event
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the character input is handled, if not handled by the screen
|
||||
* and the corresponding {@link KeyboardCharTypedEvent.Pre} is not cancelled.
|
||||
* and the corresponding {@link CharacterTyped.Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the character input will be set as handled. </p>
|
||||
* If the event is cancelled, the character input will be set as handled.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends KeyboardCharTypedEvent
|
||||
public static class Post extends CharacterTyped
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onScreenCharTypedPost(Screen, char, int)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, char codePoint, int modifiers)
|
||||
{
|
||||
super(screen, codePoint, modifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired before any {@link Screen} is opened, to allow changing it or preventing it from being opened.
|
||||
* All screen layers on the screen are closed before this event is fired.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the {@code Screen} shall be prevented from opening and any previous screen
|
||||
* will remain open. However, cancelling this event will not prevent the closing of screen layers which happened before
|
||||
* this event fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Opening extends ScreenEvent
|
||||
{
|
||||
@Nullable
|
||||
private final Screen currentScreen;
|
||||
private Screen newScreen;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Opening(@Nullable Screen currentScreen, Screen screen)
|
||||
{
|
||||
super(screen);
|
||||
this.currentScreen = currentScreen;
|
||||
this.newScreen = screen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently open screen at the time of the event being fired.
|
||||
* <p>
|
||||
* May be null if no screen was open.
|
||||
*/
|
||||
@Nullable
|
||||
public Screen getCurrentScreen()
|
||||
{
|
||||
return currentScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The screen that will be opened if the event is not cancelled. May be null.
|
||||
*/
|
||||
@Nullable
|
||||
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)
|
||||
{
|
||||
this.newScreen = newScreen;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired before a {@link Screen} is closed.
|
||||
* All screen layers on the screen are closed before this event is fired.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Closing extends ScreenEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Closing(Screen screen)
|
||||
{
|
||||
super(screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired before any {@link Screen} will be opened, to allow changing or preventing it from being opened. All screen
|
||||
* layers on the screen are closed before this event is fired.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the {@code Screen} shall be prevented from opening and any previous screen
|
||||
* will remain open. However, cancelling this event will not prevent the closing of screen layers which happened before
|
||||
* this event fired.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
@Cancelable
|
||||
public class ScreenOpenEvent extends Event
|
||||
{
|
||||
private Screen screen;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public ScreenOpenEvent(Screen screen)
|
||||
{
|
||||
this.setScreen(screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the screen that will be opened, if the event is not cancelled}
|
||||
*/
|
||||
public Screen getScreen()
|
||||
{
|
||||
return screen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new screen to be opened, if the event is not cancelled.
|
||||
*
|
||||
* @param screen the new screen
|
||||
*/
|
||||
public void setScreen(Screen screen)
|
||||
{
|
||||
this.screen = screen;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -24,14 +25,13 @@ import java.io.IOException;
|
||||
* to the player's chat.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see Screenshot
|
||||
*/
|
||||
@Cancelable
|
||||
public class ScreenshotEvent extends Event
|
||||
{
|
||||
|
||||
public static final Component DEFAULT_CANCEL_REASON = Component.literal("Screenshot canceled");
|
||||
|
||||
private final NativeImage image;
|
||||
@@ -39,17 +39,17 @@ public class ScreenshotEvent extends Event
|
||||
|
||||
private Component resultMessage = null;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#onScreenshot(NativeImage, File)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public ScreenshotEvent(NativeImage image, File screenshotFile)
|
||||
{
|
||||
this.image = image;
|
||||
this.screenshotFile = screenshotFile;
|
||||
try {
|
||||
try
|
||||
{
|
||||
this.screenshotFile = screenshotFile.getCanonicalFile(); // FORGE: Fix errors on Windows with paths that include \.\
|
||||
} catch (IOException ignored) {}
|
||||
} catch (IOException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,5 +109,4 @@ public class ScreenshotEvent extends Event
|
||||
{
|
||||
return getResultMessage() != null ? getResultMessage() : DEFAULT_CANCEL_REASON;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,18 +5,17 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Fired before and after a texture atlas stitched together.
|
||||
* See the two subclasses to listen for before and after stitching.
|
||||
@@ -29,9 +28,7 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final TextureAtlas atlas;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public TextureStitchEvent(TextureAtlas atlas)
|
||||
{
|
||||
this.atlas = atlas;
|
||||
@@ -47,21 +44,18 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
|
||||
/**
|
||||
* <p>Fired <b>before</b> a texture atlas is stitched together.
|
||||
* This can be used to add custom sprites to be stitched into the atlas. </p>
|
||||
* This can be used to add custom sprites to be stitched into the atlas.</p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Pre extends TextureStitchEvent
|
||||
{
|
||||
private final Set<ResourceLocation> sprites;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onTextureStitchedPre(TextureAtlas, Set)
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Pre(TextureAtlas map, Set<ResourceLocation> sprites)
|
||||
{
|
||||
super(map);
|
||||
@@ -76,7 +70,8 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
*
|
||||
* @param sprite the location of the sprite
|
||||
*/
|
||||
public boolean addSprite(ResourceLocation sprite) {
|
||||
public boolean addSprite(ResourceLocation sprite)
|
||||
{
|
||||
return this.sprites.add(sprite);
|
||||
}
|
||||
}
|
||||
@@ -84,17 +79,17 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
/**
|
||||
* Fired <b>after</b> a texture atlas is stitched together and all textures therein has been loaded.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends TextureStitchEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onTextureStitchedPost(TextureAtlas)
|
||||
*/
|
||||
public Post(TextureAtlas map){ super(map); }
|
||||
@ApiStatus.Internal
|
||||
public Post(TextureAtlas map)
|
||||
{
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
-64
@@ -5,18 +5,16 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.mojang.blaze3d.shaders.FogShape;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
import com.mojang.blaze3d.shaders.FogShape;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired for hooking into the entity view rendering in {@link GameRenderer}.
|
||||
@@ -24,23 +22,21 @@ import com.mojang.blaze3d.shaders.FogShape;
|
||||
* See the various subclasses for listening to different features.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see EntityViewRenderEvent.RenderFogEvent
|
||||
* @see EntityViewRenderEvent.FogColors
|
||||
* @see EntityViewRenderEvent.CameraSetup
|
||||
* @see EntityViewRenderEvent.FieldOfView
|
||||
* @see RenderFog
|
||||
* @see ComputeFogColor
|
||||
* @see ComputeCameraAngles
|
||||
* @see ComputeFov
|
||||
*/
|
||||
public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event
|
||||
public abstract class ViewportEvent extends Event
|
||||
{
|
||||
private final GameRenderer renderer;
|
||||
private final Camera camera;
|
||||
private final double partialTick;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public EntityViewRenderEvent(GameRenderer renderer, Camera camera, double partialTick)
|
||||
@ApiStatus.Internal
|
||||
public ViewportEvent(GameRenderer renderer, Camera camera, double partialTick)
|
||||
{
|
||||
this.renderer = renderer;
|
||||
this.camera = camera;
|
||||
@@ -72,28 +68,24 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired for customizing the <b>rendering</b> of the fog visible to the player. The plane distances are based on
|
||||
* the player's render distance.
|
||||
* Fired for <b>rendering</b> custom fog. The plane distances are based on the player's render distance.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and {@linkplain HasResult has a result}. <br/>
|
||||
* The event must be cancelled for any changes to the plane distances to take effect.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RenderFogEvent extends EntityViewRenderEvent
|
||||
public static class RenderFog extends ViewportEvent
|
||||
{
|
||||
private final FogType type;
|
||||
private float farPlaneDistance;
|
||||
private float nearPlaneDistance;
|
||||
private FogShape fogShape;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onFogRender(FogType, Camera, float, float, float, FogShape)
|
||||
*/
|
||||
public RenderFogEvent(FogType type, Camera camera, float partialTicks, float nearPlaneDistance, float farPlaneDistance, FogShape fogShape)
|
||||
@ApiStatus.Internal
|
||||
public RenderFog(FogType type, Camera camera, float partialTicks, float nearPlaneDistance, float farPlaneDistance, FogShape fogShape)
|
||||
{
|
||||
super(Minecraft.getInstance().gameRenderer, camera, partialTicks);
|
||||
this.type = type;
|
||||
@@ -190,22 +182,19 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
/**
|
||||
* Fired for customizing the <b>color</b> of the fog visible to the player.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class FogColors extends EntityViewRenderEvent
|
||||
public static class ComputeFogColor extends ViewportEvent
|
||||
{
|
||||
private float red;
|
||||
private float green;
|
||||
private float blue;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see FogRenderer#setupColor(Camera, float, ClientLevel, int, float)
|
||||
*/
|
||||
public FogColors(Camera camera, float partialTicks, float red, float green, float blue)
|
||||
@ApiStatus.Internal
|
||||
public ComputeFogColor(Camera camera, float partialTicks, float red, float green, float blue)
|
||||
{
|
||||
super(Minecraft.getInstance().gameRenderer, camera, partialTicks);
|
||||
this.setRed(red);
|
||||
@@ -216,55 +205,75 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
/**
|
||||
* {@return the red color value of the fog}
|
||||
*/
|
||||
public float getRed() { return red; }
|
||||
public float getRed()
|
||||
{
|
||||
return red;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new red color value of the fog.
|
||||
*
|
||||
* @param red the new red color value
|
||||
*/
|
||||
public void setRed(float red) { this.red = red; }
|
||||
public void setRed(float red)
|
||||
{
|
||||
this.red = red;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the green color value of the fog}
|
||||
*/
|
||||
public float getGreen() { return green; }
|
||||
public float getGreen()
|
||||
{
|
||||
return green;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new green color value of the fog.
|
||||
*
|
||||
* @param green the new blue color value
|
||||
*/
|
||||
public void setGreen(float green) { this.green = green; }
|
||||
public void setGreen(float green)
|
||||
{
|
||||
this.green = green;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the blue color value of the fog}
|
||||
*/
|
||||
public float getBlue() { return blue; }
|
||||
public float getBlue()
|
||||
{
|
||||
return blue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new blue color value of the fog.
|
||||
*
|
||||
* @param blue the new blue color value
|
||||
*/
|
||||
public void setBlue(float blue) { this.blue = blue; }
|
||||
public void setBlue(float blue)
|
||||
{
|
||||
this.blue = blue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired to allow altering the angles of the player's camera.
|
||||
* This can be used to alter the player's view for different effects, such as applying roll.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class CameraSetup extends EntityViewRenderEvent
|
||||
public static class ComputeCameraAngles extends ViewportEvent
|
||||
{
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
private float roll;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onCameraSetup(GameRenderer, Camera, float)
|
||||
*/
|
||||
public CameraSetup(GameRenderer renderer, Camera camera, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
@ApiStatus.Internal
|
||||
public ComputeCameraAngles(GameRenderer renderer, Camera camera, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
{
|
||||
super(renderer, camera, renderPartialTicks);
|
||||
this.setYaw(yaw);
|
||||
@@ -275,55 +284,76 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
/**
|
||||
* {@return the yaw of the player's camera}
|
||||
*/
|
||||
public float getYaw() { return yaw; }
|
||||
public float getYaw()
|
||||
{
|
||||
return yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the yaw of the player's camera.
|
||||
*
|
||||
* @param yaw the new yaw
|
||||
*/
|
||||
public void setYaw(float yaw) { this.yaw = yaw; }
|
||||
public void setYaw(float yaw)
|
||||
{
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pitch of the player's camera}
|
||||
*/
|
||||
public float getPitch() { return pitch; }
|
||||
public float getPitch()
|
||||
{
|
||||
return pitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pitch of the player's camera.
|
||||
*
|
||||
* @param pitch the new pitch
|
||||
*/
|
||||
public void setPitch(float pitch) { this.pitch = pitch; }
|
||||
public void setPitch(float pitch)
|
||||
{
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the roll of the player's camera}
|
||||
*/
|
||||
public float getRoll() { return roll; }
|
||||
public float getRoll()
|
||||
{
|
||||
return roll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the roll of the player's camera.
|
||||
*
|
||||
* @param roll the new roll
|
||||
*/
|
||||
public void setRoll(float roll) { this.roll = roll; }
|
||||
public void setRoll(float roll)
|
||||
{
|
||||
this.roll = roll;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired for altering the raw field of view (FOV).
|
||||
* This is after the FOV settings are applied, and before modifiers such as the Nausea effect.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see FOVModifierEvent
|
||||
* @see ComputeFovModifierEvent
|
||||
*/
|
||||
public static class FieldOfView extends EntityViewRenderEvent
|
||||
public static class ComputeFov extends ViewportEvent
|
||||
{
|
||||
private double fov;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#getFieldOfView(GameRenderer, Camera, double, double)
|
||||
*/
|
||||
public FieldOfView(GameRenderer renderer, Camera camera, double renderPartialTicks, double fov) {
|
||||
@ApiStatus.Internal
|
||||
public ComputeFov(GameRenderer renderer, Camera camera, double renderPartialTicks, double fov)
|
||||
{
|
||||
super(renderer, camera, renderPartialTicks);
|
||||
this.setFOV(fov);
|
||||
}
|
||||
@@ -331,7 +361,8 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
/**
|
||||
* {@return the raw field of view value}
|
||||
*/
|
||||
public double getFOV() {
|
||||
public double getFOV()
|
||||
{
|
||||
return fov;
|
||||
}
|
||||
|
||||
@@ -340,7 +371,8 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
*
|
||||
* @param fov the new FOV value
|
||||
*/
|
||||
public void setFOV(double fov) {
|
||||
public void setFOV(double fov)
|
||||
{
|
||||
this.fov = fov;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -18,10 +19,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
* others). This can be used to change or prevent (by passing {@code null)} a sound from being played through
|
||||
* {@link #setSound(SoundInstance)}).
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see PlaySoundSourceEvent
|
||||
* @see PlayStreamingSourceEvent
|
||||
@@ -33,9 +34,7 @@ public class PlaySoundEvent extends SoundEvent
|
||||
@Nullable
|
||||
private SoundInstance sound;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public PlaySoundEvent(SoundEngine manager, SoundInstance sound)
|
||||
{
|
||||
super(manager);
|
||||
|
||||
@@ -5,31 +5,30 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when a <em>non-streaming</em> sound is being played. A non-streaming sound is loaded fully into memory
|
||||
* in a buffer before being played, and used for most sounds of short length such as sound effects for clicking
|
||||
* buttons.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public class PlaySoundSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public PlaySoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
super(engine, sound, channel);
|
||||
|
||||
@@ -5,31 +5,30 @@
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when a <em>streaming</em> sound is being played. A streaming sound is streamed directly from its source
|
||||
* (such as a file), and used for sounds of long length which are unsuitable to keep fully loaded in-memory in a buffer
|
||||
* (as is done for regular non-streaming sounds), such as background music or music discs.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public class PlayStreamingSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public PlayStreamingSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
super(engine, sound, channel);
|
||||
|
||||
@@ -10,21 +10,20 @@ import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Fired when the {@link SoundEngine} is constructed or (re)loaded, such as during game initialization or when the sound
|
||||
* output device is changed.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class SoundEngineLoadEvent extends SoundEvent implements IModBusEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public SoundEngineLoadEvent(SoundEngine manager)
|
||||
{
|
||||
super(manager);
|
||||
|
||||
@@ -11,25 +11,24 @@ import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Superclass for sound related events.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see SoundSourceEvent
|
||||
* @see PlaySoundEvent
|
||||
* @see SoundEngineLoadEvent
|
||||
*/
|
||||
public class SoundEvent extends Event
|
||||
public abstract class SoundEvent extends Event
|
||||
{
|
||||
private final SoundEngine engine;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public SoundEvent(SoundEngine engine)
|
||||
@ApiStatus.Internal
|
||||
protected SoundEvent(SoundEngine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
}
|
||||
@@ -46,21 +45,19 @@ public class SoundEvent extends Event
|
||||
* Superclass for when a sound has started to play on an audio channel.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*
|
||||
* @see PlaySoundSourceEvent
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public static class SoundSourceEvent extends SoundEvent
|
||||
public static abstract class SoundSourceEvent extends SoundEvent
|
||||
{
|
||||
private final SoundInstance sound;
|
||||
private final Channel channel;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public SoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
@ApiStatus.Internal
|
||||
protected SoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
super(engine);
|
||||
this.name = sound.getLocation().getPath();
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ForgeItemBlockRenderTypes
|
||||
{
|
||||
private static final Predicate<RenderType> SOLID_PREDICATE = type -> type == RenderType.solid();
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
private static final Map<Holder.Reference<Block>, Predicate<RenderType>> blockRenderChecks = createMap();
|
||||
private static final Map<Holder.Reference<Fluid>, Predicate<RenderType>> fluidRenderChecks = createMap();
|
||||
|
||||
@Nullable
|
||||
private static volatile Map<Holder.Reference<Block>, Predicate<RenderType>> blockRenderChecksReadOnly = null;
|
||||
@Nullable
|
||||
private static volatile Map<Holder.Reference<Fluid>, Predicate<RenderType>> fluidRenderChecksReadOnly = null;
|
||||
|
||||
public static void setRenderLayer(Block block, Predicate<RenderType> predicate)
|
||||
{
|
||||
Objects.requireNonNull(predicate);
|
||||
synchronized (LOCK)
|
||||
{
|
||||
blockRenderChecks.put(ForgeRegistries.BLOCKS.getDelegateOrThrow(block), predicate);
|
||||
blockRenderChecksReadOnly = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setRenderLayer(Fluid fluid, Predicate<RenderType> predicate)
|
||||
{
|
||||
Objects.requireNonNull(predicate);
|
||||
synchronized (LOCK)
|
||||
{
|
||||
fluidRenderChecks.put(ForgeRegistries.FLUIDS.getDelegateOrThrow(fluid), predicate);
|
||||
fluidRenderChecksReadOnly = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected static Map<Holder.Reference<Block>, Predicate<RenderType>> getBlockLayerPredicates()
|
||||
{
|
||||
Map<Holder.Reference<Block>, Predicate<RenderType>> map = blockRenderChecksReadOnly;
|
||||
if (map == null)
|
||||
{
|
||||
synchronized (LOCK)
|
||||
{
|
||||
blockRenderChecksReadOnly = map = copy(blockRenderChecks);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
protected static Map<Holder.Reference<Fluid>, Predicate<RenderType>> getFluidLayerPredicates()
|
||||
{
|
||||
Map<Holder.Reference<Fluid>, Predicate<RenderType>> map = fluidRenderChecksReadOnly;
|
||||
if (map == null)
|
||||
{
|
||||
synchronized (LOCK)
|
||||
{
|
||||
fluidRenderChecksReadOnly = map = copy(fluidRenderChecks);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static <T> Map<Holder.Reference<T>, Predicate<RenderType>> copy(Map<Holder.Reference<T>, Predicate<RenderType>> map)
|
||||
{
|
||||
var newMap = new Object2ObjectOpenHashMap<>(map);
|
||||
newMap.defaultReturnValue(SOLID_PREDICATE);
|
||||
return newMap;
|
||||
}
|
||||
|
||||
private static <T> Map<Holder.Reference<T>, Predicate<RenderType>> createMap()
|
||||
{
|
||||
Object2ObjectMap<Holder.Reference<T>, Predicate<RenderType>> map = new Object2ObjectOpenHashMap<>(
|
||||
Object2ObjectOpenHashMap.DEFAULT_INITIAL_SIZE, .75F
|
||||
);
|
||||
map.defaultReturnValue(SOLID_PREDICATE);
|
||||
return map;
|
||||
}
|
||||
|
||||
protected static void initFromVanillaMaps(Map<Block, RenderType> typeByBlock, Map<Fluid, RenderType> typeByFluid)
|
||||
{
|
||||
for (Map.Entry<Block, RenderType> entry : typeByBlock.entrySet())
|
||||
{
|
||||
RenderType type = entry.getValue();
|
||||
blockRenderChecks.put(ForgeRegistries.BLOCKS.getDelegateOrThrow(entry.getKey()), t -> t == type);
|
||||
}
|
||||
|
||||
for (Map.Entry<Fluid, RenderType> entry : typeByFluid.entrySet())
|
||||
{
|
||||
RenderType type = entry.getValue();
|
||||
fluidRenderChecks.put(ForgeRegistries.FLUIDS.getDelegateOrThrow(entry.getKey()), t -> t == type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,28 +5,26 @@
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.ChunkRenderTypeSet;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link IForgeBakedModel}.
|
||||
*/
|
||||
@@ -37,51 +35,76 @@ public interface IForgeBakedModel
|
||||
return (BakedModel) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A null {@link RenderType} is used for the breaking overlay as well as non-standard rendering, so models should return all their quads.
|
||||
*/
|
||||
@NotNull
|
||||
default List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull IModelData extraData)
|
||||
default List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType)
|
||||
{
|
||||
return self().getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
default boolean useAmbientOcclusion(BlockState state) { return self().useAmbientOcclusion(); }
|
||||
|
||||
/**
|
||||
* Override to tell the new model loader that it shouldn't wrap this model
|
||||
*/
|
||||
default boolean doesHandlePerspectives() { return false; }
|
||||
|
||||
/*
|
||||
* Returns the pair of the model for the given perspective, and the matrix that
|
||||
* should be applied to the GL state before rendering it (matrix may be null).
|
||||
*/
|
||||
default BakedModel handlePerspective(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack)
|
||||
default boolean useAmbientOcclusion(BlockState state)
|
||||
{
|
||||
return net.minecraftforge.client.ForgeHooksClient.handlePerspective(self(), cameraTransformType, poseStack);
|
||||
return self().useAmbientOcclusion();
|
||||
}
|
||||
|
||||
default @NotNull IModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull IModelData modelData)
|
||||
/**
|
||||
* Applies a transform for the given {@link ItemTransforms.TransformType} and {@code applyLeftHandTransform}, and
|
||||
* returns the model to be rendered.
|
||||
*/
|
||||
default BakedModel applyTransform(ItemTransforms.TransformType transformType, PoseStack poseStack, boolean applyLeftHandTransform)
|
||||
{
|
||||
self().getTransforms().getTransform(transformType).apply(applyLeftHandTransform, poseStack);
|
||||
return self();
|
||||
}
|
||||
|
||||
default @NotNull ModelData getModelData(@NotNull BlockAndTintGetter level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ModelData modelData)
|
||||
{
|
||||
return modelData;
|
||||
}
|
||||
|
||||
default TextureAtlasSprite getParticleIcon(@NotNull IModelData data)
|
||||
default TextureAtlasSprite getParticleIcon(@NotNull ModelData data)
|
||||
{
|
||||
return self().getParticleIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to true, to tell forge to call the getLayerModels method below.
|
||||
* Gets the set of {@link RenderType render types} to use when drawing this block in the level.
|
||||
* Supported types are those returned by {@link RenderType#chunkBufferLayers()}.
|
||||
* <p>
|
||||
* By default, defers query to {@link ItemBlockRenderTypes}.
|
||||
*/
|
||||
default boolean isLayered()
|
||||
default ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data)
|
||||
{
|
||||
return false;
|
||||
return ItemBlockRenderTypes.getRenderLayers(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* If {@see isLayered()} returns true, this is called to get the list of layers to draw.
|
||||
* Gets an ordered list of {@link RenderType render types} to use when drawing this item.
|
||||
* All render types using the {@link com.mojang.blaze3d.vertex.DefaultVertexFormat#NEW_ENTITY} format are supported.
|
||||
* <p>
|
||||
* This method will only be called on the models returned by {@link #getRenderPasses(ItemStack, boolean)}.
|
||||
* <p>
|
||||
* By default, defers query to {@link ItemBlockRenderTypes}.
|
||||
*
|
||||
* @see #getRenderPasses(ItemStack, boolean)
|
||||
*/
|
||||
default List<Pair<BakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous)
|
||||
default List<RenderType> getRenderTypes(ItemStack itemStack, boolean fabulous)
|
||||
{
|
||||
return Collections.singletonList(Pair.of(self(), ItemBlockRenderTypes.getRenderType(itemStack, fabulous)));
|
||||
return List.of(ItemBlockRenderTypes.getRenderType(itemStack, fabulous));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an ordered list of baked models used to render this model as an item.
|
||||
* Each of those models' render types will be queried via {@link #getRenderTypes(ItemStack, boolean)}.
|
||||
* <p>
|
||||
* By default, returns the model itself.
|
||||
*
|
||||
* @see #getRenderTypes(ItemStack, boolean)
|
||||
*/
|
||||
default List<BakedModel> getRenderPasses(ItemStack itemStack, boolean fabulous)
|
||||
{
|
||||
return List.of(self());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link BlockAndTintGetter}.
|
||||
*/
|
||||
public interface IForgeBlockAndTintGetter
|
||||
{
|
||||
private BlockAndTintGetter self()
|
||||
{
|
||||
return (BlockAndTintGetter) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the shade for a given normal.
|
||||
* Alternate version of the vanilla method taking in a {@link Direction}.
|
||||
*/
|
||||
default float getShade(float normalX, float normalY, float normalZ, boolean shade)
|
||||
{
|
||||
return self().getShade(Direction.getNearest(normalX, normalY, normalZ), shade);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.DimensionSpecialEffects;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link DimensionSpecialEffects}.
|
||||
*/
|
||||
public interface IForgeDimensionSpecialEffects
|
||||
{
|
||||
private DimensionSpecialEffects self()
|
||||
{
|
||||
return (DimensionSpecialEffects) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the clouds of this dimension.
|
||||
*
|
||||
* @return true to prevent vanilla cloud rendering
|
||||
*/
|
||||
default boolean renderClouds(ClientLevel level, int ticks, float partialTick, PoseStack poseStack, double camX, double camY, double camZ, Matrix4f projectionMatrix)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the sky of this dimension.
|
||||
*
|
||||
* @return true to prevent vanilla sky rendering
|
||||
*/
|
||||
default boolean renderSky(ClientLevel level, int ticks, float partialTick, PoseStack poseStack, Camera camera, Matrix4f projectionMatrix, boolean isFoggy, Runnable setupFog)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the snow and rain effects of this dimension.
|
||||
*
|
||||
* @return true to prevent vanilla snow and rain rendering
|
||||
*/
|
||||
default boolean renderSnowAndRain(ClientLevel level, int ticks, float partialTick, LightTexture lightTexture, double camX, double camY, double camZ)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the rain of this dimension.
|
||||
*
|
||||
* @return true to prevent vanilla rain ticking
|
||||
*/
|
||||
default boolean tickRain(ClientLevel level, int ticks, Camera camera)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public interface IForgeKeyMapping
|
||||
@NotNull InputConstants.Key getKey();
|
||||
|
||||
/**
|
||||
* Checks that the key conflict context and modifier are active, and that the keyCode matches this binding.
|
||||
* {@return true if the key conflict context and modifier are active and the keyCode matches this binding, false otherwise}
|
||||
*/
|
||||
default boolean isActiveAndMatches(InputConstants.Key keyCode)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,8 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link IForgeMinecraft}.
|
||||
*/
|
||||
@@ -36,4 +38,13 @@ public interface IForgeMinecraft
|
||||
{
|
||||
ForgeHooksClient.popGuiLayer(self());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@link Locale} set by the player.
|
||||
* Useful for creating string and number formatters.
|
||||
*/
|
||||
default Locale getLocale()
|
||||
{
|
||||
return self().getLanguageManager().getSelected().getJavaLocale();
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.math.Transformation;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link ModelState}. An {@code ModelState} is a function from model part to a
|
||||
* transformation that should be applied when that part is baked, thus representing the current "state" of the model
|
||||
* and its parts.
|
||||
*/
|
||||
public interface IForgeModelState
|
||||
{
|
||||
private ModelState self()
|
||||
{
|
||||
return (ModelState) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return A transformation to apply to the part} This may be an {@linkplain Transformation#isIdentity() identity
|
||||
* transformation} if there is no transformation to be applied. The coordinate system of the transform is determined
|
||||
* by the part type.
|
||||
*
|
||||
* @param part part of the model we are wanting to transform. An empty optional means
|
||||
* we want a transform for the entire model.
|
||||
*/
|
||||
default Transformation getPartTransformation(Object part)
|
||||
{
|
||||
return Transformation.identity();
|
||||
}
|
||||
}
|
||||
@@ -5,25 +5,15 @@
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraftforge.client.model.IQuadTransformer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link VertexConsumer}.
|
||||
@@ -35,90 +25,43 @@ public interface IForgeVertexConsumer
|
||||
return (VertexConsumer) this;
|
||||
}
|
||||
|
||||
VertexFormat getVertexFormat();
|
||||
|
||||
// Copy of putBulkData, but enables tinting and per-vertex alpha
|
||||
default void putBulkData(PoseStack.Pose poseStack, BakedQuad bakedQuad, float red, float green, float blue, int packedLight, int packedOverlay, boolean readExistingColor) {
|
||||
putBulkData(poseStack, bakedQuad, red, green, blue, 1.0f, packedLight, packedOverlay, readExistingColor);
|
||||
/**
|
||||
* Consumes an unknown {@link VertexFormatElement} as a raw int data array.
|
||||
* <p>
|
||||
* If the consumer needs to store the data for later use, it must copy it. There are no guarantees on immutability.
|
||||
*/
|
||||
default VertexConsumer misc(VertexFormatElement element, int... rawData)
|
||||
{
|
||||
return self();
|
||||
}
|
||||
|
||||
// Copy of putBulkData with alpha support
|
||||
default void putBulkData(PoseStack.Pose pose, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int packedLight, int packedOverlay) {
|
||||
putBulkData(pose, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{packedLight, packedLight, packedLight, packedLight}, packedOverlay, false);
|
||||
/**
|
||||
* Variant with no per-vertex shading.
|
||||
*/
|
||||
default void putBulkData(PoseStack.Pose pose, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int packedLight, int packedOverlay, boolean readExistingColor)
|
||||
{
|
||||
self().putBulkData(pose, bakedQuad, new float[] { 1.0F, 1.0F, 1.0F, 1.0F }, red, green, blue, alpha, new int[] { packedLight, packedLight, packedLight, packedLight }, packedOverlay, readExistingColor);
|
||||
}
|
||||
|
||||
// Copy of putBulkData with alpha support
|
||||
default void putBulkData(PoseStack.Pose pose, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int packedLight, int packedOverlay, boolean readExistingColor) {
|
||||
putBulkData(pose, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{packedLight, packedLight, packedLight, packedLight}, packedOverlay, readExistingColor);
|
||||
}
|
||||
|
||||
// Copy of putBulkData with alpha support
|
||||
default void putBulkData(PoseStack.Pose pose, BakedQuad bakedQuad, float[] baseBrightness, float red, float green, float blue, float alpha, int[] lightmap, int packedOverlay, boolean readExistingColor) {
|
||||
int[] aint = bakedQuad.getVertices();
|
||||
Vec3i faceNormal = bakedQuad.getDirection().getNormal();
|
||||
Vector3f normal = new Vector3f((float)faceNormal.getX(), (float)faceNormal.getY(), (float)faceNormal.getZ());
|
||||
Matrix4f matrix4f = pose.pose();
|
||||
normal.transform(pose.normal());
|
||||
int intSize = DefaultVertexFormat.BLOCK.getIntegerSize();
|
||||
int vertexCount = aint.length / intSize;
|
||||
|
||||
try (MemoryStack memorystack = MemoryStack.stackPush()) {
|
||||
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormat.BLOCK.getVertexSize());
|
||||
IntBuffer intbuffer = bytebuffer.asIntBuffer();
|
||||
|
||||
for(int v = 0; v < vertexCount; ++v) {
|
||||
((Buffer)intbuffer).clear();
|
||||
intbuffer.put(aint, v * 8, 8);
|
||||
float f = bytebuffer.getFloat(0);
|
||||
float f1 = bytebuffer.getFloat(4);
|
||||
float f2 = bytebuffer.getFloat(8);
|
||||
float cr;
|
||||
float cg;
|
||||
float cb;
|
||||
float ca;
|
||||
if (readExistingColor) {
|
||||
float r = (float)(bytebuffer.get(12) & 255) / 255.0F;
|
||||
float g = (float)(bytebuffer.get(13) & 255) / 255.0F;
|
||||
float b = (float)(bytebuffer.get(14) & 255) / 255.0F;
|
||||
float a = (float)(bytebuffer.get(15) & 255) / 255.0F;
|
||||
cr = r * baseBrightness[v] * red;
|
||||
cg = g * baseBrightness[v] * green;
|
||||
cb = b * baseBrightness[v] * blue;
|
||||
ca = a * alpha;
|
||||
} else {
|
||||
cr = baseBrightness[v] * red;
|
||||
cg = baseBrightness[v] * green;
|
||||
cb = baseBrightness[v] * blue;
|
||||
ca = alpha;
|
||||
}
|
||||
|
||||
int lightmapCoord = applyBakedLighting(lightmap[v], bytebuffer);
|
||||
float f9 = bytebuffer.getFloat(16);
|
||||
float f10 = bytebuffer.getFloat(20);
|
||||
Vector4f pos = new Vector4f(f, f1, f2, 1.0F);
|
||||
pos.transform(matrix4f);
|
||||
applyBakedNormals(normal, bytebuffer, pose.normal());
|
||||
self().vertex(pos.x(), pos.y(), pos.z(), cr, cg, cb, ca, f9, f10, packedOverlay, lightmapCoord, normal.x(), normal.y(), normal.z());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default int applyBakedLighting(int packedLight, ByteBuffer data) {
|
||||
int bl = packedLight&0xFFFF;
|
||||
int sl = (packedLight>>16)&0xFFFF;
|
||||
int offset = LightUtil.getLightOffset(0) * 4; // int offset for vertex 0 * 4 bytes per int
|
||||
default int applyBakedLighting(int packedLight, ByteBuffer data)
|
||||
{
|
||||
int bl = packedLight & 0xFFFF;
|
||||
int sl = (packedLight >> 16) & 0xFFFF;
|
||||
int offset = IQuadTransformer.UV2 * 4; // int offset for vertex 0 * 4 bytes per int
|
||||
int blBaked = Short.toUnsignedInt(data.getShort(offset));
|
||||
int slBaked = Short.toUnsignedInt(data.getShort(offset + 2));
|
||||
bl = Math.max(bl, blBaked);
|
||||
sl = Math.max(sl, slBaked);
|
||||
return bl | (sl<<16);
|
||||
return bl | (sl << 16);
|
||||
}
|
||||
|
||||
default void applyBakedNormals(Vector3f generated, ByteBuffer data, Matrix3f normalTransform) {
|
||||
default void applyBakedNormals(Vector3f generated, ByteBuffer data, Matrix3f normalTransform)
|
||||
{
|
||||
byte nx = data.get(28);
|
||||
byte ny = data.get(29);
|
||||
byte nz = data.get(30);
|
||||
if (nx != 0 || ny != 0 || nz != 0) {
|
||||
if (nx != 0 || ny != 0 || nz != 0)
|
||||
{
|
||||
generated.set(nx / 127f, ny / 127f, nz / 127f);
|
||||
generated.transform(normalTransform);
|
||||
}
|
||||
|
||||
+21
-4
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
package net.minecraftforge.client.extensions.common;
|
||||
|
||||
import com.mojang.math.Vector3d;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
@@ -14,15 +14,32 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
public interface IBlockRenderProperties
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link Block}.
|
||||
*
|
||||
* @see Block#initializeClient(Consumer)
|
||||
*/
|
||||
public interface IClientBlockExtensions
|
||||
{
|
||||
IBlockRenderProperties DUMMY = new IBlockRenderProperties()
|
||||
IClientBlockExtensions DEFAULT = new IClientBlockExtensions() { };
|
||||
|
||||
static IClientBlockExtensions of(BlockState state)
|
||||
{
|
||||
};
|
||||
return of(state.getBlock());
|
||||
}
|
||||
|
||||
static IClientBlockExtensions of(Block block)
|
||||
{
|
||||
return block.getRenderPropertiesInternal() instanceof IClientBlockExtensions e ? e : DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a digging particle effect in the level, this is a wrapper
|
||||
+53
-67
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client;
|
||||
package net.minecraftforge.client.extensions.common;
|
||||
|
||||
import com.mojang.blaze3d.shaders.FogShape;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
@@ -20,41 +20,47 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ScreenEffectRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraftforge.client.model.FluidModel;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* An interface which defines properties relating to how a {@link FluidType}
|
||||
* should render.
|
||||
* {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link FluidType}.
|
||||
*
|
||||
* <p>Note: This does not define any data regarding {@link RenderType}s as those
|
||||
* are specified by the Fluid via {@link ItemBlockRenderTypes#setRenderLayer(Fluid, RenderType)}
|
||||
* in the {@link FMLClientSetupEvent}.
|
||||
* @see FluidType#initializeClient(Consumer)
|
||||
*/
|
||||
public interface IFluidTypeRenderProperties
|
||||
public interface IClientFluidTypeExtensions
|
||||
{
|
||||
/**
|
||||
* A dummy instance returned when no render properties are specified.
|
||||
*/
|
||||
IFluidTypeRenderProperties DUMMY = new IFluidTypeRenderProperties()
|
||||
IClientFluidTypeExtensions DEFAULT = new IClientFluidTypeExtensions() { };
|
||||
|
||||
static IClientFluidTypeExtensions of(FluidState state)
|
||||
{
|
||||
};
|
||||
return of(state.getFluidType());
|
||||
}
|
||||
|
||||
static IClientFluidTypeExtensions of(Fluid fluid)
|
||||
{
|
||||
return of(fluid.getFluidType());
|
||||
}
|
||||
|
||||
static IClientFluidTypeExtensions of(FluidType type)
|
||||
{
|
||||
return type.getRenderPropertiesInternal() instanceof IClientFluidTypeExtensions props ? props : DEFAULT;
|
||||
}
|
||||
|
||||
/* Default Accessors */
|
||||
|
||||
@@ -66,7 +72,7 @@ public interface IFluidTypeRenderProperties
|
||||
*
|
||||
* @return the tint applied to the fluid's textures in ARGB format
|
||||
*/
|
||||
default int getColorTint()
|
||||
default int getTintColor()
|
||||
{
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
@@ -127,7 +133,7 @@ public interface IFluidTypeRenderProperties
|
||||
/**
|
||||
* Returns a stream of textures applied to a fluid.
|
||||
*
|
||||
* <p>This is used by the {@link FluidModel} to load in all textures that
|
||||
* <p>This is used by the {@link net.minecraft.client.resources.model.ModelBakery} to load in all textures that
|
||||
* can be applied on reload.
|
||||
*
|
||||
* @return a stream of textures applied to a fluid
|
||||
@@ -135,7 +141,7 @@ public interface IFluidTypeRenderProperties
|
||||
default Stream<ResourceLocation> getTextures()
|
||||
{
|
||||
return Stream.of(this.getStillTexture(), this.getFlowingTexture(), this.getOverlayTexture())
|
||||
.filter(Objects::nonNull);
|
||||
.filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,32 +166,14 @@ public interface IFluidTypeRenderProperties
|
||||
* Renders {@code #getRenderOverlayTexture} onto the camera when within
|
||||
* the fluid.
|
||||
*
|
||||
* @param mc the client instance
|
||||
* @param stack the transformations representing the current rendering position
|
||||
* @param mc the client instance
|
||||
* @param poseStack the transformations representing the current rendering position
|
||||
*/
|
||||
default void renderOverlay(Minecraft mc, PoseStack stack)
|
||||
default void renderOverlay(Minecraft mc, PoseStack poseStack)
|
||||
{
|
||||
ResourceLocation texture = this.getRenderOverlayTexture(mc);
|
||||
if (texture == null) return;
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.setShaderTexture(0, texture);
|
||||
BufferBuilder buffer = Tesselator.getInstance().getBuilder();
|
||||
BlockPos playerEyePos = new BlockPos(mc.player.getX(), mc.player.getEyeY(), mc.player.getZ());
|
||||
float brightness = LightTexture.getBrightness(mc.player.level.dimensionType(), mc.player.level.getMaxLocalRawBrightness(playerEyePos));
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.setShaderColor(brightness, brightness, brightness, 0.1F);
|
||||
float uOffset = -mc.player.getYRot() / 64.0F;
|
||||
float vOffset = mc.player.getXRot() / 64.0F;
|
||||
Matrix4f pose = stack.last().pose();
|
||||
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
|
||||
buffer.vertex(pose, -1.0F, -1.0F, -0.5F).uv(4.0F + uOffset, 4.0F + vOffset).endVertex();
|
||||
buffer.vertex(pose, 1.0F, -1.0F, -0.5F).uv(uOffset, 4.0F + vOffset).endVertex();
|
||||
buffer.vertex(pose, 1.0F, 1.0F, -0.5F).uv(uOffset, vOffset).endVertex();
|
||||
buffer.vertex(pose, -1.0F, 1.0F, -0.5F).uv(4.0F + uOffset, vOffset).endVertex();
|
||||
BufferUploader.drawWithShader(buffer.end());
|
||||
RenderSystem.disableBlend();
|
||||
if (texture != null)
|
||||
ScreenEffectRenderer.renderFluid(mc, poseStack, texture);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,12 +182,12 @@ public interface IFluidTypeRenderProperties
|
||||
* <p>The result expects a three float vector representing the red, green,
|
||||
* and blue channels respectively. Each channel should be between [0,1].
|
||||
*
|
||||
* @param camera the camera instance
|
||||
* @param partialTick the delta time of where the current frame is within a tick
|
||||
* @param level the level the camera is located in
|
||||
* @param renderDistance the render distance of the client
|
||||
* @param camera the camera instance
|
||||
* @param partialTick the delta time of where the current frame is within a tick
|
||||
* @param level the level the camera is located in
|
||||
* @param renderDistance the render distance of the client
|
||||
* @param darkenWorldAmount the amount to darken the world by
|
||||
* @param fluidFogColor the current color of the fog
|
||||
* @param fluidFogColor the current color of the fog
|
||||
* @return the color of the fog
|
||||
*/
|
||||
@NotNull
|
||||
@@ -212,13 +200,13 @@ public interface IFluidTypeRenderProperties
|
||||
* Modifies how the fog is currently being rendered when the camera is
|
||||
* within a fluid.
|
||||
*
|
||||
* @param camera the camera instance
|
||||
* @param mode the type of fog being rendered
|
||||
* @param camera the camera instance
|
||||
* @param mode the type of fog being rendered
|
||||
* @param renderDistance the render distance of the client
|
||||
* @param partialTick the delta time of where the current frame is within a tick
|
||||
* @param nearDistance the near plane of where the fog starts to render
|
||||
* @param farDistance the far plane of where the fog ends rendering
|
||||
* @param shape the shape of the fog being rendered
|
||||
* @param partialTick the delta time of where the current frame is within a tick
|
||||
* @param nearDistance the near plane of where the fog starts to render
|
||||
* @param farDistance the far plane of where the fog ends rendering
|
||||
* @param shape the shape of the fog being rendered
|
||||
*/
|
||||
default void modifyFogRender(Camera camera, FogRenderer.FogMode mode, float renderDistance, float partialTick, float nearDistance, float farDistance, FogShape shape)
|
||||
{
|
||||
@@ -236,9 +224,9 @@ public interface IFluidTypeRenderProperties
|
||||
* <p>Important: This method should only return {@code null} for {@link Fluids#EMPTY}.
|
||||
* All other implementations must define this property.
|
||||
*
|
||||
* @param state the state of the fluid
|
||||
* @param state the state of the fluid
|
||||
* @param getter the getter the fluid can be obtained from
|
||||
* @param pos the position of the fluid
|
||||
* @param pos the position of the fluid
|
||||
* @return the reference of the texture to apply to a source fluid
|
||||
*/
|
||||
default ResourceLocation getStillTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos)
|
||||
@@ -256,9 +244,9 @@ public interface IFluidTypeRenderProperties
|
||||
* <p>Important: This method should only return {@code null} for {@link Fluids#EMPTY}.
|
||||
* All other implementations must define this property.
|
||||
*
|
||||
* @param state the state of the fluid
|
||||
* @param state the state of the fluid
|
||||
* @param getter the getter the fluid can be obtained from
|
||||
* @param pos the position of the fluid
|
||||
* @param pos the position of the fluid
|
||||
* @return the reference of the texture to apply to a flowing fluid
|
||||
*/
|
||||
default ResourceLocation getFlowingTexture(FluidState state, BlockAndTintGetter getter, BlockPos pos)
|
||||
@@ -276,9 +264,9 @@ public interface IFluidTypeRenderProperties
|
||||
* texture itself (e.g. {@code minecraft:block/water_overlay} will point to
|
||||
* {@code assets/minecraft/textures/block/water_overlay.png}).
|
||||
*
|
||||
* @param state the state of the fluid
|
||||
* @param state the state of the fluid
|
||||
* @param getter the getter the fluid can be obtained from
|
||||
* @param pos the position of the fluid
|
||||
* @param pos the position of the fluid
|
||||
* @return the reference of the texture to apply to a fluid directly touching
|
||||
* a non-opaque block
|
||||
*/
|
||||
@@ -287,26 +275,24 @@ public interface IFluidTypeRenderProperties
|
||||
return this.getOverlayTexture();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the tint applied to the fluid's textures.
|
||||
*
|
||||
* <p>The result represents a 32-bit integer where each 8-bits represent
|
||||
* the alpha, red, green, and blue channel respectively.
|
||||
*
|
||||
* @param state the state of the fluid
|
||||
* @param state the state of the fluid
|
||||
* @param getter the getter the fluid can be obtained from
|
||||
* @param pos the position of the fluid
|
||||
* @param pos the position of the fluid
|
||||
* @return the tint applied to the fluid's textures in ARGB format
|
||||
*/
|
||||
default int getColorTint(FluidState state, BlockAndTintGetter getter, BlockPos pos)
|
||||
default int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos)
|
||||
{
|
||||
return this.getColorTint();
|
||||
return this.getTintColor();
|
||||
}
|
||||
|
||||
/* Stack-Based Accessors */
|
||||
|
||||
|
||||
/**
|
||||
* Returns the tint applied to the fluid's textures.
|
||||
*
|
||||
@@ -316,9 +302,9 @@ public interface IFluidTypeRenderProperties
|
||||
* @param stack the stack the fluid is in
|
||||
* @return the tint applied to the fluid's textures in ARGB format
|
||||
*/
|
||||
default int getColorTint(FluidStack stack)
|
||||
default int getTintColor(FluidStack stack)
|
||||
{
|
||||
return this.getColorTint();
|
||||
return this.getTintColor();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions.common;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link Item}.
|
||||
*
|
||||
* @see Item#initializeClient(Consumer)
|
||||
*/
|
||||
public interface IClientItemExtensions
|
||||
{
|
||||
IClientItemExtensions DEFAULT = new IClientItemExtensions() { };
|
||||
|
||||
static IClientItemExtensions of(ItemStack stack)
|
||||
{
|
||||
return of(stack.getItem());
|
||||
}
|
||||
|
||||
static IClientItemExtensions of(Item item)
|
||||
{
|
||||
return item.getRenderPropertiesInternal() instanceof IClientItemExtensions e ? e : DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font used to render data related to this item as specified in the {@code context}.
|
||||
* Return {@code null} to use the default font.
|
||||
*
|
||||
* @param stack The item stack
|
||||
* @param context The context in which the font will be used
|
||||
* @return A {@link Font} or null to use the default
|
||||
*/
|
||||
@Nullable
|
||||
default Font getFont(ItemStack stack, FontContext context)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the humanoid armor model for this item when it's equipped.
|
||||
*
|
||||
* @param livingEntity The entity wearing the armor
|
||||
* @param itemStack The item stack
|
||||
* @param equipmentSlot The slot the item is in
|
||||
* @param original The original armor model. Will have attributes set.
|
||||
* @return A HumanoidModel to be rendered. Relevant properties are to be copied over by the caller.
|
||||
* @see #getGenericArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)
|
||||
*/
|
||||
@NotNull
|
||||
default HumanoidModel<?> getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<?> original)
|
||||
{
|
||||
return original;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the armor model for this item when it's equipped. Useful in place of
|
||||
* {@link #getHumanoidArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)} for wrapping the original
|
||||
* model or returning anything non-standard.
|
||||
* <p>
|
||||
* If you override this method you are responsible for copying any properties you care about from the original model.
|
||||
*
|
||||
* @param livingEntity The entity wearing the armor
|
||||
* @param itemStack The item stack
|
||||
* @param equipmentSlot The slot the item is in
|
||||
* @param original The original armor model. Will have attributes set.
|
||||
* @return A Model to be rendered. Relevant properties must be copied over manually.
|
||||
* @see #getHumanoidArmorModel(LivingEntity, ItemStack, EquipmentSlot, HumanoidModel)
|
||||
*/
|
||||
@NotNull
|
||||
default Model getGenericArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<?> original)
|
||||
{
|
||||
HumanoidModel<?> replacement = getHumanoidArmorModel(livingEntity, itemStack, equipmentSlot, original);
|
||||
if (replacement != original)
|
||||
{
|
||||
ForgeHooksClient.copyModelProperties(original, replacement);
|
||||
return replacement;
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the client starts rendering the HUD, and is wearing this item in the helmet slot.
|
||||
* <p>
|
||||
* This is where pumpkins would render their overlay.
|
||||
*
|
||||
* @param stack The item stack
|
||||
* @param player The player entity
|
||||
* @param width The viewport width
|
||||
* @param height Viewport height
|
||||
* @param partialTick Partial tick time, useful for interpolation
|
||||
*/
|
||||
default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTick)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries this item's renderer.
|
||||
* <p>
|
||||
* Only used if {@link BakedModel#isCustomRenderer()} returns {@code true} or {@link BlockState#getRenderShape()}
|
||||
* returns {@link net.minecraft.world.level.block.RenderShape#ENTITYBLOCK_ANIMATED}.
|
||||
* <p>
|
||||
* By default, returns vanilla's block entity renderer.
|
||||
*/
|
||||
default BlockEntityWithoutLevelRenderer getCustomRenderer()
|
||||
{
|
||||
return Minecraft.getInstance().getItemRenderer().getBlockEntityRenderer();
|
||||
}
|
||||
|
||||
enum FontContext
|
||||
{
|
||||
/**
|
||||
* Used to display the amount of items in the {@link ItemStack}.
|
||||
*/
|
||||
ITEM_COUNT,
|
||||
/**
|
||||
* Used to display text in the {@link net.minecraft.world.inventory.tooltip.TooltipComponent}.
|
||||
*/
|
||||
TOOLTIP,
|
||||
/**
|
||||
* Used to display the item name above the hotbar when the player selects it.
|
||||
*/
|
||||
SELECTED_ITEM_NAME
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions.common;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* {@linkplain LogicalSide#CLIENT Client-only} extensions to {@link MobEffect}.
|
||||
*
|
||||
* @see MobEffect#initializeClient(Consumer)
|
||||
*/
|
||||
public interface IClientMobEffectExtensions
|
||||
{
|
||||
IClientMobEffectExtensions DEFAULT = new IClientMobEffectExtensions() { };
|
||||
|
||||
static IClientMobEffectExtensions of(MobEffectInstance instance)
|
||||
{
|
||||
return of(instance.getEffect());
|
||||
}
|
||||
|
||||
static IClientMobEffectExtensions of(MobEffect effect)
|
||||
{
|
||||
return effect.getEffectRendererInternal() instanceof IClientMobEffectExtensions r ? r : DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries whether the given effect should be shown in the player's inventory.
|
||||
* <p>
|
||||
* By default, this returns {@code true}.
|
||||
*/
|
||||
default boolean isVisibleInInventory(MobEffectInstance instance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries whether the given effect should be shown in the HUD.
|
||||
* <p>
|
||||
* By default, this returns {@code true}.
|
||||
*/
|
||||
default boolean isVisibleInGui(MobEffectInstance instance)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the icon of the specified effect in the player's inventory.
|
||||
* This can be used to render icons from your own texture sheet.
|
||||
*
|
||||
* @param instance The effect instance
|
||||
* @param screen The effect-rendering screen
|
||||
* @param poseStack The pose stack
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param blitOffset The blit offset
|
||||
* @return true to prevent default rendering, false otherwise
|
||||
*/
|
||||
default boolean renderInventoryIcon(MobEffectInstance instance, EffectRenderingInventoryScreen<?> screen, PoseStack poseStack, int x, int y, int blitOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the text of the specified effect in the player's inventory.
|
||||
*
|
||||
* @param instance The effect instance
|
||||
* @param screen The effect-rendering screen
|
||||
* @param poseStack The pose stack
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param blitOffset The blit offset
|
||||
* @return true to prevent default rendering, false otherwise
|
||||
*/
|
||||
default boolean renderInventoryText(MobEffectInstance instance, EffectRenderingInventoryScreen<?> screen, PoseStack poseStack, int x, int y, int blitOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the icon of the specified effect on the player's HUD.
|
||||
* This can be used to render icons from your own texture sheet.
|
||||
*
|
||||
* @param instance The effect instance
|
||||
* @param gui The gui
|
||||
* @param poseStack The pose stack
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param z The z depth
|
||||
* @param alpha The alpha value. Blinks when the effect is about to run out
|
||||
* @return true to prevent default rendering, false otherwise
|
||||
*/
|
||||
default boolean renderGuiIcon(MobEffectInstance instance, Gui gui, PoseStack poseStack, int x, int y, float z, float alpha)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraftforge.client.event.RegisterClientTooltipComponentFactoriesEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Manager for {@link ClientTooltipComponent} factories.
|
||||
* <p>
|
||||
* Provides a lookup.
|
||||
*/
|
||||
public final class ClientTooltipComponentManager
|
||||
{
|
||||
private static ImmutableMap<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> FACTORIES;
|
||||
|
||||
/**
|
||||
* Creates a client component for the given argument, or null if unsupported.
|
||||
*/
|
||||
@Nullable
|
||||
public static ClientTooltipComponent createClientTooltipComponent(TooltipComponent component)
|
||||
{
|
||||
var factory = FACTORIES.get(component.getClass());
|
||||
return factory != null ? factory.apply(component) : null;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void init()
|
||||
{
|
||||
var factories = new HashMap<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>>();
|
||||
var event = new RegisterClientTooltipComponentFactoriesEvent(factories);
|
||||
ModLoader.get().postEventWithWrapInModOrder(event, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null));
|
||||
FACTORIES = ImmutableMap.copyOf(factories);
|
||||
}
|
||||
|
||||
private ClientTooltipComponentManager()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public interface IIngameOverlay
|
||||
{
|
||||
void render(ForgeIngameGui gui, PoseStack poseStack, float partialTick, int width, int height);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraftforge.client.gui.widget.ModListWidget;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.client.gui.widget.ScrollPanel;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import net.minecraftforge.resource.PathResourcePack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -184,7 +184,7 @@ public class ModListScreen extends Screen
|
||||
RenderSystem.setShaderTexture(0, logoPath);
|
||||
// Draw the logo image inscribed in a rectangle with width entryWidth (minus some padding) and height 50
|
||||
int headerHeight = 50;
|
||||
GuiUtils.drawInscribedRect(poseStack, left + PADDING, relativeY, width - (PADDING * 2), headerHeight, logoDims.width, logoDims.height, false, true);
|
||||
ScreenUtils.blitInscribed(poseStack, left + PADDING, relativeY, width - (PADDING * 2), headerHeight, logoDims.width, logoDims.height, false, true);
|
||||
relativeY += headerHeight + PADDING;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraftforge.client.gui.widget.ScrollPanel;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OverlayRegistry
|
||||
{
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed at the beginning of the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayBottom(@NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(-1, null, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed before the {@code other} parameter in the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param other The overlay to insert before. The overlay must be registered.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayBelow(@NotNull IIngameOverlay other, @NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(-1, other, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed after the {@code other} parameter in the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param other The overlay to insert after. The overlay must be registered.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayAbove(@NotNull IIngameOverlay other, @NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(1, other, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed at the end of the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayTop(@NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(1, null, displayName, overlay);
|
||||
}
|
||||
|
||||
private static IIngameOverlay registerOverlay(int sort, @Nullable IIngameOverlay other, @NotNull String displayName, @NotNull IIngameOverlay overlay)
|
||||
{
|
||||
OverlayEntry entry = overlays.get(overlay);
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
overlaysOrdered.remove(entry);
|
||||
}
|
||||
|
||||
int insertAt = overlays.size();
|
||||
if (other == null)
|
||||
{
|
||||
if (sort < 0)
|
||||
insertAt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < overlaysOrdered.size(); i++)
|
||||
{
|
||||
OverlayEntry ov = overlaysOrdered.get(i);
|
||||
if (ov.getOverlay() == other)
|
||||
{
|
||||
if (sort < 0) insertAt = i;
|
||||
else insertAt = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entry = new OverlayEntry(overlay, displayName);
|
||||
|
||||
overlaysOrdered.add(insertAt, entry);
|
||||
overlays.put(overlay, entry);
|
||||
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables an overlay. This is preferred over removing overlays.
|
||||
* @param overlay The overlay object to enable or disable
|
||||
* @param enable The new state
|
||||
*/
|
||||
public static synchronized void enableOverlay(@NotNull IIngameOverlay overlay, boolean enable)
|
||||
{
|
||||
OverlayEntry entry = overlays.get(overlay);
|
||||
if (entry != null)
|
||||
{
|
||||
entry.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the information on a registered overlay.
|
||||
* @param overlay The overlay to obtain the information for.
|
||||
* @return The registration entry for this overlay.
|
||||
*/
|
||||
@Nullable
|
||||
public static synchronized OverlayEntry getEntry(@NotNull IIngameOverlay overlay)
|
||||
{
|
||||
return overlays.get(overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns an unmodifiable view of the ordered list of entries.
|
||||
*/
|
||||
public static List<OverlayEntry> orderedEntries()
|
||||
{
|
||||
return Collections.unmodifiableList(overlaysOrdered);
|
||||
}
|
||||
|
||||
private static final Map<IIngameOverlay, OverlayEntry> overlays = Maps.newHashMap();
|
||||
private static final List<OverlayEntry> overlaysOrdered = Lists.newArrayList();
|
||||
|
||||
public static class OverlayEntry {
|
||||
private final IIngameOverlay overlay;
|
||||
private final String displayName;
|
||||
private boolean enabled = true;
|
||||
|
||||
public OverlayEntry(IIngameOverlay overlay, String displayName)
|
||||
{
|
||||
this.overlay = overlay;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the overlay renderer.
|
||||
*/
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the debug name for this entry.
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns true if the entry will be rendered.
|
||||
*/
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* For internal use. Call via {@link #enableOverlay(IIngameOverlay, boolean)}.
|
||||
*/
|
||||
private void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+18
-29
@@ -7,33 +7,22 @@ package net.minecraftforge.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class provides several methods and constants used by the Config GUI classes.
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public class GuiUtils
|
||||
public class ScreenUtils
|
||||
{
|
||||
public static final int DEFAULT_BACKGROUND_COLOR = 0xF0100010;
|
||||
public static final int DEFAULT_BORDER_COLOR_START = 0x505000FF;
|
||||
@@ -43,12 +32,12 @@ public class GuiUtils
|
||||
public static final String VALID = "\u2714";
|
||||
public static final String INVALID = "\u2715";
|
||||
|
||||
public static int[] colorCodes = new int[] { 0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215,
|
||||
public static int[] TEXT_COLOR_CODES = new int[] { 0, 170, 43520, 43690, 11141120, 11141290, 16755200, 11184810, 5592405, 5592575, 5635925, 5636095, 16733525, 16733695, 16777045, 16777215,
|
||||
0, 42, 10752, 10794, 2752512, 2752554, 2763264, 2763306, 1381653, 1381695, 1392405, 1392447, 4134165, 4134207, 4144917, 4144959 };
|
||||
|
||||
public static int getColorCode(char c, boolean isLighter)
|
||||
public static int getColorFromFormattingCharacter(char c, boolean isLighter)
|
||||
{
|
||||
return colorCodes[isLighter ? "0123456789abcdef".indexOf(c) : "0123456789abcdef".indexOf(c) + 16];
|
||||
return TEXT_COLOR_CODES[isLighter ? "0123456789abcdef".indexOf(c) : "0123456789abcdef".indexOf(c) + 16];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,10 +57,10 @@ public class GuiUtils
|
||||
* @param borderSize the size of the box's borders
|
||||
* @param zLevel the zLevel to draw at
|
||||
*/
|
||||
public static void drawContinuousTexturedBox(PoseStack poseStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int borderSize, float zLevel)
|
||||
public static void blitWithBorder(PoseStack poseStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int borderSize, float zLevel)
|
||||
{
|
||||
drawContinuousTexturedBox(poseStack, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
blitWithBorder(poseStack, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,10 +81,10 @@ public class GuiUtils
|
||||
* @param borderSize the size of the box's borders
|
||||
* @param zLevel the zLevel to draw at
|
||||
*/
|
||||
public static void drawContinuousTexturedBox(PoseStack poseStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int borderSize, float zLevel)
|
||||
public static void blitWithBorder(PoseStack poseStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int borderSize, float zLevel)
|
||||
{
|
||||
drawContinuousTexturedBox(poseStack, res, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
blitWithBorder(poseStack, res, x, y, u, v, width, height, textureWidth, textureHeight, borderSize, borderSize, borderSize, borderSize, zLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,12 +108,12 @@ public class GuiUtils
|
||||
* @param rightBorder the size of the box's right border
|
||||
* @param zLevel the zLevel to draw at
|
||||
*/
|
||||
public static void drawContinuousTexturedBox(PoseStack poseStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
|
||||
public static void blitWithBorder(PoseStack poseStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
|
||||
{
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, res);
|
||||
drawContinuousTexturedBox(poseStack, x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel);
|
||||
blitWithBorder(poseStack, x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,8 +136,8 @@ public class GuiUtils
|
||||
* @param rightBorder the size of the box's right border
|
||||
* @param zLevel the zLevel to draw at
|
||||
*/
|
||||
public static void drawContinuousTexturedBox(PoseStack poseStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
|
||||
public static void blitWithBorder(PoseStack poseStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
|
||||
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
|
||||
{
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.enableBlend();
|
||||
@@ -241,12 +230,12 @@ public class GuiUtils
|
||||
RenderSystem.enableTexture();
|
||||
}
|
||||
|
||||
public static void drawInscribedRect(PoseStack poseStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
|
||||
public static void blitInscribed(PoseStack poseStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
|
||||
{
|
||||
drawInscribedRect(poseStack, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true);
|
||||
blitInscribed(poseStack, x, y, boundsWidth, boundsHeight, rectWidth, rectHeight, true, true);
|
||||
}
|
||||
|
||||
public static void drawInscribedRect(PoseStack poseStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
|
||||
public static void blitInscribed(PoseStack poseStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
|
||||
{
|
||||
if (rectWidth * boundsHeight > rectHeight * boundsWidth) {
|
||||
int h = boundsHeight;
|
||||
+7
-7
@@ -21,7 +21,7 @@ import net.minecraftforge.client.loading.ClientModLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class NotificationModUpdateScreen extends Screen
|
||||
public class TitleScreenModUpdateIndicator extends Screen
|
||||
{
|
||||
|
||||
private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png");
|
||||
@@ -30,7 +30,7 @@ public class NotificationModUpdateScreen extends Screen
|
||||
private VersionChecker.Status showNotification = null;
|
||||
private boolean hasCheckedForUpdates = false;
|
||||
|
||||
public NotificationModUpdateScreen(Button modButton)
|
||||
public TitleScreenModUpdateIndicator(Button modButton)
|
||||
{
|
||||
super(Component.translatable("forge.menu.updatescreen.title"));
|
||||
this.modButton = modButton;
|
||||
@@ -67,12 +67,12 @@ public class NotificationModUpdateScreen extends Screen
|
||||
blit(poseStack, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
|
||||
}
|
||||
|
||||
public static NotificationModUpdateScreen init(TitleScreen guiMainMenu, Button modButton)
|
||||
public static TitleScreenModUpdateIndicator init(TitleScreen guiMainMenu, Button modButton)
|
||||
{
|
||||
NotificationModUpdateScreen notificationModUpdateScreen = new NotificationModUpdateScreen(modButton);
|
||||
notificationModUpdateScreen.resize(guiMainMenu.getMinecraft(), guiMainMenu.width, guiMainMenu.height);
|
||||
notificationModUpdateScreen.init();
|
||||
return notificationModUpdateScreen;
|
||||
TitleScreenModUpdateIndicator titleScreenModUpdateIndicator = new TitleScreenModUpdateIndicator(modButton);
|
||||
titleScreenModUpdateIndicator.resize(guiMainMenu.getMinecraft(), guiMainMenu.width, guiMainMenu.height);
|
||||
titleScreenModUpdateIndicator.init();
|
||||
return titleScreenModUpdateIndicator;
|
||||
}
|
||||
|
||||
}
|
||||
+145
-351
@@ -3,72 +3,77 @@
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
package net.minecraftforge.client.gui.overlay;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.DebugScreenOverlay;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
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.Objective;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.food.FoodData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraftforge.client.RenderProperties;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGuiEvent;
|
||||
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
|
||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ForgeIngameGui extends Gui
|
||||
/**
|
||||
* Forge wrapper around {@link Gui} to be able to render {@link IGuiOverlay HUD overlays}.
|
||||
*/
|
||||
public class ForgeGui extends Gui
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final int WHITE = 0xFFFFFF;
|
||||
|
||||
/*
|
||||
* If the Euclidian distance to the moused-over block in meters is less than this value, the "Looking at" text will appear on the debug overlay.
|
||||
* If the Euclidean distance to the moused-over block in meters is less than this value, the "Looking at" text will appear on the debug overlay.
|
||||
*/
|
||||
public static double rayTraceDistance = 20.0D;
|
||||
|
||||
public int left_height = 39;
|
||||
public int right_height = 39;
|
||||
public int leftHeight = 39;
|
||||
public int rightHeight = 39;
|
||||
|
||||
private Font font = null;
|
||||
private RenderGameOverlayEvent eventParent;
|
||||
|
||||
private ForgeDebugScreenOverlay debugOverlay;
|
||||
private final ForgeDebugScreenOverlay debugOverlay;
|
||||
|
||||
public ForgeGui(Minecraft mc)
|
||||
{
|
||||
super(mc, mc.getItemRenderer());
|
||||
debugOverlay = new ForgeDebugScreenOverlay(mc);
|
||||
}
|
||||
|
||||
public Minecraft getMinecraft()
|
||||
{
|
||||
return minecraft;
|
||||
}
|
||||
|
||||
public void setupOverlayRenderState(boolean blend, boolean depthText)
|
||||
{
|
||||
@@ -110,253 +115,40 @@ public class ForgeIngameGui extends Gui
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
}
|
||||
|
||||
public static final IIngameOverlay VIGNETTE_ELEMENT = OverlayRegistry.registerOverlayTop("Vignette", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (Minecraft.useFancyGraphics())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderVignette(gui.minecraft.getCameraEntity());
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay SPYGLASS_ELEMENT = OverlayRegistry.registerOverlayTop("Spyglass", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderSpyglassOverlay();
|
||||
});
|
||||
|
||||
public static final IIngameOverlay HELMET_ELEMENT = OverlayRegistry.registerOverlayTop("Helmet", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHelmet(partialTick, poseStack);
|
||||
});
|
||||
|
||||
public static final IIngameOverlay FROSTBITE_ELEMENT = OverlayRegistry.registerOverlayTop("Frostbite", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderFrostbite(poseStack);
|
||||
});
|
||||
|
||||
public static final IIngameOverlay PORTAL_ELEMENT = OverlayRegistry.registerOverlayTop("Portal", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
if (!gui.minecraft.player.hasEffect(MobEffects.CONFUSION))
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderPortalOverlay(partialTick);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
public static final IIngameOverlay HOTBAR_ELEMENT = OverlayRegistry.registerOverlayTop("Hotbar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
if (gui.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR)
|
||||
{
|
||||
gui.spectatorGui.renderHotbar(poseStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui.renderHotbar(partialTick, poseStack);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay CROSSHAIR_ELEMENT = OverlayRegistry.registerOverlayTop("Crosshair", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.setBlitOffset(-90);
|
||||
|
||||
gui.renderCrosshair(poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay BOSS_HEALTH_ELEMENT = OverlayRegistry.registerOverlayTop("Boss Health", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.setBlitOffset(-90);
|
||||
|
||||
gui.renderBossHealth(poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay PLAYER_HEALTH_ELEMENT = OverlayRegistry.registerOverlayTop("Player Health", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHealth(screenWidth, screenHeight, poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay ARMOR_LEVEL_ELEMENT = OverlayRegistry.registerOverlayTop("Armor Level",(gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderArmor(poseStack, screenWidth, screenHeight);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay FOOD_LEVEL_ELEMENT = OverlayRegistry.registerOverlayTop("Food Level", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
boolean isMounted = gui.minecraft.player.getVehicle() instanceof LivingEntity;
|
||||
if (!isMounted && !gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderFood(screenWidth, screenHeight, poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay MOUNT_HEALTH_ELEMENT = OverlayRegistry.registerOverlayTop("Mount Health", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHealthMount(screenWidth, screenHeight, poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay AIR_LEVEL_ELEMENT = OverlayRegistry.registerOverlayTop("Air Level", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderAir(screenWidth, screenHeight, poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay JUMP_BAR_ELEMENT = OverlayRegistry.registerOverlayTop("Jump Bar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (gui.minecraft.player.isRidingJumpable() && !gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderJumpMeter(poseStack, screenWidth / 2 - 91);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay EXPERIENCE_BAR_ELEMENT = OverlayRegistry.registerOverlayTop("Experience Bar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.player.isRidingJumpable() && !gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderExperience(screenWidth / 2 - 91, poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay ITEM_NAME_ELEMENT = OverlayRegistry.registerOverlayTop("Item Name", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
if (gui.minecraft.options.heldItemTooltips && gui.minecraft.gameMode.getPlayerMode() != GameType.SPECTATOR) {
|
||||
gui.renderSelectedItemName(poseStack);
|
||||
} else if (gui.minecraft.player.isSpectator()) {
|
||||
gui.spectatorGui.renderTooltip(poseStack);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay SLEEP_FADE_ELEMENT = OverlayRegistry.registerOverlayTop("Sleep Fade", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderSleepFade(screenWidth, screenHeight, poseStack);
|
||||
});
|
||||
|
||||
public static final IIngameOverlay HUD_TEXT_ELEMENT = OverlayRegistry.registerOverlayTop("Text Columns", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderHUDText(screenWidth, screenHeight, poseStack);
|
||||
});
|
||||
|
||||
public static final IIngameOverlay FPS_GRAPH_ELEMENT = OverlayRegistry.registerOverlayTop("FPS Graph", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderFPSGraph(poseStack);
|
||||
});
|
||||
|
||||
public static final IIngameOverlay POTION_ICONS_ELEMENT = OverlayRegistry.registerOverlayTop("Potion Icons", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderEffects(poseStack);
|
||||
});
|
||||
|
||||
public static final IIngameOverlay RECORD_OVERLAY_ELEMENT = OverlayRegistry.registerOverlayTop("Record", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.renderRecordOverlay(screenWidth, screenHeight, partialTick, poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay SUBTITLES_ELEMENT = OverlayRegistry.registerOverlayTop("Subtitles", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.renderSubtitles(poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay TITLE_TEXT_ELEMENT = OverlayRegistry.registerOverlayTop("Title Text", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.minecraft.options.hideGui)
|
||||
{
|
||||
gui.renderTitle(screenWidth, screenHeight, partialTick, poseStack);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay SCOREBOARD_ELEMENT = OverlayRegistry.registerOverlayTop("Scoreboard", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
Scoreboard scoreboard = gui.minecraft.level.getScoreboard();
|
||||
Objective objective = null;
|
||||
PlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(gui.minecraft.player.getScoreboardName());
|
||||
if (scoreplayerteam != null)
|
||||
{
|
||||
int slot = scoreplayerteam.getColor().getId();
|
||||
if (slot >= 0) objective = scoreboard.getDisplayObjective(3 + slot);
|
||||
}
|
||||
Objective scoreobjective1 = objective != null ? objective : scoreboard.getDisplayObjective(1);
|
||||
if (scoreobjective1 != null)
|
||||
{
|
||||
gui.displayScoreboardSidebar(poseStack, scoreobjective1);
|
||||
}
|
||||
});
|
||||
|
||||
public static final IIngameOverlay CHAT_PANEL_ELEMENT = OverlayRegistry.registerOverlayTop("Chat History", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
gui.renderChat(screenWidth, screenHeight, poseStack);
|
||||
});
|
||||
|
||||
public static final IIngameOverlay PLAYER_LIST_ELEMENT = OverlayRegistry.registerOverlayTop("Player List", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
gui.renderPlayerList(screenWidth, screenHeight, poseStack);
|
||||
});
|
||||
|
||||
public ForgeIngameGui(Minecraft mc)
|
||||
{
|
||||
super(mc, mc.getItemRenderer());
|
||||
debugOverlay = new ForgeDebugScreenOverlay(mc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, float partialTick)
|
||||
{
|
||||
this.screenWidth = this.minecraft.getWindow().getGuiScaledWidth();
|
||||
this.screenHeight = this.minecraft.getWindow().getGuiScaledHeight();
|
||||
eventParent = new RenderGameOverlayEvent(poseStack, partialTick, this.minecraft.getWindow());
|
||||
|
||||
right_height = 39;
|
||||
left_height = 39;
|
||||
rightHeight = 39;
|
||||
leftHeight = 39;
|
||||
|
||||
if (pre(ALL, poseStack)) return;
|
||||
if (MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Pre(minecraft.getWindow(), poseStack, partialTick)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
font = minecraft.font;
|
||||
|
||||
this.random.setSeed(tickCount * 312871L);
|
||||
|
||||
OverlayRegistry.orderedEntries().forEach(entry -> {
|
||||
GuiOverlayManager.getOverlays().forEach(entry -> {
|
||||
try
|
||||
{
|
||||
if (!entry.isEnabled()) return;
|
||||
IIngameOverlay overlay = entry.getOverlay();
|
||||
if (pre(overlay, poseStack)) return;
|
||||
IGuiOverlay overlay = entry.overlay();
|
||||
if (pre(entry, poseStack)) return;
|
||||
overlay.render(this, poseStack, partialTick, screenWidth, screenHeight);
|
||||
post(overlay, poseStack);
|
||||
}
|
||||
catch(Exception e)
|
||||
post(entry, poseStack);
|
||||
} catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Error rendering overlay '{}'", entry.getDisplayName(), e);
|
||||
LOGGER.error("Error rendering overlay '{}'", entry.id(), e);
|
||||
}
|
||||
});
|
||||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
post(ALL, poseStack);
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGuiEvent.Post(minecraft.getWindow(), poseStack, partialTick));
|
||||
}
|
||||
|
||||
public boolean shouldDrawSurvivalElements()
|
||||
@@ -378,7 +170,7 @@ public class ForgeIngameGui extends Gui
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
private void renderSpyglassOverlay()
|
||||
void renderSpyglassOverlay()
|
||||
{
|
||||
float deltaFrame = this.minecraft.getDeltaFrameTime();
|
||||
this.scopeScale = Mth.lerp(0.5F * deltaFrame, this.scopeScale, 1.125F);
|
||||
@@ -387,14 +179,15 @@ public class ForgeIngameGui extends Gui
|
||||
if (this.minecraft.player.isScoping())
|
||||
{
|
||||
this.renderSpyglassOverlay(this.scopeScale);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
this.scopeScale = 0.5F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderHelmet(float partialTick, PoseStack poseStack)
|
||||
void renderHelmet(float partialTick, PoseStack poseStack)
|
||||
{
|
||||
ItemStack itemstack = this.minecraft.player.getInventory().getArmor(3);
|
||||
|
||||
@@ -407,14 +200,15 @@ public class ForgeIngameGui extends Gui
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderProperties.get(item).renderHelmetOverlay(itemstack, minecraft.player, this.screenWidth, this.screenHeight, partialTick);
|
||||
IClientItemExtensions.of(item).renderHelmetOverlay(itemstack, minecraft.player, this.screenWidth, this.screenHeight, partialTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFrostbite(PoseStack pStack)
|
||||
void renderFrostbite(PoseStack pStack)
|
||||
{
|
||||
if (this.minecraft.player.getTicksFrozen() > 0) {
|
||||
if (this.minecraft.player.getTicksFrozen() > 0)
|
||||
{
|
||||
this.renderTextureOverlay(POWDER_SNOW_OUTLINE_LOCATION, this.minecraft.player.getPercentFrozen());
|
||||
}
|
||||
}
|
||||
@@ -425,7 +219,7 @@ public class ForgeIngameGui extends Gui
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
int left = width / 2 - 91;
|
||||
int top = height - left_height;
|
||||
int top = height - leftHeight;
|
||||
|
||||
int level = minecraft.player.getArmorValue();
|
||||
for (int i = 1; level > 0 && i < 20; i += 2)
|
||||
@@ -444,7 +238,7 @@ public class ForgeIngameGui extends Gui
|
||||
}
|
||||
left += 8;
|
||||
}
|
||||
left_height += 10;
|
||||
leftHeight += 10;
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
minecraft.getProfiler().pop();
|
||||
@@ -464,22 +258,22 @@ public class ForgeIngameGui extends Gui
|
||||
protected void renderAir(int width, int height, PoseStack poseStack)
|
||||
{
|
||||
minecraft.getProfiler().push("air");
|
||||
Player player = (Player)this.minecraft.getCameraEntity();
|
||||
Player player = (Player) this.minecraft.getCameraEntity();
|
||||
RenderSystem.enableBlend();
|
||||
int left = width / 2 + 91;
|
||||
int top = height - right_height;
|
||||
int top = height - rightHeight;
|
||||
|
||||
int air = player.getAirSupply();
|
||||
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;
|
||||
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)
|
||||
{
|
||||
blit(poseStack, left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
|
||||
}
|
||||
right_height += 10;
|
||||
rightHeight += 10;
|
||||
}
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
@@ -492,19 +286,19 @@ public class ForgeIngameGui extends Gui
|
||||
minecraft.getProfiler().push("health");
|
||||
RenderSystem.enableBlend();
|
||||
|
||||
Player player = (Player)this.minecraft.getCameraEntity();
|
||||
Player player = (Player) this.minecraft.getCameraEntity();
|
||||
int health = Mth.ceil(player.getHealth());
|
||||
boolean highlight = healthBlinkTime > (long)tickCount && (healthBlinkTime - (long)tickCount) / 3L %2L == 1L;
|
||||
boolean highlight = healthBlinkTime > (long) tickCount && (healthBlinkTime - (long) tickCount) / 3L % 2L == 1L;
|
||||
|
||||
if (health < this.lastHealth && player.invulnerableTime > 0)
|
||||
{
|
||||
this.lastHealthTime = Util.getMillis();
|
||||
this.healthBlinkTime = (long)(this.tickCount + 20);
|
||||
this.healthBlinkTime = (long) (this.tickCount + 20);
|
||||
}
|
||||
else if (health > this.lastHealth && player.invulnerableTime > 0)
|
||||
{
|
||||
this.lastHealthTime = Util.getMillis();
|
||||
this.healthBlinkTime = (long)(this.tickCount + 10);
|
||||
this.healthBlinkTime = (long) (this.tickCount + 10);
|
||||
}
|
||||
|
||||
if (Util.getMillis() - this.lastHealthTime > 1000L)
|
||||
@@ -518,18 +312,18 @@ public class ForgeIngameGui extends Gui
|
||||
int healthLast = this.displayHealth;
|
||||
|
||||
AttributeInstance attrMaxHealth = player.getAttribute(Attributes.MAX_HEALTH);
|
||||
float healthMax = Math.max((float)attrMaxHealth.getValue(), Math.max(healthLast, health));
|
||||
float healthMax = Math.max((float) attrMaxHealth.getValue(), Math.max(healthLast, health));
|
||||
int absorb = Mth.ceil(player.getAbsorptionAmount());
|
||||
|
||||
int healthRows = Mth.ceil((healthMax + absorb) / 2.0F / 10.0F);
|
||||
int rowHeight = Math.max(10 - (healthRows - 2), 3);
|
||||
|
||||
this.random.setSeed((long)(tickCount * 312871));
|
||||
this.random.setSeed((long) (tickCount * 312871));
|
||||
|
||||
int left = width / 2 - 91;
|
||||
int top = height - left_height;
|
||||
left_height += (healthRows * rowHeight);
|
||||
if (rowHeight != 10) left_height += 10 - rowHeight;
|
||||
int top = height - leftHeight;
|
||||
leftHeight += (healthRows * rowHeight);
|
||||
if (rowHeight != 10) leftHeight += 10 - rowHeight;
|
||||
|
||||
int regen = -1;
|
||||
if (player.hasEffect(MobEffects.REGENERATION))
|
||||
@@ -547,11 +341,11 @@ public class ForgeIngameGui extends Gui
|
||||
{
|
||||
minecraft.getProfiler().push("food");
|
||||
|
||||
Player player = (Player)this.minecraft.getCameraEntity();
|
||||
Player player = (Player) this.minecraft.getCameraEntity();
|
||||
RenderSystem.enableBlend();
|
||||
int left = width / 2 + 91;
|
||||
int top = height - right_height;
|
||||
right_height += 10;
|
||||
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();
|
||||
@@ -596,14 +390,14 @@ public class ForgeIngameGui extends Gui
|
||||
RenderSystem.disableDepthTest();
|
||||
// RenderSystem.disableAlphaTest();
|
||||
int sleepTime = minecraft.player.getSleepTimer();
|
||||
float opacity = (float)sleepTime / 100.0F;
|
||||
float opacity = (float) sleepTime / 100.0F;
|
||||
|
||||
if (opacity > 1.0F)
|
||||
{
|
||||
opacity = 1.0F - (float)(sleepTime - 100) / 10.0F;
|
||||
opacity = 1.0F - (float) (sleepTime - 100) / 10.0F;
|
||||
}
|
||||
|
||||
int color = (int)(220.0F * opacity) << 24 | 1052704;
|
||||
int color = (int) (220.0F * opacity) << 24 | 1052704;
|
||||
fill(poseStack, 0, 0, width, height, color);
|
||||
// RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableDepthTest();
|
||||
@@ -643,8 +437,9 @@ public class ForgeIngameGui extends Gui
|
||||
{
|
||||
minecraft.getProfiler().push("forgeHudText");
|
||||
RenderSystem.defaultBlendFunc();
|
||||
ArrayList<String> listL = new ArrayList<String>();
|
||||
ArrayList<String> listR = new ArrayList<String>();
|
||||
|
||||
var listL = new ArrayList<String>();
|
||||
var listR = new ArrayList<String>();
|
||||
|
||||
if (minecraft.isDemo())
|
||||
{
|
||||
@@ -655,48 +450,45 @@ public class ForgeIngameGui extends Gui
|
||||
}
|
||||
else
|
||||
{
|
||||
listR.add(I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int)(120500L - time))));
|
||||
listR.add(I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int) (120500L - time))));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.minecraft.options.renderDebug && !pre(DEBUG, poseStack))
|
||||
if (this.minecraft.options.renderDebug)
|
||||
{
|
||||
debugOverlay.update();
|
||||
listL.addAll(debugOverlay.getLeft());
|
||||
listR.addAll(debugOverlay.getRight());
|
||||
post(DEBUG, poseStack);
|
||||
}
|
||||
|
||||
RenderGameOverlayEvent.Text event = new RenderGameOverlayEvent.Text(poseStack, eventParent, listL, listR);
|
||||
if (!MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
int top = 2;
|
||||
for (String msg : listL)
|
||||
{
|
||||
if (msg != null && !msg.isEmpty())
|
||||
{
|
||||
fill(poseStack, 1, top - 1, 2 + font.width(msg) + 1, top + font.lineHeight - 1, -1873784752);
|
||||
font.draw(poseStack, msg, 2, top, 14737632);
|
||||
}
|
||||
top += font.lineHeight;
|
||||
}
|
||||
var event = new CustomizeGuiOverlayEvent.DebugText(minecraft.getWindow(), poseStack, minecraft.getFrameTime(), listL, listR);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
top = 2;
|
||||
for (String msg : listR)
|
||||
int top = 2;
|
||||
for (String msg : listL)
|
||||
{
|
||||
if (msg != null && !msg.isEmpty())
|
||||
{
|
||||
if (msg != null && !msg.isEmpty())
|
||||
{
|
||||
int w = font.width(msg);
|
||||
int left = width - 2 - w;
|
||||
fill(poseStack, left - 1, top - 1, left + w + 1, top + font.lineHeight - 1, -1873784752);
|
||||
font.draw(poseStack, msg, left, top, 14737632);
|
||||
}
|
||||
top += font.lineHeight;
|
||||
fill(poseStack, 1, top - 1, 2 + font.width(msg) + 1, top + font.lineHeight - 1, -1873784752);
|
||||
font.draw(poseStack, msg, 2, top, 14737632);
|
||||
}
|
||||
top += font.lineHeight;
|
||||
}
|
||||
|
||||
top = 2;
|
||||
for (String msg : listR)
|
||||
{
|
||||
if (msg != null && !msg.isEmpty())
|
||||
{
|
||||
int w = font.width(msg);
|
||||
int left = width - 2 - w;
|
||||
fill(poseStack, left - 1, top - 1, left + w + 1, top + font.lineHeight - 1, -1873784752);
|
||||
font.draw(poseStack, msg, left, top, 14737632);
|
||||
}
|
||||
top += font.lineHeight;
|
||||
}
|
||||
|
||||
minecraft.getProfiler().pop();
|
||||
post(TEXT, poseStack);
|
||||
}
|
||||
|
||||
protected void renderFPSGraph(PoseStack poseStack)
|
||||
@@ -712,8 +504,8 @@ public class ForgeIngameGui extends Gui
|
||||
if (overlayMessageTime > 0)
|
||||
{
|
||||
minecraft.getProfiler().push("overlayMessage");
|
||||
float hue = (float)overlayMessageTime - partialTick;
|
||||
int opacity = (int)(hue * 255.0F / 20.0F);
|
||||
float hue = (float) overlayMessageTime - partialTick;
|
||||
int opacity = (int) (hue * 255.0F / 20.0F);
|
||||
if (opacity > 255) opacity = 255;
|
||||
|
||||
if (opacity > 8)
|
||||
@@ -738,15 +530,15 @@ public class ForgeIngameGui extends Gui
|
||||
if (title != null && titleTime > 0)
|
||||
{
|
||||
minecraft.getProfiler().push("titleAndSubtitle");
|
||||
float age = (float)this.titleTime - partialTick;
|
||||
float age = (float) this.titleTime - partialTick;
|
||||
int opacity = 255;
|
||||
|
||||
if (titleTime > titleFadeOutTime + titleStayTime)
|
||||
{
|
||||
float f3 = (float)(titleFadeInTime + titleStayTime + titleFadeOutTime) - age;
|
||||
opacity = (int)(f3 * 255.0F / (float)titleFadeInTime);
|
||||
float f3 = (float) (titleFadeInTime + titleStayTime + titleFadeOutTime) - age;
|
||||
opacity = (int) (f3 * 255.0F / (float) titleFadeInTime);
|
||||
}
|
||||
if (titleTime <= titleFadeOutTime) opacity = (int)(age * 255.0F / (float)this.titleFadeOutTime);
|
||||
if (titleTime <= titleFadeOutTime) opacity = (int) (age * 255.0F / (float) this.titleFadeOutTime);
|
||||
|
||||
opacity = Mth.clamp(opacity, 0, 255);
|
||||
|
||||
@@ -759,13 +551,13 @@ public class ForgeIngameGui extends Gui
|
||||
pStack.pushPose();
|
||||
pStack.scale(4.0F, 4.0F, 4.0F);
|
||||
int l = opacity << 24 & -16777216;
|
||||
this.getFont().drawShadow(pStack, this.title.getVisualOrderText(), (float)(-this.getFont().width(this.title) / 2), -10.0F, 16777215 | l);
|
||||
this.getFont().drawShadow(pStack, this.title.getVisualOrderText(), (float) (-this.getFont().width(this.title) / 2), -10.0F, 16777215 | l);
|
||||
pStack.popPose();
|
||||
if (this.subtitle != null)
|
||||
{
|
||||
pStack.pushPose();
|
||||
pStack.scale(2.0F, 2.0F, 2.0F);
|
||||
this.getFont().drawShadow(pStack, this.subtitle.getVisualOrderText(), (float)(-this.getFont().width(this.subtitle) / 2), 5.0F, 16777215 | l);
|
||||
this.getFont().drawShadow(pStack, this.subtitle.getVisualOrderText(), (float) (-this.getFont().width(this.subtitle) / 2), 5.0F, 16777215 | l);
|
||||
pStack.popPose();
|
||||
}
|
||||
RenderSystem.disableBlend();
|
||||
@@ -780,16 +572,14 @@ public class ForgeIngameGui extends Gui
|
||||
{
|
||||
minecraft.getProfiler().push("chat");
|
||||
|
||||
RenderGameOverlayEvent.Chat event = new RenderGameOverlayEvent.Chat(pStack, eventParent, 0, height - 48);
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) return;
|
||||
var event = new CustomizeGuiOverlayEvent.Chat(minecraft.getWindow(), pStack, minecraft.getFrameTime(), 0, height - 48);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
pStack.pushPose();
|
||||
pStack.translate(event.getPosX(), event.getPosY(), 0.0D);
|
||||
chat.render(pStack, tickCount);
|
||||
pStack.popPose();
|
||||
|
||||
post(CHAT, pStack);
|
||||
|
||||
minecraft.getProfiler().pop();
|
||||
}
|
||||
|
||||
@@ -801,9 +591,8 @@ public class ForgeIngameGui extends Gui
|
||||
if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null))
|
||||
{
|
||||
this.tabList.setVisible(true);
|
||||
if (pre(PLAYER_LIST, poseStack)) return;
|
||||
this.tabList.render(poseStack, width, this.minecraft.level.getScoreboard(), scoreobjective);
|
||||
post(PLAYER_LIST, poseStack);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -813,7 +602,7 @@ public class ForgeIngameGui extends Gui
|
||||
|
||||
protected void renderHealthMount(int width, int height, PoseStack poseStack)
|
||||
{
|
||||
Player player = (Player)minecraft.getCameraEntity();
|
||||
Player player = (Player) minecraft.getCameraEntity();
|
||||
Entity tmp = player.getVehicle();
|
||||
if (!(tmp instanceof LivingEntity)) return;
|
||||
|
||||
@@ -824,10 +613,10 @@ public class ForgeIngameGui extends Gui
|
||||
|
||||
minecraft.getProfiler().popPush("mountHealth");
|
||||
RenderSystem.enableBlend();
|
||||
LivingEntity mount = (LivingEntity)tmp;
|
||||
int health = (int)Math.ceil((double)mount.getHealth());
|
||||
LivingEntity mount = (LivingEntity) tmp;
|
||||
int health = (int) Math.ceil((double) mount.getHealth());
|
||||
float healthMax = mount.getMaxHealth();
|
||||
int hearts = (int)(healthMax + 0.5F) / 2;
|
||||
int hearts = (int) (healthMax + 0.5F) / 2;
|
||||
|
||||
if (hearts > 30) hearts = 30;
|
||||
|
||||
@@ -838,7 +627,7 @@ public class ForgeIngameGui extends Gui
|
||||
|
||||
for (int heart = 0; hearts > 0; heart += 20)
|
||||
{
|
||||
int top = height - right_height;
|
||||
int top = height - rightHeight;
|
||||
|
||||
int rowCount = Math.min(hearts, 10);
|
||||
hearts -= rowCount;
|
||||
@@ -854,49 +643,50 @@ public class ForgeIngameGui extends Gui
|
||||
blit(poseStack, x, top, HALF, 9, 9, 9);
|
||||
}
|
||||
|
||||
right_height += 10;
|
||||
rightHeight += 10;
|
||||
}
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
//Helper macros
|
||||
private boolean pre(ElementType type, PoseStack poseStack)
|
||||
private boolean pre(NamedGuiOverlay overlay, PoseStack poseStack)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Pre(poseStack, eventParent, type));
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Pre(minecraft.getWindow(), poseStack, minecraft.getFrameTime(), overlay));
|
||||
}
|
||||
private void post(ElementType type, PoseStack poseStack)
|
||||
|
||||
private void post(NamedGuiOverlay overlay, PoseStack poseStack)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(poseStack, eventParent, type));
|
||||
}
|
||||
private boolean pre(IIngameOverlay overlay, PoseStack poseStack)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.PreLayer(poseStack, eventParent, overlay));
|
||||
}
|
||||
private void post(IIngameOverlay overlay, PoseStack poseStack)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.PostLayer(poseStack, eventParent, overlay));
|
||||
MinecraftForge.EVENT_BUS.post(new RenderGuiOverlayEvent.Post(minecraft.getWindow(), poseStack, minecraft.getFrameTime(), overlay));
|
||||
}
|
||||
|
||||
private void bind(ResourceLocation res)
|
||||
{
|
||||
RenderSystem.setShaderTexture(0, res);
|
||||
}
|
||||
|
||||
private class ForgeDebugScreenOverlay extends DebugScreenOverlay
|
||||
private static class ForgeDebugScreenOverlay extends DebugScreenOverlay
|
||||
{
|
||||
private Minecraft mc;
|
||||
private final Minecraft mc;
|
||||
|
||||
private ForgeDebugScreenOverlay(Minecraft mc)
|
||||
{
|
||||
super(mc);
|
||||
this.mc = mc;
|
||||
}
|
||||
|
||||
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(PoseStack poseStack){}
|
||||
@Override protected void drawSystemInformation(PoseStack poseStack){}
|
||||
|
||||
@Override
|
||||
protected void drawGameInformation(PoseStack poseStack) {}
|
||||
|
||||
@Override
|
||||
protected void drawSystemInformation(PoseStack poseStack) {}
|
||||
|
||||
private List<String> getLeft()
|
||||
{
|
||||
List<String> ret = this.getGameInformation();
|
||||
@@ -906,6 +696,10 @@ public class ForgeIngameGui extends Gui
|
||||
ret.add("For help: press F3 + Q");
|
||||
return ret;
|
||||
}
|
||||
private List<String> getRight(){ return this.getSystemInformation(); }
|
||||
|
||||
private List<String> getRight()
|
||||
{
|
||||
return this.getSystemInformation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui.overlay;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Manager for {@linkplain IGuiOverlay HUD overlays}.
|
||||
* <p>
|
||||
* Provides a lookup by ID, as well as all registered {@link IGuiOverlay overlays}.
|
||||
*/
|
||||
public final class GuiOverlayManager
|
||||
{
|
||||
private static ImmutableList<NamedGuiOverlay> OVERLAYS;
|
||||
private static ImmutableMap<ResourceLocation, NamedGuiOverlay> OVERLAYS_BY_NAME;
|
||||
|
||||
/**
|
||||
* Retrieves an ordered list of all registered overlays.
|
||||
*/
|
||||
public static ImmutableList<NamedGuiOverlay> getOverlays()
|
||||
{
|
||||
return OVERLAYS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the overlay corresponding to a given ID.
|
||||
* Do not call this before {@link RegisterGuiOverlaysEvent} has finished firing.
|
||||
*/
|
||||
@Nullable
|
||||
public static NamedGuiOverlay findOverlay(ResourceLocation id)
|
||||
{
|
||||
return OVERLAYS_BY_NAME.get(id);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void init()
|
||||
{
|
||||
var overlays = new HashMap<ResourceLocation, IGuiOverlay>();
|
||||
var orderedOverlays = new ArrayList<ResourceLocation>();
|
||||
preRegisterVanillaOverlays(overlays, orderedOverlays);
|
||||
var event = new RegisterGuiOverlaysEvent(overlays, orderedOverlays);
|
||||
ModLoader.get().postEventWithWrapInModOrder(event, (mc, e) -> ModLoadingContext.get().setActiveContainer(mc), (mc, e) -> ModLoadingContext.get().setActiveContainer(null));
|
||||
OVERLAYS = orderedOverlays.stream()
|
||||
.map(id -> new NamedGuiOverlay(id, overlays.get(id)))
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
OVERLAYS_BY_NAME = OVERLAYS.stream()
|
||||
.collect(ImmutableMap.toImmutableMap(NamedGuiOverlay::id, Function.identity()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-registers vanilla overlays so they are available for ordering.
|
||||
*/
|
||||
private static void preRegisterVanillaOverlays(HashMap<ResourceLocation, IGuiOverlay> overlays, ArrayList<ResourceLocation> orderedOverlays)
|
||||
{
|
||||
for (var entry : VanillaGuiOverlay.values())
|
||||
{
|
||||
overlays.put(entry.id(), entry.overlay);
|
||||
orderedOverlays.add(entry.id());
|
||||
}
|
||||
}
|
||||
|
||||
private GuiOverlayManager()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui.overlay;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
|
||||
|
||||
/**
|
||||
* A HUD overlay.
|
||||
*
|
||||
* @see RegisterGuiOverlaysEvent
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IGuiOverlay
|
||||
{
|
||||
void render(ForgeGui gui, PoseStack poseStack, float partialTick, int width, int height);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui.overlay;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* An object representation of an {@link IGuiOverlay overlay} with a name.
|
||||
* <p>
|
||||
* Useful to identify overlays in {@link net.minecraftforge.client.event.RenderGuiOverlayEvent}.
|
||||
* <p>
|
||||
* Users should not be instantiating this themselves. Retrieve from {@link GuiOverlayManager}.
|
||||
*/
|
||||
public record NamedGuiOverlay(ResourceLocation id, IGuiOverlay overlay)
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public NamedGuiOverlay
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui.overlay;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* All the vanilla {@linkplain IGuiOverlay HUD overlays} in the order that they render.
|
||||
*/
|
||||
public enum VanillaGuiOverlay
|
||||
{
|
||||
VIGNETTE("vignette", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (Minecraft.useFancyGraphics())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderVignette(gui.getMinecraft().getCameraEntity());
|
||||
}
|
||||
}),
|
||||
SPYGLASS("spyglass", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderSpyglassOverlay();
|
||||
}),
|
||||
HELMET("helmet", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHelmet(partialTick, poseStack);
|
||||
}),
|
||||
FROSTBITE("frostbite", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderFrostbite(poseStack);
|
||||
}),
|
||||
PORTAL("portal", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
if (!gui.getMinecraft().player.hasEffect(MobEffects.CONFUSION))
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderPortalOverlay(partialTick);
|
||||
}
|
||||
|
||||
}),
|
||||
HOTBAR("hotbar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
if (gui.getMinecraft().gameMode.getPlayerMode() == GameType.SPECTATOR)
|
||||
{
|
||||
gui.getSpectatorGui().renderHotbar(poseStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui.renderHotbar(partialTick, poseStack);
|
||||
}
|
||||
}
|
||||
}),
|
||||
CROSSHAIR("crosshair", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.setBlitOffset(-90);
|
||||
|
||||
gui.renderCrosshair(poseStack);
|
||||
}
|
||||
}),
|
||||
BOSS_EVENT_PROGRESS("boss_event_progress", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.setBlitOffset(-90);
|
||||
|
||||
gui.renderBossHealth(poseStack);
|
||||
}
|
||||
}),
|
||||
PLAYER_HEALTH("player_health", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHealth(screenWidth, screenHeight, poseStack);
|
||||
}
|
||||
}),
|
||||
ARMOR_LEVEL("armor_level", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderArmor(poseStack, screenWidth, screenHeight);
|
||||
}
|
||||
}),
|
||||
FOOD_LEVEL("food_level", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
boolean isMounted = gui.getMinecraft().player.getVehicle() instanceof LivingEntity;
|
||||
if (!isMounted && !gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderFood(screenWidth, screenHeight, poseStack);
|
||||
}
|
||||
}),
|
||||
MOUNT_HEALTH("mount_health", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderHealthMount(screenWidth, screenHeight, poseStack);
|
||||
}
|
||||
}),
|
||||
AIR_LEVEL("air_level", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui && gui.shouldDrawSurvivalElements())
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderAir(screenWidth, screenHeight, poseStack);
|
||||
}
|
||||
}),
|
||||
JUMP_BAR("jump_bar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (gui.getMinecraft().player.isRidingJumpable() && !gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderJumpMeter(poseStack, screenWidth / 2 - 91);
|
||||
}
|
||||
}),
|
||||
EXPERIENCE_BAR("experience_bar", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().player.isRidingJumpable() && !gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
gui.renderExperience(screenWidth / 2 - 91, poseStack);
|
||||
}
|
||||
}),
|
||||
ITEM_NAME("item_name", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.setupOverlayRenderState(true, false);
|
||||
if (gui.getMinecraft().options.heldItemTooltips && gui.getMinecraft().gameMode.getPlayerMode() != GameType.SPECTATOR)
|
||||
{
|
||||
gui.renderSelectedItemName(poseStack);
|
||||
}
|
||||
else if (gui.getMinecraft().player.isSpectator())
|
||||
{
|
||||
gui.getSpectatorGui().renderTooltip(poseStack);
|
||||
}
|
||||
}
|
||||
}),
|
||||
SLEEP_FADE("sleep_fade", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderSleepFade(screenWidth, screenHeight, poseStack);
|
||||
}),
|
||||
DEBUG_TEXT("debug_text", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderHUDText(screenWidth, screenHeight, poseStack);
|
||||
}),
|
||||
FPS_GRAPH("fps_graph", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderFPSGraph(poseStack);
|
||||
}),
|
||||
POTION_ICONS("potion_icons", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
gui.renderEffects(poseStack);
|
||||
}),
|
||||
RECORD_OVERLAY("record_overlay", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderRecordOverlay(screenWidth, screenHeight, partialTick, poseStack);
|
||||
}
|
||||
}),
|
||||
SUBTITLES("subtitles", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderSubtitles(poseStack);
|
||||
}
|
||||
}),
|
||||
TITLE_TEXT("title_text", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
if (!gui.getMinecraft().options.hideGui)
|
||||
{
|
||||
gui.renderTitle(screenWidth, screenHeight, partialTick, poseStack);
|
||||
}
|
||||
}),
|
||||
SCOREBOARD("scoreboard", (gui, poseStack, 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);
|
||||
}
|
||||
Objective scoreobjective1 = objective != null ? objective : scoreboard.getDisplayObjective(1);
|
||||
if (scoreobjective1 != null)
|
||||
{
|
||||
gui.displayScoreboardSidebar(poseStack, scoreobjective1);
|
||||
}
|
||||
}),
|
||||
CHAT_PANEL("chat_panel", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
gui.renderChat(screenWidth, screenHeight, poseStack);
|
||||
}),
|
||||
PLAYER_LIST("player_list", (gui, poseStack, partialTick, screenWidth, screenHeight) -> {
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
gui.renderPlayerList(screenWidth, screenHeight, poseStack);
|
||||
});
|
||||
|
||||
private final ResourceLocation id;
|
||||
final IGuiOverlay overlay;
|
||||
|
||||
VanillaGuiOverlay(String id, IGuiOverlay overlay)
|
||||
{
|
||||
this.id = new ResourceLocation("minecraft", id);
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ResourceLocation id()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.client.gui.GuiUtils;
|
||||
import net.minecraftforge.client.gui.ScreenUtils;
|
||||
|
||||
/**
|
||||
* This class provides a button that fixes several bugs present in the vanilla GuiButton drawing code.
|
||||
@@ -36,7 +36,7 @@ public class ExtendedButton extends Button
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
int k = this.getYImage(this.isHovered);
|
||||
GuiUtils.drawContinuousTexturedBox(poseStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
|
||||
ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
|
||||
this.renderBg(poseStack, mc, mouseX, mouseY);
|
||||
|
||||
Component buttonText = this.getMessage();
|
||||
|
||||
+3
-2
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
package net.minecraftforge.client.gui.widget;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraftforge.client.gui.ScreenUtils;
|
||||
|
||||
/**
|
||||
* Abstract scroll panel class.
|
||||
@@ -367,7 +368,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
|
||||
protected void drawGradientRect(PoseStack poseStack, int left, int top, int right, int bottom, int color1, int color2)
|
||||
{
|
||||
GuiUtils.drawGradientRect(poseStack.last().pose(), 0, left, top, right, bottom, color1, color2);
|
||||
ScreenUtils.drawGradientRect(poseStack.last().pose(), 0, left, top, right, bottom, color1, color2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -9,7 +9,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.client.gui.GuiUtils;
|
||||
import net.minecraftforge.client.gui.ScreenUtils;
|
||||
|
||||
/**
|
||||
* This class provides a button that shows a string glyph at the beginning. The glyph can be scaled using the glyphScale parameter.
|
||||
@@ -36,7 +36,7 @@ public class UnicodeGlyphButton extends ExtendedButton
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||
int k = this.getYImage(this.isHovered);
|
||||
GuiUtils.drawContinuousTexturedBox(poseStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
|
||||
ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
|
||||
this.renderBg(poseStack, mc, mouseX, mouseY);
|
||||
|
||||
Component buttonText = this.createNarrationMessage();
|
||||
|
||||
Loaded 100 of 295 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user