Jump to content

Recommended Posts

Posted

Hello all,

 

So I have these 'transreceivers' for transporting around energy, however, I'm having trouble saving the connections to NBT.

I do have a error that I caught, which is:

[21:58:54] [Client thread/FATAL]: Registering a TileEntity failed!
java.lang.InstantiationException: com.lambda.plentifulmisc.tile.TileEntityTransreceiverRelay
at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_91]
at com.lambda.plentifulmisc.tile.TileEntityBase.register(TileEntityBase.java:66) [TileEntityBase.class:?]
at com.lambda.plentifulmisc.tile.TileEntityBase.init(TileEntityBase.java:57) [TileEntityBase.class:?]
at com.lambda.plentifulmisc.PlentifulMisc.init(PlentifulMisc.java:60) [PlentifulMisc.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602) [FMLModContainer.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) [LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:795) [Loader.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:330) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:560) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:385) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:?]
Caused by: java.lang.NoSuchMethodException: com.lambda.plentifulmisc.tile.TileEntityTransreceiverRelay.<init>()
at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_91]
at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_91]
... 51 more

 

However, this error is from the 'base relay' which gets extended by the energy / fluid relays.

 

Here is the TE Base, where the TE are registered and just makes creating new TE easier:

 

ppackage com.lambda.plentifulmisc.tile;

/**
* Created by Blake on 11/23/2016.
*/
import com.lambda.plentifulmisc.config.ConfigIntValues;
import com.lambda.plentifulmisc.network.PacketHandler;
import com.lambda.plentifulmisc.network.PacketServerToClient;
import com.lambda.plentifulmisc.util.ModUtil;
import com.lambda.plentifulmisc.util.StringUtil;
import com.lambda.plentifulmisc.util.WorldUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

public abstract class TileEntityBase extends TileEntity implements ITickable{

    public final String name;
    public boolean isRedstonePowered;
    public boolean isPulseMode;
    protected int ticksElapsed;

    protected TileEntity[] tilesAround = new TileEntity[6];
    protected boolean hasSavedDataOnChangeOrWorldStart;

    public TileEntityBase(String name){
        this.name = name;
    }

    public static void init(){
        ModUtil.LOGGER.info("Registering TileEntities...");

        register(TileEntityCoalGenerator.class);
        register(TileEntityEnergeticFab.class);
        register(TileEntitySolarGenerator.class);
        register(TileEntityRefinery.class);
        register(TileEntityElectricFurnace.class);
        register(TileEntityCrusher.class);
        register(TileEntityAtomicDiffuser.class);
        register(TileEntityDigger.class);

        register(TileEntityTransreceiverRelay.class);
        register(TileEntityTransreceiverFluid.class);
        register(TileEntityTransreceiverRelayEnergyAdv.class);
        register(TileEntityTransreciverRelayEnergy.class);

    }

    private static void register(Class<? extends TileEntityBase> tileClass){
        try{
            String name = ModUtil.MOD_ID+":"+tileClass.newInstance().name;
            GameRegistry.registerTileEntity(tileClass, name);
        }
        catch(Exception e){
            ModUtil.LOGGER.fatal("Registering a TileEntity failed!", e);
        }
    }

    @Override
    public final NBTTagCompound writeToNBT(NBTTagCompound compound){
        this.writeSyncableNBT(compound, NBTType.SAVE_TILE);
        return compound;
    }

    @Override
    public final void readFromNBT(NBTTagCompound compound){
        this.readSyncableNBT(compound, NBTType.SAVE_TILE);
    }

    @Override
    public final SPacketUpdateTileEntity getUpdatePacket(){
        NBTTagCompound compound = new NBTTagCompound();
        this.writeSyncableNBT(compound, NBTType.SYNC);
        return new SPacketUpdateTileEntity(this.pos, -1, compound);
    }

    @Override
    public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){
        this.readSyncableNBT(pkt.getNbtCompound(), NBTType.SYNC);
    }

    @Override
    public final NBTTagCompound getUpdateTag(){
        NBTTagCompound compound = new NBTTagCompound();
        this.writeSyncableNBT(compound, NBTType.SYNC);
        return compound;
    }

    @Override
    public final void handleUpdateTag(NBTTagCompound compound){
        this.readSyncableNBT(compound, NBTType.SYNC);
    }

    public final void sendUpdate(){
        if(!this.worldObj.isRemote){
            NBTTagCompound compound = new NBTTagCompound();
            this.writeSyncableNBT(compound, NBTType.SYNC);

            NBTTagCompound data = new NBTTagCompound();
            data.setTag("Data", compound);
            data.setInteger("X", this.pos.getX());
            data.setInteger("Y", this.pos.getY());
            data.setInteger("Z", this.pos.getZ());
            PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(data, PacketHandler.TILE_ENTITY_HANDLER), new NetworkRegistry.TargetPoint(this.worldObj.provider.getDimension(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 128));
        }
    }

    public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
        if(type != NBTType.SAVE_BLOCK){
            super.writeToNBT(compound);
        }

        if(type == NBTType.SAVE_TILE){
            compound.setBoolean("Redstone", this.isRedstonePowered);
            compound.setInteger("TicksElapsed", this.ticksElapsed);
        }
    }

    public void readSyncableNBT(NBTTagCompound compound, NBTType type){
        if(type != NBTType.SAVE_BLOCK){
            super.readFromNBT(compound);
        }

        if(type == NBTType.SAVE_TILE){
            this.isRedstonePowered = compound.getBoolean("Redstone");
            this.ticksElapsed = compound.getInteger("TicksElapsed");
        }

    }

    @Override
    public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState){
        return !oldState.getBlock().isAssociatedBlock(newState.getBlock());
    }

    public String getDisplayedName(){
        return StringUtil.localize("container."+ModUtil.MOD_ID+"."+this.name+".name");
    }

    @Override
    public ITextComponent getDisplayName(){
        return new TextComponentString(this.getDisplayedName());
    }

    @Override
    public final void update(){
         this.updateEntity();
    }

    public void updateEntity(){
        this.ticksElapsed++;

        if(!this.worldObj.isRemote && worldObj != null){
            if(this instanceof ISharingEnergyProvider){
                ISharingEnergyProvider provider = (ISharingEnergyProvider)this;
                if(provider.doesShareEnergy()){
                    int total = provider.getEnergyToSplitShare();
                    if(total > 0){
                        EnumFacing[] sides = provider.getEnergyShareSides();

                        int amount = total/sides.length;
                        if(amount <= 0){
                            amount = total;
                        }

                        for(EnumFacing side : sides){
                            TileEntity tile = this.tilesAround[side.ordinal()];
                            if(tile != null){
                                WorldUtil.doEnergyInteraction(this, tile, side, amount);
                            }
                        }
                    }
                }
            }

            if(this instanceof ISharingFluidHandler){
                ISharingFluidHandler handler = (ISharingFluidHandler)this;
                if(handler.doesShareFluid()){
                    int total = handler.getMaxFluidAmountToSplitShare();
                    if(total > 0){
                        EnumFacing[] sides = handler.getFluidShareSides();

                        int amount = total/sides.length;
                        if(amount <= 0){
                            amount = total;
                        }

                        for(EnumFacing side : sides){
                            TileEntity tile = this.tilesAround[side.ordinal()];
                            if(tile != null){
                                WorldUtil.doFluidInteraction(this, tile, side, amount);
                            }
                        }
                    }
                }
            }

            if(!this.hasSavedDataOnChangeOrWorldStart){
                if(this.shouldSaveDataOnChangeOrWorldStart()){
                    this.saveDataOnChangeOrWorldStart();
                }

                this.hasSavedDataOnChangeOrWorldStart = true;
            }
        }
    }

    public void saveDataOnChangeOrWorldStart(){
        for(EnumFacing side : EnumFacing.values()){
            this.tilesAround[side.ordinal()] = this.worldObj.getTileEntity(this.pos.offset(side));
        }
    }

    public boolean shouldSaveDataOnChangeOrWorldStart(){
        return this instanceof ISharingEnergyProvider || this instanceof ISharingFluidHandler;
    }

    public void setRedstonePowered(boolean powered){
        this.isRedstonePowered = powered;
        this.markDirty();
    }

    public boolean canPlayerUse(EntityPlayer player){
        return player.getDistanceSq(this.getPos().getX()+0.5D, this.pos.getY()+0.5D, this.pos.getZ()+0.5D) <= 64 && !this.isInvalid() && this.worldObj.getTileEntity(this.pos) == this;
    }

    protected boolean sendUpdateWithInterval(){
        if(this.ticksElapsed% 1 == 0){
            this.sendUpdate();
            return true;
        }
        else{
            return false;
        }

    }

    @Override
    public boolean hasCapability(Capability<?> capability, EnumFacing facing){
        return this.getCapability(capability, facing) != null;
    }

    @Override
    public <T> T getCapability(Capability<T> capability, EnumFacing facing){
        if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
            IFluidHandler tank = this.getFluidHandler(facing);
            if (tank != null) {
                return (T) tank;
            }
        }
        return super.getCapability(capability, facing);
    }

    public IFluidHandler getFluidHandler(EnumFacing facing){
        return null;
    }

    public boolean isRedstoneToggle(){
        return false;
    }

    public void activateOnPulse(){

    }

    public enum NBTType{
        SAVE_TILE,
        SYNC,
        SAVE_BLOCK
    }
}

 

 

Now for the 'TileEntityTransreceiverRelay' , which gets extended by all other transrecievers:

 

 

 

package com.lambda.plentifulmisc.tile;

/**
* Created by Blake on 11/25/2016.
*/
import com.lambda.api.transmitters.IConnectionPair;
import com.lambda.api.PlentifulMiscAPI;
import com.lambda.api.transmitters.TransreceiversType;
import com.lambda.plentifulmisc.util.misc.ConnectionPair;
import io.netty.util.internal.ConcurrentSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.Set;

public abstract class TileEntityTransreceiverRelay extends TileEntityBase{

    public static final int MAX_DISTANCE = 15;

    public final TransreceiversType type;

    private Set<IConnectionPair> tempConnectionStorage;

    public TileEntityTransreceiverRelay(String name, TransreceiversType type){
        super(name);
        this.type = type;
    }



    @Override
    public void readSyncableNBT(NBTTagCompound compound, NBTType type){
        super.readSyncableNBT(compound, type);

        if(type == NBTType.SYNC){
            PlentifulMiscAPI.connectionHandler.removeRelayFromNetwork(this.pos, this.worldObj);

            NBTTagList list = compound.getTagList("Connections", 10);
            if(!list.hasNoTags()){
                for(int i = 0; i < list.tagCount(); i++){
                    ConnectionPair pair = new ConnectionPair();
                    pair.readFromNBT(list.getCompoundTagAt(i));
                    PlentifulMiscAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], this.type, this.worldObj, pair.doesSuppressRender());
                }
            }
        }
    }

    @Override
    public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
        super.writeSyncableNBT(compound, type);

        if(type == NBTType.SYNC){
            NBTTagList list = new NBTTagList();

            ConcurrentSet<IConnectionPair> connections = PlentifulMiscAPI.connectionHandler.getConnectionsFor(this.pos, this.worldObj);
            if(connections != null && !connections.isEmpty()){
                for(IConnectionPair pair : connections){
                    NBTTagCompound tag = new NBTTagCompound();
                    pair.writeToNBT(tag);
                    list.appendTag(tag);
                }
            }

            compound.setTag("Connections", list);
        }
    }
/*
    @Override
    public void updateEntity(){
        super.updateEntity();
        if(this.worldObj.isRemote){
        }
    }

*/
    @Override
    public void invalidate(){
        super.invalidate();
        //This is because Minecraft randomly invalidates tiles on world join and then validates them again
        //We need to compensate for this so that connections don't get broken randomly
        this.tempConnectionStorage = PlentifulMiscAPI.connectionHandler.getConnectionsFor(this.pos, this.worldObj);

        PlentifulMiscAPI.connectionHandler.removeRelayFromNetwork(this.pos, this.worldObj);
    }

    @Override
    public void validate(){
        if(this.tempConnectionStorage != null){
            for(IConnectionPair pair : this.tempConnectionStorage){
                PlentifulMiscAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), this.worldObj, pair.doesSuppressRender());
            }
            this.tempConnectionStorage = null;
        }

        super.validate();
    }

    @Override
    public AxisAlignedBB getRenderBoundingBox(){
        return INFINITE_EXTENT_AABB;
    }
}

 

 

 

Now for the 'TileEntityTransreceiverRelayEnergy', I'll just be using this one for example, all of them have the NBT issue, however. In this class, because the original Relay class was outputting an error, I overwrote the NBT READ/WRITE.

package com.lambda.plentifulmisc.tile;

/**
* Created by Blake on 11/25/2016.
*/
import cofh.api.energy.IEnergyReceiver;
import com.lambda.api.transmitters.IConnectionPair;
import com.lambda.api.transmitters.Network;
import com.lambda.api.PlentifulMiscAPI;
import com.lambda.api.transmitters.TransreceiversType;
import com.lambda.plentifulmisc.config.ConfigBoolValues;
import com.lambda.plentifulmisc.util.misc.ConnectionPair;
import io.netty.util.internal.ConcurrentSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class TileEntityTransreciverRelayEnergy extends TileEntityTransreceiverRelay implements ICustomEnergyReceiver{

    public static final int CAP = 1000;
    public final ConcurrentHashMap<EnumFacing, TileEntity> receiversAround = new ConcurrentHashMap<EnumFacing, TileEntity>();

    public TileEntityTransreciverRelayEnergy(String name){
        super(name, TransreceiversType.ENERGY);
    }

    public TileEntityTransreciverRelayEnergy(){
        this("transreceiverRelay");
    }

    @Override
    public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
        return this.transmitEnergy(from, maxReceive, simulate);
    }

    @Override
    public int getEnergyStored(EnumFacing from){
        return 0;
    }

    @Override
    public int getMaxEnergyStored(EnumFacing from){
        return this.getEnergyCap();
    }

    private int transmitEnergy(EnumFacing from, int maxTransmit, boolean simulate){
        int transmitted = 0;
        if(maxTransmit > 0){
            Network network = PlentifulMiscAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj);
            if(network != null){
                transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate);
            }
        }
        return transmitted;
    }

    @Override
    public boolean canConnectEnergy(EnumFacing from){
        return true;
    }

    @Override
    public boolean shouldSaveDataOnChangeOrWorldStart(){
        return true;
    }

    @Override
    public void saveDataOnChangeOrWorldStart(){
        Map<EnumFacing, TileEntity> old = new HashMap<EnumFacing, TileEntity>(this.receiversAround);
        boolean change = false;

        this.receiversAround.clear();
        for(EnumFacing side : EnumFacing.values()){
            BlockPos pos = this.getPos().offset(side);
            TileEntity tile = this.worldObj.getTileEntity(pos);
            if(tile != null && !(tile instanceof TileEntityTransreceiverRelay)){
                if(tile instanceof IEnergyReceiver){
                    this.receiversAround.put(side, tile);

                    TileEntity oldTile = old.get(side);
                    if(oldTile == null || !tile.equals(oldTile)){
                        change = true;
                    }
                }
            }
        }

        if(change){
            Network network = PlentifulMiscAPI.connectionHandler.getNetworkFor(this.getPos(), this.getWorld());
            if(network != null){
                network.changeAmount++;
            }
        }
    }

    @Override
    public void readSyncableNBT(NBTTagCompound compound, NBTType type){
        super.readSyncableNBT(compound, type);

        if(type == NBTType.SYNC){
            PlentifulMiscAPI.connectionHandler.removeRelayFromNetwork(this.pos, this.worldObj);

            NBTTagList list = compound.getTagList("Connections", 10);
            if(!list.hasNoTags()){
                for(int i = 0; i < list.tagCount(); i++){
                    ConnectionPair pair = new ConnectionPair();
                    pair.readFromNBT(list.getCompoundTagAt(i));
                    PlentifulMiscAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], this.type, this.worldObj, pair.doesSuppressRender());
                }
            }
        }
    }

    @Override
    public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
        super.writeSyncableNBT(compound, type);

        if(type == NBTType.SYNC){
            NBTTagList list = new NBTTagList();

            ConcurrentSet<IConnectionPair> connections = PlentifulMiscAPI.connectionHandler.getConnectionsFor(this.pos, this.worldObj);
            if(connections != null && !connections.isEmpty()){
                for(IConnectionPair pair : connections){
                    NBTTagCompound tag = new NBTTagCompound();
                    pair.writeToNBT(tag);
                    list.appendTag(tag);
                }
            }

            compound.setTag("Connections", list);
        }
    }

    private int transferEnergyToReceiverInNeed(EnumFacing from, Network network, int maxTransfer, boolean simulate){
        int transmitted = 0;
        //Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times
        List<BlockPos> alreadyChecked = new ArrayList<BlockPos>();

        List<TileEntityTransreciverRelayEnergy> relaysThatWork = new ArrayList<TileEntityTransreciverRelayEnergy>();
        int totalReceiverAmount = 0;

        for(IConnectionPair pair : network.connections){
            for(BlockPos relay : pair.getPositions()){
                if(relay != null && !alreadyChecked.contains(relay)){
                    alreadyChecked.add(relay);
                    TileEntity relayTile = this.worldObj.getTileEntity(relay);
                    if(relayTile instanceof TileEntityTransreciverRelayEnergy){
                        TileEntityTransreciverRelayEnergy theRelay = (TileEntityTransreciverRelayEnergy)relayTile;
                        int amount = theRelay.receiversAround.size();
                        if(amount > 0){
                            relaysThatWork.add(theRelay);
                            totalReceiverAmount += amount;
                        }
                    }
                }
            }
        }



        if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){
            int amountPer = maxTransfer/totalReceiverAmount;
            if(amountPer <= 0){
                amountPer = maxTransfer;
            }

            for(TileEntityTransreciverRelayEnergy theRelay : relaysThatWork){
                double highestLoss = Math.max(theRelay.getLossPercentage(), this.getLossPercentage());
                int lowestCap = Math.min(theRelay.getEnergyCap(), this.getEnergyCap());
                for(Map.Entry<EnumFacing, TileEntity> receiver : theRelay.receiversAround.entrySet()){
                    if(receiver != null){
                        EnumFacing side = receiver.getKey();
                        EnumFacing opp = side.getOpposite();
                        TileEntity tile = receiver.getValue();
                        if(!alreadyChecked.contains(tile.getPos())){
                            alreadyChecked.add(tile.getPos());
                            if(theRelay != this || side != from){
                                if(tile instanceof IEnergyReceiver){
                                    IEnergyReceiver iReceiver = (IEnergyReceiver)tile;
                                    if(iReceiver.canConnectEnergy(opp)){
                                        int theoreticalReceived = iReceiver.receiveEnergy(opp, Math.min(amountPer, lowestCap), true);
                                        if(theoreticalReceived > 0){
                                            int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
                                            if(deduct >= theoreticalReceived){ //Happens with small numbers
                                                deduct = 0;
                                            }

                                            transmitted += iReceiver.receiveEnergy(opp, theoreticalReceived-deduct, simulate);
                                            transmitted += deduct;
                                        }
                                    }
                                }
                                    if(transmitted >= maxTransfer){
                                         return transmitted;
                                    }
                            }
                        }
                    }
                }
            }
        }

        return transmitted;
    }

    private int calcDeduction(int theoreticalReceived, double highestLoss){
        return ConfigBoolValues.TRANSMIT_LOSS.isEnabled() ? MathHelper.ceiling_double_int(theoreticalReceived*(highestLoss/100)) : 0;
    }

    public int getEnergyCap(){
        return CAP;
    }

    public double getLossPercentage(){
        return 5;
    }
}

 

Thanks for your time.

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

Hello all,

 

So I have these 'transreceivers' for transporting around energy, however, I'm having trouble saving the connections to NBT.

I do have a error that I caught, which is:

[21:58:54] [Client thread/FATAL]: Registering a TileEntity failed!
java.lang.InstantiationException: com.lambda.plentifulmisc.tile.TileEntityTransreceiverRelay
at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_91]
at com.lambda.plentifulmisc.tile.TileEntityBase.register(TileEntityBase.java:66) [TileEntityBase.class:?]
at com.lambda.plentifulmisc.tile.TileEntityBase.init(TileEntityBase.java:57) [TileEntityBase.class:?]
at com.lambda.plentifulmisc.PlentifulMisc.init(PlentifulMisc.java:60) [PlentifulMisc.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602) [FMLModContainer.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) [LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:795) [Loader.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:330) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:560) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:385) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:?]
Caused by: java.lang.NoSuchMethodException: com.lambda.plentifulmisc.tile.TileEntityTransreceiverRelay.<init>()
at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_91]
at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_91]
... 51 more

 

However, this error is from the 'base relay' which gets extended by the energy / fluid relays.

 

Here is the TE Base, where the TE are registered and just makes creating new TE easier:

 

ppackage com.lambda.plentifulmisc.tile;

/**
* Created by Blake on 11/23/2016.
*/
import com.lambda.plentifulmisc.config.ConfigIntValues;
import com.lambda.plentifulmisc.network.PacketHandler;
import com.lambda.plentifulmisc.network.PacketServerToClient;
import com.lambda.plentifulmisc.util.ModUtil;
import com.lambda.plentifulmisc.util.StringUtil;
import com.lambda.plentifulmisc.util.WorldUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

public abstract class TileEntityBase extends TileEntity implements ITickable{

    public final String name;
    public boolean isRedstonePowered;
    public boolean isPulseMode;
    protected int ticksElapsed;

    protected TileEntity[] tilesAround = new TileEntity[6];
    protected boolean hasSavedDataOnChangeOrWorldStart;

    public TileEntityBase(String name){
        this.name = name;
    }

    public static void init(){
        ModUtil.LOGGER.info("Registering TileEntities...");

        register(TileEntityCoalGenerator.class);
        register(TileEntityEnergeticFab.class);
        register(TileEntitySolarGenerator.class);
        register(TileEntityRefinery.class);
        register(TileEntityElectricFurnace.class);
        register(TileEntityCrusher.class);
        register(TileEntityAtomicDiffuser.class);
        register(TileEntityDigger.class);

        register(TileEntityTransreceiverRelay.class);
        register(TileEntityTransreceiverFluid.class);
        register(TileEntityTransreceiverRelayEnergyAdv.class);
        register(TileEntityTransreciverRelayEnergy.class);

    }

    private static void register(Class<? extends TileEntityBase> tileClass){
        try{
            String name = ModUtil.MOD_ID+":"+tileClass.newInstance().name;
            GameRegistry.registerTileEntity(tileClass, name);
        }
        catch(Exception e){
            ModUtil.LOGGER.fatal("Registering a TileEntity failed!", e);
        }
    }

    @Override
    public final NBTTagCompound writeToNBT(NBTTagCompound compound){
        this.writeSyncableNBT(compound, NBTType.SAVE_TILE);
        return compound;
    }

    @Override
    public final void readFromNBT(NBTTagCompound compound){
        this.readSyncableNBT(compound, NBTType.SAVE_TILE);
    }

    @Override
    public final SPacketUpdateTileEntity getUpdatePacket(){
        NBTTagCompound compound = new NBTTagCompound();
        this.writeSyncableNBT(compound, NBTType.SYNC);
        return new SPacketUpdateTileEntity(this.pos, -1, compound);
    }

    @Override
    public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){
        this.readSyncableNBT(pkt.getNbtCompound(), NBTType.SYNC);
    }

    @Override
    public final NBTTagCompound getUpdateTag(){
        NBTTagCompound compound = new NBTTagCompound();
        this.writeSyncableNBT(compound, NBTType.SYNC);
        return compound;
    }

    @Override
    public final void handleUpdateTag(NBTTagCompound compound){
        this.readSyncableNBT(compound, NBTType.SYNC);
    }

    public final void sendUpdate(){
        if(!this.worldObj.isRemote){
            NBTTagCompound compound = new NBTTagCompound();
            this.writeSyncableNBT(compound, NBTType.SYNC);

            NBTTagCompound data = new NBTTagCompound();
            data.setTag("Data", compound);
            data.setInteger("X", this.pos.getX());
            data.setInteger("Y", this.pos.getY());
            data.setInteger("Z", this.pos.getZ());
            PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(data, PacketHandler.TILE_ENTITY_HANDLER), new NetworkRegistry.TargetPoint(this.worldObj.provider.getDimension(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 128));
        }
    }

    public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
        if(type != NBTType.SAVE_BLOCK){
            super.writeToNBT(compound);
        }

        if(type == NBTType.SAVE_TILE){
            compound.setBoolean("Redstone", this.isRedstonePowered);
            compound.setInteger("TicksElapsed", this.ticksElapsed);
        }
    }

    public void readSyncableNBT(NBTTagCompound compound, NBTType type){
        if(type != NBTType.SAVE_BLOCK){
            super.readFromNBT(compound);
        }

        if(type == NBTType.SAVE_TILE){
            this.isRedstonePowered = compound.getBoolean("Redstone");
            this.ticksElapsed = compound.getInteger("TicksElapsed");
        }

    }

    @Override
    public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState){
        return !oldState.getBlock().isAssociatedBlock(newState.getBlock());
    }

    public String getDisplayedName(){
        return StringUtil.localize("container."+ModUtil.MOD_ID+"."+this.name+".name");
    }

    @Override
    public ITextComponent getDisplayName(){
        return new TextComponentString(this.getDisplayedName());
    }

    @Override
    public final void update(){
         this.updateEntity();
    }

    public void updateEntity(){
        this.ticksElapsed++;

        if(!this.worldObj.isRemote && worldObj != null){
            if(this instanceof ISharingEnergyProvider){
                ISharingEnergyProvider provider = (ISharingEnergyProvider)this;
                if(provider.doesShareEnergy()){
                    int total = provider.getEnergyToSplitShare();
                    if(total > 0){
                        EnumFacing[] sides = provider.getEnergyShareSides();

                        int amount = total/sides.length;
                        if(amount <= 0){
                            amount = total;
                        }

                        for(EnumFacing side : sides){
                            TileEntity tile = this.tilesAround[side.ordinal()];
                            if(tile != null){
                                WorldUtil.doEnergyInteraction(this, tile, side, amount);
                            }
                        }
                    }
                }
            }

            if(this instanceof ISharingFluidHandler){
                ISharingFluidHandler handler = (ISharingFluidHandler)this;
                if(handler.doesShareFluid()){
                    int total = handler.getMaxFluidAmountToSplitShare();
                    if(total > 0){
                        EnumFacing[] sides = handler.getFluidShareSides();

                        int amount = total/sides.length;
                        if(amount <= 0){
                            amount = total;
                        }

                        for(EnumFacing side : sides){
                            TileEntity tile = this.tilesAround[side.ordinal()];
                            if(tile != null){
                                WorldUtil.doFluidInteraction(this, tile, side, amount);
                            }
                        }
                    }
                }
            }

            if(!this.hasSavedDataOnChangeOrWorldStart){
                if(this.shouldSaveDataOnChangeOrWorldStart()){
                    this.saveDataOnChangeOrWorldStart();
                }

                this.hasSavedDataOnChangeOrWorldStart = true;
            }
        }
    }

    public void saveDataOnChangeOrWorldStart(){
        for(EnumFacing side : EnumFacing.values()){
            this.tilesAround[side.ordinal()] = this.worldObj.getTileEntity(this.pos.offset(side));
        }
    }

    public boolean shouldSaveDataOnChangeOrWorldStart(){
        return this instanceof ISharingEnergyProvider || this instanceof ISharingFluidHandler;
    }

    public void setRedstonePowered(boolean powered){
        this.isRedstonePowered = powered;
        this.markDirty();
    }

    public boolean canPlayerUse(EntityPlayer player){
        return player.getDistanceSq(this.getPos().getX()+0.5D, this.pos.getY()+0.5D, this.pos.getZ()+0.5D) <= 64 && !this.isInvalid() && this.worldObj.getTileEntity(this.pos) == this;
    }

    protected boolean sendUpdateWithInterval(){
        if(this.ticksElapsed% 1 == 0){
            this.sendUpdate();
            return true;
        }
        else{
            return false;
        }

    }

    @Override
    public boolean hasCapability(Capability<?> capability, EnumFacing facing){
        return this.getCapability(capability, facing) != null;
    }

    @Override
    public <T> T getCapability(Capability<T> capability, EnumFacing facing){
        if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
            IFluidHandler tank = this.getFluidHandler(facing);
            if (tank != null) {
                return (T) tank;
            }
        }
        return super.getCapability(capability, facing);
    }

    public IFluidHandler getFluidHandler(EnumFacing facing){
        return null;
    }

    public boolean isRedstoneToggle(){
        return false;
    }

    public void activateOnPulse(){

    }

    public enum NBTType{
        SAVE_TILE,
        SYNC,
        SAVE_BLOCK
    }
}

 

 

Now for the 'TileEntityTransreceiverRelay' , which gets extended by all other transrecievers:

 

 

 

package com.lambda.plentifulmisc.tile;

/**
* Created by Blake on 11/25/2016.
*/
import com.lambda.api.transmitters.IConnectionPair;
import com.lambda.api.PlentifulMiscAPI;
import com.lambda.api.transmitters.TransreceiversType;
import com.lambda.plentifulmisc.util.misc.ConnectionPair;
import io.netty.util.internal.ConcurrentSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.Set;

public abstract class TileEntityTransreceiverRelay extends TileEntityBase{

    public static final int MAX_DISTANCE = 15;

    public final TransreceiversType type;

    private Set<IConnectionPair> tempConnectionStorage;

    public TileEntityTransreceiverRelay(String name, TransreceiversType type){
        super(name);
        this.type = type;
    }



    @Override
    public void readSyncableNBT(NBTTagCompound compound, NBTType type){
        super.readSyncableNBT(compound, type);

        if(type == NBTType.SYNC){
            PlentifulMiscAPI.connectionHandler.removeRelayFromNetwork(this.pos, this.worldObj);

            NBTTagList list = compound.getTagList("Connections", 10);
            if(!list.hasNoTags()){
                for(int i = 0; i < list.tagCount(); i++){
                    ConnectionPair pair = new ConnectionPair();
                    pair.readFromNBT(list.getCompoundTagAt(i));
                    PlentifulMiscAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], this.type, this.worldObj, pair.doesSuppressRender());
                }
            }
        }
    }

    @Override
    public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
        super.writeSyncableNBT(compound, type);

        if(type == NBTType.SYNC){
            NBTTagList list = new NBTTagList();

            ConcurrentSet<IConnectionPair> connections = PlentifulMiscAPI.connectionHandler.getConnectionsFor(this.pos, this.worldObj);
            if(connections != null && !connections.isEmpty()){
                for(IConnectionPair pair : connections){
                    NBTTagCompound tag = new NBTTagCompound();
                    pair.writeToNBT(tag);
                    list.appendTag(tag);
                }
            }

            compound.setTag("Connections", list);
        }
    }
/*
    @Override
    public void updateEntity(){
        super.updateEntity();
        if(this.worldObj.isRemote){
        }
    }

*/
    @Override
    public void invalidate(){
        super.invalidate();
        //This is because Minecraft randomly invalidates tiles on world join and then validates them again
        //We need to compensate for this so that connections don't get broken randomly
        this.tempConnectionStorage = PlentifulMiscAPI.connectionHandler.getConnectionsFor(this.pos, this.worldObj);

        PlentifulMiscAPI.connectionHandler.removeRelayFromNetwork(this.pos, this.worldObj);
    }

    @Override
    public void validate(){
        if(this.tempConnectionStorage != null){
            for(IConnectionPair pair : this.tempConnectionStorage){
                PlentifulMiscAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), this.worldObj, pair.doesSuppressRender());
            }
            this.tempConnectionStorage = null;
        }

        super.validate();
    }

    @Override
    public AxisAlignedBB getRenderBoundingBox(){
        return INFINITE_EXTENT_AABB;
    }
}

 

 

 

Now for the 'TileEntityTransreceiverRelayEnergy', I'll just be using this one for example, all of them have the NBT issue, however. In this class, because the original Relay class was outputting an error, I overwrote the NBT READ/WRITE.

package com.lambda.plentifulmisc.tile;

/**
* Created by Blake on 11/25/2016.
*/
import cofh.api.energy.IEnergyReceiver;
import com.lambda.api.transmitters.IConnectionPair;
import com.lambda.api.transmitters.Network;
import com.lambda.api.PlentifulMiscAPI;
import com.lambda.api.transmitters.TransreceiversType;
import com.lambda.plentifulmisc.config.ConfigBoolValues;
import com.lambda.plentifulmisc.util.misc.ConnectionPair;
import io.netty.util.internal.ConcurrentSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class TileEntityTransreciverRelayEnergy extends TileEntityTransreceiverRelay implements ICustomEnergyReceiver{

    public static final int CAP = 1000;
    public final ConcurrentHashMap<EnumFacing, TileEntity> receiversAround = new ConcurrentHashMap<EnumFacing, TileEntity>();

    public TileEntityTransreciverRelayEnergy(String name){
        super(name, TransreceiversType.ENERGY);
    }

    public TileEntityTransreciverRelayEnergy(){
        this("transreceiverRelay");
    }

    @Override
    public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
        return this.transmitEnergy(from, maxReceive, simulate);
    }

    @Override
    public int getEnergyStored(EnumFacing from){
        return 0;
    }

    @Override
    public int getMaxEnergyStored(EnumFacing from){
        return this.getEnergyCap();
    }

    private int transmitEnergy(EnumFacing from, int maxTransmit, boolean simulate){
        int transmitted = 0;
        if(maxTransmit > 0){
            Network network = PlentifulMiscAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj);
            if(network != null){
                transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate);
            }
        }
        return transmitted;
    }

    @Override
    public boolean canConnectEnergy(EnumFacing from){
        return true;
    }

    @Override
    public boolean shouldSaveDataOnChangeOrWorldStart(){
        return true;
    }

    @Override
    public void saveDataOnChangeOrWorldStart(){
        Map<EnumFacing, TileEntity> old = new HashMap<EnumFacing, TileEntity>(this.receiversAround);
        boolean change = false;

        this.receiversAround.clear();
        for(EnumFacing side : EnumFacing.values()){
            BlockPos pos = this.getPos().offset(side);
            TileEntity tile = this.worldObj.getTileEntity(pos);
            if(tile != null && !(tile instanceof TileEntityTransreceiverRelay)){
                if(tile instanceof IEnergyReceiver){
                    this.receiversAround.put(side, tile);

                    TileEntity oldTile = old.get(side);
                    if(oldTile == null || !tile.equals(oldTile)){
                        change = true;
                    }
                }
            }
        }

        if(change){
            Network network = PlentifulMiscAPI.connectionHandler.getNetworkFor(this.getPos(), this.getWorld());
            if(network != null){
                network.changeAmount++;
            }
        }
    }

    @Override
    public void readSyncableNBT(NBTTagCompound compound, NBTType type){
        super.readSyncableNBT(compound, type);

        if(type == NBTType.SYNC){
            PlentifulMiscAPI.connectionHandler.removeRelayFromNetwork(this.pos, this.worldObj);

            NBTTagList list = compound.getTagList("Connections", 10);
            if(!list.hasNoTags()){
                for(int i = 0; i < list.tagCount(); i++){
                    ConnectionPair pair = new ConnectionPair();
                    pair.readFromNBT(list.getCompoundTagAt(i));
                    PlentifulMiscAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], this.type, this.worldObj, pair.doesSuppressRender());
                }
            }
        }
    }

    @Override
    public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
        super.writeSyncableNBT(compound, type);

        if(type == NBTType.SYNC){
            NBTTagList list = new NBTTagList();

            ConcurrentSet<IConnectionPair> connections = PlentifulMiscAPI.connectionHandler.getConnectionsFor(this.pos, this.worldObj);
            if(connections != null && !connections.isEmpty()){
                for(IConnectionPair pair : connections){
                    NBTTagCompound tag = new NBTTagCompound();
                    pair.writeToNBT(tag);
                    list.appendTag(tag);
                }
            }

            compound.setTag("Connections", list);
        }
    }

    private int transferEnergyToReceiverInNeed(EnumFacing from, Network network, int maxTransfer, boolean simulate){
        int transmitted = 0;
        //Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times
        List<BlockPos> alreadyChecked = new ArrayList<BlockPos>();

        List<TileEntityTransreciverRelayEnergy> relaysThatWork = new ArrayList<TileEntityTransreciverRelayEnergy>();
        int totalReceiverAmount = 0;

        for(IConnectionPair pair : network.connections){
            for(BlockPos relay : pair.getPositions()){
                if(relay != null && !alreadyChecked.contains(relay)){
                    alreadyChecked.add(relay);
                    TileEntity relayTile = this.worldObj.getTileEntity(relay);
                    if(relayTile instanceof TileEntityTransreciverRelayEnergy){
                        TileEntityTransreciverRelayEnergy theRelay = (TileEntityTransreciverRelayEnergy)relayTile;
                        int amount = theRelay.receiversAround.size();
                        if(amount > 0){
                            relaysThatWork.add(theRelay);
                            totalReceiverAmount += amount;
                        }
                    }
                }
            }
        }



        if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){
            int amountPer = maxTransfer/totalReceiverAmount;
            if(amountPer <= 0){
                amountPer = maxTransfer;
            }

            for(TileEntityTransreciverRelayEnergy theRelay : relaysThatWork){
                double highestLoss = Math.max(theRelay.getLossPercentage(), this.getLossPercentage());
                int lowestCap = Math.min(theRelay.getEnergyCap(), this.getEnergyCap());
                for(Map.Entry<EnumFacing, TileEntity> receiver : theRelay.receiversAround.entrySet()){
                    if(receiver != null){
                        EnumFacing side = receiver.getKey();
                        EnumFacing opp = side.getOpposite();
                        TileEntity tile = receiver.getValue();
                        if(!alreadyChecked.contains(tile.getPos())){
                            alreadyChecked.add(tile.getPos());
                            if(theRelay != this || side != from){
                                if(tile instanceof IEnergyReceiver){
                                    IEnergyReceiver iReceiver = (IEnergyReceiver)tile;
                                    if(iReceiver.canConnectEnergy(opp)){
                                        int theoreticalReceived = iReceiver.receiveEnergy(opp, Math.min(amountPer, lowestCap), true);
                                        if(theoreticalReceived > 0){
                                            int deduct = this.calcDeduction(theoreticalReceived, highestLoss);
                                            if(deduct >= theoreticalReceived){ //Happens with small numbers
                                                deduct = 0;
                                            }

                                            transmitted += iReceiver.receiveEnergy(opp, theoreticalReceived-deduct, simulate);
                                            transmitted += deduct;
                                        }
                                    }
                                }
                                    if(transmitted >= maxTransfer){
                                         return transmitted;
                                    }
                            }
                        }
                    }
                }
            }
        }

        return transmitted;
    }

    private int calcDeduction(int theoreticalReceived, double highestLoss){
        return ConfigBoolValues.TRANSMIT_LOSS.isEnabled() ? MathHelper.ceiling_double_int(theoreticalReceived*(highestLoss/100)) : 0;
    }

    public int getEnergyCap(){
        return CAP;
    }

    public double getLossPercentage(){
        return 5;
    }
}

 

Thanks for your time.

Your TE has to have a 0 argument constructor.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

java.lang.InstantiationException: com.lambda.plentifulmisc.tile.TileEntityTransreceiverRelay

 

You can't instantiate an abstract class.

TileEntityTransreceiverRelay

is abstract. So you can't make an instance of that class.

 

Also, only register the actual

TileEntity

classes that are going to be placed in the world. So don't register

TileEntityTransreceiverRelay

, in the same way the

TileEntity

class isn't registered too.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I am having trouble getting the game to load. I changed nothing about my code but one day it chose to start doing this for some reason. I also get this error message aswell: Caused by: java.lang.NullPointerException: Registry Object not present: wonderfulwoodlands:turkey_tail_mushrooms. So I tried changing my registering to use a supplier of my block which corrected that error before but now it no longer changes anything. My blocks class: public class ModBlocks { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, WonderfulWoodlands.MOD_ID); public static final RegistryObject<Block> TURKEY_TAIL_MUSHROOMS = registerBlock("turkey_tail_mushrooms", () -> new SmallShelfridgeBlock(BlockBehaviour.Properties.of() .setId(BLOCKS.key("turkey_tail_mushrooms")) .noCollission() .sound(SoundType.WOOD) )); public static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) { RegistryObject<T> registeredBlock = BLOCKS.register(name, block); registerBlockItem(name, registeredBlock); return registeredBlock; } public static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) { ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().setId(ModItems.ITEMS.key(name)))); } public static void register(IEventBus eventBus) { BLOCKS.register(eventBus); } } The SmallShelfridgeBlock class: public class SmallShelfridgeBlock extends Block { public static final EnumProperty<Direction> FACING = BlockStateProperties.HORIZONTAL_FACING; public static final IntegerProperty AMOUNT = BlockStateProperties.FLOWER_AMOUNT; public static final VoxelShape NORTH_SHAPE = Block.box(0, 0, 13, 16, 16, 3); public static final VoxelShape EAST_SHAPE = Block.box(0, 0, 0, 3, 16, 16); public static final VoxelShape SOUTH_SHAPE = Block.box(0, 0, 0, 16, 16, 3); public static final VoxelShape WEST_SHAPE = Block.box(0, 0, 13, 3, 16, 16); public SmallShelfridgeBlock(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(AMOUNT, 1)); } @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) { pBuilder.add(FACING, AMOUNT); } @Override public boolean canBeReplaced(@NotNull BlockState blockState, BlockPlaceContext blockPlaceContext) { return !blockPlaceContext.isSecondaryUseActive() && blockPlaceContext.getItemInHand().is(this.asItem()) && blockState.getValue(AMOUNT) < 4 || super.canBeReplaced(blockState, blockPlaceContext); } @Override public @NotNull VoxelShape getShape(BlockState blockState, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos, @NotNull CollisionContext collisionContext) { Direction direction = blockState.getValue(FACING); switch(direction) { default -> { return NORTH_SHAPE; } case EAST -> { return EAST_SHAPE; } case SOUTH -> { return SOUTH_SHAPE; } case WEST -> { return WEST_SHAPE; } } } @Override public BlockState getStateForPlacement(BlockPlaceContext blockPlaceContext) { BlockState blockstate = blockPlaceContext.getLevel().getBlockState(blockPlaceContext.getClickedPos()); return blockstate.is(this) ? blockstate.setValue(AMOUNT, Math.min(4, blockstate.getValue(AMOUNT) + 1)) : this.defaultBlockState().setValue(FACING, blockPlaceContext.getHorizontalDirection().getOpposite()); } } My latest.log: [22Feb2025 14:13:00.602] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forge_userdev_client, --version, MOD_DEV, --assetIndex, 19, --assetsDir, C:\Users\campb\.gradle\caches\forge_gradle\assets, --gameDir, ., --mixin.config, wonderfulwoodlands.mixins.json] [22Feb2025 14:13:00.605] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: JVM identified as Eclipse Adoptium OpenJDK 64-Bit Server VM 21.0.4+7-LTS [22Feb2025 14:13:00.606] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.2.4 starting: java version 21.0.4 by Eclipse Adoptium; OS Windows 11 arch amd64 version 10.0 [22Feb2025 14:13:00.791] [main/INFO] [net.minecraftforge.fml.loading.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow [22Feb2025 14:13:00.988] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 [22Feb2025 14:13:01.035] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 [22Feb2025 14:13:01.504] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.7 Source=jar:file:///C:/Users/campb/.gradle/caches/modules-2/files-2.1/org.spongepowered/mixin/0.8.7/8ab114ac385e6dbdad5efafe28aba4df8120915f/mixin-0.8.7.jar!/ Service=ModLauncher Env=CLIENT [22Feb2025 14:13:02.124] [EarlyDisplay/INFO] [EARLYDISPLAY/]: GL info: Intel(R) UHD Graphics GL version 4.6.0 - Build 26.20.100.6911, Intel [22Feb2025 14:13:04.063] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: No dependencies to load found. Skipping! [22Feb2025 14:13:05.719] [main/INFO] [mixin/]: Compatibility level set to JAVA_21 [22Feb2025 14:13:05.774] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forge_userdev_client' with arguments [--version, MOD_DEV, --gameDir, ., --assetsDir, C:\Users\campb\.gradle\caches\forge_gradle\assets, --assetIndex, 19] [22Feb2025 14:13:05.927] [main/WARN] [mixin/]: Reference map 'wonderfulwoodlands.refmap.json' for wonderfulwoodlands.mixins.json could not be read. If this is a development environment you can ignore this message [22Feb2025 14:13:10.506] [Datafixer Bootstrap/INFO] [com.mojang.datafixers.DataFixerBuilder/]: 243 Datafixer optimizations took 996 milliseconds [22Feb2025 14:13:18.985] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:root [22Feb2025 14:13:18.985] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:sound_event [22Feb2025 14:13:18.985] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:fluid [22Feb2025 14:13:18.985] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:particle_type [22Feb2025 14:13:18.986] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:attribute [22Feb2025 14:13:18.987] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:mob_effect [22Feb2025 14:13:18.987] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:block [22Feb2025 14:13:18.987] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:enchantment_effect_component_type [22Feb2025 14:13:18.987] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:data_component_type [22Feb2025 14:13:18.988] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:entity_type [22Feb2025 14:13:18.988] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:item [22Feb2025 14:13:18.991] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:game_event [22Feb2025 14:13:18.991] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:potion [22Feb2025 14:13:18.991] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:block_entity_type [22Feb2025 14:13:18.992] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:stat_type [22Feb2025 14:13:18.992] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:custom_stat [22Feb2025 14:13:18.992] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:chunk_status [22Feb2025 14:13:18.992] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:rule_test [22Feb2025 14:13:18.993] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:rule_block_entity_modifier [22Feb2025 14:13:18.993] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:pos_rule_test [22Feb2025 14:13:18.993] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:menu [22Feb2025 14:13:18.993] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:recipe_type [22Feb2025 14:13:18.994] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:recipe_serializer [22Feb2025 14:13:18.995] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:position_source_type [22Feb2025 14:13:18.996] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:command_argument_type [22Feb2025 14:13:18.996] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:villager_type [22Feb2025 14:13:18.996] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:villager_profession [22Feb2025 14:13:18.998] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:point_of_interest_type [22Feb2025 14:13:19.001] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:memory_module_type [22Feb2025 14:13:19.017] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:sensor_type [22Feb2025 14:13:19.018] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:activity [22Feb2025 14:13:19.018] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:schedule [22Feb2025 14:13:19.018] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:loot_score_provider_type [22Feb2025 14:13:19.018] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:loot_number_provider_type [22Feb2025 14:13:19.019] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:map_decoration_type [22Feb2025 14:13:19.019] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:loot_nbt_provider_type [22Feb2025 14:13:19.019] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:loot_function_type [22Feb2025 14:13:19.019] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:loot_pool_entry_type [22Feb2025 14:13:19.019] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:loot_condition_type [22Feb2025 14:13:19.022] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:float_provider_type [22Feb2025 14:13:19.022] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:int_provider_type [22Feb2025 14:13:19.022] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:height_provider_type [22Feb2025 14:13:19.023] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:block_predicate_type [22Feb2025 14:13:19.023] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/carver [22Feb2025 14:13:19.023] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/structure_processor [22Feb2025 14:13:19.023] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/feature [22Feb2025 14:13:19.024] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/structure_placement [22Feb2025 14:13:19.024] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/structure_piece [22Feb2025 14:13:19.024] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/structure_type [22Feb2025 14:13:19.024] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/placement_modifier_type [22Feb2025 14:13:19.024] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/block_state_provider_type [22Feb2025 14:13:19.025] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/foliage_placer_type [22Feb2025 14:13:19.025] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/trunk_placer_type [22Feb2025 14:13:19.025] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/root_placer_type [22Feb2025 14:13:19.025] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/tree_decorator_type [22Feb2025 14:13:19.027] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/feature_size_type [22Feb2025 14:13:19.028] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/biome_source [22Feb2025 14:13:19.030] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/chunk_generator [22Feb2025 14:13:19.030] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/material_condition [22Feb2025 14:13:19.030] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/material_rule [22Feb2025 14:13:19.030] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/density_function_type [22Feb2025 14:13:19.031] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:block_type [22Feb2025 14:13:19.031] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/structure_pool_element [22Feb2025 14:13:19.031] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:worldgen/pool_alias_binding [22Feb2025 14:13:19.031] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:cat_variant [22Feb2025 14:13:19.031] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:frog_variant [22Feb2025 14:13:19.032] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:decorated_pot_pattern [22Feb2025 14:13:19.032] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:creative_mode_tab [22Feb2025 14:13:19.032] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:trigger_type [22Feb2025 14:13:19.032] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:number_format_type [22Feb2025 14:13:19.032] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:entity_sub_predicate_type [22Feb2025 14:13:19.034] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:item_sub_predicate_type [22Feb2025 14:13:19.034] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:enchantment_level_based_value_type [22Feb2025 14:13:19.035] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:enchantment_entity_effect_type [22Feb2025 14:13:19.035] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:enchantment_location_based_effect_type [22Feb2025 14:13:19.035] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:enchantment_value_effect_type [22Feb2025 14:13:19.036] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:enchantment_provider_type [22Feb2025 14:13:19.037] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:consume_effect_type [22Feb2025 14:13:19.037] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:recipe_display [22Feb2025 14:13:19.037] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:slot_display [22Feb2025 14:13:19.037] [pool-5-thread-1/INFO] [net.minecraftforge.registries.GameData/REGISTRIES]: minecraft:recipe_book_category [22Feb2025 14:13:19.595] [Render thread/WARN] [net.minecraft.server.packs.VanillaPackResourcesBuilder/]: Assets URL 'union:/C:/Users/campb/.gradle/caches/forge_gradle/minecraft_user_repo/net/minecraftforge/forge/1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4/forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar%230!/assets/.mcassetsroot' uses unexpected schema [22Feb2025 14:13:19.597] [Render thread/WARN] [net.minecraft.server.packs.VanillaPackResourcesBuilder/]: Assets URL 'union:/C:/Users/campb/.gradle/caches/forge_gradle/minecraft_user_repo/net/minecraftforge/forge/1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4/forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar%230!/data/.mcassetsroot' uses unexpected schema [22Feb2025 14:13:19.639] [Render thread/INFO] [com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService/]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD] [22Feb2025 14:13:19.654] [Render thread/INFO] [net.minecraft.client.Minecraft/]: Setting user: Dev [22Feb2025 14:13:19.860] [Render thread/INFO] [net.minecraft.client.Minecraft/]: Backend library: LWJGL version 3.3.3+5 [22Feb2025 14:13:21.001] [modloading-worker-0/INFO] [net.minecraftforge.common.ForgeMod/FORGEMOD]: Forge mod loading, version 54.0.26, for MC 1.21.4 with MCP 20241203.143248 [22Feb2025 14:13:21.002] [modloading-worker-0/INFO] [net.minecraftforge.common.MinecraftForge/FORGE]: MinecraftForge v54.0.26 Initialized [22Feb2025 14:13:21.021] [modloading-worker-0/INFO] [net.minecraftforge.common.ForgeMod/FORGEMOD]: Opening jdk.naming.dns/com.sun.jndi.dns to java.naming [22Feb2025 14:13:21.448] [Render thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/]: Exception caught during firing event: null Index: 3 Listeners: 0: NORMAL 1: ASM: net.minecraftforge.registries.DeferredRegister$EventDispatcher@30548a28 handleEvent(Lnet/minecraftforge/registries/RegisterEvent;)V 2: ASM: net.minecraftforge.registries.DeferredRegister$EventDispatcher@446f7e86 handleEvent(Lnet/minecraftforge/registries/RegisterEvent;)V 3: ASM: net.minecraftforge.registries.DeferredRegister$EventDispatcher@523fad04 handleEvent(Lnet/minecraftforge/registries/RegisterEvent;)V java.lang.ExceptionInInitializerError at TRANSFORMER/[email protected]/net.Saveloy_Master.Wonderful_Woodlands.block.ModBlocks.lambda$static$0(ModBlocks.java:27) at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent$0(DeferredRegister.java:381) at TRANSFORMER/[email protected]/net.minecraftforge.registries.RegisterEvent.register(RegisterEvent.java:55) at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.handleEvent(DeferredRegister.java:381) at TRANSFORMER/[email protected]/net.minecraftforge.registries.__EventDispatcher_handleEvent_RegisterEvent.invoke(.dynamic) at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:46) at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:288) at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:184) at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.lambda$postEventWithWrapInModOrder$19(ModLoader.java:400) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModList.forEachModInOrder(ModList.java:148) at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.postEventWithWrapInModOrder(ModLoader.java:398) at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.postEventWrapContainerInModOrder(ModLoader.java:387) at TRANSFORMER/[email protected]/net.minecraftforge.registries.GameData.postRegisterEvents(GameData.java:351) at TRANSFORMER/[email protected]/net.minecraftforge.common.ForgeStatesProvider.lambda$gather$0(ForgeStatesProvider.java:34) at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.handleInlineTransition(ModLoader.java:258) at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:247) at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:214) at TRANSFORMER/[email protected]/net.minecraftforge.client.loading.ClientModLoader.lambda$begin$1(ClientModLoader.java:48) at TRANSFORMER/[email protected]/net.minecraftforge.client.loading.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:68) at TRANSFORMER/[email protected]/net.minecraftforge.client.loading.ClientModLoader.begin(ClientModLoader.java:48) at TRANSFORMER/[email protected]/net.minecraft.client.Minecraft.<init>(Minecraft.java:485) at TRANSFORMER/[email protected]/net.minecraft.client.main.Main.main(Main.java:224) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at SECURE-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:96) at SECURE-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonLaunchHandler.lambda$makeService$0(CommonLaunchHandler.java:79) at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:77) at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:97) at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:116) at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:75) at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapEntry.main(BootstrapEntry.java:17) at [email protected]/net.minecraftforge.bootstrap.Bootstrap.moduleMain(Bootstrap.java:188) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at net.minecraftforge.bootstrap.Bootstrap.bootstrapMain(Bootstrap.java:133) at net.minecraftforge.bootstrap.Bootstrap.start(Bootstrap.java:53) at net.minecraftforge.bootstrap.ForgeBootstrap.main(ForgeBootstrap.java:19) Caused by: java.lang.IllegalArgumentException: The min values need to be smaller or equals to the max values at TRANSFORMER/[email protected]/net.minecraft.world.phys.shapes.Shapes.box(Shapes.java:50) at TRANSFORMER/[email protected]/net.minecraft.world.level.block.Block.box(Block.java:145) at TRANSFORMER/[email protected]/net.Saveloy_Master.Wonderful_Woodlands.block.custom.SmallShelfridgeBlock.<clinit>(SmallShelfridgeBlock.java:25) ... 39 more [22Feb2025 14:13:21.453] [Render thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Caught exception during event RegisterEvent dispatch for modid wonderfulwoodlands java.lang.ExceptionInInitializerError: null at TRANSFORMER/[email protected]/net.Saveloy_Master.Wonderful_Woodlands.block.ModBlocks.lambda$static$0(ModBlocks.java:27) ~[main/:?] at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent$0(DeferredRegister.java:381) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar%231!/:?] at TRANSFORMER/[email protected]/net.minecraftforge.registries.RegisterEvent.register(RegisterEvent.java:55) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar%231!/:?] at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.handleEvent(DeferredRegister.java:381) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar%231!/:?] at TRANSFORMER/[email protected]/net.minecraftforge.registries.__EventDispatcher_handleEvent_RegisterEvent.invoke(.dynamic) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar%231!/:?] at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:46) ~[eventbus-6.2.26.jar:?] at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-6.2.26.jar:?] at SECURE-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:288) ~[eventbus-6.2.26.jar:?] at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:184) ~[javafmllanguage-1.21.4-54.0.26.jar:54.0.26] at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.lambda$postEventWithWrapInModOrder$19(ModLoader.java:400) ~[fmlcore-1.21.4-54.0.26.jar:1.0] at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModList.forEachModInOrder(ModList.java:148) ~[fmlcore-1.21.4-54.0.26.jar:1.0] at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.postEventWithWrapInModOrder(ModLoader.java:398) ~[fmlcore-1.21.4-54.0.26.jar:1.0] at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.postEventWrapContainerInModOrder(ModLoader.java:387) ~[fmlcore-1.21.4-54.0.26.jar:1.0] at TRANSFORMER/[email protected]/net.minecraftforge.registries.GameData.postRegisterEvents(GameData.java:351) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at TRANSFORMER/[email protected]/net.minecraftforge.common.ForgeStatesProvider.lambda$gather$0(ForgeStatesProvider.java:34) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.handleInlineTransition(ModLoader.java:258) ~[fmlcore-1.21.4-54.0.26.jar:1.0] at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:247) ~[fmlcore-1.21.4-54.0.26.jar:1.0] at LAYER PLUGIN/[email protected]/net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:214) ~[fmlcore-1.21.4-54.0.26.jar:1.0] at TRANSFORMER/[email protected]/net.minecraftforge.client.loading.ClientModLoader.lambda$begin$1(ClientModLoader.java:48) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at TRANSFORMER/[email protected]/net.minecraftforge.client.loading.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:68) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at TRANSFORMER/[email protected]/net.minecraftforge.client.loading.ClientModLoader.begin(ClientModLoader.java:48) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at TRANSFORMER/[email protected]/net.minecraft.client.Minecraft.<init>(Minecraft.java:485) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at TRANSFORMER/[email protected]/net.minecraft.client.main.Main.main(Main.java:224) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?] at SECURE-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:96) ~[fmlloader-1.21.4-54.0.26.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonLaunchHandler.lambda$makeService$0(CommonLaunchHandler.java:79) ~[fmlloader-1.21.4-54.0.26.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:77) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:97) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:116) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:75) [modlauncher-10.2.4.jar!/:?] at SECURE-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapEntry.main(BootstrapEntry.java:17) [modlauncher-10.2.4.jar!/:?] at [email protected]/net.minecraftforge.bootstrap.Bootstrap.moduleMain(Bootstrap.java:188) [bootstrap-2.1.8.jar!/:?] at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?] at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?] at net.minecraftforge.bootstrap.Bootstrap.bootstrapMain(Bootstrap.java:133) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.Bootstrap.start(Bootstrap.java:53) [bootstrap-2.1.8.jar:2.1.8] at net.minecraftforge.bootstrap.ForgeBootstrap.main(ForgeBootstrap.java:19) [bootstrap-2.1.8.jar:2.1.8] Caused by: java.lang.IllegalArgumentException: The min values need to be smaller or equals to the max values at TRANSFORMER/[email protected]/net.minecraft.world.phys.shapes.Shapes.box(Shapes.java:50) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at TRANSFORMER/[email protected]/net.minecraft.world.level.block.Block.box(Block.java:145) ~[forge-1.21.4-54.0.26_mapped_parchment_2025.01.19-1.21.4-recomp.jar:?] at TRANSFORMER/[email protected]/net.Saveloy_Master.Wonderful_Woodlands.block.custom.SmallShelfridgeBlock.<clinit>(SmallShelfridgeBlock.java:25) ~[main/:?] ... 39 more [22Feb2025 14:13:21.488] [Render thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/]: Exception caught during firing event: Registry Object not present: wonderfulwoodlands:turkey_tail_mushrooms Index: 2 Listeners: 0: NORMAL 1: ASM: net.minecraftforge.registries.DeferredRegister$EventDispatcher@30548a28 handleEvent(Lnet/minecraftforge/registries/RegisterEvent;)V 2: ASM: net.minecraftforge.registries.DeferredRegister$EventDispatcher@446f7e86 handleEvent(Lnet/minecraftforge/registries/RegisterEvent;)V 3: ASM: net.minecraftforge.registries.DeferredRegister$EventDispatcher@523fad04 handleEvent(Lnet/minecraftforge/registries/RegisterEvent;)V java.lang.NullPointerException: Registry Object not present: wonderfulwoodlands:turkey_tail_mushrooms  
    • actually, the thing is that forge is an client that was developed well for mods back in the day, (i know that i  write it 11 years later), and the downside was that forge needs a long of time to load (yes i tested it i need sometimes 2 minutes for optifine in forge to run it) and that will probably not change. if you are 1.16+ i suggest you to use fabric as the load times are lower than 10 seconds and yes i do have a lot of mods there. not to mehtion there is an better optimization client and yes i do get more fps on 1.21 fabric with sodium lithium and much more than with forge and optifine on 1.8.9
    • Also add the latest.log from your logs folder
    • Кимэцу но яиба
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.