Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Significant refactor to support BC2 power (and the beginnings of IC2

power).

Add the beginnings of 3D model import and rendering support.
  • Loading branch information...
commit 95db9f38901c7b94d0fdbe60f76f0c3178f87baf 1 parent 1c09f6e
@diamondq authored
Showing with 2,250 additions and 43 deletions.
  1. +4 −0 PetrolCraft/.classpath
  2. +11 −0 PetrolCraft/src/gfx/model/OilExtractor.mtl
  3. +721 −0 PetrolCraft/src/gfx/model/OilExtractor.obj
  4. +27 −1 PetrolCraft/src/petrolcraft/Mod_PetrolCraft.java
  5. +5 −0 PetrolCraft/src/petrolcraft/common/Constants.java
  6. +61 −0 PetrolCraft/src/petrolcraft/common/DebugLogFormatter.java
  7. +43 −0 PetrolCraft/src/petrolcraft/common/PacketGenerator.java
  8. +47 −0 PetrolCraft/src/petrolcraft/common/PacketHandler.java
  9. +5 −0 PetrolCraft/src/petrolcraft/common/PetrolPacket.java
  10. +54 −0 PetrolCraft/src/petrolcraft/common/PetrolUpdatePacket.java
  11. +14 −0 PetrolCraft/src/petrolcraft/common/Textures.java
  12. +144 −0 PetrolCraft/src/petrolcraft/common/TileEntityDelegate.java
  13. +50 −0 PetrolCraft/src/petrolcraft/machines/IMachineTileEntity.java
  14. +18 −1 PetrolCraft/src/petrolcraft/machines/Machines.java
  15. +27 −8 PetrolCraft/src/petrolcraft/machines/OilExtractorBlock.java
  16. +70 −0 PetrolCraft/src/petrolcraft/machines/OilExtractorRenderer.java
  17. +124 −33 PetrolCraft/src/petrolcraft/machines/OilExtractorTileEntity.java
  18. +97 −0 PetrolCraft/src/petrolcraft/machines/PoweredTileEntity.java
  19. +33 −0 PetrolCraft/src/petrolcraft/power/IEnergyConsumer.java
  20. +28 −0 PetrolCraft/src/petrolcraft/power/PowerAdapter.java
  21. +30 −0 PetrolCraft/src/petrolcraft/power/PowerConversion.java
  22. +90 −0 PetrolCraft/src/petrolcraft/power/bc/BCPoweredTileEntity.java
  23. +105 −0 PetrolCraft/src/petrolcraft/power/bc/PetrolBCPowerProvider.java
  24. +101 −0 PetrolCraft/src/petrolcraft/power/ic2/IC2EnergyConsumer.java
  25. +102 −0 PetrolCraft/src/petrolcraft/power/ic2/IC2PoweredTileEntity.java
  26. +119 −0 PetrolCraft/src/petrolcraft/render/ModelParser.java
  27. +90 −0 PetrolCraft/src/petrolcraft/render/OpenGLRenderer.java
  28. +30 −0 PetrolCraft/src/petrolcraft/render/VertexData.java
View
4 PetrolCraft/.classpath
@@ -4,5 +4,9 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/Minecraft"/>
<classpathentry combineaccessrules="false" kind="src" path="/IndustrialCraft-API"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/BuildCraft"/>
+ <classpathentry kind="lib" path="C:/PetrolCraft-Eclipse-3.7.2/forge/mcp/jars/bin/jinput.jar"/>
+ <classpathentry kind="lib" path="C:/PetrolCraft-Eclipse-3.7.2/forge/mcp/jars/bin/lwjgl.jar"/>
+ <classpathentry kind="lib" path="C:/PetrolCraft-Eclipse-3.7.2/forge/mcp/jars/bin/lwjgl_util.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
11 PetrolCraft/src/gfx/model/OilExtractor.mtl
@@ -0,0 +1,11 @@
+# Blender MTL File: 'None'
+# Material Count: 1
+
+newmtl initialShadingGroup
+Ns 96.078431
+Ka 0.000000 0.000000 0.000000
+Kd 0.400000 0.400000 0.400000
+Ks 0.500000 0.500000 0.500000
+Ni 1.000000
+d 0.000000
+illum 2
View
721 PetrolCraft/src/gfx/model/OilExtractor.obj
@@ -0,0 +1,721 @@
+# Blender v2.65 (sub 0) OBJ File: ''
+# www.blender.org
+mtllib OilExtractor.mtl
+o pCube2
+v -0.051199 -1.058376 1.185606
+v 0.051199 -1.058376 1.185606
+v 0.051199 -0.905569 1.164182
+v -0.051199 -0.905569 1.164182
+v -0.051199 -0.822855 -0.615224
+v 0.051199 -0.822855 -0.615224
+v 0.051199 -0.789114 -0.759509
+v -0.051199 -0.789114 -0.759509
+v -0.051199 -1.182990 -0.814476
+v 0.051199 -1.182990 -0.814476
+v 0.051199 -1.335797 -0.793051
+v -0.051199 -1.335797 -0.793051
+v -0.042392 -1.676416 -0.615302
+v 0.020579 -1.685191 -0.617387
+v 0.042392 -1.599156 -0.515290
+v -0.020579 -1.590382 -0.513204
+v 0.051199 -1.162289 -0.656936
+v 0.051199 -1.315096 -0.635512
+v -0.051199 -1.315096 -0.635512
+v -0.051199 -1.162289 -0.656936
+v 0.031693 -1.104768 0.854726
+v -0.031693 -1.104768 0.854726
+v -0.031693 -0.951961 0.833301
+v 0.031693 -0.951961 0.833301
+v -0.031693 -1.080254 1.029567
+v 0.031693 -1.080254 1.029567
+v -0.031693 -0.927447 1.008142
+v 0.031693 -0.927447 1.008142
+v -0.012920 -1.304458 0.882724
+v 0.012920 -1.304458 0.882724
+v 0.012920 -1.279945 1.057565
+v -0.012920 -1.279945 1.057565
+v -0.080005 -0.951961 0.833301
+v -0.080005 -1.104768 0.854726
+v -0.080005 -1.080254 1.029567
+v -0.080005 -0.927447 1.008142
+v -0.019166 -0.727756 0.980144
+v 0.019166 -0.727756 0.980144
+v 0.019166 -0.752270 0.805303
+v -0.019166 -0.752270 0.805303
+v 0.080005 -0.927447 1.008142
+v 0.080005 -1.080254 1.029567
+v 0.080005 -1.104768 0.854726
+v 0.080005 -0.951961 0.833301
+v 0.051199 -0.950341 -0.656275
+v -0.051199 -0.950341 -0.656275
+v 0.051199 -0.982992 -0.807401
+v -0.051199 -0.982992 -0.807401
+v 0.041791 -1.518378 -0.739184
+v -0.041791 -1.518378 -0.739184
+v 0.041791 -1.483845 -0.599478
+v -0.041791 -1.483845 -0.599478
+v 0.080005 -1.104768 0.854726
+v 0.080005 -1.080254 1.029567
+v 0.032616 -1.279945 1.057565
+v 0.032616 -1.304458 0.882724
+v -0.080005 -1.080254 1.029567
+v -0.080005 -1.104768 0.854726
+v -0.032616 -1.304458 0.882724
+v -0.032616 -1.279945 1.057565
+v 0.080005 -0.927447 1.008142
+v 0.080005 -0.951961 0.833301
+v 0.048383 -0.752270 0.805303
+v 0.048383 -0.727756 0.980144
+v -0.080005 -0.951961 0.833301
+v -0.080005 -0.927447 1.008142
+v -0.048383 -0.727756 0.980144
+v -0.048383 -0.752270 0.805303
+vt 0.000000 0.000000
+vt 1.000000 0.000000
+vt 1.000000 1.000000
+vt 0.000000 1.000000
+vt 0.000000 1.847497
+vt 1.000000 1.847497
+vt 1.000000 2.000000
+vt 0.000000 2.000000
+vt 0.000000 3.000000
+vt 1.000000 3.000000
+vt 1.000000 3.152503
+vt 0.000000 3.152503
+vt 1.000000 3.832775
+vt 0.000000 3.832775
+vt -0.847497 1.000000
+vt -0.847497 0.000000
+vt -0.167225 0.000000
+vt -0.167225 1.000000
+vt 0.000000 1.167225
+vt 1.000000 1.167225
+vt 1.167225 1.000000
+vt 1.167225 0.000000
+vt 1.847497 0.000000
+vt 1.847497 1.000000
+vt 1.000000 4.000000
+vt 0.000000 4.000000
+vt 0.000000 3.921139
+vt 1.000000 3.921139
+vt -0.078861 1.000000
+vt -0.078861 0.000000
+vt 1.000000 1.078861
+vt 0.000000 1.078861
+vt 1.078861 0.000000
+vt 1.078861 1.000000
+vt 2.000000 0.000000
+vt 2.000000 1.000000
+vt -1.000000 0.000000
+vt -1.000000 1.000000
+vn 0.000000 0.138845 0.990314
+vn 0.000000 0.973730 0.227706
+vn -0.083342 -0.753193 0.652499
+vn 0.000000 -0.990187 0.139752
+vn -0.999916 0.001799 0.012834
+vn 0.000000 0.990187 -0.139752
+vn 0.999916 0.001799 0.012834
+vn 0.000000 -0.990314 0.138850
+vn -0.992424 -0.017059 -0.121668
+vn 0.000000 0.990313 -0.138850
+vn 0.992424 -0.017059 -0.121668
+vn -1.000000 0.000000 -0.000000
+vn 1.000000 0.000000 -0.000000
+vn 0.000000 -0.003119 0.999995
+vn 0.000000 0.208828 0.977952
+vn 0.973478 -0.226564 0.031765
+vn -0.973478 -0.226564 0.031765
+vn 0.987926 0.153427 -0.021511
+vn -0.987926 0.153427 -0.021511
+vn 0.000000 -0.138851 -0.990313
+vn 0.000000 0.138852 0.990313
+vn 0.000000 0.990314 -0.138849
+vn 0.000000 0.990314 -0.138850
+vn 0.000000 -0.990314 0.138849
+vn 0.994089 -0.101242 -0.039195
+vn -0.047312 -0.600503 -0.798221
+vn -0.995745 -0.004456 0.092047
+vn 0.047854 0.611540 0.789765
+vn 0.000000 -0.306506 0.951869
+vn 0.000000 0.239813 -0.970819
+vn -0.687979 -0.037690 -0.724723
+vn 0.687979 -0.037690 -0.724723
+vn 0.696005 -0.167669 -0.698141
+vn -0.696005 -0.167669 -0.698141
+vn 0.920316 0.291971 0.260262
+vn 0.910306 -0.248939 0.330668
+vn -0.910306 -0.248939 0.330668
+vn -0.920316 0.291971 0.260262
+vn 0.000000 -0.798425 -0.602069
+vn 0.000000 -0.602069 0.798425
+vn 0.000000 0.798425 0.602069
+vn 0.000000 0.602069 -0.798425
+vn 0.684591 0.100803 -0.721915
+vn 0.743339 -0.104770 0.660604
+vn -0.684591 0.100803 -0.721915
+vn -0.743339 -0.104770 0.660604
+vn 0.652577 -0.369945 -0.661214
+vn -0.677297 -0.356731 -0.643391
+vn 0.775018 0.218665 0.592853
+vn -0.749596 0.236976 0.617969
+vn -0.302561 -0.427320 -0.851955
+vn 0.302561 -0.427320 -0.851955
+vn 0.307352 -0.207007 0.928800
+vn -0.307352 -0.207007 0.928800
+vn -0.307352 0.454451 0.836024
+vn 0.307352 0.454451 0.836024
+vn 0.302072 0.176397 -0.936796
+vn -0.302072 0.176397 -0.936796
+vn 0.501144 -0.544481 0.672567
+vn 0.646077 0.585498 0.489608
+vn 0.501144 -0.708426 -0.496902
+vn 0.646077 0.428266 -0.631733
+vn -0.501144 -0.708426 -0.496902
+vn -0.646077 0.428266 -0.631733
+vn -0.501144 -0.544481 0.672567
+vn -0.646077 0.585498 0.489608
+vn 0.526719 0.528428 -0.665792
+vn 0.624561 -0.608173 -0.489883
+vn 0.526719 0.691153 0.494797
+vn 0.624561 -0.449995 0.638264
+vn -0.526719 0.691153 0.494797
+vn -0.624561 -0.449995 0.638264
+vn -0.526719 0.528428 -0.665792
+vn -0.624561 -0.608173 -0.489883
+usemtl initialShadingGroup
+s off
+f 1/1/1 2/2/1 3/3/1
+f 1/1/1 3/3/1 4/4/1
+f 5/5/2 6/6/2 7/7/2
+f 5/5/2 7/7/2 8/8/2
+f 13/9/3 14/10/3 15/11/3
+f 13/9/3 15/11/3 16/12/3
+f 19/12/4 18/11/4 21/13/4
+f 19/12/4 21/13/4 22/14/4
+f 20/15/5 19/16/5 22/17/5
+f 20/15/5 22/17/5 23/18/5
+f 23/19/6 24/20/6 17/6/6
+f 23/19/6 17/6/6 20/5/6
+f 24/21/7 21/22/7 18/23/7
+f 24/21/7 18/23/7 17/24/7
+f 2/25/8 1/26/8 25/27/8
+f 2/25/8 25/27/8 26/28/8
+f 1/1/9 4/4/9 27/29/9
+f 1/1/9 27/29/9 25/30/9
+f 4/4/10 3/3/10 28/31/10
+f 4/4/10 28/31/10 27/32/10
+f 2/2/11 26/33/11 28/34/11
+f 2/2/11 28/34/11 3/3/11
+f 33/18/12 34/17/12 35/30/12
+f 33/18/12 35/30/12 36/29/12
+f 41/34/13 42/33/13 43/22/13
+f 41/34/13 43/22/13 44/21/13
+f 20/5/14 17/6/14 45/6/14
+f 20/5/14 45/6/14 46/5/14
+f 18/11/15 19/12/15 52/12/15
+f 18/11/15 52/12/15 51/11/15
+f 53/13/16 54/28/16 55/28/16
+f 53/13/16 55/28/16 56/13/16
+f 57/27/17 58/14/17 59/14/17
+f 57/27/17 59/14/17 60/27/17
+f 61/31/18 62/20/18 63/20/18
+f 61/31/18 63/20/18 64/31/18
+f 65/19/19 66/32/19 67/32/19
+f 65/19/19 67/32/19 68/19/19
+f 23/18/20 22/17/20 34/17/20
+f 23/18/20 34/17/20 33/18/20
+f 22/17/8 25/30/8 35/30/8
+f 22/17/8 35/30/8 34/17/8
+f 25/30/21 27/29/21 36/29/21
+f 25/30/21 36/29/21 35/30/21
+f 27/29/22 23/18/22 33/18/22
+f 27/29/22 33/18/22 36/29/22
+f 28/34/21 26/33/21 42/33/21
+f 28/34/21 42/33/21 41/34/21
+f 26/33/8 21/22/8 43/22/8
+f 26/33/8 43/22/8 42/33/8
+f 21/22/20 24/21/20 44/21/20
+f 21/22/20 44/21/20 43/22/20
+f 24/21/22 28/34/22 41/34/22
+f 24/21/22 41/34/22 44/21/22
+f 21/13/23 26/28/23 54/28/23
+f 21/13/23 54/28/23 53/13/23
+f 25/27/23 22/14/23 58/14/23
+f 25/27/23 58/14/23 57/27/23
+f 28/31/24 24/20/24 62/20/24
+f 28/31/24 62/20/24 61/31/24
+f 23/19/24 27/32/24 66/32/24
+f 23/19/24 66/32/24 65/19/24
+f 49/10/25 51/11/25 15/11/25
+f 49/10/25 15/11/25 14/10/25
+f 50/9/26 49/10/26 14/10/26
+f 50/9/26 14/10/26 13/9/26
+f 52/12/27 50/9/27 13/9/27
+f 52/12/27 13/9/27 16/12/27
+f 51/11/28 52/12/28 16/12/28
+f 51/11/28 16/12/28 15/11/28
+f 46/5/29 45/6/29 6/6/29
+f 46/5/29 6/6/29 5/5/29
+f 48/8/12 46/5/12 5/5/12
+f 48/8/12 5/5/12 8/8/12
+f 47/7/30 48/8/30 8/8/30
+f 47/7/30 8/8/30 7/7/30
+f 45/6/13 47/7/13 7/7/13
+f 45/6/13 7/7/13 6/6/13
+s 1
+f 9/8/31 10/7/32 11/10/33
+f 9/8/31 11/10/33 12/9/34
+f 17/24/35 18/23/36 11/35/33
+f 17/24/35 11/35/33 10/36/32
+f 12/37/34 19/16/37 20/15/38
+f 12/37/34 20/15/38 9/38/31
+f 29/14/39 30/13/39 31/28/40
+f 29/14/39 31/28/40 32/27/40
+f 37/32/41 38/31/41 39/20/42
+f 37/32/41 39/20/42 40/19/42
+f 17/6/35 10/7/32 47/7/43
+f 17/6/35 47/7/43 45/6/44
+f 10/7/32 9/8/31 48/8/45
+f 10/7/32 48/8/45 47/7/43
+f 9/8/31 20/5/38 46/5/46
+f 9/8/31 46/5/46 48/8/45
+f 12/9/34 11/10/33 49/10/47
+f 12/9/34 49/10/47 50/9/48
+f 11/10/33 18/11/36 51/11/49
+f 11/10/33 51/11/49 49/10/47
+f 19/12/37 12/9/34 50/9/48
+f 19/12/37 50/9/48 52/12/50
+f 22/14/51 21/13/52 30/13/39
+f 22/14/51 30/13/39 29/14/39
+f 26/28/53 25/27/54 32/27/40
+f 26/28/53 32/27/40 31/28/40
+f 27/32/55 28/31/56 38/31/41
+f 27/32/55 38/31/41 37/32/41
+f 24/20/57 23/19/58 40/19/42
+f 24/20/57 40/19/42 39/20/42
+f 26/28/53 31/28/40 55/28/59
+f 26/28/53 55/28/59 54/28/60
+f 31/28/40 30/13/39 56/13/61
+f 31/28/40 56/13/61 55/28/59
+f 30/13/39 21/13/52 53/13/62
+f 30/13/39 53/13/62 56/13/61
+f 22/14/51 29/14/39 59/14/63
+f 22/14/51 59/14/63 58/14/64
+f 29/14/39 32/27/40 60/27/65
+f 29/14/39 60/27/65 59/14/63
+f 32/27/40 25/27/54 57/27/66
+f 32/27/40 57/27/66 60/27/65
+f 24/20/57 39/20/42 63/20/67
+f 24/20/57 63/20/67 62/20/68
+f 39/20/42 38/31/41 64/31/69
+f 39/20/42 64/31/69 63/20/67
+f 38/31/41 28/31/56 61/31/70
+f 38/31/41 61/31/70 64/31/69
+f 27/32/55 37/32/41 67/32/71
+f 27/32/55 67/32/71 66/32/72
+f 37/32/41 40/19/42 68/19/73
+f 37/32/41 68/19/73 67/32/71
+f 40/19/42 23/19/58 65/19/74
+f 40/19/42 65/19/74 68/19/73
+o pCube3
+v -0.151113 -0.243399 0.860208
+v 0.151113 -0.243399 0.860208
+v 0.151113 -0.000746 0.860208
+v -0.151113 -0.000746 0.860208
+v 0.151113 -0.000746 0.151782
+v -0.151113 -0.000746 0.151782
+v 0.151113 -0.243399 0.151782
+v -0.151113 -0.243399 0.151782
+vt 0.000000 0.000000
+vt 1.000000 0.000000
+vt 1.000000 1.000000
+vt 0.000000 1.000000
+vt 1.000000 2.000000
+vt 0.000000 2.000000
+vt 1.000000 3.000000
+vt 0.000000 3.000000
+vt 1.000000 4.000000
+vt 0.000000 4.000000
+vt 2.000000 0.000000
+vt 2.000000 1.000000
+vt -1.000000 0.000000
+vt -1.000000 1.000000
+vn 0.000000 -0.000000 1.000000
+vn 0.000000 1.000000 0.000000
+vn 0.000000 0.000000 -1.000000
+vn 0.000000 -1.000000 -0.000000
+usemtl initialShadingGroup
+s off
+f 69/39/75 70/40/75 71/41/75
+f 69/39/75 71/41/75 72/42/75
+f 72/42/76 71/41/76 73/43/76
+f 72/42/76 73/43/76 74/44/76
+f 74/44/77 73/43/77 75/45/77
+f 74/44/77 75/45/77 76/46/77
+f 70/47/78 69/48/78 76/46/78
+f 70/47/78 76/46/78 75/45/78
+f 70/40/13 75/49/13 73/50/13
+f 70/40/13 73/50/13 71/41/13
+f 76/51/12 69/39/12 72/42/12
+f 76/51/12 72/42/12 74/52/12
+o pCube1
+v -0.500000 -0.000000 1.124710
+v -0.250000 -0.000000 1.124710
+v 0.000000 -0.000000 1.124710
+v 0.000000 0.091924 1.124710
+v -0.250000 0.091924 1.124710
+v -0.500000 0.091924 1.124710
+v -0.500000 0.091924 -0.392387
+v -0.250000 0.091924 -0.392387
+v -0.250000 0.091924 -0.875290
+v -0.500000 0.091924 -0.875290
+v -0.250000 0.000000 -0.875290
+v -0.500000 0.000000 -0.875290
+v -0.250000 0.000000 -0.392387
+v -0.500000 0.000000 -0.392387
+v 0.500000 0.000000 -0.392387
+v 0.500000 0.000000 -0.875290
+v 0.500000 0.091924 -0.875290
+v 0.500000 0.091924 -0.392387
+v 0.000000 0.091924 -0.392387
+v 0.250000 0.091924 -0.392387
+v 0.250000 0.091924 -0.875290
+v 0.000000 0.091924 -0.875290
+v 0.000000 0.000000 -0.875290
+v 0.250000 0.000000 -0.875290
+v 0.250000 0.000000 -0.392387
+v 0.000000 0.000000 -0.392387
+v 0.250000 -0.000000 1.124710
+v 0.250000 0.091924 1.124710
+v 0.500000 -0.000000 1.124710
+v 0.500000 0.091924 1.124710
+v -0.500000 0.000000 0.124710
+v -0.500000 -0.000000 0.629597
+v -0.500000 0.091924 0.629597
+v -0.500000 0.091924 0.124710
+v -0.250000 0.091924 0.629597
+v -0.250000 0.091924 0.124710
+v 0.000000 0.091924 0.629597
+v 0.000000 0.091924 0.124710
+v 0.250000 0.091924 0.629597
+v 0.250000 0.091924 0.124710
+v 0.500000 0.091924 0.124710
+v 0.500000 0.091924 0.629597
+v 0.500000 -0.000000 0.629597
+v 0.500000 0.000000 0.124710
+v 0.046266 -1.147574 0.584849
+v 0.046266 -1.147574 0.391297
+v 0.092533 -1.147574 0.391297
+v 0.092533 -1.147574 0.584849
+v 0.250000 -0.000000 0.629597
+v 0.000000 -0.000000 0.629597
+v 0.000000 0.000000 0.124710
+v 0.250000 0.000000 0.124710
+v -0.250000 -0.000000 0.629597
+v -0.250000 0.000000 0.124710
+v -0.092533 -1.147574 0.391297
+v -0.046266 -1.147574 0.391297
+v -0.046266 -1.147574 0.584849
+v -0.092533 -1.147574 0.584849
+v 0.082590 -0.534118 0.308082
+v 0.082590 -0.534118 0.668064
+v 0.165180 -0.534118 0.308082
+v 0.165180 -0.534118 0.668064
+v -0.082590 -0.534118 0.308082
+v -0.165180 -0.534118 0.308082
+v -0.082590 -0.534118 0.668064
+v -0.165180 -0.534118 0.668064
+vt 0.000000 1.745093
+vt 0.251843 1.745093
+vt 0.251843 2.000000
+vt 0.000000 2.000000
+vt 0.251843 3.000000
+vt 0.000000 3.000000
+vt 0.251843 3.254907
+vt 0.000000 3.254907
+vt 1.745093 0.000000
+vt 2.000000 0.000000
+vt 2.000000 1.000000
+vt 1.745093 1.000000
+vt -1.000000 0.000000
+vt -0.745093 0.000000
+vt -0.745093 1.000000
+vt -1.000000 1.000000
+vt 0.503685 1.745093
+vt 0.751843 1.745093
+vt 0.751843 2.000000
+vt 0.503685 2.000000
+vt 0.503685 3.000000
+vt 0.751843 3.000000
+vt 0.751843 3.254907
+vt 0.503685 3.254907
+vt 0.503685 1.000000
+vt 0.503685 0.000000
+vt 0.751843 0.000000
+vt 0.751843 1.000000
+vt 1.000000 2.000000
+vt 1.000000 3.000000
+vt 1.000000 3.254907
+vt 1.000000 0.000000
+vt 1.000000 1.000000
+vt 1.000000 1.745093
+vt 0.000000 1.233760
+vt 0.251843 1.233760
+vt 0.251843 1.472136
+vt 0.000000 1.472136
+vt 0.503685 1.233760
+vt 0.503685 1.472136
+vt 0.751843 1.233760
+vt 0.751843 1.472136
+vt 1.000000 1.472136
+vt 1.000000 1.233760
+vt 0.751843 3.766240
+vt 0.751843 3.527864
+vt 1.000000 3.527864
+vt 1.000000 3.766240
+vt 0.503685 3.766240
+vt 0.503685 3.527864
+vt 0.251843 3.766240
+vt 0.251843 3.527864
+vt 0.000000 3.527864
+vt 0.000000 3.766240
+vt -0.472135 0.000000
+vt -0.472135 1.000000
+vt 1.472136 0.000000
+vt 1.472136 1.000000
+vt 0.251843 4.000000
+vt 0.503685 4.000000
+vt 0.000000 4.000000
+vt 0.000000 0.000000
+vt 0.000000 1.000000
+vt -0.233760 1.000000
+vt -0.233760 0.000000
+vt 0.251843 1.000000
+vt 1.233760 0.000000
+vt 1.233760 1.000000
+vt 0.751843 4.000000
+vt 1.000000 4.000000
+vt 0.251843 0.000000
+vn 0.000000 -1.000000 -0.000001
+vn 0.000000 0.000000 0.000000
+vn -0.836726 -0.512192 -0.193609
+vn -0.869381 -0.454421 0.193976
+vn -0.707083 0.707083 0.000000
+vn 0.869381 -0.454421 0.193976
+vn 0.836726 -0.512192 -0.193609
+vn 0.707083 0.707083 0.000000
+vn -0.328715 -0.858882 0.392712
+vn -0.222480 -0.918485 -0.326853
+vn -0.752861 0.003204 -0.658132
+vn -0.702109 0.099460 0.705069
+vn 0.600696 -0.407361 -0.687857
+vn 0.589709 -0.220801 0.776818
+vn 0.222480 -0.918485 -0.326853
+vn 0.752861 0.003204 -0.658132
+vn -0.600696 -0.407361 -0.687857
+vn 0.328715 -0.858882 0.392712
+vn 0.702109 0.099460 0.705069
+vn -0.589709 -0.220801 0.776818
+vn -0.604022 -0.593677 -0.531663
+vn -0.604022 -0.593677 0.531663
+vn 0.544816 -0.643025 -0.538194
+vn 0.544816 -0.643025 0.538194
+vn 0.604022 -0.593677 -0.531663
+vn -0.544816 -0.643025 -0.538194
+vn 0.604022 -0.593677 0.531663
+vn -0.544816 -0.643025 0.538194
+usemtl initialShadingGroup
+s off
+f 83/53/76 84/54/76 85/55/76
+f 83/53/76 85/55/76 86/56/76
+f 86/56/77 85/55/77 87/57/77
+f 86/56/77 87/57/77 88/58/77
+f 88/58/78 87/57/78 89/59/78
+f 88/58/78 89/59/78 90/60/78
+f 91/61/13 92/62/13 93/63/13
+f 91/61/13 93/63/13 94/64/13
+f 88/65/12 90/66/12 83/67/12
+f 88/65/12 83/67/12 86/68/12
+f 95/69/76 96/70/76 97/71/76
+f 95/69/76 97/71/76 98/72/76
+f 99/73/77 98/72/77 97/71/77
+f 99/73/77 97/71/77 100/74/77
+f 101/75/78 102/76/78 99/73/78
+f 101/75/78 99/73/78 100/74/78
+f 80/77/75 79/78/75 103/79/75
+f 80/77/75 103/79/75 104/80/75
+f 84/54/76 95/69/76 98/72/76
+f 84/54/76 98/72/76 85/55/76
+f 87/57/77 85/55/77 98/72/77
+f 87/57/77 98/72/77 99/73/77
+f 89/59/78 87/57/78 99/73/78
+f 89/59/78 99/73/78 102/76/78
+f 100/74/77 97/71/77 93/81/77
+f 100/74/77 93/81/77 92/82/77
+f 101/75/78 100/74/78 92/82/78
+f 101/75/78 92/82/78 91/83/78
+f 104/80/75 103/79/75 105/84/75
+f 104/80/75 105/84/75 106/85/75
+f 97/71/76 96/70/76 94/86/76
+f 97/71/76 94/86/76 93/81/76
+f 109/87/76 111/88/76 112/89/76
+f 109/87/76 112/89/76 110/90/76
+f 111/88/76 113/91/76 114/92/76
+f 111/88/76 114/92/76 112/89/76
+f 113/91/76 115/93/76 116/94/76
+f 113/91/76 116/94/76 114/92/76
+f 117/95/76 116/94/76 115/93/76
+f 117/95/76 115/93/76 118/96/76
+f 121/97/79 122/98/79 123/99/79
+f 121/97/79 123/99/79 124/100/79
+f 125/97/78 126/101/78 127/102/78
+f 125/97/78 127/102/78 128/98/78
+f 129/103/78 130/104/78 127/102/78
+f 129/103/78 127/102/78 126/101/78
+f 131/105/79 132/104/79 133/103/79
+f 131/105/79 133/103/79 134/106/79
+f 130/104/78 89/59/78 102/76/78
+f 130/104/78 102/76/78 127/102/78
+f 90/60/78 89/59/78 130/104/78
+f 90/60/78 130/104/78 107/105/78
+f 83/67/12 90/66/12 107/107/12
+f 83/67/12 107/107/12 110/108/12
+f 110/90/76 112/89/76 84/54/76
+f 110/90/76 84/54/76 83/53/76
+f 112/89/76 114/92/76 95/69/76
+f 112/89/76 95/69/76 84/54/76
+f 114/92/76 116/94/76 96/70/76
+f 114/92/76 96/70/76 95/69/76
+f 94/86/76 96/70/76 116/94/76
+f 94/86/76 116/94/76 117/95/76
+f 120/109/13 91/61/13 94/64/13
+f 120/109/13 94/64/13 117/110/13
+f 128/98/78 101/75/78 91/83/78
+f 128/98/78 91/83/78 120/99/78
+f 127/102/78 102/76/78 101/75/78
+f 127/102/78 101/75/78 128/98/78
+f 78/111/78 129/103/78 126/101/78
+f 78/111/78 126/101/78 79/112/78
+f 78/111/78 77/113/78 108/106/78
+f 78/111/78 108/106/78 129/103/78
+f 77/114/12 82/115/12 109/116/12
+f 77/114/12 109/116/12 108/117/12
+f 82/115/76 81/118/76 111/88/76
+f 82/115/76 111/88/76 109/87/76
+f 81/118/76 80/77/76 113/91/76
+f 81/118/76 113/91/76 111/88/76
+f 80/77/76 104/80/76 115/93/76
+f 80/77/76 115/93/76 113/91/76
+f 118/96/76 115/93/76 104/80/76
+f 118/96/76 104/80/76 106/85/76
+f 105/84/13 119/119/13 118/120/13
+f 105/84/13 118/120/13 106/85/13
+f 103/121/78 125/97/78 119/100/78
+f 103/121/78 119/100/78 105/122/78
+f 79/112/78 126/101/78 125/97/78
+f 79/112/78 125/97/78 103/121/78
+f 82/115/75 77/114/75 81/118/75
+f 81/118/75 77/114/75 80/77/75
+f 80/77/75 77/114/75 79/78/75
+f 79/78/80 77/114/80 78/123/80
+s 1
+f 107/107/81 108/117/82 109/116/83
+f 107/107/81 109/116/83 110/108/83
+f 119/119/84 120/109/85 117/110/86
+f 119/119/84 117/110/86 118/120/86
+f 125/97/87 128/98/88 135/98/89
+f 125/97/87 135/98/89 136/97/90
+f 128/98/88 120/99/85 137/99/91
+f 128/98/88 137/99/91 135/98/89
+f 120/99/85 119/100/84 138/100/92
+f 120/99/85 138/100/92 137/99/91
+f 119/100/84 125/97/87 136/97/90
+f 119/100/84 136/97/90 138/100/92
+f 107/105/81 130/104/93 139/104/94
+f 107/105/81 139/104/94 140/105/95
+f 130/104/93 129/103/96 141/103/97
+f 130/104/93 141/103/97 139/104/94
+f 129/103/96 108/106/82 142/106/98
+f 129/103/96 142/106/98 141/103/97
+f 108/106/82 107/105/81 140/105/95
+f 108/106/82 140/105/95 142/106/98
+f 136/97/90 135/98/89 122/98/99
+f 136/97/90 122/98/99 121/97/100
+f 135/98/89 137/99/91 123/99/101
+f 135/98/89 123/99/101 122/98/99
+f 137/99/91 138/100/92 124/100/102
+f 137/99/91 124/100/102 123/99/101
+f 138/100/92 136/97/90 121/97/100
+f 138/100/92 121/97/100 124/100/102
+f 140/105/95 139/104/94 132/104/103
+f 140/105/95 132/104/103 131/105/104
+f 139/104/94 141/103/97 133/103/105
+f 139/104/94 133/103/105 132/104/103
+f 141/103/97 142/106/98 134/106/106
+f 141/103/97 134/106/106 133/103/105
+f 142/106/98 140/105/95 131/105/104
+f 142/106/98 131/105/104 134/106/106
+o pCylinder1
+v 0.008936 -0.829348 -0.728869
+v -0.023396 -0.829348 -0.718364
+v -0.023396 0.034790 -0.718364
+v 0.008936 0.034790 -0.728869
+v -0.023396 -0.829348 -0.684368
+v -0.023396 0.034790 -0.684368
+v 0.008936 -0.829348 -0.673862
+v 0.008936 0.034790 -0.673862
+v 0.028919 -0.829348 -0.701366
+v 0.028919 0.034790 -0.701366
+v 0.000000 -0.829348 -0.701366
+v 0.000000 0.034790 -0.701366
+vt 0.000000 0.159155
+vt 0.200000 0.159155
+vt 0.200000 0.477465
+vt 0.000000 0.477465
+vt 0.400000 0.159155
+vt 0.400000 0.477465
+vt 0.600000 0.159155
+vt 0.600000 0.477465
+vt 0.800000 0.159155
+vt 0.800000 0.477465
+vt 1.000000 0.159155
+vt 1.000000 0.477465
+vt 0.500000 0.000000
+vt 0.500000 0.636620
+vn -0.309009 0.000000 -0.951059
+vn -0.309036 -0.000000 0.951050
+vn 0.809015 -0.000000 0.587788
+vn 0.809004 0.000000 -0.587802
+vn -0.649800 -0.595691 -0.472091
+vn 0.248177 -0.595691 -0.763878
+vn -0.649800 -0.595691 0.472091
+vn 0.248177 -0.595691 0.763878
+vn 0.803186 -0.595691 0.000000
+vn 0.248177 0.595691 -0.763878
+vn -0.649800 0.595691 -0.472091
+vn -0.649800 0.595691 0.472091
+vn 0.248177 0.595691 0.763878
+vn 0.803186 0.595691 0.000000
+usemtl initialShadingGroup
+s off
+f 143/124/107 144/125/107 145/126/107
+f 143/124/107 145/126/107 146/127/107
+f 144/125/12 147/128/12 148/129/12
+f 144/125/12 148/129/12 145/126/12
+f 147/128/108 149/130/108 150/131/108
+f 147/128/108 150/131/108 148/129/108
+f 149/130/109 151/132/109 152/133/109
+f 149/130/109 152/133/109 150/131/109
+f 151/132/110 143/134/110 146/135/110
+f 151/132/110 146/135/110 152/133/110
+s 1
+f 144/125/111 143/124/112 153/136/78
+f 147/128/113 144/125/111 153/136/78
+f 149/130/114 147/128/113 153/136/78
+f 151/132/115 149/130/114 153/136/78
+f 143/134/112 151/132/115 153/136/78
+f 146/127/116 145/126/117 154/137/76
+f 145/126/117 148/129/118 154/137/76
+f 148/129/118 150/131/119 154/137/76
+f 150/131/119 152/133/120 154/137/76
+f 152/133/120 146/135/116 154/137/76
View
28 PetrolCraft/src/petrolcraft/Mod_PetrolCraft.java
@@ -7,18 +7,24 @@
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.FMLRelaunchLog;
+import java.lang.reflect.Field;
+import java.util.logging.Handler;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import net.minecraftforge.common.Configuration;
import petrolcraft.blocks.Blocks;
+import petrolcraft.common.Constants;
+import petrolcraft.common.DebugLogFormatter;
+import petrolcraft.common.PacketHandler;
import petrolcraft.common.Textures;
import petrolcraft.generation.OnChunkCreation;
import petrolcraft.machines.Machines;
@Mod(modid = "PetrolCraft", name = "PetrolCraft", version = "0.0.1")
-@NetworkMod(clientSideRequired = false, serverSideRequired = false)
+@NetworkMod(channels = { Constants.sCHANNEL_NAME }, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true)
public class Mod_PetrolCraft {
public static final String sVersion = "0.0.1";
@@ -39,6 +45,26 @@
Logger parent = LogManager.getLogManager().getLogger("ForgeModLoader");
if (parent != null)
sLog.setParent(parent);
+
+ /* For debug purposes, update the logging formatter */
+
+ try {
+ Field field = FMLRelaunchLog.class.getDeclaredField("myLog");
+ field.setAccessible(true);
+ Logger logger = (Logger) field.get(FMLRelaunchLog.log);
+ Handler[] handlers = logger.getHandlers();
+ for (Handler h : handlers) {
+ h.setFormatter(new DebugLogFormatter());
+ }
+ } catch (SecurityException ex) {
+ ex.printStackTrace();
+ } catch (NoSuchFieldException ex) {
+ ex.printStackTrace();
+ } catch (IllegalArgumentException ex) {
+ ex.printStackTrace();
+ } catch (IllegalAccessException ex) {
+ ex.printStackTrace();
+ }
}
@PreInit
View
5 PetrolCraft/src/petrolcraft/common/Constants.java
@@ -0,0 +1,5 @@
+package petrolcraft.common;
+
+public class Constants {
+ public static final String sCHANNEL_NAME = "PetrolCraft";
+}
View
61 PetrolCraft/src/petrolcraft/common/DebugLogFormatter.java
@@ -0,0 +1,61 @@
+package petrolcraft.common;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.SimpleDateFormat;
+import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class DebugLogFormatter extends Formatter {
+ static final String LINE_SEPARATOR = System.getProperty("line.separator");
+ private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ public String format(LogRecord record) {
+ StringBuilder msg = new StringBuilder();
+ msg.append(this.dateFormat.format(Long.valueOf(record.getMillis())));
+ Level lvl = record.getLevel();
+
+ if (lvl == Level.FINEST) {
+ msg.append(" [FINEST] ");
+ } else if (lvl == Level.FINER) {
+ msg.append(" [FINER] ");
+ } else if (lvl == Level.FINE) {
+ msg.append(" [FINE] ");
+ } else if (lvl == Level.INFO) {
+ msg.append(" [INFO] ");
+ } else if (lvl == Level.WARNING) {
+ msg.append(" [WARNING] ");
+ } else if (lvl == Level.SEVERE) {
+ msg.append(" [SEVERE] ");
+ } else if (lvl == Level.SEVERE) {
+ msg.append(" [" + lvl.getLocalizedName() + "] ");
+ }
+
+ if (record.getSourceClassName() != null)
+ msg.append(record.getSourceClassName());
+
+ if (record.getSourceMethodName() != null) {
+ msg.append(' ');
+ msg.append(record.getSourceMethodName());
+ msg.append(' ');
+ }
+
+ if (record.getLoggerName() != null) {
+ msg.append("[" + record.getLoggerName() + "] ");
+ } else {
+ msg.append("[] ");
+ }
+ msg.append(formatMessage(record));
+ msg.append(LINE_SEPARATOR);
+ Throwable thr = record.getThrown();
+
+ if (thr != null) {
+ StringWriter thrDump = new StringWriter();
+ thr.printStackTrace(new PrintWriter(thrDump));
+ msg.append(thrDump.toString());
+ }
+
+ return msg.toString();
+ }
+}
View
43 PetrolCraft/src/petrolcraft/common/PacketGenerator.java
@@ -0,0 +1,43 @@
+package petrolcraft.common;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet250CustomPayload;
+import petrolcraft.machines.IMachineTileEntity;
+
+public class PacketGenerator {
+
+ public static Packet buildUpdatePacket(IMachineTileEntity pTileEntity) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ try {
+ dos.writeInt(1);
+ PetrolUpdatePacket updatePacket = new PetrolUpdatePacket(dos, pTileEntity.getActualTileEntity());
+ pTileEntity.writeUpdate(updatePacket);
+ dos.close();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ byte[] data = baos.toByteArray();
+ return new Packet250CustomPayload(Constants.sCHANNEL_NAME, data);
+ }
+
+ public static PetrolPacket parsePacket(Packet250CustomPayload pPacket) {
+ DataInputStream data = new DataInputStream(new ByteArrayInputStream(pPacket.data));
+ try {
+ int packetID = data.readInt();
+ switch (packetID) {
+ case 1:
+ return new PetrolUpdatePacket(data);
+ }
+ return null;
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
View
47 PetrolCraft/src/petrolcraft/common/PacketHandler.java
@@ -0,0 +1,47 @@
+package petrolcraft.common;
+
+import cpw.mods.fml.common.network.IPacketHandler;
+import cpw.mods.fml.common.network.Player;
+
+import java.io.IOException;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet250CustomPayload;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import petrolcraft.machines.PoweredTileEntity;
+
+public class PacketHandler implements IPacketHandler {
+
+ public PacketHandler() {
+ }
+
+ @Override
+ public void onPacketData(INetworkManager pManager, Packet250CustomPayload pPacket, Player pPlayer) {
+ PetrolPacket packet = PacketGenerator.parsePacket(pPacket);
+ if (packet instanceof PetrolUpdatePacket) {
+ PetrolUpdatePacket p = (PetrolUpdatePacket) packet;
+ World world = ((EntityPlayer) pPlayer).worldObj;
+ int x = p.getX();
+ int y = p.getY();
+ int z = p.getZ();
+ if (!world.blockExists(x, y, z))
+ return;
+
+ TileEntity entity = world.getBlockTileEntity(x, y, z);
+ if (!(entity instanceof PoweredTileEntity))
+ return;
+
+ PoweredTileEntity poweredEntity = (PoweredTileEntity) entity;
+
+ try {
+ poweredEntity.getMachineTileEntity().processUpdate(p);
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ }
+ }
+
+}
View
5 PetrolCraft/src/petrolcraft/common/PetrolPacket.java
@@ -0,0 +1,5 @@
+package petrolcraft.common;
+
+public class PetrolPacket {
+
+}
View
54 PetrolCraft/src/petrolcraft/common/PetrolUpdatePacket.java
@@ -0,0 +1,54 @@
+package petrolcraft.common;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import net.minecraft.tileentity.TileEntity;
+
+public class PetrolUpdatePacket extends PetrolPacket {
+
+ private int mX;
+ private int mY;
+ private int mZ;
+ private DataInputStream mReadStream;
+ private DataOutputStream mWriteStream;
+
+ public PetrolUpdatePacket(DataInputStream pData) throws IOException {
+ mReadStream = pData;
+ mX = pData.readInt();
+ mY = pData.readInt();
+ mZ = pData.readInt();
+ }
+
+ public PetrolUpdatePacket(DataOutputStream pData, TileEntity pEntity) throws IOException {
+ mWriteStream = pData;
+ mX = pEntity.xCoord;
+ mY = pEntity.yCoord;
+ mZ = pEntity.zCoord;
+ pData.writeInt(mX);
+ pData.writeInt(mY);
+ pData.writeInt(mZ);
+ }
+
+ public int getX() {
+ return mX;
+ }
+
+ public int getY() {
+ return mY;
+ }
+
+ public int getZ() {
+ return mZ;
+ }
+
+ public DataOutputStream getWriteStream() {
+ return mWriteStream;
+ }
+
+ public DataInputStream getReadStream() {
+ return mReadStream;
+ }
+
+}
View
14 PetrolCraft/src/petrolcraft/common/Textures.java
@@ -12,6 +12,20 @@
public static final int sOIL_EXTRACTOR_LEFT_ID = 16;
public static final int sOIL_EXTRACTOR_RIGHT_ID = 16;
+ public static final int sOIL_EXTRACTOR_ON_TOP_ID = 34;
+ public static final int sOIL_EXTRACTOR_ON_BOTTOM_ID = 32;
+ public static final int sOIL_EXTRACTOR_ON_FRONT_ID = 33;
+ public static final int sOIL_EXTRACTOR_ON_BACK_ID = 32;
+ public static final int sOIL_EXTRACTOR_ON_LEFT_ID = 32;
+ public static final int sOIL_EXTRACTOR_ON_RIGHT_ID = 32;
+
+ public static final int sOIL_EXTRACTOR_MID_TOP_ID = 50;
+ public static final int sOIL_EXTRACTOR_MID_BOTTOM_ID = 48;
+ public static final int sOIL_EXTRACTOR_MID_FRONT_ID = 49;
+ public static final int sOIL_EXTRACTOR_MID_BACK_ID = 48;
+ public static final int sOIL_EXTRACTOR_MID_LEFT_ID = 48;
+ public static final int sOIL_EXTRACTOR_MID_RIGHT_ID = 48;
+
public void setupRender() {
}
View
144 PetrolCraft/src/petrolcraft/common/TileEntityDelegate.java
@@ -0,0 +1,144 @@
+package petrolcraft.common;
+
+import net.minecraft.block.Block;
+import net.minecraft.crash.CrashReportCategory;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.INetworkManager;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+public class TileEntityDelegate extends TileEntity {
+
+ private TileEntity mDelegate;
+
+ public TileEntityDelegate(TileEntity pDelegate) {
+ super();
+ mDelegate = pDelegate;
+
+ worldObj = pDelegate.worldObj;
+ xCoord = pDelegate.xCoord;
+ yCoord = pDelegate.yCoord;
+ zCoord = pDelegate.zCoord;
+ blockMetadata = pDelegate.blockMetadata;
+ blockType = pDelegate.blockType;
+
+ }
+
+ public void updateInternals() {
+ worldObj = mDelegate.worldObj;
+ xCoord = mDelegate.xCoord;
+ yCoord = mDelegate.yCoord;
+ zCoord = mDelegate.zCoord;
+ blockMetadata = mDelegate.blockMetadata;
+ blockType = mDelegate.blockType;
+ }
+
+ public int hashCode() {
+ return mDelegate.hashCode();
+ }
+
+ public World getWorldObj() {
+ return mDelegate.getWorldObj();
+ }
+
+ public void setWorldObj(World pPar1World) {
+ mDelegate.setWorldObj(pPar1World);
+ worldObj = mDelegate.worldObj;
+ }
+
+ public boolean func_70309_m() {
+ return mDelegate.func_70309_m();
+ }
+
+ public void readFromNBT(NBTTagCompound pPar1nbtTagCompound) {
+ mDelegate.readFromNBT(pPar1nbtTagCompound);
+ }
+
+ public void writeToNBT(NBTTagCompound pPar1nbtTagCompound) {
+ mDelegate.writeToNBT(pPar1nbtTagCompound);
+ }
+
+ public void updateEntity() {
+ mDelegate.updateEntity();
+ }
+
+ public boolean equals(Object pObj) {
+ return mDelegate.equals(pObj);
+ }
+
+ public int getBlockMetadata() {
+ int result = mDelegate.getBlockMetadata();
+ blockMetadata = result;
+ return result;
+ }
+
+ public void onInventoryChanged() {
+ mDelegate.onInventoryChanged();
+ }
+
+ public double getDistanceFrom(double pPar1, double pPar3, double pPar5) {
+ return mDelegate.getDistanceFrom(pPar1, pPar3, pPar5);
+ }
+
+ public double func_82115_m() {
+ return mDelegate.func_82115_m();
+ }
+
+ public Block getBlockType() {
+ blockType = mDelegate.getBlockType();
+ return blockType;
+ }
+
+ public Packet getDescriptionPacket() {
+ return mDelegate.getDescriptionPacket();
+ }
+
+ public boolean isInvalid() {
+ return mDelegate.isInvalid();
+ }
+
+ public void invalidate() {
+ mDelegate.invalidate();
+ }
+
+ public void validate() {
+ mDelegate.validate();
+ }
+
+ public void receiveClientEvent(int pPar1, int pPar2) {
+ mDelegate.receiveClientEvent(pPar1, pPar2);
+ }
+
+ public void updateContainingBlockInfo() {
+ mDelegate.updateContainingBlockInfo();
+ blockType = mDelegate.blockType;
+ blockMetadata = mDelegate.blockMetadata;
+ }
+
+ public void func_85027_a(CrashReportCategory pPar1CrashReportCategory) {
+ mDelegate.func_85027_a(pPar1CrashReportCategory);
+ }
+
+ public boolean canUpdate() {
+ return mDelegate.canUpdate();
+ }
+
+ public void onDataPacket(INetworkManager pNet, Packet132TileEntityData pPkt) {
+ mDelegate.onDataPacket(pNet, pPkt);
+ }
+
+ public String toString() {
+ return mDelegate.toString();
+ }
+
+ public void onChunkUnload() {
+ mDelegate.onChunkUnload();
+ }
+
+ public boolean shouldRefresh(int pOldID, int pNewID, int pOldMeta, int pNewMeta, World pWorld, int pX, int pY, int pZ) {
+ return mDelegate.shouldRefresh(pOldID, pNewID, pOldMeta, pNewMeta, pWorld, pX, pY, pZ);
+ }
+
+}
View
50 PetrolCraft/src/petrolcraft/machines/IMachineTileEntity.java
@@ -0,0 +1,50 @@
+package petrolcraft.machines;
+
+import java.io.IOException;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import petrolcraft.common.PetrolUpdatePacket;
+import petrolcraft.power.IEnergyConsumer;
+
+public interface IMachineTileEntity {
+
+ /**
+ * Reads a tile entity from NBT.
+ */
+ public void readFromNBT(NBTTagCompound par1NBTTagCompound);
+
+ /**
+ * Writes a tile entity to NBT.
+ */
+ public void writeToNBT(NBTTagCompound par1NBTTagCompound);
+
+ public TileEntity getActualTileEntity();
+
+ /**
+ * Allows the entity to update its state. Overridden in most subclasses,
+ * e.g. the mob spawner uses this to count ticks and creates a new spawn
+ * inside its implementation.
+ */
+ public void updateEntity();
+
+ /**
+ * Called when an the contents of an Inventory change, usually
+ */
+ public void onInventoryChanged();
+
+ /**
+ * Determines if this TileEntity requires update calls.
+ *
+ * @return True if you want updateEntity() to be called, false if not
+ */
+ public boolean canUpdate();
+
+ public IEnergyConsumer getEnergyConsumer();
+
+ public int getMetadata();
+
+ public void writeUpdate(PetrolUpdatePacket pUpdatePacket) throws IOException;
+
+ public void processUpdate(PetrolUpdatePacket pUpdatePacket) throws IOException;
+}
View
19 PetrolCraft/src/petrolcraft/machines/Machines.java
@@ -1,9 +1,13 @@
package petrolcraft.machines;
+import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.item.ItemBlock;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
import petrolcraft.Mod_PetrolCraft;
+import petrolcraft.power.bc.BCPoweredTileEntity;
public class Machines {
public static OilExtractorBlock sOilExtractor;
@@ -16,8 +20,21 @@ public static void init() {
sOilExtractor = new OilExtractorBlock(Mod_PetrolCraft.sConfig.getBlock("Oil_Extractor_Block_ID",
sDEFAULT_MACHINE_BLOCK_START_ID + 1, "Oil Extractor Block ID").getInt());
- GameRegistry.registerTileEntity(OilExtractorTileEntity.class, sOilExtractor.getBlockName());
+ GameRegistry.registerTileEntity(getPoweredTileEntityClass(), sOilExtractor.getBlockName());
GameRegistry.registerBlock(sOilExtractor, ItemBlock.class, sOilExtractor.getBlockName(), Mod_PetrolCraft.sMOD_ID);
+ ClientRegistry.bindTileEntitySpecialRenderer(getPoweredTileEntityClass(), new OilExtractorRenderer());
LanguageRegistry.addName(sOilExtractor, "Oil Extractor");
}
+
+ public static Class<? extends TileEntity> getPoweredTileEntityClass() {
+ return BCPoweredTileEntity.class;
+ }
+
+ public static PoweredTileEntity createPoweredTileEntity(World pWorld, int pMetadata) {
+ return new BCPoweredTileEntity(pWorld, pMetadata);
+ }
+
+ public static IMachineTileEntity createMachineTileEntity(TileEntity pTileEntity, int pMetadata) {
+ return new OilExtractorTileEntity(pTileEntity);
+ }
}
View
35 PetrolCraft/src/petrolcraft/machines/OilExtractorBlock.java
@@ -19,6 +19,19 @@ public OilExtractorBlock(int pBlockID) {
setStepSound(soundMetalFootstep);
}
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ private int view = 0;
+ private long lastFlip = System.currentTimeMillis();
+
/**
* 0 -bottom 1 - top 2 - left 3 - right 4 - front 5 - back
*
@@ -26,21 +39,27 @@ public OilExtractorBlock(int pBlockID) {
*/
@Override
public int getBlockTextureFromSide(int pSide) {
+ if (System.currentTimeMillis() - lastFlip > 1000) {
+ view += 16;
+ if (view > 32)
+ view = 0;
+ lastFlip = System.currentTimeMillis();
+ }
switch (pSide) {
case 0:
- return Textures.sOIL_EXTRACTOR_BOTTOM_ID;
+ return Textures.sOIL_EXTRACTOR_BOTTOM_ID + view;
case 1:
- return Textures.sOIL_EXTRACTOR_TOP_ID;
+ return Textures.sOIL_EXTRACTOR_TOP_ID + view;
case 2:
- return Textures.sOIL_EXTRACTOR_LEFT_ID;
+ return Textures.sOIL_EXTRACTOR_LEFT_ID + view;
case 3:
- return Textures.sOIL_EXTRACTOR_RIGHT_ID;
+ return Textures.sOIL_EXTRACTOR_RIGHT_ID + view;
case 4:
- return Textures.sOIL_EXTRACTOR_FRONT_ID;
+ return Textures.sOIL_EXTRACTOR_FRONT_ID + view;
case 5:
- return Textures.sOIL_EXTRACTOR_BACK_ID;
+ return Textures.sOIL_EXTRACTOR_BACK_ID + view;
default:
- return Textures.sOIL_EXTRACTOR_BOTTOM_ID;
+ return Textures.sOIL_EXTRACTOR_BOTTOM_ID + view;
}
}
@@ -79,7 +98,7 @@ public boolean hasTileEntity(int pMetadata) {
*/
@Override
public TileEntity createTileEntity(World pWorld, int pMetadata) {
- return new OilExtractorTileEntity(pWorld, pMetadata);
+ return Machines.createPoweredTileEntity(pWorld, pMetadata);
}
/**
View
70 PetrolCraft/src/petrolcraft/machines/OilExtractorRenderer.java
@@ -0,0 +1,70 @@
+package petrolcraft.machines;
+
+import java.io.InputStream;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+
+import org.lwjgl.opengl.GL11;
+
+import petrolcraft.render.ModelParser;
+import petrolcraft.render.OpenGLRenderer;
+
+public class OilExtractorRenderer extends TileEntitySpecialRenderer {
+ private static final Logger sLog = Logger.getLogger("PetrolCraft");
+ private static final String sClassName = OilExtractorRenderer.class.getName();
+
+ private OpenGLRenderer mObj1;
+ private OpenGLRenderer mObj2;
+ private OpenGLRenderer mObj3;
+ private OpenGLRenderer mObj4;
+
+ private float mAngle = 0;
+ private long mLastChange = System.currentTimeMillis();
+
+ public OilExtractorRenderer() {
+ super();
+ InputStream pStream1 = OilExtractorRenderer.class.getResourceAsStream("/gfx/model/OilExtractor.obj");
+ InputStream pStream2 = OilExtractorRenderer.class.getResourceAsStream("/gfx/model/OilExtractor.obj");
+ Map<String, OpenGLRenderer> map = ModelParser.parse(pStream1, pStream2);
+ mObj1 = map.get("pCube1");
+ mObj2 = map.get("pCube2");
+ mObj3 = map.get("pCube3");
+ mObj4 = map.get("pCylinder1");
+ }
+
+ @Override
+ public void renderTileEntityAt(TileEntity pEntity, double pX, double pY, double pZ, float pF) {
+ sLog.entering(sClassName, "renderTileEntityAt", new Object[] { pX, pY, pZ, pF });
+
+ GL11.glPushMatrix();
+ GL11.glDisable(2896 /* GL_LIGHTING */);
+
+ GL11.glTranslatef((float) pX, (float) pY + 3, (float) pZ);
+ mObj1.render(1.0F);
+
+ if (System.currentTimeMillis() - mLastChange > 50) {
+ mLastChange = System.currentTimeMillis();
+ mAngle += 0.15;
+ }
+ mObj2.rotationPointY = 0.0F;
+ mObj2.rotateAngleX = mAngle;
+
+ mObj2.render(1.0F);
+ mObj3.render(1.0F);
+ mObj4.render(1.0F);
+ // GL11.glColor3f(0, 1, 0);
+ // mObj1.renderParts();
+ // GL11.glColor3f(1, 0, 0);
+ // mObj2.renderParts();
+ // GL11.glColor3f(0, 0, 1);
+ // mObj3.renderParts();
+ // GL11.glColor3f(1, 1, 1);
+ // mObj4.renderParts();
+ GL11.glEnable(2896 /* GL_LIGHTING */);
+ GL11.glPopMatrix();
+
+ }
+}
View
157 PetrolCraft/src/petrolcraft/machines/OilExtractorTileEntity.java
@@ -1,71 +1,162 @@
package petrolcraft.machines;
-import ic2.api.Direction;
-import ic2.api.energy.EnergyNet;
-import ic2.api.energy.tile.IEnergySink;
+import cpw.mods.fml.common.FMLCommonHandler;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
-import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeDirection;
+import petrolcraft.common.PacketGenerator;
+import petrolcraft.common.PetrolUpdatePacket;
+import petrolcraft.power.IEnergyConsumer;
+
+public class OilExtractorTileEntity implements IEnergyConsumer, IMachineTileEntity {
-public class OilExtractorTileEntity extends TileEntity implements IEnergySink {
+ private static final Logger sLog = Logger.getLogger("PetrolCraft");
+ private static final String sClassName = OilExtractorTileEntity.class.getName();
private int mStoredEnergy = 0;
private int mMaxEnergy = 3000;
+ private TileEntity mTileEntity;
- public OilExtractorTileEntity(World pWorld, int pMetadata) {
- System.out.println("new entity");
+ public OilExtractorTileEntity(TileEntity pTileEntity) {
+ sLog.entering(sClassName, "OilExtractorTileEntity");
+ mTileEntity = pTileEntity;
+ sLog.exiting(sClassName, "OilExtractorTileEntity");
}
- public OilExtractorTileEntity() {
+ @Override
+ public int getMetadata() {
+ return 0;
+ }
+ public TileEntity getActualTileEntity() {
+ return mTileEntity;
}
@Override
- public boolean acceptsEnergyFrom(TileEntity pEntity, Direction pDir) {
- System.out.println(toString() + " acceptsEnergyFrom");
- return true;
+ public void writeUpdate(PetrolUpdatePacket pPacket) throws IOException {
+ DataOutputStream stream = pPacket.getWriteStream();
+ stream.writeInt(mStoredEnergy);
+ stream.writeInt(mMaxEnergy);
}
@Override
- public boolean isAddedToEnergyNet() {
- System.out.println(toString() + " isAddedToEnergyNet");
- return true;
+ public void processUpdate(PetrolUpdatePacket pUpdatePacket) throws IOException {
+ sLog.entering(sClassName, "processUpdate", FMLCommonHandler.instance().getEffectiveSide());
+ DataInputStream stream = pUpdatePacket.getReadStream();
+ mStoredEnergy = stream.readInt();
+ mMaxEnergy = stream.readInt();
+ mTileEntity.getWorldObj().markBlockForUpdate(mTileEntity.xCoord, mTileEntity.yCoord, mTileEntity.zCoord);
+ }
+
+ /**
+ * @see petrolcraft.power.IEnergyConsumer#getDescriptionPacket()
+ */
+ @Override
+ public Packet getDescriptionPacket() {
+ sLog.entering(sClassName, "getDescriptionPacket");
+ return PacketGenerator.buildUpdatePacket(this);
}
+ /**
+ * We'll accept energy from any direction
+ *
+ * @see petrolcraft.power.IEnergyConsumer#acceptEnergyFrom(net.minecraft.tileentity.TileEntity,
+ * net.minecraftforge.common.ForgeDirection)
+ */
@Override
- public int injectEnergy(Direction pEntity, int pAmount) {
- int consumable = Math.min(pAmount, mMaxEnergy - mStoredEnergy);
+ public boolean acceptEnergyFrom(TileEntity pEntity, ForgeDirection pDirection) {
+ // sLog.entering(sClassName, "acceptEnergyFrom", pDirection);
+ boolean result = true;
+ // sLog.exiting(sClassName, "acceptEnergyFrom", result);
+ return result;
+ }
+
+ /**
+ * Return the amount of energy room left in the internal batteries
+ *
+ * @see petrolcraft.power.IEnergyConsumer#getAcceptedEnergyAmount()
+ */
+ @Override
+ public int getAcceptedEnergyAmount() {
+ // sLog.entering(sClassName, "getAcceptedEnergyAmount");
+ int result = mMaxEnergy - mStoredEnergy;
+ // sLog.exiting(sClassName, "getAcceptedEnergyAmount", result);
+ return result;
+ }
+
+ /**
+ * Accept energy from the connected power source
+ *
+ * @see petrolcraft.power.IEnergyConsumer#addEnergy(net.minecraftforge.common.ForgeDirection,
+ * int)
+ */
+ @Override
+ public int addEnergy(ForgeDirection pForgeDirection, int pEnergy) {
+ sLog.entering(sClassName, "addEnergy", new Object[] { pForgeDirection.name(), pEnergy, mTileEntity.getWorldObj().isRemote });
+ int consumable = Math.min(pEnergy, mMaxEnergy - mStoredEnergy);
mStoredEnergy += consumable;
+ mTileEntity.getWorldObj().markBlockForUpdate(mTileEntity.xCoord, mTileEntity.yCoord, mTileEntity.zCoord);
if ((consumable > 0) && (mStoredEnergy == mMaxEnergy))
System.out.println("Extractor energy full");
- return pAmount - consumable;
+ int result = pEnergy - consumable;
+ sLog.exiting(sClassName, "addEnergy", result);
+ return result;
}
- @SuppressWarnings("deprecation")
+ /**
+ * Return the amount of power that we can accept. Currently, we'll accept
+ * any power
+ *
+ * @see petrolcraft.power.IEnergyConsumer#getMaxSafeInput()
+ */
@Override
- public void invalidate() {
- System.out.println(toString() + " invalidate");
- EnergyNet.getForWorld(getWorldObj()).removeTileEntity(this);
- super.invalidate();
+ public int getMaxSafeInput() {
+ sLog.entering(sClassName, "getMaxSafeInput");
+ return Integer.MAX_VALUE;
}
- @SuppressWarnings("deprecation")
@Override
- public void validate() {
- System.out.println(toString() + " validate");
- super.validate();
- EnergyNet.getForWorld(getWorldObj()).addTileEntity(this);
+ public void readFromNBT(NBTTagCompound pTags) {
+ mMaxEnergy = pTags.getInteger("pc_maxEnergy");
+ mStoredEnergy = pTags.getInteger("pc_storedEnergy");
}
@Override
- public int demandsEnergy() {
- System.out.println(this.toString() + " demandsEnergy " + String.valueOf(mStoredEnergy));
- return mMaxEnergy - mStoredEnergy;
+ public void writeToNBT(NBTTagCompound pTags) {
+ pTags.setInteger("pc_maxEnergy", mMaxEnergy);
+ pTags.setInteger("pc_storedEnergy", mStoredEnergy);
}
@Override
- public int getMaxSafeInput() {
- System.out.println(toString() + " getMaxSafeInput");
- return Integer.MAX_VALUE;
+ public void updateEntity() {
+
+ }
+
+ @Override
+ public void onInventoryChanged() {
+
+ }
+
+ @Override
+ public boolean canUpdate() {
+ return true;
+ }
+
+ @Override
+ public IEnergyConsumer getEnergyConsumer() {
+ return this;
+ }
+
+ @Override
+ public int getMaxStorage() {
+ return mMaxEnergy;
}
}
View
97 PetrolCraft/src/petrolcraft/machines/PoweredTileEntity.java
@@ -0,0 +1,97 @@
+package petrolcraft.machines;
+
+import java.util.logging.Logger;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.packet.Packet;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import petrolcraft.power.IEnergyConsumer;
+
+public class PoweredTileEntity extends TileEntity {
+
+ private static final Logger sLog = Logger.getLogger("PetrolCraft");
+ private static final String sClassName = PoweredTileEntity.class.getName();
+
+ protected IMachineTileEntity mActualTileEntity;
+ protected IEnergyConsumer mConsumer;
+
+ public PoweredTileEntity(World pWorld, int pMetadata) {
+ sLog.entering(sClassName, "PoweredTileEntity", pMetadata);
+ setWorldObj(pWorld);
+ mActualTileEntity = Machines.createMachineTileEntity(this, pMetadata);
+ mConsumer = mActualTileEntity.getEnergyConsumer();
+ sLog.exiting(sClassName, "PoweredTileEntity");
+ }
+
+ public PoweredTileEntity() {
+ sLog.entering(sClassName, "PoweredTileEntity");
+ sLog.exiting(sClassName, "PoweredTileEntity");
+ }
+
+ public IEnergyConsumer getConsumer() {
+ return mConsumer;
+ }
+
+ public IMachineTileEntity getMachineTileEntity() {
+ return mActualTileEntity;
+ }
+
+ /**
+ * @see net.minecraft.tileentity.TileEntity#getDescriptionPacket()
+ */
+ @Override
+ public Packet getDescriptionPacket() {
+ return mConsumer.getDescriptionPacket();
+ }
+
+ /**
+ * @see net.minecraft.tileentity.TileEntity#readFromNBT(net.minecraft.nbt.NBTTagCompound)
+ */
+ @Override
+ public void readFromNBT(NBTTagCompound pPar1nbtTagCompound) {
+ sLog.entering(sClassName, "readFromNBT");
+ super.readFromNBT(pPar1nbtTagCompound);
+ int metadata = pPar1nbtTagCompound.getInteger("metadata");
+ mActualTileEntity = Machines.createMachineTileEntity(this, metadata);
+ mActualTileEntity.readFromNBT(pPar1nbtTagCompound);
+ mConsumer = mActualTileEntity.getEnergyConsumer();
+ sLog.exiting(sClassName, "readFromNBT");
+ }
+
+ /**
+ * @see net.minecraft.tileentity.TileEntity#writeToNBT(net.minecraft.nbt.NBTTagCompound)
+ */
+ @Override
+ public void writeToNBT(NBTTagCompound pPar1nbtTagCompound) {
+ sLog.entering(sClassName, "writeToNBT");
+ super.writeToNBT(pPar1nbtTagCompound);
+ pPar1nbtTagCompound.setInteger("metadata", mActualTileEntity.getMetadata());
+ mActualTileEntity.writeToNBT(pPar1nbtTagCompound);
+ sLog.exiting(sClassName, "writeToNBT");
+ }
+
+ /**
+ * @see net.minecraft.tileentity.TileEntity#updateEntity()
+ */
+ @Override
+ public void updateEntity() {
+ mActualTileEntity.updateEntity();
+ }
+
+ /**
+ * @see net.minecraft.tileentity.TileEntity#onInventoryChanged()
+ */
+ @Override
+ public void onInventoryChanged() {
+ mActualTileEntity.onInventoryChanged();
+ }
+
+ /**
+ * @see net.minecraft.tileentity.TileEntity#canUpdate()
+ */
+ @Override
+ public boolean canUpdate() {
+ return mActualTileEntity.canUpdate();
+ }
+}
View
33 PetrolCraft/src/petrolcraft/power/IEnergyConsumer.java
@@ -0,0 +1,33 @@
+package petrolcraft.power;
+
+import net.minecraft.network.packet.Packet;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.ForgeDirection;
+
+public interface IEnergyConsumer {
+ /**
+ * Will this consumer accept a power connection from this direction
+ * @param pEmitter
+ *
+ * @param pDirection
+ * the direction
+ * @return true or false
+ */
+ public boolean acceptEnergyFrom(TileEntity pEmitter, ForgeDirection pDirection);
+
+ /**
+ * Returns the amount of energy that this consumer will accept
+ *
+ * @return
+ */
+ public int getAcceptedEnergyAmount();
+
+ public int addEnergy(ForgeDirection pForgeDirection, int pEnergy);
+
+ public int getMaxSafeInput();
+
+ public int getMaxStorage();
+
+ public Packet getDescriptionPacket();
+
+}
View
28 PetrolCraft/src/petrolcraft/power/PowerAdapter.java
@@ -0,0 +1,28 @@
+package petrolcraft.power;
+
+import net.minecraft.tileentity.TileEntity;
+import petrolcraft.power.ic2.IC2EnergyConsumer;
+
+public class PowerAdapter {
+
+ private IC2EnergyConsumer mIC2Consumer;
+
+ public PowerAdapter(TileEntity pEntity, IEnergyConsumer pConsumer) {
+ mIC2Consumer = new IC2EnergyConsumer(pEntity, pConsumer);
+ }
+
+ public void disable() {
+ if (mIC2Consumer != null)
+ mIC2Consumer.disable();
+ }
+
+ public void enable() {
+ if (mIC2Consumer != null)
+ mIC2Consumer.enable();
+ }
+
+ public void updateInternals() {
+ if (mIC2Consumer != null)
+ mIC2Consumer.updateInternals();
+ }
+}
View
30 PetrolCraft/src/petrolcraft/power/PowerConversion.java
@@ -0,0 +1,30 @@
+package petrolcraft.power;
+
+public class PowerConversion {
+
+ private static final double sENERGY_TO_MJ = 1.0D;
+ public static double sENERGY_TO_EU = 1.0D;
+
+ /**
+ * Converts petrol energy to EU energy
+ *
+ * @param pPetrolEnergy
+ * @return
+ */
+ public static int convertToEU(int pPetrolEnergy) {
+ return (int) (pPetrolEnergy * sENERGY_TO_EU);
+ }
+
+ public static int convertFromEU(int pEU) {
+ return (int) (pEU / sENERGY_TO_EU);
+ }
+
+ public static int convertToMJ(int pPetrolEnergy) {
+ return (int) (pPetrolEnergy * sENERGY_TO_MJ);
+ }
+
+ public static int convertFromMJ(float pQuantity) {
+ return (int) (pQuantity / sENERGY_TO_MJ);
+ }
+
+}
View
90 PetrolCraft/src/petrolcraft/power/bc/BCPoweredTileEntity.java
@@ -0,0 +1,90 @@
+package petrolcraft.power.bc;
+
+import buildcraft.api.power.IPowerProvider;
+import buildcraft.api.power.IPowerReceptor;
+import buildcraft.api.power.PowerFramework;
+
+import java.util.logging.Logger;
+
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+import petrolcraft.machines.PoweredTileEntity;
+import petrolcraft.power.PowerConversion;
+
+public class BCPoweredTileEntity extends PoweredTileEntity implements IPowerReceptor {
+
+ private static final Logger sLog = Logger.getLogger("PetrolCraft");
+ private static final String sClassName = BCPoweredTileEntity.class.getName();
+
+ private IPowerProvider mProvider;
+
+ public BCPoweredTileEntity(World pWorld, int pMetadata) {
+ super(pWorld, pMetadata);
+ mProvider = new PetrolBCPowerProvider(this);
+ mProvider.configure(0, 0, PowerConversion.convertToMJ(mConsumer.getAcceptedEnergyAmount()), 0,
+ PowerConversion.convertToMJ(mConsumer.getMaxStorage()));
+ }
+
+ public BCPoweredTileEntity() {
+ mProvider = new PetrolBCPowerProvider(this);
+ }
+
+ /**
+ * @see petrolcraft.machines.PoweredTileEntity#readFromNBT(net.minecraft.nbt.NBTTagCompound)
+ */
+ @Override
+ public void readFromNBT(NBTTagCompound pTags) {
+ super.readFromNBT(pTags);
+ PowerFramework.currentFramework.loadPowerProvider(this, pTags);
+ }
+
+ /**
+ * @see petrolcraft.machines.PoweredTileEntity#writeToNBT(net.minecraft.nbt.NBTTagCompound)
+ */
+ @Override
+ public void writeToNBT(NBTTagCompound pTags) {
+ super.writeToNBT(pTags);
+ PowerFramework.currentFramework.savePowerProvider(this, pTags);
+ }
+
+ /**
+ * @see buildcraft.api.power.IPowerReceptor#setPowerProvider(buildcraft.api.power.IPowerProvider)
+ */
+ @Override
+ public void setPowerProvider(IPowerProvider pProvider) {
+ if (pProvider instanceof PetrolBCPowerProvider)
+ mProvider = pProvider;
+ else
+ mProvider = new PetrolBCPowerProvider(this, pProvider);
+ }
+
+ /**
+ * @see buildcraft.api.power.IPowerReceptor#getPowerProvider()
+ */
+ @Override
+ public IPowerProvider getPowerProvider() {
+ return mProvider;
+ }
+
+ /**
+ * @see buildcraft.api.power.IPowerReceptor#doWork()
+ */
+ @Override
+ public void doWork() {
+ /* We don't do any work. We'll handle work in our update routine */
+ }
+
+ /**
+ * @see buildcraft.api.power.IPowerReceptor#powerRequest()
+ */
+ @Override
+ public int powerRequest() {
+ // sLog.entering(sClassName, "powerRequest");
+ if (mConsumer == null)
+ sLog.warning("Consumer is null");
+ int result = (mConsumer == null ? 0 : PowerConversion.convertToMJ(mConsumer.getAcceptedEnergyAmount()));
+ // sLog.exiting(sClassName, "powerRequest", result);
+ return result;
+ }
+
+}
View
105 PetrolCraft/src/petrolcraft/power/bc/PetrolBCPowerProvider.java
@@ -0,0 +1,105 @@
+package petrolcraft.power.bc;
+
+import buildcraft.api.core.SafeTimeTracker;
+import buildcraft.api.power.IPowerProvider;
+import buildcraft.api.power.IPowerReceptor;
+import buildcraft.api.power.PowerFramework;
+import buildcraft.api.power.PowerProvider;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.ForgeDirection;
+import petrolcraft.power.IEnergyConsumer;
+import petrolcraft.power.PowerConversion;
+
+public class PetrolBCPowerProvider extends PowerProvider {
+
+ private IPowerProvider mDelegate;
+ private BCPoweredTileEntity mPoweredTileEntity;
+
+ public PetrolBCPowerProvider(BCPoweredTileEntity pPoweredTileEntity) {
+ super();
+ mPoweredTileEntity = pPoweredTileEntity;
+ if (PowerFramework.currentFramework != null)
+ mDelegate = PowerFramework.currentFramework.createPowerProvider();
+ }
+
+ public PetrolBCPowerProvider(BCPoweredTileEntity pPoweredTileEntity, IPowerProvider pProvider) {
+ super();
+ mPoweredTileEntity = pPoweredTileEntity;
+ mDelegate = pProvider;
+ }
+
+ public int getLatency() {
+ return mDelegate.getLatency();
+ }
+
+ public int getMinEnergyReceived() {
+ return mDelegate.getMinEnergyReceived();
+ }
+
+ public int getMaxEnergyReceived() {
+ return mDelegate.getMaxEnergyReceived();
+ }
+
+ public int getMaxEnergyStored() {
+ return mDelegate.getMaxEnergyStored();
+ }
+
+ public int getActivationEnergy() {
+ return mDelegate.getActivationEnergy();
+ }
+
+ public float getEnergyStored() {
+ return mDelegate.getEnergyStored();
+ }
+
+ public void configure(int pLatency, int pMinEnergyReceived, int pMaxEnergyReceived, int pMinActivationEnergy, int pMaxStoredEnergy) {
+ mDelegate.configure(pLatency, pMinEnergyReceived, pMaxEnergyReceived, pMinActivationEnergy, pMaxStoredEnergy);
+ }
+
+ public void configurePowerPerdition(int pPowerLoss, int pPowerLossRegularity) {
+ mDelegate.configurePowerPerdition(pPowerLoss, pPowerLossRegularity);
+ }
+
+ public boolean update(IPowerReceptor pReceptor) {
+ return mDelegate.update(pReceptor);
+ }
+
+ /**
+ * @see buildcraft.api.power.PowerProvider#preConditions(buildcraft.api.power.IPowerReceptor)
+ */
+ public boolean preConditions(IPowerReceptor pReceptor) {
+ return mDelegate.preConditions(pReceptor);
+ }
+
+ public float useEnergy(float pMin, float pMax, boolean pDoUse) {
+ return mDelegate.useEnergy(pMin, pMax, pDoUse);
+ }
+
+ public void readFromNBT(NBTTagCompound pNbttagcompound) {
+ mDelegate.readFromNBT(pNbttagcompound);
+ }
+
+ public void writeToNBT(NBTTagCompound pNbttagcompound) {
+ mDelegate.writeToNBT(pNbttagcompound);
+ }
+
+ public void receiveEnergy(float pQuantity, ForgeDirection pFrom) {
+ IEnergyConsumer consumer = mPoweredTileEntity.getConsumer();
+ if (consumer.acceptEnergyFrom(null, pFrom) == true) {
+ mDelegate.receiveEnergy(pQuantity, pFrom);
+ int petrolPower = PowerConversion.convertFromMJ(pQuantity);
+ int remainingEnergy = consumer.addEnergy(pFrom, petrolPower);
+ int usedPower = petrolPower - remainingEnergy;
+ mDelegate.useEnergy(0, PowerConversion.convertToMJ(usedPower), true);
+ }
+ }
+
+ public boolean isPowerSource(ForgeDirection pFrom) {
+ return mDelegate.isPowerSource(pFrom);
+ }
+
+ public SafeTimeTracker getTimeTracker() {
+ return mDelegate.getTimeTracker();
+ }
+
+}
View
101 PetrolCraft/src/petrolcraft/power/ic2/IC2EnergyConsumer.java
@@ -0,0 +1,101 @@
+package petrolcraft.power.ic2;
+
+import ic2.api.Direction;
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+
+import java.util.logging.Logger;
+
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.MinecraftForge;
+import petrolcraft.common.TileEntityDelegate;
+import petrolcraft.power.IEnergyConsumer;
+import petrolcraft.power.PowerConversion;
+
+public class IC2EnergyConsumer extends TileEntityDelegate implements IEnergySink {
+
+ private static final Logger sLog = Logger.getLogger("PetrolCraft");
+ private static final String sClassName = IC2EnergyConsumer.class.getName();
+
+ private IEnergyConsumer mConsumer;
+ private boolean mIsAddedToNet = false;
+
+ public IC2EnergyConsumer(TileEntity pEntity, IEnergyConsumer pConsumer) {
+ super(pEntity);
+ mConsumer = pConsumer;
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergyAcceptor#acceptsEnergyFrom(net.minecraft.tileentity.TileEntity,
+ * ic2.api.Direction)
+ */
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity pEmitter, Direction pDirection) {
+ sLog.entering(sClassName, "acceptsEnergyFrom");
+ return mConsumer.acceptEnergyFrom(pEmitter, pDirection.toForgeDirection());
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergyTile#isAddedToEnergyNet()
+ */
+ @Override
+ public boolean isAddedToEnergyNet() {
+ sLog.entering(sClassName, "isAddedToEnergyNet");
+ return mIsAddedToNet;
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergySink#demandsEnergy()
+ */
+ @Override
+ public int demandsEnergy() {
+ sLog.entering(sClassName, "demandsEnergy");
+ return PowerConversion.convertToEU(mConsumer.getAcceptedEnergyAmount());
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergySink#injectEnergy(ic2.api.Direction, int)
+ */
+ @Override
+ public int injectEnergy(Direction pDirectionFrom, int pAmount) {
+ sLog.entering(sClassName, "injectEnergy");
+ return PowerConversion.convertToEU(mConsumer.addEnergy(pDirectionFrom.toForgeDirection(), PowerConversion.convertFromEU(pAmount)));
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergySink#getMaxSafeInput()
+ */
+ @Override
+ public int getMaxSafeInput() {
+ sLog.entering(sClassName, "getMaxSafeInput");
+ int eu = PowerConversion.convertToEU(mConsumer.getMaxSafeInput());
+ if (eu <= 32)
+ return 32;
+ if (eu <= 128)
+ return 128;
+ if (eu <= 512)
+ return 512;
+ if (eu <= 2048)
+ return 2048;
+ if (eu <= 8192)
+ return 8192;
+ return eu;
+ }
+
+ public void disable() {
+ sLog.entering(sClassName, "disable");
+ if (mIsAddedToNet == true) {
+ mIsAddedToNet = false;
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ }
+ }
+
+ public void enable() {
+ sLog.entering(sClassName, "enable");
+ if (mIsAddedToNet == false) {
+ mIsAddedToNet = true;
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ }
+ }
+}
View
102 PetrolCraft/src/petrolcraft/power/ic2/IC2PoweredTileEntity.java
@@ -0,0 +1,102 @@
+package petrolcraft.power.ic2;
+
+import ic2.api.Direction;
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+
+import java.util.logging.Logger;
+
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.MinecraftForge;
+import petrolcraft.machines.PoweredTileEntity;
+import petrolcraft.power.IEnergyConsumer;
+import petrolcraft.power.PowerConversion;
+
+public class IC2PoweredTileEntity extends PoweredTileEntity implements IEnergySink {
+
+ private static final Logger sLog = Logger.getLogger("PetrolCraft");
+ private static final String sClassName = IC2PoweredTileEntity.class.getName();
+
+ private IEnergyConsumer mConsumer;
+ private boolean mIsAddedToNet = false;
+
+ /**
+ * @see ic2.api.energy.tile.IEnergyAcceptor#acceptsEnergyFrom(net.minecraft.tileentity.TileEntity,
+ * ic2.api.Direction)
+ */
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity pEmitter, Direction pDirection) {
+ sLog.entering(sClassName, "acceptsEnergyFrom");
+ boolean result = mConsumer.acceptEnergyFrom(pEmitter, pDirection.toForgeDirection());
+ sLog.exiting(sClassName, "acceptsEnergyFrom", result);
+ return result;
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergyTile#isAddedToEnergyNet()
+ */
+ @Override
+ public boolean isAddedToEnergyNet() {
+ sLog.entering(sClassName, "isAddedToEnergyNet");
+ boolean result = mIsAddedToNet;
+ sLog.exiting(sClassName, "isAddedToEnergyNet", result);
+ return result;
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergySink#demandsEnergy()
+ */
+ @Override
+ public int demandsEnergy() {
+ sLog.entering(sClassName, "demandsEnergy");
+ int result = PowerConversion.convertToEU(mConsumer.getAcceptedEnergyAmount());
+ sLog.exiting(sClassName, "demandsEnergy", result);
+ return result;
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergySink#injectEnergy(ic2.api.Direction, int)
+ */
+ @Override
+ public int injectEnergy(Direction pDirectionFrom, int pAmount) {
+ sLog.entering(sClassName, "injectEnergy");
+ return PowerConversion.convertToEU(mConsumer.addEnergy(pDirectionFrom.toForgeDirection(), PowerConversion.convertFromEU(pAmount)));
+ }
+
+ /**
+ * @see ic2.api.energy.tile.IEnergySink#getMaxSafeInput()
+ */
+ @Override
+ public int getMaxSafeInput() {
+ sLog.entering(sClassName, "getMaxSafeInput");
+ int eu = PowerConversion.convertToEU(mConsumer.getMaxSafeInput());
+ if (eu <= 32)
+ return 32;
+ if (eu <= 128)
+ return 128;
+ if (eu <= 512)
+ return 512;
+ if (eu <= 2048)
+ return 2048;
+ if (eu <= 8192)
+ return 8192;
+ return eu;
+ }
+
+ public void disable() {
+ sLog.entering(sClassName, "disable");
+ if (mIsAddedToNet == true) {
+ mIsAddedToNet = false;
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ }
+ }
+
+ public void enable() {
+ sLog.entering(sClassName, "enable");
+ if (mIsAddedToNet == false) {
+ mIsAddedToNet = true;
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ }
+ }
+}
View
119 PetrolCraft/src/petrolcraft/render/ModelParser.java
@@ -0,0 +1,119 @@
+package petrolcraft.render;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ModelParser {
+
+ public static Map<String, OpenGLRenderer> parse(InputStream pStream1, InputStream pStream2) {
+ try {
+ String line;
+
+ /* First walk through the file to find the counts */
+
+ int vertexCount = 0;
+ int textureCount = 0;
+ int normalCount = 0;
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(pStream1));
+ try {
+ while ((line = br.readLine()) != null) {
+ if (line.startsWith("v "))
+ vertexCount++;
+ if (line.startsWith("vt "))
+ textureCount++;
+ if (line.startsWith("vn "))
+ normalCount++;
+ }
+ } finally {
+ br.close();
+ }
+
+ /* Now parse the file into the buffers */
+
+ Map<String, OpenGLRenderer> modelList = new HashMap<String, OpenGLRenderer>();
+ String objName = null;
+
+ double[][] vertexData = new double[vertexCount][3];
+ double[][] textureData = new double[textureCount][3];
+ float[][] normalData = new float[normalCount][3];
+ List<VertexData> dataList = new ArrayList<VertexData>();
+ int vertexOffset = -1;
+ int textureOffset = -1;
+ int normalOffset = -1;
+ br = new BufferedReader(new InputStreamReader(pStream2));
+ try {
+ while ((line = br.readLine()) != null) {
+ if (line.startsWith("v ")) {
+ String[] split = line.split(" ");
+ double x = Double.valueOf(split[1]);
+ double y = Double.valueOf(split[2]);
+ double z = Double.valueOf(split[3]);
+ double w = 1.0D;
+ if (split.length == 5)
+ w = Double.valueOf(split[5]);
+ vertexOffset++;
+ vertexData[vertexOffset][0] = x / w;
+ vertexData[vertexOffset][1] = y / w;
+ vertexData[vertexOffset][2] = z / w;
+ } else if (line.startsWith("vt ")) {
+ String[] split = line.split(" ");
+ double u = Double.valueOf(split[1]);
+ double v = 0.0D;
+ double w = 0.0D;
+ if (split.length > 2)
+ v = Double.valueOf(split[2]);
+ if (split.length > 3)
+ w = Double.valueOf(split[3]);
+ textureOffset++;
+ textureData[textureOffset][0] = u;
+ textureData[textureOffset][1] = v;
+ textureData[textureOffset][2] = w;
+ } else if (line.startsWith("vn ")) {
+ String[] split = line.split(" ");
+ float x = Float.valueOf(split[1]);
+ float y = Float.valueOf(split[2]);
+ float z = Float.valueOf(split[3]);
+ normalOffset++;
+ normalData[normalOffset][0] = x;
+ normalData[normalOffset][1] = y;
+ normalData[normalOffset][2] = z;
+ } else if (line.startsWith("f ")) {
+ String[] split = line.split(" ");
+ for (int o = 1; o < split.length; o++) {
+ String[] pieces = split[o].split("/");
+ int vOff = (pieces[0].length() > 0 ? Integer.parseInt(pieces[0]) : -1);
+ int tOff = (pieces[1].length() > 0 ? Integer.parseInt(pieces[1]) : -1);
+ int nOff = (pieces[2].length() > 0 ? Integer.parseInt(pieces[2]) : -1);
+ dataList.add(new VertexData(vertexData[vOff - 1][0], vertexData[vOff - 1][1], vertexData[vOff - 1][2],
+ (tOff == -1 ? false : true), (tOff == -1 ? 0 : textureData[tOff - 1][0]), (tOff == -1 ? 0
+ : textureData[tOff - 1][1]), (nOff == -1 ? false : true), (nOff == -1 ? 0
+ : normalData[nOff - 1][0]), (nOff == -1 ? 0 : normalData[nOff - 1][1]), (nOff == -1 ? 0
+ : normalData[nOff - 1][2])));
+ }
+ } else if (line.startsWith("o ")) {
+ if (dataList.size() > 0)
+ modelList.put(objName, new OpenGLRenderer(objName, dataList));
+
+ objName = line.substring(2).trim();
+ dataList = new ArrayList<VertexData>();
+ }
+
+ }
+ } finally {
+ br.close();
+ }
+ if (dataList.size() > 0)
+ modelList.put(objName, new OpenGLRenderer(objName, dataList));
+ return modelList;
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
View
90 PetrolCraft/src/petrolcraft/render/OpenGLRenderer.java
@@ -0,0 +1,90 @@
+package petrolcraft.render;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelRenderer;
+import net.minecraft.client.renderer.GLAllocation;
+import net.minecraft.client.renderer.Tessellator;
+
+import org.lwjgl.opengl.GL11;
+
+public class OpenGLRenderer extends ModelRenderer {
+
+ private List<VertexData> mDataList;
+ private boolean mCompiled = false;
+
+ public OpenGLRenderer(String pObjName, List<VertexData> pDataList) {
+ super(new ModelBase() {
+ });
+ mDataList = pDataList;
+ }
+
+ @Override
+ public void render(float pPar1) {
+ if (mCompiled == false) {
+ compileList();
+ mCompiled = true;
+ }
+ super.render(pPar1);
+ }
+
+ @Override
+ public void renderWithRotation(float pPar1) {
+ if (mCompiled == false) {
+ compileList();
+ mCompiled = true;
+ }
+ super.renderWithRotation(pPar1);
+ }
+
+ public void renderParts() {
+ // GL11.glShadeModel(GL11.GL_SMOOTH);
+ GL11.glBegin(GL11.GL_TRIANGLES);
+ for (VertexData d : mDataList) {
+ GL11.glNormal3f(d.mNX, d.mNY, d.mNZ);
+ GL11.glVertex3d(d.mX, d.mY, d.mZ);
+ }
+ GL11.glEnd();
+ GL11.glFlush();
+ }
+
+ public void compileList() {
+ int displayListID = GLAllocation.generateDisplayLists(1);
+ GL11.glNewList(displayListID, GL11.GL_COMPILE);
+ Tessellator var2 = Tessellator.instance;
+
+ var2.startDrawing(GL11.GL_TRIANGLES);