Lambda Posted November 23, 2016 Posted November 23, 2016 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. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Draco18s Posted November 23, 2016 Posted November 23, 2016 My first guess is that worldObj is null (which can happen). Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 How would I make sure this doesnt happen or should I just nullcheck and return false? EDIT: if(!this.worldObj.isRemote && worldObj != null){ this in updateEntity didnt seem to work. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Draco18s Posted November 23, 2016 Posted November 23, 2016 Null check, yes. Also sendUpdate is a void, so you don't return anything. Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 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; } } Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted November 23, 2016 Posted November 23, 2016 You never set currentValue so it is 0. Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 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? Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Draco18s Posted November 23, 2016 Posted November 23, 2016 You never set currentValue (so it is 0). *Cough* Quote 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.
Animefan8888 Posted November 23, 2016 Posted November 23, 2016 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; } Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 Oh didnt see that. Anyways still getting the crash. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
TheGreyGhost Posted November 23, 2016 Posted November 23, 2016 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 Quote
Lambda Posted November 23, 2016 Author Posted November 23, 2016 Thanks for your response, however, I'm getting a new error posted above. Thanks again. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Draco18s Posted November 23, 2016 Posted November 23, 2016 Always post the crash report. Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 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? Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted November 23, 2016 Posted November 23, 2016 What is sendUpdateWithInterval line 231? Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 this.sendUpdate(); Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted November 23, 2016 Posted November 23, 2016 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. Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 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 Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Lambda Posted November 23, 2016 Author Posted November 23, 2016 Should I be checking if the world is null before calling the update? Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted November 23, 2016 Posted November 23, 2016 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. Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 Yeah I dont think it is either, bottom of the spoiler i said something like that, how would I do that? Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted November 23, 2016 Posted November 23, 2016 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. Quote 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.
Lambda Posted November 23, 2016 Author Posted November 23, 2016 That seemed to do it Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
jeffryfisher Posted November 23, 2016 Posted November 23, 2016 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 Quote 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.
Recommended Posts
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.