Fix light level detection for petrified creatures breaking out
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package electroblob.wizardry.tileentity;
|
||||
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
@@ -107,8 +108,7 @@ public class TileEntityStatue extends TileEntity implements ITickable {
|
||||
// Breaks the block at light levels of 7 or below, with a higher chance the lower the light level.
|
||||
// The chance is (8 - light level)/12, so at light 0 the chance is 3/4 and at light 7 the chance is 1/12.
|
||||
if(!this.world.isRemote && this.timer % 200 == 0 && this.timer > lifetime && !this.isIce && this.position == 1){
|
||||
// TESTME: There are about 10 different light-related methods in world now... is this the right one?
|
||||
if(this.world.getLight(pos) < this.world.rand.nextInt(12) - 3){
|
||||
if(WizardryUtilities.getLightLevel(world, pos) < this.world.rand.nextInt(12) - 3){
|
||||
// This is all that is needed because destroyBlock invokes the breakBlock function in
|
||||
// BlockPetrifiedStone
|
||||
// and that function handles all the spawning and stuff.
|
||||
|
||||
@@ -98,6 +98,26 @@ public final class WizardryUtilities {
|
||||
// SECTION Block/Entity/World Utilities
|
||||
// ===============================================================================================================
|
||||
|
||||
/**
|
||||
* Returns the actual light level, taking natural light (skylight) and artificial light (block light) into account.
|
||||
* This uses the same logic as mob spawning.
|
||||
*
|
||||
* @return The light level, from 0 (pitch darkness) to 15 (full daylight/at a torch).
|
||||
*/
|
||||
public static int getLightLevel(World world, BlockPos pos){
|
||||
|
||||
int i = world.getLightFromNeighbors(pos);
|
||||
|
||||
if(world.isThundering()){
|
||||
int j = world.getSkylightSubtracted();
|
||||
world.setSkylightSubtracted(10);
|
||||
i = world.getLightFromNeighbors(pos);
|
||||
world.setSkylightSubtracted(j);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the block at the given coordinates can be replaced by another one (works as if a block is being
|
||||
* placed by a player). True for air, liquids, vines, tall grass and snow layers but not for flowers, signs etc.
|
||||
|
||||
Reference in New Issue
Block a user