Leaf decay (server and client side)

This commit is contained in:
PeytonPlayz595 2024-03-27 17:27:35 -04:00
parent 72e60b2259
commit 5ba81a0669
6 changed files with 15307 additions and 15271 deletions

Binary file not shown.

View File

@ -4,96 +4,110 @@ import java.util.Random;
public class BlockLeaves extends BlockLeavesBase { public class BlockLeaves extends BlockLeavesBase {
private int baseIndexInPNG; private int baseIndexInPNG;
private int field_663_c = 0; int field_464_c[];
protected BlockLeaves(int var1, int var2) { protected BlockLeaves(int var1, int var2) {
super(var1, var2, Material.field_4218_h, false); super(var1, var2, Material.field_4218_h, false);
this.baseIndexInPNG = var2; this.baseIndexInPNG = var2;
setTickOnLoad(true);
} }
public void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { public void onBlockRemoval(World var1, int var2, int var3, int var4) {
if(this == null) { int l = 1;
this.field_663_c = 0; int i1 = l + 1;
this.func_316_g(var1, var2, var3, var4); if (var1.checkChunksExist(var2 - i1, var3 - i1, var4 - i1, var2 + i1, var3 + i1, var4 + i1)) {
super.onNeighborBlockChange(var1, var2, var3, var4, var5); for (int j1 = -l; j1 <= l; j1++) {
} for (int k1 = -l; k1 <= l; k1++) {
} for (int l1 = -l; l1 <= l; l1++) {
int i2 = var1.getBlockId(var2 + j1, var3 + k1, var4 + l1);
if (i2 == Block.leaves.blockID) {
int j2 = var1.getBlockMetadata(var2 + j1, var3 + k1, var4 + l1);
var1.setBlockMetadata(var2 + j1, var3 + k1, var4 + l1, j2 | 4);
}
}
public void func_6089_e(World var1, int var2, int var3, int var4, int var5) {
if(var1.getBlockId(var2, var3, var4) == this.blockID) {
int var6 = var1.getBlockMetadata(var2, var3, var4);
if(var6 != 0 && var6 == var5 - 1) {
this.func_316_g(var1, var2, var3, var4);
}
}
}
public void func_316_g(World var1, int var2, int var3, int var4) {
if(this == null) {
if(this.field_663_c++ < 100) {
int var5 = var1.getBlockMaterial(var2, var3 - 1, var4).func_216_a() ? 16 : 0;
int var6 = var1.getBlockMetadata(var2, var3, var4);
if(var6 == 0) {
var6 = 1;
var1.setBlockMetadataWithNotify(var2, var3, var4, 1);
}
var5 = this.func_6090_f(var1, var2, var3 - 1, var4, var5);
var5 = this.func_6090_f(var1, var2, var3, var4 - 1, var5);
var5 = this.func_6090_f(var1, var2, var3, var4 + 1, var5);
var5 = this.func_6090_f(var1, var2 - 1, var3, var4, var5);
var5 = this.func_6090_f(var1, var2 + 1, var3, var4, var5);
int var7 = var5 - 1;
if(var7 < 10) {
var7 = 1;
}
if(var7 != var6) {
var1.setBlockMetadataWithNotify(var2, var3, var4, var7);
this.func_6089_e(var1, var2, var3 - 1, var4, var6);
this.func_6089_e(var1, var2, var3 + 1, var4, var6);
this.func_6089_e(var1, var2, var3, var4 - 1, var6);
this.func_6089_e(var1, var2, var3, var4 + 1, var6);
this.func_6089_e(var1, var2 - 1, var3, var4, var6);
this.func_6089_e(var1, var2 + 1, var3, var4, var6);
} }
} }
}
}
private int func_6090_f(World var1, int var2, int var3, int var4, int var5) {
int var6 = var1.getBlockId(var2, var3, var4);
if(var6 == Block.wood.blockID) {
return 16;
} else {
if(var6 == this.blockID) {
int var7 = var1.getBlockMetadata(var2, var3, var4);
if(var7 != 0 && var7 > var5) {
return var7;
}
}
return var5;
} }
} }
public void updateTick(World var1, int var2, int var3, int var4, Random var5) { public void updateTick(World var1, int var2, int var3, int var4, Random var5) {
if(this == null) { int l = var1.getBlockMetadata(var2, var3, var4);
int var6 = var1.getBlockMetadata(var2, var3, var4); if ((l & 4) != 0) {
if(var6 == 0) { byte byte0 = 4;
this.field_663_c = 0; int i1 = byte0 + 1;
this.func_316_g(var1, var2, var3, var4); byte byte1 = 32;
} else if(var6 == 1) { int j1 = byte1 * byte1;
this.func_6091_h(var1, var2, var3, var4); int k1 = byte1 / 2;
} else if(var5.nextInt(10) == 0) { if (field_464_c == null) {
this.func_316_g(var1, var2, var3, var4); field_464_c = new int[byte1 * byte1 * byte1];
} }
if (var1.checkChunksExist(var2 - i1, var3 - i1, var4 - i1, var2 + i1, var3 + i1, var4 + i1)) {
for (int l1 = -byte0; l1 <= byte0; l1++) {
for (int k2 = -byte0; k2 <= byte0; k2++) {
for (int i3 = -byte0; i3 <= byte0; i3++) {
int k3 = var1.getBlockId(var2 + l1, var3 + k2, var4 + i3);
if (k3 == Block.wood.blockID) {
field_464_c[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0;
continue;
}
if (k3 == Block.leaves.blockID) {
field_464_c[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2;
} else {
field_464_c[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1;
}
}
}
}
for (int i2 = 1; i2 <= 4; i2++) {
for (int l2 = -byte0; l2 <= byte0; l2++) {
for (int j3 = -byte0; j3 <= byte0; j3++) {
for (int l3 = -byte0; l3 <= byte0; l3++) {
if (field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1) {
continue;
}
if (field_464_c[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
field_464_c[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if (field_464_c[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
field_464_c[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if (field_464_c[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2) {
field_464_c[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2;
}
if (field_464_c[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2) {
field_464_c[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2;
}
if (field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2) {
field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2;
}
if (field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2) {
field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2;
}
}
}
}
}
}
int j2 = field_464_c[k1 * j1 + k1 * byte1 + k1];
if (j2 >= 0) {
var1.setBlockMetadataWithNotify(var2, var3, var4, l & -5);
} else {
func_6360_i(var1, var2, var3, var4);
}
} }
} }
private void func_6091_h(World var1, int var2, int var3, int var4) { private void func_6360_i(World var1, int var2, int var3, int var4) {
this.dropBlockAsItem(var1, var2, var3, var4, var1.getBlockMetadata(var2, var3, var4)); this.dropBlockAsItem(var1, var2, var3, var4, var1.getBlockMetadata(var2, var3, var4));
var1.setBlockWithNotify(var2, var3, var4, 0); var1.setBlockWithNotify(var2, var3, var4, 0);
} }
@ -106,11 +120,17 @@ public class BlockLeaves extends BlockLeavesBase {
return Block.sapling.blockID; return Block.sapling.blockID;
} }
public boolean allowsAttachment() { public boolean isOpaqueCube() {
return !this.graphicsLevel; return !this.graphicsLevel;
} }
public void setGraphicsLevel(boolean var1) {
this.graphicsLevel = var1;
this.blockIndexInTexture = this.baseIndexInPNG + (var1 ? 0 : 1);
}
public void onEntityWalking(World var1, int var2, int var3, int var4, Entity var5) { public void onEntityWalking(World var1, int var2, int var3, int var4, Entity var5) {
super.onEntityWalking(var1, var2, var3, var4, var5); super.onEntityWalking(var1, var2, var3, var4, var5);
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -4,11 +4,12 @@ import java.util.Random;
public class BlockLeaves extends BlockLeavesBase { public class BlockLeaves extends BlockLeavesBase {
private int baseIndexInPNG; private int baseIndexInPNG;
private int field_464_c = 0; int field_464_c[];
protected BlockLeaves(int var1, int var2) { protected BlockLeaves(int var1, int var2) {
super(var1, var2, Material.leaves, false); super(var1, var2, Material.leaves, false);
this.baseIndexInPNG = var2; this.baseIndexInPNG = var2;
setTickOnLoad(true);
} }
public int colorMultiplier(IBlockAccess var1, int var2, int var3, int var4) { public int colorMultiplier(IBlockAccess var1, int var2, int var3, int var4) {
@ -18,85 +19,101 @@ public class BlockLeaves extends BlockLeavesBase {
return ColorizerFoliage.func_4146_a(var5, var7); return ColorizerFoliage.func_4146_a(var5, var7);
} }
public void onNeighborBlockChange(World var1, int var2, int var3, int var4, int var5) { public void onBlockRemoval(World var1, int var2, int var3, int var4) {
if(this == null) { int l = 1;
this.field_464_c = 0; int i1 = l + 1;
this.func_308_h(var1, var2, var3, var4); if (var1.checkChunksExist(var2 - i1, var3 - i1, var4 - i1, var2 + i1, var3 + i1, var4 + i1)) {
super.onNeighborBlockChange(var1, var2, var3, var4, var5); for (int j1 = -l; j1 <= l; j1++) {
} for (int k1 = -l; k1 <= l; k1++) {
} for (int l1 = -l; l1 <= l; l1++) {
int i2 = var1.getBlockId(var2 + j1, var3 + k1, var4 + l1);
if (i2 == Block.leaves.blockID) {
int j2 = var1.getBlockMetadata(var2 + j1, var3 + k1, var4 + l1);
var1.setBlockMetadata(var2 + j1, var3 + k1, var4 + l1, j2 | 4);
}
}
public void func_6361_f(World var1, int var2, int var3, int var4, int var5) {
if(var1.getBlockId(var2, var3, var4) == this.blockID) {
int var6 = var1.getBlockMetadata(var2, var3, var4);
if(var6 != 0 && var6 == var5 - 1) {
this.func_308_h(var1, var2, var3, var4);
}
}
}
public void func_308_h(World var1, int var2, int var3, int var4) {
if(this == null) {
if(this.field_464_c++ < 100) {
int var5 = var1.getBlockMaterial(var2, var3 - 1, var4).func_878_a() ? 16 : 0;
int var6 = var1.getBlockMetadata(var2, var3, var4);
if(var6 == 0) {
var6 = 1;
var1.setBlockMetadataWithNotify(var2, var3, var4, 1);
}
var5 = this.func_6362_g(var1, var2, var3 - 1, var4, var5);
var5 = this.func_6362_g(var1, var2, var3, var4 - 1, var5);
var5 = this.func_6362_g(var1, var2, var3, var4 + 1, var5);
var5 = this.func_6362_g(var1, var2 - 1, var3, var4, var5);
var5 = this.func_6362_g(var1, var2 + 1, var3, var4, var5);
int var7 = var5 - 1;
if(var7 < 10) {
var7 = 1;
}
if(var7 != var6) {
var1.setBlockMetadataWithNotify(var2, var3, var4, var7);
this.func_6361_f(var1, var2, var3 - 1, var4, var6);
this.func_6361_f(var1, var2, var3 + 1, var4, var6);
this.func_6361_f(var1, var2, var3, var4 - 1, var6);
this.func_6361_f(var1, var2, var3, var4 + 1, var6);
this.func_6361_f(var1, var2 - 1, var3, var4, var6);
this.func_6361_f(var1, var2 + 1, var3, var4, var6);
} }
} }
}
}
private int func_6362_g(World var1, int var2, int var3, int var4, int var5) {
int var6 = var1.getBlockId(var2, var3, var4);
if(var6 == Block.wood.blockID) {
return 16;
} else {
if(var6 == this.blockID) {
int var7 = var1.getBlockMetadata(var2, var3, var4);
if(var7 != 0 && var7 > var5) {
return var7;
}
}
return var5;
} }
} }
public void updateTick(World var1, int var2, int var3, int var4, Random var5) { public void updateTick(World var1, int var2, int var3, int var4, Random var5) {
if(this == null) { if (var1.multiplayerWorld) {
int var6 = var1.getBlockMetadata(var2, var3, var4); return;
if(var6 == 0) { }
this.field_464_c = 0; int l = var1.getBlockMetadata(var2, var3, var4);
this.func_308_h(var1, var2, var3, var4); if ((l & 4) != 0) {
} else if(var6 == 1) { byte byte0 = 4;
this.func_6360_i(var1, var2, var3, var4); int i1 = byte0 + 1;
} else if(var5.nextInt(10) == 0) { byte byte1 = 32;
this.func_308_h(var1, var2, var3, var4); int j1 = byte1 * byte1;
int k1 = byte1 / 2;
if (field_464_c == null) {
field_464_c = new int[byte1 * byte1 * byte1];
} }
if (var1.checkChunksExist(var2 - i1, var3 - i1, var4 - i1, var2 + i1, var3 + i1, var4 + i1)) {
for (int l1 = -byte0; l1 <= byte0; l1++) {
for (int k2 = -byte0; k2 <= byte0; k2++) {
for (int i3 = -byte0; i3 <= byte0; i3++) {
int k3 = var1.getBlockId(var2 + l1, var3 + k2, var4 + i3);
if (k3 == Block.wood.blockID) {
field_464_c[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0;
continue;
}
if (k3 == Block.leaves.blockID) {
field_464_c[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2;
} else {
field_464_c[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1;
}
}
}
}
for (int i2 = 1; i2 <= 4; i2++) {
for (int l2 = -byte0; l2 <= byte0; l2++) {
for (int j3 = -byte0; j3 <= byte0; j3++) {
for (int l3 = -byte0; l3 <= byte0; l3++) {
if (field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1) {
continue;
}
if (field_464_c[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
field_464_c[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if (field_464_c[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
field_464_c[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if (field_464_c[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2) {
field_464_c[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2;
}
if (field_464_c[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2) {
field_464_c[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2;
}
if (field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2) {
field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2;
}
if (field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2) {
field_464_c[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2;
}
}
}
}
}
}
int j2 = field_464_c[k1 * j1 + k1 * byte1 + k1];
if (j2 >= 0) {
var1.setBlockMetadataWithNotify(var2, var3, var4, l & -5);
} else {
func_6360_i(var1, var2, var3, var4);
}
} }
} }
@ -126,3 +143,4 @@ public class BlockLeaves extends BlockLeavesBase {
super.onEntityWalking(var1, var2, var3, var4, var5); super.onEntityWalking(var1, var2, var3, var4, var5);
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long