22
33import static WayofTime .alchemicalWizardry .client .ClientUtils .mc ;
44import static WayofTime .alchemicalWizardry .client .nei .NEIConfig .ARROW_TEXTURE ;
5+ import static codechicken .lib .gui .GuiDraw .fontRenderer ;
56
67import java .awt .Rectangle ;
8+ import java .util .Collections ;
9+ import java .util .List ;
710
8- import net .minecraft .client .gui .FontRenderer ;
911import net .minecraft .client .renderer .Tessellator ;
1012import net .minecraft .client .renderer .texture .TextureManager ;
1113import net .minecraft .item .ItemStack ;
@@ -28,19 +30,39 @@ public class NEICalcinatorHandler extends TemplateRecipeHandler {
2830 public class CachedReagentInfo extends CachedRecipe {
2931
3032 private final Reagent reagent ;
33+ private final PositionedStack stack ;
34+ private final PositionedStack orbs ;
3135 private final int amount ;
32- private final int color ;
36+
37+ private final String amountText ;
38+ private final int amountTextWidth ;
39+
40+ private final String nameText ;
41+ private final int nameTextWidth ;
42+
43+ private static final int ARROW_WIDTH = 24 ;
44+ private static final int ARROW_HEIGHT = 16 ;
45+ private static final int FILL_TIME = 192 ;
46+ private static final int HOLD_TIME = 8 ;
3347
3448 public CachedReagentInfo (ReagentStack reagent ) {
3549 this .reagent = reagent .reagent ;
50+ this .stack = new PositionedStack (ReagentRegistry .getItemForReagent (reagent .reagent ), 32 , 6 );
3651 this .amount = reagent .amount ;
37- this .color = reagent .reagent .getColourRed () << 16 | reagent .reagent .getColourGreen () << 8
38- | reagent .reagent .getColourBlue ();
52+
53+ ItemStack [] orbStacks = NEIConfig .getBloodOrbs ().stream ().map (ItemStack ::new ).toArray (ItemStack []::new );
54+ this .orbs = new PositionedStack (orbStacks , 32 , 33 );
55+
56+ this .amountText = String .format ("%,d AR" , amount );
57+ this .amountTextWidth = fontRenderer .getStringWidth (amountText );
58+
59+ this .nameText = this .reagent .name ;
60+ this .nameTextWidth = fontRenderer .getStringWidth (nameText );
3961 }
4062
4163 @ Override
4264 public PositionedStack getResult () {
43- return new PositionedStack ( ReagentRegistry . getItemForReagent ( reagent ), 32 , 6 ) ;
65+ return stack ;
4466 }
4567
4668 public Reagent getReagent () {
@@ -54,75 +76,63 @@ public int getAmount() {
5476 public void onDraw (int x , int y ) {
5577 drawColoredProgressBar (x , y );
5678
57- String amountText = String .format ("%,d AR" , amount );
58- FontRenderer fontRenderer = mc .fontRenderer ;
59-
60- int textWidth = fontRenderer .getStringWidth (amountText );
61- int textX = x + 84 - (textWidth / 2 );
79+ int textX = x + 84 - (amountTextWidth / 2 );
6280 int textY = y + 19 ;
63-
6481 fontRenderer .drawString (amountText , textX , textY , 0x000000 );
6582
66- textWidth = fontRenderer .getStringWidth (reagent .name );
67- textX = x + 84 - (textWidth / 2 );
68- textY = y + 29 ;
69-
70- fontRenderer .drawString (reagent .name , textX , textY , color );
83+ textX = x + 84 - (nameTextWidth / 2 );
84+ textY += 10 ;
85+ int color = reagent .getColourRed () << 16 | reagent .getColourGreen () << 8 | reagent .getColourBlue ();
86+ fontRenderer .drawString (nameText , textX , textY , color );
7187 }
7288
7389 private void drawColoredProgressBar (int x , int y ) {
7490 int arrowX = x + 25 ;
7591 int arrowY = y + 19 ;
76- int arrowWidth = 24 ;
77- int arrowHeight = 16 ;
7892
79- int fillTime = 192 ;
80- int holdTime = 8 ;
81- int totalCycle = fillTime + holdTime ;
93+ int totalCycle = FILL_TIME + HOLD_TIME ;
8294
8395 int cycleTick = cycleticks % totalCycle ;
8496
8597 int fillWidth ;
86- if (cycleTick < fillTime ) {
87- fillWidth = cycleTick * arrowWidth / fillTime ;
98+ if (cycleTick < FILL_TIME ) {
99+ fillWidth = cycleTick * ARROW_WIDTH / FILL_TIME ;
88100 } else {
89- fillWidth = arrowWidth ;
101+ fillWidth = ARROW_WIDTH ;
90102 }
91103
92104 TextureManager texManager = mc .getTextureManager ();
93105 texManager .bindTexture (ARROW_TEXTURE );
94106
95107 Tessellator tessellator = Tessellator .instance ;
96108
109+ GL11 .glPushMatrix ();
110+ GL11 .glPushAttrib (GL11 .GL_ALL_ATTRIB_BITS );
111+
97112 GL11 .glEnable (GL11 .GL_BLEND );
98113 GL11 .glBlendFunc (GL11 .GL_SRC_ALPHA , GL11 .GL_ONE_MINUS_SRC_ALPHA );
99114
100- float r = (( color >> 16 ) & 0xFF ) / 255f ;
101- float g = (( color >> 8 ) & 0xFF ) / 255f ;
102- float b = ( color & 0xFF ) / 255f ;
103-
104- GL11 . glColor4f ( r , g , b , 1.0f );
115+ GL11 . glColor4ub (
116+ ( byte ) reagent . getColourRed (),
117+ ( byte ) reagent . getColourGreen (),
118+ ( byte ) reagent . getColourBlue (),
119+ ( byte ) 255 );
105120
106121 tessellator .startDrawingQuads ();
107-
108- tessellator . addVertexWithUV ( arrowX , arrowY + arrowHeight , 0 , 0 , 1 );
109- tessellator .addVertexWithUV (arrowX + fillWidth , arrowY + arrowHeight , 0 , fillWidth / (float ) arrowWidth , 1 );
110- tessellator .addVertexWithUV (arrowX + fillWidth , arrowY , 0 , fillWidth / (float ) arrowWidth , 0 );
122+ tessellator . addVertexWithUV ( arrowX , arrowY + ARROW_HEIGHT , 0 , 0 , 1 );
123+ tessellator
124+ .addVertexWithUV (arrowX + fillWidth , arrowY + ARROW_HEIGHT , 0 , fillWidth / (float ) ARROW_WIDTH , 1 );
125+ tessellator .addVertexWithUV (arrowX + fillWidth , arrowY , 0 , fillWidth / (float ) ARROW_WIDTH , 0 );
111126 tessellator .addVertexWithUV (arrowX , arrowY , 0 , 0 , 0 );
112-
113127 tessellator .draw ();
114128
115- GL11 .glDisable (GL11 .GL_BLEND );
129+ GL11 .glPopAttrib ();
130+ GL11 .glPopMatrix ();
116131 }
117132
118133 @ Override
119- public PositionedStack getOtherStack () {
120- ItemStack [] orbStacks = NEIConfig .getBloodOrbs ().stream ().map (ItemStack ::new ).toArray (ItemStack []::new );
121-
122- PositionedStack stack = new PositionedStack (orbStacks , 32 , 33 , true );
123- stack .setPermutationToRender ((cycleticks / 20 ) % orbStacks .length );
124-
125- return stack ;
134+ public List <PositionedStack > getIngredients () {
135+ return getCycledIngredients (cycleticks / 20 , Collections .singletonList (this .orbs ));
126136 }
127137 }
128138
@@ -151,24 +161,26 @@ private void checkReagents(ItemStack result) {
151161 ReagentStack rs = ReagentRegistry .getReagentStackForItem (result );
152162 if (rs != null ) {
153163 arecipes .add (new CachedReagentInfo (rs ));
154- } else { // Check reagents in crystal belljars or other reagent storages
155- NBTTagCompound tagCompound = result .getTagCompound ();
156- if (tagCompound == null || tagCompound .hasNoTags ()) {
157- return ;
158- }
159- NBTTagList tagList = tagCompound .getTagList ("reagentTanks" , Constants .NBT .TAG_COMPOUND );
160- if (tagList .tagList .isEmpty ()) {
161- return ;
162- }
163- for (int i = 0 ; i < tagList .tagCount (); i ++) {
164- // Get the proper size of the ReagentStack created by melting the item for this reagent
165- NBTTagCompound savedTag = tagList .getCompoundTagAt (i );
166- ReagentStack reagent = ReagentContainer .readFromNBT (savedTag ).getReagent ();
167- ItemStack reagentItem = ReagentRegistry .getItemForReagent (reagent .reagent );
168- ReagentStack reagentStackForItem = ReagentRegistry .getReagentStackForItem (reagentItem );
169- if (reagentStackForItem != null ) {
170- arecipes .add (new CachedReagentInfo (reagentStackForItem ));
171- }
164+ return ;
165+ }
166+ // Check reagents in crystal belljars or other reagent storages
167+ NBTTagCompound tagCompound = result .getTagCompound ();
168+ if (tagCompound == null || tagCompound .hasNoTags ()) {
169+ return ;
170+ }
171+ NBTTagList tagList = tagCompound .getTagList ("reagentTanks" , Constants .NBT .TAG_COMPOUND );
172+ if (tagList .tagList .isEmpty ()) {
173+ return ;
174+ }
175+ for (int i = 0 ; i < tagList .tagCount (); i ++) {
176+ // Get the proper size of the ReagentStack created by melting the item for this reagent
177+ NBTTagCompound savedTag = tagList .getCompoundTagAt (i );
178+ ReagentStack reagent = ReagentContainer .readFromNBT (savedTag ).getReagent ();
179+ if (reagent == null ) continue ;
180+ ItemStack reagentItem = ReagentRegistry .getItemForReagent (reagent .reagent );
181+ ReagentStack reagentStackForItem = ReagentRegistry .getReagentStackForItem (reagentItem );
182+ if (reagentStackForItem != null ) {
183+ arecipes .add (new CachedReagentInfo (reagentStackForItem ));
172184 }
173185 }
174186 }
@@ -191,7 +203,7 @@ public String getOverlayIdentifier() {
191203
192204 @ Override
193205 public void loadTransferRects () {
194- transferRects .add (new RecipeTransferRect (new Rectangle (54 , 23 , 23 , 16 ), "alchemicalwizardry.calcinator" ));
206+ transferRects .add (new RecipeTransferRect (new Rectangle (55 , 18 , 24 , 17 ), "alchemicalwizardry.calcinator" ));
195207 }
196208
197209 @ Override
0 commit comments