Rendering is working, tile base is broken, also registry not working?

This commit is contained in:
KitsuShadow
2015-08-15 02:43:03 -04:00
parent e961b16b0e
commit cf52b3c950
13 changed files with 261 additions and 15 deletions

View File

@@ -3,6 +3,9 @@ package nmd.primal.energy;
import nmd.primal.energy.common.CommonProxy;
import nmd.primal.energy.common.ModInfo;
import nmd.primal.energy.crafting.CraftingHandler;
import nmd.primal.energy.render.RenderID;
import nmd.primal.energy.render.RenderRegistry;
import nmd.primal.energy.tileents.TileRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
@@ -26,6 +29,9 @@ public class Energy {
Energy.proxy.preInit(event);
// some example code
// System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
TileRegistry.init();
RenderID.init();
RenderRegistry.init();
}
@EventHandler

View File

@@ -0,0 +1,43 @@
package nmd.primal.energy.block;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import nmd.primal.energy.common.ModInfo;
import nmd.primal.energy.render.RenderID;
import nmd.primal.energy.tileents.TileEntCrank;
import nmd.primal.energy.util.CustomTab;
public class CrankBlock extends Block implements ITileEntityProvider{
protected CrankBlock(String unlocalizedName, Material mat) {
super(mat);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(ModInfo.MOD_ID + ":" + unlocalizedName);
this.setCreativeTab(CustomTab.NMDEnergyTab);
this.setHardness(1.0F);
this.setResistance(6.0F);
this.setStepSound(soundTypeStone);
}
@Override
public TileEntity createNewTileEntity(World world, int i) {
return new TileEntCrank("tileEntCrack");
}
@Override
public int getRenderType() {
return RenderID.crankID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@@ -7,13 +7,13 @@ import cpw.mods.fml.common.registry.GameRegistry;
public class ModBlocks {
public static Block SMBBlock;
public static Block crankBlock;
public static final void init() {
GameRegistry.registerBlock(SMBBlock = new SMBBlock("SMBBlock", Material.iron), "SMBBlock");
GameRegistry.registerBlock(crankBlock = new CrankBlock("CrankBlock", Material.wood), "CrankBlock");
//GameRegistry.registerBlock(mineralBlock = new MineralBlock("mineralBlock", Material.rock), "mineralBlock");
}
}

View File

@@ -3,6 +3,8 @@ package nmd.primal.energy.common;
import nmd.primal.energy.block.ModBlocks;
import nmd.primal.energy.crafting.ModCrafting;
import nmd.primal.energy.item.ModItems;
import nmd.primal.energy.render.RenderID;
import nmd.primal.energy.render.RenderRegistry;
import nmd.primal.energy.tileents.TileRegistry;
import nmd.primal.energy.util.CustomTab;
import cpw.mods.fml.common.event.FMLInitializationEvent;
@@ -17,6 +19,7 @@ public class CommonProxy {
ModItems.registerItems();
ModBlocks.init();
ModCrafting.init();
}
public void init(FMLInitializationEvent event)
@@ -26,7 +29,7 @@ public class CommonProxy {
public void postInit(FMLPostInitializationEvent event)
{
RenderRegistry.init();
}

View File

@@ -0,0 +1,14 @@
package nmd.primal.energy.render;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class RenderID {
public static int crankID;
public static void init(){
crankID = RenderingRegistry.getNextAvailableRenderId();
}
}

View File

@@ -0,0 +1,14 @@
package nmd.primal.energy.render;
import cpw.mods.fml.client.registry.ClientRegistry;
import nmd.primal.energy.render.block.RenderCrank;
import nmd.primal.energy.tileents.TileEntCrank;
public class RenderRegistry {
public static final void init() {
//MinecraftForgeClient.registerItemRenderer(ModItems.woodenShield, new ItemRenderWoodenShield());
//MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.emptySoftCrucible), new ItemRendererSECrucible());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntCrank.class, new RenderCrank());
}
}

View File

@@ -0,0 +1,48 @@
package nmd.primal.energy.render.block;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import nmd.primal.energy.block.ModBlocks;
import nmd.primal.energy.tileents.TileEntCrank;
public class RenderCrank extends TileEntitySpecialRenderer {
public static final ResourceLocation MODEL = new ResourceLocation("energy:models/Crank.obj");
public static final ResourceLocation TEXTURE = new ResourceLocation("energy:models/Crank.png");
private IModelCustom model = AdvancedModelLoader.loadModel(MODEL);
@Override
public void renderTileEntityAt(TileEntity tileEnt, double x, double y, double z, float scale) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
TileEntCrank tile = (TileEntCrank) tileEnt;
renderBlock(tile, tileEnt.getWorldObj(), tileEnt.xCoord,tileEnt.yCoord, tileEnt.zCoord, ModBlocks.crankBlock);
GL11.glPopMatrix();
}
public void renderBlock(TileEntCrank tl, World world, int i, int j,int k, Block block) {
GL11.glPushMatrix();
float scale = 0.75F;
GL11.glScalef(scale, 0.75f, scale);
GL11.glTranslatef(0.65F, 0.48F, 0.65F);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
this.model.renderAll();
GL11.glPopMatrix();
}
}

View File

@@ -7,9 +7,10 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class TileBase extends TileEntity{
public abstract class TileBase extends TileEntity{
private String specName;
private NBTTagCompound nbt = new NBTTagCompound();
public TileBase(String name){
specName = name;
@@ -30,21 +31,21 @@ public class TileBase extends TileEntity{
if (worldObj.isRemote) return;
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
if (tagCompound.hasKey("CustomName", 8)) {
specName = tagCompound.getString("CustomName");
/*@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
if (nbt.hasKey("CustomName", 8)) {
specName = nbt.getString("CustomName");
}
}
@Override
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
}
}*/
@Override
/*@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
@@ -55,6 +56,6 @@ public class TileBase extends TileEntity{
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.func_148857_g());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}*/
}

View File

@@ -0,0 +1,13 @@
package nmd.primal.energy.tileents;
import net.minecraft.tileentity.TileEntity;
public class TileEntCrank extends TileBase {
public TileEntCrank(String name) {
super(name);
}
}

View File

@@ -6,6 +6,6 @@ public class TileRegistry {
public static final void init() {
//GameRegistry.registerTileEntity(TileEntityTestForge.class, "TestForge");
GameRegistry.registerTileEntity(TileEntCrank.class, "TileEntCrank");
}
}

View File

@@ -0,0 +1,104 @@
# Blender v2.69 (sub 0) OBJ File: 'Crank.blend'
# www.blender.org
mtllib Crank.mtl
o Cube
v 0.100000 0.264795 -0.100000
v 0.100000 0.264795 0.100000
v -0.100000 0.264795 0.100000
v -0.100000 0.264795 -0.100000
v 0.100000 0.464795 -0.100000
v 0.100000 0.464795 0.100000
v -0.100000 0.464795 0.100000
v -0.100000 0.464795 -0.100000
v 0.100000 0.264795 -0.600000
v -0.100000 0.264795 -0.600000
v 0.100000 0.464795 -0.600000
v -0.100000 0.464795 -0.600000
v 0.100000 -0.485205 -0.100000
v 0.100000 -0.485205 0.100000
v -0.100000 -0.485205 0.100000
v -0.100000 -0.485205 -0.100000
vt 0.500580 0.555234
vt 0.446843 0.555234
vt 0.446843 0.337432
vt 0.776634 0.644650
vt 0.722897 0.644650
vt 0.776634 0.590913
vt 0.778006 0.501058
vt 0.831743 0.501058
vt 0.778006 0.554795
vt 0.607812 0.777694
vt 0.607812 0.831431
vt 0.554076 0.777694
vt 0.499924 0.556928
vt 0.499924 0.610665
vt 0.446187 0.610665
vt 0.724218 0.669231
vt 0.776419 0.669231
vt 0.776419 0.776629
vt 0.334729 0.778768
vt 0.388466 0.778768
vt 0.388466 0.832505
vt 0.443683 0.559544
vt 0.443683 0.609220
vt 0.334581 0.609220
vt 0.831853 0.498644
vt 0.779864 0.498644
vt 0.779864 0.390775
vt 0.444856 0.642828
vt 0.498592 0.642828
vt 0.444856 0.777170
vt 0.498796 0.778935
vt 0.498796 0.832671
vt 0.445059 0.832671
vt 0.554076 0.576181
vt 0.666923 0.777694
vt 0.613186 0.777694
vt 0.613186 0.576181
vt 0.776472 0.501058
vt 0.776472 0.554795
vt 0.612790 0.554795
vt 0.500580 0.337432
vt 0.554076 0.831431
vt 0.722897 0.590913
vt 0.498592 0.777170
vt 0.446187 0.556928
vt 0.724218 0.776629
vt 0.334729 0.832505
vt 0.334581 0.559544
vt 0.831853 0.390775
vt 0.445059 0.778935
vt 0.607812 0.576181
vt 0.666923 0.576181
vt 0.612790 0.501058
vt 0.831743 0.554795
usemtl Material
s off
f 3/1 4/2 16/3
f 5/4 8/5 6/6
f 1/7 5/8 2/9
f 2/10 6/11 3/12
f 3/13 7/14 8/15
f 8/16 5/17 11/18
f 11/19 9/20 10/21
f 4/22 8/23 12/24
f 5/25 1/26 9/27
f 1/28 4/29 9/30
f 13/31 14/32 15/33
f 2/10 3/12 15/34
f 4/35 1/36 13/37
f 1/38 2/39 14/40
f 15/41 3/1 16/3
f 6/11 7/42 3/12
f 8/5 7/43 6/6
f 4/29 10/44 9/30
f 4/45 3/13 8/15
f 12/46 8/16 11/18
f 12/47 11/19 10/21
f 10/48 4/22 12/24
f 11/49 5/25 9/27
f 16/50 13/31 15/33
f 14/51 2/10 15/34
f 16/52 4/35 13/37
f 13/53 1/38 14/40
f 5/8 6/54 2/9

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 868 B

After

Width:  |  Height:  |  Size: 862 B