mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Forge 1.19
* Bump pack.mcmeta formats * 1.19 biome modifiers * Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable * Add docs and package-info to client extension interfaces package * Move RenderBlockOverlayEvent hooks to ForgeHooksClient * Add package-infos to client events package * Rename SoundLoadEvent to SoundEngineLoadEvent This reduces confusion from consumers which may think the name SoundLoadEvent refers to an individual sound being loaded rather than the sound engine. * Document and change SoundLoadEvent to fire on mod bus Previously, it fired on both the mod bus and the Forge bus, which is confusing for consumers. * Delete SoundSetupEvent Looking at its original implementation shows that there isn't an appropriate place in the new sound code to reinsert the event, and the place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent. * Perform some cleanup on client events - Removed nullable annotations from ClientPlayerNetworkEvent - Renamed #getPartialTicks methods to #getPartialTick, to be consistent with vanilla's naming of the partial tick - Cleanup documentation to remove line breaks, use the spelling 'cancelled' over 'canceled', and improve docs on existing and new methods. * Remove EntityEvent.CanUpdate Closes MinecraftForge/MinecraftForge#6394 * Switch to Jetbrains nullability annotations * New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent * Remove ForgeWorldPresetScreens * Remove IForgeRegistryEntry * Remove use of List<Throwable> in FML's CompletableFutures * Add docs to mod loading stages, stages, and phases * Gradle 7.4.2 * Use SLF4J in FMLLoader and other subprojects * Switch dynamic versions in subprojects to pinned ones * Switch ForgeRoot and MDK to FG plugin markers * Configure Forge javadoc task The task now uses a custom stylesheet with MCForge elements, and configured to combine the generation from the four FML subprojects (fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project into the javadoc output. * Update docs/md files, for 1.19 update and the move away from IRC to Discord. * Make "Potentially dangerous alternative prefix" a debug warning, not info. Co-authored-by: Curle <[email protected]> Co-authored-by: sciwhiz12 <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
270e778ac5
commit
4ed9117799
1485 files changed
+14960
-15446
No files matched your search
@@ -62,7 +62,7 @@ public class AudioStreamTest
|
||||
{
|
||||
protected SineSound(Vec3 position)
|
||||
{
|
||||
super(new ResourceLocation(MOD_ID, "sine_wave"), SoundSource.BLOCKS);
|
||||
super(new ResourceLocation(MOD_ID, "sine_wave"), SoundSource.BLOCKS, SoundInstance.createUnseededRandom());
|
||||
x = position.x;
|
||||
y = position.y;
|
||||
z = position.z;
|
||||
|
||||
@@ -8,7 +8,6 @@ package net.minecraftforge.debug.client;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.EndermanModel;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.model.Model;
|
||||
import net.minecraft.client.model.geom.ModelLayers;
|
||||
@@ -35,7 +34,6 @@ import net.minecraftforge.registries.RegistryObject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -68,7 +66,7 @@ public class CustomArmorModelTest
|
||||
{
|
||||
consumer.accept(new IItemRenderProperties()
|
||||
{
|
||||
@Override @Nonnull
|
||||
@Override @NotNull
|
||||
public Model getBaseArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot armorSlot, HumanoidModel<?> _default)
|
||||
{
|
||||
TintedArmorModel.INSTANCE.base = _default;
|
||||
@@ -118,7 +116,7 @@ public class CustomArmorModelTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderToBuffer(@Nonnull PoseStack poseStack, @Nonnull VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha)
|
||||
public void renderToBuffer(@NotNull PoseStack poseStack, @NotNull VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha)
|
||||
{
|
||||
if (base != null)
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ package net.minecraftforge.debug.client;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -26,6 +24,7 @@ import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mod(CustomTASTest.MOD_ID)
|
||||
public class CustomTASTest
|
||||
@@ -55,7 +54,7 @@ public class CustomTASTest
|
||||
private static class TasLoader implements ITextureAtlasSpriteLoader
|
||||
{
|
||||
@Override
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public TextureAtlasSprite load(TextureAtlas atlas, ResourceManager resourceManager, TextureAtlasSprite.Info textureInfo, Resource resource, int atlasWidth, int atlasHeight, int spriteX, int spriteY, int mipmapLevel, NativeImage image)
|
||||
{
|
||||
return new TextureAtlasSprite(
|
||||
|
||||
@@ -19,7 +19,6 @@ 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.network.chat.TextComponent;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
@@ -44,8 +43,8 @@ import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -113,7 +112,7 @@ public class CustomTooltipTest
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> components, TooltipFlag flag)
|
||||
{
|
||||
super.appendHoverText(stack, level, components, flag);
|
||||
components.add(new TextComponent("This is a very very very very very very long hover text that should really really be split across multiple lines.").withStyle(ChatFormatting.YELLOW));
|
||||
components.add(Component.literal("This is a very very very very very very long hover text that should really really be split across multiple lines.").withStyle(ChatFormatting.YELLOW));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,7 +191,7 @@ public class CustomTooltipTest
|
||||
|
||||
protected TooltipTestScreen()
|
||||
{
|
||||
super(new TextComponent("TooltipMethodTest"));
|
||||
super(Component.literal("TooltipMethodTest"));
|
||||
}
|
||||
|
||||
static void show()
|
||||
@@ -210,14 +209,14 @@ public class CustomTooltipTest
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
addRenderableWidget(new Button(10, 10, 200, 20, new TextComponent("Toggle Stack: EMPTY"), button -> {
|
||||
addRenderableWidget(new Button(10, 10, 200, 20, Component.literal("Toggle Stack: EMPTY"), button -> {
|
||||
this.testStack = this.testStack.isEmpty() ? new ItemStack(Items.APPLE) : ItemStack.EMPTY;
|
||||
button.setMessage(new TextComponent("Toggle Stack: " + (testStack.isEmpty() ? "EMPTY" : "Apple")));
|
||||
button.setMessage(Component.literal("Toggle Stack: " + (testStack.isEmpty() ? "EMPTY" : "Apple")));
|
||||
}));
|
||||
|
||||
addRenderableWidget(new Button(220, 10, 200, 20, new TextComponent("Toggle Font: null"), button -> {
|
||||
addRenderableWidget(new Button(220, 10, 200, 20, Component.literal("Toggle Font: null"), button -> {
|
||||
this.testFont = this.testFont == null ? ClientModBusEventHandler.customFont : null;
|
||||
button.setMessage(new TextComponent("Toggle Font: " + (testFont == null ? "null" : "customFont")));
|
||||
button.setMessage(Component.literal("Toggle Font: " + (testFont == null ? "null" : "customFont")));
|
||||
}));
|
||||
|
||||
// * must have stack context
|
||||
@@ -242,7 +241,7 @@ public class CustomTooltipTest
|
||||
int y = 50;
|
||||
for (var test : tooltipTests)
|
||||
{
|
||||
addRenderableWidget(new Button(x, y, 100, 20, new TextComponent(test.getKey()), button -> {}, test.getValue()));
|
||||
addRenderableWidget(new Button(x, y, 100, 20, Component.literal(test.getKey()), button -> {}, test.getValue()));
|
||||
y+= 22;
|
||||
if (y >= height - 50)
|
||||
{
|
||||
@@ -260,72 +259,72 @@ public class CustomTooltipTest
|
||||
// renderTooltip with List<Component> and all combinations of ItemStack/Font
|
||||
private void test2(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(new TextComponent("test")), Optional.empty(), mouseX, mouseY, this.testStack);
|
||||
renderTooltip(poseStack, List.of(Component.literal("test")), Optional.empty(), mouseX, mouseY, this.testStack);
|
||||
}
|
||||
|
||||
private void test3(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(new TextComponent("test")), Optional.empty(), mouseX, mouseY, this.testFont);
|
||||
renderTooltip(poseStack, List.of(Component.literal("test")), Optional.empty(), mouseX, mouseY, this.testFont);
|
||||
}
|
||||
|
||||
private void test4(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(new TextComponent("test")), Optional.empty(), mouseX, mouseY, this.testFont, this.testStack);
|
||||
renderTooltip(poseStack, List.of(Component.literal("test")), Optional.empty(), mouseX, mouseY, this.testFont, this.testStack);
|
||||
}
|
||||
|
||||
private void test5(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(new TextComponent("test")), Optional.empty(), mouseX, mouseY);
|
||||
renderTooltip(poseStack, List.of(Component.literal("test")), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderTooltip with just Component
|
||||
private void test6(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, new TextComponent("test"), mouseX, mouseY);
|
||||
renderTooltip(poseStack, Component.literal("test"), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderComponentTooltip with all combinations of ItemStack/Font
|
||||
private void test7(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(new TextComponent("test")), mouseX, mouseY, this.testStack);
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testStack);
|
||||
}
|
||||
|
||||
private void test8(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(new TextComponent("test")), mouseX, mouseY, this.testFont);
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testFont);
|
||||
}
|
||||
|
||||
private void test9(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(new TextComponent("test")), mouseX, mouseY, this.testFont, this.testStack);
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testFont, this.testStack);
|
||||
}
|
||||
|
||||
private void test10(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(new TextComponent("test")), mouseX, mouseY);
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderTooltip with list of FormattedCharSequence
|
||||
private void test11(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(new TextComponent("test").getVisualOrderText()), mouseX, mouseY);
|
||||
renderTooltip(poseStack, List.of(Component.literal("test").getVisualOrderText()), mouseX, mouseY);
|
||||
}
|
||||
|
||||
// renderTooltip with list of FormattedCharSequence and Font
|
||||
private void test12(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(new TextComponent("test").getVisualOrderText()), mouseX, mouseY, this.testFont);
|
||||
renderTooltip(poseStack, List.of(Component.literal("test").getVisualOrderText()), mouseX, mouseY, this.testFont);
|
||||
}
|
||||
|
||||
// legacy ToolTip methods
|
||||
private void test13(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderTooltip(poseStack, List.of(new TextComponent("test").getVisualOrderText()), mouseX, mouseY, this.testFont);
|
||||
renderTooltip(poseStack, List.of(Component.literal("test").getVisualOrderText()), mouseX, mouseY, this.testFont);
|
||||
}
|
||||
|
||||
private void test14(Button button, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
renderComponentTooltip(poseStack, List.of(new TextComponent("test")), mouseX, mouseY, this.testFont, ItemStack.EMPTY);
|
||||
renderComponentTooltip(poseStack, List.of(Component.literal("test")), mouseX, mouseY, this.testFont, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -33,11 +32,11 @@ public class GuiLayeringTest
|
||||
{
|
||||
if (event.getScreen() instanceof AbstractContainerScreen)
|
||||
{
|
||||
event.addListener(new Button(2, 2, 150, 20, new TextComponent("Test Gui Layering"), btn -> {
|
||||
Minecraft.getInstance().pushGuiLayer(new TestLayer(new TextComponent("LayerScreen")));
|
||||
event.addListener(new Button(2, 2, 150, 20, Component.literal("Test Gui Layering"), btn -> {
|
||||
Minecraft.getInstance().pushGuiLayer(new TestLayer(Component.literal("LayerScreen")));
|
||||
}));
|
||||
event.addListener(new Button(2, 25, 150, 20, new TextComponent("Test Gui Normal"), btn -> {
|
||||
Minecraft.getInstance().setScreen(new TestLayer(new TextComponent("LayerScreen")));
|
||||
event.addListener(new Button(2, 25, 150, 20, Component.literal("Test Gui Normal"), btn -> {
|
||||
Minecraft.getInstance().setScreen(new TestLayer(Component.literal("LayerScreen")));
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -73,9 +72,9 @@ public class GuiLayeringTest
|
||||
xoff = RANDOM.nextInt(xoff);
|
||||
yoff = RANDOM.nextInt(yoff);
|
||||
|
||||
this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, new TextComponent("Push New Layer"), this::pushLayerButton));
|
||||
this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, new TextComponent("Pop Current Layer"), this::popLayerButton));
|
||||
this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, new TextComponent("Close entire stack"), this::closeStack));
|
||||
this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, Component.literal("Push New Layer"), this::pushLayerButton));
|
||||
this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, Component.literal("Pop Current Layer"), this::popLayerButton));
|
||||
this.addRenderableWidget(new Button(xoff, yoff + buttonSpacing * (cnt++), buttonWidth, buttonHeight, Component.literal("Close entire stack"), this::closeStack));
|
||||
}
|
||||
|
||||
private void closeStack(Button button)
|
||||
@@ -90,7 +89,7 @@ public class GuiLayeringTest
|
||||
|
||||
private void pushLayerButton(Button button)
|
||||
{
|
||||
this.minecraft.pushGuiLayer(new TestLayer(new TextComponent("LayerScreen")));
|
||||
this.minecraft.pushGuiLayer(new TestLayer(Component.literal("LayerScreen")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mod(CompositeModelTest.MODID)
|
||||
public class CompositeModelTest
|
||||
|
||||
@@ -113,7 +113,7 @@ public class CustomTransformTypeTest
|
||||
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, MODID);
|
||||
|
||||
public static final RegistryObject<Block>
|
||||
ITEM_HANGER_BLOCK = BLOCKS.register("item_hanger", () -> new ItemHangerBlock(BlockBehaviour.Properties.of(Material.WOOL).noCollission().noOcclusion().noDrops()));
|
||||
ITEM_HANGER_BLOCK = BLOCKS.register("item_hanger", () -> new ItemHangerBlock(BlockBehaviour.Properties.of(Material.WOOL).noCollission().noOcclusion().noLootTable()));
|
||||
public static final RegistryObject<BlockEntityType<ItemHangerBlockEntity>>
|
||||
ITEM_HANGER_BE = BLOCK_ENTITY_TYPES.register("item_hanger", () -> BlockEntityType.Builder.of(ItemHangerBlockEntity::new, ITEM_HANGER_BLOCK.get()).build(null));
|
||||
public static final RegistryObject<Item>
|
||||
@@ -132,11 +132,8 @@ public class CustomTransformTypeTest
|
||||
{
|
||||
DataGenerator gen = event.getGenerator();
|
||||
|
||||
if (event.includeClient())
|
||||
{
|
||||
gen.addProvider(new ItemModels(gen, event.getExistingFileHelper()));
|
||||
gen.addProvider(new BlockStateModels(gen, event.getExistingFileHelper()));
|
||||
}
|
||||
gen.addProvider(event.includeClient(), new ItemModels(gen, event.getExistingFileHelper()));
|
||||
gen.addProvider(event.includeClient(), new BlockStateModels(gen, event.getExistingFileHelper()));
|
||||
}
|
||||
|
||||
public static class BlockStateModels extends BlockStateProvider
|
||||
|
||||
@@ -13,10 +13,12 @@ import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
@Mod(MultiLayerModelTest.MODID)
|
||||
public class MultiLayerModelTest
|
||||
@@ -27,33 +29,29 @@ public class MultiLayerModelTest
|
||||
|
||||
private static final String blockName = "test_layer_block";
|
||||
private static final ResourceLocation blockId = new ResourceLocation(MODID, blockName);
|
||||
@ObjectHolder(blockName)
|
||||
@ObjectHolder(registryName = "block", value = blockName)
|
||||
public static final Block TEST_BLOCK = null;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class Registration
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegisterEvent event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
if (!ENABLED || !event.getRegistryKey().equals(ForgeRegistries.Keys.BLOCKS))
|
||||
return;
|
||||
event.getRegistry().register(
|
||||
new Block(Block.Properties.of(Material.WOOD).noOcclusion())
|
||||
{
|
||||
}.setRegistryName(blockId)
|
||||
);
|
||||
event.register(ForgeRegistries.Keys.BLOCKS, blockId, () -> new Block(Block.Properties.of(Material.WOOD).noOcclusion()));
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegisterEvent event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
if (!ENABLED || !event.getRegistryKey().equals(ForgeRegistries.Keys.ITEMS))
|
||||
return;
|
||||
event.getRegistry().register(new BlockItem(TEST_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)).setRegistryName(TEST_BLOCK.getRegistryName()));
|
||||
event.register(ForgeRegistries.Keys.ITEMS, blockId, () -> new BlockItem(TEST_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
@SubscribeEvent
|
||||
public static void clientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
|
||||
@@ -50,7 +50,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@@ -65,6 +64,7 @@ import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mod(NewModelLoaderTest.MODID)
|
||||
public class NewModelLoaderTest
|
||||
@@ -215,13 +215,10 @@ public class NewModelLoaderTest
|
||||
{
|
||||
DataGenerator gen = event.getGenerator();
|
||||
|
||||
if (event.includeClient())
|
||||
{
|
||||
// Let blockstate provider see generated item models by passing its existing file helper
|
||||
ItemModelProvider itemModels = new ItemModels(gen, event.getExistingFileHelper());
|
||||
gen.addProvider(itemModels);
|
||||
gen.addProvider(new BlockStates(gen, itemModels.existingFileHelper));
|
||||
}
|
||||
// Let blockstate provider see generated item models by passing its existing file helper
|
||||
ItemModelProvider itemModels = new ItemModels(gen, event.getExistingFileHelper());
|
||||
gen.addProvider(event.includeClient(), itemModels);
|
||||
gen.addProvider(event.includeClient(), new BlockStates(gen, itemModels.existingFileHelper));
|
||||
}
|
||||
|
||||
public static class ItemModels extends ItemModelProvider
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
@@ -41,6 +39,7 @@ import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mod(TRSRTransformerTest.MODID)
|
||||
public class TRSRTransformerTest {
|
||||
@@ -75,7 +74,7 @@ public class TRSRTransformerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData data) {
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand, IModelData data) {
|
||||
ImmutableList.Builder<BakedQuad> quads = new ImmutableList.Builder<>();
|
||||
|
||||
Quaternion rot = TransformationHelper.quatFromXYZ(new Vector3f(0, 45, 0), true);
|
||||
|
||||
+9
-5
@@ -25,11 +25,12 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -38,14 +39,17 @@ import java.util.Collections;
|
||||
public class EntityRendererEventsTest
|
||||
{
|
||||
private static final ResourceLocation MY_ENTITY = new ResourceLocation("entity_renderer_events_test", "test_entity");
|
||||
|
||||
@ObjectHolder("entity_renderer_events_test:test_entity")
|
||||
|
||||
@ObjectHolder(registryName = "entity_type", value = "entity_renderer_events_test:test_entity")
|
||||
public static EntityType<MyEntity> MY_ENTITY_TYPE;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void entityRegistry(RegistryEvent.Register<EntityType<?>> event)
|
||||
public static void entityRegistry(RegisterEvent event)
|
||||
{
|
||||
event.getRegistry().register(EntityType.Builder.of(MyEntity::new, MobCategory.MONSTER).build("test_entity").setRegistryName("test_entity"));
|
||||
if (event.getRegistryKey().equals(ForgeRegistries.Keys.ENTITY_TYPES))
|
||||
{
|
||||
event.register(ForgeRegistries.Keys.ENTITY_TYPES, MY_ENTITY, () -> EntityType.Builder.of(MyEntity::new, MobCategory.MONSTER).build("test_entity"));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@
|
||||
|
||||
package net.minecraftforge.debug.client.rendering;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.animal.Cow;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraftforge.client.event.RenderNameplateEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -34,7 +34,7 @@ public class NameplateRenderingEventTest
|
||||
|
||||
if(event.getEntity() instanceof Cow)
|
||||
{
|
||||
event.setContent(new TextComponent("Evil Cow").withStyle(ChatFormatting.RED));
|
||||
event.setContent(Component.literal("Evil Cow").withStyle(ChatFormatting.RED));
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user