Skip to content

Commit

Permalink
允许2826及以上客户端使用DataSerializers
Browse files Browse the repository at this point in the history
  • Loading branch information
Luohuayu committed Aug 25, 2019
1 parent 0f814e8 commit 40f2af3
Show file tree
Hide file tree
Showing 17 changed files with 289 additions and 64 deletions.
24 changes: 19 additions & 5 deletions patches/net/minecraft/block/Block.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
public SoundType getSoundType()
{
return this.blockSoundType;
@@ -934,6 +960,1374 @@
@@ -934,6 +960,1388 @@
{
}

Expand Down Expand Up @@ -1461,7 +1461,21 @@
+ return null;
+ }
+
+ /**
+ /**
+ * Called when entities are swimming in the given liquid and returns the relative height (used by {@link net.minecraft.entity.item.EntityBoat})
+ *
+ * @param world world that is being tested.
+ * @param pos block thats being tested.
+ * @param state state at world/pos
+ * @param material liquid thats being tested.
+ * @return relative height of the given liquid (material), a value between 0 and 1
+ */
+ public float getBlockLiquidHeight(World world, BlockPos pos, IBlockState state, Material material)
+ {
+ return 0;
+ }
+
+ /**
+ * Queries if this block should render in a given layer.
+ * ISmartBlockModel can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter their model based on layer.
+ */
Expand Down Expand Up @@ -1649,7 +1663,7 @@
public static void registerBlocks()
{
registerBlock(0, AIR_ID, (new BlockAir()).setUnlocalizedName("air"));
@@ -1105,7 +2499,7 @@
@@ -1105,7 +2513,7 @@
Block block11 = (new BlockQuartz()).setSoundType(SoundType.STONE).setHardness(0.8F).setUnlocalizedName("quartzBlock");
registerBlock(155, "quartz_block", block11);
registerBlock(156, "quartz_stairs", (new BlockStairs(block11.getDefaultState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.DEFAULT))).setUnlocalizedName("stairsQuartz"));
Expand All @@ -1658,7 +1672,7 @@
registerBlock(158, "dropper", (new BlockDropper()).setHardness(3.5F).setSoundType(SoundType.STONE).setUnlocalizedName("dropper"));
registerBlock(159, "stained_hardened_clay", (new BlockStainedHardenedClay()).setHardness(1.25F).setResistance(7.0F).setSoundType(SoundType.STONE).setUnlocalizedName("clayHardenedStained"));
registerBlock(160, "stained_glass_pane", (new BlockStainedGlassPane()).setHardness(0.3F).setSoundType(SoundType.GLASS).setUnlocalizedName("thinStainedGlass"));
@@ -1230,31 +2624,6 @@
@@ -1230,31 +2638,6 @@
block15.useNeighborBrightness = flag;
}
}
Expand Down Expand Up @@ -1690,7 +1704,7 @@
}

private static void registerBlock(int id, ResourceLocation textualID, Block block_)
@@ -1266,7 +2635,17 @@
@@ -1266,7 +2649,17 @@
{
registerBlock(id, new ResourceLocation(textualID), block_);
}
Expand Down
12 changes: 11 additions & 1 deletion patches/net/minecraft/block/BlockLiquid.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@
return true;
}
}
@@ -452,4 +454,29 @@
@@ -448,8 +450,39 @@
return (float)pos.getY() + getBlockLiquidHeight(state, worldIn, pos);
}

+ @Override
+ public float getBlockLiquidHeight(World world, BlockPos pos, IBlockState state, Material material)
+ {
+ return BlockLiquid.getBlockLiquidHeight(state, world, pos);
+ }
+
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
{
return BlockFaceShape.UNDEFINED;
}
Expand Down
66 changes: 55 additions & 11 deletions patches/net/minecraft/entity/item/EntityBoat.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,19 @@
}
}
}
@@ -508,7 +564,7 @@
@@ -448,6 +504,11 @@
{
blockpos$pooledmutableblockpos.setPos(l1, k1, i2);
IBlockState iblockstate = this.world.getBlockState(blockpos$pooledmutableblockpos);
+ Boolean result = iblockstate.getBlock().isAABBInsideMaterial(world, blockpos$pooledmutableblockpos, new AxisAlignedBB(blockpos$pooledmutableblockpos), Material.WATER);
+ if (result != null) {
+ if (!result) continue;
+ f = Math.max(f, iblockstate.getBlock().getBlockLiquidHeight(world, blockpos$pooledmutableblockpos, iblockstate, Material.WATER) + blockpos$pooledmutableblockpos.getY());
+ }

if (iblockstate.getMaterial() == Material.WATER)
{
@@ -508,7 +569,7 @@

if (!list.isEmpty())
{
Expand All @@ -176,7 +188,39 @@
++k1;
}

@@ -598,7 +654,7 @@
@@ -550,7 +611,15 @@
{
blockpos$pooledmutableblockpos.setPos(k1, l1, i2);
IBlockState iblockstate = this.world.getBlockState(blockpos$pooledmutableblockpos);
+ Boolean result = iblockstate.getBlock().isAABBInsideMaterial(world, blockpos$pooledmutableblockpos, axisalignedbb, Material.WATER);
+ if (result != null) {
+ if (!result) continue;

+ float f = iblockstate.getBlock().getBlockLiquidHeight(world, blockpos$pooledmutableblockpos, iblockstate, Material.WATER) + blockpos$pooledmutableblockpos.getY();
+ this.waterLevel = Math.max((double)f, this.waterLevel);
+ flag |= axisalignedbb.minY < (double)f;
+ }
+
if (iblockstate.getMaterial() == Material.WATER)
{
float f = BlockLiquid.getLiquidHeight(iblockstate, this.world, blockpos$pooledmutableblockpos);
@@ -594,11 +663,23 @@
blockpos$pooledmutableblockpos.setPos(k1, l1, i2);
IBlockState iblockstate = this.world.getBlockState(blockpos$pooledmutableblockpos);

+ Boolean result = iblockstate.getBlock().isAABBInsideMaterial(world, blockpos$pooledmutableblockpos, axisalignedbb, Material.WATER);
+ if (result != null) {
+ if (!result) continue;
+
+ if(iblockstate.getBlock().getBlockLiquidHeight(world, blockpos$pooledmutableblockpos, iblockstate, Material.WATER) > 0)
+ {
+ blockpos$pooledmutableblockpos.release();
+ return EntityBoat.Status.UNDER_FLOWING_WATER;
+ } else
+ continue;
+ }
+
if (iblockstate.getMaterial() == Material.WATER && d0 < (double)BlockLiquid.getLiquidHeight(iblockstate, this.world, blockpos$pooledmutableblockpos))
{
if (((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() != 0)
{
Expand All @@ -185,7 +229,7 @@
return entityboat$status;
}

@@ -613,7 +669,7 @@
@@ -613,7 +694,7 @@
blockpos$pooledmutableblockpos.release();
}

Expand All @@ -194,7 +238,7 @@
}

private void updateMotion()
@@ -623,36 +679,36 @@
@@ -623,36 +704,36 @@
double d2 = 0.0D;
this.momentum = 0.05F;

Expand Down Expand Up @@ -238,7 +282,7 @@
{
this.momentum = this.boatGlide;

@@ -782,7 +838,7 @@
@@ -782,7 +863,7 @@
{
if (compound.hasKey("Type", 8))
{
Expand All @@ -247,7 +291,7 @@
}
}

@@ -813,7 +869,7 @@
@@ -813,7 +894,7 @@
{
if (this.fallDistance > 3.0F)
{
Expand All @@ -256,7 +300,7 @@
{
this.fallDistance = 0.0F;
return;
@@ -823,19 +879,20 @@
@@ -823,19 +904,20 @@

if (!this.world.isRemote && !this.isDead)
{
Expand Down Expand Up @@ -288,7 +332,7 @@
}
}
}
@@ -884,14 +941,14 @@
@@ -884,14 +966,14 @@
return ((Integer)this.dataManager.get(FORWARD_DIRECTION)).intValue();
}

Expand All @@ -306,7 +350,7 @@
}

protected boolean canFitPassenger(Entity passenger)
@@ -957,7 +1014,7 @@
@@ -957,7 +1039,7 @@
return this.name;
}

Expand All @@ -315,7 +359,7 @@
{
if (id < 0 || id >= values().length)
{
@@ -967,7 +1024,7 @@
@@ -967,7 +1049,7 @@
return values()[id];
}

Expand All @@ -324,7 +368,7 @@
{
for (int i = 0; i < values().length; ++i)
{
@@ -980,4 +1037,20 @@
@@ -980,4 +1062,20 @@
return values()[0];
}
}
Expand Down
Loading

0 comments on commit 40f2af3

Please sign in to comment.