Basic sigils implementation
This commit is contained in:
parent
ae85224003
commit
5dff08380d
61 changed files with 1394 additions and 106 deletions
|
@ -156,6 +156,21 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable,
|
|||
return bloodAltar.getDislocationMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getConsumptionMultiplier() {
|
||||
return bloodAltar.getConsumptionMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getConsumptionRate() {
|
||||
return bloodAltar.getConsumptionRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLiquidRequired() {
|
||||
return bloodAltar.getLiquidRequired();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferCapacity() {
|
||||
return bloodAltar.getBufferCapacity();
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ITickable;
|
||||
|
||||
public class TilePhantomBlock extends TileEntity implements ITickable {
|
||||
|
||||
private int ticksRemaining;
|
||||
|
||||
public TilePhantomBlock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
ticksRemaining--;
|
||||
|
||||
if (ticksRemaining <= 0) {
|
||||
worldObj.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
ticksRemaining = duration;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileSpectralBlock extends TileEntity implements ITickable {
|
||||
|
||||
private int ticksRemaining;
|
||||
private String containedBlockName;
|
||||
private int containedBlockMeta;
|
||||
|
||||
public TileSpectralBlock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
|
||||
containedBlockName = tagCompound.getString(Constants.NBT.CONTAINED_BLOCK_NAME);
|
||||
containedBlockMeta = tagCompound.getInteger(Constants.NBT.CONTAINED_BLOCK_META);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining);
|
||||
tagCompound.setString(Constants.NBT.CONTAINED_BLOCK_NAME, containedBlockName);
|
||||
tagCompound.setInteger(Constants.NBT.CONTAINED_BLOCK_META, containedBlockMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
ticksRemaining--;
|
||||
|
||||
if (ticksRemaining <= 0) {
|
||||
returnContainedBlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void setContainedBlockInfo(IBlockState blockState) {
|
||||
containedBlockName = blockState.getBlock().getUnlocalizedName().substring(5);
|
||||
containedBlockMeta = blockState.getBlock().getMetaFromState(blockState);
|
||||
}
|
||||
|
||||
private void setDuration(int duration) {
|
||||
ticksRemaining = duration;
|
||||
}
|
||||
|
||||
public void resetDuration(int reset) {
|
||||
if (ticksRemaining < reset) ticksRemaining = reset;
|
||||
}
|
||||
|
||||
public void returnContainedBlock() {
|
||||
Block block = null;
|
||||
|
||||
if (!Strings.isNullOrEmpty(containedBlockName))
|
||||
block = Block.getBlockFromName(containedBlockName);
|
||||
|
||||
if (block != null && worldObj.setBlockState(pos, block.getStateFromMeta(containedBlockMeta)))
|
||||
worldObj.markBlockForUpdate(pos);
|
||||
}
|
||||
|
||||
public static void createSpectralBlock(World world, BlockPos blockPos, int duration) {
|
||||
if (world.isAirBlock(blockPos)) return;
|
||||
IBlockState cachedState = world.getBlockState(blockPos);
|
||||
world.setBlockState(blockPos, ModBlocks.spectralBlock.getDefaultState());
|
||||
TileSpectralBlock tile = (TileSpectralBlock) world.getTileEntity(blockPos);
|
||||
tile.setContainedBlockInfo(cachedState);
|
||||
tile.setDuration(duration);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue