Finished BlockLimbo.
There are extra texture files for limbo blocks that appear unused; I left them in case I'm wrong.
This commit is contained in:
parent
881ead8acf
commit
bdf7532b14
7 changed files with 37 additions and 47 deletions
|
@ -7,12 +7,9 @@ import com.zixiken.dimdoors.config.DDProperties;
|
|||
import com.zixiken.dimdoors.world.LimboDecay;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockLimbo extends Block {
|
||||
public static final String ID = "blockLimbo";
|
||||
|
@ -30,39 +27,12 @@ public class BlockLimbo extends Block {
|
|||
setUnlocalizedName(ID);
|
||||
setLightLevel(.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side)
|
||||
{
|
||||
return this.getIcon(side, blockAccess.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.blockIcon = iconRegister.registerIcon(DimDoors.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon 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)
|
||||
{
|
||||
decay.applySpreadDecay(world, x, y, z);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
|
||||
if(worldIn.provider.getDimensionId() == limboDimensionID) decay.applySpreadDecay(worldIn, pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ public class BlockRenderManager {
|
|||
register(DimDoors.blockDimWall, 2, "Altered");
|
||||
|
||||
register(DimDoors.blockDimWallPerm);
|
||||
register(DimDoors.blockLimbo);
|
||||
}
|
||||
|
||||
public static void addModelVariants() {
|
||||
|
@ -29,7 +30,7 @@ public class BlockRenderManager {
|
|||
private static void register(Block block) {
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
|
||||
.register(Item.getItemFromBlock(block), 0,
|
||||
new ModelResourceLocation(ID + ':' + block.getUnlocalizedName().substring(5)));
|
||||
new ModelResourceLocation(ID + ':' + block.getUnlocalizedName().substring(5), "inventory"));
|
||||
}
|
||||
|
||||
private static void register(Block block, int meta, String name) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.zixiken.dimdoors.DimDoors;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
@ -71,20 +72,20 @@ public class LimboDecay {
|
|||
* Checks the blocks orthogonally around a given location (presumably the location of an Unraveled Fabric block)
|
||||
* and applies Limbo decay to them. This gives the impression that decay spreads outward from Unraveled Fabric.
|
||||
*/
|
||||
public void applySpreadDecay(World world, int x, int y, int z)
|
||||
{
|
||||
public void applySpreadDecay(World world, BlockPos pos) {
|
||||
|
||||
//Check if we randomly apply decay spread or not. This can be used to moderate the frequency of
|
||||
//full spread decay checks, which can also shift its performance impact on the game.
|
||||
if (random.nextInt(MAX_DECAY_SPREAD_CHANCE) < DECAY_SPREAD_CHANCE)
|
||||
{
|
||||
//Apply decay to the blocks above, below, and on all four sides.
|
||||
//World.getBlockId() implements bounds checking, so we don't have to worry about reaching out of the world
|
||||
decayBlock(world, x - 1, y, z);
|
||||
decayBlock(world, x + 1, y, z);
|
||||
decayBlock(world, x, y, z - 1);
|
||||
decayBlock(world, x, y, z + 1);
|
||||
decayBlock(world, x, y - 1, z);
|
||||
decayBlock(world, x, y + 1, z);
|
||||
decayBlock(world, pos.west());
|
||||
decayBlock(world, pos.east());
|
||||
decayBlock(world, pos.north());
|
||||
decayBlock(world, pos.south());
|
||||
decayBlock(world, pos.south());
|
||||
decayBlock(world, pos.north());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,8 +140,7 @@ public class LimboDecay {
|
|||
/**
|
||||
* Checks if a block can be decayed and, if so, changes it to the next block ID along the decay sequence.
|
||||
*/
|
||||
private boolean decayBlock(World world, int x, int y, int z)
|
||||
{
|
||||
private boolean decayBlock(World world, BlockPos pos) {
|
||||
int index;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (canDecayBlock(block, world, x, y, z))
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"variants": {
|
||||
"normal": { "model": "dimdoors:blockLimbo" }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"parent": "block/cube_all",
|
||||
"textures": { "all": "dimdoors:blocks/blockLimbo" }
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"parent": "dimdoors:block/blockLimbo",
|
||||
"display": {
|
||||
"thirdperson": {
|
||||
"rotation": [ 10, -45, 170 ],
|
||||
"translation": [ 0, 1.5, -2.75 ],
|
||||
"scale": [ 0.375, 0.375, 0.375 ]
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 489 B |
Loading…
Reference in a new issue