mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Update to 1.17
Update to Official classnames Patchwork Make the game compile and run Merge in the new HUD overlay API Merge in the new render properties API PEEL Use Gradle 7.2 snapshot to fix eclipse integration bug in 7.1, Would use 7.0 but FG needs 7.1 for some reason. New FML installer Update to 1.17.1 Co-authored-by: LexManos <[email protected]> Co-authored-by: SizableShrimp <[email protected]> Co-authored-by: cpw <[email protected]> Co-authored-by: Curle <[email protected]> Co-authored-by: Unnoen <[email protected]> Co-authored-by: covers1624 <[email protected]> Co-authored-by: DaemonUmbra <[email protected]> Co-authored-by: gigaherz <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
064ae6961b
commit
be5446b91c
1990 files changed
+35661
-37544
No files matched your search
@@ -19,24 +19,24 @@
|
||||
|
||||
package net.minecraftforge.debug.misc;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
@@ -44,24 +44,24 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import net.minecraftforge.fmllegacy.network.NetworkHooks;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
@Mod("containertypetest")
|
||||
public class ContainerTypeTest
|
||||
{
|
||||
@ObjectHolder("containertypetest:container")
|
||||
public static final ContainerType<TestContainer> TYPE = null;
|
||||
public class TestContainer extends Container
|
||||
public static final MenuType<TestContainer> TYPE = null;
|
||||
public class TestContainer extends AbstractContainerMenu
|
||||
{
|
||||
private final String text;
|
||||
|
||||
protected TestContainer(int windowId, PlayerInventory playerInv, PacketBuffer extraData)
|
||||
protected TestContainer(int windowId, Inventory playerInv, FriendlyByteBuf extraData)
|
||||
{
|
||||
this(windowId, new Inventory(9), extraData.readUtf(128));
|
||||
this(windowId, new SimpleContainer(9), extraData.readUtf(128));
|
||||
}
|
||||
|
||||
public TestContainer(int windowId, Inventory inv, String text)
|
||||
public TestContainer(int windowId, SimpleContainer inv, String text)
|
||||
{
|
||||
super(TYPE, windowId);
|
||||
this.text = text;
|
||||
@@ -72,21 +72,21 @@ public class ContainerTypeTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(PlayerEntity playerIn)
|
||||
public boolean stillValid(Player playerIn)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestGui extends ContainerScreen<TestContainer>
|
||||
public class TestGui extends AbstractContainerScreen<TestContainer>
|
||||
{
|
||||
public TestGui(TestContainer container, PlayerInventory inv, ITextComponent name)
|
||||
public TestGui(TestContainer container, Inventory inv, Component name)
|
||||
{
|
||||
super(container, inv, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(MatrixStack mStack, float partialTicks, int mouseX, int mouseY)
|
||||
protected void renderBg(PoseStack mStack, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
drawString(mStack, this.font, getMenu().text, mouseX, mouseY, -1);
|
||||
}
|
||||
@@ -94,34 +94,34 @@ public class ContainerTypeTest
|
||||
|
||||
public ContainerTypeTest()
|
||||
{
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(ContainerType.class, this::registerContainers);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(MenuType.class, this::registerContainers);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onRightClick);
|
||||
}
|
||||
|
||||
private void registerContainers(final RegistryEvent.Register<ContainerType<?>> event)
|
||||
private void registerContainers(final RegistryEvent.Register<MenuType<?>> event)
|
||||
{
|
||||
event.getRegistry().register(IForgeContainerType.create(TestContainer::new).setRegistryName("container"));
|
||||
}
|
||||
|
||||
private void setup(FMLClientSetupEvent event)
|
||||
{
|
||||
ScreenManager.register(TYPE, TestGui::new);
|
||||
MenuScreens.register(TYPE, TestGui::new);
|
||||
}
|
||||
|
||||
private void onRightClick(PlayerInteractEvent.RightClickBlock event)
|
||||
{
|
||||
if (!event.getWorld().isClientSide && event.getHand() == Hand.MAIN_HAND)
|
||||
if (!event.getWorld().isClientSide && event.getHand() == InteractionHand.MAIN_HAND)
|
||||
{
|
||||
if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.SPONGE)
|
||||
{
|
||||
String text = "Hello World!";
|
||||
NetworkHooks.openGui((ServerPlayerEntity) event.getPlayer(), new INamedContainerProvider()
|
||||
NetworkHooks.openGui((ServerPlayer) event.getPlayer(), new MenuProvider()
|
||||
{
|
||||
@Override
|
||||
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_)
|
||||
public AbstractContainerMenu createMenu(int p_createMenu_1_, Inventory p_createMenu_2_, Player p_createMenu_3_)
|
||||
{
|
||||
Inventory inv = new Inventory(9);
|
||||
SimpleContainer inv = new SimpleContainer(9);
|
||||
for (int i = 0; i < inv.getContainerSize(); i++)
|
||||
{
|
||||
inv.setItem(i, new ItemStack(Items.DIAMOND));
|
||||
@@ -130,9 +130,9 @@ public class ContainerTypeTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
public Component getDisplayName()
|
||||
{
|
||||
return new StringTextComponent("Test");
|
||||
return new TextComponent("Test");
|
||||
}
|
||||
}, extraData -> {
|
||||
extraData.writeUtf(text);
|
||||
|
||||
@@ -23,23 +23,24 @@ import com.google.common.collect.Sets;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.PotionItem;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.potion.Potions;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.PotionItem;
|
||||
import net.minecraft.world.item.alchemy.Potion;
|
||||
import net.minecraft.world.item.alchemy.PotionUtils;
|
||||
import net.minecraft.world.item.alchemy.Potions;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagCollectionManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.tags.SerializationTags;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeTagHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
@@ -47,9 +48,9 @@ import net.minecraftforge.common.data.ForgeRegistryTagsProvider;
|
||||
import net.minecraftforge.common.util.ReverseTagWrapper;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fmllegacy.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
@@ -69,11 +70,11 @@ public class CustomTagTypesTest
|
||||
private static final RegistryObject<Custom> CUSTOM = CUSTOMS.register("custom", Custom::new);
|
||||
private static final Supplier<IForgeRegistry<Custom>> CUSTOM_REG = CUSTOMS.makeRegistry(customRegistryName.getPath(),
|
||||
() -> new RegistryBuilder<Custom>().tagFolder(MODID + "/custom_types"));
|
||||
private static final ITag.INamedTag<Custom> TESTS = ForgeTagHandler.createOptionalTag(customRegistryName, new ResourceLocation(MODID, "tests"), Sets.newHashSet(CUSTOM));
|
||||
private static final ITag.INamedTag<Item> OPTIONAL_TEST = ItemTags.createOptional(new ResourceLocation(MODID, "optional_test"), Sets.newHashSet(() -> Items.BONE));
|
||||
private static final ITag.INamedTag<Enchantment> FIRE = ForgeTagHandler.createOptionalTag(ForgeRegistries.ENCHANTMENTS, new ResourceLocation(MODID, "fire"));
|
||||
private static final ITag.INamedTag<Potion> DAMAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.POTION_TYPES, new ResourceLocation(MODID, "damage"));
|
||||
private static final ITag.INamedTag<TileEntityType<?>> STORAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.TILE_ENTITIES, new ResourceLocation(MODID, "storage"));
|
||||
private static final Tag.Named<Custom> TESTS = ForgeTagHandler.createOptionalTag(customRegistryName, new ResourceLocation(MODID, "tests"), Sets.newHashSet(CUSTOM));
|
||||
private static final Tag.Named<Item> OPTIONAL_TEST = ItemTags.createOptional(new ResourceLocation(MODID, "optional_test"), Sets.newHashSet(() -> Items.BONE));
|
||||
private static final Tag.Named<Enchantment> FIRE = ForgeTagHandler.createOptionalTag(ForgeRegistries.ENCHANTMENTS, new ResourceLocation(MODID, "fire"));
|
||||
private static final Tag.Named<Potion> DAMAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.POTION_TYPES, new ResourceLocation(MODID, "damage"));
|
||||
private static final Tag.Named<BlockEntityType<?>> STORAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.BLOCK_ENTITIES, new ResourceLocation(MODID, "storage"));
|
||||
|
||||
public CustomTagTypesTest()
|
||||
{
|
||||
@@ -92,7 +93,7 @@ public class CustomTagTypesTest
|
||||
gen.addProvider(new CustomRegistryTags(gen, existingFileHelper));
|
||||
gen.addProvider(new EnchantmentTags(gen, existingFileHelper));
|
||||
gen.addProvider(new PotionTags(gen, existingFileHelper));
|
||||
gen.addProvider(new TileEntityTypeTags(gen, existingFileHelper));
|
||||
gen.addProvider(new BlockEntityTypeTags(gen, existingFileHelper));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,11 +102,11 @@ public class CustomTagTypesTest
|
||||
ItemStack itemStack = event.getItemStack();
|
||||
if (!itemStack.isEmpty())
|
||||
{
|
||||
LOGGER.info("{} {} {}", Items.BONE.getTags(), OPTIONAL_TEST.getValues().size(), TagCollectionManager.getInstance().getItems().getTag(new ResourceLocation(MODID, "optional_test")));
|
||||
LOGGER.info("{} {} {}", Items.BONE.getTags(), OPTIONAL_TEST.getValues().size(), SerializationTags.getInstance().getOrEmpty(Registry.ITEM_REGISTRY).getTag(new ResourceLocation(MODID, "optional_test")));
|
||||
EnchantmentHelper.getEnchantments(itemStack).forEach((enchantment, level) -> logTagsIfPresent(enchantment.getTags()));
|
||||
if (itemStack.getItem() instanceof PotionItem) logTagsIfPresent(PotionUtils.getPotion(itemStack).getTags());
|
||||
TileEntity tileEntity = event.getWorld().getBlockEntity(event.getPos());
|
||||
if (tileEntity != null) logTagsIfPresent(tileEntity.getType().getTags());
|
||||
BlockEntity blockEntity = event.getWorld().getBlockEntity(event.getPos());
|
||||
if (blockEntity != null) logTagsIfPresent(blockEntity.getType().getTags());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,14 +120,14 @@ public class CustomTagTypesTest
|
||||
|
||||
public static class Custom extends ForgeRegistryEntry<Custom>
|
||||
{
|
||||
private final ReverseTagWrapper<Custom> reverseTags = new ReverseTagWrapper<>(this, () -> TagCollectionManager.getInstance().getCustomTypeCollection(CUSTOM_REG.get()));
|
||||
private final ReverseTagWrapper<Custom> reverseTags = new ReverseTagWrapper<>(this, () -> SerializationTags.getInstance().getCustomTypeCollection(CUSTOM_REG.get()));
|
||||
|
||||
public Set<ResourceLocation> getTags()
|
||||
{
|
||||
return reverseTags.getTagNames();
|
||||
}
|
||||
|
||||
public boolean isIn(ITag<Custom> tag)
|
||||
public boolean isIn(Tag<Custom> tag)
|
||||
{
|
||||
return tag.contains(this);
|
||||
}
|
||||
@@ -192,17 +193,17 @@ public class CustomTagTypesTest
|
||||
}
|
||||
}
|
||||
|
||||
public static class TileEntityTypeTags extends ForgeRegistryTagsProvider<TileEntityType<?>>
|
||||
public static class BlockEntityTypeTags extends ForgeRegistryTagsProvider<BlockEntityType<?>>
|
||||
{
|
||||
public TileEntityTypeTags(DataGenerator gen, @Nullable ExistingFileHelper existingFileHelper)
|
||||
public BlockEntityTypeTags(DataGenerator gen, @Nullable ExistingFileHelper existingFileHelper)
|
||||
{
|
||||
super(gen, ForgeRegistries.TILE_ENTITIES, MODID, existingFileHelper);
|
||||
super(gen, ForgeRegistries.BLOCK_ENTITIES, MODID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags()
|
||||
{
|
||||
tag(STORAGE).add(TileEntityType.BARREL, TileEntityType.CHEST, TileEntityType.ENDER_CHEST);
|
||||
tag(STORAGE).add(BlockEntityType.BARREL, BlockEntityType.CHEST, BlockEntityType.ENDER_CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
package net.minecraftforge.debug.misc;
|
||||
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.command.arguments.EntityArgument;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
@@ -57,8 +57,8 @@ public class FakePlayerTest
|
||||
//Makes sure fake player does not crash when its `connection` is accessed [#7604]
|
||||
.then(Commands.literal("opencontainer")
|
||||
.executes(context -> {
|
||||
ServerPlayerEntity fakePlayer = FakePlayerFactory.getMinecraft(context.getSource().getLevel());
|
||||
Hand hand = Hand.MAIN_HAND;
|
||||
ServerPlayer fakePlayer = FakePlayerFactory.getMinecraft(context.getSource().getLevel());
|
||||
InteractionHand hand = InteractionHand.MAIN_HAND;
|
||||
ItemStack stack = Items.WRITABLE_BOOK.getDefaultInstance();
|
||||
fakePlayer.setItemInHand(hand, stack);
|
||||
fakePlayer.openItemGui(stack, hand);
|
||||
|
||||
@@ -22,4 +22,4 @@
|
||||
package net.minecraftforge.debug.misc;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
Reference in new issue
Block a user