block base class cleanup
This commit is contained in:
parent
346937ba4a
commit
828d215048
161 changed files with 1832 additions and 2044 deletions
|
@ -1029,7 +1029,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
else
|
||||
{
|
||||
float f = block.getPlayerRelativeBlockHardness(this.entity, this.entity.worldObj, this.removingPos) * (float)(i + 1);
|
||||
float f = block.getHardness(this.entity, this.entity.worldObj, this.removingPos) * (float)(i + 1);
|
||||
int j = (int)(f * 10.0F);
|
||||
|
||||
if (j != this.durabilityRemainingOnBlock)
|
||||
|
@ -1058,7 +1058,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
else
|
||||
{
|
||||
int k = this.curblockDamage - this.initialDamage;
|
||||
float f1 = block1.getPlayerRelativeBlockHardness(this.entity, this.entity.worldObj, this.removingPos) * (float)(k + 1);
|
||||
float f1 = block1.getHardness(this.entity, this.entity.worldObj, this.removingPos) * (float)(k + 1);
|
||||
int l = (int)(f1 * 10.0F);
|
||||
|
||||
if (l != this.durabilityRemainingOnBlock)
|
||||
|
@ -1097,8 +1097,8 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
if (block != Blocks.air)
|
||||
{
|
||||
block.onBlockClicked(this.entity.worldObj, pos, this.entity);
|
||||
f = block.getPlayerRelativeBlockHardness(this.entity, this.entity.worldObj, pos);
|
||||
block.onStartBreak(this.entity.worldObj, pos, this.entity);
|
||||
f = block.getHardness(this.entity, this.entity.worldObj, pos);
|
||||
}
|
||||
|
||||
if (block != Blocks.air && f >= 1.0F)
|
||||
|
@ -1125,7 +1125,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
if (block != Blocks.air)
|
||||
{
|
||||
float f = block.getPlayerRelativeBlockHardness(this.entity, this.entity.worldObj, pos) * (float)(i + 1);
|
||||
float f = block.getHardness(this.entity, this.entity.worldObj, pos) * (float)(i + 1);
|
||||
|
||||
if (f >= 0.7F)
|
||||
{
|
||||
|
@ -1153,12 +1153,12 @@ public class Player extends User implements Executor, IPlayer
|
|||
private boolean removeBlock(BlockPos pos)
|
||||
{
|
||||
State iblockstate = this.entity.worldObj.getState(pos);
|
||||
iblockstate.getBlock().onBlockHarvested(this.entity.worldObj, pos, iblockstate, this.entity);
|
||||
iblockstate.getBlock().preBroken(this.entity.worldObj, pos, iblockstate, this.entity);
|
||||
boolean flag = this.entity.worldObj.setBlockToAir(pos);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
iblockstate.getBlock().onBlockDestroyedByPlayer(this.entity.worldObj, pos, iblockstate);
|
||||
iblockstate.getBlock().onBroken(this.entity.worldObj, pos, iblockstate);
|
||||
}
|
||||
|
||||
return flag;
|
||||
|
@ -1199,7 +1199,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
if (flag1 && flag)
|
||||
{
|
||||
iblockstate.getBlock().harvestBlock(this.entity.worldObj, this.entity, pos, iblockstate, tileentity);
|
||||
iblockstate.getBlock().postBroken(this.entity.worldObj, this.entity, pos, iblockstate, tileentity);
|
||||
}
|
||||
// }
|
||||
|
||||
|
@ -1247,7 +1247,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
{
|
||||
State iblockstate = this.entity.worldObj.getState(pos);
|
||||
|
||||
if (iblockstate.getBlock().onBlockActivated(this.entity.worldObj, pos, iblockstate, this.entity, side, offsetX, offsetY, offsetZ))
|
||||
if (iblockstate.getBlock().onUse(this.entity.worldObj, pos, iblockstate, this.entity, side, offsetX, offsetY, offsetZ))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class NextTickListEntry implements Comparable<NextTickListEntry>
|
|||
else
|
||||
{
|
||||
NextTickListEntry nextticklistentry = (NextTickListEntry)p_equals_1_;
|
||||
return this.position.equals(nextticklistentry.position) && Block.isEqualTo(this.block, nextticklistentry.block);
|
||||
return this.position.equals(nextticklistentry.position) && this.block != null && this.block == nextticklistentry.block;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -528,7 +528,7 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
if(this.isRaining()) { // && this.getBiomeGenForCoords(blockpos1).canRain()) {
|
||||
this.getState(blockpos1).getBlock().fillWithRain(this, blockpos1);
|
||||
this.getState(blockpos1).getBlock().onRain(this, blockpos1);
|
||||
}
|
||||
|
||||
if(SVars.igniteChance > 0 && Vars.fire && !this.isRaining() &&
|
||||
|
@ -556,10 +556,12 @@ public final class WorldServer extends AWorldServer {
|
|||
State state = section.get(x, y, z);
|
||||
Block block = state.getBlock();
|
||||
|
||||
if(block.getTickRandomly()) {
|
||||
if(block.isTicked()) {
|
||||
++dtics;
|
||||
block.randomTick(this, new BlockPos(x + cx, y + section.getY(), z + cz), state,
|
||||
this.rand);
|
||||
BlockPos bpos = new BlockPos(x + cx, y + section.getY(), z + cz);
|
||||
block.tick(this, bpos, state, this.rand);
|
||||
if(block.getRadiation() > 0.0f && this.rand.chance(tics / 3))
|
||||
this.applyRadiation(bpos, state, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -571,6 +573,19 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
}
|
||||
|
||||
private void applyRadiation(BlockPos pos, State state, Block block) {
|
||||
float rad = block.getRadiation() * 8.0f * 0.25f;
|
||||
float r = ExtMath.clampf(rad * 2.0f, 0.0f, 25.0f);
|
||||
BoundingBox box = block.getCollisionBox(this, pos, state);
|
||||
if(box == null)
|
||||
box = new BoundingBox(pos, pos.add(1, 1, 1));
|
||||
for(EntityLiving entity : this.getEntitiesWithinAABB(EntityLiving.class, box.expand(r, r, r))) {
|
||||
float effect = rad * 2.0f * (r - ExtMath.sqrtf((float)entity.getDistanceSq(pos))) / r;
|
||||
if(effect > 0.0f)
|
||||
entity.addRadiation(effect);
|
||||
}
|
||||
}
|
||||
|
||||
private BlockPos adjustPosToNearbyEntity(BlockPos pos) {
|
||||
BlockPos blockpos = this.getPrecipitationHeight(pos);
|
||||
BoundingBox axisalignedbb = (new BoundingBox(blockpos, new BlockPos(blockpos.getX(), World.MAX_SIZE_Y, blockpos.getZ()))).expand(3.0D,
|
||||
|
@ -598,14 +613,14 @@ public final class WorldServer extends AWorldServer {
|
|||
|
||||
if(this.updatesForced > 0 && blockIn != Blocks.air) {
|
||||
--this.updatesForced;
|
||||
if(blockIn.requiresUpdates()) {
|
||||
if(blockIn.canTick()) {
|
||||
i = 8;
|
||||
|
||||
if(this.isAreaLoaded(nextticklistentry.position.add(-i, -i, -i), nextticklistentry.position.add(i, i, i))) {
|
||||
State iblockstate = this.getState(nextticklistentry.position);
|
||||
|
||||
if(iblockstate.getBlock() != Blocks.air && iblockstate.getBlock() == nextticklistentry.getBlock()) {
|
||||
iblockstate.getBlock().updateTick(this, nextticklistentry.position, iblockstate, this.rand);
|
||||
iblockstate.getBlock().tick(this, nextticklistentry.position, iblockstate, this.rand);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -701,8 +716,8 @@ public final class WorldServer extends AWorldServer {
|
|||
State iblockstate = this.getState(nextticklistentry1.position);
|
||||
|
||||
if(iblockstate.getBlock() != Blocks.air
|
||||
&& Block.isEqualTo(iblockstate.getBlock(), nextticklistentry1.getBlock())) {
|
||||
iblockstate.getBlock().updateTick(this, nextticklistentry1.position, iblockstate, this.rand);
|
||||
&& iblockstate.getBlock() == nextticklistentry1.getBlock()) {
|
||||
iblockstate.getBlock().tick(this, nextticklistentry1.position, iblockstate, this.rand);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -944,11 +959,11 @@ public final class WorldServer extends AWorldServer {
|
|||
if(fire && Vars.fire) {
|
||||
BlockPos pos = new BlockPos(entity);
|
||||
if(this.isAreaLoaded(pos, 10)) {
|
||||
if(this.getState(pos).getBlock() == Blocks.air && Blocks.fire.canPlaceBlockAt(this, pos))
|
||||
if(this.getState(pos).getBlock() == Blocks.air && Blocks.fire.canPlace(this, pos))
|
||||
this.setState(pos, Blocks.fire.getState());
|
||||
for(int n = 0; n < 4; n++) {
|
||||
BlockPos extra = pos.add(this.rand.range(-1, 1), this.rand.range(-1, 1), this.rand.range(-1, 1));
|
||||
if(this.getState(extra).getBlock() == Blocks.air && Blocks.fire.canPlaceBlockAt(this, extra))
|
||||
if(this.getState(extra).getBlock() == Blocks.air && Blocks.fire.canPlace(this, extra))
|
||||
this.setState(extra, Blocks.fire.getState());
|
||||
}
|
||||
}
|
||||
|
@ -1614,7 +1629,7 @@ public final class WorldServer extends AWorldServer {
|
|||
|
||||
public void forceBlockUpdateTick(Block blockType, BlockPos pos, Random random) {
|
||||
this.updatesForced = 128;
|
||||
blockType.updateTick(this, pos, this.getState(pos), random);
|
||||
blockType.tick(this, pos, this.getState(pos), random);
|
||||
this.updatesForced = 0;
|
||||
}
|
||||
|
||||
|
@ -2165,7 +2180,7 @@ public final class WorldServer extends AWorldServer {
|
|||
if(pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) {
|
||||
Block block = this.getState(pos).getBlock();
|
||||
|
||||
if(block == Blocks.air && Blocks.fire.canPlaceBlockAt(this, pos)) {
|
||||
if(block == Blocks.air && Blocks.fire.canPlace(this, pos)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class FeatureDoublePlant
|
|||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && (worldIn.dimension.hasSkyLight() || blockpos.getY() < 254) && this.type.canPlaceBlockAt(worldIn, blockpos))
|
||||
if (worldIn.isAirBlock(blockpos) && (worldIn.dimension.hasSkyLight() || blockpos.getY() < 254) && this.type.canPlace(worldIn, blockpos))
|
||||
{
|
||||
this.type.placeAt(worldIn, blockpos, 2);
|
||||
flag = true;
|
||||
|
|
|
@ -14,7 +14,7 @@ public class WorldGenMelon extends FeatureGenerator
|
|||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (Blocks.melon_block.canPlaceBlockAt(worldIn, blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass)
|
||||
if (Blocks.melon_block.canPlace(worldIn, blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.melon_block.getState(), 2);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class WorldGenPumpkin extends FeatureGenerator
|
|||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass && Blocks.pumpkin.canPlaceBlockAt(worldIn, blockpos))
|
||||
if (worldIn.isAirBlock(blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass && Blocks.pumpkin.canPlace(worldIn, blockpos))
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.pumpkin.getState(), 2);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public class WorldGenVines extends FeatureGenerator
|
|||
{
|
||||
for (Facing enumfacing : Facing.Plane.HORIZONTAL.facings())
|
||||
{
|
||||
if (Blocks.vine.canPlaceBlockOnSide(worldIn, position, enumfacing))
|
||||
if (Blocks.vine.canPlace(worldIn, position, enumfacing))
|
||||
{
|
||||
State iblockstate = Blocks.vine.getState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == Facing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == Facing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == Facing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == Facing.WEST));
|
||||
worldIn.setState(position, iblockstate, 2);
|
||||
|
|
|
@ -18,7 +18,7 @@ public class WorldGenWaterlily extends FeatureGenerator
|
|||
int k = position.getY() + rand.zrange(4) - rand.zrange(4);
|
||||
int l = position.getZ() + rand.zrange(8) - rand.zrange(8);
|
||||
|
||||
if (worldIn.isAirBlock(new BlockPos(j, k, l)) && Blocks.waterlily.canPlaceBlockAt(worldIn, new BlockPos(j, k, l)))
|
||||
if (worldIn.isAirBlock(new BlockPos(j, k, l)) && Blocks.waterlily.canPlace(worldIn, new BlockPos(j, k, l)))
|
||||
{
|
||||
worldIn.setState(new BlockPos(j, k, l), Blocks.waterlily.getState().withProperty(BlockLilyPad.FACING, Facing.randHorizontal(rand)), 2);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue