mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 20:22:28 +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
@@ -9,7 +9,6 @@ import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -20,7 +19,6 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -39,14 +37,17 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.ChunkRenderTypeSet;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.model.*;
|
||||
import net.minecraftforge.client.model.data.*;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.client.model.geometry.IUnbakedGeometry;
|
||||
import net.minecraftforge.common.util.ConcatenatedListView;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
@@ -167,13 +168,13 @@ public class FullPotsAccessorDemo
|
||||
{
|
||||
public static final ModelProperty<Block> PLANT_PROPERTY = new ModelProperty<>();
|
||||
|
||||
private final IModelData modelData = new ModelDataMap.Builder().build();
|
||||
private ModelData modelData;
|
||||
private Block plant = Blocks.AIR;
|
||||
|
||||
public DioriteFlowerPotBlockEntity(BlockPos pos, BlockState state)
|
||||
{
|
||||
super(DIORITE_POT_BLOCK_ENTITY.get(), pos, state);
|
||||
modelData.setData(PLANT_PROPERTY, plant);
|
||||
modelData = ModelData.builder().with(PLANT_PROPERTY, plant).build();
|
||||
}
|
||||
|
||||
public void setPlant(Block plant)
|
||||
@@ -187,7 +188,7 @@ public class FullPotsAccessorDemo
|
||||
public Block getPlant() { return plant; }
|
||||
|
||||
@Override
|
||||
public IModelData getModelData() { return modelData; }
|
||||
public ModelData getModelData() {return modelData; }
|
||||
|
||||
@Override
|
||||
public CompoundTag getUpdateTag()
|
||||
@@ -199,7 +200,7 @@ public class FullPotsAccessorDemo
|
||||
public void handleUpdateTag(CompoundTag tag)
|
||||
{
|
||||
super.handleUpdateTag(tag);
|
||||
modelData.setData(PLANT_PROPERTY, plant);
|
||||
modelData = modelData.derive().with(PLANT_PROPERTY, plant).build();
|
||||
requestModelDataUpdate();
|
||||
}
|
||||
|
||||
@@ -237,42 +238,31 @@ public class FullPotsAccessorDemo
|
||||
private static class ClientHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(final FMLClientSetupEvent event)
|
||||
public static void registerLoader(final ModelEvent.RegisterGeometryLoaders event)
|
||||
{
|
||||
if (!ENABLED) { return; }
|
||||
|
||||
ItemBlockRenderTypes.setRenderLayer(DIORITE_POT.get(), RenderType.cutout());
|
||||
event.register("diorite_pot", new DioritePotGeometryLoader());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerLoader(final ModelRegistryEvent event)
|
||||
{
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(MOD_ID, "diorite_pot"), new DioritePotModelLoader());
|
||||
}
|
||||
|
||||
private static class DioritePotModelLoader implements IModelLoader<DioritePotModelGeometry>
|
||||
private static class DioritePotGeometryLoader implements IGeometryLoader<DioritePotModelGeometry>
|
||||
{
|
||||
@Override
|
||||
public void onResourceManagerReload(ResourceManager manager) { }
|
||||
|
||||
@Override
|
||||
public DioritePotModelGeometry read(JsonDeserializationContext context, JsonObject modelContents)
|
||||
public DioritePotModelGeometry read(JsonObject jsonObject, JsonDeserializationContext deserializationContext)
|
||||
{
|
||||
JsonObject wrappedModel = modelContents.getAsJsonObject("model");
|
||||
return new DioritePotModelGeometry(context.deserialize(wrappedModel, BlockModel.class));
|
||||
JsonObject wrappedModel = jsonObject.getAsJsonObject("model");
|
||||
return new DioritePotModelGeometry(deserializationContext.deserialize(wrappedModel, BlockModel.class));
|
||||
}
|
||||
}
|
||||
|
||||
private record DioritePotModelGeometry(UnbakedModel wrappedModel) implements IModelGeometry<DioritePotModelGeometry>
|
||||
private record DioritePotModelGeometry(UnbakedModel wrappedModel) implements IUnbakedGeometry<DioritePotModelGeometry>
|
||||
{
|
||||
@Override
|
||||
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<net.minecraft.client.resources.model.Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
public BakedModel bake(IGeometryBakingContext context, ModelBakery bakery, Function<net.minecraft.client.resources.model.Material, TextureAtlasSprite> spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation)
|
||||
{
|
||||
return new DioritePotModel(wrappedModel.bake(bakery, spriteGetter, modelTransform, modelLocation));
|
||||
return new DioritePotModel(wrappedModel.bake(bakery, spriteGetter, modelState, modelLocation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<net.minecraft.client.resources.model.Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection<net.minecraft.client.resources.model.Material> getMaterials(IGeometryBakingContext context, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
return wrappedModel.getMaterials(modelGetter, missingTextureErrors);
|
||||
}
|
||||
@@ -280,6 +270,7 @@ public class FullPotsAccessorDemo
|
||||
|
||||
private static class DioritePotModel extends BakedModelWrapper<BakedModel>
|
||||
{
|
||||
private static final ChunkRenderTypeSet CUTOUT = ChunkRenderTypeSet.of(RenderType.cutout());
|
||||
private static final ResourceLocation POT_TEXTURE = new ResourceLocation("minecraft:block/flower_pot");
|
||||
private static final ResourceLocation DIRT_TEXTURE = new ResourceLocation("minecraft:block/dirt");
|
||||
|
||||
@@ -287,30 +278,37 @@ public class FullPotsAccessorDemo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull IModelData extraData)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData extraData, @Nullable RenderType renderType)
|
||||
{
|
||||
List<BakedQuad> quads = new ArrayList<>(originalModel.getQuads(state, side, rand, extraData));
|
||||
List<List<BakedQuad>> quads = new ArrayList<>();
|
||||
quads.add(originalModel.getQuads(state, side, rand, extraData, renderType));
|
||||
|
||||
Block plant = extraData.getData(DioriteFlowerPotBlockEntity.PLANT_PROPERTY);
|
||||
Block plant = extraData.get(DioriteFlowerPotBlockEntity.PLANT_PROPERTY);
|
||||
if (plant != null && plant != Blocks.AIR)
|
||||
{
|
||||
quads.addAll(getPlantQuads(plant, side, rand));
|
||||
quads.add(getPlantQuads(plant, side, rand, renderType));
|
||||
}
|
||||
|
||||
return quads;
|
||||
return ConcatenatedListView.of(quads);
|
||||
}
|
||||
|
||||
private List<BakedQuad> getPlantQuads(Block plant, @Nullable Direction face, RandomSource rand)
|
||||
private List<BakedQuad> getPlantQuads(Block plant, @Nullable Direction face, RandomSource rand, @Nullable RenderType renderType)
|
||||
{
|
||||
BlockState potState = ((FlowerPotBlock) Blocks.FLOWER_POT).getFullPotsView().getOrDefault(ForgeRegistries.BLOCKS.getKey(plant), ForgeRegistries.BLOCKS.getDelegateOrThrow(Blocks.AIR)).get().defaultBlockState();
|
||||
BakedModel potModel = Minecraft.getInstance().getBlockRenderer().getBlockModel(potState);
|
||||
|
||||
return potModel.getQuads(potState, face, rand, EmptyModelData.INSTANCE)
|
||||
return potModel.getQuads(potState, face, rand, ModelData.EMPTY, renderType)
|
||||
.stream()
|
||||
.filter(q -> !q.getSprite().getName().equals(POT_TEXTURE))
|
||||
.filter(q -> !q.getSprite().getName().equals(DIRT_TEXTURE))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkRenderTypeSet getRenderTypes(@NotNull BlockState state, @NotNull RandomSource rand, @NotNull ModelData data)
|
||||
{
|
||||
return CUTOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Item.Properties;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderProperties;
|
||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -62,12 +62,12 @@ public class CustomArmorModelTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeClient(Consumer<IItemRenderProperties> consumer)
|
||||
public void initializeClient(Consumer<IClientItemExtensions> consumer)
|
||||
{
|
||||
consumer.accept(new IItemRenderProperties()
|
||||
consumer.accept(new IClientItemExtensions()
|
||||
{
|
||||
@Override @NotNull
|
||||
public Model getBaseArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
public Model getGenericArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
{
|
||||
TintedArmorModel.INSTANCE.base = _default;
|
||||
return TintedArmorModel.INSTANCE;
|
||||
@@ -91,12 +91,12 @@ public class CustomArmorModelTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeClient(Consumer<IItemRenderProperties> consumer)
|
||||
public void initializeClient(Consumer<IClientItemExtensions> consumer)
|
||||
{
|
||||
consumer.accept(new IItemRenderProperties()
|
||||
consumer.accept(new IClientItemExtensions()
|
||||
{
|
||||
@Override
|
||||
public HumanoidModel<?> getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
public HumanoidModel<?> getHumanoidArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
{
|
||||
return TintedArmorModel.ENDERMAN.get();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,12 @@ import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.Tickable;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.event.RegisterTextureAtlasSpriteLoadersEvent;
|
||||
import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
@@ -40,15 +38,15 @@ public class CustomTASTest
|
||||
{
|
||||
if (FMLLoader.getDist().isClient())
|
||||
{
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerTextureAtlasSpriteLoaders);
|
||||
}
|
||||
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
}
|
||||
}
|
||||
|
||||
private void clientSetup(FMLClientSetupEvent event)
|
||||
private void registerTextureAtlasSpriteLoaders(RegisterTextureAtlasSpriteLoadersEvent event)
|
||||
{
|
||||
MinecraftForgeClient.registerTextureAtlasSpriteLoader(new ResourceLocation(MOD_ID, "tas_loader"), new TasLoader());
|
||||
event.register("tas_loader", new TasLoader());
|
||||
}
|
||||
|
||||
private static class TasLoader implements ITextureAtlasSpriteLoader
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.client.gui.font.FontManager;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -31,7 +30,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.event.RegisterClientTooltipComponentFactoriesEvent;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -142,7 +141,6 @@ public class CustomTooltipTest
|
||||
@SubscribeEvent
|
||||
public static void clientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
MinecraftForgeClient.registerTooltipComponentFactory(CustomTooltip.class, CustomClientTooltip::new);
|
||||
event.enqueueWork(() -> {
|
||||
customFontManager = new FontManager(Minecraft.getInstance().textureManager);
|
||||
customFont = customFontManager.createFont();
|
||||
@@ -151,6 +149,12 @@ public class CustomTooltipTest
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterClientTooltipComponentFactories(RegisterClientTooltipComponentFactoriesEvent event)
|
||||
{
|
||||
event.register(CustomTooltip.class, CustomClientTooltip::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ClientEventHandler
|
||||
|
||||
@@ -28,7 +28,7 @@ public class GuiLayeringTest
|
||||
public static class ClientEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void guiOpen(ScreenEvent.InitScreenEvent event)
|
||||
public static void guiOpen(ScreenEvent.Init event)
|
||||
{
|
||||
if (event.getScreen() instanceof AbstractContainerScreen)
|
||||
{
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.gui.OverlayRegistry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Mod("overlay_layers_test")
|
||||
public class OverlayLayersTest
|
||||
{
|
||||
public static final boolean ENABLE = true;
|
||||
private boolean visible = false;
|
||||
|
||||
public OverlayLayersTest()
|
||||
{
|
||||
if (ENABLE && FMLEnvironment.dist == Dist.CLIENT)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.addListener(this::renderTextEvent);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::keyInputEvent);
|
||||
}
|
||||
}
|
||||
|
||||
int overlayIndex = 0;
|
||||
|
||||
public void renderTextEvent(RenderGameOverlayEvent.Text event)
|
||||
{
|
||||
if (event.getType() != RenderGameOverlayEvent.ElementType.TEXT || !visible)
|
||||
return;
|
||||
|
||||
List<OverlayRegistry.OverlayEntry> overlays = OverlayRegistry.orderedEntries();
|
||||
for(int i=0;i<overlays.size();i++)
|
||||
{
|
||||
OverlayRegistry.OverlayEntry entry = overlays.get(i);
|
||||
event.getLeft().add(String.format(Locale.ENGLISH, overlayIndex == i ? "> %s [%s] <" : " %s [%s] ", entry.getDisplayName(), entry.isEnabled()));
|
||||
}
|
||||
}
|
||||
|
||||
public void keyInputEvent(InputEvent.KeyInputEvent event)
|
||||
{
|
||||
if (event.getAction() != GLFW.GLFW_PRESS || Minecraft.getInstance().level == null || Minecraft.getInstance().screen != null)
|
||||
return;
|
||||
|
||||
if (event.getKey() == GLFW.GLFW_KEY_H)
|
||||
{
|
||||
visible = !visible;
|
||||
return;
|
||||
}
|
||||
if (!visible)
|
||||
return;
|
||||
if (event.getKey() == GLFW.GLFW_KEY_J)
|
||||
{
|
||||
List<OverlayRegistry.OverlayEntry> overlays = OverlayRegistry.orderedEntries();
|
||||
if (overlayIndex >= overlays.size())
|
||||
overlayIndex = 0;
|
||||
else
|
||||
overlayIndex = (overlayIndex + overlays.size() - 1) % overlays.size();
|
||||
}
|
||||
else if (event.getKey() == GLFW.GLFW_KEY_K)
|
||||
{
|
||||
List<OverlayRegistry.OverlayEntry> overlays = OverlayRegistry.orderedEntries();
|
||||
if (overlayIndex >= overlays.size())
|
||||
overlayIndex = 0;
|
||||
else
|
||||
overlayIndex = (overlayIndex + 1) % overlays.size();
|
||||
}
|
||||
else if (event.getKey() == GLFW.GLFW_KEY_I)
|
||||
{
|
||||
List<OverlayRegistry.OverlayEntry> overlays = OverlayRegistry.orderedEntries();
|
||||
if (overlayIndex >= overlays.size())
|
||||
overlayIndex = 0;
|
||||
else
|
||||
{
|
||||
OverlayRegistry.OverlayEntry entry = overlays.get(overlayIndex);
|
||||
OverlayRegistry.enableOverlay(entry.getOverlay(), !entry.isEnabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Test mod for {@link net.minecraftforge.client.event.ScreenEvent.PotionSizeEvent}. When enabled, this mod forces the
|
||||
* Test mod for {@link ScreenEvent.RenderInventoryMobEffects}. When enabled, this mod forces the
|
||||
* potion indicators in the {@linkplain net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen
|
||||
* inventory screen} to either render in compact mode when there are less than or equal to three active effects on the player,
|
||||
* or render in classic mode if there are more than three active effects.
|
||||
@@ -40,7 +40,7 @@ public class PotionSizeEventTest
|
||||
static final class ClientEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onPotionSize(ScreenEvent.PotionSizeEvent event)
|
||||
public static void onPotionSize(ScreenEvent.RenderInventoryMobEffects event)
|
||||
{
|
||||
if (!ENABLED) return;
|
||||
|
||||
@@ -48,10 +48,10 @@ public class PotionSizeEventTest
|
||||
|
||||
if (player.getActiveEffects().size() <= 3)
|
||||
{
|
||||
event.setResult(Event.Result.ALLOW); // Force compact mode for 3 or less active effects
|
||||
event.setCompact(true); // Force compact mode for 3 or less active effects
|
||||
} else
|
||||
{
|
||||
event.setResult(Event.Result.DENY); // Force classic mode for 4 or more active effects
|
||||
event.setCompact(false); // Force classic mode for 4 or more active effects
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
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.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||
import net.minecraftforge.client.model.IQuadTransformer;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Test mod that demos most Forge-provided model loaders in a single block + item, as well as in-JSON render states
|
||||
* and the refactored immutable ModelData managed by the client level. The block can be found in the decoration tab.
|
||||
* <p>
|
||||
* Additionally, some fields in the JSON have deprecated names, so those MUST be updated in 1.20, or the model will
|
||||
* break. They have all been annotated accordingly.
|
||||
* <ul>
|
||||
* <li>As a block: Composite loader, using 3 child element models, each with a different render type,
|
||||
* some using vanilla's elements loader, and some Forge's</li>
|
||||
* <li>In the right hand: Fluid container with lava (emissive)</li>
|
||||
* <li>In the left hand: Multi-layer item with chainmail chestplate + emissive bow</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Clicking on the upper half of the block will make the model move up by a bit, and clicking on the lower half will
|
||||
* move it down.
|
||||
*/
|
||||
@Mod(MegaModelTest.MOD_ID)
|
||||
public class MegaModelTest
|
||||
{
|
||||
public static final String MOD_ID = "mega_model_test";
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);
|
||||
private static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, MOD_ID);
|
||||
|
||||
private static final String REG_NAME = "test_block";
|
||||
public static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register(REG_NAME, TestBlock::new);
|
||||
public static final RegistryObject<Item> TEST_BLOCK_ITEM = ITEMS.register(REG_NAME, () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_DECORATIONS)));
|
||||
public static final RegistryObject<BlockEntityType<?>> TEST_BLOCK_ENTITY = BLOCK_ENTITIES.register(REG_NAME, () -> new BlockEntityType<>(
|
||||
TestBlock.Entity::new, Set.of(TEST_BLOCK.get()), null
|
||||
));
|
||||
|
||||
public MegaModelTest()
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
BLOCKS.register(modEventBus);
|
||||
ITEMS.register(modEventBus);
|
||||
BLOCK_ENTITIES.register(modEventBus);
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class ClientEvents
|
||||
{
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onModelBakingCompleted(ModelEvent.BakingCompleted event)
|
||||
{
|
||||
var name = new ModelResourceLocation(MOD_ID, REG_NAME, "");
|
||||
event.getModels().computeIfPresent(name, (n, m) -> new TransformingModelWrapper(m));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class TestBlock extends Block implements EntityBlock
|
||||
{
|
||||
public TestBlock()
|
||||
{
|
||||
super(Properties.of(Material.STONE));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state)
|
||||
{
|
||||
return new Entity(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||
{
|
||||
var entity = level.getBlockEntity(pos);
|
||||
if (entity instanceof Entity e)
|
||||
{
|
||||
e.y += Mth.sign(hit.getLocation().y - pos.getY() - 0.5);
|
||||
e.requestModelDataUpdate();
|
||||
level.sendBlockUpdated(pos, state, state, 8);
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
return super.use(state, level, pos, player, hand, hit);
|
||||
}
|
||||
|
||||
public static class Entity extends BlockEntity
|
||||
{
|
||||
public int y = 0;
|
||||
|
||||
public Entity(BlockPos pos, BlockState state)
|
||||
{
|
||||
super(TEST_BLOCK_ENTITY.get(), pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ModelData getModelData()
|
||||
{
|
||||
return ModelData.builder().with(TestData.PROPERTY, new TestData(new Transformation(
|
||||
new Vector3f(0, y * 0.2f, 0),
|
||||
Quaternion.ONE,
|
||||
Transformation.identity().getScale(),
|
||||
Quaternion.ONE
|
||||
))).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record TestData(Transformation transform)
|
||||
{
|
||||
public static final ModelProperty<TestData> PROPERTY = new ModelProperty<>();
|
||||
}
|
||||
|
||||
private static class TransformingModelWrapper extends BakedModelWrapper<BakedModel>
|
||||
{
|
||||
public TransformingModelWrapper(BakedModel originalModel)
|
||||
{
|
||||
super(originalModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull ModelData data, @Nullable RenderType renderType)
|
||||
{
|
||||
var quads = super.getQuads(state, side, rand, data, renderType);
|
||||
if (!data.has(TestData.PROPERTY))
|
||||
return quads;
|
||||
return IQuadTransformer.applying(data.get(TestData.PROPERTY).transform()).process(quads);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,20 +5,17 @@
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
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.client.renderer.texture.TextureAtlasSprite;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -27,20 +24,19 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.model.IModelBuilder;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryBakingContext;
|
||||
import net.minecraftforge.client.model.geometry.IGeometryLoader;
|
||||
import net.minecraftforge.client.model.generators.BlockModelBuilder;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
||||
import net.minecraftforge.client.model.generators.loaders.ItemLayersModelBuilder;
|
||||
import net.minecraftforge.client.model.generators.loaders.OBJLoaderBuilder;
|
||||
import net.minecraftforge.client.model.generators.loaders.SeparatePerspectiveModelBuilder;
|
||||
import net.minecraftforge.client.model.geometry.ISimpleModelGeometry;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
import net.minecraftforge.client.model.generators.loaders.ObjModelBuilder;
|
||||
import net.minecraftforge.client.model.generators.loaders.SeparateTransformsModelBuilder;
|
||||
import net.minecraftforge.client.model.geometry.SimpleUnbakedGeometry;
|
||||
import net.minecraftforge.client.model.pipeline.QuadBakingVertexConsumer;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
@@ -139,75 +135,45 @@ public class NewModelLoaderTest
|
||||
modEventBus.addListener(this::datagen);
|
||||
}
|
||||
|
||||
public void modelRegistry(ModelRegistryEvent event)
|
||||
public void modelRegistry(ModelEvent.RegisterGeometryLoaders event)
|
||||
{
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(MODID, "custom_loader"), new TestLoader());
|
||||
event.register("custom_loader", new TestLoader());
|
||||
}
|
||||
|
||||
static class TestLoader implements IModelLoader<TestModel>
|
||||
static class TestLoader implements IGeometryLoader<TestModel>
|
||||
{
|
||||
@Override
|
||||
public void onResourceManagerReload(ResourceManager resourceManager)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents)
|
||||
public TestModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext)
|
||||
{
|
||||
return new TestModel();
|
||||
}
|
||||
}
|
||||
|
||||
static class TestModel implements ISimpleModelGeometry<TestModel>
|
||||
static class TestModel extends SimpleUnbakedGeometry<TestModel>
|
||||
{
|
||||
@Override
|
||||
public void addQuads(IModelConfiguration owner, IModelBuilder<?> modelBuilder, ModelBakery bakery, Function< net.minecraft.client.resources.model.Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation)
|
||||
protected void addQuads(IGeometryBakingContext owner, IModelBuilder<?> modelBuilder, ModelBakery bakery, Function< net.minecraft.client.resources.model.Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ResourceLocation modelLocation)
|
||||
{
|
||||
TextureAtlasSprite texture = spriteGetter.apply(owner.resolveTexture("particle"));
|
||||
TextureAtlasSprite texture = spriteGetter.apply(owner.getMaterial("particle"));
|
||||
|
||||
BakedQuadBuilder builder = new BakedQuadBuilder();
|
||||
var quad = new BakedQuad[1];
|
||||
var quadBaker = new QuadBakingVertexConsumer(q -> quad[0] = q);
|
||||
|
||||
builder.setTexture(texture);
|
||||
builder.setQuadOrientation(Direction.UP);
|
||||
quadBaker.setDirection(Direction.UP);
|
||||
quadBaker.setSprite(texture);
|
||||
|
||||
putVertex(builder, 0,1,0.5f, texture.getU(0), texture.getV(0), 1, 1, 1);
|
||||
putVertex(builder, 0,0,0.5f, texture.getU(0), texture.getV(16), 1, 1, 1);
|
||||
putVertex(builder, 1,0,0.5f, texture.getU(16), texture.getV(16), 1, 1, 1);
|
||||
putVertex(builder, 1,1,0.5f, texture.getU(16), texture.getV(0), 1, 1, 1);
|
||||
quadBaker.vertex(0, 1, 0.5f).color(255, 255, 255, 255).uv(texture.getU(0), texture.getV(0)).uv2(0).normal(0, 0, 0).endVertex();
|
||||
quadBaker.vertex(0, 0, 0.5f).color(255, 255, 255, 255).uv(texture.getU(0), texture.getV(16)).uv2(0).normal(0, 0, 0).endVertex();
|
||||
quadBaker.vertex(1, 0, 0.5f).color(255, 255, 255, 255).uv(texture.getU(16), texture.getV(16)).uv2(0).normal(0, 0, 0).endVertex();
|
||||
quadBaker.vertex(1, 1, 0.5f).color(255, 255, 255, 255).uv(texture.getU(16), texture.getV(0)).uv2(0).normal(0, 0, 0).endVertex();
|
||||
|
||||
modelBuilder.addGeneralQuad(builder.build());
|
||||
}
|
||||
|
||||
private void putVertex(BakedQuadBuilder builder, int x, float y, float z, float u, float v, float red, float green, float blue)
|
||||
{
|
||||
ImmutableList<VertexFormatElement> elements = DefaultVertexFormat.BLOCK.getElements();
|
||||
for(int i=0;i<elements.size();i++)
|
||||
{
|
||||
switch(elements.get(i).getUsage())
|
||||
{
|
||||
case POSITION:
|
||||
builder.put(i, x, y, z);
|
||||
break;
|
||||
case UV:
|
||||
if (elements.get(i).getIndex() == 0)
|
||||
builder.put(i, u, v);
|
||||
else
|
||||
builder.put(i);
|
||||
break;
|
||||
case COLOR:
|
||||
builder.put(i, red, green, blue, 1.0f);
|
||||
break;
|
||||
default:
|
||||
builder.put(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
modelBuilder.addUnculledFace(quad[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection< net.minecraft.client.resources.model.Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
public Collection< net.minecraft.client.resources.model.Material> getMaterials(IGeometryBakingContext context, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
|
||||
{
|
||||
return Collections.singleton(owner.resolveTexture("particle"));
|
||||
return Collections.singleton(context.getMaterial("particle"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,10 +201,10 @@ public class NewModelLoaderTest
|
||||
.texture("layer0", "minecraft:item/coal")
|
||||
.texture("layer1", "minecraft:item/stick")
|
||||
.customLoader(ItemLayersModelBuilder::begin)
|
||||
.fullbright(1)
|
||||
.emissive(1)
|
||||
.end();
|
||||
withExistingParent(NewModelLoaderTest.separate_perspective.getId().getPath(), "forge:item/default")
|
||||
.customLoader(SeparatePerspectiveModelBuilder::begin)
|
||||
.customLoader(SeparateTransformsModelBuilder::begin)
|
||||
.base(nested().parent(getExistingFile(mcLoc("minecraft:item/coal"))))
|
||||
.perspective(ItemTransforms.TransformType.GUI, nested().parent(getExistingFile(mcLoc("minecraft:item/snowball"))))
|
||||
.perspective(ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, nested().parent(getExistingFile(mcLoc("minecraft:item/bone"))))
|
||||
@@ -258,7 +224,7 @@ public class NewModelLoaderTest
|
||||
{
|
||||
BlockModelBuilder model = models()
|
||||
.getBuilder(NewModelLoaderTest.obj_block.getId().getPath())
|
||||
.customLoader(OBJLoaderBuilder::begin)
|
||||
.customLoader(ObjModelBuilder::begin)
|
||||
.modelLocation(new ResourceLocation("new_model_loader_test:models/item/sugar_glider.obj"))
|
||||
.flipV(true)
|
||||
.end()
|
||||
|
||||
@@ -7,8 +7,7 @@ package net.minecraftforge.debug.client.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -26,12 +25,11 @@ import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
import net.minecraftforge.client.model.pipeline.TRSRTransformer;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.model.IQuadTransformer;
|
||||
import net.minecraftforge.client.model.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.common.util.TransformationHelper;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
@@ -58,10 +56,10 @@ public class TRSRTransformerTest {
|
||||
ITEMS.register(mod);
|
||||
}
|
||||
|
||||
public void onModelBake(ModelBakeEvent e) {
|
||||
for (ResourceLocation id : e.getModelRegistry().keySet()) {
|
||||
public void onModelBake(ModelEvent.BakingCompleted e) {
|
||||
for (ResourceLocation id : e.getModels().keySet()) {
|
||||
if (MODID.equals(id.getNamespace()) && "test".equals(id.getPath())) {
|
||||
e.getModelRegistry().put(id, new MyBakedModel(e.getModelRegistry().get(id)));
|
||||
e.getModels().put(id, new MyBakedModel(e.getModels().get(id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,32 +72,14 @@ public class TRSRTransformerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, IModelData data) {
|
||||
ImmutableList.Builder<BakedQuad> quads = new ImmutableList.Builder<>();
|
||||
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, ModelData data, @Nullable RenderType renderType) {
|
||||
Quaternion rot = TransformationHelper.quatFromXYZ(new Vector3f(0, 45, 0), true);
|
||||
Vector3f translation = new Vector3f(0, 0.33f, 0);
|
||||
|
||||
Transformation trans = new Transformation(translation, rot, null, null).blockCenterToCorner();
|
||||
var transformer = IQuadTransformer.applying(trans);
|
||||
|
||||
for (BakedQuad quad : base.getQuads(state, side, rand, data)) {
|
||||
|
||||
if (true)
|
||||
{
|
||||
BakedQuadBuilder builder = new BakedQuadBuilder();
|
||||
|
||||
TRSRTransformer transformer = new TRSRTransformer(builder, trans);
|
||||
|
||||
quad.pipe(transformer);
|
||||
|
||||
quads.add(builder.build());
|
||||
} /* else {
|
||||
QuadTransformer qt = new QuadTransformer(trans);
|
||||
quads.add(qt.processOne(quad));
|
||||
}*/
|
||||
}
|
||||
|
||||
return quads.build();
|
||||
return transformer.process(base.getQuads(state, side, rand, data, renderType));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ package net.minecraftforge.debug.client.rendering;
|
||||
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraftforge.client.ForgeRenderTypes;
|
||||
import net.minecraftforge.client.event.ScreenEvent.DrawScreenEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent.Render;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -20,7 +20,7 @@ public class LinearTextTextureFilteringTest
|
||||
static final boolean ENABLED = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onGuiRenderPre(DrawScreenEvent.Pre event)
|
||||
public static void onGuiRenderPre(Render.Pre event)
|
||||
{
|
||||
if (ENABLED && event.getScreen() instanceof TitleScreen)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ public class LinearTextTextureFilteringTest
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onGuiRenderPost(DrawScreenEvent.Post event)
|
||||
public static void onGuiRenderPost(Render.Post event)
|
||||
{
|
||||
if (ENABLED && event.getScreen() instanceof TitleScreen)
|
||||
{
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.animal.Cow;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraftforge.client.event.RenderNameplateEvent;
|
||||
import net.minecraftforge.client.event.RenderNameTagEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -24,7 +24,7 @@ public class NameplateRenderingEventTest
|
||||
static final boolean ENABLED = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onNameplateRender(RenderNameplateEvent event)
|
||||
public static void onNameplateRender(RenderNameTagEvent event)
|
||||
{
|
||||
|
||||
if(!ENABLED)
|
||||
|
||||
@@ -17,20 +17,17 @@ import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.event.ModelEvent;
|
||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
||||
import net.minecraftforge.client.model.ForgeModelBakery;
|
||||
import net.minecraftforge.client.model.StandaloneModelConfiguration;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.renderable.BakedRenderable;
|
||||
import net.minecraftforge.client.model.geometry.StandaloneGeometryBakingContext;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.obj.ObjLoader;
|
||||
import net.minecraftforge.client.model.obj.ObjModel;
|
||||
import net.minecraftforge.client.model.renderable.BakedModelRenderable;
|
||||
import net.minecraftforge.client.model.renderable.CompositeRenderable;
|
||||
import net.minecraftforge.client.model.renderable.IRenderable;
|
||||
import net.minecraftforge.client.model.renderable.MultipartTransforms;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
@@ -59,8 +56,8 @@ public class RenderableTest
|
||||
{
|
||||
private static ResourceLocation MODEL_LOC = new ResourceLocation("minecraft:block/diamond_block");
|
||||
|
||||
private static IRenderable<MultipartTransforms> renderable;
|
||||
private static IRenderable<IModelData> bakedRenderable;
|
||||
private static IRenderable<CompositeRenderable.Transforms> renderable;
|
||||
private static IRenderable<ModelData> bakedRenderable;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
@@ -70,19 +67,19 @@ public class RenderableTest
|
||||
MinecraftForge.EVENT_BUS.addListener(Client::renderLast);
|
||||
}
|
||||
|
||||
private static void registerModels(ModelRegistryEvent t)
|
||||
private static void registerModels(ModelEvent.RegisterAdditional event)
|
||||
{
|
||||
ForgeModelBakery.addSpecialModel(MODEL_LOC);
|
||||
event.register(MODEL_LOC);
|
||||
}
|
||||
|
||||
public static void registerReloadListeners(RegisterClientReloadListenersEvent event)
|
||||
{
|
||||
event.registerReloadListener(new SimplePreparableReloadListener<OBJModel>()
|
||||
event.registerReloadListener(new SimplePreparableReloadListener<ObjModel>()
|
||||
{
|
||||
@Override
|
||||
protected OBJModel prepare(ResourceManager resourceManager, ProfilerFiller profilerFiller)
|
||||
protected ObjModel prepare(ResourceManager resourceManager, ProfilerFiller profilerFiller)
|
||||
{
|
||||
var settings = new OBJModel.ModelSettings(
|
||||
var settings = new ObjModel.ModelSettings(
|
||||
new ResourceLocation("new_model_loader_test:models/item/sugar_glider.obj"),
|
||||
false,
|
||||
true,
|
||||
@@ -90,13 +87,13 @@ public class RenderableTest
|
||||
false,
|
||||
null
|
||||
);
|
||||
return OBJLoader.INSTANCE.loadModel(settings);
|
||||
return ObjLoader.INSTANCE.loadModel(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(OBJModel model, ResourceManager resourceManager, ProfilerFiller profilerFiller)
|
||||
protected void apply(ObjModel model, ResourceManager resourceManager, ProfilerFiller profilerFiller)
|
||||
{
|
||||
var config = StandaloneModelConfiguration.create(Map.of(
|
||||
var config = StandaloneGeometryBakingContext.create(Map.of(
|
||||
"#qr", new ResourceLocation("minecraft:block/quartz_block_top")
|
||||
));
|
||||
renderable = model.bakeRenderable(config);
|
||||
@@ -110,7 +107,7 @@ public class RenderableTest
|
||||
{
|
||||
if (bakedRenderable == null)
|
||||
{
|
||||
bakedRenderable = BakedRenderable.of(MODEL_LOC);
|
||||
bakedRenderable = BakedModelRenderable.of(MODEL_LOC).withModelDataContext();
|
||||
}
|
||||
|
||||
var poseStack = event.getPoseStack();
|
||||
@@ -130,13 +127,13 @@ public class RenderableTest
|
||||
right.multiply(Quaternion.fromYXZ(0, 0, -(float)Math.sin(time * 0.05) * 0.1f));
|
||||
map.put("object_9", right);
|
||||
|
||||
var transforms = MultipartTransforms.of(map.build());
|
||||
var transforms = CompositeRenderable.Transforms.of(map.build());
|
||||
|
||||
renderable.render(poseStack, bufferSource, RenderType::entitySolid, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, event.getPartialTick(), transforms);
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0,0.5f,0);
|
||||
bakedRenderable.render(poseStack, bufferSource, RenderType::entitySolid, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, event.getPartialTick(), EmptyModelData.INSTANCE);
|
||||
bakedRenderable.render(poseStack, bufferSource, RenderType::entitySolid, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, event.getPartialTick(), ModelData.EMPTY);
|
||||
poseStack.popPose();
|
||||
|
||||
bufferSource.endBatch();
|
||||
|
||||
@@ -5,21 +5,20 @@
|
||||
|
||||
package net.minecraftforge.debug.client.rendering;
|
||||
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterEntitySpectatorShadersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.client.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
|
||||
@Mod("shader_fix_test")
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ShaderFixTest
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void clientSetup(final FMLClientSetupEvent event)
|
||||
public static void onRegisterEntitySpectatorShaders(final RegisterEntitySpectatorShadersEvent event)
|
||||
{
|
||||
ClientRegistry.registerEntityShader(LocalPlayer.class, new ResourceLocation("shaders/post/desaturate.json"));
|
||||
event.register(EntityType.PLAYER, new ResourceLocation("shaders/post/desaturate.json"));
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,8 @@ import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.IFluidTypeRenderProperties;
|
||||
import net.minecraftforge.client.RenderProperties;
|
||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fluids.FluidInteractionRegistry;
|
||||
@@ -87,9 +86,9 @@ public class FluidTypeTest
|
||||
new FluidType(FluidType.Properties.create().supportsBoating(true).canHydrate(true))
|
||||
{
|
||||
@Override
|
||||
public void initializeClient(Consumer<IFluidTypeRenderProperties> consumer)
|
||||
public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer)
|
||||
{
|
||||
consumer.accept(new IFluidTypeRenderProperties()
|
||||
consumer.accept(new IClientFluidTypeExtensions()
|
||||
{
|
||||
private static final ResourceLocation STILL = new ResourceLocation("block/water_still"),
|
||||
FLOW = new ResourceLocation("block/water_flow"),
|
||||
@@ -121,7 +120,7 @@ public class FluidTypeTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorTint()
|
||||
public int getTintColor()
|
||||
{
|
||||
return 0xAF7FFFD4;
|
||||
}
|
||||
@@ -129,7 +128,7 @@ public class FluidTypeTest
|
||||
@Override
|
||||
public @NotNull Vector3f modifyFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, Vector3f fluidFogColor)
|
||||
{
|
||||
int color = this.getColorTint();
|
||||
int color = this.getTintColor();
|
||||
return new Vector3f((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F);
|
||||
}
|
||||
|
||||
@@ -208,14 +207,14 @@ public class FluidTypeTest
|
||||
.forEach(fluid -> ItemBlockRenderTypes.setRenderLayer(fluid, RenderType.translucent()));
|
||||
}
|
||||
|
||||
private void registerBlockColors(ColorHandlerEvent.Block event)
|
||||
private void registerBlockColors(RegisterColorHandlersEvent.Block event)
|
||||
{
|
||||
event.getBlockColors().register((state, getter, pos, index) ->
|
||||
{
|
||||
if (getter != null && pos != null)
|
||||
{
|
||||
FluidState fluidState = getter.getFluidState(pos);
|
||||
return RenderProperties.get(fluidState).getColorTint(fluidState, getter, pos);
|
||||
return IClientFluidTypeExtensions.of(fluidState).getTintColor(fluidState, getter, pos);
|
||||
} else return 0xAF7FFFD4;
|
||||
}, TEST_FLUID_BLOCK.get());
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.client.IFluidTypeRenderProperties;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
import net.minecraftforge.fluids.DispenseFluidContainer;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
@@ -73,9 +73,9 @@ public class NewFluidTest
|
||||
public static RegistryObject<FluidType> test_fluid_type = FLUID_TYPES.register("test_fluid", () -> new FluidType(FluidType.Properties.create())
|
||||
{
|
||||
@Override
|
||||
public void initializeClient(Consumer<IFluidTypeRenderProperties> consumer)
|
||||
public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer)
|
||||
{
|
||||
consumer.accept(new IFluidTypeRenderProperties()
|
||||
consumer.accept(new IClientFluidTypeExtensions()
|
||||
{
|
||||
@Override
|
||||
public ResourceLocation getStillTexture()
|
||||
@@ -97,7 +97,7 @@ public class NewFluidTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorTint()
|
||||
public int getTintColor()
|
||||
{
|
||||
return 0x3F1080FF;
|
||||
}
|
||||
|
||||
+5
-6
@@ -8,10 +8,9 @@ package net.minecraftforge.debug.recipe.recipebook;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.client.RecipeBookCategories;
|
||||
import net.minecraft.stats.RecipeBook;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.client.RecipeBookRegistry;
|
||||
import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -21,11 +20,11 @@ public class RecipeBookExtensionClientHelper
|
||||
public static final Supplier<RecipeBookCategories> TESTING_CAT_1 = Suppliers.memoize(() -> RecipeBookCategories.create("TESTING_CAT_1", new ItemStack(Items.DIAMOND)));
|
||||
public static final Supplier<RecipeBookCategories> TESTING_CAT_2 = Suppliers.memoize(() -> RecipeBookCategories.create("TESTING_CAT_2", new ItemStack(Items.NETHERITE_INGOT)));
|
||||
|
||||
public static void init()
|
||||
public static void init(RegisterRecipeBookCategoriesEvent event)
|
||||
{
|
||||
RecipeBookRegistry.addCategoriesToType(RecipeBookExtensionTest.TEST_TYPE, ImmutableList.of(TESTING_SEARCH.get(), TESTING_CAT_1.get(), TESTING_CAT_2.get()));
|
||||
RecipeBookRegistry.addAggregateCategories(TESTING_SEARCH.get(), ImmutableList.of(TESTING_CAT_1.get(), TESTING_CAT_2.get()));
|
||||
RecipeBookRegistry.addCategoriesFinder(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), r ->
|
||||
event.registerBookCategories(RecipeBookExtensionTest.TEST_TYPE, ImmutableList.of(TESTING_SEARCH.get(), TESTING_CAT_1.get(), TESTING_CAT_2.get()));
|
||||
event.registerAggregateCategory(TESTING_SEARCH.get(), ImmutableList.of(TESTING_CAT_1.get(), TESTING_CAT_2.get()));
|
||||
event.registerRecipeCategoryFinder(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), r ->
|
||||
{
|
||||
if (r.getResultItem().getItem() == Items.DIAMOND_BLOCK)
|
||||
return TESTING_CAT_1.get();
|
||||
|
||||
+8
-1
@@ -18,6 +18,7 @@ import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
@@ -87,9 +88,15 @@ public class RecipeBookExtensionTest
|
||||
event.enqueueWork(() ->
|
||||
{
|
||||
MenuScreens.register(RECIPE_BOOK_TEST_MENU_TYPE.get(), RecipeBookTestScreen::new);
|
||||
RecipeBookExtensionClientHelper.init();
|
||||
});
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void onRegisterRecipeBookCategories(RegisterRecipeBookCategoriesEvent event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
return;
|
||||
RecipeBookExtensionClientHelper.init(event);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecipeBookTestContainer extends SimpleContainer
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package net.minecraftforge.eventtest.internal;
|
||||
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraftforge.client.event.ScreenOpenEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.GameShuttingDownEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -116,7 +116,7 @@ public class TestFramework {
|
||||
* the ScreenOpenEvent fired by TitleScreen is the last event fired without user interaction, so it is the
|
||||
* end of the "automatic" bootstrap time.
|
||||
*/
|
||||
private void collectBootstrapTests(ScreenOpenEvent event) {
|
||||
private void collectBootstrapTests(ScreenEvent.Opening event) {
|
||||
if(!(event.getScreen() instanceof TitleScreen) || bootstrapHandled)
|
||||
return;
|
||||
|
||||
|
||||
Reference in new issue
Block a user