Changed formatting to have bracing on a new line
This commit is contained in:
parent
e5eddd6c45
commit
e48eedb874
189 changed files with 6092 additions and 4041 deletions
|
@ -8,66 +8,78 @@ import net.minecraft.util.ITickable;
|
|||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffect;
|
||||
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
|
||||
|
||||
public class TileAlchemyArray extends TileInventory implements ITickable {
|
||||
public class TileAlchemyArray extends TileInventory implements ITickable
|
||||
{
|
||||
|
||||
public boolean isActive = false;
|
||||
public int activeCounter = 0;
|
||||
public boolean isActive = false;
|
||||
public int activeCounter = 0;
|
||||
|
||||
public TileAlchemyArray() {
|
||||
super(2, "alchemyArray");
|
||||
}
|
||||
public TileAlchemyArray()
|
||||
{
|
||||
super(2, "alchemyArray");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
this.isActive = tagCompound.getBoolean("isActive");
|
||||
this.activeCounter = tagCompound.getInteger("activeCounter");
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
this.isActive = tagCompound.getBoolean("isActive");
|
||||
this.activeCounter = tagCompound.getInteger("activeCounter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setBoolean("isActive", isActive);
|
||||
tagCompound.setInteger("activeCounter", activeCounter);
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setBoolean("isActive", isActive);
|
||||
tagCompound.setInteger("activeCounter", activeCounter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (isActive && attemptCraft()) {
|
||||
activeCounter++;
|
||||
} else {
|
||||
isActive = false;
|
||||
activeCounter = 0;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (isActive && attemptCraft())
|
||||
{
|
||||
activeCounter++;
|
||||
} else
|
||||
{
|
||||
isActive = false;
|
||||
activeCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean attemptCraft() {
|
||||
AlchemyArrayEffect effect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(this.getStackInSlot(0), this.getStackInSlot(1));
|
||||
if (effect != null) {
|
||||
isActive = true;
|
||||
public boolean attemptCraft()
|
||||
{
|
||||
AlchemyArrayEffect effect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(this.getStackInSlot(0), this.getStackInSlot(1));
|
||||
if (effect != null)
|
||||
{
|
||||
isActive = true;
|
||||
|
||||
if (effect.update(this, this.activeCounter)) {
|
||||
this.decrStackSize(0, 1);
|
||||
this.decrStackSize(1, 1);
|
||||
this.worldObj.setBlockToAir(getPos());
|
||||
}
|
||||
if (effect.update(this, this.activeCounter))
|
||||
{
|
||||
this.decrStackSize(0, 1);
|
||||
this.decrStackSize(1, 1);
|
||||
this.worldObj.setBlockToAir(getPos());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeToNBT(nbttagcompound);
|
||||
return new S35PacketUpdateTileEntity(pos, this.getBlockMetadata(), nbttagcompound);
|
||||
}
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeToNBT(nbttagcompound);
|
||||
return new S35PacketUpdateTileEntity(pos, this.getBlockMetadata(), nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
super.onDataPacket(net, packet);
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
super.onDataPacket(net, packet);
|
||||
readFromNBT(packet.getNbtCompound());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,196 +13,231 @@ import WayofTime.bloodmagic.altar.BloodAltar;
|
|||
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
|
||||
public class TileAltar extends TileInventory implements IBloodAltar, ITickable, IFluidTank, IFluidHandler {
|
||||
public class TileAltar extends TileInventory implements IBloodAltar, ITickable, IFluidTank, IFluidHandler
|
||||
{
|
||||
|
||||
private BloodAltar bloodAltar;
|
||||
|
||||
public TileAltar() {
|
||||
private BloodAltar bloodAltar;
|
||||
|
||||
public TileAltar()
|
||||
{
|
||||
super(1, "altar");
|
||||
this.bloodAltar = new BloodAltar(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
|
||||
NBTTagCompound altarTag = tagCompound.getCompoundTag("bloodAltar");
|
||||
|
||||
|
||||
this.bloodAltar.readFromNBT(altarTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
|
||||
NBTTagCompound altarTag = new NBTTagCompound();
|
||||
this.bloodAltar.writeToNBT(altarTag);
|
||||
|
||||
|
||||
tagCompound.setTag("bloodAltar", altarTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update()
|
||||
{
|
||||
bloodAltar.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sacrificialDaggerCall(int amount, boolean isSacrifice) {
|
||||
public void sacrificialDaggerCall(int amount, boolean isSacrifice)
|
||||
{
|
||||
bloodAltar.sacrificialDaggerCall(amount, isSacrifice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
||||
{
|
||||
return slot == 0;
|
||||
}
|
||||
|
||||
|
||||
// IFluidHandler
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||
{
|
||||
return new FluidTankInfo[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumFacing from, Fluid fluid) {
|
||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// IFluidTank
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid() {
|
||||
public FluidStack getFluid()
|
||||
{
|
||||
return bloodAltar.getFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount() {
|
||||
public int getFluidAmount()
|
||||
{
|
||||
return bloodAltar.getFluidAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo getInfo() {
|
||||
public FluidTankInfo getInfo()
|
||||
{
|
||||
return new FluidTankInfo(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
public int fill(FluidStack resource, boolean doFill)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, boolean doDrain) {
|
||||
public FluidStack drain(int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return bloodAltar.getCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentBlood() {
|
||||
return bloodAltar.getCurrentBlood();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAltarTier getTier() {
|
||||
return bloodAltar.getTier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProgress() {
|
||||
return bloodAltar.getProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSacrificeMultiplier() {
|
||||
return bloodAltar.getSacrificeMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSelfSacrificeMultiplier() {
|
||||
return bloodAltar.getSelfSacrificeMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getOrbMultiplier() {
|
||||
return bloodAltar.getOrbMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDislocationMultiplier() {
|
||||
return bloodAltar.getDislocationMultiplier();
|
||||
}
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
return bloodAltar.getCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getConsumptionMultiplier() {
|
||||
public int getCurrentBlood()
|
||||
{
|
||||
return bloodAltar.getCurrentBlood();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAltarTier getTier()
|
||||
{
|
||||
return bloodAltar.getTier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProgress()
|
||||
{
|
||||
return bloodAltar.getProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSacrificeMultiplier()
|
||||
{
|
||||
return bloodAltar.getSacrificeMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSelfSacrificeMultiplier()
|
||||
{
|
||||
return bloodAltar.getSelfSacrificeMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getOrbMultiplier()
|
||||
{
|
||||
return bloodAltar.getOrbMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDislocationMultiplier()
|
||||
{
|
||||
return bloodAltar.getDislocationMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getConsumptionMultiplier()
|
||||
{
|
||||
return bloodAltar.getConsumptionMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getConsumptionRate() {
|
||||
public float getConsumptionRate()
|
||||
{
|
||||
return bloodAltar.getConsumptionRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLiquidRequired() {
|
||||
public int getLiquidRequired()
|
||||
{
|
||||
return bloodAltar.getLiquidRequired();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferCapacity() {
|
||||
return bloodAltar.getBufferCapacity();
|
||||
}
|
||||
@Override
|
||||
public int getBufferCapacity()
|
||||
{
|
||||
return bloodAltar.getBufferCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startCycle() {
|
||||
bloodAltar.startCycle();
|
||||
}
|
||||
@Override
|
||||
public void startCycle()
|
||||
{
|
||||
bloodAltar.startCycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkTier() {
|
||||
bloodAltar.checkTier();
|
||||
}
|
||||
@Override
|
||||
public void checkTier()
|
||||
{
|
||||
bloodAltar.checkTier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestPauseAfterCrafting(int cooldown) {
|
||||
bloodAltar.requestPauseAfterCrafting(cooldown);
|
||||
}
|
||||
@Override
|
||||
public void requestPauseAfterCrafting(int cooldown)
|
||||
{
|
||||
bloodAltar.requestPauseAfterCrafting(cooldown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return bloodAltar.isActive();
|
||||
}
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
return bloodAltar.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fillMainTank(int amount) {
|
||||
return bloodAltar.fillMainTank(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(){
|
||||
bloodAltar.setActive();
|
||||
}
|
||||
@Override
|
||||
public int fillMainTank(int amount)
|
||||
{
|
||||
return bloodAltar.fillMainTank(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive()
|
||||
{
|
||||
bloodAltar.setActive();
|
||||
}
|
||||
}
|
|
@ -12,14 +12,17 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
@NoArgsConstructor
|
||||
public class TileImperfectRitualStone extends TileEntity implements IImperfectRitualStone {
|
||||
public class TileImperfectRitualStone extends TileEntity implements IImperfectRitualStone
|
||||
{
|
||||
|
||||
// IImperfectRitualStone
|
||||
|
||||
@Override
|
||||
public boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player) {
|
||||
public boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player)
|
||||
{
|
||||
|
||||
if (imperfectRitual != null && ImperfectRitualRegistry.ritualEnabled(imperfectRitual)) {
|
||||
if (imperfectRitual != null && ImperfectRitualRegistry.ritualEnabled(imperfectRitual))
|
||||
{
|
||||
NetworkHelper.getSoulNetwork(player, world).syphonAndDamage(imperfectRitual.getActivationCost());
|
||||
if (imperfectRitual.onActivate(this, player))
|
||||
if (imperfectRitual.isLightshow())
|
||||
|
@ -30,12 +33,14 @@ public class TileImperfectRitualStone extends TileEntity implements IImperfectRi
|
|||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
public World getWorld()
|
||||
{
|
||||
return super.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
public BlockPos getPos()
|
||||
{
|
||||
return super.getPos();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,22 +17,27 @@ import net.minecraft.util.IChatComponent;
|
|||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileInventory extends TileEntity implements IInventory {
|
||||
public class TileInventory extends TileEntity implements IInventory
|
||||
{
|
||||
|
||||
protected int[] syncedSlots = new int[0];
|
||||
private ItemStack[] inventory;
|
||||
private int size;
|
||||
private String name;
|
||||
|
||||
public TileInventory(int size, String name) {
|
||||
public TileInventory(int size, String name)
|
||||
{
|
||||
this.inventory = new ItemStack[size];
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private boolean isSyncedSlot(int slot) {
|
||||
for (int s : this.syncedSlots) {
|
||||
if (s == slot) {
|
||||
private boolean isSyncedSlot(int slot)
|
||||
{
|
||||
for (int s : this.syncedSlots)
|
||||
{
|
||||
if (s == slot)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -40,17 +45,21 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
NBTTagList tags = tagCompound.getTagList("Items", 10);
|
||||
inventory = new ItemStack[getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
if (!isSyncedSlot(i)) {
|
||||
for (int i = 0; i < tags.tagCount(); i++)
|
||||
{
|
||||
if (!isSyncedSlot(i))
|
||||
{
|
||||
NBTTagCompound data = tags.getCompoundTagAt(i);
|
||||
byte j = data.getByte("Slot");
|
||||
|
||||
if (j >= 0 && j < inventory.length) {
|
||||
if (j >= 0 && j < inventory.length)
|
||||
{
|
||||
inventory[j] = ItemStack.loadItemStackFromNBT(data);
|
||||
}
|
||||
}
|
||||
|
@ -58,12 +67,15 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
if ((inventory[i] != null) && !isSyncedSlot(i)) {
|
||||
for (int i = 0; i < inventory.length; i++)
|
||||
{
|
||||
if ((inventory[i] != null) && !isSyncedSlot(i))
|
||||
{
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("Slot", (byte) i);
|
||||
inventory[i].writeToNBT(data);
|
||||
|
@ -75,46 +87,55 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
|
||||
{
|
||||
super.onDataPacket(net, pkt);
|
||||
readFromNBT(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) {
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
|
||||
{
|
||||
return oldState.getBlock() != newState.getBlock();
|
||||
}
|
||||
|
||||
public void dropItems() {
|
||||
public void dropItems()
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(getWorld(), getPos(), this);
|
||||
}
|
||||
|
||||
// IInventory
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index) {
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return inventory[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count) {
|
||||
if (inventory[index] != null) {
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
if (inventory[index] != null)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
worldObj.markBlockForUpdate(this.pos);
|
||||
|
||||
if (inventory[index].stackSize <= count) {
|
||||
if (inventory[index].stackSize <= count)
|
||||
{
|
||||
ItemStack itemStack = inventory[index];
|
||||
inventory[index] = null;
|
||||
markDirty();
|
||||
|
@ -133,8 +154,10 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
public ItemStack removeStackFromSlot(int slot)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
ItemStack itemStack = inventory[slot];
|
||||
setInventorySlotContents(slot, null);
|
||||
return itemStack;
|
||||
|
@ -143,7 +166,8 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
inventory[slot] = stack;
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit())
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
|
@ -153,64 +177,76 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player) {
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
public int getField(int id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
public void clear()
|
||||
{
|
||||
this.inventory = new ItemStack[size];
|
||||
}
|
||||
|
||||
// IWorldNameable
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getName()
|
||||
{
|
||||
return StatCollector.translateToLocal("tile.BloodMagic." + name + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName() {
|
||||
public IChatComponent getDisplayName()
|
||||
{
|
||||
return new ChatComponentTranslation("tile.BloodMagic." + name + ".name");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,171 +29,197 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class TileMasterRitualStone extends TileEntity implements IMasterRitualStone, ITickable {
|
||||
public class TileMasterRitualStone extends TileEntity implements IMasterRitualStone, ITickable
|
||||
{
|
||||
|
||||
public static final int UPDATE_TIME = 20;
|
||||
public static final int UPDATE_TIME = 20;
|
||||
|
||||
private String owner;
|
||||
private boolean active;
|
||||
private int activeTime;
|
||||
private int cooldown;
|
||||
private Ritual currentRitual;
|
||||
@Setter
|
||||
private EnumFacing direction = EnumFacing.NORTH;
|
||||
private String owner;
|
||||
private boolean active;
|
||||
private int activeTime;
|
||||
private int cooldown;
|
||||
private Ritual currentRitual;
|
||||
@Setter
|
||||
private EnumFacing direction = EnumFacing.NORTH;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (getCurrentRitual() != null && isActive()) {
|
||||
if (activeTime % getCurrentRitual().getRefreshTime() == 0)
|
||||
performRitual(getWorld(), getPos());
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (getCurrentRitual() != null && isActive())
|
||||
{
|
||||
if (activeTime % getCurrentRitual().getRefreshTime() == 0)
|
||||
performRitual(getWorld(), getPos());
|
||||
|
||||
activeTime++;
|
||||
}
|
||||
}
|
||||
activeTime++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
owner = tag.getString(Constants.NBT.OWNER_UUID);
|
||||
currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
|
||||
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
|
||||
activeTime = tag.getInteger(Constants.NBT.RUNTIME);
|
||||
direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
owner = tag.getString(Constants.NBT.OWNER_UUID);
|
||||
currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
|
||||
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
|
||||
activeTime = tag.getInteger(Constants.NBT.RUNTIME);
|
||||
direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual());
|
||||
tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner());
|
||||
tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
||||
tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
|
||||
tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
|
||||
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual());
|
||||
tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner());
|
||||
tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
||||
tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
|
||||
tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
|
||||
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual) {
|
||||
@Override
|
||||
public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual)
|
||||
{
|
||||
|
||||
if (PlayerHelper.isFakePlayer(activator))
|
||||
return false;
|
||||
if (PlayerHelper.isFakePlayer(activator))
|
||||
return false;
|
||||
|
||||
activationCrystal = NBTHelper.checkNBT(activationCrystal);
|
||||
String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
activationCrystal = NBTHelper.checkNBT(activationCrystal);
|
||||
String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
||||
if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) {
|
||||
if (activationCrystal.getItem() instanceof ItemActivationCrystal) {
|
||||
int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
|
||||
if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) {
|
||||
if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null)
|
||||
{
|
||||
if (activationCrystal.getItem() instanceof ItemActivationCrystal)
|
||||
{
|
||||
int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
|
||||
if (RitualHelper.canCrystalActivate(ritual, crystalLevel))
|
||||
{
|
||||
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner, getWorld());
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner, getWorld());
|
||||
|
||||
if (network.getCurrentEssence() < ritual.getActivationCost()) {
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.weak");
|
||||
return false;
|
||||
}
|
||||
if (network.getCurrentEssence() < ritual.getActivationCost())
|
||||
{
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.weak");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentRitual != null)
|
||||
currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE);
|
||||
if (currentRitual != null)
|
||||
currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE);
|
||||
|
||||
RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, crystalOwner, ritual, activator, activationCrystal, crystalLevel);
|
||||
RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, crystalOwner, ritual, activator, activationCrystal, crystalLevel);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) {
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.prevent");
|
||||
return false;
|
||||
}
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
{
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.prevent");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ritual.activateRitual(this, activator)) {
|
||||
network.syphon(ritual.getActivationCost());
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.activate");
|
||||
this.active = true;
|
||||
this.owner = crystalOwner; // Set the owner of the
|
||||
// ritual to the crystal's
|
||||
// owner
|
||||
this.currentRitual = ritual;
|
||||
if (ritual.activateRitual(this, activator))
|
||||
{
|
||||
network.syphon(ritual.getActivationCost());
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.activate");
|
||||
this.active = true;
|
||||
this.owner = crystalOwner; // Set the owner of the
|
||||
// ritual to the crystal's
|
||||
// owner
|
||||
this.currentRitual = ritual;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.notValid");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.notValid");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performRitual(World world, BlockPos pos) {
|
||||
if (getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual()) && RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) {
|
||||
RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual());
|
||||
@Override
|
||||
public void performRitual(World world, BlockPos pos)
|
||||
{
|
||||
if (getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual()) && RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection()))
|
||||
{
|
||||
RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual());
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
return;
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
return;
|
||||
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(getOwner(), getWorld());
|
||||
network.syphonAndDamage(getCurrentRitual().getRefreshCost());
|
||||
getCurrentRitual().performRitual(this);
|
||||
}
|
||||
}
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(getOwner(), getWorld());
|
||||
network.syphonAndDamage(getCurrentRitual().getRefreshCost());
|
||||
getCurrentRitual().performRitual(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopRitual(Ritual.BreakType breakType) {
|
||||
if (getCurrentRitual() != null) {
|
||||
RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType);
|
||||
@Override
|
||||
public void stopRitual(Ritual.BreakType breakType)
|
||||
{
|
||||
if (getCurrentRitual() != null)
|
||||
{
|
||||
RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
return;
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
return;
|
||||
|
||||
getCurrentRitual().stopRitual(this, breakType);
|
||||
this.currentRitual = null;
|
||||
this.active = false;
|
||||
this.activeTime = 0;
|
||||
}
|
||||
}
|
||||
getCurrentRitual().stopRitual(this, breakType);
|
||||
this.currentRitual = null;
|
||||
this.active = false;
|
||||
this.activeTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
@Override
|
||||
public int getCooldown()
|
||||
{
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCooldown(int cooldown) {
|
||||
this.cooldown = cooldown;
|
||||
}
|
||||
@Override
|
||||
public void setCooldown(int cooldown)
|
||||
{
|
||||
this.cooldown = cooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getDirection() {
|
||||
return direction;
|
||||
}
|
||||
@Override
|
||||
public EnumFacing getDirection()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areTanksEmpty() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean areTanksEmpty()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunningTime() {
|
||||
return activeTime;
|
||||
}
|
||||
@Override
|
||||
public int getRunningTime()
|
||||
{
|
||||
return activeTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
@Override
|
||||
public String getOwner()
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return super.getWorld();
|
||||
}
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return super.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return super.getPos();
|
||||
}
|
||||
@Override
|
||||
public BlockPos getPos()
|
||||
{
|
||||
return super.getPos();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,35 +5,42 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ITickable;
|
||||
|
||||
public class TilePhantomBlock extends TileEntity implements ITickable {
|
||||
public class TilePhantomBlock extends TileEntity implements ITickable
|
||||
{
|
||||
|
||||
private int ticksRemaining;
|
||||
|
||||
public TilePhantomBlock() {
|
||||
public TilePhantomBlock()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update()
|
||||
{
|
||||
ticksRemaining--;
|
||||
|
||||
if (ticksRemaining <= 0) {
|
||||
if (ticksRemaining <= 0)
|
||||
{
|
||||
worldObj.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
public void setDuration(int duration)
|
||||
{
|
||||
ticksRemaining = duration;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
public class TilePlinth extends TileInventory {
|
||||
public class TilePlinth extends TileInventory
|
||||
{
|
||||
|
||||
public TilePlinth() {
|
||||
public TilePlinth()
|
||||
{
|
||||
super(1, "plinth");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,17 +11,20 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileSpectralBlock extends TileEntity implements ITickable {
|
||||
public class TileSpectralBlock extends TileEntity implements ITickable
|
||||
{
|
||||
|
||||
private int ticksRemaining;
|
||||
private String containedBlockName;
|
||||
private int containedBlockMeta;
|
||||
|
||||
public TileSpectralBlock() {
|
||||
public TileSpectralBlock()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
ticksRemaining = tagCompound.getInteger(Constants.NBT.TICKS_REMAINING);
|
||||
containedBlockName = tagCompound.getString(Constants.NBT.CONTAINED_BLOCK_NAME);
|
||||
|
@ -29,7 +32,8 @@ public class TileSpectralBlock extends TileEntity implements ITickable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setInteger(Constants.NBT.TICKS_REMAINING, ticksRemaining);
|
||||
tagCompound.setString(Constants.NBT.CONTAINED_BLOCK_NAME, containedBlockName);
|
||||
|
@ -37,28 +41,35 @@ public class TileSpectralBlock extends TileEntity implements ITickable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void update()
|
||||
{
|
||||
ticksRemaining--;
|
||||
|
||||
if (ticksRemaining <= 0) {
|
||||
if (ticksRemaining <= 0)
|
||||
{
|
||||
returnContainedBlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void setContainedBlockInfo(IBlockState blockState) {
|
||||
private void setContainedBlockInfo(IBlockState blockState)
|
||||
{
|
||||
containedBlockName = blockState.getBlock().getUnlocalizedName().substring(5);
|
||||
containedBlockMeta = blockState.getBlock().getMetaFromState(blockState);
|
||||
}
|
||||
|
||||
private void setDuration(int duration) {
|
||||
private void setDuration(int duration)
|
||||
{
|
||||
ticksRemaining = duration;
|
||||
}
|
||||
|
||||
public void resetDuration(int reset) {
|
||||
if (ticksRemaining < reset) ticksRemaining = reset;
|
||||
public void resetDuration(int reset)
|
||||
{
|
||||
if (ticksRemaining < reset)
|
||||
ticksRemaining = reset;
|
||||
}
|
||||
|
||||
public void returnContainedBlock() {
|
||||
public void returnContainedBlock()
|
||||
{
|
||||
Block block = null;
|
||||
|
||||
if (!Strings.isNullOrEmpty(containedBlockName))
|
||||
|
@ -68,8 +79,10 @@ public class TileSpectralBlock extends TileEntity implements ITickable {
|
|||
worldObj.markBlockForUpdate(pos);
|
||||
}
|
||||
|
||||
public static void createSpectralBlock(World world, BlockPos blockPos, int duration) {
|
||||
if (world.isAirBlock(blockPos)) return;
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue