Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import forge.ISidedInventory;
- import ic2.common.IHasGuiContainer;
- import ic2.platform.Platform;
- import java.util.HashMap;
- import java.util.Random;
- public class TileEntityRotary extends TileEntityAdvBlock3
- implements IHasGuiContainer, ISidedInventory
- {
- public int soundTicker;
- public static short maxSpeed = 10000;
- public short speed;
- public short progress;
- public static HashMap maceration;
- private static final int inputSlot = 0;
- private static final int fuelSlot = 1;
- private static final int outputSlot = 2;
- public TileEntityRotary()
- {
- super(4, 2, maxSpeed, 128);
- this.speed = 0;
- this.progress = 0;
- this.wrenchRate = 0.8F;
- this.soundTicker = mod_IC2.random.nextInt(64);
- }
- public String c()
- {
- if (Platform.isRendering())
- {
- return "Rotary Macerator";
- }
- return "RotaryMacerator";
- }
- public void a(xb nbttagcompound)
- {
- super.a(nbttagcompound);
- this.speed = nbttagcompound.d("speed");
- this.progress = nbttagcompound.d("progress");
- }
- public void b(xb nbttagcompound)
- {
- super.b(nbttagcompound);
- nbttagcompound.a("speed", this.speed);
- nbttagcompound.a("progress", this.progress);
- }
- public String getSpeed()
- {
- return "" + this.speed + " RPM";
- }
- public int gaugeProgressScaled(int i)
- {
- return i * this.progress / 4000;
- }
- public int gaugeFuelScaled(int i)
- {
- return i * this.energy / this.maxEnergy;
- }
- public void b_()
- {
- super.b_();
- if (Platform.isSimulating())
- {
- boolean flag = false;
- if (this.energy <= this.maxEnergy)
- {
- flag = provideEnergy();
- }
- boolean flag1 = getActive();
- if (this.progress >= 4000)
- {
- operate();
- flag = true;
- this.progress = 0;
- flag1 = false;
- }
- boolean flag2 = canOperate();
- if ((this.energy > 0) && ((flag2) || (isRedstonePowered())))
- {
- this.energy -= 1;
- if (this.speed < maxSpeed)
- {
- this.speed = (short)(this.speed + 1);
- }
- flag1 = true;
- }
- else {
- this.speed = (short)(this.speed - Math.min(this.speed, 4));
- }
- if ((!flag1) || (this.progress == 0))
- {
- if (flag2)
- {
- if (this.energy >= 15)
- {
- flag1 = true;
- }
- }
- else {
- this.progress = 0;
- }
- }
- else if ((!flag2) || (this.energy < 15))
- {
- if (!flag2)
- {
- this.progress = 0;
- }
- flag1 = false;
- }
- if ((flag1) && (flag2))
- {
- this.progress = (short)(this.progress + this.speed / 30);
- this.energy -= 15;
- }
- if (flag)
- {
- l();
- }
- if (flag1 != getActive())
- {
- setActive(flag1);
- }
- }
- }
- public void operate()
- {
- if (!canOperate())
- {
- return;
- }
- ul itemstack = getResultFor(this.inventory[0]);
- if (this.inventory[2] == null)
- {
- this.inventory[2] = itemstack.k();
- }
- else if (this.inventory[2].a + itemstack.a >= this.inventory[2].c() + 1)
- {
- if (this.inventory[3] == null)
- {
- this.inventory[3] = itemstack.k();
- }
- else
- {
- this.inventory[3].a += itemstack.a;
- }
- }
- else if (!this.inventory[2].a(itemstack))
- {
- if (this.inventory[3] == null)
- {
- this.inventory[3] = itemstack.k();
- }
- else
- {
- this.inventory[3].a += itemstack.a;
- }
- }
- else
- {
- this.inventory[2].a += itemstack.a;
- }
- if (this.inventory[0].a().j())
- {
- this.inventory[0] = new ul(this.inventory[0].a().i());
- }
- else {
- this.inventory[0].a -= 1;
- }
- if (this.inventory[0].a <= 0)
- {
- this.inventory[0] = null;
- }
- }
- public boolean canOperate()
- {
- if (this.inventory[0] == null)
- {
- return false;
- }
- ul itemstack = getResultFor(this.inventory[0]);
- if (itemstack == null)
- {
- return false;
- }
- if ((this.inventory[2] == null) || (this.inventory[3] == null))
- {
- return true;
- }
- if ((!this.inventory[3].a(itemstack)) && (!this.inventory[2].a(itemstack)))
- {
- return false;
- }
- return (this.inventory[2].a < this.inventory[2].c() - 1) || (this.inventory[3].a < this.inventory[3].c() - 1);
- }
- public boolean isRedstonePowered()
- {
- return this.i.r(this.j, this.k, this.l);
- }
- public static void initmaceration()
- {
- maceration = new HashMap();
- addRecipe(lr.I.bA, new ul(mod_IC2.itemDustIron, 2));
- addRecipe(lr.H.bA, new ul(mod_IC2.itemDustGold, 2));
- addRecipe(mod_IC2.blockOreTin.bA, new ul(mod_IC2.itemDustTin, 2));
- addRecipe(mod_IC2.blockOreCopper.bA, new ul(mod_IC2.itemDustCopper, 2));
- addRecipe(sv.n.br, new ul(mod_IC2.itemDustCoal));
- addRecipe(mod_IC2.itemIngotAdvIron.br, new ul(mod_IC2.itemDustIron));
- addRecipe(mod_IC2.itemIngotTin.br, new ul(mod_IC2.itemDustTin));
- addRecipe(mod_IC2.itemIngotCopper.br, new ul(mod_IC2.itemDustCopper));
- addRecipe(sv.p.br, new ul(mod_IC2.itemDustIron));
- addRecipe(mod_IC2.itemIngotAdvIron.br, new ul(mod_IC2.itemDustIron));
- addRecipe(sv.q.br, new ul(mod_IC2.itemDustGold));
- addRecipe(lr.ac.bA, new ul(sv.L));
- addRecipe(lr.G.bA, new ul(sv.aq));
- addRecipe(lr.u.bA, new ul(lr.x));
- addRecipe(lr.x.bA, new ul(lr.F));
- addRecipe(lr.R.bA, new ul(lr.F));
- addRecipe(lr.aU.bA, new ul(sv.aE));
- }
- public static void addRecipe(int i, ul itemstack)
- {
- maceration.put(Integer.valueOf(i), itemstack);
- }
- public ul getResultFor(ul itemstack)
- {
- if ((itemstack.c == sv.n.br) && (itemstack.i() != 0))
- {
- return null;
- }
- return (ul)maceration.get(Integer.valueOf(itemstack.c));
- }
- public cf getGuiContainer(ui inventoryplayer)
- {
- return new ContainerRotary(inventoryplayer, this);
- }
- public int getStartInventorySide(int i)
- {
- switch (i)
- {
- case 0:
- return 1;
- case 1:
- return 0;
- }
- return 2;
- }
- public int getSizeInventorySide(int i)
- {
- switch (i)
- {
- case 0:
- return 1;
- }
- return 2;
- }
- }
Add Comment
Please, Sign In to add comment