use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.
the class TileEntityGrill method update.
@Override
public void update() {
if (!world.isRemote) {
if (fire) {
if (inventory[0] != null) {
RecipeData dataLeft = RecipeAPI.getGrillRecipeFromInput(inventory[0]);
if (dataLeft != null) {
if (leftCookTime >= COOK_DURATION) {
if (!leftCooked) {
if (flippedLeft) {
inventory[0] = dataLeft.getOutput().copy();
}
leftCooked = true;
TileEntityUtil.markBlockForUpdate(world, pos);
leftSoundLoop = 0;
}
if (leftSoundLoop % 20 == 0) {
world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 0.5F);
}
} else {
if (leftSoundLoop % 20 == 0) {
if (!leftCooked) {
if (flippedLeft && leftCookTime >= 20) {
world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 1.0F);
} else if (!flippedLeft) {
world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
}
leftCookTime++;
}
leftSoundLoop++;
}
}
if (inventory[1] != null) {
RecipeData dataRight = RecipeAPI.getGrillRecipeFromInput(inventory[1]);
if (dataRight != null) {
if (rightCookTime >= COOK_DURATION) {
if (!rightCooked) {
if (flippedRight) {
inventory[1] = dataRight.getOutput().copy();
}
rightCooked = true;
TileEntityUtil.markBlockForUpdate(world, pos);
rightSoundLoop = 0;
}
if (rightSoundLoop % 20 == 0) {
world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 0.5F);
}
} else {
if (rightSoundLoop % 20 == 0) {
if (!rightCooked) {
if (flippedRight && rightCookTime >= 20) {
world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 1.0F);
} else if (!flippedRight) {
world.playSound(null, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, FurnitureSounds.sizzle, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
}
rightCookTime++;
}
rightSoundLoop++;
}
}
coalTick++;
if (coalTick >= COAL_DURATION) {
coalTick = 0;
coal--;
if (coal <= 0) {
fire = false;
}
TileEntityUtil.markBlockForUpdate(world, pos);
}
}
} else {
if (flippedLeft && leftFlipCount < FLIP_DURATION) {
leftFlipCount++;
}
if (flippedRight && rightFlipCount < FLIP_DURATION) {
rightFlipCount++;
}
}
}
use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.
the class TileEntityBlender method hasValidIngredients.
public boolean hasValidIngredients() {
RecipeData data = RecipeAPI.getBlenderRecipeDataFromIngredients(ingredients);
if (data == null) {
return false;
}
drinkName = data.getDrinkName();
healAmount = data.getHealAmount();
currentRed = data.getRed();
currentGreen = data.getGreen();
currentBlue = data.getBlue();
return true;
}
use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.
the class TileEntityChoppingBoard method chopFood.
public boolean chopFood() {
if (food != null) {
RecipeData data = RecipeAPI.getChoppingBoardRecipeFromInput(food);
if (data != null) {
if (!world.isRemote) {
EntityItem entityItem = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.2, pos.getZ() + 0.5, data.getOutput().copy());
world.spawnEntity(entityItem);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), FurnitureSounds.knife_chop, SoundCategory.BLOCKS, 0.75F, 1.0F);
}
setFood(null);
TileEntityUtil.markBlockForUpdate(world, pos);
return true;
}
}
return false;
}
use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.
the class BlockToaster method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack heldItem = playerIn.getHeldItem(hand);
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof TileEntityToaster) {
TileEntityToaster tileEntityToaster = (TileEntityToaster) tileEntity;
if (!heldItem.isEmpty() && !tileEntityToaster.isToasting()) {
RecipeData data = RecipeAPI.getToasterRecipeFromInput(heldItem);
if (data != null) {
if (tileEntityToaster.addSlice(new ItemStack(heldItem.getItem(), 1))) {
TileEntityUtil.markBlockForUpdate(worldIn, pos);
heldItem.shrink(1);
}
} else {
tileEntityToaster.removeSlice();
}
} else {
if (playerIn.isSneaking()) {
if (!tileEntityToaster.isToasting()) {
tileEntityToaster.startToasting();
worldIn.updateComparatorOutputLevel(pos, this);
if (!worldIn.isRemote) {
worldIn.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, FurnitureSounds.toaster_down, SoundCategory.BLOCKS, 0.75F, 1.0F, false);
}
}
} else if (!tileEntityToaster.isToasting()) {
tileEntityToaster.removeSlice();
}
}
}
return true;
}
use of com.mrcrayfish.furniture.api.RecipeData in project MrCrayfishFurnitureMod by MrCrayfish.
the class ContainerWashingMachine method transferStackInSlot.
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotNum) {
ItemStack itemCopy = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(slotNum);
if (slot != null && slot.getHasStack()) {
ItemStack item = slot.getStack();
itemCopy = item.copy();
if (slotNum < 5) {
if (!this.mergeItemStack(item, 5, this.inventorySlots.size(), false)) {
return ItemStack.EMPTY;
}
} else if (slotNum > 4) {
RecipeData data = RecipeAPI.getWashingMachineRecipeFromInput(item);
if (data != null && (itemCopy.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN) || itemCopy.getItem() == Items.SKULL || itemCopy.getItem().getEquipmentSlot(itemCopy) != null || (itemCopy.getItem() instanceof ItemArmor && ((ItemArmor) itemCopy.getItem()).armorType != null) || EntityLiving.getSlotForItemStack(itemCopy) != EntityEquipmentSlot.HEAD)) {
if (!this.mergeItemStack(item, 0, 4, true)) {
return ItemStack.EMPTY;
} else if (slotNum > 4 && slotNum < this.inventorySlots.size() - 9) {
if (!this.mergeItemStack(item, this.inventorySlots.size() - 9, this.inventorySlots.size(), false)) {
return ItemStack.EMPTY;
}
} else if (slotNum >= this.inventorySlots.size() - 9 && slotNum < this.inventorySlots.size()) {
if (!this.mergeItemStack(item, 5, this.inventorySlots.size() - 9, false)) {
return ItemStack.EMPTY;
}
}
} else if (item.getItem() == FurnitureItems.SOAPY_WATER | item.getItem() == FurnitureItems.SUPER_SOAPY_WATER) {
if (!this.mergeItemStack(item, 4, 5, false)) {
return ItemStack.EMPTY;
}
} else if (slotNum > 4 && slotNum < this.inventorySlots.size() - 9) {
if (!this.mergeItemStack(item, this.inventorySlots.size() - 9, this.inventorySlots.size(), false)) {
return ItemStack.EMPTY;
}
} else if (slotNum >= this.inventorySlots.size() - 9 && slotNum < this.inventorySlots.size()) {
if (!this.mergeItemStack(item, 5, this.inventorySlots.size() - 9, false)) {
return ItemStack.EMPTY;
}
}
} else if (!this.mergeItemStack(item, 0, 9, false)) {
return ItemStack.EMPTY;
}
if (item.getCount() == 0) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return itemCopy;
}
Aggregations