mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
Port capability patches to 1.13 and refactor to new system (#5134)
* resource package and misc leftover rendering stuff * Port Item and ItemStack patches * Extract most item patches to interface * Refactor Item#setNoRepair to be part of Item.Builder * Adapt AnimationItemOverrideList to new cap system * Improve null contract of OptionalCapabilityInstance * Remove Capability.cast * Update CapabilityAnimation to new cap system * Remove OptionalCapabilityInstance#flatMap and add NonNullConsumer * Add capability patch to Entity, not everything yet * Fix Entity patch and add missing methods to IForgeEntity * Fix null contract of CapabilityDispatcher * Add TileEntity caps * Adapt FluidUtil to new cap system * Add world caps * Add chunk caps * Clean up cap patches * Replace all tabs with spaces * Move builder methods on Item to Item.Builder Whitepsace fix * Sided stuff take 2 * Prevent OptionalCapabilityInstance creating additional empty instances * Cache getCapability result in AnimationTESR * Fix imports in TileEntity patch * Pull out cap code to base class, add village caps
This commit is contained in:
1 parent
f851b37aa0
commit
334d925972
45 files changed
+1967
-266
No files matched your search
@@ -328,9 +328,9 @@ public class ForgeEventFactory
|
||||
return event.getNewState();
|
||||
}
|
||||
|
||||
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable EntityPlayer entityPlayer, List<String> toolTip, ITooltipFlag flags)
|
||||
public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable EntityPlayer entityPlayer, List<ITextComponent> list, ITooltipFlag flags)
|
||||
{
|
||||
ItemTooltipEvent event = new ItemTooltipEvent(itemStack, entityPlayer, toolTip, flags);
|
||||
ItemTooltipEvent event = new ItemTooltipEvent(itemStack, entityPlayer, list, flags);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event;
|
||||
}
|
||||
@@ -624,41 +624,18 @@ public class ForgeEventFactory
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new RenderBlockOverlayEvent(player, renderPartialTicks, type, block, pos));
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public static CapabilityDispatcher gatherCapabilities(TileEntity tileEntity)
|
||||
public static <T extends ICapabilityProvider> CapabilityDispatcher gatherCapabilities(Class<? extends T> type, T provider)
|
||||
{
|
||||
return gatherCapabilities(new AttachCapabilitiesEvent<TileEntity>(TileEntity.class, tileEntity), null);
|
||||
return gatherCapabilities(type, provider, null);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static CapabilityDispatcher gatherCapabilities(Entity entity)
|
||||
public static <T extends ICapabilityProvider> CapabilityDispatcher gatherCapabilities(Class<? extends T> type, T provider, @Nullable ICapabilityProvider parent)
|
||||
{
|
||||
return gatherCapabilities(new AttachCapabilitiesEvent<Entity>(Entity.class, entity), null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CapabilityDispatcher gatherCapabilities(Village village)
|
||||
{
|
||||
return gatherCapabilities(new AttachCapabilitiesEvent<Village>(Village.class, village), null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CapabilityDispatcher gatherCapabilities(ItemStack stack, ICapabilityProvider parent)
|
||||
{
|
||||
return gatherCapabilities(new AttachCapabilitiesEvent<ItemStack>(ItemStack.class, stack), parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CapabilityDispatcher gatherCapabilities(World world, ICapabilityProvider parent)
|
||||
{
|
||||
return gatherCapabilities(new AttachCapabilitiesEvent<World>(World.class, world), parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CapabilityDispatcher gatherCapabilities(Chunk chunk)
|
||||
{
|
||||
return gatherCapabilities(new AttachCapabilitiesEvent<Chunk>(Chunk.class, chunk), null);
|
||||
return gatherCapabilities(new AttachCapabilitiesEvent<T>((Class<T>) type, provider), parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -34,17 +35,17 @@ public class ItemTooltipEvent extends PlayerEvent
|
||||
private final ITooltipFlag flags;
|
||||
@Nonnull
|
||||
private final ItemStack itemStack;
|
||||
private final List<String> toolTip;
|
||||
private final List<ITextComponent> toolTip;
|
||||
|
||||
/**
|
||||
* This event is fired in {@link ItemStack#getTooltip(EntityPlayer, ITooltipFlag)}, which in turn is called from it's respective GUIContainer.
|
||||
* Tooltips are also gathered with a null entityPlayer during startup by {@link Minecraft#populateSearchTreeManager()}.
|
||||
*/
|
||||
public ItemTooltipEvent(@Nonnull ItemStack itemStack, @Nullable EntityPlayer entityPlayer, List<String> toolTip, ITooltipFlag flags)
|
||||
public ItemTooltipEvent(@Nonnull ItemStack itemStack, @Nullable EntityPlayer entityPlayer, List<ITextComponent> list, ITooltipFlag flags)
|
||||
{
|
||||
super(entityPlayer);
|
||||
this.itemStack = itemStack;
|
||||
this.toolTip = toolTip;
|
||||
this.toolTip = list;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ public class ItemTooltipEvent extends PlayerEvent
|
||||
/**
|
||||
* The {@link ItemStack} tooltip.
|
||||
*/
|
||||
public List<String> getToolTip()
|
||||
public List<ITextComponent> getToolTip()
|
||||
{
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user