d923e98942
Reimplemented Limbo Decay in two forms. Firstly, Unraveled Fabric accepts random ticks now and has a 50% chance of searching the 6 blocks against its faces for blocks to decay. The average time for this decay to occur is about 2 minutes and 17 seconds. The decay progresses a little slowly because of having to go through stages. We might want to consider decaying straight into Unraveled Fabric, or at least having fewer stages. This approach is better than randomly decaying isolated blocks because it looks like decay is spreading from the Unraveled Fabric. Secondly, every tick, we pick a random block from each active section in Limbo and turn it into Unraveled Fabric immediately. Note that a section is a 16x16x16 block cube inside a chunk. This is "fast decay", and it's meant to stop players from avoiding Limbo decay by building floating structures. It's not immediately obvious if you place a single block, but if you build a 5x5 block platform, the average time for some block to get converted drops to about 8 seconds, and it spreads from there. Most of the logic for this is in a new class: LimboDecay. It's worth studying whether this new implementation affects Minecraft's performance. I'm not completely sure whether that would be an issue. The frequency of either decay type can be decreased to improve performance.
62 lines
1.7 KiB
Java
62 lines
1.7 KiB
Java
package StevenDimDoors.mod_pocketDim.blocks;
|
|
|
|
import java.util.Random;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
import net.minecraft.util.Icon;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import StevenDimDoors.mod_pocketDim.LimboDecay;
|
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
public class BlockLimbo extends Block
|
|
{
|
|
private final int limboDimensionID;
|
|
|
|
public BlockLimbo(int i, int j, Material par2Material, int limboDimensionID)
|
|
{
|
|
super(i, Material.ground);
|
|
this.limboDimensionID = limboDimensionID;
|
|
this.setTickRandomly(true);
|
|
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
|
}
|
|
|
|
/**
|
|
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
@Override
|
|
public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, int side)
|
|
{
|
|
return this.getIcon(side, blockAccess.getBlockMetadata(x, y, z));
|
|
}
|
|
|
|
@Override
|
|
public void registerIcons(IconRegister iconRegister)
|
|
{
|
|
this.blockIcon = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
|
}
|
|
|
|
@Override
|
|
public Icon getIcon(int par1, int par2)
|
|
{
|
|
return this.blockIcon;
|
|
}
|
|
|
|
/**
|
|
* If the block is in Limbo, attempt to decay surrounding blocks upon receiving a random update tick.
|
|
*/
|
|
@Override
|
|
public void updateTick(World world, int x, int y, int z, Random random)
|
|
{
|
|
//Make sure this block is in Limbo
|
|
if (world.provider.dimensionId == limboDimensionID)
|
|
{
|
|
LimboDecay.ApplySpreadDecay(world, x, y, z);
|
|
}
|
|
}
|
|
}
|