-Changed Coffee Machine

-Changed Machines not to lose Progress when Power is low
This commit is contained in:
Ellpeck 2015-06-13 12:52:22 +02:00
parent 0ce4d001b9
commit 3c8b3a7bfc
20 changed files with 58 additions and 135 deletions

View file

@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.inventory.slot.SlotOutput; import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.ItemCoffee;
import ellpeck.actuallyadditions.items.metalists.TheMiscItems; import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityCoffeeMachine; import ellpeck.actuallyadditions.tile.TileEntityCoffeeMachine;
@ -33,13 +34,7 @@ public class ContainerCoffeeMachine extends Container{
for (int i = 0; i < 4; i++){ for (int i = 0; i < 4; i++){
for (int j = 0; j < 2; j++){ for (int j = 0; j < 2; j++){
this.addSlotToContainer(new Slot(machine, j+i*2+3, 125+j*18, 6+i*18){ this.addSlotToContainer(new Slot(machine, j+i*2+3, 125+j*18, 6+i*18));
@Override
public int getSlotStackLimit(){
return 1;
}
});
} }
} }
@ -111,6 +106,9 @@ public class ContainerCoffeeMachine extends Container{
if(currentStack.getItem() == InitItems.itemMisc && currentStack.getItemDamage() == TheMiscItems.CUP.ordinal()){ if(currentStack.getItem() == InitItems.itemMisc && currentStack.getItemDamage() == TheMiscItems.CUP.ordinal()){
this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT+1, false); this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT+1, false);
} }
if(ItemCoffee.getIngredientFromStack(newStack) != null){
this.mergeItemStack(newStack, 3, 10, false);
}
} }
if(slot <= hotbarEnd && slot >= hotbarStart){ if(slot <= hotbarEnd && slot >= hotbarStart){

View file

@ -62,10 +62,11 @@ public class ItemCoffee extends ItemFood implements INameableItem{
} }
public ItemCoffee(){ public ItemCoffee(){
super(2, 2.0F, false); super(8, 5.0F, false);
this.setMaxDamage(ConfigIntValues.COFFEE_DRINK_AMOUNT.getValue()-1); this.setMaxDamage(ConfigIntValues.COFFEE_DRINK_AMOUNT.getValue()-1);
this.setAlwaysEdible(); this.setAlwaysEdible();
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setNoRepair();
} }
public static Ingredient getIngredientFromStack(ItemStack stack){ public static Ingredient getIngredientFromStack(ItemStack stack){

View file

@ -35,8 +35,10 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
if(!worldObj.isRemote){ if(!worldObj.isRemote){
if(this.isCanola(0) && this.storage.getEnergyStored() >= energyUsedPerTick && this.mbProducedPerCanola <= this.tank.getCapacity()-this.tank.getFluidAmount()){ if(this.isCanola(0) && this.mbProducedPerCanola <= this.tank.getCapacity()-this.tank.getFluidAmount()){
if(this.storage.getEnergyStored() >= energyUsedPerTick){
this.currentProcessTime++; this.currentProcessTime++;
this.storage.extractEnergy(energyUsedPerTick, false);
if(this.currentProcessTime >= this.maxTimeProcessing){ if(this.currentProcessTime >= this.maxTimeProcessing){
this.currentProcessTime = 0; this.currentProcessTime = 0;
@ -47,6 +49,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
this.markDirty(); this.markDirty();
} }
} }
}
else this.currentProcessTime = 0; else this.currentProcessTime = 0;
if(this.slots[1] != null && this.slots[1].getItem() == Items.bucket && this.slots[2] == null){ if(this.slots[1] != null && this.slots[1].getItem() == Items.bucket && this.slots[2] == null){
@ -58,8 +61,6 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
} }
} }
if(this.currentProcessTime > 0) this.storage.extractEnergy(energyUsedPerTick, false);
if(this.tank.getFluidAmount() > 0){ if(this.tank.getFluidAmount() > 0){
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, this.tank); WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, this.tank);
} }

View file

@ -41,7 +41,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
if(!worldObj.isRemote){ if(!worldObj.isRemote){
this.storeCoffee(); this.storeCoffee();
if(this.brewTime > 0){ if(this.brewTime > 0 || this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
this.brew(); this.brew();
} }
} }
@ -59,19 +59,22 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
public void brew(){ public void brew(){
if(!worldObj.isRemote){ if(!worldObj.isRemote){
if(this.slots[SLOT_INPUT] != null && this.slots[SLOT_INPUT].getItem() == InitItems.itemMisc && this.slots[SLOT_INPUT].getItemDamage() == TheMiscItems.CUP.ordinal() && this.slots[SLOT_OUTPUT] == null && this.storage.getEnergyStored() >= energyUsePerTick && this.coffeeCacheAmount >= this.coffeeCacheUsePerItem){ if(this.slots[SLOT_INPUT] != null && this.slots[SLOT_INPUT].getItem() == InitItems.itemMisc && this.slots[SLOT_INPUT].getItemDamage() == TheMiscItems.CUP.ordinal() && this.slots[SLOT_OUTPUT] == null && this.coffeeCacheAmount >= this.coffeeCacheUsePerItem){
if(this.storage.getEnergyStored() >= energyUsePerTick){
this.brewTime++; this.brewTime++;
this.storage.extractEnergy(energyUsePerTick, false);
if(this.brewTime >= this.maxBrewTime){ if(this.brewTime >= this.maxBrewTime){
this.brewTime = 0; this.brewTime = 0;
ItemStack output = new ItemStack(InitItems.itemCoffee); ItemStack output = new ItemStack(InitItems.itemCoffee);
while(getFirstAvailIngredient() > 0){ for(int i = 3; i < this.slots.length; i++){
int ingr = this.getFirstAvailIngredient(); if(this.slots[i] != null && ItemCoffee.getIngredientFromStack((this.slots[i])) != null){
ItemCoffee.Ingredient ingredient = ItemCoffee.getIngredientFromStack(this.slots[ingr]); ItemCoffee.Ingredient ingredient = ItemCoffee.getIngredientFromStack(this.slots[i]);
if(ingredient != null){ if(ingredient != null){
ingredient.effect(output); ingredient.effect(output);
} }
this.slots[ingr].stackSize--; this.slots[i].stackSize--;
if(this.slots[ingr].stackSize <= 0) this.slots[ingr] = this.slots[ingr].getItem().getContainerItem(this.slots[ingr]); if(this.slots[i].stackSize <= 0) this.slots[i] = this.slots[i].getItem().getContainerItem(this.slots[i]);
}
} }
this.slots[SLOT_OUTPUT] = output.copy(); this.slots[SLOT_OUTPUT] = output.copy();
this.slots[SLOT_INPUT].stackSize--; this.slots[SLOT_INPUT].stackSize--;
@ -79,21 +82,11 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
this.coffeeCacheAmount -= this.coffeeCacheUsePerItem; this.coffeeCacheAmount -= this.coffeeCacheUsePerItem;
} }
} }
}
else this.brewTime = 0; else this.brewTime = 0;
if(this.brewTime > 0) this.storage.extractEnergy(energyUsePerTick, false);
} }
} }
public int getFirstAvailIngredient(){
for(int i = 3; i < this.slots.length; i++){
if(this.slots[i] != null && this.slots[i].stackSize == 1 && ItemCoffee.getIngredientFromStack((this.slots[i])) != null){
return i;
}
}
return 0;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getCoffeeScaled(int i){ public int getCoffeeScaled(int i){
return this.coffeeCacheAmount * i / this.coffeeCacheMaxAmount; return this.coffeeCacheAmount * i / this.coffeeCacheMaxAmount;
@ -127,7 +120,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal()); return (i >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal());
} }
@Override @Override

View file

@ -38,31 +38,30 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
boolean canSmeltOnFirst = this.canSmeltOn(SLOT_INPUT_1, SLOT_OUTPUT_1); boolean canSmeltOnFirst = this.canSmeltOn(SLOT_INPUT_1, SLOT_OUTPUT_1);
boolean canSmeltOnSecond = this.canSmeltOn(SLOT_INPUT_2, SLOT_OUTPUT_2); boolean canSmeltOnSecond = this.canSmeltOn(SLOT_INPUT_2, SLOT_OUTPUT_2);
if(this.storage.getEnergyStored() >= energyUsePerTick){
if(canSmeltOnFirst){ if(canSmeltOnFirst){
if(this.storage.getEnergyStored() >= energyUsePerTick){
this.firstSmeltTime++; this.firstSmeltTime++;
if(this.firstSmeltTime >= maxBurnTime){ if(this.firstSmeltTime >= maxBurnTime){
this.finishBurning(SLOT_INPUT_1, SLOT_OUTPUT_1); this.finishBurning(SLOT_INPUT_1, SLOT_OUTPUT_1);
this.firstSmeltTime = 0; this.firstSmeltTime = 0;
} }
} }
}
else this.firstSmeltTime = 0; else this.firstSmeltTime = 0;
if(canSmeltOnSecond){ if(canSmeltOnSecond){
if(this.storage.getEnergyStored() >= energyUsePerTick){
this.secondSmeltTime++; this.secondSmeltTime++;
if(this.secondSmeltTime >= maxBurnTime){ if(this.secondSmeltTime >= maxBurnTime){
this.finishBurning(SLOT_INPUT_2, SLOT_OUTPUT_2); this.finishBurning(SLOT_INPUT_2, SLOT_OUTPUT_2);
this.secondSmeltTime = 0; this.secondSmeltTime = 0;
} }
} }
}
else this.secondSmeltTime = 0; else this.secondSmeltTime = 0;
}
else{
this.firstSmeltTime = 0;
this.secondSmeltTime = 0;
}
if(this.firstSmeltTime > 0 || this.secondSmeltTime > 0) this.storage.extractEnergy(energyUsePerTick, false); if(this.storage.getEnergyStored() >= energyUsePerTick && this.firstSmeltTime > 0 || this.secondSmeltTime > 0) this.storage.extractEnergy(energyUsePerTick, false);
} }
} }

View file

@ -82,33 +82,31 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
boolean canCrushOnSecond = false; boolean canCrushOnSecond = false;
if(this.isDouble) canCrushOnSecond = this.canCrushOn(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2); if(this.isDouble) canCrushOnSecond = this.canCrushOn(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2);
if(this.storage.getEnergyStored() >= energyUsePerTick){
if(canCrushOnFirst){ if(canCrushOnFirst){
if(this.storage.getEnergyStored() >= energyUsePerTick){
this.firstCrushTime++; this.firstCrushTime++;
if(this.firstCrushTime >= maxCrushTime){ if(this.firstCrushTime >= maxCrushTime){
this.finishCrushing(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2); this.finishCrushing(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2);
this.firstCrushTime = 0; this.firstCrushTime = 0;
} }
} }
}
else this.firstCrushTime = 0; else this.firstCrushTime = 0;
if(this.isDouble){ if(this.isDouble){
if(canCrushOnSecond){ if(canCrushOnSecond){
if(this.storage.getEnergyStored() >= energyUsePerTick){
this.secondCrushTime++; this.secondCrushTime++;
if(this.secondCrushTime >= maxCrushTime){ if(this.secondCrushTime >= maxCrushTime){
this.finishCrushing(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2); this.finishCrushing(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2);
this.secondCrushTime = 0; this.secondCrushTime = 0;
} }
} }
}
else this.secondCrushTime = 0; else this.secondCrushTime = 0;
} }
}
else{
this.firstCrushTime = 0;
this.secondCrushTime = 0;
}
if(this.firstCrushTime > 0 || this.secondCrushTime > 0) this.storage.extractEnergy(energyUsePerTick, false); if(this.storage.getEnergyStored() >= energyUsePerTick && this.firstCrushTime > 0 || this.secondCrushTime > 0) this.storage.extractEnergy(energyUsePerTick, false);
} }
} }

View file

@ -1,67 +0,0 @@
package ellpeck.actuallyadditions.tile;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.ItemSpecialDrop;
import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops;
import ellpeck.actuallyadditions.network.gui.IButtonReactor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor{
public TileEntityXPSolidifier(){
super(12, "xpSolidifier");
}
public int getFirstSlot(int itemsNeeded){
for(int i = 0; i < this.slots.length; i++){
if(this.slots[i] == null || this.slots[i].stackSize <= this.slots[i].getMaxStackSize()-itemsNeeded){
return i;
}
}
return -1;
}
@Override
public boolean canUpdate(){
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return false;
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side){
return this.isItemValidForSlot(slot, stack);
}
@Override
public boolean canExtractItem(int slot, ItemStack stack, int side){
return true;
}
@Override
public void onButtonPressed(int buttonID, EntityPlayer player){
if(!player.worldObj.isRemote){
if(buttonID == 0 && player.experienceTotal >= ItemSpecialDrop.SOLID_XP_AMOUNT){
int slot = this.getFirstSlot(1);
if(slot >= 0){
if(this.slots[slot] != null){
this.slots[slot].stackSize++;
}
else this.slots[slot] = new ItemStack(InitItems.itemSpecialDrop, 1, TheSpecialDrops.SOLIDIFIED_EXPERIENCE.ordinal());
player.addExperience(ItemSpecialDrop.SOLID_XP_AMOUNT);
}
}
else if(buttonID == 1 && player.experienceTotal >= 64*ItemSpecialDrop.SOLID_XP_AMOUNT){
int slot = this.getFirstSlot(64);
if(slot >= 0){
this.slots[slot] = new ItemStack(InitItems.itemSpecialDrop, 64, TheSpecialDrops.SOLIDIFIED_EXPERIENCE.ordinal());
player.addExperience(64*ItemSpecialDrop.SOLID_XP_AMOUNT);
}
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 383 B

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 B

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 377 B

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 B

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 490 B