mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
fix: yeet solar furnace?
This commit is contained in:
parent
4273fdd0f5
commit
5236744941
1 changed files with 118 additions and 117 deletions
|
@ -1,117 +1,118 @@
|
||||||
/*
|
///*
|
||||||
* This file ("TileEntityFurnaceSolar.java") is part of the Actually Additions mod for Minecraft.
|
// * This file ("TileEntityFurnaceSolar.java") is part of the Actually Additions mod for Minecraft.
|
||||||
* It is created and owned by Ellpeck and distributed
|
// * It is created and owned by Ellpeck and distributed
|
||||||
* under the Actually Additions License to be found at
|
// * under the Actually Additions License to be found at
|
||||||
* http://ellpeck.de/actaddlicense
|
// * http://ellpeck.de/actaddlicense
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
*
|
// *
|
||||||
* © 2015-2017 Ellpeck
|
// * © 2015-2017 Ellpeck
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
//package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
//
|
||||||
import net.minecraft.block.BlockState;
|
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
//import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
//import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.Direction;
|
//import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
//import net.minecraft.util.Direction;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
//import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
//import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
//import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
|
//
|
||||||
|
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
|
||||||
public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay {
|
//
|
||||||
|
//public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay {
|
||||||
public static final int PRODUCE = 8;
|
//
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 100);
|
// public static final int PRODUCE = 8;
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
// public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 100);
|
||||||
private int oldEnergy;
|
// public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
||||||
|
// private int oldEnergy;
|
||||||
public TileEntityFurnaceSolar() {
|
//
|
||||||
super(ActuallyTiles.SOLAR_TILE.get());
|
// public TileEntityFurnaceSolar() {
|
||||||
}
|
// super(ActuallyBlocks.SO.SOLAR_TILE.get());
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
|
// @Override
|
||||||
super.writeSyncableNBT(compound, type);
|
// public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
|
||||||
this.storage.writeToNBT(compound);
|
// super.writeSyncableNBT(compound, type);
|
||||||
}
|
// this.storage.writeToNBT(compound);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void readSyncableNBT(CompoundNBT compound, NBTType type) {
|
// @Override
|
||||||
super.readSyncableNBT(compound, type);
|
// public void readSyncableNBT(CompoundNBT compound, NBTType type) {
|
||||||
this.storage.readFromNBT(compound);
|
// super.readSyncableNBT(compound, type);
|
||||||
}
|
// this.storage.readFromNBT(compound);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void updateEntity() {
|
// @Override
|
||||||
super.updateEntity();
|
// public void updateEntity() {
|
||||||
if (!this.level.isClientSide) {
|
// super.updateEntity();
|
||||||
int power = this.getPowerToGenerate(PRODUCE);
|
// if (!this.level.isClientSide) {
|
||||||
if (this.level.isDay() && power > 0) {
|
// int power = this.getPowerToGenerate(PRODUCE);
|
||||||
if (power <= this.storage.getMaxEnergyStored() - this.storage.getEnergyStored()) {
|
// if (this.level.isDay() && power > 0) {
|
||||||
this.storage.receiveEnergyInternal(power, false);
|
// if (power <= this.storage.getMaxEnergyStored() - this.storage.getEnergyStored()) {
|
||||||
this.setChanged();
|
// this.storage.receiveEnergyInternal(power, false);
|
||||||
}
|
// this.setChanged();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) {
|
//
|
||||||
this.oldEnergy = this.storage.getEnergyStored();
|
// if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) {
|
||||||
}
|
// this.oldEnergy = this.storage.getEnergyStored();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
public int getPowerToGenerate(int power) {
|
//
|
||||||
for (int y = 1; y <= this.level.getMaxBuildHeight() - this.worldPosition.getY(); y++) {
|
// public int getPowerToGenerate(int power) {
|
||||||
if (power > 0) {
|
// for (int y = 1; y <= this.level.getMaxBuildHeight() - this.worldPosition.getY(); y++) {
|
||||||
BlockPos pos = this.worldPosition.above(y);
|
// if (power > 0) {
|
||||||
BlockState state = this.level.getBlockState(pos);
|
// BlockPos pos = this.worldPosition.above(y);
|
||||||
|
// BlockState state = this.level.getBlockState(pos);
|
||||||
if (state.getMaterial().isSolidBlocking()) {
|
//
|
||||||
power = 0;
|
// if (state.getMaterial().isSolidBlocking()) {
|
||||||
} else if (!state.getBlock().isAir(state, this.level, pos)) {
|
// power = 0;
|
||||||
power--;
|
// } else if (!state.getBlock().isAir(state, this.level, pos)) {
|
||||||
}
|
// power--;
|
||||||
} else {
|
// }
|
||||||
break;
|
// } else {
|
||||||
}
|
// break;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
return power;
|
//
|
||||||
}
|
// return power;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public CustomEnergyStorage getEnergyStorage() {
|
// @Override
|
||||||
return this.storage;
|
// public CustomEnergyStorage getEnergyStorage() {
|
||||||
}
|
// return this.storage;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean needsHoldShift() {
|
// @Override
|
||||||
return false;
|
// public boolean needsHoldShift() {
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public int getEnergyToSplitShare() {
|
// @Override
|
||||||
return this.storage.getEnergyStored();
|
// public int getEnergyToSplitShare() {
|
||||||
}
|
// return this.storage.getEnergyStored();
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean doesShareEnergy() {
|
// @Override
|
||||||
return true;
|
// public boolean doesShareEnergy() {
|
||||||
}
|
// return true;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public Direction[] getEnergyShareSides() {
|
// @Override
|
||||||
return Direction.values();
|
// public Direction[] getEnergyShareSides() {
|
||||||
}
|
// return Direction.values();
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean canShareTo(TileEntity tile) {
|
// @Override
|
||||||
return true;
|
// public boolean canShareTo(TileEntity tile) {
|
||||||
}
|
// return true;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
// @Override
|
||||||
return this.lazyEnergy;
|
// public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
||||||
}
|
// return this.lazyEnergy;
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
Loading…
Reference in a new issue