public NeoPotInFirepitRenderer(ICoreClientAPI capi, ItemStack stack, BlockPos pos, bool isInOutputSlot) { this.capi = capi; this.stack = stack; this.pos = pos; this.isInOutputSlot = isInOutputSlot; BlockCookedContainer potBlock = capi.World.GetBlock(stack.Collectible.CodeWithVariant("type", "cooked")) as BlockCookedContainer; if (isInOutputSlot) { MealMeshCacheFix meshcache = capi.ModLoader.GetModSystem <MealMeshCacheFix>(); MeshData potMesh = meshcache.CreateMealMesh(potBlock.Shape, potBlock.GetCookingRecipe(capi.World, stack), potBlock.GetContents(capi.World, stack), potBlock, new Vec3f(0, 2.5f / 16f, 0)); potRef = capi.Render.UploadMesh(potMesh); } else { MeshData potMesh; capi.Tesselator.TesselateShape(potBlock, capi.Assets.TryGet("shapes/block/clay/pot-opened-empty.json").ToObject <Shape>(), out potMesh); potRef = capi.Render.UploadMesh(potMesh); MeshData lidMesh; capi.Tesselator.TesselateShape(potBlock, capi.Assets.TryGet("shapes/block/clay/pot-part-lid.json").ToObject <Shape>(), out lidMesh); lidRef = capi.Render.UploadMesh(lidMesh); } }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { int stage = Stage; ItemStack stack = byPlayer.InventoryManager.ActiveHotbarSlot?.Itemstack; if (stage == 5) { BlockEntityCampFire bef = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityCampFire; if (bef != null && stack?.Block != null && stack.Block.HasBehavior <BlockBehaviorCanIgnite>()) { return(false); } if (bef != null && stack != null && byPlayer.Entity.Controls.Sneak) { if (stack.Collectible.CombustibleProps != null && stack.Collectible.CombustibleProps.MeltingPoint > 0) { ItemStackMoveOperation op = new ItemStackMoveOperation(world, EnumMouseButton.Button1, 0, EnumMergePriority.DirectMerge, 1); byPlayer.InventoryManager.ActiveHotbarSlot.TryPutInto(bef.inputSlot, ref op); if (op.MovedQuantity > 0) { (byPlayer as IClientPlayer)?.TriggerFpAnimation(EnumHandInteract.HeldItemInteract); return(true); } } if (stack.Collectible.CombustibleProps != null && stack.Collectible.CombustibleProps.BurnTemperature > 0) { ItemStackMoveOperation op = new ItemStackMoveOperation(world, EnumMouseButton.Button1, 0, EnumMergePriority.DirectMerge, 1); byPlayer.InventoryManager.ActiveHotbarSlot.TryPutInto(bef.fuelSlot, ref op); if (op.MovedQuantity > 0) { (byPlayer as IClientPlayer)?.TriggerFpAnimation(EnumHandInteract.HeldItemInteract); return(true); } } } if (stack?.Collectible.Attributes?.IsTrue("mealContainer") == true) { ItemSlot potSlot = null; if (bef?.inputStack?.Collectible is BlockCookedContainer) { potSlot = bef.inputSlot; } if (bef?.outputStack?.Collectible is BlockCookedContainer) { potSlot = bef.outputSlot; } if (potSlot != null) { BlockCookedContainer blockPot = potSlot.Itemstack.Collectible as BlockCookedContainer; ItemSlot targetSlot = byPlayer.InventoryManager.ActiveHotbarSlot; if (byPlayer.InventoryManager.ActiveHotbarSlot.StackSize > 1) { targetSlot = new DummySlot(targetSlot.TakeOut(1)); byPlayer.InventoryManager.ActiveHotbarSlot.MarkDirty(); blockPot.ServeIntoBowlStack(targetSlot, potSlot, world); if (!byPlayer.InventoryManager.TryGiveItemstack(targetSlot.Itemstack, true)) { world.SpawnItemEntity(targetSlot.Itemstack, byPlayer.Entity.ServerPos.XYZ); } } else { blockPot.ServeIntoBowlStack(targetSlot, potSlot, world); } } else { return(false); } return(true); } return(base.OnBlockInteractStart(world, byPlayer, blockSel)); } if (stack != null && TryConstruct(world, blockSel.Position, stack.Collectible, byPlayer)) { if (byPlayer != null && byPlayer.WorldData.CurrentGameMode != EnumGameMode.Creative) { byPlayer.InventoryManager.ActiveHotbarSlot.TakeOut(1); } return(true); } return(false); }