I tried that and it still doesn't show. I just have no idea anymore. I have been on this ever since 1.4.4.
That solution wasn't the complete picture. I've been meaning to come back here and repost a more detailed explanation. Basically my tests changing that number made it so that the render didn't disappear right away... but, ultimately it wasn't the proper fix to the problem. I'm not really all that qualified to help with your problem, as I'm just learning this stuff myself, but I did finally get it all working exactly how it should... so I'll post all my code here for you to browse through. I've spend the time to strip away everything from my mod that wasn't TNT related to save you wading through extraneous info... so forgive me if I've left some impertinent remnants behind.
You should also know that I wanted to be able to customize the Fuse Length, the Blast Radius, and the Drop Rate of my TNT, so I have a config in there too. The Explosion Handler was necessary to alter and control the Explosion.class for control of the Drop Rate. If you don't care about Drop Rate, I'm sure you can remove TNTBoxExplosion and TNTBoxExplosionHandler... and patch up the errors doing so left behind by pointing your stuff to vanilla Explosion.java.
My TNT is called "TNTBox".
ModRegistry:
package khufu.pack;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
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.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "khufu", name = "Khufu TNT", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class ModRegistry {
@Instance("khufu")
public static ModRegistry instance;
@SidedProxy(clientSide = "khufu.pack.client.ClientProxy", serverSide = "khufu.pack.CommonProxy")
public static CommonProxy proxy;
public static String configDir;
public static float tntBoxExplodeSize;
public static float tntBoxDropChance;
public static int tntBoxFuse;
public static Block tntbox;
public static int tntboxID;
@SuppressWarnings("static-access")
@PreInit
public void preInit(FMLPreInitializationEvent event) {
configDir = event.getModConfigurationDirectory().getAbsolutePath();
// Config
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
config.load();
tntboxID = config.get(config.CATEGORY_BLOCK, "TNT Box ID", 794).getInt(794);
tntBoxExplodeSize = config.get(config.CATEGORY_GENERAL, "TNT Box Explosion Size", 12).getInt();
tntBoxDropChance = config.get(config.CATEGORY_GENERAL, "TNT Box Drop Chance", 100).getInt();
tntBoxFuse = config.get(config.CATEGORY_GENERAL, "TNT Box Fuse", 80).getInt();
config.save();
}
@Init
public void load(FMLInitializationEvent event) {
proxy.registerRenderInformation();
EntityRegistry.registerGlobalEntityID(EntityTNTBoxPrimed.class, "entitytntbox", EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerModEntity(EntityTNTBoxPrimed.class, "entitytntbox", 0, this, 16, 1, false);
tntbox = new BlockTNTBox(tntboxID, 0).setBlockName("tntbox").setCreativeTab(CreativeTabs.tabRedstone);
GameRegistry.registerBlock(tntbox);
LanguageRegistry.addName(tntbox, "Box of TNT");
}
@PostInit
public void postInit(FMLPostInitializationEvent event) {
}
}
CommonProxy:
package khufu.pack;
public class CommonProxy {
public static String TNTBOX_PNG = "/khufu/pack/img/tntbox.png";
public void registerRenderers () {
}
public void registerEntites() {
}
public void registerRenderInformation() {
}
}
BlockTNTBox:
package khufu.pack;
import java.util.Random;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityArrow;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Explosion;
import net.minecraft.src.Item;
import net.minecraft.src.Material;
import net.minecraft.src.World;
public class BlockTNTBox extends Block
{
public BlockTNTBox(int par1, int par2)
{
super(par1, par2, Material.tnt);
this.setCreativeTab(CreativeTabs.tabRedstone);
}
/**
* Returns the block texture based on the side being looked at. Args: side
*/
public int getBlockTextureFromSide(int par1)
{
return par1 == 0 ? this.blockIndexInTexture + 2 : (par1 == 1 ? this.blockIndexInTexture + 1 : this.blockIndexInTexture);
}
/**t
* Called whenever the block is added into the world. Args: world, x, y, z
*/
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
super.onBlockAdded(par1World, par2, par3, par4);
if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
}
/**
* Gets if we can place a torch on a block.
*/
private boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
{
if (par1World.doesBlockHaveSolidTopSurface(par2, par3, par4))
{
return true;
}
else
{
int var5 = par1World.getBlockId(par2, par3, par4);
return (Block.blocksList[var5] != null && Block.blocksList[var5].canPlaceTorchOnTop(par1World, par2, par3, par4));
}
}
/**
* Called upon the block being destroyed by an explosion
*/
public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4)
{
if (!par1World.isRemote)
{
EntityTNTBoxPrimed var5 = new EntityTNTBoxPrimed(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F));
var5.fuse = par1World.rand.nextInt(var5.fuse / 4) + var5.fuse / 8;
par1World.spawnEntityInWorld(var5);
}
}
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (par5 > 0 && Block.blocksList[par5].canProvidePower() && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
this.explode(par1World, par2, par3, par4, 1);
}
}
public void explode(World par1World, int par2, int par3, int par4, int par5){
EntityTNTBoxPrimed var5 = new EntityTNTBoxPrimed(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F));
par1World.spawnEntityInWorld(var5);
par1World.setBlockWithNotify(par2, par3, par4, 0);
par1World.playSoundAtEntity(var5, "random.fuse", 1.0F, 1.0F);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random)
{
return 1;
}
/**
* Called right before the block is destroyed by a player. Args: world, x, y, z, metaData
*/
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
{
}
/**
* Called upon block activation (right click on the block.)
*/
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
if (par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.shiftedIndex)
{
this.explode(par1World, par2, par3, par4, 1);
return true;
}
else
{
return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
}
}
/**
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
*/
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
if (par5Entity instanceof EntityArrow && !par1World.isRemote)
{
EntityArrow var6 = (EntityArrow)par5Entity;
if (var6.isBurning())
{
this.explode(par1World, par2, par3, par4, 1);
}
}
}
public boolean func_85103_a(Explosion par1Explosion)
{
return false;
}
public String getTextureFile() {
return CommonProxy.TNTBOX_PNG;
}
}
EntityTNTBoxPrimed:
package khufu.pack;
import net.minecraft.src.Entity;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
public class EntityTNTBoxPrimed extends Entity
{
/** How long the fuse is */
public int fuse;
private TNTBoxExplosionHandler expHandTNT;
public EntityTNTBoxPrimed(World par1World)
{
super(par1World);
this.fuse = 0;
this.preventEntitySpawning = true;
this.setSize(0.98F, 0.98F);
this.yOffset = this.height / 2.0F;
}
public EntityTNTBoxPrimed(World par1World, double par2, double par4, double par6)
{
this(par1World);
this.setPosition(par2, par4, par6);
float var8 = (float)(Math.random() * Math.PI * 2.0D);
this.motionX = (double)(-((float)Math.sin((double)var8)) * 0.02F);
this.motionY = 0.20000000298023224D;
this.motionZ = (double)(-((float)Math.cos((double)var8)) * 0.02F);
this.fuse = ModRegistry.tntBoxFuse;
this.prevPosX = par2;
this.prevPosY = par4;
this.prevPosZ = par6;
expHandTNT = new TNTBoxExplosionHandler();
}
protected void entityInit() {}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
* prevent them from trampling crops
*/
protected boolean canTriggerWalking()
{
return false;
}
/**
* Returns true if other Entities should be prevented from moving through this Entity.
*/
public boolean canBeCollidedWith()
{
return !this.isDead;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.motionY -= 0.03999999910593033D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.9800000190734863D;
this.motionY *= 0.9800000190734863D;
this.motionZ *= 0.9800000190734863D;
if (this.onGround)
{
this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D;
this.motionY *= -0.5D;
}
if (this.fuse-- <= 0)
{
this.setDead();
if (!this.worldObj.isRemote)
{
this.explode();
}
}
else
{
this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
}
}
private void explode()
{
float var1 = ModRegistry.tntBoxExplodeSize;
this.expHandTNT.createExplosion(this.worldObj, (Entity)null, this.posX, this.posY, this.posZ, var1, true, 1F);
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setByte("Fuse", (byte)this.fuse);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
this.fuse = par1NBTTagCompound.getByte("Fuse");
}
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 0.0F;
}
}
Hey, I've been trying to read over your code posted about but there appears to be some formatting errors in commonproxy and blocktntbox, just thought I'd give you a heads up
Wait. Did you use mod loader for this mod? And also I am updating my mod after leaving it on 1.2.5 for a while, so what is common proxy?Also my mod only uses mod loader and not forge.
Wait. Did you use mod loader for this mod? And also I am updating my mod after leaving it on 1.2.5 for a while, so what is common proxy?
Also my mod only uses mod loader and not forge.
Typically mods that want to be SMP and SSP are going to have a CommonProxy and a ClientProxy. Additionally, you'll often see the package structure made by the author split up into two distinct sections; the common branch (which is server and client side) and the client branch (which is only client sided code). Examples of this are as follows:
Client:
- Rendering for mobs, tileentities, items, blocks, etc. because think about it, does the server really need to render it? If the server renders something, the Client doesn't actually see it. The client needs to render it to display it to the player.
Server:
- Mob AI, TileEntity logic, basically everything else. You want the vast majority of things to be done primarily on server side.
Now in implementation, you'll see the client doing things and the server doing the same things. So say you open up a custom TileEntity that is a container, such as a chest. You (the client) put an item into the chest. You see it happen and everything, but then all the sudden, moments later, it jumps back into your cursor. This is an example of the client trying to do something it thinks it can, while the server says no, you can't do that.
This happens because the coding structure for minecraft handles this kind of methodology:
To reduce lag between clients and the server, the code is executed client side while the information is being sent to the server in packets to be processed and returned to the client. If the client for some reason manages to do something the server doesn't allow, you'll see the action carried out, but then reset after the response gets back from the server and says that is not possible.
It's a bit of a fuzzy line, and was quite a new thing to get used to after the integrated server started existing. It caused problems because you can't just simply call world.spawnEntity(..) anymore. Since there are two instances of world running at all times, the spawnEntity method would be done on both the server and the client, resulting in one real entity in the game, and a second one ghosting around like it doesn't exist.
ANYWAYS (/endrant) CommonProxy and ClientProxy was basically the result of the brilliant Forge maintainers' answer to this. They developed a system that introduced SidedProxy. SidedProxy allows us modders to choose which side (client/server) to execute code on so that it's not run twice. It's quite fantastic really. But its hard to grasp at first.
Well i don't make my mod for servers, so is that what common proxy is for.
I am a complete beginner with coding. I actually made a mod knowing nothing.
Hey guys, I know it has been a while but since the minecraft update of 1.5.1, in CommonProxy this line
public static String TNTx5 = "/mods/toomuchtnt/textures/blocks/TNTx5.png"; I don't think works any more. Does anyone know how to fix this in the new update? Thanks
Oh and also when I do it the tnt renders but its not my custom texture, instead it is Black
Fixed the problem, Just follow everything in the post above but in the common proxy change this line
publicstatic String "name" = "/mods/toomuchtnt/textures/blocks/TNTx5.png";
to publicstatic String "name" = "/terrain.png";
That fixed the problem for me
That solution wasn't the complete picture. I've been meaning to come back here and repost a more detailed explanation. Basically my tests changing that number made it so that the render didn't disappear right away... but, ultimately it wasn't the proper fix to the problem. I'm not really all that qualified to help with your problem, as I'm just learning this stuff myself, but I did finally get it all working exactly how it should... so I'll post all my code here for you to browse through. I've spend the time to strip away everything from my mod that wasn't TNT related to save you wading through extraneous info... so forgive me if I've left some impertinent remnants behind.
You should also know that I wanted to be able to customize the Fuse Length, the Blast Radius, and the Drop Rate of my TNT, so I have a config in there too. The Explosion Handler was necessary to alter and control the Explosion.class for control of the Drop Rate. If you don't care about Drop Rate, I'm sure you can remove TNTBoxExplosion and TNTBoxExplosionHandler... and patch up the errors doing so left behind by pointing your stuff to vanilla Explosion.java.
My TNT is called "TNTBox".
ModRegistry:
CommonProxy:
BlockTNTBox:
EntityTNTBoxPrimed:
TNTBoxExplosionHandler:
TNTBoxExplosion:
ClientProxy:
RenderTNTBoxPrimed:
Fixed. Thanks!
I used Forge. You've got some catching up to do if you don't about Common Proxy. I'm not the guy to explain it to ya, unfortunately. Ask around.
Typically mods that want to be SMP and SSP are going to have a CommonProxy and a ClientProxy. Additionally, you'll often see the package structure made by the author split up into two distinct sections; the common branch (which is server and client side) and the client branch (which is only client sided code). Examples of this are as follows:
Client:
- Rendering for mobs, tileentities, items, blocks, etc. because think about it, does the server really need to render it? If the server renders something, the Client doesn't actually see it. The client needs to render it to display it to the player.
Server:
- Mob AI, TileEntity logic, basically everything else. You want the vast majority of things to be done primarily on server side.
Now in implementation, you'll see the client doing things and the server doing the same things. So say you open up a custom TileEntity that is a container, such as a chest. You (the client) put an item into the chest. You see it happen and everything, but then all the sudden, moments later, it jumps back into your cursor. This is an example of the client trying to do something it thinks it can, while the server says no, you can't do that.
This happens because the coding structure for minecraft handles this kind of methodology:
To reduce lag between clients and the server, the code is executed client side while the information is being sent to the server in packets to be processed and returned to the client. If the client for some reason manages to do something the server doesn't allow, you'll see the action carried out, but then reset after the response gets back from the server and says that is not possible.
It's a bit of a fuzzy line, and was quite a new thing to get used to after the integrated server started existing. It caused problems because you can't just simply call world.spawnEntity(..) anymore. Since there are two instances of world running at all times, the spawnEntity method would be done on both the server and the client, resulting in one real entity in the game, and a second one ghosting around like it doesn't exist.
ANYWAYS (/endrant) CommonProxy and ClientProxy was basically the result of the brilliant Forge maintainers' answer to this. They developed a system that introduced SidedProxy. SidedProxy allows us modders to choose which side (client/server) to execute code on so that it's not run twice. It's quite fantastic really. But its hard to grasp at first.
I am a complete beginner with coding. I actually made a mod knowing nothing.
Is the fact I don't use forge making the rendering not load?
Probably... if you're going by my code, and since my code is for Forge.
public static String TNTx5 = "/mods/toomuchtnt/textures/blocks/TNTx5.png";
I don't think works any more. Does anyone know how to fix this in the new update?
Thanks
Oh and also when I do it the tnt renders but its not my custom texture, instead it is Black
public static String "name" = "/mods/toomuchtnt/textures/blocks/TNTx5.png";
to
public static String "name" = "/terrain.png";
That fixed the problem for me
I has the same problem as well but I was able to get it to show when it was lit but it was only a white box
Create your own thread instead of reviving a 3 year old thread that may be irrelevant.
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
thanks!