Fix a few places where the vanilla method was being called instead of the forge one (#7535)

Cleanup javadocs references slightly, fix a couple spots not using the proper forge hooks, and remove a couple unneeded patches
Update deprecation comment on isAir
This commit is contained in:
Sara Freimer authored and GitHub committed 2021-03-03 12:50:32 -08:00
1 parent 17500032ae
commit 9602c22083
12 files changed
+64 -78

No files matched your search

@@ -80,11 +80,17 @@
public abstract static class AbstractBlockState extends StateHolder<Block, BlockState> {
private final int field_215708_d;
private final boolean field_215709_e;
@@ -428,14 +439,18 @@
@@ -424,18 +435,24 @@
return this.field_215709_e;
}
+ /** @deprecated use {@link BlockState#getLightValue(IBlockReader, BlockPos)} */
+ @Deprecated
public int func_185906_d() {
return this.field_215708_d;
}
+ /** @deprecated use {@link BlockState#isAir(IBlockReader, BlockPos) */
+ /** @deprecated use {@link BlockState#isAir(IBlockReader, BlockPos)} until 1.17, at which point this method will be undreprecated. See https://github.com/MinecraftForge/MinecraftForge/issues/7409 for more details */
+ @Deprecated
public boolean func_196958_f() {
- return this.field_235702_f_;
@@ -95,12 +101,12 @@
return this.field_235704_h_;
}
+ /** @deprecated use {@link BlockState#rotate(IWorld, BlockPos, Rotation) */
+ /** @deprecated use {@link BlockState#rotate(IWorld, BlockPos, Rotation)} */
+ @Deprecated
public BlockState func_185907_a(Rotation p_185907_1_) {
return this.func_177230_c().func_185499_a(this.func_230340_p_(), p_185907_1_);
}
@@ -802,6 +817,9 @@
@@ -802,8 +819,11 @@
private ResourceLocation field_222381_j;
private boolean field_226895_m_ = true;
private boolean field_235813_o_;
@@ -108,9 +114,12 @@
+ private net.minecraftforge.common.ToolType harvestTool;
+ private java.util.function.Supplier<ResourceLocation> lootTableSupplier;
private AbstractBlock.IExtendedPositionPredicate<EntityType<?>> field_235814_p_ = (p_235832_0_, p_235832_1_, p_235832_2_, p_235832_3_) -> {
return p_235832_0_.func_224755_d(p_235832_1_, p_235832_2_, Direction.UP) && p_235832_0_.func_185906_d() < 14;
- return p_235832_0_.func_224755_d(p_235832_1_, p_235832_2_, Direction.UP) && p_235832_0_.func_185906_d() < 14;
+ return p_235832_0_.func_224755_d(p_235832_1_, p_235832_2_, Direction.UP) && p_235832_0_.getLightValue(p_235832_1_, p_235832_2_) < 14;
};
@@ -863,6 +881,8 @@
private AbstractBlock.IPositionPredicate field_235815_q_ = (p_235853_0_, p_235853_1_, p_235853_2_) -> {
return p_235853_0_.func_185904_a().func_76218_k() && p_235853_0_.func_235785_r_(p_235853_1_, p_235853_2_);
@@ -863,6 +883,8 @@
abstractblock$properties.field_226895_m_ = p_200950_0_.field_235684_aB_.field_226895_m_;
abstractblock$properties.field_235813_o_ = p_200950_0_.field_235684_aB_.field_235813_o_;
abstractblock$properties.field_235806_h_ = p_200950_0_.field_235684_aB_.field_235806_h_;
@@ -119,7 +128,7 @@
return abstractblock$properties;
}
@@ -877,6 +897,24 @@
@@ -877,6 +899,24 @@
return this;
}
@@ -144,7 +153,7 @@
public AbstractBlock.Properties func_200941_a(float p_200941_1_) {
this.field_200961_i = p_200941_1_;
return this;
@@ -932,11 +970,17 @@
@@ -932,11 +972,17 @@
return this;
}
@@ -90,7 +90,7 @@
}
@OnlyIn(Dist.CLIENT)
@@ -410,6 +417,83 @@
@@ -410,6 +417,78 @@
return this;
}
@@ -100,11 +100,6 @@
+ private int harvestLevel;
+ private final net.minecraftforge.common.util.ReverseTagWrapper<Block> reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, BlockTags::func_199896_a);
+
+ @Override
+ public float getSlipperiness(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity) {
+ return this.field_149765_K;
+ }
+
+ @Nullable
+ @Override
+ public net.minecraftforge.common.ToolType getHarvestTool(BlockState state) {
@@ -1,14 +0,0 @@
--- a/net/minecraft/block/LadderBlock.java
+++ b/net/minecraft/block/LadderBlock.java
@@ -93,6 +93,11 @@
return null;
}
+ @Override
+ public boolean isLadder(BlockState state, net.minecraft.world.IWorldReader world, BlockPos pos, net.minecraft.entity.LivingEntity entity) {
+ return true;
+ }
+
public BlockState func_185499_a(BlockState p_185499_1_, Rotation p_185499_2_) {
return p_185499_1_.func_206870_a(field_176382_a, p_185499_2_.func_185831_a(p_185499_1_.func_177229_b(field_176382_a)));
}
@@ -1,11 +0,0 @@
--- a/net/minecraft/block/ScaffoldingBlock.java
+++ b/net/minecraft/block/ScaffoldingBlock.java
@@ -138,6 +138,8 @@
return i;
}
+ @Override public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, net.minecraft.entity.LivingEntity entity) { return true; }
+
static {
VoxelShape voxelshape = Block.func_208617_a(0.0D, 14.0D, 0.0D, 16.0D, 16.0D, 16.0D);
VoxelShape voxelshape1 = Block.func_208617_a(0.0D, 0.0D, 0.0D, 2.0D, 16.0D, 2.0D);
@@ -10,7 +10,7 @@
+ public boolean isLadder(BlockState state, net.minecraft.world.IWorldReader world, BlockPos pos, net.minecraft.entity.LivingEntity entity) {
+ if (state.func_177229_b(field_176283_b)) {
+ BlockState down = world.func_180495_p(pos.func_177977_b());
+ if (down.func_177230_c() == net.minecraft.block.Blocks.field_150468_ap)
+ if (down.func_203425_a(net.minecraft.block.Blocks.field_150468_ap))
+ return down.func_177229_b(LadderBlock.field_176382_a) == state.func_177229_b(field_185512_D);
+ }
+ return false;
@@ -38,11 +38,3 @@
BlockState blockstate2 = this.func_196544_a(p_225542_1_, blockstate1, p_225542_4_);
if (blockstate1 != blockstate2 && this.func_196540_x(blockstate2)) {
p_225542_2_.func_180501_a(blockpos1, blockstate2, 2);
@@ -322,4 +323,7 @@
public static BooleanProperty func_176267_a(Direction p_176267_0_) {
return field_196546_A.get(p_176267_0_);
}
+
+ @Override
+ public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, net.minecraft.entity.LivingEntity entity) { return true; }
}
@@ -27,6 +27,15 @@
if (this.func_92059_d().func_190926_b()) {
this.func_70106_y();
} else {
@@ -108,7 +114,7 @@
this.func_213315_a(MoverType.SELF, this.func_213322_ci());
float f1 = 0.98F;
if (this.field_70122_E) {
- f1 = this.field_70170_p.func_180495_p(new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_())).func_177230_c().func_208618_m() * 0.98F;
+ f1 = this.field_70170_p.func_180495_p(new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_())).getSlipperiness(field_70170_p, new BlockPos(this.func_226277_ct_(), this.func_226278_cu_() - 1.0D, this.func_226281_cx_()), this) * 0.98F;
}
this.func_213317_d(this.func_213322_ci().func_216372_d((double)f1, 0.98D, (double)f1));
@@ -144,7 +150,14 @@
}
}
@@ -1,5 +1,14 @@
--- a/net/minecraft/item/MerchantOffer.java
+++ b/net/minecraft/item/MerchantOffer.java
@@ -74,7 +74,7 @@
int i = this.field_222223_a.func_190916_E();
ItemStack itemstack = this.field_222223_a.func_77946_l();
int j = Math.max(0, MathHelper.func_76141_d((float)(i * this.field_222230_h) * this.field_222231_i));
- itemstack.func_190920_e(MathHelper.func_76125_a(i + j + this.field_222229_g, 1, this.field_222223_a.func_77973_b().func_77639_j()));
+ itemstack.func_190920_e(MathHelper.func_76125_a(i + j + this.field_222229_g, 1, this.field_222223_a.func_77976_d()));
return itemstack;
}
@@ -178,7 +178,7 @@
return true;
} else {
@@ -74,9 +74,9 @@ public interface IForgeBlock
* between 0 and 1.
* <p>
* Note that entities may reduce slipperiness by a certain factor of their own;
* for {@link net.minecraft.entity.EntityLivingBase}, this is {@code .91}.
* {@link net.minecraft.entity.item.EntityItem} uses {@code .98}, and
* {@link net.minecraft.entity.projectile.EntityFishHook} uses {@code .92}.
* for {@link net.minecraft.entity.LivingEntity}, this is {@code .91}.
* {@link net.minecraft.entity.item.ItemEntity} uses {@code .98}, and
* {@link net.minecraft.entity.projectile.FishingBobberEntity} uses {@code .92}.
*
* @param state state of the block
* @param world the world
@@ -84,7 +84,10 @@ public interface IForgeBlock
* @param entity the entity in question
* @return the factor by which the entity's motion should be multiplied
*/
float getSlipperiness(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity);
default float getSlipperiness(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity)
{
return getBlock().getSlipperiness();
}
/**
* Get a light value for this block, taking into account the given state and coordinates, normal ranges are between 0 and 15
@@ -379,7 +382,7 @@ public interface IForgeBlock
/**
* Allows a block to override the standard vanilla running particles.
* This is called from {@link Entity#spawnRunningParticles} and is called both,
* This is called from {@link Entity#handleRunningEffect} and is called both,
* Client and server side, it's up to the implementor to client check / server check.
* By default vanilla spawns particles only on the client and the server methods no-op.
*
@@ -407,7 +410,7 @@ public interface IForgeBlock
* @return True to prevent vanilla digging particles form spawning.
*/
@OnlyIn(Dist.CLIENT)
default boolean addHitEffects(BlockState state, World worldObj, RayTraceResult target, ParticleManager manager)
default boolean addHitEffects(BlockState state, World world, RayTraceResult target, ParticleManager manager)
{
return false;
}
@@ -463,6 +466,7 @@ public interface IForgeBlock
* @param pos Block position in world
* @param source Source plant's position in world
*/
@Deprecated//TODO - 1.17: Remove (unused)
default void onPlantGrow(BlockState state, IWorld world, BlockPos pos, BlockPos source)
{
if (state.isIn(Tags.Blocks.DIRT))
@@ -562,6 +566,7 @@ public interface IForgeBlock
* @param changedBlock The updated block.
* @param changedBlockPos The updated block's position.
*/
@Deprecated//TODO - 1.17: Remove (unused)
default void observedNeighborChange(BlockState observerState, World world, BlockPos observerPos, Block changedBlock, BlockPos changedBlockPos){}
/**
@@ -57,9 +57,9 @@ public interface IForgeBlockState
* between 0 and 1.
* <p>
* Note that entities may reduce slipperiness by a certain factor of their own;
* for {@link net.minecraft.entity.EntityLivingBase}, this is {@code .91}.
* {@link net.minecraft.entity.item.EntityItem} uses {@code .98}, and
* {@link net.minecraft.entity.projectile.EntityFishHook} uses {@code .92}.
* for {@link net.minecraft.entity.LivingEntity}, this is {@code .91}.
* {@link net.minecraft.entity.item.ItemEntity} uses {@code .98}, and
* {@link net.minecraft.entity.projectile.FishingBobberEntity} uses {@code .92}.
*
* @param world the world
* @param pos the position in the world
@@ -327,7 +327,7 @@ public interface IForgeBlockState
}
/**
* Allows a block to override the standard vanilla running particles.
* This is called from {@link Entity#spawnRunningParticles} and is called both,
* This is called from {@link Entity#handleRunningEffect} and is called both,
* Client and server side, it's up to the implementor to client check / server check.
* By default vanilla spawns particles only on the client and the server methods no-op.
*
@@ -478,12 +478,12 @@ public interface IForgeBlockState
/**
* Called on an Observer block whenever an update for an Observer is received.
*
* @param observerState The Observer block's state.
* @param world The current world.
* @param pos The Observer block's position.
* @param changed The updated block.
* @param changedPos The updated block's position.
*/
@Deprecated//TODO - 1.17: Remove (unused)
default void observedNeighborChange(World world, BlockPos pos, Block changed, BlockPos changedPos)
{
getBlockState().getBlock().observedNeighborChange(getBlockState(), world, pos, changed, changedPos);
@@ -553,7 +553,7 @@ public interface IForgeBlockState
/**
* @param world The world
* @param pos The position of this state
* @param beaconPos The position of the beacon
* @param beacon The position of the beacon
* @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
@@ -594,7 +594,6 @@ public interface IForgeBlockState
}
/**
* @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 isSlimeBlock()
@@ -603,7 +602,6 @@ public interface IForgeBlockState
}
/**
* @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()
@@ -790,7 +788,7 @@ public interface IForgeBlockState
* @param pos The block position in world
* @param player The player clicking the block
* @param stack The stack being used by the player
* @param toolTypes The tool types to be considered when performing the action
* @param toolType The tool type to be considered when performing the action
* @return The resulting state after the action has been performed
*/
@Nullable
@@ -381,11 +381,11 @@ public interface IForgeItem
/**
* Override this to set a non-default armor slot for an ItemStack, but <em>do
* not use this to get the armor slot of said stack; for that, use
* {@link net.minecraft.entity.EntityLiving#getSlotForItemStack(ItemStack)}.</em>
* {@link net.minecraft.entity.LivingEntity#getSlotForItemStack(ItemStack)}.</em>
*
* @param stack the ItemStack
* @return the armor slot of the ItemStack, or {@code null} to let the default
* vanilla logic as per {@code EntityLiving.getSlotForItemStack(stack)}
* vanilla logic as per {@code LivingEntity.getSlotForItemStack(stack)}
* decide
*/
@Nullable
@@ -733,8 +733,8 @@ public interface IForgeItem
*
* @param stack The ItemStack
* @param shield The shield in question
* @param entity The EntityLivingBase holding the shield
* @param attacker The EntityLivingBase holding the ItemStack
* @param entity The LivingEntity holding the shield
* @param attacker The LivingEntity holding the ItemStack
* @retrun True if this ItemStack can disable the shield in question.
*/
default boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker)
@@ -61,7 +61,6 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
* ItemStack sensitive version of getContainerItem. Returns a full ItemStack
* instance of the result.
*
* @param itemStack The current ItemStack
* @return The resulting ItemStack
*/
default ItemStack getContainerItem()
@@ -72,7 +71,6 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
/**
* ItemStack sensitive version of hasContainerItem
*
* @param stack The current item stack
* @return True if this item has a 'container'
*/
default boolean hasContainerItem()
@@ -168,7 +166,6 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
* check the individual implementation for reference. By default this will check
* if the enchantment type is valid for this item type.
*
* @param stack the item stack to be enchanted
* @param enchantment the enchantment to be applied
* @return true if the enchantment can be applied to this item
*/
@@ -190,10 +187,10 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
/**
* Override this to set a non-default armor slot for an ItemStack, but <em>do
* not use this to get the armor slot of said stack; for that, use
* {@link net.minecraft.entity.EntityLiving#getSlotForItemStack(ItemStack)}.</em>
* {@link net.minecraft.entity.LivingEntity#getSlotForItemStack(ItemStack)}.</em>
*
* @return the armor slot of the ItemStack, or {@code null} to let the default
* vanilla logic as per {@code EntityLiving.getSlotForItemStack(stack)}
* vanilla logic as per {@code LivingEntity.getSlotForItemStack(stack)}
* decide
*/
@Nullable
@@ -206,8 +203,8 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
* Can this Item disable a shield
*
* @param shield The shield in question
* @param entity The EntityLivingBase holding the shield
* @param attacker The EntityLivingBase holding the ItemStack
* @param entity The LivingEntity holding the shield
* @param attacker The LivingEntity holding the ItemStack
* @retrun True if this ItemStack can disable the shield in question.
*/
default boolean canDisableShield(ItemStack shield, LivingEntity entity, LivingEntity attacker)
@@ -292,7 +289,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
}
/**
* Called every tick from {@link EntityHorse#onUpdate()} on the item in the
* Called every tick from {@link HorseEntity#onUpdate()} on the item in the
* armor slot.
*
* @param world the world the horse is in
@@ -319,7 +316,6 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
/**
* Allow or forbid the specific book/item combination as an anvil enchant
*
* @param stack The item
* @param book The book
* @return if the enchantment is allowed
*/
@@ -335,7 +331,6 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
* spawning in the world
*
* @param player The player that dropped the item
* @param item The item stack, before the item is removed.
*/
default boolean onDroppedByPlayer(PlayerEntity player)
{
@@ -378,7 +373,6 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
* Override this method to decide what to do with the NBT data received from
* getNBTShareTag().
*
* @param stack The stack that received NBT
* @param nbt Received NBT, can be null
*/
default void readShareTag(@Nullable CompoundNBT nbt)