public override void OnTryIgniteBlockOver(EntityAgent byEntity, BlockPos pos, float secondsIgniting, ref EnumHandling handling) { handling = EnumHandling.PreventDefault; BlockEntityOven beo = byEntity.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityOven; beo?.TryIgnite(); }
//public override bool ShouldReceiveClientParticleTicks(IWorldAccessor world, IPlayer player, BlockPos pos, out bool isWindAffected) //{ // bool val = base.ShouldReceiveClientParticleTicks(world, player, pos, out _); // isWindAffected = false; // return val; //} public override void OnAsyncClientParticleTick(IAsyncParticleManager manager, BlockPos pos, float windAffectednessAtPos, float secondsTicking) { BlockEntityOven beo = manager.BlockAccess.GetBlockEntity(pos) as BlockEntityOven; if (beo != null && beo.IsBurning) { beo.RenderParticleTick(manager, pos, windAffectednessAtPos, secondsTicking, particles); } base.OnAsyncClientParticleTick(manager, pos, windAffectednessAtPos, secondsTicking); }
public override EnumIgniteState OnTryIgniteBlock(EntityAgent byEntity, BlockPos pos, float secondsIgniting) { BlockEntityOven beo = byEntity.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityOven; if (beo == null || !beo.CanIgnite()) { return(EnumIgniteState.NotIgnitablePreventDefault); } return(secondsIgniting > 4 ? EnumIgniteState.IgniteNow : EnumIgniteState.Ignitable); }
public override void OnLoaded(ICoreAPI api) { base.OnLoaded(api); if (api.Side != EnumAppSide.Client) { return; } ICoreClientAPI capi = api as ICoreClientAPI; if (capi != null) { interactions = ObjectCacheUtil.GetOrCreate(api, "ovenInteractions", () => { List <ItemStack> bakeableStacklist = new List <ItemStack>(); List <ItemStack> fuelStacklist = new List <ItemStack>(); List <ItemStack> canIgniteStacks = new List <ItemStack>(); foreach (CollectibleObject obj in api.World.Collectibles) { // we test firewood first because LazyWarlock's mod adds a wood baking recipe, which we don't want to be treated as a bakeable item here if (obj.Attributes?.IsTrue("isFirewood") == true) { List <ItemStack> stacks = obj.GetHandBookStacks(capi); if (stacks != null) { fuelStacklist.AddRange(stacks); } } else if (obj.Attributes?["bakingProperties"]?.AsObject <BakingProperties>() != null || obj.CombustibleProps?.SmeltingType == EnumSmeltType.Bake && obj.CombustibleProps.SmeltedStack != null && obj.CombustibleProps.MeltingPoint < BlockEntityOven.maxBakingTemperatureAccepted) { List <ItemStack> stacks = obj.GetHandBookStacks(capi); if (stacks != null) { bakeableStacklist.AddRange(stacks); } } else if (obj is Block) { if ((obj as Block).HasBehavior <BlockBehaviorCanIgnite>() || obj is ItemFirestarter) { List <ItemStack> stacks = obj.GetHandBookStacks(capi); if (stacks != null) { canIgniteStacks.AddRange(stacks); } } } } return(new WorldInteraction[] { new WorldInteraction() { ActionLangCode = "blockhelp-oven-bakeable", HotKeyCode = null, MouseButton = EnumMouseButton.Right, Itemstacks = bakeableStacklist.ToArray(), GetMatchingStacks = (wi, bs, es) => { if (wi.Itemstacks.Length == 0) { return null; } BlockEntityOven beo = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityOven; return beo != null ? beo.CanAdd(wi.Itemstacks) : null; } }, new WorldInteraction() { ActionLangCode = "blockhelp-oven-fuel", HotKeyCode = null, MouseButton = EnumMouseButton.Right, Itemstacks = fuelStacklist.ToArray(), GetMatchingStacks = (wi, bs, es) => { //if (wi.Itemstacks.Length == 0) return null; BlockEntityOven beo = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityOven; return beo != null ? beo.CanAddAsFuel(fuelStacklist.ToArray()) : null; } }, new WorldInteraction() { ActionLangCode = "blockhelp-oven-ignite", MouseButton = EnumMouseButton.Right, HotKeyCode = "sneak", Itemstacks = canIgniteStacks.ToArray(), GetMatchingStacks = (wi, bs, es) => { if (wi.Itemstacks.Length == 0) { return null; } BlockEntityOven beo = api.World.BlockAccessor.GetBlockEntity(bs.Position) as BlockEntityOven; return beo != null && beo.CanIgnite() ? wi.Itemstacks : null; } } }); }); } InitializeParticles(); }