Bonjour
Un amie a mois dev un mod qui utilise des énergie mes celui ci reçois énergie mes ne restitue pas m'agrée plusieurs tentative le problème persiste nous utulisont api energie de forge et les câble de thermal expansion
le mod fonction sauf des que on active le mod debug de intel idea sur la class getCapability avec cette ereure
TileMachine
modtilenti
Tileentitymeter
Un amie a mois dev un mod qui utilise des énergie mes celui ci reçois énergie mes ne restitue pas m'agrée plusieurs tentative le problème persiste nous utulisont api energie de forge et les câble de thermal expansion
le mod fonction sauf des que on active le mod debug de intel idea sur la class getCapability avec cette ereure
Code:
"Server thread@9823" prio=5 tid=0x31 nid=NA runnable
java.lang.Thread.State: RUNNABLE
at net.vadamdev.sfbase.core.energy.TileMachine.getCapability(TileMachine.java:84)
at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.cacheTile(DuctUnitEnergy.java:116)
at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.cacheTile(DuctUnitEnergy.java:19)
at cofh.thermaldynamics.duct.tiles.DuctUnit.loadSignificantCache(DuctUnit.java:157)
at cofh.thermaldynamics.duct.energy.DuctUnitEnergy.handleTileSideUpdate(DuctUnitEnergy.java:88)
at cofh.thermaldynamics.duct.tiles.DuctUnit.handleTileSideUpdate(DuctUnit.java:115)
at cofh.thermaldynamics.duct.tiles.DuctUnit.updateAllSides(DuctUnit.java:231)
at cofh.thermaldynamics.duct.tiles.TileGrid.onNeighborBlockChange(TileGrid.java:199)
at cofh.thermaldynamics.duct.tiles.DuctUnit.onNeighborBlockChange(DuctUnit.java:283)
at cofh.thermaldynamics.multiblock.MultiBlockFormer.checkMultiBlock(MultiBlockFormer.java:33)
at cofh.thermaldynamics.multiblock.MultiBlockFormer.formGrid(MultiBlockFormer.java:23)
at cofh.thermaldynamics.duct.tiles.DuctUnit.formGrid(DuctUnit.java:252)
at cofh.thermaldynamics.duct.tiles.DuctUnit.singleTick(DuctUnit.java:349)
at cofh.thermaldynamics.util.WorldGridList.tickEnd(WorldGridList.java:84)
at cofh.thermaldynamics.util.TickHandler.tick(TickHandler.java:93)
- locked <0x2fc4> (a java.util.WeakHashMap)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_99_TickHandler_tick_WorldTickEvent.invoke(.dynamic:-1)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.fml.common.FMLCommonHandler.onPostWorldTick(FMLCommonHandler.java:274)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:851)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
at java.lang.Thread.run(Thread.java:748)
TileMachine
Java:
package net.vadamdev.sfbase.core.energy;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.EnergyStorage;
import javax.annotation.Nullable;
public abstract class TileMachine extends TileEntity implements ITickable, ICapabilityProvider {
public EnergyStorage energyStorage;
public TileMachine(EnergyStorage energyStorage) {
this.energyStorage = energyStorage;
}
/*
NBT Data
*/
/*@Override
public void readFromNBT(NBTTagCompound compound) {
this.energy = compound.getInteger("Energy");
this.capacity = compound.getInteger("Capacity");
this.maxReceive = compound.getInteger("MaxReceive");
this.maxExtract = compound.getInteger("MaxExtract");
super.readFromNBT(compound);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
energyStorage.writeToNBT(compound);
return super.writeToNBT(compound);
}*/
/*
public void readFromNBT(NBTTagCompound compound)
{
this.energy = compound.getInteger("Energy");
this.capacity = compound.getInteger("Capacity");
this.maxReceive = compound.getInteger("MaxReceive");
this.maxExtract = compound.getInteger("MaxExtract");
}
public void writeToNBT(NBTTagCompound compound)
{
compound.setInteger("Energy", this.energy);
compound.setInteger("Capacity", this.capacity);
compound.setInteger("MaxReceive", this.maxReceive);
compound.setInteger("MaxExtract", this.maxExtract);
}*/
/*
ITickable
*/
@Override
public void update() {
}
/*
Forge Energy
*/
public int getMaxEnergyStored() {
return energyStorage.getMaxEnergyStored();
}
public int getEnergyStored() {
return energyStorage.getEnergyStored();
}
/*
Capability
*/
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
if(capability == CapabilityEnergy.ENERGY) return (T) energyStorage;
return super.getCapability(capability, facing);
}
@Override
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
if(capability == CapabilityEnergy.ENERGY) return true;
return super.hasCapability(capability, facing);
}
}
modtilenti
Java:
package net.vadamdev.sfbase.init;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.common.registry.GameRegistry;
import java.util.ArrayList;
import java.util.List;
public class ModTileEntities {
private List<TileEntity> tileEntities = new ArrayList<>();
public void init() {
tileEntities.forEach(te -> GameRegistry.registerTileEntity(te.getClass(), te.getClass().getSimpleName()));
}
public List<TileEntity> getTileEntities() {
return tileEntities;
}
}
Tileentitymeter
Java:
package net.vadamdev.sfbase.init.tileentity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.EnergyStorage;
import net.vadamdev.sfbase.core.energy.TileMachine;
public class TileEntityEnergyMeter extends TileMachine {
public TileEntityEnergyMeter() {
super(new EnergyStorage(10000, 10000, 10000));
}
}