Update to 1.14.2

This commit is contained in:
LexManos authored and cpw committed 2019-06-07 16:50:47 -04:00
1 parent d3e8804dbf
commit a7df63e1a1
1010 files changed
+15254 -19520

No files matched your search

@@ -1,118 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.extensions;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import com.google.common.collect.Maps;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.resources.IResourceManager;
import net.minecraft.resources.IResourceManagerReloadListener;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.RecipeType;
import net.minecraftforge.items.wrapper.RecipeWrapper;
@SuppressWarnings("deprecation")
public abstract class ForgeRecipeManager implements IResourceManagerReloadListener
{
/**
* Master list of sorted recipes.
*/
protected final Map<RecipeType<? extends IRecipe>, List<? extends IRecipe>> sortedRecipes = Maps.newHashMap();
@Override
public void onResourceManagerReload(IResourceManager resourceManager)
{
this.sortedRecipes.clear();
CraftingHelper.reloadConstants(resourceManager);
}
/**
* Returns all the recipes that match this type.
* @param type A recipe type.
* @return All recipes that are of the passed type. This list may be empty.
*/
@SuppressWarnings("unchecked")
public <T extends IRecipe> List<T> getRecipes(RecipeType<T> type)
{
return (List<T>) this.sortedRecipes.computeIfAbsent(type, t -> new ArrayList<>());
}
/**
* Automatically returns a result from the first recipe that matches this inv and type.
* Modders should probably not use this, and instead use {@link #getRecipe(IInventory, World, RecipeType)} since you get the recipe object itself.
* @param input An inventory.
* @param world The world.
* @param type The type of recipe to match against.
* @return The output of the first matching recipe, or {@link ItemStack#EMPTY} if no recipes match.
*/
public ItemStack getResult(IInventory input, World world, RecipeType<?> type)
{
for(IRecipe irecipe : getRecipes(type))
if (irecipe.matches(input, world)) return irecipe.getCraftingResult(input);
return ItemStack.EMPTY;
}
/**
* Used to find a matching recipe for the given inv, world, and type.
* Since this requires an IInventory, modders can use {@link RecipeWrapper} to avoid direct implementation.
* For crafting recipes, it is advised to still use {@link InventoryCrafting}. The dynamic vanilla recipes require they be crafted in one.
* @param input An inventory.
* @param world The world.
* @param type The type of recipe to match against.
* @return The first matching recipe.
*/
@Nullable
public <T extends IRecipe> T getRecipe(IInventory input, World world, RecipeType<T> type)
{
for(T irecipe : getRecipes(type))
if (irecipe.matches(input, world)) return irecipe;
return null;
}
/**
* Modders should not use this if possible. In the context that this is used, you should already have the recipe. Do not run extra lookups using this method.
* Use {@link IRecipe#getRemainingItems(IInventory)}.
*/
@Deprecated
public NonNullList<ItemStack> getRemainingItems(IInventory input, World world, RecipeType<?> type)
{
for(IRecipe irecipe : getRecipes(type))
if (irecipe.matches(input, world)) return irecipe.getRemainingItems(input);
NonNullList<ItemStack> nonnulllist = NonNullList.withSize(input.getSizeInventory(), ItemStack.EMPTY);
for(int i = 0; i < nonnulllist.size(); ++i)
nonnulllist.set(i, input.getStackInSlot(i));
return nonnulllist;
}
}
@@ -20,40 +20,41 @@
package net.minecraftforge.common.extensions;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBed;
import net.minecraft.block.BlockFarmland;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockFire;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockStainedGlass;
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;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EntitySpawnPlacementRegistry;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityWitherSkull;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.WitherSkullEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.EnumDyeColor;
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;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathNodeType;
@@ -62,8 +63,8 @@ import net.minecraft.state.properties.BedPart;
import net.minecraft.tags.BlockTags;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
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;
@@ -72,12 +73,12 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IEnviromentBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.IWorldReaderBase;
import net.minecraft.world.IWorldWriter;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.ServerWorld;
import net.minecraft.world.dimension.EndDimension;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -107,7 +108,7 @@ public interface IForgeBlock
* @param entity the entity in question
* @return the factor by which the entity's motion should be multiplied
*/
float getSlipperiness(IBlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity);
float getSlipperiness(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity);
/**
* Get a light value for this block, taking into account the given state and coordinates, normal ranges are between 0 and 15
@@ -117,7 +118,7 @@ public interface IForgeBlock
* @param pos
* @return The light value
*/
default int getLightValue(IBlockState state, IWorldReader world, BlockPos pos)
default int getLightValue(BlockState state, IEnviromentBlockReader world, BlockPos pos)
{
return state.getLightValue();
}
@@ -131,25 +132,11 @@ public interface IForgeBlock
* @param entity The entity trying to use the ladder, CAN be null.
* @return True if the block should act like a ladder
*/
default boolean isLadder(IBlockState state, IWorldReader world, BlockPos pos, EntityLivingBase entity)
default boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity)
{
return false;
}
/**
* Return true if the block is a normal, solid cube. This
* determines indirect power state, entity ejection from blocks, and a few
* others.
*
* @param state The current state
* @param world The current world
* @param pos Block position in world
* @return True if the block is a full cube
*/
default boolean isNormalCube(IBlockState state, IBlockReader world, BlockPos pos)
{
return state.isNormalCube();
}
/**
* Check if the face of a block should block rendering.
*
@@ -162,7 +149,7 @@ public interface IForgeBlock
* @param face The side to check
* @return True if the block is opaque on the specified side.
*/
default boolean doesSideBlockRendering(IBlockState state, IWorldReader world, BlockPos pos, EnumFacing face)
default boolean doesSideBlockRendering(BlockState state, IEnviromentBlockReader world, BlockPos pos, Direction face)
{
return state.isOpaqueCube(world, pos);
}
@@ -175,9 +162,9 @@ public interface IForgeBlock
* @param pos Block position in world
* @return True if the block should deal damage
*/
default boolean isBurning(IBlockState state, IBlockReader world, BlockPos pos)
default boolean isBurning(BlockState state, IBlockReader world, BlockPos pos)
{
return false;
return this == Blocks.FIRE || this == Blocks.LAVA;
}
/**
@@ -191,7 +178,7 @@ public interface IForgeBlock
* @return True if block has a tile entity, false otherwise
*/
@SuppressWarnings("deprecation")
default boolean hasTileEntity(IBlockState state)
default boolean hasTileEntity(BlockState state)
{
return this instanceof ITileEntityProvider;
}
@@ -207,24 +194,13 @@ public interface IForgeBlock
*/
@SuppressWarnings("deprecation")
@Nullable
default TileEntity createTileEntity(IBlockState state, IBlockReader world)
default TileEntity createTileEntity(BlockState state, IBlockReader world)
{
if (getBlock() instanceof ITileEntityProvider)
return ((ITileEntityProvider)getBlock()).createNewTileEntity(world);
return null;
}
/**
* Return true from this function if the player with silk touch can harvest this block directly, and not it's normal drops.
*
* @param state current block state
* @param world The world
* @param pos Block position in world
* @param player The player doing the harvesting
* @return True if the block can be directly harvested using silk touch
*/
boolean canSilkHarvest(IBlockState state, IWorldReader world, BlockPos pos, EntityPlayer player);
/**
* Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.
*
@@ -233,7 +209,7 @@ public interface IForgeBlock
* @param player The player damaging the block
* @return True to spawn the drops
*/
default public boolean canHarvestBlock(IBlockState state, IBlockReader world, BlockPos pos, EntityPlayer player)
default public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player)
{
return ForgeHooks.canHarvestBlock(state, player, world, pos);
}
@@ -258,10 +234,10 @@ public interface IForgeBlock
* @param fluid The current fluid state at current position
* @return True if the block is actually destroyed.
*/
default boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest, IFluidState fluid)
default boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid)
{
getBlock().onBlockHarvested(world, pos, state, player);
return world.setBlockState(pos, fluid.getBlockState(), world.isRemote ? 11 : 3);
return world.func_217377_a(pos, false);
}
/**
@@ -275,9 +251,9 @@ public interface IForgeBlock
* @param player The player or camera entity, null in some cases.
* @return True to treat this as a bed
*/
default boolean isBed(IBlockState state, IBlockReader world, BlockPos pos, @Nullable Entity player)
default boolean isBed(BlockState state, IBlockReader world, BlockPos pos, @Nullable Entity player)
{
return this.getBlock() instanceof BlockBed; //TODO: Forge: Keep isBed function?
return this.getBlock() instanceof BedBlock; //TODO: Forge: Keep isBed function?
}
/**
@@ -290,29 +266,29 @@ public interface IForgeBlock
* @param type The Mob Category Type
* @return True to allow a mob of the specified category to spawn, false to prevent it.
*/
default boolean canCreatureSpawn(IBlockState state, IWorldReaderBase world, BlockPos pos, EntitySpawnPlacementRegistry.SpawnPlacementType type, @Nullable EntityType<? extends EntityLiving> entityType)
default boolean canCreatureSpawn(BlockState state, IBlockReader world, BlockPos pos, EntitySpawnPlacementRegistry.PlacementType type, @Nullable EntityType<?> entityType)
{
return state.isTopSolid() || entityType != null && EntitySpawnPlacementRegistry.func_209345_a(entityType, state);
return state.func_215688_a(world, pos, entityType);
}
/**
* Returns the position that the player is moved to upon
* Returns the position that the sleeper is moved to upon
* waking up, or respawning at the bed.
*
* @param state The current state
* @param world The current world
* @param pos Block position in world
* @param player The player or camera entity, null in some cases.
* @param sleeper The sleeper or camera entity, null in some cases.
* @return The spawn position
*/
@Nullable
default BlockPos getBedSpawnPosition(IBlockState state, IBlockReader world, BlockPos pos, @Nullable EntityPlayer player)
default Optional<Vec3d> getBedSpawnPosition(EntityType<?> entityType, BlockState state, IWorldReader world, BlockPos pos, @Nullable LivingEntity sleeper)
{
if (world instanceof World)
{
return BlockBed.getSafeExitLocation(world,pos,0);
return BedBlock.func_220172_a(entityType, world,pos,0);
}
return null;
return Optional.empty();
}
/**
@@ -321,29 +297,29 @@ public interface IForgeBlock
*
* @param world The current world
* @param pos Block position in world
* @param player The player or camera entity, null in some cases.
* @param sleeper The sleeper or camera entity, null in some cases.
* @param occupied True if we are occupying the bed, or false if they are stopping use of the bed
*/
default void setBedOccupied(IBlockState state, IWorldReader world, BlockPos pos, EntityPlayer player, boolean occupied)
default void setBedOccupied(BlockState state, IWorldReader world, BlockPos pos, LivingEntity sleeper, boolean occupied)
{
if (world instanceof IWorldWriter)
{
((IWorldWriter)world).setBlockState(pos, state.with(BlockBed.OCCUPIED,occupied), 4);
((IWorldWriter)world).setBlockState(pos, state.with(BedBlock.OCCUPIED,occupied), 4);
}
}
/**
* Returns the direction of the block. Same values that
* are returned by BlockDirectional
* are returned by BlockDirectional. Called every frame tick for every living entity. Be VERY fast.
*
* @param state The current state
* @param world The current world
* @param pos Block position in world
* @return Bed direction
*/
default EnumFacing getBedDirection(IBlockState state, IWorldReader world, BlockPos pos)
default Direction getBedDirection(BlockState state, IWorldReader world, BlockPos pos)
{
return state.get(BlockHorizontal.HORIZONTAL_FACING);
return state.get(HorizontalBlock.HORIZONTAL_FACING);
}
/**
@@ -353,9 +329,9 @@ public interface IForgeBlock
* @param pos Block position in world
* @return True if the current block is the foot side of a bed.
*/
default boolean isBedFoot(IBlockState state, IWorldReader world, BlockPos pos)
default boolean isBedFoot(BlockState state, IWorldReader world, BlockPos pos)
{
return state.get(BlockBed.PART) == BedPart.FOOT;
return state.get(BedBlock.PART) == BedPart.FOOT;
}
/**
@@ -365,7 +341,7 @@ public interface IForgeBlock
* @param world The current world
* @param pos Block position in world
*/
default void beginLeaveDecay(IBlockState state, IWorldReader world, BlockPos pos) {}
default void beginLeaveDecay(BlockState state, IWorldReader world, BlockPos pos) {}
/**
* Determines this block should be treated as an air block
@@ -378,7 +354,7 @@ public interface IForgeBlock
* @param pos Block position in world
* @return True if the block considered air
*/
default boolean isAir(IBlockState state, IBlockReader world, BlockPos pos)
default boolean isAir(BlockState state, IBlockReader world, BlockPos pos)
{
return state.getMaterial() == Material.AIR;
}
@@ -391,11 +367,25 @@ public interface IForgeBlock
* @param pos Block position in world
* @return true if this block can be replaced by growing leaves.
*/
default boolean canBeReplacedByLeaves(IBlockState state, IWorldReaderBase world, BlockPos pos)
default boolean canBeReplacedByLeaves(BlockState state, IWorldReader world, BlockPos pos)
{
return (isAir(state, world, pos) || state.isIn(BlockTags.LEAVES)) || !state.isOpaqueCube(world, pos);
}
/**
* Used during tree growth to determine if newly generated logs can replace this block.
*
* @param state The current state
* @param world The current world
* @param pos Block position in world
* @return true if this block can be replaced by growing leaves.
*/
default boolean canBeReplacedByLogs(BlockState state, IWorldReader world, BlockPos pos)
{
return (isAir(state, world, pos) || state.isIn(BlockTags.LEAVES)) || this == Blocks.GRASS_BLOCK || Block.isDirt(getBlock())
|| getBlock().isIn(BlockTags.LOGS) || getBlock().isIn(BlockTags.SAPLINGS) || this == Blocks.VINE;
}
/**
* Determines if the current block is replaceable by Ore veins during world generation.
*
@@ -406,7 +396,7 @@ public interface IForgeBlock
* for overworld generation, and neatherack for the nether.
* @return True to allow this block to be replaced by a ore
*/
default boolean isReplaceableOreGen(IBlockState state, IWorldReader world, BlockPos pos, Predicate<IBlockState> target)
default boolean isReplaceableOreGen(BlockState state, IWorldReader world, BlockPos pos, Predicate<BlockState> target)
{
return target.test(state);
}
@@ -420,25 +410,11 @@ public interface IForgeBlock
* @param explosion The explosion
* @return The amount of the explosion absorbed.
*/
default float getExplosionResistance(IBlockState state, IWorldReader world, BlockPos pos, @Nullable Entity exploder, Explosion explosion)
default float getExplosionResistance(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity exploder, Explosion explosion)
{
return this.getBlock().getExplosionResistance();
}
/**
* Called when the block is destroyed by an explosion.
* Useful for allowing the block to take into account tile entities,
* state, etc. when exploded, before it is removed.
*
* @param world The current world
* @param pos Block position in world
* @param explosion The explosion instance affecting the block
*/
default void onBlockExploded(IBlockState state, World world, BlockPos pos, Explosion explosion) {
world.removeBlock(pos);
getBlock().onExplosionDestroy(world, pos, explosion);
}
/**
* Determine if this block can make a redstone connection on the side provided,
* Useful to control which sides are inputs and outputs for redstone wires.
@@ -449,33 +425,11 @@ public interface IForgeBlock
* @param side The side that is trying to make the connection, CAN BE NULL
* @return True to make the connection
*/
default boolean canConnectRedstone(IBlockState state, IBlockReader world, BlockPos pos, @Nullable EnumFacing side)
default boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, @Nullable Direction side)
{
return state.canProvidePower() && side != null;
}
/**
* Determines if a torch can be placed on the top surface of this block.
* Useful for creating your own block that torches can be on, such as fences.
*
* @param state The current state
* @param world The current world
* @param pos Block position in world
* @return True to allow the torch to be placed
*/
default boolean canPlaceTorchOnTop(IBlockState state, IWorldReaderBase world, BlockPos pos)
{
// Keep conditionals in sync with BlockTorch#isValidPosition
if (this == Blocks.END_GATEWAY) {
return false;
} else if (this instanceof BlockFence || this instanceof BlockStainedGlass || this == Blocks.GLASS || this == Blocks.COBBLESTONE_WALL || this == Blocks.MOSSY_COBBLESTONE_WALL || state.isTopSolid()) {
return true;
} else {
BlockFaceShape shape = state.getBlockFaceShape(world, pos, EnumFacing.UP);
return (shape == BlockFaceShape.SOLID || shape == BlockFaceShape.CENTER || shape == BlockFaceShape.CENTER_BIG) && !Block.isExceptionBlockForAttaching(getBlock());
}
}
/**
*
* Called when A user uses the creative pick block button on this block
@@ -483,7 +437,7 @@ public interface IForgeBlock
* @param target The full target the player is looking at
* @return A ItemStack to add to the player's inventory, empty itemstack if nothing should be added.
*/
default ItemStack getPickBlock(IBlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, EntityPlayer player)
default ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player)
{
return this.getBlock().getItem(world, pos, state);
}
@@ -494,7 +448,7 @@ public interface IForgeBlock
*
* @return False to disallow spawning.
*/
default boolean isFoliage(IBlockState state, IWorldReader world, BlockPos pos)
default boolean isFoliage(BlockState state, IWorldReader world, BlockPos pos)
{
return false;
}
@@ -511,7 +465,7 @@ public interface IForgeBlock
* @param numberOfParticles That vanilla world have spawned
* @return True to prevent vanilla landing particles from spawning
*/
default boolean addLandingEffects(IBlockState state1, WorldServer worldserver, BlockPos pos, IBlockState state2, EntityLivingBase entity, int numberOfParticles)
default boolean addLandingEffects(BlockState state1, ServerWorld worldserver, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles)
{
return false;
}
@@ -528,7 +482,7 @@ public interface IForgeBlock
* @param entity The entity running on the block.
* @return True to prevent vanilla running particles from spawning.
*/
default boolean addRunningEffects(IBlockState state, World world, BlockPos pos, Entity entity)
default boolean addRunningEffects(BlockState state, World world, BlockPos pos, Entity entity)
{
return false;
}
@@ -546,7 +500,7 @@ public interface IForgeBlock
* @return True to prevent vanilla digging particles form spawning.
*/
@OnlyIn(Dist.CLIENT)
default boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager)
default boolean addHitEffects(BlockState state, World worldObj, RayTraceResult target, ParticleManager manager)
{
return false;
}
@@ -563,7 +517,7 @@ public interface IForgeBlock
* @return True to prevent vanilla break particles from spawning.
*/
@OnlyIn(Dist.CLIENT)
default boolean addDestroyEffects(IBlockState state, World world, BlockPos pos, ParticleManager manager)
default boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager manager)
{
return false;
}
@@ -586,7 +540,7 @@ public interface IForgeBlock
* @param plantable The plant that wants to check
* @return True to allow the plant to be planted/stay.
*/
boolean canSustainPlant(IBlockState state, IBlockReader world, BlockPos pos, EnumFacing facing, IPlantable plantable);
boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction facing, IPlantable plantable);
/**
* Called when a plant grows on this block, only implemented for saplings using the WorldGen*Trees classes right now.
@@ -602,9 +556,9 @@ public interface IForgeBlock
* @param pos Block position in world
* @param source Source plant's position in world
*/
default void onPlantGrow(IBlockState state, IWorld world, BlockPos pos, BlockPos source)
default void onPlantGrow(BlockState state, IWorld world, BlockPos pos, BlockPos source)
{
if (this.getBlock() == Blocks.GRASS_BLOCK || this.getBlock() == Blocks.MYCELIUM || this.getBlock() == Blocks.FARMLAND || this.getBlock() == Blocks.AIR)
if (Block.isDirt(getBlock()))
world.setBlockState(pos, Blocks.DIRT.getDefaultState(), 2);
}
@@ -617,10 +571,10 @@ public interface IForgeBlock
* @param pos Block position in world
* @return True if the soil should be considered fertile.
*/
default boolean isFertile(IBlockState state, IBlockReader world, BlockPos pos)
default boolean isFertile(BlockState state, IBlockReader world, BlockPos pos)
{
if (this.getBlock() == Blocks.FARMLAND)
return state.get(BlockFarmland.MOISTURE) > 0;
return state.get(FarmlandBlock.MOISTURE) > 0;
return false;
}
@@ -633,7 +587,7 @@ public interface IForgeBlock
* @param beacon Beacon position in world
* @return True, to support the beacon, and make it active with this block.
*/
default boolean isBeaconBase(IBlockState state, IWorldReader world, BlockPos pos, BlockPos beacon)
default boolean isBeaconBase(BlockState state, IWorldReader world, BlockPos pos, BlockPos beacon)
{
return this.getBlock() == Blocks.EMERALD_BLOCK || this.getBlock() == Blocks.GOLD_BLOCK ||
this.getBlock() == Blocks.DIAMOND_BLOCK || this.getBlock() == Blocks.IRON_BLOCK;
@@ -647,13 +601,13 @@ public interface IForgeBlock
* @param fortune
* @return Amount of XP from breaking this block.
*/
default int getExpDrop(IBlockState state, IWorldReader world, BlockPos pos, int fortune)
default int getExpDrop(BlockState state, IWorldReader world, BlockPos pos, int fortune, int silktouch)
{
return 0;
}
@SuppressWarnings("deprecation")
default IBlockState rotate(IBlockState state, IWorld world, BlockPos pos, Rotation direction)
default BlockState rotate(BlockState state, IWorld world, BlockPos pos, Rotation direction)
{
return state.rotate(direction);
}
@@ -667,15 +621,15 @@ public interface IForgeBlock
* @return An array of valid axes to rotate around, or null for none or unknown
*/
@Nullable
default EnumFacing[] getValidRotations(IBlockState state, IBlockReader world, BlockPos pos)
default Direction[] getValidRotations(BlockState state, IBlockReader world, BlockPos pos)
{
for (IProperty<?> prop : state.getProperties())
{
if ((prop.getName().equals("facing") || prop.getName().equals("rotation")) && prop.getValueClass() == EnumFacing.class)
if ((prop.getName().equals("facing") || prop.getName().equals("rotation")) && prop.getValueClass() == Direction.class)
{
@SuppressWarnings("unchecked")
Collection<EnumFacing> values = ((Collection<EnumFacing>)prop.getAllowedValues());
return values.toArray(new EnumFacing[values.size()]);
Collection<Direction> values = ((Collection<Direction>)prop.getAllowedValues());
return values.toArray(new Direction[values.size()]);
}
}
return null;
@@ -687,7 +641,7 @@ public interface IForgeBlock
* @param pos Block position in world
* @return The amount of enchanting power this block produces.
*/
default float getEnchantPowerBonus(IBlockState state, IWorldReader world, BlockPos pos)
default float getEnchantPowerBonus(BlockState state, IWorldReader world, BlockPos pos)
{
return this.getBlock() == Blocks.BOOKSHELF ? 1: 0;
}
@@ -703,16 +657,16 @@ public interface IForgeBlock
* @return Amount of XP from breaking this block.
*/
@SuppressWarnings("unchecked")
default boolean recolorBlock(IBlockState state, IWorld world, BlockPos pos, EnumFacing facing, EnumDyeColor color)
default boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction facing, DyeColor color)
{
for (IProperty<?> prop : state.getProperties())
{
if (prop.getName().equals("color") && prop.getValueClass() == EnumDyeColor.class)
if (prop.getName().equals("color") && prop.getValueClass() == DyeColor.class)
{
EnumDyeColor current = (EnumDyeColor)state.get(prop);
DyeColor current = (DyeColor)state.get(prop);
if (current != color && prop.getAllowedValues().contains(color))
{
world.setBlockState(pos, state.with(((IProperty<EnumDyeColor>)prop), color), 3);
world.setBlockState(pos, state.with(((IProperty<DyeColor>)prop), color), 3);
return true;
}
}
@@ -726,7 +680,7 @@ public interface IForgeBlock
* @param pos Block position in world
* @param neighbor Block position of neighbor
*/
default void onNeighborChange(IBlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor){}
default void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor){}
/**
* Called on an Observer block whenever an update for an Observer is received.
@@ -737,7 +691,7 @@ public interface IForgeBlock
* @param changedBlock The updated block.
* @param changedBlockPos The updated block's position.
*/
default void observedNeighborChange(IBlockState observerState, World world, BlockPos observerPos, Block changedBlock, BlockPos changedBlockPos){}
default void observedNeighborChange(BlockState observerState, World world, BlockPos observerPos, Block changedBlock, BlockPos changedBlockPos){}
/**
* Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules.
@@ -746,9 +700,9 @@ public interface IForgeBlock
* @param side The INPUT side of the block to be powered - ie the opposite of this block's output side
* @return Whether Block#isProvidingWeakPower should be called when determining indirect power
*/
default boolean shouldCheckWeakPower(IBlockState state, IWorldReader world, BlockPos pos, EnumFacing side)
default boolean shouldCheckWeakPower(BlockState state, IWorldReader world, BlockPos pos, Direction side)
{
return state.isNormalCube(world, pos);
return state.func_215686_e(world, pos);
}
/**
@@ -760,7 +714,7 @@ public interface IForgeBlock
* @param pos Block position in world
* @return true To be notified of changes
*/
default boolean getWeakChanges(IBlockState state, IWorldReader world, BlockPos pos)
default boolean getWeakChanges(BlockState state, IWorldReader world, BlockPos pos)
{
return false;
}
@@ -769,7 +723,7 @@ public interface IForgeBlock
* Queries the class of tool required to harvest this block, if null is returned
* we assume that anything can harvest this block.
*/
ToolType getHarvestTool(IBlockState state);
ToolType getHarvestTool(BlockState state);
/**
* Queries the harvest level of this item stack for the specified tool class,
@@ -777,13 +731,13 @@ public interface IForgeBlock
*
* @return Harvest level, or -1 if not the specified tool type.
*/
int getHarvestLevel(IBlockState state);
int getHarvestLevel(BlockState state);
/**
* Checks if the specified tool type is efficient on this block,
* meaning that it digs at full speed.
*/
default boolean isToolEffective(IBlockState state, ToolType tool)
default boolean isToolEffective(BlockState state, ToolType tool)
{
if (tool == ToolType.PICKAXE && (this.getBlock() == Blocks.REDSTONE_ORE || this.getBlock() == Blocks.REDSTONE_LAMP || this.getBlock() == Blocks.OBSIDIAN))
return false;
@@ -793,7 +747,7 @@ public interface IForgeBlock
/**
* Can return IExtendedBlockState
*/
default IBlockState getExtendedState(IBlockState state, IBlockReader world, BlockPos pos)
default BlockState getExtendedState(BlockState state, IBlockReader world, BlockPos pos)
{
return state;
}
@@ -802,7 +756,7 @@ public interface IForgeBlock
* Queries if this block should render in a given layer.
* A custom {@link IBakedModel} can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter the model based on layer.
*/
default boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer)
default boolean canRenderInLayer(BlockState state, BlockRenderLayer layer)
{
return this.getBlock().getRenderLayer() == layer;
}
@@ -815,9 +769,9 @@ public interface IForgeBlock
* @param entity The entity that is breaking/stepping on/placing/hitting/falling on this block, or null if no entity is in this context
* @return A SoundType to use
*/
default SoundType getSoundType(IBlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity)
default SoundType getSoundType(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity)
{
return this.getBlock().getSoundType();
return this.getBlock().func_220072_p(state);
}
/**
@@ -828,8 +782,10 @@ public interface IForgeBlock
* @return A float RGB [0.0, 1.0] array to be averaged with a beacon's existing beam color, or null to do nothing to the beam
*/
@Nullable
default float[] getBeaconColorMultiplier(IBlockState state, IWorldReader world, BlockPos pos, BlockPos beaconPos)
default float[] getBeaconColorMultiplier(BlockState state, IWorldReader world, BlockPos pos, BlockPos beaconPos)
{
if (getBlock() instanceof IBeaconBeamColorProvider)
return ((IBeaconBeamColorProvider)getBlock()).getColor().getColorComponentValues();
return null;
}
@@ -845,18 +801,18 @@ public interface IForgeBlock
* @return The new fog color.
*/
@OnlyIn(Dist.CLIENT)
default Vec3d getFogColor(IBlockState state, IWorldReader world, BlockPos pos, Entity entity, Vec3d originalColor, float partialTicks)
default Vec3d getFogColor(BlockState state, IWorldReader world, BlockPos pos, Entity entity, Vec3d originalColor, float partialTicks)
{
if (state.getMaterial() == Material.WATER)
{
float f12 = 0.0F;
if (entity instanceof EntityLivingBase)
if (entity instanceof LivingEntity)
{
EntityLivingBase ent = (EntityLivingBase)entity;
LivingEntity ent = (LivingEntity)entity;
f12 = (float) EnchantmentHelper.getRespirationModifier(ent) * 0.2F;
if (ent.isPotionActive(MobEffects.WATER_BREATHING))
if (ent.isPotionActive(Effects.WATER_BREATHING))
{
f12 = f12 * 0.3F + 0.6F;
}
@@ -881,7 +837,7 @@ public interface IForgeBlock
* @param viewpoint the viewpoint
* @return the block state that should be 'seen'
*/
default IBlockState getStateAtViewpoint(IBlockState state, IBlockReader world, BlockPos pos, Vec3d viewpoint)
default BlockState getStateAtViewpoint(BlockState state, IBlockReader world, BlockPos pos, Vec3d viewpoint)
{
return state;
}
@@ -900,7 +856,7 @@ public interface IForgeBlock
* @return The state to be placed in the world
*/
@SuppressWarnings("deprecation")
default IBlockState getStateForPlacement(IBlockState state, EnumFacing facing, IBlockState state2, IWorld world, BlockPos pos1, BlockPos pos2, EnumHand hand)
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);
}
@@ -914,7 +870,7 @@ public interface IForgeBlock
* @param facing The side the connecting block is on
* @return True to allow another block to connect to this block
*/
default boolean canBeConnectedTo(IBlockState state, IBlockReader world, BlockPos pos, EnumFacing facing)
default boolean canBeConnectedTo(BlockState state, IBlockReader world, BlockPos pos, Direction facing)
{
return false;
}
@@ -925,58 +881,20 @@ public interface IForgeBlock
* @return the PathNodeType
*/
@Nullable
default PathNodeType getAiPathNodeType(IBlockState state, IBlockReader world, BlockPos pos, @Nullable EntityLiving entity)
default PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos, @Nullable MobEntity entity)
{
return state.isBurning(world, pos) ? PathNodeType.DAMAGE_FIRE : null;
}
/**
* @param blockState The state for this block
* @param world The world this block is in
* @param pos The position of this block
* @param side The side of this block that the chest lid is trying to open into
* @return true if the chest should be prevented from opening by this block
*/
default boolean doesSideBlockChestOpening(IBlockState blockState, IBlockReader world, BlockPos pos, EnumFacing side)
{
ResourceLocation registryName = this.getBlock().getRegistryName();
if (registryName != null && "minecraft".equals(registryName.getNamespace()))
{
// maintain the vanilla behavior of https://bugs.mojang.com/browse/MC-378
return blockState.isNormalCube(world, pos);
}
return blockState.isTopSolid();
}
/**
* @param state The state
* @return true if the block is sticky block which used for pull or push adjacent blocks (use by piston)
*/
default boolean isStickyBlock(IBlockState state)
default boolean isStickyBlock(BlockState state)
{
return state.getBlock() == Blocks.SLIME_BLOCK;
}
/**
* This gets a complete list of items dropped from this block.
*
* @param state Current state
* @param drops add all items this block drops to this drops list
* @param world The current world, Currently hard 'World' and not 'IBlockReder' because vanilla needs it.
* @param pos Block position in world
* @param fortune Breakers fortune level
*/
default void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune)
{
int count = getBlock().getItemsToDropCount(state, fortune, world, pos, world.rand);
for (int i = 0; i < count; i++)
{
Item item = getBlock().getItemDropped(state, world, pos, fortune).asItem();
if (item != Items.AIR)
drops.add(new ItemStack(item));
}
}
/**
* Chance that fire will spread and consume this block.
* 300 being a 100% chance, 0, being a 0% chance.
@@ -987,9 +905,10 @@ 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
*/
default int getFlammability(IBlockState state, IBlockReader world, BlockPos pos, EnumFacing face)
@SuppressWarnings("deprecation")
default int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face)
{
return ((BlockFire)Blocks.FIRE).getFlammability(getBlock());
return ((FireBlock)Blocks.FIRE).func_220274_q(state);
}
/**
@@ -1002,7 +921,7 @@ public interface IForgeBlock
* @param face The face that the fire is coming from
* @return True if the face can be on fire, false otherwise.
*/
default boolean isFlammable(IBlockState state, IBlockReader world, BlockPos pos, EnumFacing face)
default boolean isFlammable(BlockState state, IBlockReader world, BlockPos pos, Direction face)
{
return state.getFlammability(world, pos, face) > 0;
}
@@ -1017,9 +936,9 @@ public interface IForgeBlock
* @param face The face that the fire is coming from
* @return A number that is used to determine the speed of fire growth around the block
*/
default int getFireSpreadSpeed(IBlockState state, IBlockReader world, BlockPos pos, EnumFacing face)
default int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face)
{
return ((BlockFire)Blocks.FIRE).getEncouragement(getBlock());
return ((FireBlock)Blocks.FIRE).func_220275_r(state);
}
/**
@@ -1033,13 +952,13 @@ public interface IForgeBlock
* @param side The face that the fire is coming from
* @return True if this block sustains fire, meaning it will never go out.
*/
default boolean isFireSource(IBlockState state, IBlockReader world, BlockPos pos, EnumFacing side)
default boolean isFireSource(BlockState state, IBlockReader world, BlockPos pos, Direction side)
{
if (side != EnumFacing.UP)
if (side != Direction.UP)
return false;
if (getBlock() == Blocks.NETHERRACK || getBlock() == Blocks.MAGMA_BLOCK)
return true;
if (world instanceof World && ((World)world).dimension instanceof EndDimension && getBlock() == Blocks.BEDROCK)
if (world instanceof IWorldReader && ((IWorldReader)world).getDimension() instanceof EndDimension && getBlock() == Blocks.BEDROCK)
return true;
return false;
}
@@ -1052,9 +971,9 @@ public interface IForgeBlock
* @param pos Block position in world
* @return True to allow the ender dragon to destroy this block
*/
default boolean canEntityDestroy(IBlockState state, IBlockReader world, BlockPos pos, Entity entity)
default boolean canEntityDestroy(BlockState state, IBlockReader world, BlockPos pos, Entity entity)
{
if (entity instanceof EntityDragon)
if (entity instanceof EnderDragonEntity)
{
return this != Blocks.BARRIER &&
this != Blocks.OBSIDIAN &&
@@ -1068,28 +987,15 @@ public interface IForgeBlock
this != Blocks.IRON_BARS &&
this != Blocks.END_GATEWAY;
}
else if ((entity instanceof EntityWither) ||
(entity instanceof EntityWitherSkull))
else if ((entity instanceof WitherEntity) ||
(entity instanceof WitherSkullEntity))
{
return EntityWither.canDestroyBlock(getBlock());
return state.isAir(world, pos) || WitherEntity.canDestroyBlock(state);
}
return true;
}
/**
* Determines if the top is consider 'solid'. This is a helper for getBlockFaceShape(UP) == SOLID.
* Sadly some vanilla logic doesn't sync this value, so we have to have this special function.
*
* @param world The world
* @param pos Block position in world
* @return True if the top is considered solid
*/
default boolean isTopSolid(IBlockState state, IWorldReader world, BlockPos pos)
{
return state.isTopSolid();
}
/**
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
*
@@ -1102,8 +1008,17 @@ public interface IForgeBlock
* @return A result that suits your block
*/
@Nullable
default RayTraceResult getRayTraceResult(IBlockState state, World world, BlockPos pos, Vec3d start, Vec3d end, RayTraceResult original)
default RayTraceResult getRayTraceResult(BlockState state, World world, BlockPos pos, Vec3d start, Vec3d end, RayTraceResult original)
{
return original;
}
/**
* 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);
}
}
@@ -19,22 +19,22 @@
package net.minecraftforge.common.extensions;
import java.util.Optional;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.block.*;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntitySpawnPlacementRegistry.SpawnPlacementType;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.IFluidState;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathNodeType;
@@ -45,11 +45,11 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IEnviromentBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.IWorldReaderBase;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.ServerWorld;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.IPlantable;
@@ -57,9 +57,9 @@ import net.minecraftforge.common.ToolType;
public interface IForgeBlockState
{
default IBlockState getBlockState()
default BlockState getBlockState()
{
return (IBlockState)this;
return (BlockState)this;
}
/**
@@ -84,7 +84,7 @@ public interface IForgeBlockState
/**
* Get a light value for this block, taking into account the given state and coordinates, normal ranges are between 0 and 15
*/
default int getLightValue(IWorldReader world, BlockPos pos)
default int getLightValue(IEnviromentBlockReader world, BlockPos pos)
{
return getBlockState().getBlock().getLightValue(getBlockState(), world, pos);
}
@@ -97,25 +97,11 @@ public interface IForgeBlockState
* @param entity The entity trying to use the ladder, CAN be null.
* @return True if the block should act like a ladder
*/
default boolean isLadder(IWorldReader world, BlockPos pos, EntityLivingBase entity)
default boolean isLadder(IWorldReader world, BlockPos pos, LivingEntity entity)
{
return getBlockState().getBlock().isLadder(getBlockState(), world, pos, entity);
}
/**
* Return true if the block is a normal, solid cube. This
* determines indirect power state, entity ejection from blocks, and a few
* others.
*
* @param world The current world
* @param pos Block position in world
* @return True if the block is a full cube
*/
default boolean isNormalCube(IBlockReader world, BlockPos pos)
{
return getBlockState().getBlock().isNormalCube(getBlockState(), world, pos);
}
/**
* Check if the face of a block should block rendering.
*
@@ -127,7 +113,7 @@ public interface IForgeBlockState
* @param face The side to check
* @return True if the block is opaque on the specified side.
*/
default boolean doesSideBlockRendering(IWorldReader world, BlockPos pos, EnumFacing face)
default boolean doesSideBlockRendering(IEnviromentBlockReader world, BlockPos pos, Direction face)
{
return getBlockState().getBlock().doesSideBlockRendering(getBlockState(), world, pos, face);
}
@@ -160,19 +146,6 @@ public interface IForgeBlockState
return getBlockState().getBlock().createTileEntity(getBlockState(), world);
}
/**
* Return true from this function if the player with silk touch can harvest this block directly, and not it's normal drops.
*
* @param world The world
* @param pos Block position in world
* @param player The player doing the harvesting
* @return True if the block can be directly harvested using silk touch
*/
default boolean canSilkHarvest(IWorldReader world, BlockPos pos, EntityPlayer player)
{
return getBlockState().getBlock().canSilkHarvest(getBlockState(), world, pos, player);
}
/**
* Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.
*
@@ -181,7 +154,7 @@ public interface IForgeBlockState
* @param player The player damaging the block
* @return True to spawn the drops
*/
default boolean canHarvestBlock(IBlockReader world, BlockPos pos, EntityPlayer player)
default boolean canHarvestBlock(IBlockReader world, BlockPos pos, PlayerEntity player)
{
return getBlockState().getBlock().canHarvestBlock(getBlockState(), world, pos, player);
}
@@ -205,7 +178,7 @@ public interface IForgeBlockState
* @param fluid The current fluid and block state for the position in the world.
* @return True if the block is actually destroyed.
*/
default boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest, IFluidState fluid)
default boolean removedByPlayer(World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid)
{
return getBlockState().getBlock().removedByPlayer(getBlockState(), world, pos, player, willHarvest, fluid);
}
@@ -220,7 +193,7 @@ public interface IForgeBlockState
* @param player The player or camera entity, null in some cases.
* @return True to treat this as a bed
*/
default boolean isBed(IBlockReader world, BlockPos pos, @Nullable EntityPlayer player)
default boolean isBed(IBlockReader world, BlockPos pos, @Nullable LivingEntity player)
{
return getBlockState().getBlock().isBed(getBlockState(), world, pos, player);
}
@@ -234,23 +207,22 @@ public interface IForgeBlockState
* @param type The Mob Category Type
* @return True to allow a mob of the specified category to spawn, false to prevent it.
*/
default boolean canCreatureSpawn(IWorldReaderBase world, BlockPos pos, SpawnPlacementType type, EntityType<? extends EntityLiving> entityType)
default boolean canCreatureSpawn(IWorldReader world, BlockPos pos, PlacementType type, EntityType<?> entityType)
{
return getBlockState().getBlock().canCreatureSpawn(getBlockState(), world, pos, type, entityType);
}
/**
* Returns the position that the player is moved to upon
* Returns the position that the sleeper is moved to upon
* waking up, or respawning at the bed.
*
* @param world The current world
* @param pos Block position in world
* @param player The player or camera entity, null in some cases.
* @param sleeper The sleeper or camera entity, null in some cases.
* @return The spawn position
*/
@Nullable
default BlockPos getBedSpawnPosition(IBlockReader world, BlockPos pos, @Nullable EntityPlayer player)
default Optional<Vec3d> getBedSpawnPosition(EntityType<?> type, IWorldReader world, BlockPos pos, @Nullable LivingEntity sleeper)
{
return getBlockState().getBlock().getBedSpawnPosition(getBlockState(), world, pos, player);
return getBlockState().getBlock().getBedSpawnPosition(type, getBlockState(), world, pos, sleeper);
}
/**
@@ -258,12 +230,12 @@ public interface IForgeBlockState
*
* @param world The current world
* @param pos Block position in world
* @param player The player or camera entity, null in some cases.
* @param sleeper The sleeper or camera entity, null in some cases.
* @param occupied True if we are occupying the bed, or false if they are stopping use of the bed
*/
default void setBedOccupied(IWorldReader world, BlockPos pos, EntityPlayer player, boolean occupied)
default void setBedOccupied(IWorldReader world, BlockPos pos, LivingEntity sleeper, boolean occupied)
{
getBlockState().getBlock().setBedOccupied(getBlockState(), world, pos, player, occupied);
getBlockState().getBlock().setBedOccupied(getBlockState(), world, pos, sleeper, occupied);
}
/**
@@ -274,7 +246,7 @@ public interface IForgeBlockState
* @param pos Block position in world
* @return Bed direction
*/
default EnumFacing getBedDirection(IWorldReader world, BlockPos pos)
default Direction getBedDirection(IWorldReader world, BlockPos pos)
{
return getBlockState().getBlock().getBedDirection(getBlockState(), world, pos);
}
@@ -324,11 +296,24 @@ public interface IForgeBlockState
* @param pos Block position in world
* @return true if this block can be replaced by growing leaves.
*/
default boolean canBeReplacedByLeaves(IWorldReaderBase world, BlockPos pos)
default boolean canBeReplacedByLeaves(IWorldReader world, BlockPos pos)
{
return getBlockState().getBlock().canBeReplacedByLeaves(getBlockState(), world, pos);
}
/**
* Used during tree growth to determine if newly generated logs can replace this block.
*
* @param state The current state
* @param world The current world
* @param pos Block position in world
* @return true if this block can be replaced by growing leaves.
*/
default boolean canBeReplacedByLogs(IWorldReader world, BlockPos pos)
{
return getBlockState().getBlock().canBeReplacedByLogs(getBlockState(), world, pos);
}
/**
* Determines if the current block is replaceable by Ore veins during world generation.
*
@@ -338,7 +323,7 @@ public interface IForgeBlockState
* for overworld generation, and neatherack for the nether.
* @return True to allow this block to be replaced by a ore
*/
default boolean isReplaceableOreGen(IWorldReader world, BlockPos pos, Predicate<IBlockState> target)
default boolean isReplaceableOreGen(IWorldReader world, BlockPos pos, Predicate<BlockState> target)
{
return getBlockState().getBlock().isReplaceableOreGen(getBlockState(), world, pos, target);
}
@@ -357,20 +342,6 @@ public interface IForgeBlockState
return getBlockState().getBlock().getExplosionResistance(getBlockState(), world, pos, exploder, explosion);
}
/**
* Called when the block is destroyed by an explosion.
* Useful for allowing the block to take into account tile entities,
* state, etc. when exploded, before it is removed.
*
* @param world The current world
* @param pos Block position in world
* @param explosion The explosion instance affecting the block
*/
default void onBlockExploded(World world, BlockPos pos, Explosion explosion)
{
getBlockState().getBlock().onBlockExploded(getBlockState(), world, pos, explosion);
}
/**
* Determine if this block can make a redstone connection on the side provided,
* Useful to control which sides are inputs and outputs for redstone wires.
@@ -380,24 +351,11 @@ public interface IForgeBlockState
* @param side The side that is trying to make the connection, CAN BE NULL
* @return True to make the connection
*/
default boolean canConnectRedstone(IBlockReader world, BlockPos pos, @Nullable EnumFacing side)
default boolean canConnectRedstone(IBlockReader world, BlockPos pos, @Nullable Direction side)
{
return getBlockState().getBlock().canConnectRedstone(getBlockState(), world, pos, side);
}
/**
* Determines if a torch can be placed on the top surface of this block.
* Useful for creating your own block that torches can be on, such as fences.
*
* @param world The current world
* @param pos Block position in world
* @return True to allow the torch to be placed
*/
default boolean canPlaceTorchOnTop(IWorldReaderBase world, BlockPos pos)
{
return getBlockState().getBlock().canPlaceTorchOnTop(getBlockState(), world, pos);
}
/**
*
* Called when A user uses the creative pick block button on this block
@@ -405,7 +363,7 @@ public interface IForgeBlockState
* @param target The full target the player is looking at
* @return A ItemStack to add to the player's inventory, empty itemstack if nothing should be added.
*/
default ItemStack getPickBlock(RayTraceResult target, IBlockReader world, BlockPos pos, EntityPlayer player)
default ItemStack getPickBlock(RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player)
{
return getBlockState().getBlock().getPickBlock(getBlockState(), target, world, pos, player);
}
@@ -433,7 +391,7 @@ public interface IForgeBlockState
* @param numberOfParticles That vanilla world have spawned
* @return True to prevent vanilla landing particles from spawning
*/
default boolean addLandingEffects(WorldServer worldserver, BlockPos pos, IBlockState state2, EntityLivingBase entity, int numberOfParticles)
default boolean addLandingEffects(ServerWorld worldserver, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles)
{
return getBlockState().getBlock().addLandingEffects(getBlockState(), worldserver, pos, state2, entity, numberOfParticles);
}
@@ -503,7 +461,7 @@ public interface IForgeBlockState
* @param plantable The plant that wants to check
* @return True to allow the plant to be planted/stay.
*/
default boolean canSustainPlant(IBlockReader world, BlockPos pos, EnumFacing facing, IPlantable plantable)
default boolean canSustainPlant(IBlockReader world, BlockPos pos, Direction facing, IPlantable plantable)
{
return getBlockState().getBlock().canSustainPlant(getBlockState(), world, pos, facing, plantable);
}
@@ -561,12 +519,12 @@ public interface IForgeBlockState
* @param fortune
* @return Amount of XP from breaking this block.
*/
default int getExpDrop(IWorldReader world, BlockPos pos, int fortune)
default int getExpDrop(IWorldReader world, BlockPos pos, int fortune, int silktouch)
{
return getBlockState().getBlock().getExpDrop(getBlockState(), world, pos, fortune);
return getBlockState().getBlock().getExpDrop(getBlockState(), world, pos, fortune, silktouch);
}
default IBlockState rotate(IWorld world, BlockPos pos, Rotation direction)
default BlockState rotate(IWorld world, BlockPos pos, Rotation direction)
{
return getBlockState().getBlock().rotate(getBlockState(), world, pos, direction);
}
@@ -592,7 +550,7 @@ public interface IForgeBlockState
* @param fortune
* @return Amount of XP from breaking this block.
*/
default boolean recolorBlock(IWorld world, BlockPos pos, EnumFacing facing, EnumDyeColor color)
default boolean recolorBlock(IWorld world, BlockPos pos, Direction facing, DyeColor color)
{
return getBlockState().getBlock().recolorBlock(getBlockState(), world, pos, facing, color);
}
@@ -629,7 +587,7 @@ public interface IForgeBlockState
* @param side The INPUT side of the block to be powered - ie the opposite of this block's output side
* @return Whether Block#isProvidingWeakPower should be called when determining indirect power
*/
default boolean shouldCheckWeakPower(IWorldReader world, BlockPos pos, EnumFacing side)
default boolean shouldCheckWeakPower(IWorldReader world, BlockPos pos, Direction side)
{
return getBlockState().getBlock().shouldCheckWeakPower(getBlockState(), world, pos, side);
}
@@ -674,7 +632,7 @@ public interface IForgeBlockState
/**
* Can return IExtendedBlockState
*/
default IBlockState getExtendedState(IBlockReader world, BlockPos pos)
default BlockState getExtendedState(IBlockReader world, BlockPos pos)
{
return getBlockState().getBlock().getExtendedState(getBlockState(), world, pos);
}
@@ -738,7 +696,7 @@ public interface IForgeBlockState
* @param viewpoint the viewpoint
* @return the block state that should be 'seen'
*/
default IBlockState getStateAtViewpoint(IWorldReader world, BlockPos pos, Vec3d viewpoint)
default BlockState getStateAtViewpoint(IBlockReader world, BlockPos pos, Vec3d viewpoint)
{
return getBlockState().getBlock().getStateAtViewpoint(getBlockState(), world, pos, viewpoint);
}
@@ -756,7 +714,7 @@ public interface IForgeBlockState
* @param hand The player hand used to place this block
* @return The state to be placed in the world
*/
default IBlockState getStateForPlacement(EnumFacing facing, IBlockState state2, IWorld world, BlockPos pos1, BlockPos pos2, EnumHand hand)
default BlockState getStateForPlacement(Direction facing, BlockState state2, IWorld world, BlockPos pos1, BlockPos pos2, Hand hand)
{
return getBlockState().getBlock().getStateForPlacement(getBlockState(), facing, state2, world, pos1, pos2, hand);
}
@@ -769,23 +727,11 @@ public interface IForgeBlockState
* @param facing The side the connecting block is on
* @return True to allow another block to connect to this block
*/
default boolean canBeConnectedTo(IBlockReader world, BlockPos pos, EnumFacing facing)
default boolean canBeConnectedTo(IBlockReader world, BlockPos pos, Direction facing)
{
return getBlockState().getBlock().canBeConnectedTo(getBlockState(), world, pos, facing);
}
/**
* @param blockState The state for this block
* @param world The world this block is in
* @param pos The position of this block
* @param side The side of this block that the chest lid is trying to open into
* @return true if the chest should be prevented from opening by this block
*/
default boolean doesSideBlockChestOpening(IBlockReader world, BlockPos pos, EnumFacing side)
{
return getBlockState().getBlock().doesSideBlockChestOpening(getBlockState(), world, pos, side);
}
/**
* @param state The state
* @return true if the block is sticky block which used for pull or push adjacent blocks (use by piston)
@@ -795,19 +741,6 @@ public interface IForgeBlockState
return getBlockState().getBlock().isStickyBlock(getBlockState());
}
/**
* This gets a complete list of items dropped from this block.
*
* @param drops add all items this block drops to this drops list
* @param world The current world
* @param pos Block position in world
* @param fortune Breakers fortune level
*/
default void getDrops(NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune)
{
getBlockState().getBlock().getDrops(getBlockState(), drops, world, pos, fortune);
}
/**
* Chance that fire will spread and consume this block.
* 300 being a 100% chance, 0, being a 0% chance.
@@ -817,7 +750,7 @@ public interface IForgeBlockState
* @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
*/
default int getFlammability(IBlockReader world, BlockPos pos, EnumFacing face)
default int getFlammability(IBlockReader world, BlockPos pos, Direction face)
{
return getBlockState().getBlock().getFlammability(getBlockState(), world, pos, face);
}
@@ -830,7 +763,7 @@ public interface IForgeBlockState
* @param face The face that the fire is coming from
* @return True if the face can be on fire, false otherwise.
*/
default boolean isFlammable(IBlockReader world, BlockPos pos, EnumFacing face)
default boolean isFlammable(IBlockReader world, BlockPos pos, Direction face)
{
return getBlockState().getBlock().isFlammable(getBlockState(), world, pos, face);
}
@@ -844,7 +777,7 @@ public interface IForgeBlockState
* @param face The face that the fire is coming from
* @return A number that is used to determine the speed of fire growth around the block
*/
default int getFireSpreadSpeed(IBlockReader world, BlockPos pos, EnumFacing face)
default int getFireSpreadSpeed(IBlockReader world, BlockPos pos, Direction face)
{
return getBlockState().getBlock().getFireSpreadSpeed(getBlockState(), world, pos, face);
}
@@ -859,7 +792,7 @@ public interface IForgeBlockState
* @param side The face that the fire is coming from
* @return True if this block sustains fire, meaning it will never go out.
*/
default boolean isFireSource(IBlockReader world, BlockPos pos, EnumFacing side)
default boolean isFireSource(IBlockReader world, BlockPos pos, Direction side)
{
return getBlockState().getBlock().isFireSource(getBlockState(), world, pos, side);
}
@@ -884,7 +817,7 @@ public interface IForgeBlockState
* @return An array of valid axes to rotate around, or null for none or unknown
*/
@Nullable
default EnumFacing[] getValidRotations(IBlockReader world, BlockPos pos)
default Direction[] getValidRotations(IBlockReader world, BlockPos pos)
{
return getBlockState().getBlock().getValidRotations(getBlockState(), world, pos);
}
@@ -902,27 +835,22 @@ public interface IForgeBlockState
return getBlockState().getBlock().isBurning(getBlockState(), world, pos);
}
/**
* Determines if the top is consider 'solid'. This is a helper for getBlockFaceShape(UP) == SOLID.
* Sadly some vanilla logic doesn't sync this value, so we have to have this special function.
*
* @param world The world
* @param pos Block position in world
* @return True if the top is considered solid
*/
default boolean isTopSolid(IWorldReader world, BlockPos pos)
{
return getBlockState().getBlock().isTopSolid(getBlockState(), world, pos);
}
/**
* Get the {@code PathNodeType} for this block. Return {@code null} for vanilla behavior.
*
* @return the PathNodeType
*/
@Nullable
default PathNodeType getAiPathNodeType(IBlockReader world, BlockPos pos, @Nullable EntityLiving entity)
default PathNodeType getAiPathNodeType(IBlockReader world, BlockPos pos, @Nullable MobEntity entity)
{
return getBlockState().getBlock().getAiPathNodeType(getBlockState(), world, pos, entity);
}
/**
* Determines if this block should drop loot when exploded.
*/
default boolean canDropFromExplosion(IBlockReader world, BlockPos pos, Explosion explosion)
{
return getBlockState().getBlock().canDropFromExplosion(getBlockState(), world, pos, explosion);
}
}
@@ -23,8 +23,8 @@ import javax.annotation.Nullable;
import net.minecraft.client.audio.MusicTicker;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@@ -84,22 +84,6 @@ public interface IForgeDimension
return 1.0;
}
/**
* If this method returns true, then chunks received by the client will
* have {@link net.minecraft.world.chunk.Chunk#resetRelightChecks} called
* on them, queuing lighting checks for all air blocks in the chunk (and
* any adjacent light-emitting blocks).
*
* Returning true here is recommended if the chunk generator used also
* does this for newly generated chunks.
*
* @return true if lighting checks should be performed
*/
default boolean shouldClientCheckLighting()
{
return !(this instanceof OverworldDimension);
}
@OnlyIn(Dist.CLIENT)
@Nullable
IRenderHandler getSkyRenderer();
@@ -166,9 +150,9 @@ public interface IForgeDimension
* @param pos The location where the player tries to sleep at (the position of the clicked on bed for example)
* @return the result of a player trying to sleep at the given location
*/
default SleepResult canSleepAt(net.minecraft.entity.player.EntityPlayer player, BlockPos pos)
default SleepResult canSleepAt(net.minecraft.entity.player.PlayerEntity player, BlockPos pos)
{
return (getDimension().canRespawnHere() && getWorld().getBiome(pos) != net.minecraft.init.Biomes.NETHER) ? SleepResult.ALLOW : SleepResult.BED_EXPLODES;
return (getDimension().canRespawnHere() && getWorld().getBiome(pos) != net.minecraft.world.biome.Biomes.NETHER) ? SleepResult.ALLOW : SleepResult.BED_EXPLODES;
}
enum SleepResult
@@ -196,24 +180,15 @@ public interface IForgeDimension
*
* @return The current brightness factor
**/
default float getSunBrightnessFactor(float partialTicks)
{
return getWorld().getSunBrightnessFactor(partialTicks);
}
/**
* Gets the Sun Brightness for rendering sky.
* */
@OnlyIn(Dist.CLIENT)
default float getSunBrightness(float partialTicks)
{
return getWorld().getSunBrightnessBody(partialTicks);
}
@OnlyIn(Dist.CLIENT)
default Vec3d getSkyColor(Entity cameraEntity, float partialTicks)
default Vec3d getSkyColor(BlockPos cameraPos, float partialTicks)
{
return getWorld().getSkyColorBody(cameraEntity, partialTicks);
return getWorld().getSkyColorBody(cameraPos, partialTicks);
}
@OnlyIn(Dist.CLIENT)
@@ -238,10 +213,7 @@ public interface IForgeDimension
@OnlyIn(Dist.CLIENT)
default float getStarBrightness(float partialTicks)
{
float f = getWorld().getCelestialAngle(partialTicks);
float f1 = 1.0F - (MathHelper.cos(f * ((float)Math.PI * 2F)) * 2.0F + 0.25F);
f1 = MathHelper.clamp(f1, 0.0F, 1.0F);
return f1 * f1 * 0.5F;
return getWorld().getStarBrightnessBody(partialTicks);
}
default void setAllowedSpawnTypes(boolean allowHostile, boolean allowPeaceful) { }
@@ -251,9 +223,9 @@ public interface IForgeDimension
getWorld().calculateInitialWeatherBody();
}
default void updateWeather()
default void updateWeather(Runnable defaultLogic)
{
getWorld().updateWeatherBody();
defaultLogic.run();
}
default long getSeed()
@@ -282,7 +254,7 @@ public interface IForgeDimension
getWorld().getWorldInfo().setSpawn(pos);
}
default boolean canMineBlock(EntityPlayer player, BlockPos pos)
default boolean canMineBlock(PlayerEntity player, BlockPos pos)
{
return getWorld().canMineBlockBody(player, pos);
}
@@ -304,7 +276,7 @@ public interface IForgeDimension
default double getHorizon()
{
return getWorld().getWorldInfo().getTerrainType().getHorizon(getWorld());
return getWorld().getWorldInfo().getGenerator().getHorizon(getWorld());
}
/**
@@ -327,7 +299,7 @@ public interface IForgeDimension
* @param player The player that is respawning
* @return The dimension to respawn the player in
*/
default DimensionType getRespawnDimension(EntityPlayerMP player)
default DimensionType getRespawnDimension(ServerPlayerEntity player)
{
return player.getSpawnDimension();
}
@@ -0,0 +1,108 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.extensions;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.DisplayEffectsScreen;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IForgeEffect {
default Effect getEffect() {
return (Effect)this;
}
/**
* If the Potion effect should be displayed in the players inventory
* @param effect the active PotionEffect
* @return true to display it (default), false to hide it.
*/
default boolean shouldRender(EffectInstance effect) { return true; }
/**
* If the standard PotionEffect text (name and duration) should be drawn when this potion is active.
* @param effect the active PotionEffect
* @return true to draw the standard text
*/
default boolean shouldRenderInvText(EffectInstance effect) { return true; }
/**
* If the Potion effect should be displayed in the player's ingame HUD
* @param effect the active PotionEffect
* @return true to display it (default), false to hide it.
*/
default boolean shouldRenderHUD(EffectInstance effect) { return true; }
/**
* Called to draw the this Potion onto the player's inventory when it's active.
* This can be used to e.g. render Potion icons from your own texture.
*
* @param effect the active PotionEffect
* @param gui the gui instance
* @param x the x coordinate
* @param y the y coordinate
* @param z the z level
*/
@OnlyIn(Dist.CLIENT)
default void renderInventoryEffect(EffectInstance effect, DisplayEffectsScreen<?> gui, int x, int y, float z) { }
/**
* Called to draw the this Potion onto the player's ingame HUD when it's active.
* This can be used to e.g. render Potion icons from your own texture.
* @param effect the active PotionEffect
* @param gui the gui instance
* @param x the x coordinate
* @param y the y coordinate
* @param z the z level
* @param alpha the alpha value, blinks when the potion is about to run out
*/
@OnlyIn(Dist.CLIENT)
default void renderHUDEffect(EffectInstance effect, AbstractGui gui, int x, int y, float z, float alpha) { }
/**
* Get a fresh list of items that can cure this Potion.
* All new PotionEffects created from this Potion will call this to initialize the default curative items
* @see PotionEffect#getCurativeItems
* @return A list of items that can cure this Potion
*/
default List<ItemStack> getCurativeItems() {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(new ItemStack(Items.MILK_BUCKET));
return ret;
}
/**
* Used for determining {@code PotionEffect} sort order in GUIs.
* Defaults to the {@code PotionEffect}'s liquid color.
* @param potionEffect the {@code PotionEffect} instance containing the potion
* @return a value used to sort {@code PotionEffect}s in GUIs
*/
default int getGuiSortColor(EffectInstance potionEffect) {
return getEffect().getLiquidColor();
}
}
@@ -0,0 +1,73 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.extensions;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Potion;
public interface IForgeEffectInstance {
default EffectInstance getEffectInstance() {
return (EffectInstance)this;
}
/***
* Returns a list of curative items for the potion effect
* By default, this list is initialized using {@link Potion#getCurativeItems}
*
* @return The list (ItemStack) of curative items for the potion effect
*/
List<ItemStack> getCurativeItems();
/***
* Checks the given ItemStack to see if it is in the list of curative items for the potion effect
* @param stack The ItemStack being checked against the list of curative items for this PotionEffect
* @return true if the given ItemStack is in the list of curative items for this PotionEffect, false otherwise
*/
default boolean isCurativeItem(ItemStack stack) {
return this.getCurativeItems().stream().anyMatch(e -> e.isItemEqual(stack));
}
/***
* Sets the list of curative items for this potion effect, overwriting any already present
* @param curativeItems The list of ItemStacks being set to the potion effect
*/
void setCurativeItems(List<ItemStack> curativeItems);
/***
* Adds the given stack to the list of curative items for this PotionEffect
* @param stack The ItemStack being added to the curative item list
*/
default void addCurativeItem(ItemStack stack) {
if (!this.isCurativeItem(stack))
this.getCurativeItems().add(stack);
}
default void writeCurativeItems(CompoundNBT nbt) {
ListNBT list = new ListNBT();
getCurativeItems().forEach(s -> list.add(s.write(new CompoundNBT())));
nbt.func_218657_a("CurativeItems", list);
}
}
@@ -20,52 +20,43 @@
package net.minecraftforge.common.extensions;
import java.util.Collection;
import javax.annotation.Nullable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLeashKnot;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemSpawnEgg;
import net.minecraft.entity.item.LeashKnotEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.item.BoatEntity;
import net.minecraft.entity.item.EnderCrystalEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.item.PaintingEntity;
import net.minecraft.item.Items;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.common.util.ITeleporter;
public interface IForgeEntity extends ICapabilitySerializable<NBTTagCompound>
public interface IForgeEntity extends ICapabilitySerializable<CompoundNBT>
{
default Entity getEntity() { return (Entity) this; }
default void deserializeNBT(NBTTagCompound nbt)
default void deserializeNBT(CompoundNBT nbt)
{
getEntity().read(nbt);
}
default NBTTagCompound serializeNBT()
default CompoundNBT serializeNBT()
{
NBTTagCompound ret = new NBTTagCompound();
CompoundNBT ret = new CompoundNBT();
String id = getEntity().getEntityString();
if (id != null)
{
ret.setString("id", getEntity().getEntityString());
ret.putString("id", getEntity().getEntityString());
}
return getEntity().writeWithoutTypeId(ret);
}
@@ -74,8 +65,8 @@ public interface IForgeEntity extends ICapabilitySerializable<NBTTagCompound>
void canUpdate(boolean value);
@Nullable
Collection<EntityItem> captureDrops();
Collection<EntityItem> captureDrops(@Nullable Collection<EntityItem> captureDrops);
Collection<ItemEntity> captureDrops();
Collection<ItemEntity> captureDrops(@Nullable Collection<ItemEntity> captureDrops);
/**
@@ -83,7 +74,7 @@ public interface IForgeEntity extends ICapabilitySerializable<NBTTagCompound>
* It will be written, and read from disc, so it persists over world saves.
* @return A NBTTagCompound
*/
NBTTagCompound getEntityData();
CompoundNBT getEntityData();
/**
* Used in model rendering to determine if the entity riding this entity should be in the 'sitting' position.
@@ -102,51 +93,34 @@ public interface IForgeEntity extends ICapabilitySerializable<NBTTagCompound>
*/
default ItemStack getPickedResult(RayTraceResult target)
{
if (this instanceof EntityPainting)
{
if (this instanceof PaintingEntity)
return new ItemStack(Items.PAINTING);
}
else if (this instanceof EntityLeashKnot)
{
else if (this instanceof LeashKnotEntity)
return new ItemStack(Items.LEAD);
}
else if (this instanceof EntityItemFrame)
else if (this instanceof ItemFrameEntity)
{
ItemStack held = ((EntityItemFrame)this).getDisplayedItem();
ItemStack held = ((ItemFrameEntity)this).getDisplayedItem();
if (held.isEmpty())
return new ItemStack(Items.ITEM_FRAME);
else
return held.copy();
}
else if (this instanceof EntityMinecart)
{
return ((EntityMinecart)this).getCartItem();
}
else if (this instanceof EntityBoat)
{
return new ItemStack(((EntityBoat)this).getItemBoat());
}
else if (this instanceof EntityArmorStand)
{
else if (this instanceof AbstractMinecartEntity)
return ((AbstractMinecartEntity)this).getCartItem();
else if (this instanceof BoatEntity)
return new ItemStack(((BoatEntity)this).getItemBoat());
else if (this instanceof ArmorStandEntity)
return new ItemStack(Items.ARMOR_STAND);
}
else if (this instanceof EntityEnderCrystal)
{
else if (this instanceof EnderCrystalEntity)
return new ItemStack(Items.END_CRYSTAL);
}
else
{
ItemSpawnEgg egg = ItemSpawnEgg.getEgg(getEntity().getType());
SpawnEggItem egg = SpawnEggItem.getEgg(getEntity().getType());
if (egg != null) return new ItemStack(egg);
}
return ItemStack.EMPTY;
}
default boolean shouldRenderInPass(int pass)
{
return pass == 0;
}
/**
* If a rider of this entity can interact with this entity. Should return true on the
* ridden entity if so.
@@ -166,21 +140,9 @@ public interface IForgeEntity extends ICapabilitySerializable<NBTTagCompound>
*/
default boolean canBeRiddenInWater(Entity rider)
{
return this instanceof EntityLivingBase;
return this instanceof LivingEntity;
}
/**
* Override instead of
* {@link Entity#changeDimension(DimensionType, ITeleporter)} if your entity
* needs special handling for specific teleporters.
*
* @param type The target dimension
* @param teleporter The teleporter being used to move the entity to the dimension
* @return The entity to be placed in the target dimension. {@code null} if the entity should despawn.
*/
@Nullable
Entity changeDimension(DimensionType type, ITeleporter teleporter);
/**
* Checks if this {@link Entity} can trample a {@link Block}.
*
@@ -188,18 +150,16 @@ public interface IForgeEntity extends ICapabilitySerializable<NBTTagCompound>
* @param fallDistance The fall distance
* @return {@code true} if this entity can trample, {@code false} otherwise
*/
boolean canTrample(IBlockState state, BlockPos pos, float fallDistance);
boolean canTrample(BlockState state, BlockPos pos, float fallDistance);
/**
* Returns true if the entity is of the @link{EnumCreatureType} provided
* @param type The EnumCreatureType type this entity is evaluating
* Returns The classification of this entity
* @param forSpawnCount If this is being invoked to check spawn count caps.
* @return If the creature is of the type provided
*/
default boolean isCreatureType(EnumCreatureType type, boolean forSpawnCount)
default EntityClassification getClassification(boolean forSpawnCount)
{
if (forSpawnCount && (this instanceof EntityLiving) && ((EntityLiving)this).isNoDespawnRequired()) return false;
return type.getBaseClass().isAssignableFrom(this.getClass());
return getEntity().getType().func_220339_d();
}
/**
@@ -19,20 +19,14 @@
package net.minecraftforge.common.extensions;
import net.minecraft.block.BlockRailBase;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.item.EntityMinecartChest;
import net.minecraft.entity.item.EntityMinecartCommandBlock;
import net.minecraft.entity.item.EntityMinecartFurnace;
import net.minecraft.entity.item.EntityMinecartHopper;
import net.minecraft.entity.item.EntityMinecartTNT;
import net.minecraft.init.Items;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.IMinecartCollisionHandler;
public interface IForgeEntityMinecart
@@ -42,8 +36,8 @@ public interface IForgeEntityMinecart
public static double DEFAULT_AIR_DRAG = 0.95f;
public static IMinecartCollisionHandler COLLISIONS = null;
default EntityMinecart getMinecart() {
return (EntityMinecart)this;
default AbstractMinecartEntity getMinecart() {
return (AbstractMinecartEntity)this;
}
/**
@@ -74,23 +68,7 @@ public interface IForgeEntityMinecart
* Moved to allow overrides.
* This code handles minecart movement and speed capping when on a rail.
*/
default void moveMinecartOnRail(BlockPos pos)
{
EntityMinecart mc = getMinecart();
double mX = mc.motionX;
double mZ = mc.motionZ;
if (mc.isBeingRidden())
{
mX *= 0.75D;
mZ *= 0.75D;
}
double max = getMaxSpeed();
mX = MathHelper.clamp(mX, -max, max);
mZ = MathHelper.clamp(mZ, -max, max);
mc.move(MoverType.SELF, mX, 0.0D, mZ);
}
void moveMinecartOnRail(BlockPos pos);
/**
* This function returns an ItemStack that represents this cart.
@@ -138,7 +116,7 @@ public interface IForgeEntityMinecart
* @return True if powered.
*/
default boolean isPoweredCart() {
return getMinecart().getMinecartType() == EntityMinecart.Type.FURNACE;
return getMinecart().getMinecartType() == AbstractMinecartEntity.Type.FURNACE;
}
/**
@@ -146,7 +124,7 @@ public interface IForgeEntityMinecart
* @return True if this cart can be ridden.
*/
default boolean canBeRidden() {
return getMinecart().getMinecartType() == EntityMinecart.Type.RIDEABLE;
return getMinecart().getMinecartType() == AbstractMinecartEntity.Type.RIDEABLE;
}
/**
@@ -53,7 +53,7 @@ public interface IForgeFluid
*/
default boolean isEntityInside(IFluidState state, IWorldReader world, BlockPos pos, Entity entity, double yToTest, Tag<Fluid> tag, boolean testingHead)
{
return state.isTagged(tag) && yToTest < (double)(pos.getY() + state.getHeight() + 0.11111111F);
return state.isTagged(tag) && yToTest < (double)(pos.getY() + state.func_215679_a(world, pos) + 0.11111111F);
}
/**
@@ -51,6 +51,7 @@ public interface IForgeFluidState
*/
default boolean isEntityInside(IWorldReader world, BlockPos pos, Entity entity, double yToTest, Tag<Fluid> tag, boolean testingHead)
{
// return ifluidstate.isTagged(p_213290_1_) && d0 < (double)((float)blockpos.getY() + ifluidstate.func_215679_a(this.world, blockpos) + 0.11111111F);
return getFluidState().getFluid().isEntityInside(getFluidState(), world, pos, entity, yToTest, tag, testingHead);
}
@@ -26,24 +26,23 @@ import javax.annotation.Nullable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.entity.model.BipedModel;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.HorseArmorType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Items;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumActionResult;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
@@ -65,7 +64,7 @@ public interface IForgeItem
* ItemStack sensitive version of getItemAttributeModifiers
*/
@SuppressWarnings("deprecation")
default Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
default Multimap<String, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack)
{
return getItem().getAttributeModifiers(slot);
}
@@ -78,7 +77,7 @@ public interface IForgeItem
* @param player The player that dropped the item
* @param item The item stack, before the item is removed.
*/
default boolean onDroppedByPlayer(ItemStack item, EntityPlayer player)
default boolean onDroppedByPlayer(ItemStack item, PlayerEntity player)
{
return true;
}
@@ -102,9 +101,9 @@ public interface IForgeItem
*
* @return Return PASS to allow vanilla handling, any other to skip normal code.
*/
default EnumActionResult onItemUseFirst(ItemStack stack, ItemUseContext context)
default ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context)
{
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
/**
@@ -113,7 +112,7 @@ public interface IForgeItem
* @return True if reparable
*/
boolean isRepairable();
/**
* Determines the amount of durability the mending enchantment
* will repair, on average, per point of experience.
@@ -140,7 +139,7 @@ public interface IForgeItem
* @return The NBT tag
*/
@Nullable
default NBTTagCompound getShareTag(ItemStack stack)
default CompoundNBT getShareTag(ItemStack stack)
{
return stack.getTag();
}
@@ -152,7 +151,7 @@ public interface IForgeItem
* @param stack The stack that received NBT
* @param nbt Received NBT, can be null
*/
default void readShareTag(ItemStack stack, @Nullable NBTTagCompound nbt)
default void readShareTag(ItemStack stack, @Nullable CompoundNBT nbt)
{
stack.setTag(nbt);
}
@@ -168,7 +167,7 @@ public interface IForgeItem
* @param player The Player that is wielding the item
* @return True to prevent harvesting, false to continue as normal
*/
default boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player)
default boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, PlayerEntity player)
{
return false;
}
@@ -181,7 +180,7 @@ public interface IForgeItem
* @param count The amount of time in tick the item has been used for
* continuously
*/
default void onUsingTick(ItemStack stack, EntityLivingBase player, int count)
default void onUsingTick(ItemStack stack, LivingEntity player, int count)
{
}
@@ -195,7 +194,7 @@ public interface IForgeItem
* @param entity The entity being attacked
* @return True to cancel the rest of the interaction.
*/
default boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
default boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity)
{
return false;
}
@@ -281,7 +280,7 @@ public interface IForgeItem
* @param entity The entity Item
* @return Return true to skip any further update code.
*/
default boolean onEntityItemUpdate(ItemStack stack, EntityItem entity)
default boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity)
{
return false;
}
@@ -321,7 +320,7 @@ public interface IForgeItem
* @param player The Player that is wielding the item
* @return
*/
default boolean doesSneakBypassUse(ItemStack stack, net.minecraft.world.IWorldReader world, BlockPos pos, EntityPlayer player)
default boolean doesSneakBypassUse(ItemStack stack, net.minecraft.world.IWorldReader world, BlockPos pos, PlayerEntity player)
{
return false;
}
@@ -329,7 +328,7 @@ public interface IForgeItem
/**
* Called to tick armor in the armor slot. Override to do something
*/
default void onArmorTick(ItemStack stack, World world, EntityPlayer player)
default void onArmorTick(ItemStack stack, World world, PlayerEntity player)
{
}
@@ -342,9 +341,9 @@ public interface IForgeItem
* @param entity The entity trying to equip the armor
* @return True if the given ItemStack can be inserted in the slot
*/
default boolean canEquip(ItemStack stack, EntityEquipmentSlot armorType, Entity entity)
default boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)
{
return EntityLiving.getSlotForItemStack(stack) == armorType;
return MobEntity.getSlotForItemStack(stack) == armorType;
}
/**
@@ -358,7 +357,7 @@ public interface IForgeItem
* decide
*/
@Nullable
default EntityEquipmentSlot getEquipmentSlot(ItemStack stack)
default EquipmentSlotType getEquipmentSlot(ItemStack stack)
{
return null;
}
@@ -389,7 +388,7 @@ public interface IForgeItem
* @return Path of texture to bind, or null to use default
*/
@Nullable
default String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
default String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlotType slot, String type)
{
return null;
}
@@ -419,8 +418,7 @@ public interface IForgeItem
*/
@OnlyIn(Dist.CLIENT)
@Nullable
default net.minecraft.client.renderer.entity.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack,
EntityEquipmentSlot armorSlot, net.minecraft.client.renderer.entity.model.ModelBiped _default)
default <A extends BipedModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, A _default)
{
return null;
}
@@ -431,7 +429,7 @@ public interface IForgeItem
* @param entity The entity swinging the item.
* @return True to cancel any further processing by EntityLiving
*/
default boolean onEntitySwing(ItemStack stack, EntityLivingBase entity)
default boolean onEntitySwing(ItemStack stack, LivingEntity entity)
{
return false;
}
@@ -447,7 +445,7 @@ public interface IForgeItem
* @param partialTicks Partial ticks for the renderer, useful for interpolation
*/
@OnlyIn(Dist.CLIENT)
default void renderHelmetOverlay(ItemStack stack, EntityPlayer player, int width, int height, float partialTicks)
default void renderHelmetOverlay(ItemStack stack, PlayerEntity player, int width, int height, float partialTicks)
{
}
@@ -535,7 +533,7 @@ public interface IForgeItem
*/
default void setDamage(ItemStack stack, int damage)
{
stack.getOrCreateTag().setInt("Damage", Math.max(0, damage));
stack.getOrCreateTag().putInt("Damage", Math.max(0, damage));
}
/**
@@ -545,7 +543,7 @@ public interface IForgeItem
* @param state The block trying to harvest
* @return true if can harvest the block
*/
default boolean canHarvestBlock(ItemStack stack, IBlockState state)
default boolean canHarvestBlock(ItemStack stack, BlockState state)
{
return getItem().canHarvestBlock(state);
}
@@ -575,7 +573,7 @@ public interface IForgeItem
* @param blockState The block to harvest
* @return Harvest level, or -1 if not the specified tool type.
*/
int getHarvestLevel(ItemStack stack, ToolType tool, @Nullable EntityPlayer player, @Nullable IBlockState blockState);
int getHarvestLevel(ItemStack stack, ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState blockState);
/**
* ItemStack sensitive version of getItemEnchantability
@@ -696,12 +694,12 @@ public interface IForgeItem
* capabilities for the life of this item.
*/
@Nullable
default net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt)
default net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt)
{
return null;
}
default ImmutableMap<String, ITimeValue> getAnimationParameters(final ItemStack stack, final World world, final EntityLivingBase entity)
default ImmutableMap<String, ITimeValue> getAnimationParameters(final ItemStack stack, final World world, final LivingEntity entity)
{
com.google.common.collect.ImmutableMap.Builder<String, ITimeValue> builder = ImmutableMap.builder();
getItem().properties.forEach((k,v) -> builder.put(k.toString(), input -> v.call(stack, world, entity)));
@@ -717,9 +715,9 @@ public interface IForgeItem
* @param attacker The EntityLivingBase holding the ItemStack
* @retrun True if this ItemStack can disable the shield in question.
*/
default boolean canDisableShield(ItemStack stack, ItemStack shield, EntityLivingBase entity, EntityLivingBase attacker)
default boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker)
{
return this instanceof ItemAxe;
return this instanceof AxeItem;
}
/**
@@ -729,7 +727,7 @@ public interface IForgeItem
* @param entity The Entity holding the ItemStack
* @return True if the ItemStack is considered a shield
*/
default boolean isShield(ItemStack stack, @Nullable EntityLivingBase entity)
default boolean isShield(ItemStack stack, @Nullable LivingEntity entity)
{
return stack.getItem() == Items.SHIELD;
}
@@ -744,21 +742,6 @@ public interface IForgeItem
return -1;
}
/**
* Returns an enum constant of type {@code HorseArmorType}. The returned enum
* constant will be used to determine the armor value and texture of this item
* when equipped.
*
* @param stack the armor stack
* @return an enum constant of type {@code HorseArmorType}. Return
* HorseArmorType.NONE if this is not horse armor
*/
@SuppressWarnings("deprecation")
default HorseArmorType getHorseArmorType(ItemStack stack)
{
return HorseArmorType.getByItem(stack.getItem());
}
/**
* Called every tick from {@link EntityHorse#onUpdate()} on the item in the
* armor slot.
@@ -767,7 +750,7 @@ public interface IForgeItem
* @param world the world the horse is in
* @param horse the horse wearing this armor
*/
default void onHorseArmorTick(ItemStack stack, World world, EntityLiving horse)
default void onHorseArmorTick(ItemStack stack, World world, MobEntity horse)
{
}
@@ -776,5 +759,5 @@ public interface IForgeItem
* one.
*/
@OnlyIn(Dist.CLIENT)
net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer getTileEntityItemStackRenderer();
net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer getTileEntityItemStackRenderer();
}
@@ -23,23 +23,21 @@ import java.util.Set;
import javax.annotation.Nullable;
import net.minecraft.block.state.BlockWorldState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.CachedBlockInfo;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.HorseArmorType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.util.EnumActionResult;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
@@ -48,7 +46,7 @@ import net.minecraftforge.common.capabilities.ICapabilitySerializable;
/*
* Extension added to ItemStack that bounces to ItemSack sensitive Item methods. Typically this is just for convince.
*/
public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
{
// Helpers for accessing Item data
default ItemStack getStack()
@@ -99,7 +97,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param state The block to harvest
* @return Harvest level, or -1 if not the specified tool type.
*/
default int getHarvestLevel(ToolType tool, @Nullable EntityPlayer player, @Nullable IBlockState state)
default int getHarvestLevel(ToolType tool, @Nullable PlayerEntity player, @Nullable BlockState state)
{
return getStack().getItem().getHarvestLevel(getStack(), tool, player, state);
}
@@ -108,27 +106,27 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
return getStack().getItem().getToolTypes(getStack());
}
default EnumActionResult onItemUseFirst(ItemUseContext context)
default ActionResultType onItemUseFirst(ItemUseContext context)
{
EntityPlayer entityplayer = context.getPlayer();
PlayerEntity entityplayer = context.getPlayer();
BlockPos blockpos = context.getPos();
BlockWorldState blockworldstate = new BlockWorldState(context.getWorld(), blockpos, false);
CachedBlockInfo blockworldstate = new CachedBlockInfo(context.getWorld(), blockpos, false);
if (entityplayer != null && !entityplayer.abilities.allowEdit && !getStack().canPlaceOn(context.getWorld().getTags(), blockworldstate)) {
return EnumActionResult.PASS;
return ActionResultType.PASS;
} else {
Item item = getStack().getItem();
EnumActionResult enumactionresult = item.onItemUseFirst(getStack(), context);
if (entityplayer != null && enumactionresult == EnumActionResult.SUCCESS) {
entityplayer.addStat(StatList.ITEM_USED.get(item));
ActionResultType enumactionresult = item.onItemUseFirst(getStack(), context);
if (entityplayer != null && enumactionresult == ActionResultType.SUCCESS) {
entityplayer.addStat(Stats.ITEM_USED.get(item));
}
return enumactionresult;
}
}
default NBTTagCompound serializeNBT()
default CompoundNBT serializeNBT()
{
NBTTagCompound ret = new NBTTagCompound();
CompoundNBT ret = new CompoundNBT();
getStack().write(ret);
return ret;
}
@@ -142,7 +140,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param player The Player that is wielding the item
* @return True to prevent harvesting, false to continue as normal
*/
default boolean onBlockStartBreak(BlockPos pos, EntityPlayer player)
default boolean onBlockStartBreak(BlockPos pos, PlayerEntity player)
{
return !getStack().isEmpty() && getStack().getItem().onBlockStartBreak(getStack(), pos, player);
}
@@ -197,7 +195,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* decide
*/
@Nullable
default EntityEquipmentSlot getEquipmentSlot()
default EquipmentSlotType getEquipmentSlot()
{
return getStack().getItem().getEquipmentSlot(getStack());
}
@@ -210,7 +208,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param attacker The EntityLivingBase holding the ItemStack
* @retrun True if this ItemStack can disable the shield in question.
*/
default boolean canDisableShield(ItemStack shield, EntityLivingBase entity, EntityLivingBase attacker)
default boolean canDisableShield(ItemStack shield, LivingEntity entity, LivingEntity attacker)
{
return getStack().getItem().canDisableShield(getStack(), shield, entity, attacker);
}
@@ -221,7 +219,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param entity The Entity holding the ItemStack
* @return True if the ItemStack is considered a shield
*/
default boolean isShield(@Nullable EntityLivingBase entity)
default boolean isShield(@Nullable LivingEntity entity)
{
return getStack().getItem().isShield(getStack(), entity);
}
@@ -232,7 +230,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param entity The entity swinging the item.
* @return True to cancel any further processing by EntityLiving
*/
default boolean onEntitySwing(EntityLivingBase entity)
default boolean onEntitySwing(LivingEntity entity)
{
return getStack().getItem().onEntitySwing(getStack(), entity);
}
@@ -244,7 +242,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param count The amount of time in tick the item has been used for
* continuously
*/
default void onUsingTick(EntityLivingBase player, int count)
default void onUsingTick(LivingEntity player, int count)
{
getStack().getItem().onUsingTick(getStack(), player, count);
}
@@ -269,28 +267,24 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param entity The entity Item
* @return Return true to skip any further update code.
*/
default boolean onEntityItemUpdate(EntityItem entity)
default boolean onEntityItemUpdate(ItemEntity entity)
{
return getStack().getItem().onEntityItemUpdate(getStack(), entity);
}
/**
* Returns an enum constant of type {@code HorseArmorType}. The returned enum
* constant will be used to determine the armor value and texture of this item
* when equipped.
*
* @return an enum constant of type {@code HorseArmorType}. Return
* HorseArmorType.NONE if this is not horse armor
*/
default HorseArmorType getHorseArmorType()
* Determines the amount of durability the mending enchantment
* will repair, on average, per point of experience.
*/
default float getXpRepairRatio()
{
return getStack().getItem().getHorseArmorType(getStack());
return getStack().getItem().getXpRepairRatio(getStack());
}
/**
* Called to tick armor in the armor slot. Override to do something
*/
default void onArmorTick(World world, EntityPlayer player)
default void onArmorTick(World world, PlayerEntity player)
{
getStack().getItem().onArmorTick(getStack(), world, player);
}
@@ -302,7 +296,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param world the world the horse is in
* @param horse the horse wearing this armor
*/
default void onHorseArmorTick(World world, EntityLiving horse)
default void onHorseArmorTick(World world, MobEntity horse)
{
getStack().getItem().onHorseArmorTick(getStack(), world, horse);
}
@@ -325,7 +319,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param entity The entity trying to equip the armor
* @return True if the given ItemStack can be inserted in the slot
*/
default boolean canEquip(EntityEquipmentSlot armorType, Entity entity)
default boolean canEquip(EquipmentSlotType armorType, Entity entity)
{
return getStack().getItem().canEquip(getStack(), armorType, entity);
}
@@ -351,7 +345,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param player The player that dropped the item
* @param item The item stack, before the item is removed.
*/
default boolean onDroppedByPlayer(EntityPlayer player)
default boolean onDroppedByPlayer(PlayerEntity player)
{
return getStack().getItem().onDroppedByPlayer(getStack(), player);
}
@@ -370,7 +364,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @return The NBT tag
*/
@Nullable
default NBTTagCompound getShareTag()
default CompoundNBT getShareTag()
{
return getStack().getItem().getShareTag(getStack());
}
@@ -382,7 +376,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param stack The stack that received NBT
* @param nbt Received NBT, can be null
*/
default void readShareTag(@Nullable NBTTagCompound nbt)
default void readShareTag(@Nullable CompoundNBT nbt)
{
getStack().getItem().readShareTag(getStack(), nbt);
}
@@ -396,7 +390,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
* @param player The Player that is wielding the item
* @return
*/
default boolean doesSneakBypassUse(net.minecraft.world.IWorldReader world, BlockPos pos, EntityPlayer player)
default boolean doesSneakBypassUse(net.minecraft.world.IWorldReader world, BlockPos pos, PlayerEntity player)
{
return getStack().isEmpty() || getStack().getItem().doesSneakBypassUse(getStack(), world, pos, player);
}
@@ -408,8 +402,8 @@ public interface IForgeItemStack extends ICapabilitySerializable<NBTTagCompound>
*/
default boolean areShareTagsEqual(ItemStack other)
{
NBTTagCompound shareTagA = getStack().getShareTag();
NBTTagCompound shareTagB = other.getShareTag();
CompoundNBT shareTagA = getStack().getShareTag();
CompoundNBT shareTagB = other.getShareTag();
if (shareTagA == null)
return shareTagB == null;
else
@@ -1,37 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.extensions;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.crafting.RecipeType;
import net.minecraftforge.common.crafting.VanillaRecipeTypes;
public interface IForgeRecipe {
/**
* Used when sorting this recipe into it's category during load. This type determines what class the recipe must subclass.
* @return The type of this recipe.
*/
default RecipeType<? extends IRecipe> getType()
{
return VanillaRecipeTypes.CRAFTING;
}
}
@@ -22,9 +22,9 @@ package net.minecraftforge.common.extensions;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@@ -36,20 +36,20 @@ import net.minecraftforge.client.model.data.EmptyModelData;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound>
public interface IForgeTileEntity extends ICapabilitySerializable<CompoundNBT>
{
default TileEntity getTileEntity() { return (TileEntity) this; }
@Override
default void deserializeNBT(NBTTagCompound nbt)
default void deserializeNBT(CompoundNBT nbt)
{
getTileEntity().read(nbt);
}
@Override
default NBTTagCompound serializeNBT()
default CompoundNBT serializeNBT()
{
NBTTagCompound ret = new NBTTagCompound();
CompoundNBT ret = new CompoundNBT();
getTileEntity().write(ret);
return ret;
}
@@ -63,7 +63,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
* @param net The NetworkManager the packet originated from
* @param pkt The data packet
*/
default void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.SPacketUpdateTileEntity pkt){ }
default void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.SUpdateTileEntityPacket pkt){ }
/**
* Called when the chunk's TE update tag, gotten from {@link #getUpdateTag()}, is received on the client.
@@ -72,7 +72,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
*
* @param tag The {@link NBTTagCompound} sent from {@link #getUpdateTag()}
*/
default void handleUpdateTag(NBTTagCompound tag)
default void handleUpdateTag(CompoundNBT tag)
{
getTileEntity().read(tag);
}
@@ -83,7 +83,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
*
* @return A compound tag for custom data
*/
NBTTagCompound getTileData();
CompoundNBT getTileData();
default void onChunkUnloaded(){}
@@ -95,17 +95,12 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
{
requestModelDataUpdate();
}
default boolean shouldRenderInPass(int pass)
{
return pass == 0;
}
/**
* Sometimes default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}.
*/
public static final AxisAlignedBB INFINITE_EXTENT_AABB = new net.minecraft.util.math.AxisAlignedBB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
/**
* Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity}
* Defaults to the collision bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated with the block
@@ -117,7 +112,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
default AxisAlignedBB getRenderBoundingBox()
{
AxisAlignedBB bb = INFINITE_EXTENT_AABB;
IBlockState state = getTileEntity().getBlockState();
BlockState state = getTileEntity().getBlockState();
Block block = state.getBlock();
BlockPos pos = getTileEntity().getPos();
if (block == Blocks.ENCHANTING_TABLE)
@@ -162,12 +157,12 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
default boolean canRenderBreaking()
{
Block block = getTileEntity().getBlockState().getBlock();
return (block instanceof net.minecraft.block.BlockChest ||
block instanceof net.minecraft.block.BlockEnderChest ||
block instanceof net.minecraft.block.BlockSign ||
block instanceof net.minecraft.block.BlockSkull);
return (block instanceof net.minecraft.block.ChestBlock ||
block instanceof net.minecraft.block.EnderChestBlock ||
block instanceof net.minecraft.block.AbstractSignBlock ||
block instanceof net.minecraft.block.SkullBlock);
}
/**
* If the TileEntitySpecialRenderer associated with this TileEntity can be batched in with another renderers, and won't access the GL state.
* If TileEntity returns true, then TESR should have the same functionality as (and probably extend) the FastTESR class.
@@ -176,7 +171,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
{
return false;
}
default void requestModelDataUpdate()
{
TileEntity te = getTileEntity();
@@ -186,7 +181,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
ModelDataManager.requestModelDataRefresh(te);
}
}
default @Nonnull IModelData getModelData()
{
return EmptyModelData.INSTANCE;
@@ -1,46 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.common.extensions;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.village.Village;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
public interface IForgeVillage extends ICapabilitySerializable<NBTTagCompound>
{
default Village getVillage()
{
return (Village) this;
}
@Override
default void deserializeNBT(NBTTagCompound nbt)
{
getVillage().readVillageDataFromNBT(nbt);
}
@Override
default NBTTagCompound serializeNBT()
{
NBTTagCompound ret = new NBTTagCompound();
getVillage().writeVillageDataToNBT(ret);
return ret;
}
}
@@ -19,17 +19,9 @@
package net.minecraftforge.common.extensions;
import java.io.File;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import net.minecraft.world.ServerWorld;
public interface IForgeWorldServer extends IForgeWorld
{
default WorldServer getWorldServer() { return (WorldServer) this; }
default File getChunkSaveLocation()
{
return ((AnvilChunkLoader) getWorldServer().getChunkProvider().chunkLoader).chunkSaveLocation;
}
default ServerWorld getWorldServer() { return (ServerWorld) this; }
}
@@ -22,19 +22,20 @@ package net.minecraftforge.common.extensions;
import java.util.function.LongFunction;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiCreateBuffetWorld;
import net.minecraft.client.gui.GuiCreateFlatWorld;
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.client.gui.screen.CreateBuffetWorldScreen;
import net.minecraft.client.gui.screen.CreateFlatWorldScreen;
import net.minecraft.client.gui.screen.CreateWorldScreen;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.IContextExtended;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.IExtendedNoiseRandom;
import net.minecraft.world.gen.OverworldGenSettings;
import net.minecraft.world.gen.area.IArea;
import net.minecraft.world.gen.area.IAreaFactory;
import net.minecraft.world.gen.layer.GenLayerBiome;
import net.minecraft.world.gen.layer.GenLayerBiomeEdge;
import net.minecraft.world.gen.layer.GenLayerZoom;
import net.minecraft.world.gen.layer.AddBambooForestLayer;
import net.minecraft.world.gen.layer.BiomeLayer;
import net.minecraft.world.gen.layer.EdgeBiomeLayer;
import net.minecraft.world.gen.layer.ZoomLayer;
import net.minecraft.world.gen.layer.LayerUtil;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -56,17 +57,17 @@ public interface IForgeWorldType
/**
* Called when the 'Customize' button is pressed on world creation GUI
*
*
* @param mc The Minecraft instance
* @param gui the createworld GUI
*/
@OnlyIn(Dist.CLIENT)
default void onCustomizeButton(Minecraft mc, GuiCreateWorld gui)
default void onCustomizeButton(Minecraft mc, CreateWorldScreen gui)
{
if (this == WorldType.FLAT)
mc.displayGuiScreen(new GuiCreateFlatWorld(gui, gui.chunkProviderSettingsJson));
mc.displayGuiScreen(new CreateFlatWorldScreen(gui, gui.chunkProviderSettingsJson));
else if (this == WorldType.BUFFET)
mc.displayGuiScreen(new GuiCreateBuffetWorld(gui, gui.chunkProviderSettingsJson));
mc.displayGuiScreen(new CreateBuffetWorldScreen(gui, gui.chunkProviderSettingsJson));
}
default boolean handleSlimeSpawnReduction(java.util.Random random, World world)
@@ -86,7 +87,7 @@ public interface IForgeWorldType
/**
* Get the height to render the clouds for this world type
*
*
* @return The height to render clouds at
*/
default float getCloudHeight()
@@ -95,7 +96,7 @@ public interface IForgeWorldType
}
@SuppressWarnings("deprecation")
default IChunkGenerator<?> createChunkGenerator(World world)
default ChunkGenerator<?> createChunkGenerator(World world)
{
return world.dimension.createChunkGenerator();
}
@@ -106,7 +107,7 @@ public interface IForgeWorldType
*
* @param <T> The type of {@link IArea}.
* @param <C> The type of {@link IContextExtended}.
*
*
* @param parentLayer The parent layer to feed into any layer you return
* @param chunkSettings The {@link OverworldGenSettings} used to create the
* {@link GenLayerBiome}.
@@ -115,12 +116,13 @@ public interface IForgeWorldType
* @return An {@link IAreaFactory} that representing the Biomes to be generated.
* @see {@link GenLayerBiome}
*/
default <T extends IArea, C extends IContextExtended<T>> IAreaFactory<T> getBiomeLayer(IAreaFactory<T> parentLayer,
default <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> getBiomeLayer(IAreaFactory<T> parentLayer,
OverworldGenSettings chunkSettings, LongFunction<C> contextFactory)
{
parentLayer = (new GenLayerBiome(getWorldType(), chunkSettings)).apply((IContextExtended) contextFactory.apply(200L), parentLayer);
parentLayer = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, parentLayer, 2, contextFactory);
parentLayer = GenLayerBiomeEdge.INSTANCE.apply((IContextExtended) contextFactory.apply(1000L), parentLayer);
parentLayer = (new BiomeLayer(getWorldType(), chunkSettings)).apply(contextFactory.apply(200L), parentLayer);
parentLayer = AddBambooForestLayer.INSTANCE.apply(contextFactory.apply(1001L), parentLayer);
parentLayer = LayerUtil.repeat(1000L, ZoomLayer.NORMAL, parentLayer, 2, contextFactory);
parentLayer = EdgeBiomeLayer.INSTANCE.apply(contextFactory.apply(1000L), parentLayer);
return parentLayer;
}
}