This commit is contained in:
eaglercraft 2024-02-19 02:02:25 -08:00
commit 401ebe2324
1261 changed files with 12766 additions and 138431 deletions

View file

@ -8,6 +8,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
@ -88,6 +89,89 @@ public abstract class BlockLeaves extends BlockLeavesBase {
}
public void updateTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom var4) {
if (!world.isRemote) {
if (((Boolean) iblockstate.getValue(CHECK_DECAY)).booleanValue()
&& ((Boolean) iblockstate.getValue(DECAYABLE)).booleanValue()) {
byte b0 = 4;
int i = b0 + 1;
int j = blockpos.getX();
int k = blockpos.getY();
int l = blockpos.getZ();
byte b1 = 32;
int i1 = b1 * b1;
int j1 = b1 / 2;
if (this.surroundings == null) {
this.surroundings = new int[b1 * b1 * b1];
}
if (world.isAreaLoaded(new BlockPos(j - i, k - i, l - i), new BlockPos(j + i, k + i, l + i))) {
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int k1 = -b0; k1 <= b0; ++k1) {
for (int l1 = -b0; l1 <= b0; ++l1) {
for (int i2 = -b0; i2 <= b0; ++i2) {
Block block = world
.getBlockState(blockpos$mutableblockpos.func_181079_c(j + k1, k + l1, l + i2))
.getBlock();
if (block != Blocks.log && block != Blocks.log2) {
if (block.getMaterial() == Material.leaves) {
this.surroundings[(k1 + j1) * i1 + (l1 + j1) * b1 + i2 + j1] = -2;
} else {
this.surroundings[(k1 + j1) * i1 + (l1 + j1) * b1 + i2 + j1] = -1;
}
} else {
this.surroundings[(k1 + j1) * i1 + (l1 + j1) * b1 + i2 + j1] = 0;
}
}
}
}
for (int k2 = 1; k2 <= 4; ++k2) {
for (int l2 = -b0; l2 <= b0; ++l2) {
for (int i3 = -b0; i3 <= b0; ++i3) {
for (int j3 = -b0; j3 <= b0; ++j3) {
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + j3 + j1] == k2 - 1) {
if (this.surroundings[(l2 + j1 - 1) * i1 + (i3 + j1) * b1 + j3 + j1] == -2) {
this.surroundings[(l2 + j1 - 1) * i1 + (i3 + j1) * b1 + j3 + j1] = k2;
}
if (this.surroundings[(l2 + j1 + 1) * i1 + (i3 + j1) * b1 + j3 + j1] == -2) {
this.surroundings[(l2 + j1 + 1) * i1 + (i3 + j1) * b1 + j3 + j1] = k2;
}
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1 - 1) * b1 + j3 + j1] == -2) {
this.surroundings[(l2 + j1) * i1 + (i3 + j1 - 1) * b1 + j3 + j1] = k2;
}
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1 + 1) * b1 + j3 + j1] == -2) {
this.surroundings[(l2 + j1) * i1 + (i3 + j1 + 1) * b1 + j3 + j1] = k2;
}
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + (j3 + j1 - 1)] == -2) {
this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + (j3 + j1 - 1)] = k2;
}
if (this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + j3 + j1 + 1] == -2) {
this.surroundings[(l2 + j1) * i1 + (i3 + j1) * b1 + j3 + j1 + 1] = k2;
}
}
}
}
}
}
}
int j2 = this.surroundings[j1 * i1 + j1 * b1 + j1];
if (j2 >= 0) {
world.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(false)), 4);
} else {
this.destroy(world, blockpos);
}
}
}
}
public void randomDisplayTick(World world, BlockPos blockpos, IBlockState var3, EaglercraftRandom random) {
if (world.canLightningStrike(blockpos.up()) && !World.doesBlockHaveSolidTopSurface(world, blockpos.down())
&& random.nextInt(15) == 1) {
@ -118,6 +202,36 @@ public abstract class BlockLeaves extends BlockLeavesBase {
return Item.getItemFromBlock(Blocks.sapling);
}
/**+
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World world, BlockPos blockpos, IBlockState iblockstate, float var4, int i) {
if (!world.isRemote) {
int j = this.getSaplingDropChance(iblockstate);
if (i > 0) {
j -= 2 << i;
if (j < 10) {
j = 10;
}
}
if (world.rand.nextInt(j) == 0) {
Item item = this.getItemDropped(iblockstate, world.rand, i);
spawnAsEntity(world, blockpos, new ItemStack(item, 1, this.damageDropped(iblockstate)));
}
j = 200;
if (i > 0) {
j -= 10 << i;
if (j < 40) {
j = 40;
}
}
this.dropApple(world, blockpos, iblockstate, j);
}
}
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) {
}