1
1
package pl .asie .computronics ;
2
2
3
3
import net .minecraft .block .Block ;
4
+ import net .minecraft .block .state .IBlockState ;
4
5
import net .minecraft .client .Minecraft ;
5
6
import net .minecraft .client .renderer .block .model .ModelResourceLocation ;
6
7
import net .minecraft .client .renderer .color .IBlockColor ;
7
8
import net .minecraft .client .renderer .color .IItemColor ;
8
9
import net .minecraft .item .Item ;
10
+ import net .minecraft .item .ItemStack ;
9
11
import net .minecraft .util .math .BlockPos ;
12
+ import net .minecraft .world .IBlockAccess ;
10
13
import net .minecraftforge .client .model .ModelLoader ;
11
14
import net .minecraftforge .common .MinecraftForge ;
12
15
import net .minecraftforge .fml .common .Optional ;
18
21
import pl .asie .computronics .oc .client .UpgradeRenderer ;
19
22
import pl .asie .computronics .reference .Mods ;
20
23
import pl .asie .computronics .util .boom .SelfDestruct ;
24
+ import pl .asie .computronics .util .internal .IBlockWithColor ;
25
+ import pl .asie .computronics .util .internal .IItemWithColor ;
21
26
import pl .asie .computronics .util .sound .Audio ;
22
27
import pl .asie .lib .network .Packet ;
23
28
24
29
import java .io .IOException ;
25
30
import java .util .ArrayList ;
26
- import java .util .HashMap ;
27
- import java .util .Map ;
31
+ import java .util .List ;
28
32
29
33
public class ClientProxy extends CommonProxy {
30
34
@@ -48,8 +52,8 @@ public void registerEntities() {
48
52
49
53
@ Override
50
54
public void registerItemModel (Item item , int meta , String name ) {
51
- if (item instanceof IItemColor ) {
52
- coloredItems .put ((( IItemColor ) item ), item );
55
+ if (item instanceof IItemWithColor ) {
56
+ coloredItems .add ( item );
53
57
}
54
58
if (name .contains ("#" )) {
55
59
ModelLoader .setCustomModelResourceLocation (item , meta , new ModelResourceLocation (name .split ("#" )[0 ], name .split ("#" )[1 ]));
@@ -60,14 +64,14 @@ public void registerItemModel(Item item, int meta, String name) {
60
64
61
65
@ Override
62
66
public void registerItemModel (Block block , int meta , String name ) {
63
- if (block instanceof IBlockColor ) {
64
- coloredBlocks .put ((( IBlockColor ) block ), block );
67
+ if (block instanceof IBlockWithColor ) {
68
+ coloredBlocks .add ( block );
65
69
}
66
70
super .registerItemModel (block , meta , name );
67
71
}
68
72
69
- private final Map < IItemColor , Item > coloredItems = new HashMap < IItemColor , Item >();
70
- private final Map < IBlockColor , Block > coloredBlocks = new HashMap < IBlockColor , Block >();
73
+ private final List < Item > coloredItems = new ArrayList < Item >();
74
+ private final List < Block > coloredBlocks = new ArrayList < Block >();
71
75
72
76
@ Override
73
77
public void init () {
@@ -77,12 +81,18 @@ public void init() {
77
81
}
78
82
79
83
private void registerColors () {
80
- for (Map .Entry <IItemColor , Item > entry : coloredItems .entrySet ()) {
81
- Minecraft .getMinecraft ().getItemColors ().registerItemColorHandler (entry .getKey (), entry .getValue ());
82
- }
83
- for (Map .Entry <IBlockColor , Block > entry : coloredBlocks .entrySet ()) {
84
- Minecraft .getMinecraft ().getBlockColors ().registerBlockColorHandler (entry .getKey (), entry .getValue ());
85
- }
84
+ Minecraft .getMinecraft ().getItemColors ().registerItemColorHandler (new IItemColor () {
85
+ @ Override
86
+ public int getColorFromItemstack (ItemStack stack , int tintIndex ) {
87
+ return stack .getItem () instanceof IItemWithColor ? ((IItemWithColor ) stack .getItem ()).getColorFromItemstack (stack , tintIndex ) : 0xFFFFFFFF ;
88
+ }
89
+ }, coloredItems .toArray (new Item [coloredItems .size ()]));
90
+ Minecraft .getMinecraft ().getBlockColors ().registerBlockColorHandler (new IBlockColor () {
91
+ @ Override
92
+ public int colorMultiplier (IBlockState state , IBlockAccess worldIn , BlockPos pos , int tintIndex ) {
93
+ return state .getBlock () instanceof IBlockWithColor ? ((IBlockWithColor ) state .getBlock ()).colorMultiplier (state , worldIn , pos , tintIndex ) : 0xFFFFFFFF ;
94
+ }
95
+ }, coloredBlocks .toArray (new Block [coloredBlocks .size ()]));
86
96
}
87
97
88
98
public void registerRenderers () {
0 commit comments