public override void Initialize(ICoreAPI api) { base.Initialize(api); if (contents != null) { contents.ResolveBlockOrItem(api.World); } if (Block.Attributes != null) { maxHeat = Block.Attributes["maxHeat"].AsFloat(maxHeat); degreesPerHour = Block.Attributes["degreesPerHour"].AsFloat(degreesPerHour); maxItems = Block.Attributes["maxItems"].AsInt(maxItems); stackRenderHeight = Block.Attributes["stackRenderHeight"].AsFloat(stackRenderHeight); elementShapeName = Block.Attributes["elementShapeName"].AsString(elementShapeName); } if (api is ICoreClientAPI) { ICoreClientAPI capi = (ICoreClientAPI)api; capi.Event.RegisterRenderer(renderer = new EForgeContentsRenderer(Pos, capi, elementShapeName), EnumRenderStage.Opaque, "forge"); renderer.SetContents(contents, stackRenderHeight, (deviceState == enDeviceState.RUNNING), true); RegisterGameTickListener(OnClientTick, 50); } RegisterGameTickListener(OnCommonTick, 200); }
public override void OnBlockRemoved() { base.OnBlockRemoved(); if (renderer != null) { renderer.Dispose(); renderer = null; } }