mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 14:34:28 +00:00
Minecraft 1.21.4
This commit is contained in:
219 files changed
+1841
-2621
No files matched your search
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.renderer.special.SpecialModelRenderer;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class CreateSpecialBlockRendererEvent extends Event {
|
||||
private final Map<Block, SpecialModelRenderer.Unbaked> map;
|
||||
|
||||
public CreateSpecialBlockRendererEvent(Map<Block, SpecialModelRenderer.Unbaked> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public void register(Block block, SpecialModelRenderer.Unbaked renderer) {
|
||||
this.map.put(block, renderer);
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@@ -201,20 +202,11 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* 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;
|
||||
private final ImmutableMap.Builder<Type, Function<EntityModelSet, SkullModelBase>> builder;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public CreateSkullModels(ImmutableMap.Builder<Type, SkullModelBase> builder, EntityModelSet entityModelSet) {
|
||||
public CreateSkullModels(ImmutableMap.Builder<Type, Function<EntityModelSet, SkullModelBase>> builder) {
|
||||
this.builder = builder;
|
||||
this.entityModelSet = entityModelSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the set of entity models}
|
||||
*/
|
||||
public EntityModelSet getEntityModelSet() {
|
||||
return entityModelSet;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +220,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* {@link EntityModelSet#bakeLayer(ModelLayerLocation)} and pass it to the constructor for
|
||||
* {@link SkullModel}.
|
||||
*/
|
||||
public void registerSkullModel(SkullBlock.Type type, SkullModelBase model) {
|
||||
public void registerSkullModel(SkullBlock.Type type, Function<EntityModelSet, SkullModelBase> model) {
|
||||
builder.put(type, model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ package net.minecraftforge.client.event;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -17,6 +19,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
@@ -32,6 +35,8 @@ import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.model.SkullModelBase;
|
||||
import net.minecraft.client.model.geom.EntityModelSet;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
@@ -45,6 +50,7 @@ import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
||||
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
|
||||
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
|
||||
import net.minecraft.client.renderer.entity.state.PlayerRenderState;
|
||||
import net.minecraft.client.renderer.special.SpecialModelRenderer;
|
||||
import net.minecraft.client.resources.PlayerSkin.Model;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
@@ -57,6 +63,8 @@ import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.SkullBlock.Type;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundSourceEvent;
|
||||
import net.minecraftforge.client.event.sound.PlayStreamingSourceEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -86,8 +94,9 @@ public final class ForgeEventFactoryClient {
|
||||
/**
|
||||
* Post an event to the {@link ModLoader#get()} event bus
|
||||
*/
|
||||
private static <T extends Event & IModBusEvent> void postModBus(T e) {
|
||||
private static <T extends Event & IModBusEvent> T postModBus(T e) {
|
||||
ML.postEvent(e);
|
||||
return e;
|
||||
}
|
||||
|
||||
public static void onGatherLayers(Map<EntityType<?>, EntityRenderer<?, ?>> renderers, Map<Model, EntityRenderer<? extends Player, ?>> playerRenderers, Context context) {
|
||||
@@ -279,4 +288,14 @@ public final class ForgeEventFactoryClient {
|
||||
public static ComputeFovModifierEvent fireFovModifierEvent(Player entity, float modifier, float scale) {
|
||||
return fire(new ComputeFovModifierEvent(entity, modifier, scale));
|
||||
}
|
||||
|
||||
public static void onCreateSpecialBlockRenderers(Map<Block, SpecialModelRenderer.Unbaked> map) {
|
||||
post(new CreateSpecialBlockRendererEvent(map));
|
||||
}
|
||||
|
||||
public static Map<Type, Function<EntityModelSet, SkullModelBase>> onCreateSkullModels() {
|
||||
var builder = ImmutableMap.<Type, Function<EntityModelSet, SkullModelBase>>builder();
|
||||
postModBus(new EntityRenderersEvent.CreateSkullModels(builder));
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
@@ -46,20 +46,20 @@ public abstract class ModelEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class ModifyBakingResult extends ModelEvent implements IModBusEvent {
|
||||
private final Map<ModelResourceLocation, BakedModel> models;
|
||||
private final ModelBakery modelBakery;
|
||||
private final ModelBakery.BakingResult results;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ModifyBakingResult(Map<ModelResourceLocation, BakedModel> models, ModelBakery modelBakery) {
|
||||
this.models = models;
|
||||
public ModifyBakingResult(ModelBakery modelBakery, ModelBakery.BakingResult results) {
|
||||
this.modelBakery = modelBakery;
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modifiable registry map of models and their model names
|
||||
*/
|
||||
public Map<ModelResourceLocation, BakedModel> getModels() {
|
||||
return models;
|
||||
public ModelBakery.BakingResult getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,13 +83,11 @@ public abstract class ModelEvent extends Event {
|
||||
*/
|
||||
public static class BakingCompleted extends ModelEvent implements IModBusEvent {
|
||||
private final ModelManager modelManager;
|
||||
private final Map<ModelResourceLocation, BakedModel> models;
|
||||
private final ModelBakery modelBakery;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BakingCompleted(ModelManager modelManager, Map<ModelResourceLocation, BakedModel> models, ModelBakery modelBakery) {
|
||||
public BakingCompleted(ModelManager modelManager, ModelBakery modelBakery) {
|
||||
this.modelManager = modelManager;
|
||||
this.models = models;
|
||||
this.modelBakery = modelBakery;
|
||||
}
|
||||
|
||||
@@ -100,13 +98,6 @@ public abstract class ModelEvent extends Event {
|
||||
return modelManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unmodifiable view of the registry map of models and their model names
|
||||
*/
|
||||
public Map<ModelResourceLocation, BakedModel> getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the model loader
|
||||
*/
|
||||
|
||||
@@ -8,11 +8,8 @@ package net.minecraftforge.client.event;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
@@ -71,56 +68,6 @@ public abstract class RegisterColorHandlersEvent extends Event implements IModBu
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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 fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Item extends RegisterColorHandlersEvent {
|
||||
private final ItemColors itemColors;
|
||||
private final BlockColors blockColors;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Item(ItemColors itemColors, BlockColors blockColors) {
|
||||
this.itemColors = itemColors;
|
||||
this.blockColors = blockColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the item colors registry}
|
||||
*
|
||||
* @see ItemColors#register(ItemColor, ItemLike...)
|
||||
*/
|
||||
public ItemColors getItemColors() {
|
||||
return itemColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the block colors registry}
|
||||
* This should only be used for referencing or delegating item colors to their respective block colors.
|
||||
*/
|
||||
public BlockColors getBlockColors() {
|
||||
return blockColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link ItemColor} instance for a set of blocks.
|
||||
*
|
||||
* @param itemColor The color provider
|
||||
* @param items The items
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void register(ItemColor itemColor, ItemLike... items) {
|
||||
itemColors.register(itemColor, items);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows registration of custom {@link ColorResolver} implementations to be used with
|
||||
* {@link net.minecraft.world.level.BlockAndTintGetter#getBlockTint(BlockPos, ColorResolver)}.
|
||||
|
||||
+6
-4
@@ -6,6 +6,8 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BiMap;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -16,8 +18,6 @@ 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}.
|
||||
*
|
||||
@@ -27,10 +27,10 @@ import java.util.Map;
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterTextureAtlasSpriteLoadersEvent extends Event implements IModBusEvent {
|
||||
private final Map<ResourceLocation, ITextureAtlasSpriteLoader> loaders;
|
||||
private final BiMap<ResourceLocation, ITextureAtlasSpriteLoader> loaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public RegisterTextureAtlasSpriteLoadersEvent(Map<ResourceLocation, ITextureAtlasSpriteLoader> loaders) {
|
||||
public RegisterTextureAtlasSpriteLoadersEvent(BiMap<ResourceLocation, ITextureAtlasSpriteLoader> loaders) {
|
||||
this.loaders = loaders;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,10 @@ public class RegisterTextureAtlasSpriteLoadersEvent extends Event implements IMo
|
||||
* Registers a custom {@link ITextureAtlasSpriteLoader sprite loader}.
|
||||
*/
|
||||
public void register(String name, ITextureAtlasSpriteLoader loader) {
|
||||
@SuppressWarnings("removal")
|
||||
var key = ResourceLocation.fromNamespaceAndPath(ModLoadingContext.get().getActiveNamespace(), name);
|
||||
Preconditions.checkArgument(!loaders.containsKey(key), "Sprite loader already registered: " + key);
|
||||
Preconditions.checkArgument(!loaders.containsValue(loader), "Sprite loader already registered as " + loaders.inverse().get(loader));
|
||||
loaders.put(key, loader);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
|
||||
import net.minecraft.client.renderer.entity.state.ItemFrameRenderState;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -46,13 +45,6 @@ public class RenderItemInFrameEvent extends Event {
|
||||
this.packedLight = packedLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the item stack being rendered}
|
||||
*/
|
||||
public ItemStack getItemStack() {
|
||||
return getItemFrameState().itemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the item frame entity}
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user