Wires now transfer energy from all mods and manages it as EU. (#686)
* Wires now transfer energy from all mods and manages it as EU. Multipart will fire in hell. * Fix TechReborn to work with latest RebornCore
This commit is contained in:
parent
23419451e7
commit
6f54e3801f
35 changed files with 258 additions and 134 deletions
|
@ -9,15 +9,10 @@ import java.util.List;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class TileBatBox extends TileEnergyStorage implements IListInfoProvider
|
||||
{
|
||||
public class TileBatBox extends TileEnergyStorage {
|
||||
|
||||
public TileBatBox()
|
||||
{
|
||||
public TileBatBox() {
|
||||
super("BatBox", 2, ModBlocks.batBox, EnumPowerTier.LOW, 32, 32, 40000);
|
||||
}
|
||||
@Override public void addInfo(List<String> info, boolean isRealTile)
|
||||
{
|
||||
info.add("Batbox");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package techreborn.tiles.storage;
|
||||
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.common.IWrenchable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -13,13 +14,14 @@ import reborncore.common.powerSystem.PoweredItem;
|
|||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.blocks.storage.BlockEnergyStorage;
|
||||
import techreborn.power.PowerNet;
|
||||
import techreborn.power.EnergyUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable, ITickable, IInventoryProvider
|
||||
{
|
||||
public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable, ITickable, IInventoryProvider, IListInfoProvider {
|
||||
|
||||
public Inventory inventory;
|
||||
public String name;
|
||||
|
@ -28,8 +30,8 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
public int maxInput;
|
||||
public int maxOutput;
|
||||
public int maxStorage;
|
||||
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage)
|
||||
{
|
||||
|
||||
public TileEnergyStorage(String name, int invSize, Block wrenchDrop, EnumPowerTier tier, int maxInput, int maxOuput, int maxStorage) {
|
||||
super(1);
|
||||
inventory = new Inventory(invSize, "Tile" + name, 64, this);
|
||||
this.wrenchDrop = wrenchDrop;
|
||||
|
@ -40,22 +42,29 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
this.maxStorage = maxStorage;
|
||||
}
|
||||
|
||||
@Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side)
|
||||
{
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
info.add(name);
|
||||
super.addInfo(info, isRealTile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, EnumFacing side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public EnumFacing getFacing()
|
||||
{
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return getFacingEnum();
|
||||
}
|
||||
|
||||
@Override public boolean wrenchCanRemove(EntityPlayer entityPlayer)
|
||||
{
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
return entityPlayer.isSneaking();
|
||||
}
|
||||
|
||||
@Override public void updateEntity() {
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (inventory.getStackInSlot(0) != null) {
|
||||
ItemStack stack = inventory.getStackInSlot(0);
|
||||
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
|
||||
|
@ -85,7 +94,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
|
||||
if (!worldObj.isRemote && getEnergy() > 0) {
|
||||
double maxOutput = getEnergy() > getMaxOutput() ? getMaxOutput() : getEnergy();
|
||||
useEnergy(PowerNet.dispatchEnergyPacket(worldObj, getPos(), maxOutput));
|
||||
useEnergy(EnergyUtils.dispatchEnergyToNeighbours(worldObj, getPos(), this, maxOutput));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,54 +104,53 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing));
|
||||
}
|
||||
|
||||
@Override public float getWrenchDropRate()
|
||||
{
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
|
||||
{
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(wrenchDrop);
|
||||
}
|
||||
|
||||
@Override public double getMaxPower()
|
||||
{
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return maxStorage;
|
||||
}
|
||||
|
||||
@Override public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||
|
||||
return getFacingEnum() != direction;
|
||||
}
|
||||
|
||||
@Override public EnumFacing getFacingEnum()
|
||||
{
|
||||
@Override
|
||||
public EnumFacing getFacingEnum() {
|
||||
Block block = worldObj.getBlockState(pos).getBlock();
|
||||
if (block instanceof BlockEnergyStorage)
|
||||
{
|
||||
if (block instanceof BlockEnergyStorage) {
|
||||
return ((BlockEnergyStorage) block).getFacing(worldObj.getBlockState(pos));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction) {
|
||||
return getFacing() == direction;
|
||||
}
|
||||
|
||||
@Override public double getMaxOutput()
|
||||
{
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return maxOutput;
|
||||
}
|
||||
|
||||
@Override public double getMaxInput()
|
||||
{
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
@Override public EnumPowerTier getTier()
|
||||
{
|
||||
@Override
|
||||
public EnumPowerTier getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
|
@ -150,4 +158,5 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
|
|||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,11 +6,9 @@ import techreborn.init.ModBlocks;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class TileMFE extends TileEnergyStorage
|
||||
{
|
||||
public class TileMFE extends TileEnergyStorage {
|
||||
|
||||
public TileMFE()
|
||||
{
|
||||
public TileMFE() {
|
||||
super("MFE", 2, ModBlocks.mfe, EnumPowerTier.MEDIUM, 512, 512, 4000000);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,10 @@ import techreborn.init.ModBlocks;
|
|||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class TileMFSU extends TileEnergyStorage
|
||||
{
|
||||
public class TileMFSU extends TileEnergyStorage {
|
||||
|
||||
public TileMFSU()
|
||||
{
|
||||
public TileMFSU() {
|
||||
super("MFSU", 2, ModBlocks.mfsu, EnumPowerTier.HIGH, 2048, 2048, 40000000);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue