-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 ellpeck.actuallyadditions.inventory.slot.SlotOutput;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.items.ItemCoffee;
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
import ellpeck.actuallyadditions.tile.TileEntityBase;
import ellpeck.actuallyadditions.tile.TileEntityCoffeeMachine;
@ -33,13 +34,7 @@ public class ContainerCoffeeMachine extends Container{
for (int i = 0; i < 4; i++){
for (int j = 0; j < 2; j++){
this.addSlotToContainer(new Slot(machine, j+i*2+3, 125+j*18, 6+i*18){
@Override
public int getSlotStackLimit(){
return 1;
}
});
this.addSlotToContainer(new Slot(machine, j+i*2+3, 125+j*18, 6+i*18));
}
}
@ -111,6 +106,9 @@ public class ContainerCoffeeMachine extends Container{
if(currentStack.getItem() == InitItems.itemMisc && currentStack.getItemDamage() == TheMiscItems.CUP.ordinal()){
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){

View file

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

View file

@ -35,16 +35,19 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
@SuppressWarnings("unchecked")
public void updateEntity(){
if(!worldObj.isRemote){
if(this.isCanola(0) && this.storage.getEnergyStored() >= energyUsedPerTick && this.mbProducedPerCanola <= this.tank.getCapacity()-this.tank.getFluidAmount()){
this.currentProcessTime++;
if(this.currentProcessTime >= this.maxTimeProcessing){
this.currentProcessTime = 0;
if(this.isCanola(0) && this.mbProducedPerCanola <= this.tank.getCapacity()-this.tank.getFluidAmount()){
if(this.storage.getEnergyStored() >= energyUsedPerTick){
this.currentProcessTime++;
this.storage.extractEnergy(energyUsedPerTick, false);
if(this.currentProcessTime >= this.maxTimeProcessing){
this.currentProcessTime = 0;
this.slots[0].stackSize--;
if(this.slots[0].stackSize == 0) this.slots[0] = null;
this.slots[0].stackSize--;
if(this.slots[0].stackSize == 0) this.slots[0] = null;
this.tank.fill(new FluidStack(InitBlocks.fluidCanolaOil, mbProducedPerCanola), true);
this.markDirty();
this.tank.fill(new FluidStack(InitBlocks.fluidCanolaOil, mbProducedPerCanola), true);
this.markDirty();
}
}
}
else this.currentProcessTime = 0;
@ -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){
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){
this.storeCoffee();
if(this.brewTime > 0){
if(this.brewTime > 0 || this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
this.brew();
}
}
@ -59,41 +59,34 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
public void brew(){
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){
this.brewTime++;
if(this.brewTime >= this.maxBrewTime){
this.brewTime = 0;
ItemStack output = new ItemStack(InitItems.itemCoffee);
while(getFirstAvailIngredient() > 0){
int ingr = this.getFirstAvailIngredient();
ItemCoffee.Ingredient ingredient = ItemCoffee.getIngredientFromStack(this.slots[ingr]);
if(ingredient != null){
ingredient.effect(output);
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.storage.extractEnergy(energyUsePerTick, false);
if(this.brewTime >= this.maxBrewTime){
this.brewTime = 0;
ItemStack output = new ItemStack(InitItems.itemCoffee);
for(int i = 3; i < this.slots.length; i++){
if(this.slots[i] != null && ItemCoffee.getIngredientFromStack((this.slots[i])) != null){
ItemCoffee.Ingredient ingredient = ItemCoffee.getIngredientFromStack(this.slots[i]);
if(ingredient != null){
ingredient.effect(output);
}
this.slots[i].stackSize--;
if(this.slots[i].stackSize <= 0) this.slots[i] = this.slots[i].getItem().getContainerItem(this.slots[i]);
}
}
this.slots[ingr].stackSize--;
if(this.slots[ingr].stackSize <= 0) this.slots[ingr] = this.slots[ingr].getItem().getContainerItem(this.slots[ingr]);
this.slots[SLOT_OUTPUT] = output.copy();
this.slots[SLOT_INPUT].stackSize--;
if(this.slots[SLOT_INPUT].stackSize <= 0) this.slots[SLOT_INPUT] = null;
this.coffeeCacheAmount -= this.coffeeCacheUsePerItem;
}
this.slots[SLOT_OUTPUT] = output.copy();
this.slots[SLOT_INPUT].stackSize--;
if(this.slots[SLOT_INPUT].stackSize <= 0) this.slots[SLOT_INPUT] = null;
this.coffeeCacheAmount -= this.coffeeCacheUsePerItem;
}
}
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)
public int getCoffeeScaled(int i){
return this.coffeeCacheAmount * i / this.coffeeCacheMaxAmount;
@ -127,7 +120,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
@Override
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

View file

@ -38,31 +38,30 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
boolean canSmeltOnFirst = this.canSmeltOn(SLOT_INPUT_1, SLOT_OUTPUT_1);
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++;
if(this.firstSmeltTime >= maxBurnTime){
this.finishBurning(SLOT_INPUT_1, SLOT_OUTPUT_1);
this.firstSmeltTime = 0;
}
}
else this.firstSmeltTime = 0;
}
else this.firstSmeltTime = 0;
if(canSmeltOnSecond){
if(canSmeltOnSecond){
if(this.storage.getEnergyStored() >= energyUsePerTick){
this.secondSmeltTime++;
if(this.secondSmeltTime >= maxBurnTime){
this.finishBurning(SLOT_INPUT_2, SLOT_OUTPUT_2);
this.secondSmeltTime = 0;
}
}
else this.secondSmeltTime = 0;
}
else{
this.firstSmeltTime = 0;
this.secondSmeltTime = 0;
}
else 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;
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++;
if(this.firstCrushTime >= maxCrushTime){
this.finishCrushing(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2);
this.firstCrushTime = 0;
}
}
else this.firstCrushTime = 0;
}
else this.firstCrushTime = 0;
if(this.isDouble){
if(canCrushOnSecond){
if(this.isDouble){
if(canCrushOnSecond){
if(this.storage.getEnergyStored() >= energyUsePerTick){
this.secondCrushTime++;
if(this.secondCrushTime >= maxCrushTime){
this.finishCrushing(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2);
this.secondCrushTime = 0;
}
}
else this.secondCrushTime = 0;
}
}
else{
this.firstCrushTime = 0;
this.secondCrushTime = 0;
else 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