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:
committed 2022-06-07 15:31:26 -05:00
1 parent 270e778ac5
commit 4ed9117799
1485 files changed
+14960 -15446

No files matched your search

@@ -1,35 +0,0 @@
/*
* Minecraft Forge - Forge Development LLC
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.debug.block;
import net.minecraft.world.item.BannerPatternItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.BannerPattern;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@Mod("banner_pattern_test")
public class BannerPatternTest
{
private static final boolean ENABLED = true;
public BannerPatternTest()
{
if (!ENABLED) return;
BannerPattern.create("BANNER_PATTERN_TEST_TEST1", "banner_pattern_test:test1", "bpt:t1");
var pattern = BannerPattern.create("BANNER_PATTERN_TEST_TEST2", "banner_pattern_test:test2", "bpt:t2", true);
BannerPattern.create("BANNER_PATTERN_TEST_TEST3", "banner_pattern_test:test3", "bpt:t3");
var register = DeferredRegister.create(ForgeRegistries.ITEMS, "banner_pattern_test");
register.register("pattern_item_test", () -> new BannerPatternItem(pattern, new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_MISC)));
register.register(FMLJavaModLoadingContext.get().getModEventBus());
}
}
@@ -25,9 +25,9 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import javax.annotation.Nullable;
import java.util.Locale;
@Mod("be_onload_test")
@@ -19,11 +19,12 @@ import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelReader;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.PlantType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.registries.RegisterEvent;
@Mod(CustomPlantTypeTest.MODID)
@Mod.EventBusSubscriber(bus = Bus.MOD)
@@ -33,22 +34,29 @@ public class CustomPlantTypeTest
private static final String CUSTOM_SOIL_BLOCK = "test_custom_block";
private static final String CUSTOM_PLANT_BLOCK = "test_custom_plant";
@ObjectHolder(CUSTOM_SOIL_BLOCK)
@ObjectHolder(registryName = "block", value = CUSTOM_SOIL_BLOCK)
public static Block CUSTOM_SOIL;
@ObjectHolder(CUSTOM_PLANT_BLOCK)
@ObjectHolder(registryName = "block", value = CUSTOM_PLANT_BLOCK)
public static Block CUSTOM_PLANT;
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
public static void registerBlocks(RegisterEvent event)
{
event.getRegistry().registerAll(new CustomBlock(), new CustomPlantBlock());
event.register(ForgeRegistries.Keys.BLOCKS, helper ->
{
helper.register(CUSTOM_SOIL_BLOCK, new CustomBlock());
helper.register(CUSTOM_PLANT_BLOCK, new CustomPlantBlock());
});
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
public static void registerItems(RegisterEvent event)
{
event.getRegistry().registerAll(new BlockItem(CUSTOM_SOIL, (new Item.Properties())).setRegistryName(MODID, CUSTOM_SOIL_BLOCK),
new BlockItem(CUSTOM_PLANT, (new Item.Properties())).setRegistryName(MODID, CUSTOM_PLANT_BLOCK));
event.register(ForgeRegistries.Keys.ITEMS, helper ->
{
helper.register(CUSTOM_SOIL_BLOCK, new BlockItem(CUSTOM_SOIL, new Item.Properties()));
helper.register(CUSTOM_PLANT_BLOCK, new BlockItem(CUSTOM_PLANT, new Item.Properties()));
});
}
public static class CustomBlock extends Block
@@ -56,7 +64,6 @@ public class CustomPlantTypeTest
public CustomBlock()
{
super(Properties.of(Material.STONE));
this.setRegistryName(MODID, CUSTOM_SOIL_BLOCK);
}
@Override
@@ -78,7 +85,6 @@ public class CustomPlantTypeTest
public CustomPlantBlock()
{
super(MobEffects.WEAKNESS, 9, Properties.of(Material.PLANT).noCollission().sound(SoundType.GRASS));
this.setRegistryName(MODID, CUSTOM_PLANT_BLOCK);
}
@Override
@@ -28,8 +28,8 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
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.Optional;
@Mod(CustomRespawnTest.MODID)
@@ -10,9 +10,9 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FlowerPotBlock;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.registries.RegisterEvent;
import net.minecraftforge.registries.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
@@ -30,20 +30,26 @@ public class FlowerPotTest
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
public static final RegistryObject<FlowerPotBlock> EMPTY_FLOWER_POT = BLOCKS.register(BLOCK_ID, () -> new FlowerPotBlock(null, Blocks.AIR.delegate, Block.Properties.copy(Blocks.FLOWER_POT)));
public static final RegistryObject<FlowerPotBlock> EMPTY_FLOWER_POT = BLOCKS.register(BLOCK_ID, () -> new FlowerPotBlock(null, ForgeRegistries.BLOCKS.getDelegateOrThrow(Blocks.AIR), Block.Properties.copy(Blocks.FLOWER_POT)));
public static final RegistryObject<FlowerPotBlock> OAK_FLOWER_POT = BLOCKS.<FlowerPotBlock>register(
BLOCK_ID + "_oak", () -> new FlowerPotBlock(EMPTY_FLOWER_POT, Blocks.OAK_SAPLING.delegate, Block.Properties.copy(Blocks.FLOWER_POT)));
BLOCK_ID + "_oak", () -> new FlowerPotBlock(EMPTY_FLOWER_POT, ForgeRegistries.BLOCKS.getDelegateOrThrow(Blocks.OAK_SAPLING), Block.Properties.copy(Blocks.FLOWER_POT)));
static {
static
{
ITEMS.register(BLOCK_ID, () -> new BlockItem(EMPTY_FLOWER_POT.get(), new Item.Properties()));
}
@SubscribeEvent
public static void onItemRegister(RegistryEvent.Register<Item> event) {
EMPTY_FLOWER_POT.get().addPlant(Blocks.OAK_SAPLING.getRegistryName(), OAK_FLOWER_POT);
public static void onItemRegister(RegisterEvent event)
{
if (event.getRegistryKey().equals(ForgeRegistries.Keys.ITEMS))
{
EMPTY_FLOWER_POT.get().addPlant(ForgeRegistries.BLOCKS.getKey(Blocks.OAK_SAPLING), OAK_FLOWER_POT);
}
}
public FlowerPotTest() {
public FlowerPotTest()
{
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
BLOCKS.register(modBus);
ITEMS.register(modBus);
@@ -22,6 +22,7 @@ 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;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
@@ -50,9 +51,9 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -104,7 +105,7 @@ public class FullPotsAccessorDemo
if (level.getBlockEntity(pos) instanceof DioriteFlowerPotBlockEntity be)
{
ItemStack stack = player.getItemInHand(hand);
boolean isFlower = stack.getItem() instanceof BlockItem item && ((FlowerPotBlock) Blocks.FLOWER_POT).getFullPotsView().containsKey(item.getRegistryName());
boolean isFlower = stack.getItem() instanceof BlockItem item && ((FlowerPotBlock) Blocks.FLOWER_POT).getFullPotsView().containsKey(ForgeRegistries.ITEMS.getKey(item));
boolean hasFlower = be.plant != Blocks.AIR;
if (isFlower != hasFlower)
@@ -227,7 +228,7 @@ public class FullPotsAccessorDemo
protected void saveAdditional(CompoundTag tag)
{
//noinspection ConstantConditions
tag.putString("plant", plant.getRegistryName().toString());
tag.putString("plant", ForgeRegistries.BLOCKS.getKey(plant).toString());
super.saveAdditional(tag);
}
}
@@ -284,9 +285,9 @@ public class FullPotsAccessorDemo
public DioritePotModel(BakedModel wrappedModel) { super(wrappedModel); }
@Nonnull
@NotNull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData)
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand, @NotNull IModelData extraData)
{
List<BakedQuad> quads = new ArrayList<>(originalModel.getQuads(state, side, rand, extraData));
@@ -299,9 +300,9 @@ public class FullPotsAccessorDemo
return quads;
}
private List<BakedQuad> getPlantQuads(Block plant, @Nullable Direction face, Random rand)
private List<BakedQuad> getPlantQuads(Block plant, @Nullable Direction face, RandomSource rand)
{
BlockState potState = ((FlowerPotBlock) Blocks.FLOWER_POT).getFullPotsView().getOrDefault(plant.getRegistryName(), Blocks.AIR.delegate).get().defaultBlockState();
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)
@@ -8,6 +8,7 @@ package net.minecraftforge.debug.block;
import java.util.List;
import java.util.Locale;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
@@ -22,7 +23,6 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.core.Direction;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.model.generators.BlockStateProvider;
@@ -80,11 +80,11 @@ public class PistonEventTest
{
if (pistonHelper.resolve())
{
player.sendMessage(new TextComponent(String.format(Locale.ENGLISH, "Piston will extend moving %d blocks and destroy %d blocks", pistonHelper.getToPush().size(), pistonHelper.getToDestroy().size())), player.getUUID());
player.sendSystemMessage(Component.literal(String.format(Locale.ENGLISH, "Piston will extend moving %d blocks and destroy %d blocks", pistonHelper.getToPush().size(), pistonHelper.getToDestroy().size())));
}
else
{
player.sendMessage(new TextComponent("Piston won't extend"), player.getUUID());
player.sendSystemMessage(Component.literal("Piston won't extend"));
}
}
@@ -125,11 +125,11 @@ public class PistonEventTest
BlockPos targetPos = event.getFaceOffsetPos().relative(event.getDirection());
boolean canPush = PistonBaseBlock.isPushable(event.getWorld().getBlockState(targetPos), (Level) event.getWorld(), event.getFaceOffsetPos(), event.getDirection().getOpposite(), false, event.getDirection());
boolean isAir = event.getWorld().isEmptyBlock(targetPos);
player.sendMessage(new TextComponent(String.format(Locale.ENGLISH, "Piston will retract moving %d blocks", !isAir && canPush ? 1 : 0)), player.getUUID());
player.sendSystemMessage(Component.literal(String.format(Locale.ENGLISH, "Piston will retract moving %d blocks", !isAir && canPush ? 1 : 0)));
}
else
{
player.sendMessage(new TextComponent("Piston will retract"), player.getUUID());
player.sendSystemMessage(Component.literal("Piston will retract"));
}
}
// Offset twice to see if retraction will pull cobblestone
@@ -141,10 +141,7 @@ public class PistonEventTest
{
DataGenerator gen = event.getGenerator();
if (event.includeClient())
{
gen.addProvider(new BlockStates(gen, event.getExistingFileHelper()));
}
gen.addProvider(event.includeClient(), new BlockStates(gen, event.getExistingFileHelper()));
}
private class BlockStates extends BlockStateProvider
@@ -157,7 +154,7 @@ public class PistonEventTest
@Override
protected void registerStatesAndModels()
{
ModelFile model = models().cubeAll(shiftOnMove.get().getRegistryName().getPath(), mcLoc("block/furnace_top"));
ModelFile model = models().cubeAll(shiftOnMove.getId().getPath(), mcLoc("block/furnace_top"));
simpleBlock(shiftOnMove.get(), model);
simpleBlockItem(shiftOnMove.get(), model);
}
@@ -22,8 +22,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
@Mod(RedstoneSidedConnectivityTest.MODID)
public class RedstoneSidedConnectivityTest
@@ -55,7 +55,7 @@ public class ScaffoldingTest
private void gatherData(final GatherDataEvent event)
{
DataGenerator gen = event.getGenerator();
if(event.includeClient()) gen.addProvider(new ScaffoldingBlockState(gen, MODID, event.getExistingFileHelper()));
gen.addProvider(event.includeClient(), new ScaffoldingBlockState(gen, MODID, event.getExistingFileHelper()));
}
static class ScaffoldingBlockState extends BlockStateProvider
@@ -14,11 +14,12 @@ import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.registries.RegisterEvent;
@Mod(SlipperinessTest.MOD_ID)
@EventBusSubscriber
@@ -27,26 +28,26 @@ public class SlipperinessTest
static final String MOD_ID = "slipperiness_test";
static final String BLOCK_ID = "test_block";
@ObjectHolder(BLOCK_ID)
@ObjectHolder(registryName = "block", value = BLOCK_ID)
public static final Block BB_BLOCK = null;
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> e)
public static void registerBlocks(RegisterEvent e)
{
e.getRegistry().register((new Block(Block.Properties.of(Material.ICE_SOLID))
e.register(ForgeRegistries.Keys.BLOCKS, helper -> helper.register(BLOCK_ID, new Block(Block.Properties.of(Material.ICE_SOLID))
{
@Override
public float getFriction(BlockState state, LevelReader level, BlockPos pos, Entity entity)
{
return entity instanceof Boat ? 2 : super.getFriction(state, level, pos, entity);
}
}).setRegistryName(MOD_ID, BLOCK_ID));
}));
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> e)
public static void registerItems(RegisterEvent e)
{
e.getRegistry().register(new BlockItem(BB_BLOCK, new Item.Properties()).setRegistryName(BB_BLOCK.getRegistryName()));
e.register(ForgeRegistries.Keys.ITEMS, helper -> helper.register(BLOCK_ID, new BlockItem(BB_BLOCK, new Item.Properties())));
}
/*
@@ -10,11 +10,12 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.registries.RegisterEvent;
@Mod(StickyBlockTest.MODID)
@Mod.EventBusSubscriber(bus = Bus.MOD)
@@ -23,25 +24,25 @@ public class StickyBlockTest
static final String MODID = "custom_slime_block_test";
static final String BLOCK_ID = "test_block";
@ObjectHolder(BLOCK_ID)
@ObjectHolder(registryName = "block", value = BLOCK_ID)
public static Block BLUE_BLOCK;
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
public static void registerBlocks(RegisterEvent event)
{
event.getRegistry().register((new Block(Block.Properties.of(Material.STONE))
event.register(ForgeRegistries.Keys.BLOCKS, helper -> helper.register(BLOCK_ID, new Block(Block.Properties.of(Material.STONE))
{
@Override
public boolean isStickyBlock(BlockState state)
{
return true;
}
}).setRegistryName(MODID, BLOCK_ID));
}));
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
public static void registerItems(RegisterEvent event)
{
event.getRegistry().register(new BlockItem(BLUE_BLOCK, new Item.Properties()).setRegistryName(MODID, BLOCK_ID));
event.register(ForgeRegistries.Keys.ITEMS, helper -> helper.register(BLOCK_ID, new BlockItem(BLUE_BLOCK, new Item.Properties())));
}
}