Jump to content

Recommended Posts

Posted

Hello,

 

So I have a custom tile entity here the uses cofh energy system. However, when I place fuel inside of it (coal) it seems to crash:

 

net.minecraft.util.ReportedException: Ticking block entity
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:800) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91]
Caused by: java.lang.NullPointerException
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdate(TileEntityBase.java:107) ~[TileEntityBase.class:?]
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdateWithInterval(TileEntityBase.java:232) ~[TileEntityBase.class:?]
at com.lambda.plentifulmisc.tile.TileEntityCoalGenerator.updateEntity(TileEntityCoalGenerator.java:82) ~[TileEntityCoalGenerator.class:?]
at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:150) ~[TileEntityBase.class:?]
at net.minecraft.world.World.updateEntities(World.java:1968) ~[World.class:?]
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646) ~[WorldServer.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794) ~[MinecraftServer.class:?]
... 4 more
[13:11:31] [server thread/ERROR]: This crash report has been saved to: F:\Minecraft Workspace\1.1.1\run\.\crash-reports\crash-2016-11-23_13.11.31-server.txt

 

Looking into it, my sendUpdate()  and sendUpdateWithInterval() functions seem to be outputting null, however i dont see why.

Here is my TE Base:

package 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);
    }

    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){
            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% ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 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
    }
}

 

and my TE Coal generator:

 

package com.lambda.plentifulmisc.tile;

/**
* Created by Blake on 11/23/2016.
*/
import cofh.api.energy.EnergyStorage;
import com.lambda.plentifulmisc.util.StackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class TileEntityCoalGenerator extends TileEntityInventoryBase implements ISharingEnergyProvider{

    public static final int PRODUCE = 45;
    public final CustomEnergyStorage storage = new CustomEnergyStorage(125000, 125);
    public int maxBurnTime;
    public int currentBurnTime;
    private int lastEnergy;
    private int lastBurnTime;
    private int lastCurrentBurnTime;

    public TileEntityCoalGenerator(){
        super(1, "coalGenerator");
    }

    @SideOnly(Side.CLIENT)
    public int getEnergyScaled(int i){
        return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
    }

    @SideOnly(Side.CLIENT)
    public int getBurningScaled(int i){
        return this.currentBurnTime*i/this.maxBurnTime;
    }

    @Override
    public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
        if(type != NBTType.SAVE_BLOCK){
            compound.setInteger("BurnTime", this.currentBurnTime);
            compound.setInteger("MaxBurnTime", this.maxBurnTime);
        }
        this.storage.writeToNBT(compound);
        super.writeSyncableNBT(compound, type);
    }

    @Override
    public void readSyncableNBT(NBTTagCompound compound, NBTType type){
        if(type != NBTType.SAVE_BLOCK){
            this.currentBurnTime = compound.getInteger("BurnTime");
            this.maxBurnTime = compound.getInteger("MaxBurnTime");
        }
        this.storage.readFromNBT(compound);
        super.readSyncableNBT(compound, type);
    }

    @Override
    public void updateEntity(){
        super.updateEntity();
        if(!this.worldObj.isRemote){
            boolean flag = this.currentBurnTime > 0;

            if(this.currentBurnTime > 0){
                this.currentBurnTime--;
                this.storage.receiveEnergyInternal(PRODUCE, false);
            }

            if(this.currentBurnTime <= 0 && StackUtil.isValid(this.slots.get(0)) && TileEntityFurnace.getItemBurnTime(this.slots.get(0)) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){
                int burnTime = TileEntityFurnace.getItemBurnTime(this.slots.get(0));
                this.maxBurnTime = burnTime;
                this.currentBurnTime = burnTime;

                this.slots.set(0, StackUtil.addStackSize(this.slots.get(0), -1));
            }

            if(flag != this.currentBurnTime > 0){
                this.markDirty();
            }

            if((this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()){
                this.lastEnergy = this.storage.getEnergyStored();
                this.lastCurrentBurnTime = this.currentBurnTime;
                this.lastBurnTime = this.currentBurnTime;
            }
        }
    }

    @Override
    public boolean isItemValidForSlot(int i, ItemStack stack){
        return TileEntityFurnace.getItemBurnTime(stack) > 0;
    }

    @Override
    public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
        return this.isItemValidForSlot(slot, stack);
    }

    @Override
    public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
        return TileEntityFurnace.getItemBurnTime(this.slots.get(0)) <= 0;
    }

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

    @Override
    public int getEnergyStored(EnumFacing from){
        return this.storage.getEnergyStored();
    }

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

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

    @Override
    public int getEnergyToSplitShare(){
        return this.storage.getEnergyStored();
    }

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

    @Override
    public EnumFacing[] getEnergyShareSides(){
        return EnumFacing.values();
    }
}

 

Also, how would I sync my git with github? I used cloning, do I have to run it everytime I update the git? I'm using Intellj

 

Thanks for your time.

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

My first guess is that

worldObj

is null (which can happen).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Null check, yes.

Also sendUpdate is a void, so you don't return anything.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Yeah mb, anyways now I'm getting this after null checking.

 

---- Minecraft Crash Report ----
// Ouch. That hurt 

Time: 11/23/16 2:05 PM
Description: Ticking block entity

java.lang.ArithmeticException: / by zero
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdateWithInterval(TileEntityBase.java:230)
at com.lambda.plentifulmisc.tile.TileEntityCoalGenerator.updateEntity(TileEntityCoalGenerator.java:82)
at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:149)
at net.minecraft.world.World.updateEntities(World.java:1968)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547)
at java.lang.Thread.run(Thread.java:745)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Server thread
Stacktrace:
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdateWithInterval(TileEntityBase.java:230)
at com.lambda.plentifulmisc.tile.TileEntityCoalGenerator.updateEntity(TileEntityCoalGenerator.java:82)
at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:149)

-- Block entity being ticked --
Details:
Name: plentifulmisc:coalgenerator // com.lambda.plentifulmisc.tile.TileEntityCoalGenerator
Block type: ID #236 (tile.plentifulmisc.coal_generator // com.lambda.plentifulmisc.blocks.BlockCoalGenerator)
Block data value: 2 / 0x2 / 0b0010
Block location: World: (248,64,10), Chunk: (at 8,4,10 in 15,0; contains blocks 240,0,0 to 255,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Actual block type: ID #236 (tile.plentifulmisc.coal_generator // com.lambda.plentifulmisc.blocks.BlockCoalGenerator)
Actual block data value: 2 / 0x2 / 0b0010
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:1968)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646)

-- Affected level --
Details:
Level name: World
All players: 0 total; []
Chunk stats: ServerChunkCache: 625 Drop: 0
Level seed: 8468416878428078370
Level generator: ID 00 - default, ver 1. Features enabled: true
Level generator options: 
Level spawn location: World: (256,64,12), Chunk: (at 0,4,12 in 16,0; contains blocks 256,0,0 to 271,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 853 game time, 853 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 141165 (now: false), thunder time: 13919 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547)
at java.lang.Thread.run(Thread.java:745)

-- System Details --
Details:
Minecraft Version: 1.11
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_91, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 751403968 bytes (716 MB) / 1540882432 bytes (1469 MB) up to 3814195200 bytes (3637 MB)
JVM Flags: 0 total; 
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP 9.35 Powered by Forge 13.19.0.2157 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJAAAA	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11-13.19.0.2157.jar) 
UCHIJAAAA	forge{13.19.0.2157} [Minecraft Forge] (forgeSrc-1.11-13.19.0.2157.jar) 
UCHIJAAAA	plentifulmisc{0.0.1} [Plentiful Misc] (1.1.1) 
Loaded coremods (and transformers): 
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

 

I dont see anywhere where I divide by 0.

 

here is my configIntValues:

package com.lambda.plentifulmisc.config;

/**
* Created by Blake on 11/23/2016.
*/
public enum ConfigIntValues {

    TILE_ENTITY_UPDATE_INTERVAL("Tile Entities: Update Interval", ConfigCategories.OTHER, 10, 1, 100, "The amount of ticks waited before a TileEntity sends an additional Update to the Client"),
    CTRL_INFO_NBT_CHAR_LIMIT("Advanced Info NBT Character Limit", ConfigCategories.OTHER, 1000, 0, 100000000, "The maximum amount of characters that is displayed by the NBT view of the CTRL Advanced Info. Set to a zero to have no limit");

    public final String name;
    public final String category;
    public final int defaultValue;
    public final int min;
    public final int max;
    public final String desc;

    public int currentValue;

    ConfigIntValues(String name, ConfigCategories category, int defaultValue, int min, int max, String desc) {
        this.name = name;
        this.category = category.name;
        this.defaultValue = defaultValue;
        this.min = min;
        this.max = max;
        this.desc = desc;
    }

    public int getValue() {
        return this.currentValue;
    }
}

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

I am here:

 

EDIT:

Just set it to a static value for now, anyways now I'm getting a crash:

java.lang.NullPointerException: Ticking block entity
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdate(TileEntityBase.java:106)
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdateWithInterval(TileEntityBase.java:231)
at com.lambda.plentifulmisc.tile.TileEntityCoalGenerator.updateEntity(TileEntityCoalGenerator.java:82)
at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:149)
at net.minecraft.world.World.updateEntities(World.java:1968)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547)
at java.lang.Thread.run(Thread.java:745)

at:

            if((this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()){

and

            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));

 

Is there something wrong with my packets?

here is the classes:

 

 

 

PacketHandler:

package com.lambda.plentifulmisc.network;

/**
* Created by Blake on 11/23/2016.
*/
import com.lambda.plentifulmisc.data.PlayerData;
import com.lambda.plentifulmisc.network.gui.IButtonReactor;
import com.lambda.plentifulmisc.network.gui.INumberSender;
import com.lambda.plentifulmisc.network.gui.IStringSender;
import com.lambda.plentifulmisc.tile.TileEntityBase;
import com.lambda.plentifulmisc.util.AssetUtil;
import com.lambda.plentifulmisc.util.ModUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.ArrayList;
import java.util.UUID;
import java.util.List;


public final class PacketHandler{

    public static final List<IDataHandler> DATA_HANDLERS = new ArrayList<IDataHandler>();
    public static final IDataHandler PARTICLE_HANDLER = new IDataHandler(){
        @Override
        @SideOnly(Side.CLIENT)
        public void handleData(NBTTagCompound compound){
            AssetUtil.renderParticlesFromAToB(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), compound.getInteger("ParticleAmount"), compound.getFloat("ParticleSize"), new float[]{compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3")}, compound.getFloat("AgeMultiplier"));
        }
    };
    public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler(){
        @Override
        @SideOnly(Side.CLIENT)
        public void handleData(NBTTagCompound compound){
            World world = Minecraft.getMinecraft().theWorld;
            if(world != null){
                TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
                if(tile instanceof TileEntityBase){
                    ((TileEntityBase)tile).readSyncableNBT(compound.getCompoundTag("Data"), TileEntityBase.NBTType.SYNC);
                }
            }
        }
    };
    public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
            TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));

            if(tile instanceof IButtonReactor){
                IButtonReactor reactor = (IButtonReactor)tile;
                Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
                if(entity instanceof EntityPlayer){
                    reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
                }
            }
        }
    };
    public static final IDataHandler GUI_BUTTON_TO_CONTAINER_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
            Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
            if(entity instanceof EntityPlayer){
                Container container = ((EntityPlayer)entity).openContainer;
                if(container instanceof IButtonReactor){
                    ((IButtonReactor)container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
                }
            }
        }
    };
    public static final IDataHandler GUI_NUMBER_TO_TILE_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
            TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));

            if(tile instanceof INumberSender){
                INumberSender reactor = (INumberSender)tile;
                reactor.onNumberReceived(compound.getInteger("Number"), compound.getInteger("NumberID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
            }
        }
    };
    public static final IDataHandler GUI_STRING_TO_TILE_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
            TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));

            if(tile instanceof IStringSender){
                IStringSender reactor = (IStringSender)tile;
                reactor.onTextReceived(compound.getString("Text"), compound.getInteger("TextID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
            }
        }
    };
    public static final IDataHandler CHANGE_PLAYER_DATA_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            NBTTagCompound data = compound.getCompoundTag("Data");
            UUID id = compound.getUniqueId("UUID");
            PlayerData.getDataFromPlayer(id).readFromNBT(data, false);
            if(compound.getBoolean("Log")){
                ModUtil.LOGGER.info("Receiving (new or changed) Player Data for player with UUID "+id+".");
            }
        }
    };
    public static SimpleNetworkWrapper theNetwork;

    public static void init(){
        theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID);
        theNetwork.registerMessage(PacketServerToClient.Handler.class, PacketServerToClient.class, 0, Side.CLIENT);
        theNetwork.registerMessage(PacketClientToServer.Handler.class, PacketClientToServer.class, 1, Side.SERVER);

        DATA_HANDLERS.add(PARTICLE_HANDLER);
        DATA_HANDLERS.add(TILE_ENTITY_HANDLER);
        DATA_HANDLERS.add(GUI_BUTTON_TO_TILE_HANDLER);
        DATA_HANDLERS.add(GUI_STRING_TO_TILE_HANDLER);
        DATA_HANDLERS.add(GUI_NUMBER_TO_TILE_HANDLER);
        DATA_HANDLERS.add(CHANGE_PLAYER_DATA_HANDLER);
        DATA_HANDLERS.add(GUI_BUTTON_TO_CONTAINER_HANDLER);
    }
}

 

ServerToClient

package com.lambda.plentifulmisc.network;

import com.lambda.plentifulmisc.util.ModUtil;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Created by Blake on 11/23/2016.
*/
public class PacketServerToClient implements IMessage{

    private NBTTagCompound data;
    private IDataHandler handler;

    public PacketServerToClient(){

    }

    public PacketServerToClient(NBTTagCompound data, IDataHandler handler){
        this.data = data;
        this.handler = handler;
    }

    @Override
    public void fromBytes(ByteBuf buf){
        PacketBuffer buffer = new PacketBuffer(buf);
        try{
            this.data = buffer.readNBTTagCompoundFromBuffer();

            int handlerId = buffer.readInt();
            if(handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()){
                this.handler = PacketHandler.DATA_HANDLERS.get(handlerId);
            }
        }
        catch(Exception e){
            ModUtil.LOGGER.error("Cannot receive a client packet!", e);
        }
    }

    @Override
    public void toBytes(ByteBuf buf){
        PacketBuffer buffer = new PacketBuffer(buf);

        buffer.writeNBTTagCompoundToBuffer(this.data);
        buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler));
    }

    public static class Handler implements IMessageHandler<PacketServerToClient, IMessage> {

        @Override
        @SideOnly(Side.CLIENT)
        public IMessage onMessage(PacketServerToClient aMessage, MessageContext ctx){
            final PacketServerToClient message = aMessage;
            Minecraft.getMinecraft().addScheduledTask(new Runnable(){
                @Override
                public void run(){
                    if(message.data != null && message.handler != null){
                        message.handler.handleData(message.data);
                    }
                }
            });
            return null;
        }
    }
}

 

ClientToServer

package com.lambda.plentifulmisc.network;

/**
* Created by Blake on 11/23/2016.
*/
import com.lambda.plentifulmisc.util.ModUtil;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class PacketClientToServer implements IMessage{

    private NBTTagCompound data;
    private IDataHandler handler;

    public PacketClientToServer(){

    }

    public PacketClientToServer(NBTTagCompound data, IDataHandler handler){
        this.data = data;
        this.handler = handler;
    }

    @Override
    public void fromBytes(ByteBuf buf){
        PacketBuffer buffer = new PacketBuffer(buf);
        try{
            this.data = buffer.readNBTTagCompoundFromBuffer();

            int handlerId = buffer.readInt();
            if(handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()){
                this.handler = PacketHandler.DATA_HANDLERS.get(handlerId);
            }
        }
        catch(Exception e){
            ModUtil.LOGGER.error("Cannot Receive Server Packet!", e);
        }
    }

    @Override
    public void toBytes(ByteBuf buf){
        PacketBuffer buffer = new PacketBuffer(buf);

        buffer.writeNBTTagCompoundToBuffer(this.data);
        buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler));
    }

    public static class Handler implements IMessageHandler<PacketClientToServer, IMessage>{

        @Override
        public IMessage onMessage(PacketClientToServer aMessage, MessageContext ctx){
            final PacketClientToServer message = aMessage;
            FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(new Runnable(){
                @Override
                public void run(){
                    if(message.data != null && message.handler != null){
                        message.handler.handleData(message.data);
                    }
                }
            });
            return null;
        }
    }
}

 

Lastly, do you have to register the handler?

 

 

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

You never set currentValue (so it is 0).

 

*Cough*

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I am here:

    public int getValue() {
        return this.currentValue;
    }

It is never set.

public int currentValue;

    ConfigIntValues(String name, ConfigCategories category, int defaultValue, int min, int max, String desc) {
        this.name = name;
        this.category = category.name;
        this.defaultValue = defaultValue;
        this.min = min;
        this.max = max;
        this.desc = desc;
    }

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

Hi

 

I dont see anywhere where I divide by 0.

 

This line in the crash report tells you exactly where to start looking for the error:

 

java.lang.ArithmeticException: / by zero
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdateWithInterval(TileEntityBase.java:230)

If you're looking at that line and it's not obvious what's causing it, you can use your debugger to set a breakpoint at that line, and inspect the variables.  You can also use a breakpoint on ArithmeticException, i.e. when ArithmeticException is about to be thrown, the program execution stops and lets you look at what's happening.

 

http://www.vogella.com/tutorials/EclipseDebugging/article.html

or

https://www.jetbrains.com/idea/webhelp/debugging.html

and

 

-TGG

Posted

Always post the crash report.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Yeah edited the post above

java.lang.NullPointerException: Ticking block entity
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdate(TileEntityBase.java:106)
at com.lambda.plentifulmisc.tile.TileEntityBase.sendUpdateWithInterval(TileEntityBase.java:231)
at com.lambda.plentifulmisc.tile.TileEntityCoalGenerator.updateEntity(TileEntityCoalGenerator.java:82)
at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:149)
at net.minecraft.world.World.updateEntities(World.java:1968)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547)
at java.lang.Thread.run(Thread.java:745)

at:

            if((this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()){

and

            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));

 

Is there something wrong with my packets?

here is the classes:

 

 

 

PacketHandler:

package com.lambda.plentifulmisc.network;

/**
* Created by Blake on 11/23/2016.
*/
import com.lambda.plentifulmisc.data.PlayerData;
import com.lambda.plentifulmisc.network.gui.IButtonReactor;
import com.lambda.plentifulmisc.network.gui.INumberSender;
import com.lambda.plentifulmisc.network.gui.IStringSender;
import com.lambda.plentifulmisc.tile.TileEntityBase;
import com.lambda.plentifulmisc.util.AssetUtil;
import com.lambda.plentifulmisc.util.ModUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.ArrayList;
import java.util.UUID;
import java.util.List;


public final class PacketHandler{

    public static final List<IDataHandler> DATA_HANDLERS = new ArrayList<IDataHandler>();
    public static final IDataHandler PARTICLE_HANDLER = new IDataHandler(){
        @Override
        @SideOnly(Side.CLIENT)
        public void handleData(NBTTagCompound compound){
            AssetUtil.renderParticlesFromAToB(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), compound.getInteger("ParticleAmount"), compound.getFloat("ParticleSize"), new float[]{compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3")}, compound.getFloat("AgeMultiplier"));
        }
    };
    public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler(){
        @Override
        @SideOnly(Side.CLIENT)
        public void handleData(NBTTagCompound compound){
            World world = Minecraft.getMinecraft().theWorld;
            if(world != null){
                TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
                if(tile instanceof TileEntityBase){
                    ((TileEntityBase)tile).readSyncableNBT(compound.getCompoundTag("Data"), TileEntityBase.NBTType.SYNC);
                }
            }
        }
    };
    public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
            TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));

            if(tile instanceof IButtonReactor){
                IButtonReactor reactor = (IButtonReactor)tile;
                Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
                if(entity instanceof EntityPlayer){
                    reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
                }
            }
        }
    };
    public static final IDataHandler GUI_BUTTON_TO_CONTAINER_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
            Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
            if(entity instanceof EntityPlayer){
                Container container = ((EntityPlayer)entity).openContainer;
                if(container instanceof IButtonReactor){
                    ((IButtonReactor)container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
                }
            }
        }
    };
    public static final IDataHandler GUI_NUMBER_TO_TILE_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
            TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));

            if(tile instanceof INumberSender){
                INumberSender reactor = (INumberSender)tile;
                reactor.onNumberReceived(compound.getInteger("Number"), compound.getInteger("NumberID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
            }
        }
    };
    public static final IDataHandler GUI_STRING_TO_TILE_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
            TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));

            if(tile instanceof IStringSender){
                IStringSender reactor = (IStringSender)tile;
                reactor.onTextReceived(compound.getString("Text"), compound.getInteger("TextID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
            }
        }
    };
    public static final IDataHandler CHANGE_PLAYER_DATA_HANDLER = new IDataHandler(){
        @Override
        public void handleData(NBTTagCompound compound){
            NBTTagCompound data = compound.getCompoundTag("Data");
            UUID id = compound.getUniqueId("UUID");
            PlayerData.getDataFromPlayer(id).readFromNBT(data, false);
            if(compound.getBoolean("Log")){
                ModUtil.LOGGER.info("Receiving (new or changed) Player Data for player with UUID "+id+".");
            }
        }
    };
    public static SimpleNetworkWrapper theNetwork;

    public static void init(){
        theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID);
        theNetwork.registerMessage(PacketServerToClient.Handler.class, PacketServerToClient.class, 0, Side.CLIENT);
        theNetwork.registerMessage(PacketClientToServer.Handler.class, PacketClientToServer.class, 1, Side.SERVER);

        DATA_HANDLERS.add(PARTICLE_HANDLER);
        DATA_HANDLERS.add(TILE_ENTITY_HANDLER);
        DATA_HANDLERS.add(GUI_BUTTON_TO_TILE_HANDLER);
        DATA_HANDLERS.add(GUI_STRING_TO_TILE_HANDLER);
        DATA_HANDLERS.add(GUI_NUMBER_TO_TILE_HANDLER);
        DATA_HANDLERS.add(CHANGE_PLAYER_DATA_HANDLER);
        DATA_HANDLERS.add(GUI_BUTTON_TO_CONTAINER_HANDLER);
    }
}

 

ServerToClient

package com.lambda.plentifulmisc.network;

import com.lambda.plentifulmisc.util.ModUtil;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Created by Blake on 11/23/2016.
*/
public class PacketServerToClient implements IMessage{

    private NBTTagCompound data;
    private IDataHandler handler;

    public PacketServerToClient(){

    }

    public PacketServerToClient(NBTTagCompound data, IDataHandler handler){
        this.data = data;
        this.handler = handler;
    }

    @Override
    public void fromBytes(ByteBuf buf){
        PacketBuffer buffer = new PacketBuffer(buf);
        try{
            this.data = buffer.readNBTTagCompoundFromBuffer();

            int handlerId = buffer.readInt();
            if(handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()){
                this.handler = PacketHandler.DATA_HANDLERS.get(handlerId);
            }
        }
        catch(Exception e){
            ModUtil.LOGGER.error("Cannot receive a client packet!", e);
        }
    }

    @Override
    public void toBytes(ByteBuf buf){
        PacketBuffer buffer = new PacketBuffer(buf);

        buffer.writeNBTTagCompoundToBuffer(this.data);
        buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler));
    }

    public static class Handler implements IMessageHandler<PacketServerToClient, IMessage> {

        @Override
        @SideOnly(Side.CLIENT)
        public IMessage onMessage(PacketServerToClient aMessage, MessageContext ctx){
            final PacketServerToClient message = aMessage;
            Minecraft.getMinecraft().addScheduledTask(new Runnable(){
                @Override
                public void run(){
                    if(message.data != null && message.handler != null){
                        message.handler.handleData(message.data);
                    }
                }
            });
            return null;
        }
    }
}

 

ClientToServer

package com.lambda.plentifulmisc.network;

/**
* Created by Blake on 11/23/2016.
*/
import com.lambda.plentifulmisc.util.ModUtil;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class PacketClientToServer implements IMessage{

    private NBTTagCompound data;
    private IDataHandler handler;

    public PacketClientToServer(){

    }

    public PacketClientToServer(NBTTagCompound data, IDataHandler handler){
        this.data = data;
        this.handler = handler;
    }

    @Override
    public void fromBytes(ByteBuf buf){
        PacketBuffer buffer = new PacketBuffer(buf);
        try{
            this.data = buffer.readNBTTagCompoundFromBuffer();

            int handlerId = buffer.readInt();
            if(handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()){
                this.handler = PacketHandler.DATA_HANDLERS.get(handlerId);
            }
        }
        catch(Exception e){
            ModUtil.LOGGER.error("Cannot Receive Server Packet!", e);
        }
    }

    @Override
    public void toBytes(ByteBuf buf){
        PacketBuffer buffer = new PacketBuffer(buf);

        buffer.writeNBTTagCompoundToBuffer(this.data);
        buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler));
    }

    public static class Handler implements IMessageHandler<PacketClientToServer, IMessage>{

        @Override
        public IMessage onMessage(PacketClientToServer aMessage, MessageContext ctx){
            final PacketClientToServer message = aMessage;
            FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(new Runnable(){
                @Override
                public void run(){
                    if(message.data != null && message.handler != null){
                        message.handler.handleData(message.data);
                    }
                }
            });
            return null;
        }
    }
}

 

Lastly, do you have to register the handler?

 

 

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

            this.sendUpdate();

Is this your updateEntity method?

            if((this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()){

If so post your sendUpdate line 106.

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

    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());
         -> 106   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));
        }
    }

 

and yes that is in my update entity

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Posted

I suspect the world is null, as was pointed out earlier. Is that 100% the only place you call sendUpdate?

Sadly if it was the world it would error earlier in the code....I'm thinking his PacketHandler.theNetwork is not initialized.

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

Yeah I dont think it is either, bottom of the spoiler i said something like that, how would I do that?

You need to call your PacketHandler.init() somewhere in your main mod class.

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

For future reference, follow the advice to use the debugger. WHENEVER you (meaning anyone reading this thread) encounter a null-pointer exception, read the call stack back to your own code (perhaps in a "caused by"), go to the referenced line (in Eclipse, just click on the red line number), and set a breakpoint.

 

Then re-run your code. After hitting the breakpoint, step through statements and into methods until you reach the exceptional line. All along the way, examine the values of variables being used. There's a good chance that palm will slap face at some point.

 

If you're unlucky enough to have one of those statements that runs a thousand times before it causes an exception, then you may need to study about conditional breakpoints.

 

If after stepping through code you still have an exception that you can't see how to fix, then post your crash report and what you learned while stepping through the debugger. People here will be so impressed that you used the debugger that they'll fall all over each other to help you  :)

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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

    • My apologies, it's a Postscript. I was able to play for an extended period of time right after generating the world without any problems. If I close it and reopen it, I get that message at random. Once it appears, I have to modify the Level.dat to open it.
    • Share logs/errors, and someone may know how to help. Make sure to read the FAQ on sharing logs.
    • Hello.  regarding Invalid player data.  First of all, my English is not good, so there might be mistakes. I am using Minecraft 1.20.1 forge 47.3.22 CurseForge and have over 250 mods in my modpack. Single-player. I can play the game after generating the world (about 5 hours) and restarting it, but there is no set timing and one day it suddenly shows ''Invalid player data''. Restarted the game several times after that, but the same message appears. Fix the level.dat file and play for a few hours, but the next day when I try to open the world I get the ''Invalid player data'' message again. Can open other worlds, but after some progress in the other worlds, the same message appears and I can't start them. Is there something wrong with the mod configuration? I would be very grateful if you could tell me how to solve this problem. ◉ErrorCode https://mclo.gs/4gcfPbY   ◉ModList AdvancementPlaques-forge-1.6.9.jar AI-Improvements-1.20-0.5.2.jar alexsmobs-1.22.9.jar alternate_current-mc1.20-1.7.0.jar AmbientSounds_FORGE_v6.1.6_mc1.20.1.jar amendments-1.20-1.2.18.jar Apotheosis-1.20.1-7.4.6.jar ApothicAttributes-1.20.1-1.3.7.jar appleskin-forge-mc1.20.1-2.5.1.jar aquamirae-6.API15.jar architectury-9.2.14-forge.jar ars_elemental-1.20.1-0.6.7.7.jar ars_extended_glyphs-1.20.1-1.9.jar ars_nouveau-1.20.1-4.12.6-all.jar AttributeFix-Forge-1.20.1-21.0.4.jar azurelib-neo-1.20.1-2.0.41.jar BadOptimizations-2.2.1-1.20.1.jar balm-forge-1.20.1-7.3.16-all.jar barbequesdelight-1.0.5.jar BattleArts-20.9.7.1.jar BattleArtsAPI-20.9.5.3.jar BEB-Forge-1.20.1-2.0.0.jar bendy-lib-forge-4.0.0.jar betterendcities-1.0.0-1.20.1.jar betterfpsdist-1.20.1-6.0.jar BetterThirdPerson-Forge-1.20-1.9.0.jar bettervillage-forge-1.20.1-3.2.0.jar biggerendcities-1.20.1-1.0.0.jar blockui-1.20.1-1.0.156-RELEASE.jar blueprint-1.20.1-7.1.1.jar blur-forge-3.1.1.jar BOMD-Forge-1.20.1-1.1.1.jar Bookshelf-Forge-1.20.1-20.2.13.jar BrewinAndChewin-1.20.1-3.1.2.jar BridgingMod-2.5.1+1.20.1.forge-release.jar caelus-forge-3.2.0+1.20.1.jar CarbonConfig-1.20-1.2.6.jar Cardiac-FORGE-0.5.3.2+1.20.1.jar carryon-forge-1.20.1-2.1.2.7.jar casualness_delight-1.20.1-0.4n.jar CerbonsApi-Forge-1.20.1-1.0.0.jar chat_heads-0.13.13-forge-1.20.jar cherishedworlds-forge-6.1.7+1.20.1.jar ChoiceTheorem's Overhauled Village-3.4.11.jar Chunk-Pregenerator-1.20-4.4.4.jar citadel-2.6.1-1.20.1.jar clean_tooltips-1.0-forge-1.20.1.jar cloth-config-11.1.136-forge.jar Clumps-forge-1.20.1-12.0.0.4.jar cobweb-forge-1.20.1-1.0.1.jar CocoaInput-1.20.5-fabric-4.4.1-EXPERIMENTAL.jar collective-1.20.1-7.91.jar cosmeticarmorreworked-1.20.1-v1a.jar create-1.20.1-0.5.1.j.jar create_easy_structures-0.1.2-forge-1.20.1.jar CreativeCore_FORGE_v2.12.31_mc1.20.1.jar creeperoverhaul-3.0.2-forge.jar cristellib-1.1.6-forge.jar cuisinedelight-1.1.16.jar cupboard-1.20.1-2.7.jar curios-forge-5.11.1+1.20.1.jar CutAllSMP_v2.5.2.jar default_skill_trees-1.1.jar DisenchantmentEditTable-1.20-1.1.2.jar DistantHorizons-2.2.1-a-1.20.1-forge-fabric.jar domesticationinnovation-1.7.1-1.20.1.jar domum_ornamentum-1.20.1-1.0.186-RELEASE-universal.jar dragonitegear-0.3.2.jar Dungeon Crawl-1.20.1-2.3.15.jar dungeons-and-taverns-ancient-city-overhaul-1 [Forge].jar DungeonsArise-1.20.x-2.1.58-release.jar dungeons_enhanced-1.20.1-5.3.0.jar dungeons_plus-1.20.1-1.5.0.jar ec_isasb_plugin-1.20.1-1.0.0-all.jar efiscompat-2.2.4.jar EFMCompat 20.2.0.1.jar embeddium-0.3.31+mc1.20.1.jar EnchantmentDescriptions-Forge-1.20.1-17.1.19.jar endermanoverhaul-forge-1.20.1-1.0.4.jar EnderWyrmlings-1.0.0-forge-1.20.1.jar endrem_forge-5.3.3-R-1.20.1.jar enhanced_boss_bars-1.20.1-1.0.0.jar entityculling-forge-1.7.2-mc1.20.1.jar entity_model_features_forge_1.20.1-2.4.1.jar entity_texture_features_forge_1.20.1-6.2.9.jar Epic-Knights-9.21.jar Epic-Knights-Addon-1.22.jar Epic-Knights-Slavic-Armory-1.5.jar epicfight-forge-20.9.7-1.20.1.jar essential_1-3-5-7_forge_1-20-1.jar ExCap-20.9.7.3.jar exoticbirds-1.20.1-1.0.0.jar expanded_combat-1.20.1-3.2.4-all.jar Explorify v1.6.2 f10-48.jar extrasounds-1.20.1-forge-1.3.jar falchionmoveset-20.8.2.jar Fallingleaves-1.20.1-2.1.0.jar FarmersDelight-1.20.1-1.2.7.jar farsight-1.20.1-3.7.jar FastFurnace-1.20.1-8.0.2.jar FastSuite-1.20.1-5.0.1.jar FastWorkbench-1.20.1-8.0.4.jar ferritecore-6.0.1-forge.jar forge-medievalend-1.0.1.jar framework-forge-1.20.1-0.7.12.jar frozen_zombie_castle-1.4.0-forge-1.20.1.jar fzzy_config-0.6.4+1.20.1+forge.jar geckolib-forge-1.20.1-4.7.jar globalxp-forge-1.20.1-1.12.jar goblintraders-forge-1.20.1-1.9.3.jar gravestone-forge-1.20.1-1.0.24.jar guardvillagers-1.20.1-1.6.10.jar harvest-with-ease-forge-1.20.1-9.4.0.jar Highlighter-1.20.1-forge-1.1.9.jar hole_filler_mod-1.2.8_mc-1.20.1_forge.jar Iceberg-1.20.1-forge-1.1.25.jar ImmediatelyFast-Forge-1.3.4+1.20.4.jar ImmersiveUI-FORGE-0.3.0.jar imst-2.1.0.jar infernalmobs-1.20.1.6.jar integrated_api-1.5.1+1.20.1-forge.jar integrated_villages-1.1.5+1.20.1-forge.jar inventoryhud.forge.1.20.1-3.4.26.jar InventoryProfilesNext-forge-1.20-1.10.14.jar inventorysorter-1.20.1-23.0.8.jar InventorySpam-1.20.1-1.5.6.jar ironchest-1.20.1-14.4.4.jar irons_spellbooks-1.20.1-3.4.0.7.jar iron_repair_kits-2.4.3-forge-1.20.1.jar ItemBorders-1.20.1-forge-1.2.2.jar ItemProductionLib-1.20.1-1.0.2a-all.jar Jade-1.20.1-Forge-11.12.3.jar jei-1.20.1-forge-15.20.0.106.jar journeymap-1.20.1-5.10.3-forge.jar justhammers-forge-2.0.3+mc1.20.1.jar Kobolds-2.12.0.jar kotlinforforge-4.11.0-all.jar LegendaryTooltips-1.20.1-forge-1.4.5.jar libIPN-forge-1.20-4.0.2.jar libraryferret-forge-1.20.1-4.0.0.jar lionfishapi-2.4-Fix.jar lithostitched-forge-1.20.1-1.4.4.jar lmft-1.0.4+1.20.1-forge.jar lootbeams-1.20.1-1.2.6.jar lootintegrations-1.20.1-4.0.jar lukis-grand-capitals-1.1.1.jar L_Enders_Cataclysm-2.54- 1.20.1.jar mes-1.3.4-1.20-forge.jar mexicans_delight-1.1.1-forge-1.20.1.jar MineAllSMP_v2.6.6.jar minecolonies-1.20.1-1.1.814-snapshot.jar mna-forge-1.20.1-3.1.0.4-all.jar modernfix-forge-5.20.2+mc1.20.1.jar ModernUI-Forge-1.20.1-3.11.1.6-universal.jar modlist.txt moonlight-1.20-2.13.65-forge.jar mowziesmobs-1.7.0.jar multipiston-1.20-1.2.43-RELEASE.jar MutantMonsters-v8.0.7-1.20.1-Forge.jar mutil-1.20.1-6.1.1.jar mvs-4.1.4-1.20-forge.jar NaturesCompass-1.20.1-1.11.2-forge.jar Neat-1.20.1-41-FORGE.jar netherportalfix-forge-1.20-13.0.1.jar notenoughanimations-forge-1.9.2-mc1.20.1.jar Obscure-Tooltips-2.2.jar obscure_api-15.jar OctoLib-FORGE-0.4.2+1.20.1.jar oculus-mc1.20.1-1.8.0.jar packetfixer-forge-2.0.0-1.19-to-1.20.1.jar PackingTape-1.20.1-0.14.3.jar PassiveSkillTree-1.20.1-BETA-0.6.14a-all.jar Patchouli-1.20.1-84.1-FORGE.jar phantasm-1.0.1.jar Placebo-1.20.1-8.6.2.jar player-animation-lib-forge-1.0.2-rc1+1.20.jar polymorph-forge-0.49.8+1.20.1.jar Prism-1.20.1-forge-1.0.5.jar projectvibrantjourneys-1.20.1-6.0.5.jar puffish_attributes-0.7.2-1.20-forge.jar puffish_skills-0.14.7-1.20-forge.jar PuzzlesLib-v8.1.25-1.20.1-Forge.jar QualityCrops-1.20.1-1.3.3.jar QualitysDelight-1.20.1-1.5.3.jar Quark-4.0-460.jar QUILT-2.0.0.jar repair_amulet-2.0-forge-1.20.1.jar repurposed_structures-7.1.15+1.20.1-forge.jar resourcefulconfig-forge-1.20.1-2.1.2.jar resourcefullib-forge-1.20.1-2.1.29.jar RPG-HUD-3.10.jar rpg_companions_tiny_dragons-0.0.4-forge-1.20.1.jar run.bat samurai_dynasty-0.0.48-1.20.1-neo.jar simplyswords-forge-1.56.0-1.20.1.jar SkyVillages-1.0.4-1.19.2-1.20.1-forge-release.jar smoothboot(reloaded)-mc1.20.1-0.0.4.jar sophisticatedbackpacks-1.20.1-3.23.5.1200.jar sophisticatedcore-1.20.1-1.2.12.872.jar sound-physics-remastered-forge-1.20.1-1.4.8.jar Stackable Potions-forge-1.20.1-1.0.0.jar StorageBox_v3.2.5.jar StorageDrawers-1.20.1-12.9.13.jar Structory_1.20.x_v1.3.5.jar Structory_Towers_1.20.x_v1.0.7.jar structure_gel-1.20.1-2.16.2.jar structurize-1.20.1-1.0.764-snapshot.jar SubtleEffects-forge-1.20.1-1.8.0.jar supermartijn642configlib-1.1.8-forge-mc1.20.jar supermartijn642corelib-1.1.18-forge-mc1.20.1.jar supplementaries-1.20-3.1.13.jar TaxCastlePillager+M.1.20.1+ForM.1.0.1.jar TaxTreeGiant+M.1.20.1+ForM.1.1.0.jar TerraBlender-forge-1.20.1-3.0.1.7.jar Terralith_1.20.x_v2.5.4.jar tetra-1.20.1-6.8.0.jar TheOuterEnd-1.0.10.jar tidal-towns-1.3.4.jar tlc_forge-1.0.3-R-1.20.X.jar toms_storage-1.20-1.7.0.jar toomanyglyphs-1.20.1-2.3.2.12345.jar totw_additions-1.3.1-1.20.x-forge.jar totw_modded-forge-1.20.1-1.0.5.jar Towns-and-Towers-1.12-Fabric+Forge.jar towntalk-1.20.1-1.1.0.jar trashcans-1.0.18b-forge-mc1.20.jar trashslot-forge-1.20-15.1.1.jar travelersbackpack-forge-1.20.1-9.1.16.jar TravelersTitles-1.20-Forge-4.0.2.jar tru.e-ending-v1.1.0c.jar uncrafter-forge-1.20.1-1.2.0.jar valarian_conquest-3.0-forge-1.20.1.jar valhelsia_core-forge-1.20.1-1.1.2.jar valhelsia_structures-forge-1.20.1-1.1.2.jar villagernames-1.20.1-8.2.jar visuality-forge-2.0.2.jar waystones-forge-1.20.1-14.1.9.jar WeaponsOfMiracles-20.1.8.5.6.jar XP From Harvest Reworked-1.20.x-1.2.4.jar YetAnotherConfigLib-3.6.2+1.20.1-forge.jar YungsApi-1.20-Forge-4.0.6.jar YungsBetterDesertTemples-1.20-Forge-3.0.3.jar YungsBetterDungeons-1.20-Forge-4.0.4.jar YungsBetterEndIsland-1.20-Forge-2.0.6.jar YungsBetterJungleTemples-1.20-Forge-2.0.5.jar YungsBetterMineshafts-1.20-Forge-4.0.4.jar YungsBetterNetherFortresses-1.20-Forge-2.0.6.jar YungsBetterOceanMonuments-1.20-Forge-3.0.4.jar YungsBetterWitchHuts-1.20-Forge-3.0.3.jar YungsBridges-1.20-Forge-4.0.3.jar YungsCaveBiomes-1.20.1-Forge-2.0.1.jar YungsExtras-1.20-Forge-4.0.3.jar Zeta-1.0-24.jar  
    • I did exactly like in the instruction , i even copied the build.gradle from alex mobs like he told in the instruction for citadel 1.7.0 and above, and i got 100 different error no matter what i changed in the build.gradle, i once managed to make a build succesfull but then the run client wasnt working I did exactly like in the instruction , i even copied the build.gradle from alex mobs like he told in the instruction for citadel 1.7.0 and above, and i got 100 different error no matter what i changed in the build.gradle, i once managed to make a build succesfull but then the run client wasnt working
    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ
  • Topics

×
×
  • Create New...

Important Information

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