mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 03:49:22 +01:00
Added internal energy methods to avoid things only using energy up to their cap
This commit is contained in:
parent
377973fc9c
commit
3ed5e9cc8a
35 changed files with 142 additions and 72 deletions
|
@ -73,7 +73,7 @@ public class BlockShockSuppressor extends BlockContainerBase{
|
|||
|
||||
for(BlockPos pos : posesToRemove){
|
||||
if(suppressor.storage.getEnergyStored() >= use){
|
||||
suppressor.storage.extractEnergy(use, false);
|
||||
suppressor.storage.extractEnergyInternal(use, false);
|
||||
affectedBlocks.remove(pos);
|
||||
}
|
||||
else{
|
||||
|
@ -82,7 +82,7 @@ public class BlockShockSuppressor extends BlockContainerBase{
|
|||
}
|
||||
for(Entity entity : entitiesToRemove){
|
||||
if(suppressor.storage.getEnergyStored() >= use){
|
||||
suppressor.storage.extractEnergy(use, false);
|
||||
suppressor.storage.extractEnergyInternal(use, false);
|
||||
affectedEntities.remove(entity);
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
import cofh.api.energy.EnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
|
@ -28,22 +29,22 @@ import java.util.List;
|
|||
|
||||
public class EnergyDisplay extends Gui{
|
||||
|
||||
private EnergyStorage rfReference;
|
||||
private CustomEnergyStorage rfReference;
|
||||
private int x;
|
||||
private int y;
|
||||
private boolean outline;
|
||||
private boolean drawTextNextTo;
|
||||
private boolean displayTesla;
|
||||
|
||||
public EnergyDisplay(int x, int y, EnergyStorage rfReference, boolean outline, boolean drawTextNextTo){
|
||||
public EnergyDisplay(int x, int y, CustomEnergyStorage rfReference, boolean outline, boolean drawTextNextTo){
|
||||
this.setData(x, y, rfReference, outline, drawTextNextTo);
|
||||
}
|
||||
|
||||
public EnergyDisplay(int x, int y, EnergyStorage rfReference){
|
||||
public EnergyDisplay(int x, int y, CustomEnergyStorage rfReference){
|
||||
this(x, y, rfReference, false, false);
|
||||
}
|
||||
|
||||
public void setData(int x, int y, EnergyStorage rfReference, boolean outline, boolean drawTextNextTo){
|
||||
public void setData(int x, int y, CustomEnergyStorage rfReference, boolean outline, boolean drawTextNextTo){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.rfReference = rfReference;
|
||||
|
|
|
@ -183,7 +183,7 @@ public class ItemDrill extends ItemEnergy{
|
|||
public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2){
|
||||
int use = this.getEnergyUsePerBlock(stack);
|
||||
if(this.getEnergyStored(stack) >= use){
|
||||
this.extractEnergy(stack, use, false);
|
||||
this.extractEnergyInternal(stack, use, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ public class ItemDrill extends ItemEnergy{
|
|||
float hardness = block.getBlockHardness(state, world, pos);
|
||||
boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getStrVsBlock(stack, world.getBlockState(pos)) > 1.0F);
|
||||
if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(world.getBlockState(pos))))){
|
||||
this.extractEnergy(stack, use, false);
|
||||
this.extractEnergyInternal(stack, use, false);
|
||||
//Break the Block
|
||||
return WorldUtil.playerHarvestBlock(stack, world, player, pos);
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ public class ItemFillingWand extends ItemEnergy{
|
|||
world.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume()+1.0F)/2.0F, sound.getPitch()*0.8F);
|
||||
|
||||
if(!creative){
|
||||
this.extractEnergy(stack, energyUse, false);
|
||||
this.extractEnergyInternal(stack, energyUse, false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ItemGrowthRing extends ItemEnergy{
|
|||
}
|
||||
|
||||
if(!player.capabilities.isCreativeMode){
|
||||
this.extractEnergy(stack, energyUse, false);
|
||||
this.extractEnergyInternal(stack, energyUse, false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ItemMagnetRing extends ItemEnergy{
|
|||
item.onCollideWithPlayer(player);
|
||||
|
||||
if(!player.capabilities.isCreativeMode){
|
||||
this.extractEnergy(stack, energyForItem, false);
|
||||
this.extractEnergyInternal(stack, energyForItem, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ItemTeleStaff extends ItemEnergy{
|
|||
player.dismountRidingEntity();
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
if(!player.capabilities.isCreativeMode){
|
||||
this.extractEnergy(stack, use, false);
|
||||
this.extractEnergyInternal(stack, use, false);
|
||||
player.getCooldownTracker().setCooldown(this, 50);
|
||||
}
|
||||
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ItemWaterRemovalRing extends ItemEnergy{
|
|||
world.setBlockToAir(pos);
|
||||
|
||||
if(!player.capabilities.isCreativeMode){
|
||||
this.extractEnergy(stack, energyUse, false);
|
||||
this.extractEnergyInternal(stack, energyUse, false);
|
||||
}
|
||||
}
|
||||
//Remove Lava
|
||||
|
@ -65,7 +65,7 @@ public class ItemWaterRemovalRing extends ItemEnergy{
|
|||
world.setBlockToAir(pos);
|
||||
|
||||
if(!player.capabilities.isCreativeMode){
|
||||
this.extractEnergy(stack, energyUse*2, false);
|
||||
this.extractEnergyInternal(stack, energyUse*2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,4 +122,24 @@ public abstract class ItemEnergy extends ItemEnergyContainer{
|
|||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt){
|
||||
return ActuallyAdditions.teslaLoaded ? new ItemTeslaWrapper(stack, this) : null;
|
||||
}
|
||||
|
||||
public int extractEnergyInternal(ItemStack stack, int maxExtract, boolean simulate){
|
||||
int before = this.maxExtract;
|
||||
this.setMaxExtract(Integer.MAX_VALUE);
|
||||
|
||||
int toReturn = this.extractEnergy(stack, maxExtract, simulate);
|
||||
|
||||
this.setMaxExtract(before);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public int receiveEnergyInternal(ItemStack stack, int maxReceive, boolean simulate){
|
||||
int before = this.maxReceive;
|
||||
this.setMaxReceive(Integer.MAX_VALUE);
|
||||
|
||||
int toReturn = this.receiveEnergy(stack, maxReceive, simulate);
|
||||
|
||||
this.setMaxReceive(before);
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* This file ("CustomEnergyStorage.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
|
||||
public class CustomEnergyStorage extends EnergyStorage{
|
||||
|
||||
public CustomEnergyStorage(int capacity){
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
public CustomEnergyStorage(int capacity, int maxTransfer){
|
||||
super(capacity, maxTransfer);
|
||||
}
|
||||
|
||||
public CustomEnergyStorage(int capacity, int maxReceive, int maxExtract){
|
||||
super(capacity, maxReceive, maxExtract);
|
||||
}
|
||||
|
||||
public int extractEnergyInternal(int maxExtract, boolean simulate){
|
||||
int before = this.maxExtract;
|
||||
this.setMaxExtract(Integer.MAX_VALUE);
|
||||
|
||||
int toReturn = this.extractEnergy(maxExtract, simulate);
|
||||
|
||||
this.setMaxExtract(before);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public int receiveEnergyInternal(int maxReceive, boolean simulate){
|
||||
int before = this.maxReceive;
|
||||
this.setMaxReceive(Integer.MAX_VALUE);
|
||||
|
||||
int toReturn = this.receiveEnergy(maxReceive, simulate);
|
||||
|
||||
this.setMaxReceive(before);
|
||||
return toReturn;
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
public interface IEnergyDisplay{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
EnergyStorage getEnergyStorage();
|
||||
CustomEnergyStorage getEnergyStorage();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
boolean needsHoldShift();
|
||||
|
|
|
@ -30,7 +30,7 @@ import net.minecraft.world.World;
|
|||
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements ICustomEnergyReceiver, IEnergyDisplay, IAtomicReconstructor{
|
||||
|
||||
public static final int ENERGY_USE = 1000;
|
||||
public final EnergyStorage storage = new EnergyStorage(300000, 5000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 5000);
|
||||
public int counter;
|
||||
private int currentTime;
|
||||
private int oldEnergy;
|
||||
|
@ -100,7 +100,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
Lens currentLens = this.getLens();
|
||||
if(currentLens.canInvoke(this, sideToManipulate, ENERGY_USE)){
|
||||
//Extract energy for shooting the laser itself too!
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
|
||||
int distance = currentLens.getDistance();
|
||||
for(int i = 0; i < distance; i++){
|
||||
|
@ -147,7 +147,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
|
||||
@Override
|
||||
public void extractEnergy(int amount){
|
||||
this.storage.extractEnergy(amount, false);
|
||||
this.storage.extractEnergyInternal(amount, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -197,7 +197,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
|
||||
public class TileEntityBioReactor extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
public final EnergyStorage storage = new EnergyStorage(200000, 800);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 800);
|
||||
|
||||
public int burnTime;
|
||||
public int maxBurnTime;
|
||||
|
@ -98,7 +98,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
|||
}
|
||||
else{
|
||||
this.burnTime--;
|
||||
this.storage.receiveEnergy(this.producePerTick, false);
|
||||
this.storage.receiveEnergyInternal(this.producePerTick, false);
|
||||
}
|
||||
|
||||
if((this.lastBurnTime != this.burnTime || this.lastProducePerTick != this.producePerTick) && this.sendUpdateWithInterval()){
|
||||
|
|
|
@ -30,7 +30,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IC
|
|||
public static final int PRODUCE = 80;
|
||||
public static final int ENERGY_USE = 35;
|
||||
private static final int TIME = 30;
|
||||
public final EnergyStorage storage = new EnergyStorage(40000, 100);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(40000, 100);
|
||||
public final FluidTank tank = new FluidTank(2*Util.BUCKET){
|
||||
@Override
|
||||
public boolean canFill(){
|
||||
|
@ -88,7 +88,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IC
|
|||
if(this.isCanola(0) && PRODUCE <= this.tank.getCapacity()-this.tank.getFluidAmount()){
|
||||
if(this.storage.getEnergyStored() >= ENERGY_USE){
|
||||
this.currentProcessTime++;
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
if(this.currentProcessTime >= TIME){
|
||||
this.currentProcessTime = 0;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
public static final int PRODUCE = 30;
|
||||
public final EnergyStorage storage = new EnergyStorage(60000, 80);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 80);
|
||||
public int maxBurnTime;
|
||||
public int currentBurnTime;
|
||||
private int lastEnergy;
|
||||
|
@ -71,7 +71,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
|||
|
||||
if(this.currentBurnTime > 0){
|
||||
this.currentBurnTime--;
|
||||
this.storage.receiveEnergy(PRODUCE, false);
|
||||
this.storage.receiveEnergyInternal(PRODUCE, false);
|
||||
}
|
||||
|
||||
if(this.currentBurnTime <= 0 && StackUtil.isValid(this.slots.get(0)) && TileEntityFurnace.getItemBurnTime(this.slots.get(0)) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){
|
||||
|
|
|
@ -40,7 +40,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
public static final int WATER_USE = 500;
|
||||
public static final int COFFEE_CACHE_MAX_AMOUNT = 300;
|
||||
private static final int TIME_USED = 500;
|
||||
public final EnergyStorage storage = new EnergyStorage(300000, 250);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 250);
|
||||
public final FluidTank tank = new FluidTank(4*Util.BUCKET){
|
||||
@Override
|
||||
public boolean canDrain(){
|
||||
|
@ -148,7 +148,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
}
|
||||
|
||||
this.brewTime++;
|
||||
this.storage.extractEnergy(ENERGY_USED, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USED, false);
|
||||
if(this.brewTime >= TIME_USED){
|
||||
this.brewTime = 0;
|
||||
ItemStack output = new ItemStack(InitItems.itemCoffee);
|
||||
|
|
|
@ -28,7 +28,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
|
||||
public static final int RANGE = 8;
|
||||
public static final int ENERGY_USE = 5;
|
||||
public final EnergyStorage storage = new EnergyStorage(10000, 20);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(10000, 20);
|
||||
private int lastEnergy;
|
||||
private int currentTime;
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
this.worldObj.playEvent(2001, coordsBlock, Block.getStateId(this.worldObj.getBlockState(coordsBlock)));
|
||||
this.worldObj.setBlockToAir(coordsBlock);
|
||||
WorldUtil.addToInventory(this, drops, true, true);
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraft.util.EnumFacing;
|
|||
|
||||
public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay, ICustomEnergyReceiver{
|
||||
|
||||
public final EnergyStorage storage = new EnergyStorage(80000, 1000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(80000, 1000);
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityDisplayStand(){
|
||||
|
@ -40,7 +40,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
|||
int energy = item.getUsePerTick(this.slots.get(0), this, this.ticksElapsed);
|
||||
if(this.storage.getEnergyStored() >= energy){
|
||||
if(item.update(this.slots.get(0), this, this.ticksElapsed)){
|
||||
this.storage.extractEnergy(energy, false);
|
||||
this.storage.extractEnergyInternal(energy, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
|
|||
boolean done = this.processTime >= recipe.time;
|
||||
|
||||
for(TileEntityDisplayStand stand : modifierStands){
|
||||
stand.storage.extractEnergy(recipe.energyPerStand/recipe.time, false);
|
||||
stand.storage.extractEnergyInternal(recipe.energyPerStand/recipe.time, false);
|
||||
|
||||
if(done){
|
||||
stand.decrStackSize(0, 1);
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
public class TileEntityEnergizer extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
|
||||
public final EnergyStorage storage = new EnergyStorage(50000, 1000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000);
|
||||
private int lastEnergy;
|
||||
|
||||
public TileEntityEnergizer(){
|
||||
|
@ -73,7 +73,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements ICus
|
|||
}
|
||||
}
|
||||
if(received > 0){
|
||||
this.storage.extractEnergy(received, false);
|
||||
this.storage.extractEnergyInternal(received, false);
|
||||
}
|
||||
|
||||
if(canTakeUp){
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
public class TileEntityEnervator extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
public final EnergyStorage storage = new EnergyStorage(50000, 1000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000);
|
||||
private int lastEnergy;
|
||||
|
||||
public TileEntityEnervator(){
|
||||
|
@ -74,7 +74,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
|
|||
}
|
||||
}
|
||||
if(extracted > 0){
|
||||
this.storage.receiveEnergy(extracted, false);
|
||||
this.storage.receiveEnergyInternal(extracted, false);
|
||||
}
|
||||
|
||||
if(canTakeUp){
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.util.List;
|
|||
public class TileEntityFarmer extends TileEntityInventoryBase implements ICustomEnergyReceiver{
|
||||
|
||||
public static final int USE_PER_OPERATION = 1500;
|
||||
public final EnergyStorage storage = new EnergyStorage(100000, 1000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(100000, 1000);
|
||||
|
||||
private int waitTime;
|
||||
private int checkX;
|
||||
|
@ -145,7 +145,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements ICustom
|
|||
}
|
||||
|
||||
if(didSomething){
|
||||
this.storage.extractEnergy(USE_PER_OPERATION, false);
|
||||
this.storage.extractEnergyInternal(USE_PER_OPERATION, false);
|
||||
}
|
||||
|
||||
this.checkX++;
|
||||
|
|
|
@ -24,7 +24,7 @@ import net.minecraft.world.World;
|
|||
public class TileEntityFireworkBox extends TileEntityBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
|
||||
public static final int USE_PER_SHOT = 300;
|
||||
public final EnergyStorage storage = new EnergyStorage(20000, 200);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(20000, 200);
|
||||
private int timeUntilNextFirework;
|
||||
private int oldEnergy;
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEner
|
|||
if(this.storage.getEnergyStored() >= USE_PER_SHOT){
|
||||
this.spawnFireworks(this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getZ());
|
||||
|
||||
this.storage.extractEnergy(USE_PER_SHOT, false);
|
||||
this.storage.extractEnergyInternal(USE_PER_SHOT, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEner
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
|||
public static final int SLOT_OUTPUT_2 = 3;
|
||||
public static final int ENERGY_USE = 25;
|
||||
private static final int SMELT_TIME = 80;
|
||||
public final EnergyStorage storage = new EnergyStorage(30000, 80);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 80);
|
||||
public int firstSmeltTime;
|
||||
public int secondSmeltTime;
|
||||
public boolean isAutoSplit;
|
||||
|
@ -118,7 +118,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
|||
this.finishBurning(SLOT_INPUT_1, SLOT_OUTPUT_1);
|
||||
this.firstSmeltTime = 0;
|
||||
}
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -132,7 +132,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
|
|||
this.finishBurning(SLOT_INPUT_2, SLOT_OUTPUT_2);
|
||||
this.secondSmeltTime = 0;
|
||||
}
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{
|
||||
|
||||
public static final int PRODUCE = 8;
|
||||
public final EnergyStorage storage = new EnergyStorage(30000, 100);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 100);
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityFurnaceSolar(){
|
||||
|
@ -65,7 +65,7 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEn
|
|||
int power = this.getPowerToGenerate(PRODUCE);
|
||||
if(this.worldObj.isDaytime() && power > 0){
|
||||
if(power <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){
|
||||
this.storage.receiveEnergy(power, false);
|
||||
this.storage.receiveEnergyInternal(power, false);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEn
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
|
|||
public static final int SLOT_OUTPUT_2_1 = 4;
|
||||
public static final int SLOT_OUTPUT_2_2 = 5;
|
||||
public static final int ENERGY_USE = 40;
|
||||
public final EnergyStorage storage = new EnergyStorage(60000, 100);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 100);
|
||||
public int firstCrushTime;
|
||||
public int secondCrushTime;
|
||||
public boolean isDouble;
|
||||
|
@ -125,7 +125,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
|
|||
this.finishCrushing(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2);
|
||||
this.firstCrushTime = 0;
|
||||
}
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -143,7 +143,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
|
|||
this.finishCrushing(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2);
|
||||
this.secondCrushTime = 0;
|
||||
}
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -25,7 +25,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
|
|||
|
||||
public static final int ENERGY_PRODUCE = 40;
|
||||
public static final int BLOCKS_NEEDED = 4;
|
||||
public final EnergyStorage storage = new EnergyStorage(30000, 80);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 80);
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityHeatCollector(){
|
||||
|
@ -60,7 +60,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
|
|||
}
|
||||
|
||||
if(blocksAround.size() >= BLOCKS_NEEDED){
|
||||
this.storage.receiveEnergy(ENERGY_PRODUCE, false);
|
||||
this.storage.receiveEnergyInternal(ENERGY_PRODUCE, false);
|
||||
this.markDirty();
|
||||
|
||||
if(this.worldObj.rand.nextInt(10000) == 0){
|
||||
|
@ -97,7 +97,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
|
|||
public static final int SLOT_INPUT = 0;
|
||||
public static final int SLOT_OUTPUT = 1;
|
||||
public static final int ENERGY_USE = 2500;
|
||||
public final EnergyStorage storage = new EnergyStorage(300000, 6000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 6000);
|
||||
public int nextRepairTick;
|
||||
private int lastEnergy;
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
|
|||
else{
|
||||
if(this.storage.getEnergyStored() >= ENERGY_USE){
|
||||
this.nextRepairTick++;
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
if(this.nextRepairTick >= 4){
|
||||
this.nextRepairTick = 0;
|
||||
input.setItemDamage(input.getItemDamage()-1);
|
||||
|
|
|
@ -27,7 +27,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
|||
public static final int HAS_LAVA = 1;
|
||||
public static final int HAS_AIR = 2;
|
||||
public static final int ENERGY_USE = 150000;
|
||||
public final EnergyStorage storage = new EnergyStorage(300000, 2000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 2000);
|
||||
private int currentWorkTime;
|
||||
private int oldEnergy;
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
|||
if(this.currentWorkTime >= 200){
|
||||
this.currentWorkTime = 0;
|
||||
this.worldObj.setBlockState(this.pos.up(), Blocks.LAVA.getDefaultState(), 2);
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -119,7 +119,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
|
|||
|
||||
public static final int RANGE = 7;
|
||||
public static final int ENERGY_PRODUCED = 300;
|
||||
public final EnergyStorage storage = new EnergyStorage(35000, 450);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(35000, 450);
|
||||
private int nextUseCounter;
|
||||
private int oldEnergy;
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
|
|||
|
||||
this.worldObj.setBlockToAir(theCoord);
|
||||
|
||||
this.storage.receiveEnergy(ENERGY_PRODUCED, false);
|
||||
this.storage.receiveEnergyInternal(ENERGY_PRODUCED, false);
|
||||
|
||||
AssetUtil.shootParticles(this.worldObj, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F, 1F);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements ICustomE
|
|||
|
||||
public static final int ENERGY_USE_PER_BLOCK = 650;
|
||||
public static final int DEFAULT_RANGE = 2;
|
||||
public final EnergyStorage storage = new EnergyStorage(200000, 2000);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 2000);
|
||||
public int layerAt = -1;
|
||||
public boolean onlyMineOres;
|
||||
private int oldLayerAt;
|
||||
|
@ -113,7 +113,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements ICustomE
|
|||
WorldUtil.addToInventory(this, drops, true, true);
|
||||
this.markDirty();
|
||||
|
||||
this.storage.extractEnergy(actualUse, false);
|
||||
this.storage.extractEnergyInternal(actualUse, false);
|
||||
this.shootParticles(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements ICustomE
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler{
|
||||
|
||||
public final EnergyStorage storage = new EnergyStorage(50000, 150);
|
||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 150);
|
||||
public final FluidTank tank = new FluidTank(2*Util.BUCKET){
|
||||
@Override
|
||||
public boolean canDrain(){
|
||||
|
@ -110,7 +110,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
|
||||
if(this.currentBurnTime > 0 && this.currentEnergyProduce > 0){
|
||||
this.currentBurnTime--;
|
||||
this.storage.receiveEnergy(this.currentEnergyProduce, false);
|
||||
this.storage.receiveEnergyInternal(this.currentEnergyProduce, false);
|
||||
}
|
||||
else if(!this.isRedstonePowered){
|
||||
int fuelUsed = 50;
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.UUID;
|
|||
public class TileEntityPlayerInterface extends TileEntityInventoryBase implements ICustomEnergyReceiver, IEnergyDisplay{
|
||||
|
||||
public static final int DEFAULT_RANGE = 32;
|
||||
private final EnergyStorage storage = new EnergyStorage(30000, 50);
|
||||
private final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 50);
|
||||
public UUID connectedPlayer;
|
||||
public String playerName;
|
||||
private int oldEnergy;
|
||||
|
@ -77,7 +77,7 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
|
|||
}
|
||||
|
||||
if(received > 0){
|
||||
this.storage.extractEnergy(received, false);
|
||||
this.storage.extractEnergyInternal(received, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class TileEntityShockSuppressor extends TileEntityBase implements ICustom
|
|||
public static final int USE_PER = 300;
|
||||
public static final int RANGE = 5;
|
||||
|
||||
public EnergyStorage storage = new EnergyStorage(300000, 400);
|
||||
public CustomEnergyStorage storage = new CustomEnergyStorage(300000, 400);
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityShockSuppressor(){
|
||||
|
@ -97,7 +97,7 @@ public class TileEntityShockSuppressor extends TileEntityBase implements ICustom
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnergyStorage getEnergyStorage(){
|
||||
public CustomEnergyStorage getEnergyStorage(){
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.util;
|
|||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
|
Loading…
Reference in a new issue