2015-12-27 19:38:12 -05:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
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;
|
2016-03-18 15:38:26 -04:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
|
|
|
import WayofTime.bloodmagic.registry.ModBlocks;
|
2015-12-27 19:38:12 -05:00
|
|
|
|
2016-03-22 21:10:05 -04:00
|
|
|
public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
|
|
|
public ItemSigilPhantomBridge()
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
super("phantomBridge", 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-30 15:34:40 -05:00
|
|
|
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
if (!player.onGround && !player.isSneaking())
|
|
|
|
return;
|
|
|
|
|
|
|
|
int range = 2;
|
|
|
|
int verticalOffset = -1;
|
|
|
|
|
|
|
|
if (player.isSneaking())
|
|
|
|
verticalOffset--;
|
|
|
|
|
|
|
|
int posX = (int) Math.round(player.posX - 0.5f);
|
|
|
|
int posY = (int) player.posY;
|
|
|
|
int posZ = (int) Math.round(player.posZ - 0.5f);
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
for (int ix = posX - range; ix <= posX + range; ix++)
|
|
|
|
{
|
|
|
|
for (int iz = posZ - range; iz <= posZ + range; iz++)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
BlockPos blockPos = new BlockPos(ix, posY + verticalOffset, iz);
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (world.isAirBlock(blockPos))
|
2016-01-11 13:36:07 -08:00
|
|
|
world.setBlockState(blockPos, ModBlocks.phantomBlock.getDefaultState());
|
2015-12-27 19:38:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|