Jump to content

Recommended Posts

Posted

Hello and may I start off saying this is really weird and I have never seen anything like this. I have made TileEntities before, and never ran into this problem.

I have other TileEntities that are being called on the server.

 

This is the updateEntity method in the TileEntity.

 

        @Override
public void updateEntity() {
	System.out.println("Server Ticking Solar Generator");
}

 

 

This is my whole Block class.

 

package com.anime.wirelessrevolution.blocks.generators;

import com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class SolarGenerator extends BlockContainer {

public SolarGenerator() {
	super(Material.iron);
	this.setHarvestLevel("pickaxe", 0);
}

@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
	if (!world.isRemote)
		System.out.println("Creating a new instance and world is not remote.");
	return new TileEntitySolarGenerator();
}

}

 

 

This is my TileEntity Registry.

 

package com.anime.wirelessrevolution;

import com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator;
import com.anime.wirelessrevolution.tileentity.energy.machine.TileEntityEnergeticFurnace;
import com.anime.wirelessrevolution.tileentity.energy.routers.TileEntityBasicRouter;
import com.anime.wirelessrevolution.tileentity.research.TileEntityTinkeringTable;
import com.anime.wirelessrevolution.util.RegistryHelper;

import cpw.mods.fml.common.registry.GameRegistry;

public class TileEntities {

public static void register() {
	/** Standard TileEntities **/
	RegistryHelper.registerTleEntity(TileEntityTinkeringTable.class);

	/** Electric Routers **/
	RegistryHelper.registerTleEntity(TileEntityBasicRouter.class);

	/** Electric Generators **/
	GameRegistry.registerTileEntity(TileEntitySolarGenerator.class, "tileEntitySolarPanel");
//		RegistryHelper.registerTleEntity(TileEntitySolarGenerator.class);

	/** Electrical Machines **/
	RegistryHelper.registerTleEntity(TileEntityEnergeticFurnace.class);

}

}

 

 

This is my main class

 

package com.anime.wirelessrevolution;

import com.anime.wirelessrevolution.inventory.gui.GUIBookResources;
import com.anime.wirelessrevolution.oredictionary.OreDict;
import com.anime.wirelessrevolution.proxy.GUIHandler;
import com.anime.wirelessrevolution.proxy.ServerProxy;
import com.anime.wirelessrevolution.util.ConfigHandler;
import com.anime.wirelessrevolution.util.CraftingHelper;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;

@Mod(modid = WirelessRevolution.MODID, version = WirelessRevolution.VERSION, name = WirelessRevolution.NAME)
public class WirelessRevolution {

public static final String MODID = "wirelessrevolution", VERSION = "1.0 ALPHA", NAME = "Wireless Revolution";

@Instance
public static  WirelessRevolution instance = new WirelessRevolution();

@SidedProxy(clientSide = "com.anime.wirelessrevolution.proxy.ClientProxy", serverSide = "com.anime.wirelessrevolution.proxy.ServerProxy")
public static ServerProxy proxy = new ServerProxy();

public static GUIHandler guiHandler;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	ConfigHandler.init(event);
	Items.init();
	Blocks.init();
	Items.register();
	Blocks.register();
}

@EventHandler
public void Init(FMLInitializationEvent event) {
	CraftingHelper.registerCrafting();
	TileEntities.register();
	OreDict.registerOreDictionary();
	proxy.registerRender();
	FMLCommonHandler.instance().bus().register(new com.anime.wirelessrevolution.events.EventHandler());
	NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler = new GUIHandler());
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
	GUIBookResources.init();
}

}

 

 

This is the Log from my dev environment from when createNewTileEntity was called until I paused the game to look at the log.

 

 

[16:59:58] [server thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.blocks.generators.SolarGenerator:createNewTileEntity:22]: Creating a new instance and world is not remote.

[16:59:58] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:58] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:58] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:58] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:58] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:58] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[16:59:59] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

[17:00:00] [Client thread/INFO] [sTDOUT]: [com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator:updateEntity:15]: Server Ticking Solar Generator

 

 

Any help would be apreciated and I am using forge 1.7.10-10.13.4.1614. I am using 1.7.10 because alot of mods aren't updated and I do plan on updating after "finishing" it.

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

Thank you for your help Diesieben I plan on updating, sorry for still using 1.7.10. I switched over to the normal Block class and set hasTileEntity to true and changed the createNewTileEntity to createTileEntity. This just caused the update method to never get called. Yes I know that tileEntitySolarPanel is a terrible name, but it was only to test if there was a problem with my methed RegistryHelper.registerTileEntity (which is just a loop into GameRegistry.registerTileEntity).

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

The reason I have the loop in is so I don't have to type GameRegistry.registerTileEntity(TileEntity.class, Main.MODID + ":tileEntity")

 

Full TileEntity class

 

package com.anime.wirelessrevolution.tileentity.energy.gen;

import api.anime.energy.EnergyGenerator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;

public class TileEntitySolarGenerator extends EnergyGenerator implements ISidedInventory {

public TileEntitySolarGenerator() {

}

@Override
public void updateEntity() {
	System.out.println("Server Ticking Solar Generator");
}

@Override
public int getSizeInventory() {
	return 0;
}

@Override
public ItemStack getStackInSlot(int p_70301_1_) {
	return null;
}

@Override
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
	return null;
}

@Override
public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
	return null;
}

@Override
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {

}

@Override
public String getInventoryName() {
	return null;
}

@Override
public boolean hasCustomInventoryName() {
	return false;
}

@Override
public int getInventoryStackLimit() {
	return 0;
}

@Override
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
	return false;
}

@Override
public void openInventory() {}

@Override
public void closeInventory() {}

@Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
	return false;
}

@Override
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
	return null;
}

@Override
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) {
	return false;
}

@Override
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
	return false;
}

}

 

 

Base Class for TileEntity

 

package api.anime.energy;

import com.anime.wirelessrevolution.energysettings.EnergyStatics;
import com.anime.wirelessrevolution.util.ConfigHandler;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class EnergyGenerator extends TileEntity implements IEnergyGenerator {

public EnergyHandler handler = new EnergyHandler(10, 100);

@Override
public void updateEntity() {}

@Override
public void readFromNBT(NBTTagCompound tag) {
	super.readFromNBT(tag);
	if (handler == null)
		setEnergyHandlerFromLoad(tag);
	if (handler != null)
		handler.readFromNBT(tag);
	updateVoltage(false);
}

@Override
public void writeToNBT(NBTTagCompound tag) {
	super.readFromNBT(tag);
	if (handler != null)
		handler.writeToNBT(tag);
}

@Override
public Packet getDescriptionPacket() {
	super.getDescriptionPacket();
	NBTTagCompound nbt = new NBTTagCompound();
	writeToNBT(nbt);
	return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbt);
}
    
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
	super.onDataPacket(net, pkt);
	readFromNBT(pkt.func_148857_g());	
}

@Override
public double getGenerated() {
	return 1;
}

@Override
public void generate(boolean simulate) {
	System.out.println("Gen Start");
	double energy = handler.getCurrent() * 100D;
	double energyReceived = Math.min(getMaxEnergyStored() * 100D - energy, getGenerated() * 100D);
	if (!simulate && handler != null) {
		System.out.println("Not a simulation");
		int newEnergy = (int) (energy + energyReceived);
		energy = newEnergy / 100D;
		System.out.println("New Energy: " + energy);
		handler.setCurrent(energy);
		updateVoltage(simulate);
		markDirty();
	}
	System.out.println("Stop");
}

@Override
public double updateVoltage(boolean simulate) {
	double deltaVoltage = EnergyStatics.calculateVoltage(handler.getCurrent(), getResistance()) - handler.getVoltage();
	if (!simulate) {
		handler.setVoltage(EnergyStatics.calculateVoltage(handler.getCurrent(), getResistance()));
	}
	return deltaVoltage;
}

@Override
public double extractEnergy(double sent, boolean simulate) {
	double energy = getEnergyStored() * 100D;
	double energyExtracted = Math.min(energy, sent * 100D);

	if (!simulate && handler != null) {
		int newEnergy = (int) (energy + energyExtracted);
		energy = newEnergy / 100D;
		handler.setCurrent(energy);
		updateVoltage(simulate);
	}
	energyExtracted /= 100D;
	return energyExtracted;
}

@Override
public int getFuelLastTime(ItemStack stack) {
	return 0;
}

@Override
public double getEnergyStored() {
	if (handler != null)
		return handler.getCurrent();
	return 0;
}

@Override
public double getMaxCurrent() {
	return handler.getMaxCurrent();
}

@Override
public double getVoltageStored() {
	return handler.getVoltage();
}

@Override
public double getMaxVoltage() {
	return handler.getMaxVoltage();
}

@Override
public double getActualMaxCurrent() {
	return getMaxEnergyStored() * ConfigHandler.energyMultiplier;
}

@Override
public double getActualMaxVoltage() {
	return getMaxVoltage() * ConfigHandler.energyMultiplier;
}

@Override
public void setEnergyStored(double amount) {
	handler.setCurrent(amount);
	updateVoltage(false);
	markDirty();
}

@Override
public double getResistance() {
	return 10;
}

@Override
public double getMaxEnergyStored() {
	return handler.getMaxCurrent();
}

@Override
public void applyCurrentUpgrades() {}

protected void setEnergyHandlerFromLoad(NBTTagCompound tag) {
	handler = new EnergyHandler(tag.getDouble("baseMaxCurrent"), tag.getDouble("baseMaxVoltage"));
	handler.setCurrent(tag.getDouble("current"));
	updateVoltage(false);
}

}

 

 

New Updated Block Class

 

package com.anime.wirelessrevolution.blocks.generators;

import com.anime.wirelessrevolution.tileentity.energy.gen.TileEntitySolarGenerator;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class SolarGenerator extends Block {

public SolarGenerator() {
	super(Material.iron);
	this.isBlockContainer = true;
	this.setHarvestLevel("pickaxe", 0);
}

@Override
public TileEntity createTileEntity(World world, int p_149915_2_) {
	if (!world.isRemote)
		System.out.println("Creating a new instance and world is not remote.");
	return new TileEntitySolarGenerator();
}

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

}

 

 

edit I added this.isBlockContainer = true after testing without it.

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

Aright thank you that kinda irritated me, but my mistake. It worked when I went back to implementing ITileEntityProvider BTW. It seems it is required to even have a TileEntity in 1.7, not sure about other versions, but good catch and Thank you again. Oh and adding this.isBlockContainer = true did not crash me.

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.

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



×
×
  • Create New...

Important Information

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