2015-12-27 19:38:12 -05:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
|
|
|
|
|
|
|
import WayofTime.bloodmagic.registry.ModBlocks;
|
|
|
|
import WayofTime.bloodmagic.tile.TilePhantomBlock;
|
|
|
|
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 15:34:40 -05:00
|
|
|
public class ItemSigilPhantomBridge extends ItemSigilToggleable
|
|
|
|
{
|
|
|
|
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--;
|
|
|
|
|
|
|
|
if (world.isRemote)
|
|
|
|
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);
|
|
|
|
Block block = world.getBlockState(blockPos).getBlock();
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (world.isAirBlock(blockPos))
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
world.setBlockState(blockPos, ModBlocks.phantomBlock.getDefaultState(), 3);
|
|
|
|
|
|
|
|
TileEntity tile = world.getTileEntity(blockPos);
|
2015-12-30 15:34:40 -05:00
|
|
|
if (tile instanceof TilePhantomBlock)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
((TilePhantomBlock) tile).setDuration(100);
|
|
|
|
}
|
2015-12-30 15:34:40 -05:00
|
|
|
} else if (block == ModBlocks.phantomBlock)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
TileEntity tile = world.getTileEntity(blockPos);
|
2015-12-30 15:34:40 -05:00
|
|
|
if (tile instanceof TilePhantomBlock)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
((TilePhantomBlock) tile).setDuration(100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|