46
46
import com .recursive_pineapple .matter_manipulator .common .utils .Mods ;
47
47
import com .recursive_pineapple .matter_manipulator .common .utils .Mods .Names ;
48
48
49
+ import de .keridos .floodlights .tileentity .TileEntityMetaFloodlight ;
50
+ import de .keridos .floodlights .tileentity .TileEntitySmallFloodlight ;
49
51
import gcewing .architecture .common .tile .TileArchitecture ;
50
52
import ic2 .api .tile .IWrenchable ;
51
53
import it .unimi .dsi .fastutil .objects .Object2ObjectArrayMap ;
52
54
import it .unimi .dsi .fastutil .objects .Object2ObjectOpenHashMap ;
53
- import scala .tools .nsc .typechecker .MethodSynthesis .MethodSynth .Getter ;
54
- import scala .tools .nsc .typechecker .MethodSynthesis .MethodSynth .Setter ;
55
55
56
56
public class BlockPropertyRegistry {
57
57
@@ -131,7 +131,7 @@ public static void getProperties(World world, int x, int y, int z, Map<String, B
131
131
132
132
properties .putAll (props );
133
133
134
- if (block .isBlockContainer ) {
134
+ if (block .hasTileEntity ( world . getBlockMetadata ( x , y , z )) ) {
135
135
TileEntity tile = world .getTileEntity (x , y , z );
136
136
137
137
if (tile != null ) {
@@ -154,7 +154,7 @@ public static BlockProperty<?> getProperty(World world, int x, int y, int z, Str
154
154
BlockProperty <?> prop = props .get (name );
155
155
if (prop != null ) return prop ;
156
156
157
- if (block .isBlockContainer ) {
157
+ if (block .hasTileEntity ( world . getBlockMetadata ( x , y , z )) ) {
158
158
TileEntity tile = world .getTileEntity (x , y , z );
159
159
160
160
if (tile != null ) {
@@ -176,6 +176,7 @@ public static void init() {
176
176
if (Mods .StorageDrawers .isModLoaded ()) initStorageDrawers ();
177
177
if (Mods .IndustrialCraft2 .isModLoaded ()) initIC2 ();
178
178
if (Mods .ArchitectureCraft .isModLoaded ()) initArch ();
179
+ if (Mods .FloodLights .isModLoaded ()) initFloodLights ();
179
180
}
180
181
181
182
// #region Vanilla
@@ -848,6 +849,131 @@ public void setValue(World world, int x, int y, int z, Orientation value) {
848
849
849
850
// #endregion
850
851
852
+ // #region FloodLights
853
+
854
+ private static void initFloodLights () {
855
+ registerTileEntityInterfaceProperty (TileEntityMetaFloodlight .class , new AbstractDirectionBlockProperty ("facing" ) {
856
+
857
+ @ Override
858
+ public ForgeDirection getValue (World world , int x , int y , int z ) {
859
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntityMetaFloodlight floodlight )) return UNKNOWN ;
860
+
861
+ return floodlight .getOrientation ();
862
+ }
863
+
864
+ @ Override
865
+ public void setValue (World world , int x , int y , int z , ForgeDirection forgeDirection ) {
866
+ // Do the same thing FloodLights do in `onBlockPlacedBy`
867
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntityMetaFloodlight floodlight )) return ;
868
+
869
+ floodlight .setOrientation (forgeDirection );
870
+
871
+ if (!(floodlight instanceof TileEntitySmallFloodlight )) {
872
+ // copy rotation info into metadata because FloodLights does it too
873
+ world .setBlockMetadataWithNotify (x , y , z , forgeDirection .ordinal (), 2 );
874
+ } else {
875
+ // NB: small electric light does not use metadata for rotation
876
+ // instead, it uses it to discern normal/small floodlights
877
+ // so don't modify metadata, just update it
878
+ world .markBlockForUpdate (x , y , z );
879
+ }
880
+ }
881
+ });
882
+
883
+ registerTileEntityInterfaceProperty (TileEntityMetaFloodlight .class , new BooleanProperty () {
884
+
885
+ @ Override
886
+ public String getName () {
887
+ return "inverted" ;
888
+ }
889
+
890
+ @ Override
891
+ public boolean getBoolean (World world , int x , int y , int z ) {
892
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntityMetaFloodlight floodlight )) return false ;
893
+
894
+ return floodlight .getInverted ();
895
+ }
896
+
897
+ @ Override
898
+ public void setBoolean (World world , int x , int y , int z , boolean value ) {
899
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntityMetaFloodlight floodlight )) return ;
900
+
901
+ if (floodlight .getInverted () != value ) {
902
+ floodlight .toggleInverted ();
903
+ }
904
+ }
905
+ });
906
+
907
+ registerTileEntityInterfaceProperty (TileEntityMetaFloodlight .class , new IntegerProperty () {
908
+
909
+ @ Override
910
+ public String getName () {
911
+ return "mode" ;
912
+ }
913
+
914
+ @ Override
915
+ public int getInt (World world , int x , int y , int z ) {
916
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntityMetaFloodlight floodlight )) return 0 ;
917
+
918
+ return floodlight .getMode ();
919
+ }
920
+
921
+ @ Override
922
+ public void setInt (World world , int x , int y , int z , int value ) {
923
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntityMetaFloodlight floodlight )) return ;
924
+
925
+ floodlight .setMode (value );
926
+ }
927
+ });
928
+
929
+ registerTileEntityInterfaceProperty (TileEntityMetaFloodlight .class , new IntegerProperty () {
930
+
931
+ @ Override
932
+ public String getName () {
933
+ return "color" ;
934
+ }
935
+
936
+ @ Override
937
+ public int getInt (World world , int x , int y , int z ) {
938
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntityMetaFloodlight floodlight )) return 0 ;
939
+
940
+ return floodlight .getColor ();
941
+ }
942
+
943
+ @ Override
944
+ public void setInt (World world , int x , int y , int z , int value ) {
945
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntityMetaFloodlight floodlight )) return ;
946
+
947
+ floodlight .setColor (value );
948
+ }
949
+ });
950
+
951
+ registerTileEntityInterfaceProperty (TileEntitySmallFloodlight .class , new BooleanProperty () {
952
+
953
+ @ Override
954
+ public String getName () {
955
+ return "rotation_state" ;
956
+ }
957
+
958
+ @ Override
959
+ public boolean getBoolean (World world , int x , int y , int z ) {
960
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntitySmallFloodlight floodlight )) return false ;
961
+
962
+ return floodlight .getRotationState ();
963
+ }
964
+
965
+ @ Override
966
+ public void setBoolean (World world , int x , int y , int z , boolean value ) {
967
+ if (!(world .getTileEntity (x , y , z ) instanceof TileEntitySmallFloodlight floodlight )) return ;
968
+
969
+ floodlight .setRotationState (value );
970
+ world .markBlockForUpdate (x , y , z );
971
+ }
972
+ });
973
+ }
974
+
975
+ // #endregion
976
+
851
977
public static DirectionBlockProperty methodIntDirectionTile (Class <?> clazz , String getterName , String setterName ) {
852
978
try {
853
979
Method getter = clazz .getDeclaredMethod (getterName );
0 commit comments