66import java .util .List ;
77
88import net .minecraft .block .Block ;
9+ import net .minecraft .client .resources .I18n ;
910import net .minecraft .init .Blocks ;
1011import net .minecraft .item .ItemStack ;
1112import net .minecraft .nbt .NBTTagCompound ;
6970import forestry .apiculture .genetics .BeeDefinition ;
7071import forestry .apiculture .genetics .BeeGenome ;
7172import forestry .arboriculture .ModuleArboriculture ;
73+ import org .jetbrains .annotations .Nullable ;
7274
7375public class MetaTileEntityMegaApiary extends MultiblockWithDisplayBase implements IControllable {
7476
7577 private boolean isWorkingEnabled = true ;
76- private boolean isWorking = false ;
78+ private boolean isWorking ;
7779
7880 private static final int PROCESS_TIME = 100 ;
7981 private int progressTicks = 0 ;
8082 private int inputSize = 0 ;
83+ private int royalJerry = 0 ;
8184
8285 private long consumption ;
8386
@@ -183,9 +186,8 @@ protected void updateFormedValid() {}
183186 .where ('A' , states (MetaBlocks .TRANSPARENT_CASING .getState (BlockGlassCasing .CasingType .FUSION_GLASS )))
184187 .where ('B' , blocks (Blocks .DIRT ).or (blocks (Blocks .GRASS )))
185188 .where ('G' , states (MetaBlocks .METAL_CASING .getState (BlockMetalCasing .MetalCasingType .BRONZE_BRICKS ))
186- .or (abilities (MultiblockAbility .IMPORT_ITEMS ).setMinGlobalLimited (1 , 2 ).setMaxGlobalLimited (5 ))
187- .or (abilities (MultiblockAbility .EXPORT_ITEMS ).setMinGlobalLimited (1 , 2 ).setMaxGlobalLimited (5 ))
188- .or (abilities (MultiblockAbility .IMPORT_FLUIDS ).setMaxGlobalLimited (5 , 1 ))
189+ .or (abilities (MultiblockAbility .IMPORT_ITEMS ).setMinGlobalLimited (1 , 2 ).setMaxGlobalLimited (10 ))
190+ .or (abilities (MultiblockAbility .EXPORT_ITEMS ).setMinGlobalLimited (1 , 2 ).setMaxGlobalLimited (10 ))
189191 .or (abilities (MultiblockAbility .MAINTENANCE_HATCH ).setExactLimit (1 ))
190192 .or (getEnergyInputPredicate ()))
191193 .where ('H' , getPlanks ())
@@ -256,7 +258,7 @@ protected ICubeRenderer getFrontOverlay() {
256258 @ Override
257259 public void renderMetaTileEntity (CCRenderState renderState , Matrix4 translation , IVertexOperation [] pipeline ) {
258260 super .renderMetaTileEntity (renderState , translation , pipeline );
259- getFrontOverlay ().renderSided ( getFrontFacing (), renderState , translation , pipeline );
261+ getFrontOverlay ().renderOrientedState ( renderState , translation , pipeline , getFrontFacing (), isActive (), isWorkingEnabled );
260262 }
261263
262264 @ Override
@@ -356,6 +358,10 @@ private void collectBees() {
356358 ItemStack stack = importItems .getStackInSlot (i );
357359 if (isQueen (stack )) {
358360 queenStacks .add (stack );
361+ } else if (isJerry (stack )) {
362+ int count = importItems .getStackInSlot (i ).getCount ();
363+ royalJerry += count ;
364+ importItems .extractItem (i , count , false );
359365 } else {
360366 stack = importItems .extractItem (i , importItems .getStackInSlot (i ).getCount (), false );
361367 if (GTTransferUtils .addItemsToItemHandler (exportItems , true ,
@@ -390,9 +396,12 @@ private void processProducts() {
390396 float speed = genome .getSpeed ();
391397 float baseModifier = mode .getBeeModifier ().getProductionModifier (genome ,
392398 MAX_PRODUCTION_MODIFIER_FROM_UPGRADES );
399+ int bonus = Math .min (royalJerry , 40 );
400+
401+ float applyBonus = (float ) (1 + bonus * 0.05 );
393402
394403 primary .getProductChances ().forEach ((stack , f ) -> {
395- double v = speed + f + baseModifier + baseModifier * getMaxTier ();
404+ float v = ( speed + f + baseModifier + baseModifier * getMaxTier ()) * applyBonus ;
396405 while (v > 1.0F ) {
397406 int size = Math .min ((int ) v , 64 );
398407 stack .setCount (size );
@@ -401,7 +410,7 @@ private void processProducts() {
401410 }
402411 });
403412 secondary .getProductChances ().forEach ((stack , f ) -> {
404- double v = speed + f + baseModifier + baseModifier * getMaxTier ();
413+ float v = ( speed + f + baseModifier + baseModifier * getMaxTier ()) * applyBonus ;
405414 while (v > 1.0F ) {
406415 int size = Math .min ((int ) v , 64 );
407416 stack .setCount (size );
@@ -411,16 +420,16 @@ private void processProducts() {
411420 });
412421
413422 primary .getSpecialtyChances ().forEach ((stack , f ) -> {
414- double v = speed + f + baseModifier + baseModifier * getMaxTier ();
423+ float v = ( speed + f + baseModifier + baseModifier * getMaxTier ()) * applyBonus ;
415424 while (v > 1.0F ) {
416425 int size = Math .min ((int ) v , 64 );
417426 stack .setCount (size );
418427 products .add (stack );
419428 v -= size ;
420429 }
421430 });
431+ royalJerry -= bonus ;
422432 }
423-
424433 mergeProducts ();
425434 }
426435
@@ -461,6 +470,10 @@ private boolean isQueen(ItemStack stack) {
461470 return stack .isItemEqual (ModuleApiculture .getItems ().beeQueenGE .getItemStack ());
462471 }
463472
473+ private boolean isJerry (ItemStack stack ) {
474+ return stack .isItemEqual (ModuleApiculture .getItems ().royalJelly .getItemStack ());
475+ }
476+
464477 // ==Display Text==
465478 @ Override
466479 protected void addDisplayText (List <ITextComponent > textList ) {
@@ -473,8 +486,19 @@ protected void addDisplayText(List<ITextComponent> textList) {
473486 .addCustom (tl -> {
474487 tl .add (TextComponentUtil .translationWithColor (
475488 TextFormatting .GRAY ,
476- "gtbm.multiblock.mega_apiary.princess " ,
489+ "gtbm.multiblock.mega_apiary.queens " ,
477490 this .inputSize ));
491+
492+ ITextComponent jerryBody = TextComponentUtil .translationWithColor (
493+ TextFormatting .GRAY ,
494+ "gtbm.multiblock.mega_apiary.jerry_body" ,
495+ TextFormattingUtil .formatNumbers (this .royalJerry ));
496+ ITextComponent jerryHover = TextComponentUtil .translationWithColor (
497+ TextFormatting .WHITE ,
498+ "gtbm.multiblock.mega_apiary.jerry_hover"
499+ );
500+ tl .add (TextComponentUtil .setHover (jerryBody , jerryHover ));
501+
478502 if (isWorking ) {
479503 float currentProgress = ((float ) progressTicks / PROCESS_TIME ) * 100 ;
480504 double current = (double ) progressTicks / 20 ;
@@ -531,7 +555,7 @@ public void setWorkingEnabled(boolean isWorkingAllowed) {
531555
532556 @ Override
533557 public boolean isActive () {
534- return isWorking ;
558+ return isWorking && isWorkingEnabled ;
535559 }
536560
537561 @ Override
@@ -549,6 +573,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound data) {
549573 data .setBoolean ("isWorkingEnabled" , this .isWorkingEnabled );
550574 data .setInteger ("inputSize" , this .inputSize );
551575 data .setInteger ("progressTicks" , this .progressTicks );
576+ data .setInteger ("royalJerry" , this .royalJerry );
552577 return data ;
553578 }
554579
@@ -559,6 +584,7 @@ public void readFromNBT(NBTTagCompound data) {
559584 this .isWorkingEnabled = data .getBoolean ("isWorkingEnabled" );
560585 this .inputSize = data .getInteger ("inputSize" );
561586 this .progressTicks = data .getInteger ("progressTicks" );
587+ this .royalJerry = data .getInteger ("royalJerry" );
562588 }
563589
564590 @ Override
@@ -568,6 +594,7 @@ public void writeInitialSyncData(PacketBuffer buf) {
568594 buf .writeBoolean (this .isWorkingEnabled );
569595 buf .writeInt (this .inputSize );
570596 buf .writeInt (this .progressTicks );
597+ buf .writeInt (this .royalJerry );
571598 }
572599
573600 @ Override
@@ -577,6 +604,7 @@ public void receiveInitialSyncData(PacketBuffer buf) {
577604 this .isWorkingEnabled = buf .readBoolean ();
578605 this .inputSize = buf .readInt ();
579606 this .progressTicks = buf .readInt ();
607+ this .royalJerry = buf .readInt ();
580608 }
581609
582610 @ Override
0 commit comments