remove explicit tesla support

tesla api is ded and this will be more work for 1.13 so rip af
This commit is contained in:
Shadows_of_Fire 2017-12-23 15:20:01 -05:00
parent 0400298510
commit 8a1ed7b14b
15 changed files with 29 additions and 250 deletions

View file

@ -33,19 +33,10 @@ minecraft {
repositories { repositories {
maven { maven {
url "http://dvs1.progwml6.com/files/maven" url "http://dvs1.progwml6.com/files/maven"
}
maven {
url "http://maven.epoxide.xyz"
}
maven {
url "http://maven.amadornes.com/"
} }
maven { maven {
url "http://tehnut.info/maven" url "http://tehnut.info/maven"
} }
maven {
url "http://maven.ic2.player.to"
}
maven { maven {
url "https://dl.bintray.com/cyclopsmc/dev/" url "https://dl.bintray.com/cyclopsmc/dev/"
} }
@ -54,8 +45,7 @@ repositories {
dependencies { dependencies {
deobfCompile "mezz.jei:jei_1.12.1:+" deobfCompile "mezz.jei:jei_1.12.1:+"
deobfCompile "mcp.mobius.waila:Hwyla:+" deobfCompile "mcp.mobius.waila:Hwyla:+"
compile "net.darkhax.tesla:Tesla-1.12:+" deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.12.2-+"
deobfCompile "org.cyclops.commoncapabilities:CommonCapabilities:1.12-1.3.3-126"
} }
processResources { processResources {

View file

@ -59,7 +59,6 @@ public class ActuallyAdditions{
@SidedProxy(clientSide = ModUtil.PROXY_CLIENT, serverSide = ModUtil.PROXY_SERVER) @SidedProxy(clientSide = ModUtil.PROXY_CLIENT, serverSide = ModUtil.PROXY_SERVER)
public static IProxy proxy; public static IProxy proxy;
public static boolean teslaLoaded;
public static boolean commonCapsLoaded; public static boolean commonCapsLoaded;
static{ static{
@ -76,7 +75,6 @@ public class ActuallyAdditions{
Lenses.init(); Lenses.init();
InitBooklet.preInit(); InitBooklet.preInit();
teslaLoaded = Loader.isModLoaded("tesla");
commonCapsLoaded = Loader.isModLoaded("commoncapabilities"); commonCapsLoaded = Loader.isModLoaded("commoncapabilities");
MinecraftForge.EVENT_BUS.register(new RegistryHandler()); MinecraftForge.EVENT_BUS.register(new RegistryHandler());

View file

@ -10,13 +10,11 @@
package de.ellpeck.actuallyadditions.mod.inventory; package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
@ -95,7 +93,7 @@ public class ContainerEnergizer extends Container{
//Other Slots in Inventory excluded //Other Slots in Inventory excluded
else if(slot >= inventoryStart){ else if(slot >= inventoryStart){
//Shift from Inventory //Shift from Inventory
if((ActuallyAdditions.teslaLoaded && newStack.hasCapability(TeslaUtil.teslaConsumer, null)) || newStack.hasCapability(CapabilityEnergy.ENERGY, null)){ if(newStack.hasCapability(CapabilityEnergy.ENERGY, null)){
if(!this.mergeItemStack(newStack, 0, 1, false)){ if(!this.mergeItemStack(newStack, 0, 1, false)){
return StackUtil.getEmpty(); return StackUtil.getEmpty();
} }

View file

@ -10,13 +10,11 @@
package de.ellpeck.actuallyadditions.mod.inventory; package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
@ -94,7 +92,7 @@ public class ContainerEnervator extends Container{
//Other Slots in Inventory excluded //Other Slots in Inventory excluded
else if(slot >= inventoryStart){ else if(slot >= inventoryStart){
//Shift from Inventory //Shift from Inventory
if((ActuallyAdditions.teslaLoaded && newStack.hasCapability(TeslaUtil.teslaProducer, null)) || newStack.hasCapability(CapabilityEnergy.ENERGY, null)){ if(newStack.hasCapability(CapabilityEnergy.ENERGY, null)){
if(!this.mergeItemStack(newStack, 0, 1, false)){ if(!this.mergeItemStack(newStack, 0, 1, false)){
return StackUtil.getEmpty(); return StackUtil.getEmpty();
} }

View file

@ -10,14 +10,13 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import java.util.List;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -30,8 +29,6 @@ import net.minecraft.world.World;
import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.energy.IEnergyStorage;
import java.util.List;
public class ItemBattery extends ItemEnergy{ public class ItemBattery extends ItemEnergy{
public ItemBattery(String name, int capacity, int transfer){ public ItemBattery(String name, int capacity, int transfer){
@ -65,12 +62,6 @@ public class ItemBattery extends ItemEnergy{
received = cap.receiveEnergy(extractable, false); received = cap.receiveEnergy(extractable, false);
} }
} }
else if(ActuallyAdditions.teslaLoaded && slot.hasCapability(TeslaUtil.teslaConsumer, null)){
ITeslaConsumer cap = slot.getCapability(TeslaUtil.teslaConsumer, null);
if(cap != null){
received = (int)cap.givePower(extractable, false);
}
}
if(received > 0){ if(received > 0){
this.extractEnergy(stack, received, false); this.extractEnergy(stack, received, false);

View file

@ -10,11 +10,14 @@
package de.ellpeck.actuallyadditions.mod.items.base; package de.ellpeck.actuallyadditions.mod.items.base;
import java.text.NumberFormat;
import java.util.List;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage; import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaForgeUnitsWrapper;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -31,10 +34,6 @@ import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.text.NumberFormat;
import java.util.List;
public abstract class ItemEnergy extends ItemBase{ public abstract class ItemEnergy extends ItemBase{
private final int maxPower; private final int maxPower;
@ -72,7 +71,6 @@ public abstract class ItemEnergy extends ItemBase{
} }
@Override @Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list){ public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list){
if(this.isInCreativeTab(tabs)){ if(this.isInCreativeTab(tabs)){
ItemStack stackFull = new ItemStack(this); ItemStack stackFull = new ItemStack(this);
@ -195,7 +193,6 @@ public abstract class ItemEnergy extends ItemBase{
private static class EnergyCapabilityProvider implements ICapabilityProvider{ private static class EnergyCapabilityProvider implements ICapabilityProvider{
public final CustomEnergyStorage storage; public final CustomEnergyStorage storage;
private Object teslaWrapper;
public EnergyCapabilityProvider(final ItemStack stack, ItemEnergy item){ public EnergyCapabilityProvider(final ItemStack stack, ItemEnergy item){
this.storage = new CustomEnergyStorage(item.maxPower, item.transfer, item.transfer){ this.storage = new CustomEnergyStorage(item.maxPower, item.transfer, item.transfer){
@ -225,20 +222,12 @@ public abstract class ItemEnergy extends ItemBase{
return this.getCapability(capability, facing) != null; return this.getCapability(capability, facing) != null;
} }
@SuppressWarnings("unchecked")//gud quality system needs @SuppressWarnings to not complain
@Nullable @Nullable
@Override @Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing){ public <T> T getCapability(Capability<T> capability, EnumFacing facing){
if(capability == CapabilityEnergy.ENERGY){ if(capability == CapabilityEnergy.ENERGY){
return (T) this.storage; return CapabilityEnergy.ENERGY.cast(this.storage);
}
else if(ActuallyAdditions.teslaLoaded){
if(capability == TeslaUtil.teslaConsumer || capability == TeslaUtil.teslaProducer || capability == TeslaUtil.teslaHolder){
if(this.teslaWrapper == null){
this.teslaWrapper = new TeslaForgeUnitsWrapper(this.storage);
}
return (T) this.teslaWrapper;
}
} }
return null; return null;
} }

View file

@ -10,14 +10,11 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler; import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaForgeUnitsWrapper;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -50,8 +47,6 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
protected TileEntity[] tilesAround = new TileEntity[6]; protected TileEntity[] tilesAround = new TileEntity[6];
protected boolean hasSavedDataOnChangeOrWorldStart; protected boolean hasSavedDataOnChangeOrWorldStart;
private Object teslaWrapper;
public TileEntityBase(String name){ public TileEntityBase(String name){
this.name = name; this.name = name;
} }
@ -348,17 +343,6 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
return (T)storage; return (T)storage;
} }
} }
else if(ActuallyAdditions.teslaLoaded){
if(capability == TeslaUtil.teslaConsumer || capability == TeslaUtil.teslaProducer || capability == TeslaUtil.teslaHolder){
IEnergyStorage storage = this.getEnergyStorage(facing);
if(storage != null){
if(this.teslaWrapper == null){
this.teslaWrapper = new TeslaForgeUnitsWrapper(storage);
}
return (T)this.teslaWrapper;
}
}
}
return super.getCapability(capability, facing); return super.getCapability(capability, facing);
} }

View file

@ -10,11 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaHolder;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -60,20 +56,6 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
canTakeUp = cap.getEnergyStored() >= cap.getMaxEnergyStored(); canTakeUp = cap.getEnergyStored() >= cap.getMaxEnergyStored();
} }
} }
else if(ActuallyAdditions.teslaLoaded){
if(this.slots.getStackInSlot(0).hasCapability(TeslaUtil.teslaConsumer, null)){
ITeslaConsumer cap = this.slots.getStackInSlot(0).getCapability(TeslaUtil.teslaConsumer, null);
if(cap != null){
received = (int)cap.givePower(this.storage.getEnergyStored(), false);
}
}
if(this.slots.getStackInSlot(0).hasCapability(TeslaUtil.teslaHolder, null)){
ITeslaHolder cap = this.slots.getStackInSlot(0).getCapability(TeslaUtil.teslaHolder, null);
if(cap != null){
canTakeUp = cap.getStoredPower() >= cap.getCapacity();
}
}
}
if(received > 0){ if(received > 0){
this.storage.extractEnergyInternal(received, false); this.storage.extractEnergyInternal(received, false);
} }
@ -93,7 +75,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return i == 0 && ((ActuallyAdditions.teslaLoaded && stack.hasCapability(TeslaUtil.teslaConsumer, null)) || stack.hasCapability(CapabilityEnergy.ENERGY, null)); return i == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null));
} }
@Override @Override

View file

@ -10,11 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaHolder;
import net.darkhax.tesla.api.ITeslaProducer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -62,20 +58,6 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
canTakeUp = cap.getEnergyStored() <= 0; canTakeUp = cap.getEnergyStored() <= 0;
} }
} }
else if(ActuallyAdditions.teslaLoaded){
if(this.slots.getStackInSlot(0).hasCapability(TeslaUtil.teslaProducer, null)){
ITeslaProducer cap = this.slots.getStackInSlot(0).getCapability(TeslaUtil.teslaProducer, null);
if(cap != null){
extracted = (int)cap.takePower(maxExtract, false);
}
}
if(this.slots.getStackInSlot(0).hasCapability(TeslaUtil.teslaHolder, null)){
ITeslaHolder cap = this.slots.getStackInSlot(0).getCapability(TeslaUtil.teslaHolder, null);
if(cap != null){
canTakeUp = cap.getStoredPower() <= 0;
}
}
}
if(extracted > 0){ if(extracted > 0){
this.storage.receiveEnergyInternal(extracted, false); this.storage.receiveEnergyInternal(extracted, false);
} }
@ -95,7 +77,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return i == 0 && ((ActuallyAdditions.teslaLoaded && stack.hasCapability(TeslaUtil.teslaProducer, null)) || stack.hasCapability(CapabilityEnergy.ENERGY, null)); return i == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null));
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)

View file

@ -10,15 +10,18 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.LaserType;
import de.ellpeck.actuallyadditions.api.laser.Network; import de.ellpeck.actuallyadditions.api.laser.Network;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -31,12 +34,6 @@ import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
public static final int CAP = 1000; public static final int CAP = 1000;
@ -120,7 +117,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
if(this.world.isBlockLoaded(pos)){ if(this.world.isBlockLoaded(pos)){
TileEntity tile = this.world.getTileEntity(pos); TileEntity tile = this.world.getTileEntity(pos);
if(tile != null && !(tile instanceof TileEntityLaserRelay)){ if(tile != null && !(tile instanceof TileEntityLaserRelay)){
if((ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, side.getOpposite())) || tile.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite())){ if(tile.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite())){
this.receiversAround.put(side, tile); this.receiversAround.put(side, tile);
TileEntity oldTile = old.get(side); TileEntity oldTile = old.get(side);
@ -171,13 +168,6 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
workedOnce = true; workedOnce = true;
} }
} }
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){
ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp);
if(cap != null && cap.givePower(maxTransfer, true) > 0){
totalReceiverAmount++;
workedOnce = true;
}
}
} }
} }
} }
@ -223,21 +213,6 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
} }
} }
} }
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){
ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp);
if(cap != null){
int theoreticalReceived = (int)cap.givePower(Math.min(amountPer, lowestCap), true);
if(theoreticalReceived > 0){
int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
if(deduct >= theoreticalReceived){ //Happens with small numbers
deduct = 0;
}
transmitted += cap.givePower(theoreticalReceived-deduct, simulate);
transmitted += deduct;
}
}
}
//If everything that could be transmitted was transmitted //If everything that could be transmitted was transmitted
if(transmitted >= maxTransfer){ if(transmitted >= maxTransfer){

View file

@ -10,9 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
@ -34,11 +32,6 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
if(tile.hasCapability(CapabilityEnergy.ENERGY, facing)){ if(tile.hasCapability(CapabilityEnergy.ENERGY, facing)){
return true; return true;
} }
else if(ActuallyAdditions.teslaLoaded){
if(tile.hasCapability(TeslaUtil.teslaHolder, facing)){
return true;
}
}
} }
} }
} }
@ -47,7 +40,7 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
@Override @Override
protected boolean isCapabilitySupported(Capability<?> capability){ protected boolean isCapabilitySupported(Capability<?> capability){
return capability == CapabilityEnergy.ENERGY || capability == TeslaUtil.teslaHolder || capability == TeslaUtil.teslaConsumer || capability == TeslaUtil.teslaProducer; return capability == CapabilityEnergy.ENERGY;
} }
@Override @Override

View file

@ -10,10 +10,9 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import java.util.UUID;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -23,8 +22,6 @@ import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper; import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import java.util.UUID;
public class TileEntityPlayerInterface extends TileEntityBase implements IEnergyDisplay{ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergyDisplay{
public static final int DEFAULT_RANGE = 32; public static final int DEFAULT_RANGE = 32;
@ -87,12 +84,6 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy
received = cap.receiveEnergy(this.storage.getEnergyStored(), false); received = cap.receiveEnergy(this.storage.getEnergyStored(), false);
} }
} }
else if(ActuallyAdditions.teslaLoaded && slot.hasCapability(TeslaUtil.teslaConsumer, null)){
ITeslaConsumer cap = slot.getCapability(TeslaUtil.teslaConsumer, null);
if(cap != null){
received = (int)cap.givePower(this.storage.getEnergyStored(), false);
}
}
if(received > 0){ if(received > 0){
this.storage.extractEnergyInternal(received, false); this.storage.extractEnergyInternal(received, false);

View file

@ -10,13 +10,15 @@
package de.ellpeck.actuallyadditions.mod.util; package de.ellpeck.actuallyadditions.mod.util;
import java.util.ArrayList;
import java.util.List;
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaProducer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -51,10 +53,6 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
import java.util.ArrayList;
import java.util.List;
public final class WorldUtil{ public final class WorldUtil{
@ -164,21 +162,6 @@ public final class WorldUtil{
} }
} }
} }
if(ActuallyAdditions.teslaLoaded){
if(tileTo.hasCapability(TeslaUtil.teslaConsumer, opp) && tileFrom.hasCapability(TeslaUtil.teslaProducer, sideTo)){
ITeslaConsumer handlerTo = tileTo.getCapability(TeslaUtil.teslaConsumer, opp);
ITeslaProducer handlerFrom = tileFrom.getCapability(TeslaUtil.teslaProducer, sideTo);
if(handlerTo != null && handlerFrom != null){
long drain = handlerFrom.takePower(maxTransfer, true);
if(drain > 0){
long filled = handlerTo.givePower(drain, false);
handlerFrom.takePower(filled, false);
}
}
}
}
} }
} }

View file

@ -1,45 +0,0 @@
/*
* This file ("TeslaForgeUnitsWrapper.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-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.util.compat;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaHolder;
import net.darkhax.tesla.api.ITeslaProducer;
import net.minecraftforge.energy.IEnergyStorage;
public class TeslaForgeUnitsWrapper implements ITeslaProducer, ITeslaHolder, ITeslaConsumer{
private final IEnergyStorage storage;
public TeslaForgeUnitsWrapper(IEnergyStorage storage){
this.storage = storage;
}
@Override
public long givePower(long power, boolean simulated){
return this.storage.receiveEnergy((int)power, simulated);
}
@Override
public long getStoredPower(){
return this.storage.getEnergyStored();
}
@Override
public long getCapacity(){
return this.storage.getMaxEnergyStored();
}
@Override
public long takePower(long power, boolean simulated){
return this.storage.extractEnergy((int)power, simulated);
}
}

View file

@ -1,30 +0,0 @@
/*
* This file ("TeslaUtil.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-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.util.compat;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaHolder;
import net.darkhax.tesla.api.ITeslaProducer;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
public final class TeslaUtil{
@CapabilityInject(ITeslaConsumer.class)
public static Capability<ITeslaConsumer> teslaConsumer;
@CapabilityInject(ITeslaProducer.class)
public static Capability<ITeslaProducer> teslaProducer;
@CapabilityInject(ITeslaHolder.class)
public static Capability<ITeslaHolder> teslaHolder;
}