22/// <reference path="../../energy.ts" />
33/// <reference path="../interface/IHeatable.ts" />
44/// <reference path="../interface/IEngine.ts" />
5+ /**
6+ * !WARNING
7+ * this code adapted from JAVA source of PC mod
8+ * this structure created not by me
9+ * dont punch me pls
10+ */
511abstract class BCEngineTileEntity implements TileEntity . TileEntityPrototype , IHeatable , IEngine {
612 public readonly MIN_HEAT : number = 20 ;
713 public readonly IDEAL_HEAT : number = 100 ;
@@ -18,7 +24,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
1824 // How many ticks ago it gave out power, capped to 4.
1925 private lastTick : number = 0 ;
2026
21- constructor ( protected texture : EngineTexture ) { }
27+ constructor ( protected texture : EngineTexture ) { }
2228 protected data : any = { // * it will be rewriten during runtime
2329 meta : null , // * this.orientation in PC version
2430 energy : 0 , // * this.energy in PC version
@@ -53,7 +59,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
5359 }
5460
5561 public setOrientation ( value : number ) {
56- if ( typeof ( value ) == "number" ) {
62+ if ( typeof ( value ) == "number" ) {
5763 const { x, y, z } = this ;
5864 this . blockSource . setBlock ( x , y , z , this . blockSource . getBlockId ( x , y , z ) , value ) ;
5965 this . updateClientOrientation ( ) ;
@@ -65,7 +71,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
6571 this . networkData . sendChanges ( ) ;
6672 }
6773
68- private setProgress ( value : number ) {
74+ private setProgress ( value : number ) {
6975 this . data . progress = value ;
7076 this . networkData . putFloat ( "progress" , value ) ;
7177 }
@@ -74,15 +80,15 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
7480 return this . data . progress ;
7581 }
7682
77- private setProgressPart ( value : number ) {
83+ private setProgressPart ( value : number ) {
7884 this . progressPart = value ;
7985 }
8086
8187 private getProgressPart ( ) : number {
8288 return this . progressPart ;
8389 }
8490
85- private setEnergyStage ( value : EngineHeat ) {
91+ private setEnergyStage ( value : EngineHeat ) {
8692 this . energyStage = value ;
8793 this . networkData . putInt ( "energyStageIndex" , HeatOrder . indexOf ( this . energyStage ) ) ;
8894 this . networkData . sendChanges ( ) ;
@@ -92,7 +98,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
9298 return this . isPumping ;
9399 }
94100
95- public setPumping ( value : boolean ) {
101+ public setPumping ( value : boolean ) {
96102 if ( this . isPumping == value ) return ;
97103 this . isPumping = value ;
98104 this . lastTick = 0 ;
@@ -173,24 +179,24 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
173179 }
174180
175181 // !TileEntity event
176- public init ( ) {
182+ public init ( ) {
177183 this . checkOrientation = true ;
178184 }
179185
180186 // !TileEntity event
181- public redstone ( params ) {
187+ public redstone ( params ) {
182188 this . isRedstonePowered = params . signal > 0 ;
183189 }
184190
185191 // !TileEntity event
186- public tick ( ) {
192+ public tick ( ) {
187193 if ( this . checkOrientation ) this . updateConnectionSide ( ) ;
188194 if ( this . lastTick < 4 ) this . lastTick ++ ;
189195
190196 this . updateHeat ( ) ;
191197 this . getEnergyStage ( ) ;
192198
193- if ( this . getEnergyStage ( ) === EngineHeat . OVERHEAT ) {
199+ if ( this . getEnergyStage ( ) === EngineHeat . OVERHEAT ) {
194200 this . data . energy = Math . max ( this . data . energy - 50 , 0 ) ;
195201 return ;
196202 }
@@ -234,7 +240,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
234240 }
235241
236242 public click ( id , count , data ) {
237- if ( id != ItemID . bc_wrench ) return false ;
243+ if ( id != ItemID . bc_wrench ) return false ;
238244 if ( this . getEnergyStage ( ) == EngineHeat . OVERHEAT ) {
239245 this . setEnergyStage ( this . computeEnergyStage ( ) ) ;
240246 }
@@ -249,21 +255,21 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
249255 // ! @MineExplorer PLEASE make EnergyTileRegistry BlockSource support
250256 // TODO move to blockSource getConnectionSide
251257 /** @param findNext - use true value if you want to rerotate engine like a wrench */
252- protected getConnectionSide ( findNext : boolean = false ) {
258+ protected getConnectionSide ( findNext : boolean = false ) {
253259 // * In common situation ends when i gets max in 5 index
254260 // * But if fhis function calling by wrench index can go beyound
255261 // * I think this code is poor, but maybe i fix it in future
256262 const orientation = this . getOrientation ( ) ;
257- for ( let t = 0 ; t < 12 ; t ++ ) {
263+ for ( let t = 0 ; t < 12 ; t ++ ) {
258264 const i = t % 6 ;
259- if ( findNext ) {
260- if ( orientation == t ) findNext = false ;
265+ if ( findNext ) {
266+ if ( orientation == t ) findNext = false ;
261267 continue ;
262268 }
263269 const relCoords = World . getRelativeCoords ( this . x , this . y , this . z , i ) ;
264270 // * ?. is new ESNext feature. Its amazing!
265271 const energyTypes = EnergyTileRegistry . accessMachineAtCoords ( relCoords . x , relCoords . y , relCoords . z ) ?. __energyTypes ;
266- if ( energyTypes ?. RF ) return i ;
272+ if ( energyTypes ?. RF ) return i ;
267273 }
268274 return null ;
269275 }
@@ -273,7 +279,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
273279 const orientation = this . getOrientation ( ) ;
274280 if ( ! this . isPoweredTile ( this . getEnergyProvider ( orientation ) , orientation ) ) {
275281 const side = this . getConnectionSide ( ) ;
276- if ( typeof ( side ) == "number" ) {
282+ if ( typeof ( side ) == "number" ) {
277283 this . setOrientation ( side ) ;
278284 } else this . updateClientOrientation ( ) ;
279285 } else this . updateClientOrientation ( ) ;
@@ -310,7 +316,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
310316
311317 private getPowerToExtract ( ) : number {
312318 const tile = this . getEnergyProvider ( this . getOrientation ( ) ) ;
313- if ( ! tile ) return 0 ;
319+ if ( ! tile ) return 0 ;
314320
315321 const oppositeSide = World . getInverseBlockSide ( this . getOrientation ( ) ) ;
316322
@@ -327,7 +333,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
327333 }
328334
329335 public isPoweredTile ( tile : any , side : number ) : boolean {
330- if ( ! tile ) return false ;
336+ if ( ! tile ) return false ;
331337 const oppositeSide = World . getInverseBlockSide ( this . getOrientation ( ) ) ;
332338
333339 if ( tile . isEngine ) {
@@ -442,7 +448,7 @@ abstract class BCEngineTileEntity implements TileEntity.TileEntityPrototype, IHe
442448 }
443449
444450 // ? why we need it? ask PC author about it. Maybe it should be overrided in future
445- protected burn ( ) : void { }
451+ protected burn ( ) : void { }
446452
447453 // abstract methods
448454 public abstract isBurning ( ) : boolean
0 commit comments