2015-12-28 00:38:12 +00:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
|
|
|
|
|
|
|
import WayofTime.bloodmagic.tile.TileSpectralBlock;
|
2016-01-11 23:07:06 +00:00
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2015-12-28 00:38:12 +00:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public class ItemSigilSuppression extends ItemSigilToggleable
|
|
|
|
{
|
|
|
|
public ItemSigilSuppression()
|
|
|
|
{
|
2015-12-28 00:38:12 +00:00
|
|
|
super("suppression", 400);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-30 20:34:40 +00:00
|
|
|
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
|
|
|
{
|
2015-12-28 00:38:12 +00:00
|
|
|
int x = (int) player.posX;
|
|
|
|
int y = (int) player.posY;
|
|
|
|
int z = (int) player.posZ;
|
|
|
|
final int radius = 5;
|
|
|
|
final int refresh = 100;
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
for (int i = -radius; i <= radius; i++)
|
|
|
|
{
|
|
|
|
for (int j = -radius; j <= radius; j++)
|
|
|
|
{
|
|
|
|
for (int k = -radius; k <= radius; k++)
|
|
|
|
{
|
|
|
|
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f))
|
|
|
|
{
|
2015-12-28 00:38:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockPos blockPos = new BlockPos(x + i, y + j, z + k);
|
|
|
|
Block block = world.getBlockState(blockPos).getBlock();
|
|
|
|
|
2016-01-11 23:07:06 +00:00
|
|
|
if (Utils.isBlockLiquid(block) && world.getTileEntity(blockPos) == null)
|
2015-12-28 00:38:12 +00:00
|
|
|
TileSpectralBlock.createSpectralBlock(world, blockPos, refresh);
|
2015-12-30 20:34:40 +00:00
|
|
|
else
|
|
|
|
{
|
2015-12-28 00:38:12 +00:00
|
|
|
TileEntity tile = world.getTileEntity(blockPos);
|
|
|
|
if (tile instanceof TileSpectralBlock)
|
|
|
|
((TileSpectralBlock) tile).resetDuration(refresh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-11 23:07:06 +00:00
|
|
|
|
2015-12-28 00:38:12 +00:00
|
|
|
}
|