Edit (11/23/2012): I fixed the texture issue, but i'm still having the placement issue.
The issue i'm having is that if I have a half block in one spot, and i try to place another on the area above it (not in the 'double slab' area', but a full block above) the block places a square below where it is
Here's the screenshot so that you know what i am talking about. the blocks on the right are the vinilla minecraft ones, and show what SHOULD be happening, while the ones on the left are obviously mine:
Anyway, here's my code:
This is the 'Ore class file', I AM still learning java and minecraft scripting, so i'm not entirely sure WHY it is needed (because none of the tutorials i've read, and i have read a lot, have bothered to go into detail about why it has to be here). Anyway, i know that it's probably wrong, but again, i'm not sure. Anyway, here it is:
package mod_tgplanks;
import net.minecraft.src.Block;
import net.minecraft.src.ItemBlock;
import net.minecraft.src.ItemStack;
public class PlanksOre extends ItemBlock{
public PlanksOre(int ID, Block block){
super(ID);
setHasSubtypes(true);
}
public String getItemNameIS(ItemStack is){
String name = "";
switch(is.getItemDamage()){
case 0: {name= "one"; break;}
case 1: {name= "two"; break;}
case 2: {name= "three"; break;}
case 3: {name= "four"; break;}
case 4: {name= "five"; break;}
case 5: {name= "six"; break;}
case 6: {name= "seven"; break;}
case 7: {name= "eight"; break;}
case 8: {name= "nine"; break;}
case 9: {name= "ten"; break;}
case 10: {name= "eleven"; break;}
case 11: {name= "twelve"; break;}
case 12: {name= "thirteen"; break;}
case 13: {name= "fourteen"; break;}
case 14: {name= "fifteen"; break;}
case 15: {name= "sixteen"; break;}}
return getItemName()+"."+name;
}
public int getMetadata(int meta){
return meta;
}
}
Second code, the main class, or the package class file, whatever you want to call it. I have no idea if this is where everything is acting up, it might be, it might not be. If you know, please tell me.
package mod_tgplanks;
import net.minecraft.src.Block;
import net.minecraft.src.FurnaceRecipes;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
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.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid="TGPlanks", name="TrinityGamer Planks basic", version="0.5.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class TGplanks {
//initialize HalfSlabs
public static Block PlanksSlabs;
//initialize Double Slabs
public static Block DPlanksSlabs;
//initialize Half slab and Double slab IDS
public int PlanksSlabsID;
public int DPlanksSlabsID;
@PreInit
public void PreLoad(FMLPreInitializationEvent event){
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
config.load();
//initialize Half slab IDS
PlanksSlabsID = config.getBlock(Configuration.CATEGORY_BLOCK, "PlanksSlabs1 ID", 1093).getInt();
//initialize Double Slab IDS
DPlanksSlabsID = config.getBlock(Configuration.CATEGORY_BLOCK, "DPlanksSlabs1 ID", 1113).getInt();
config.save();
}
@SidedProxy(clientSide = "mod_tgplanks.client.ClientProxyPlanks", serverSide = "mod_tgplanks.CommonProxyPlanks")
public static CommonProxyPlanks proxy;
@Init
public void load(FMLInitializationEvent event){
//declare mew Half Slabs
PlanksSlabs = new PlanksSlabs(PlanksSlabsID, false).setStepSound(Block.soundWoodFootstep).setHardness(3F).setResistance(1.0F).setBlockName("single");
//declare new Double Slabs
DPlanksSlabs = new PlanksSlabs(DPlanksSlabsID, true).setStepSound(Block.soundWoodFootstep).setHardness(3F).setResistance(1.0F).setBlockName("double");
//register PlankSlabs item IDs
Item.itemsList[PlanksSlabsID] = new PlanksOre(PlanksSlabsID-256, PlanksSlabs).setItemName("PlanksItem");
Item.itemsList[DPlanksSlabsID] = new PlanksOre(DPlanksSlabsID-256, DPlanksSlabs).setItemName("DPlanksItem");
//register game block names (planks)
LanguageRegistry.instance().addStringLocalization("tile.PlanksSlabs.one.name", "Dingy Pink Planks");
LanguageRegistry.instance().addStringLocalization("tile.PlanksSlabs.two.name", "Dingy Red Planks");
LanguageRegistry.instance().addStringLocalization("tile.PlanksSlabs.three.name", "Dingy Burnt Red Planks");
LanguageRegistry.instance().addStringLocalization("tile.PlanksSlabs.four.name", "Dingy Dark Red Planks");
LanguageRegistry.instance().addStringLocalization("tile.PlanksSlabs.five.name", "Dingy Peach Planks");
LanguageRegistry.instance().addStringLocalization("tile.PlanksSlabs.six.name", "Dingy Orange Planks");
LanguageRegistry.instance().addStringLocalization("tile.PlanksSlabs.seven.name", "Dingy Burny Orange Planks");
LanguageRegistry.instance().addStringLocalization("tile.PlanksSlabs.eight.name", "Dingy Orange-Brown Planks");
//register Texture
proxy.registerRenderThings();
}
I've been told that my Slab Class file SHOULD actually work right, but just in case the were wrong, here it is anyway:
package mod_tgplanks;
import java.util.List;
import java.util.Random;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.BlockHalfSlab;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.World;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
public class PlanksSlabs extends BlockHalfSlab{
public PlanksSlabs(int par1, boolean par2){
super(par1, par2, Material.wood);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setRequiresSelfNotify();
this.setLightOpacity(0);
}
//tells game what single slab drops on destruction
public int idDropped(int par1, Random par2Random, int par3)
{
return TGplanks.PlanksSlabs.blockID;
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving){
if(par1World.getBlockId(par2, par3 - 1, par4) == TGplanks.PlanksSlabs.blockID){
int metadata = par1World.getBlockMetadata(par2, par3, par4) & 7;
if(par1World.getBlockMetadata(par2, par3 - 1, par4) == metadata ){
par1World.setBlockWithNotify(par2, par3, par4, 0);
par1World.setBlockAndMetadataWithNotify(par2, par3 - 1, par4, TGplanks.DPlanksSlabs.blockID, metadata);
}
}
}
//makes the double slab drop 2 single slabs
protected ItemStack createStackedBlock(int par1){
return new ItemStack(TGplanks.PlanksSlabs.blockID, 2, par1 & 7);
}
public String getFullSlabName(int var1){
return null;
}
public int getBlockTextureFromSideAndMetadata(int side, int metadata) {
return 0 + (metadata & 7);
}
//gets texture file
public String getTextureFile()
{
return "/tgplanks.png";
}
@Override
public int damageDropped(int par2){
return par2;
}
@SideOnly(Side.CLIENT)
private static boolean isBlockSingleSlab(int par0){
return par0 == TGplanks.PlanksSlabs.blockID;
}
@SideOnly(Side.CLIENT)
public void getSubBlocks(int par1, CreativeTabs tab, List list){
if (par1 != TGplanks.PlanksSlabs.blockID){
for(int NumOfMets=0; NumOfMets<8; NumOfMets++){
list.add(new ItemStack(par1, 1, NumOfMets));
}
}
}
}
If you can help, please do. I've tried, and tried, and tried, and i've searched, but i just can't fix the stupid things T_T.