Сам то что написалFanKar написал(а):Ясно всё с тобой.
Думаешь я особо долго думал? Нет, вот и всё.svk написал(а):Сам то что написалFanKar написал(а):Ясно всё с тобой.
@Override
public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
switch(side) {
case 0: --y;break;
case 1: ++y;break;
case 2: --z;break;
case 3: ++z;break;
case 4: --x;break;
case 5: ++x;break;
}
if (world.isAirBlock(x, y, z)) {
Block block = Blocks.furnace;//Наш используемый блок
Item item = Item.getItemFromBlock(block);
if (item instanceof ItemBlock) {
ItemBlock ib = (ItemBlock)item;
ib.onItemUse(is, player, world, x, y, z, side, hitX, hitY, hitZ);
//В методе onItemUse уже встроено отнимания количесва стака (т.е. --is.stackSize;)
return true;
}
}
return false;
}
@Override
public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
int
x2 = x,
y2 = y,
z2 = z;
switch(side) {
case 0: --y2;break;
case 1: ++y2;break;
case 2: --z2;break;
case 3: ++z2;break;
case 4: --x2;break;
case 5: ++x2;break;
}
if (world.isAirBlock(x2, y2, z2)) {
int blockID = Block.furnaceIdle.blockID;//Наш используемый ID блока
Item item = Item.itemsList[blockID];
if (item != null && item instanceof ItemBlock) {
ItemBlock ib = (ItemBlock)item;
ib.onItemUse(is, player, world, x, y, z, side, hitX, hitY, hitZ);
//В методе onItemUse уже встроено отнимания количесва стака (т.е. --is.stackSize;)
return true;
}
}
return false;
}
@Override
public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
switch(side) {
case 0: --y;break;
case 1: ++y;break;
case 2: --z;break;
case 3: ++z;break;
case 4: --x;break;
case 5: ++x;break;
}
if (world.isAirBlock(x, y, z)) {
world.setBlock(x, y, z, Block.blockDiamond.blockID);
is.stackSize=0;
return true;
}
return false;
}
public ItemStack onEaten(ItemStack is, World world, EntityPlayer player) {
MovingObjectPosition mop = block(player, 1.0F, 5.0D, true);
if (mop != null && mop.typeOfHit == EnumMovingObjectType.TILE) {
int
x = mop.blockX,
y = mop.blockY,
z = mop.blockZ;
switch(mop.sideHit) {
case 0:--y;break;
case 1:++y;break;
case 2:--z;break;
case 3:++z;break;
case 4:--x;break;
case 5:++x;break;
}
if (!player.canPlayerEdit(x, y, z, mop.sideHit, is)) return is;
if (world.isAirBlock(x, y, z)) {
int blockID = Block.furnaceIdle.blockID;//Наш используемый блок
Item item = Item.itemsList[blockID];
if (item != null && item instanceof ItemBlock) {
ItemBlock ib = (ItemBlock)item;
ib.onItemUse(is, player, world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit,
(float)mop.hitVec.xCoord - (float)x,
(float)mop.hitVec.yCoord - (float)y,
(float)mop.hitVec.zCoord - (float)z);
//В методе onItemUse уже встроено отнимания количесва стака (т.е. --is.stackSize;)
}
}
}
return is;
}
public int getMaxItemUseDuration(ItemStack is) {
return 20 * 3;//Сколько тиков будет использоваться, после использования типа поставиться.
}
public EnumAction getItemUseAction(ItemStack is) {
return EnumAction.bow;//Просто для вида
}
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) {
if (is != null && is.getItem() == this) {
player.setItemInUse(is, this.getMaxItemUseDuration(is));
}
return is;
}
public static MovingObjectPosition block(EntityLivingBase entity_base, float fasc, double dist, boolean interact) {
Vec3 vec3 = Vec3.createVectorHelper(entity_base.posX, entity_base.posY + entity_base.getEyeHeight(), entity_base.posZ);
Vec3 vec31 = entity_base.getLook(fasc);
Vec3 vec32 = vec3.addVector(vec31.xCoord * dist, vec31.yCoord * dist, vec31.zCoord * dist);
MovingObjectPosition mop = entity_base.worldObj.clip(vec3, vec32, interact);
return mop;
}