2015-12-27 19:38:12 -05:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
|
|
|
|
2016-11-11 16:57:50 -08:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.tile.TileSpectralBlock;
|
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2016-03-18 15:38:26 -04:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-12-27 19:38:12 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-03-18 15:38:26 -04:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-12-27 19:38:12 -05:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public class ItemSigilSuppression extends ItemSigilToggleableBase {
|
|
|
|
public ItemSigilSuppression() {
|
2015-12-27 19:38:12 -05:00
|
|
|
super("suppression", 400);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
2016-11-11 16:57:50 -08:00
|
|
|
if (PlayerHelper.isFakePlayer(player))
|
|
|
|
return;
|
|
|
|
|
2015-12-27 19:38:12 -05:00
|
|
|
int x = (int) player.posX;
|
|
|
|
int y = (int) player.posY;
|
|
|
|
int z = (int) player.posZ;
|
|
|
|
final int radius = 5;
|
|
|
|
final int refresh = 100;
|
|
|
|
|
2017-08-15 21:30:48 -07: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-27 19:38:12 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockPos blockPos = new BlockPos(x + i, y + j, z + k);
|
2016-03-18 15:38:26 -04:00
|
|
|
IBlockState state = world.getBlockState(blockPos);
|
2015-12-27 19:38:12 -05:00
|
|
|
|
2017-01-02 00:10:28 -08:00
|
|
|
if (Utils.isBlockLiquid(state) && world.getTileEntity(blockPos) == null)
|
2017-08-15 21:30:48 -07:00
|
|
|
TileSpectralBlock.createSpectralBlock(world, blockPos, refresh);
|
|
|
|
else {
|
2015-12-27 19:38:12 -05:00
|
|
|
TileEntity tile = world.getTileEntity(blockPos);
|
|
|
|
if (tile instanceof TileSpectralBlock)
|
|
|
|
((TileSpectralBlock) tile).resetDuration(refresh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|