Add reverse tag cache, to make looking up tags for items/blocks/etc.. less costly.

This commit is contained in:
LexManos committed 2019-06-12 19:28:10 -07:00
1 parent 9542f51cd0
commit c30b27fcfe
15 files changed
+221 -26

No files matched your search

@@ -21,6 +21,7 @@ package net.minecraftforge.common.extensions;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import javax.annotation.Nullable;
@@ -28,11 +29,9 @@ import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BedBlock;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.block.FenceBlock;
import net.minecraft.block.FireBlock;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.IBeaconBeamColorProvider;
import net.minecraft.block.StainedGlassBlock;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
@@ -52,7 +51,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.WitherSkullEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.block.Blocks;
import net.minecraft.item.Items;
import net.minecraft.potion.Effects;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
@@ -65,7 +63,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
@@ -86,6 +83,7 @@ import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.ToolType;
@SuppressWarnings("deprecation")
public interface IForgeBlock
{
default Block getBlock()
@@ -177,7 +175,6 @@ public interface IForgeBlock
* @param state State of the current block
* @return True if block has a tile entity, false otherwise
*/
@SuppressWarnings("deprecation")
default boolean hasTileEntity(BlockState state)
{
return this instanceof ITileEntityProvider;
@@ -192,7 +189,6 @@ public interface IForgeBlock
* @param world The world to create the TE in
* @return A instance of a class extending TileEntity
*/
@SuppressWarnings("deprecation")
@Nullable
default TileEntity createTileEntity(BlockState state, IBlockReader world)
{
@@ -606,7 +602,6 @@ public interface IForgeBlock
return 0;
}
@SuppressWarnings("deprecation")
default BlockState rotate(BlockState state, IWorld world, BlockPos pos, Rotation direction)
{
return state.rotate(direction);
@@ -855,7 +850,6 @@ public interface IForgeBlock
* @param hand The player hand used to place this block
* @return The state to be placed in the world
*/
@SuppressWarnings("deprecation")
default BlockState getStateForPlacement(BlockState state, Direction facing, BlockState state2, IWorld world, BlockPos pos1, BlockPos pos2, Hand hand)
{
return this.getBlock().updatePostPlacement(state, facing, state2, world, pos1, pos2);
@@ -905,7 +899,6 @@ public interface IForgeBlock
* @param face The face that the fire is coming from
* @return A number ranging from 0 to 300 relating used to determine if the block will be consumed by fire
*/
@SuppressWarnings("deprecation")
default int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face)
{
return ((FireBlock)Blocks.FIRE).func_220274_q(state);
@@ -1006,9 +999,14 @@ public interface IForgeBlock
/**
* Determines if this block should drop loot when exploded.
*/
@SuppressWarnings("deprecation")
default boolean canDropFromExplosion(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion)
{
return state.getBlock().canDropFromExplosion(explosion);
}
/**
* Retrieves a list of tags names this is known to be associated with.
* This should be used in favor of TagCollection.getOwningTags, as this caches the result and automatically updates when the TagCollection changes.
*/
Set<ResourceLocation> getTags();
}
@@ -19,6 +19,8 @@
package net.minecraftforge.common.extensions;
import java.util.Set;
import javax.annotation.Nullable;
import net.minecraft.block.material.Material;
@@ -28,6 +30,7 @@ import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.IFluidState;
import net.minecraft.tags.Tag;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
@@ -108,4 +111,10 @@ public interface IForgeFluid
{
return this.getFluid().getRenderLayer() == layer;
}
/**
* Retrieves a list of tags names this is known to be associated with.
* This should be used in favor of TagCollection.getOwningTags, as this caches the result and automatically updates when the TagCollection changes.
*/
Set<ResourceLocation> getTags();
}
@@ -28,6 +28,7 @@ import com.google.common.collect.Multimap;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.LivingEntity;
@@ -43,6 +44,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
@@ -759,5 +761,11 @@ public interface IForgeItem
* one.
*/
@OnlyIn(Dist.CLIENT)
net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer getTileEntityItemStackRenderer();
ItemStackTileEntityRenderer getTileEntityItemStackRenderer();
/**
* Retrieves a list of tags names this is known to be associated with.
* This should be used in favor of TagCollection.getOwningTags, as this caches the result and automatically updates when the TagCollection changes.
*/
Set<ResourceLocation> getTags();
}