253 lines
12 KiB
Diff
253 lines
12 KiB
Diff
--- a/net/minecraft/block/Block.java
|
|
+++ b/net/minecraft/block/Block.java
|
|
@@ -75,9 +75,10 @@
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
-public class Block implements IItemProvider {
|
|
+public class Block extends net.minecraftforge.registries.ForgeRegistryEntry<Block> implements IItemProvider, net.minecraftforge.common.extensions.IForgeBlock {
|
|
protected static final Logger field_196273_d = LogManager.getLogger();
|
|
- public static final ObjectIntIdentityMap<BlockState> field_176229_d = new ObjectIntIdentityMap<>();
|
|
+ @Deprecated //Forge: Do not use, use GameRegistry
|
|
+ public static final ObjectIntIdentityMap<BlockState> field_176229_d = net.minecraftforge.registries.GameData.getBlockStateIDMap();
|
|
private static final Direction[] field_212556_a = new Direction[]{Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP};
|
|
private static final LoadingCache<VoxelShape, Boolean> field_223006_b = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader<VoxelShape, Boolean>() {
|
|
public Boolean load(VoxelShape p_load_1_) {
|
|
@@ -246,6 +247,8 @@
|
|
this.field_149765_K = p_i48440_1_.field_200961_i;
|
|
this.field_208621_p = p_i48440_1_.field_208772_j;
|
|
this.field_220085_g = p_i48440_1_.field_222381_j;
|
|
+ this.harvestLevel = p_i48440_1_.harvestLevel;
|
|
+ this.harvestTool = p_i48440_1_.harvestTool;
|
|
this.field_176227_L = builder.func_206893_a(BlockState::new);
|
|
this.func_180632_j(this.field_176227_L.func_177621_b());
|
|
}
|
|
@@ -291,7 +294,7 @@
|
|
|
|
@Deprecated
|
|
public boolean func_196253_a(BlockState p_196253_1_, BlockItemUseContext p_196253_2_) {
|
|
- return this.field_149764_J.func_76222_j() && (p_196253_2_.func_195996_i().func_190926_b() || p_196253_2_.func_195996_i().func_77973_b() != this.func_199767_j());
|
|
+ return p_196253_1_.func_185904_a().func_76222_j() && (p_196253_2_.func_195996_i().func_190926_b() || p_196253_2_.func_195996_i().func_77973_b() != this.func_199767_j());
|
|
}
|
|
|
|
@Deprecated
|
|
@@ -303,8 +306,9 @@
|
|
return this.field_149789_z;
|
|
}
|
|
|
|
+ @Deprecated //Forge: New State sensitive version.
|
|
public boolean func_149716_u() {
|
|
- return this instanceof ITileEntityProvider;
|
|
+ return hasTileEntity(func_176223_P());
|
|
}
|
|
|
|
@Deprecated
|
|
@@ -315,7 +319,7 @@
|
|
@Deprecated
|
|
@OnlyIn(Dist.CLIENT)
|
|
public int func_220058_a(BlockState p_220058_1_, IEnviromentBlockReader p_220058_2_, BlockPos p_220058_3_) {
|
|
- return p_220058_2_.func_217338_b(p_220058_3_, p_220058_1_.func_185906_d());
|
|
+ return p_220058_2_.func_217338_b(p_220058_3_, p_220058_1_.getLightValue(p_220058_2_, p_220058_3_));
|
|
}
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
@@ -460,10 +464,9 @@
|
|
|
|
@Deprecated
|
|
public void func_196243_a(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) {
|
|
- if (this.func_149716_u() && p_196243_1_.func_177230_c() != p_196243_4_.func_177230_c()) {
|
|
+ if (p_196243_1_.hasTileEntity() && p_196243_1_.func_177230_c() != p_196243_4_.func_177230_c()) {
|
|
p_196243_2_.func_175713_t(p_196243_3_);
|
|
}
|
|
-
|
|
}
|
|
|
|
@Deprecated
|
|
@@ -472,8 +475,8 @@
|
|
if (f == -1.0F) {
|
|
return 0.0F;
|
|
} else {
|
|
- int i = p_180647_2_.func_184823_b(p_180647_1_) ? 30 : 100;
|
|
- return p_180647_2_.func_184813_a(p_180647_1_) / f / (float)i;
|
|
+ int i = net.minecraftforge.common.ForgeHooks.canHarvestBlock(p_180647_1_, p_180647_2_, p_180647_3_, p_180647_4_) ? 30 : 100;
|
|
+ return p_180647_2_.getDigSpeed(p_180647_1_, p_180647_4_) / f / (float)i;
|
|
}
|
|
}
|
|
|
|
@@ -553,7 +556,7 @@
|
|
}
|
|
|
|
public static void func_180635_a(World p_180635_0_, BlockPos p_180635_1_, ItemStack p_180635_2_) {
|
|
- if (!p_180635_0_.field_72995_K && !p_180635_2_.func_190926_b() && p_180635_0_.func_82736_K().func_223586_b(GameRules.field_223603_f)) {
|
|
+ if (!p_180635_0_.field_72995_K && !p_180635_2_.func_190926_b() && p_180635_0_.func_82736_K().func_223586_b(GameRules.field_223603_f) && !p_180635_0_.restoringBlockSnapshots) { // do not drop items while restoring blockstates, prevents item dupe
|
|
float f = 0.5F;
|
|
double d0 = (double)(p_180635_0_.field_73012_v.nextFloat() * 0.5F) + 0.25D;
|
|
double d1 = (double)(p_180635_0_.field_73012_v.nextFloat() * 0.5F) + 0.25D;
|
|
@@ -565,7 +568,7 @@
|
|
}
|
|
|
|
public void func_180637_b(World p_180637_1_, BlockPos p_180637_2_, int p_180637_3_) {
|
|
- if (!p_180637_1_.field_72995_K && p_180637_1_.func_82736_K().func_223586_b(GameRules.field_223603_f)) {
|
|
+ if (!p_180637_1_.field_72995_K && p_180637_1_.func_82736_K().func_223586_b(GameRules.field_223603_f) && !p_180637_1_.restoringBlockSnapshots) { // do not drop items while restoring blockstates, prevents item dupe
|
|
while(p_180637_3_ > 0) {
|
|
int i = ExperienceOrbEntity.func_70527_a(p_180637_3_);
|
|
p_180637_3_ -= i;
|
|
@@ -575,6 +578,7 @@
|
|
|
|
}
|
|
|
|
+ @Deprecated //Forge: State sensitive version
|
|
public float func_149638_a() {
|
|
return this.field_149781_w;
|
|
}
|
|
@@ -677,6 +681,7 @@
|
|
p_176216_2_.func_213317_d(p_176216_2_.func_213322_ci().func_216372_d(1.0D, 0.0D, 1.0D));
|
|
}
|
|
|
|
+ @Deprecated // Forge: Use more sensitive version below: getPickBlock
|
|
@OnlyIn(Dist.CLIENT)
|
|
public ItemStack func_185473_a(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) {
|
|
return new ItemStack(this);
|
|
@@ -691,6 +696,7 @@
|
|
return Fluids.field_204541_a.func_207188_f();
|
|
}
|
|
|
|
+ @Deprecated //Forge: Use more sensitive version
|
|
public float func_208618_m() {
|
|
return this.field_149765_K;
|
|
}
|
|
@@ -711,6 +717,7 @@
|
|
public void func_176224_k(World p_176224_1_, BlockPos p_176224_2_) {
|
|
}
|
|
|
|
+ @Deprecated //Forge: Use more sensitive version
|
|
public boolean func_149659_a(Explosion p_149659_1_) {
|
|
return true;
|
|
}
|
|
@@ -755,6 +762,7 @@
|
|
}
|
|
}
|
|
|
|
+ @Deprecated //Forge: Use more sensitive version {@link IForgeBlockState#getSoundType(IWorldReader, BlockPos, Entity) }
|
|
public SoundType func_220072_p(BlockState p_220072_1_) {
|
|
return this.field_149762_H;
|
|
}
|
|
@@ -780,13 +788,80 @@
|
|
}
|
|
|
|
public static boolean func_196252_e(Block p_196252_0_) {
|
|
- return p_196252_0_ == Blocks.field_150348_b || p_196252_0_ == Blocks.field_196650_c || p_196252_0_ == Blocks.field_196654_e || p_196252_0_ == Blocks.field_196656_g;
|
|
+ return net.minecraftforge.common.Tags.Blocks.STONE.func_199685_a_(p_196252_0_);
|
|
}
|
|
|
|
public static boolean func_196245_f(Block p_196245_0_) {
|
|
- return p_196245_0_ == Blocks.field_150346_d || p_196245_0_ == Blocks.field_196660_k || p_196245_0_ == Blocks.field_196661_l;
|
|
+ return net.minecraftforge.common.Tags.Blocks.DIRT.func_199685_a_(p_196245_0_);
|
|
}
|
|
|
|
+ /* ======================================== FORGE START =====================================*/
|
|
+ protected Random RANDOM = new Random();
|
|
+ private net.minecraftforge.common.ToolType harvestTool;
|
|
+ private int harvestLevel;
|
|
+ private final net.minecraftforge.common.util.ReverseTagWrapper<Block> reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, BlockTags::getGeneration, 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) {
|
|
+ return harvestTool; //TODO: RE-Evaluate
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int getHarvestLevel(BlockState state) {
|
|
+ return harvestLevel; //TODO: RE-Evaluate
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction facing, net.minecraftforge.common.IPlantable plantable) {
|
|
+ BlockState plant = plantable.getPlant(world, pos.func_177972_a(facing));
|
|
+ net.minecraftforge.common.PlantType type = plantable.getPlantType(world, pos.func_177972_a(facing));
|
|
+
|
|
+ if (plant.func_177230_c() == Blocks.field_150434_aF)
|
|
+ return this.getBlock() == Blocks.field_150434_aF || this.getBlock() == Blocks.field_150354_m || this.getBlock() == Blocks.field_196611_F;
|
|
+
|
|
+ if (plant.func_177230_c() == Blocks.field_196608_cF && this == Blocks.field_196608_cF)
|
|
+ return true;
|
|
+
|
|
+ if (plantable instanceof BushBlock && ((BushBlock)plantable).func_200014_a_(state, world, pos))
|
|
+ return true;
|
|
+
|
|
+ switch (type) {
|
|
+ case Desert: return this.getBlock() == Blocks.field_150354_m || this.getBlock() == Blocks.field_150405_ch || this.getBlock() instanceof GlazedTerracottaBlock;
|
|
+ case Nether: return this.getBlock() == Blocks.field_150425_aM;
|
|
+ case Crop: return this.getBlock() == Blocks.field_150458_ak;
|
|
+ case Cave: return Block.func_220056_d(state, world, pos, Direction.UP);
|
|
+ case Plains: return this.getBlock() == Blocks.field_196658_i || Block.func_196245_f(this) || this.getBlock() == Blocks.field_150458_ak;
|
|
+ case Water: return state.func_185904_a() == Material.field_151586_h; //&& state.getValue(BlockLiquidWrapper)
|
|
+ case Beach:
|
|
+ boolean isBeach = this.getBlock() == Blocks.field_196658_i || Block.func_196245_f(this) || this.getBlock() == Blocks.field_150354_m;
|
|
+ boolean hasWater = (world.func_180495_p(pos.func_177974_f()).func_185904_a() == Material.field_151586_h ||
|
|
+ world.func_180495_p(pos.func_177976_e()).func_185904_a() == Material.field_151586_h ||
|
|
+ world.func_180495_p(pos.func_177978_c()).func_185904_a() == Material.field_151586_h ||
|
|
+ world.func_180495_p(pos.func_177968_d()).func_185904_a() == Material.field_151586_h);
|
|
+ return isBeach && hasWater;
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final java.util.Set<ResourceLocation> getTags() {
|
|
+ return reverseTags.getTagNames();
|
|
+ }
|
|
+
|
|
+ static {
|
|
+ net.minecraftforge.common.ForgeHooks.setBlockToolSetter((block, tool, level) -> {
|
|
+ block.harvestTool = tool;
|
|
+ block.harvestLevel = level;
|
|
+ });
|
|
+ }
|
|
+ /* ========================================= FORGE END ======================================*/
|
|
+
|
|
public static enum OffsetType {
|
|
NONE,
|
|
XZ,
|
|
@@ -805,6 +880,8 @@
|
|
private float field_200961_i = 0.6F;
|
|
private ResourceLocation field_222381_j;
|
|
private boolean field_208772_j;
|
|
+ private int harvestLevel = -1;
|
|
+ private net.minecraftforge.common.ToolType harvestTool;
|
|
|
|
private Properties(Material p_i48616_1_, MaterialColor p_i48616_2_) {
|
|
this.field_200953_a = p_i48616_1_;
|
|
@@ -835,6 +912,8 @@
|
|
block$properties.field_200956_d = p_200950_0_.field_149762_H;
|
|
block$properties.field_200961_i = p_200950_0_.func_208618_m();
|
|
block$properties.field_208772_j = p_200950_0_.field_208621_p;
|
|
+ block$properties.harvestLevel = p_200950_0_.harvestLevel;
|
|
+ block$properties.harvestTool = p_200950_0_.harvestTool;
|
|
return block$properties;
|
|
}
|
|
|
|
@@ -883,6 +962,16 @@
|
|
return this;
|
|
}
|
|
|
|
+ public Block.Properties harvestLevel(int harvestLevel) {
|
|
+ this.harvestLevel = harvestLevel;
|
|
+ return this;
|
|
+ }
|
|
+
|
|
+ public Block.Properties harvestTool(net.minecraftforge.common.ToolType harvestTool) {
|
|
+ this.harvestTool = harvestTool;
|
|
+ return this;
|
|
+ }
|
|
+
|
|
public Block.Properties func_222380_e() {
|
|
this.field_222381_j = LootTables.field_186419_a;
|
|
return this;
|