attempting nbt rendering

This commit is contained in:
Mohammad-Ali Minaie
2017-02-02 21:40:27 -05:00
parent ec08e00c9e
commit ef02ef50eb
14 changed files with 205 additions and 1234 deletions

View File

@@ -19,4 +19,12 @@ To-Dos
- [x] Model
- [x] Item(s)
- [ ] Functionality
- [ ] Item NBT
- [ ] Modify Model via NBT
- [ ] Remove hot things from bloomery / firebox and place in world or anvil to cool
- [ ] Anvil
- [ ] Anvil Recipe Handler
- [ ] Update Forge Version 11.2

View File

@@ -5,10 +5,10 @@ org.gradle.jvmargs=-Xmx3G
mod_group=nmd.primal.forgecraft
mod_name=ForgeCraft
mod_version=1.0.7
forge_version=13.19.1.2189
mcp_mappings=snapshot_20161130
mc_version=1.11
mod_version=1.0.8
forge_version=13.20.0.2226
mcp_mappings=snapshot_20170121
mc_version=1.11.2
primal_version=0.2.11
jei_version=4.0+

View File

@@ -34,11 +34,14 @@ public class ForgeCraft
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
ModItems.init();
ModBlocks.init();
ModItems.register();
ModBlocks.register();
ModTiles.registerTileEntities();
// ModItems.registerRenders();
proxy.preInit();
}
@EventHandler
@@ -47,6 +50,7 @@ public class ForgeCraft
//this.proxy.init(event);
proxy.init();
ModCrafting.register();
//proxy.registerModelBakeryVariants();
}
@EventHandler

View File

@@ -0,0 +1,38 @@
package nmd.primal.forgecraft.handler;
import net.minecraft.util.IStringSerializable;
/**
* Created by mminaie on 2/1/17.
*/
public class EnumHandler {
public static enum TongTypes implements IStringSerializable {
DEFAULT("default", 0),
EMPTYHOT("emptyhot", 1);
private int ID;
private String name;
private TongTypes(String name, int ID) {
this.ID = ID;
this.name = name;
}
@Override
public String getName() {
return this.name;
}
public int getID() {
return ID;
}
@Override
public String toString() {
return getName();
}
}
}

View File

@@ -1,12 +1,17 @@
package nmd.primal.forgecraft.init;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.handler.EnumHandler;
import nmd.primal.forgecraft.items.ItemBellowsHandle;
import nmd.primal.forgecraft.items.ItemSoftCrucible;
import nmd.primal.forgecraft.items.ItemStoneTongs;
@@ -20,49 +25,60 @@ public class ModItems {
public static Item test;
public static Item softcrucible;
public static Item stonetongs;
//public static ModelResourceLocation modelLocation = new ModelResourceLocation("stonetongs", "inventory");
/*
@Override
public void preInit(FMLPreInitializationEvent event) {
OBJLoader.INSTANCE.addDomain(TutorialMod.MODID);
registerModel(ModItems.tutorialItem);
}
public void registerModel(Item item) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(TutorialMod.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
*/
//public static Item stonetongsemptyhot;
//public static Item stonetongsfilledhot;
//public static Item
public static void init() {
OBJLoader.INSTANCE.addDomain(ModInfo.MOD_ID);
pistonbellows = new ItemBellowsHandle();
softcrucible = new ItemSoftCrucible();
stonetongs = new ItemStoneTongs();
//test = new ItemTest();
stonetongs = new ItemStoneTongs("stonetongs");
}
public static void register() {
GameRegistry.register(pistonbellows);
GameRegistry.register(softcrucible);
GameRegistry.register(stonetongs);
//GameRegistry.register(test);
}
public static void registerRenders() {
registerRender(pistonbellows);
registerRender(softcrucible);
registerRender(stonetongs);
//Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(stonetongs, 0, new ModelResourceLocation("stonetongs", "inventory"););
//ModelLoader.setCustomModelResourceLocation(stonetongs, 0, new ModelResourceLocation(ModInfo.MOD_ID + ":" + stonetongs + ".obj", "inventory"));
//registerRender(test);
}
public static void registerCustomRenders(){
ModelBakery.registerItemVariants(ModItems.stonetongs, ModItems.stonetongs.getRegistryName(), new ResourceLocation(ModInfo.MOD_ID, "stonetongs"));
ModelLoader.setCustomMeshDefinition(ModItems.stonetongs, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
if (stack.hasTagCompound()) {
//if (stack.getTagCompound().getInteger("type")) {
if (stack.getTagCompound().getInteger("type") == 0 ){
return new ModelResourceLocation(stack.getItem().getRegistryName() + "_default");
} else {
return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory");
}
}
return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory");
}
});
}
private static void registerRender(Item item) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
/*public static void registerRender(Item item, int meta, String fileName) {
ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(new ResourceLocation(fileName), "inventory"));
}
public static void registerRender(Item item, int meta, String fileName) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, new ModelResourceLocation(fileName, "inventory"));
}*/
}

View File

@@ -1,32 +1,77 @@
package nmd.primal.forgecraft.items;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.StatList;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.tiles.TileBloomery;
import nmd.primal.forgecraft.handler.EnumHandler.TongTypes;
import java.util.List;
/**
* Created by mminaie on 1/23/17.
*/
public class ItemStoneTongs extends BaseItem {
public class ItemStoneTongs extends Item {
public ItemStoneTongs() {
setUnlocalizedName(ModInfo.ForgecraftItems.STONETONGS.getUnlocalizedName());
//setRegistryName();
setRegistryName(new ResourceLocation(ModInfo.MOD_ID, ModInfo.ForgecraftItems.STONETONGS.getRegistryName()));
setMaxDamage(100);
setNoRepair();
setMaxStackSize(1);
public ItemStoneTongs(String unlocalizedName) {
setUnlocalizedName(unlocalizedName);
this.setRegistryName(unlocalizedName);
//this.setMaxDamage(0);
//this.setHasSubtypes(true); //This just says the item has metadata
this.setMaxStackSize(1);
this.setCreativeTab(ModInfo.TAB_FORGECRAFT);
}
public void onUpdate(ItemStack item, World world, Entity player, int itemSlot, boolean isSelected) {
if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound());
//this.setDamage(item, 1000);
item.getTagCompound().setInteger("type", 0);
//item.getTagCompound().setBoolean("active", false);
}
}
/* //For Subtypes
@Override
public String getUnlocalizedName(ItemStack stack) {
for(int i = 0; i < TongTypes.values().length; i++) {
if(stack.getItemDamage() == i) {
return this.getUnlocalizedName() + "." + TongTypes.values()[i].getName();
}
else {
continue;
}
}
return this.getUnlocalizedName() + "." + TongTypes.DEFAULT.getName();
}
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> items) {
for(int i = 0; i < TongTypes.values().length; i++) {
items.add(new ItemStack(item, 1, i));
}
}
*/
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
//pos = pos.offset(facing);
@@ -35,7 +80,7 @@ public class ItemStoneTongs extends BaseItem {
if (world.getBlockState(pos).getBlock() == ModBlocks.bloomery) {
TileBloomery tile = (TileBloomery) world.getTileEntity(pos);
System.out.println(tile.getSlotStack(1));
itemstack.damageItem(1, player);
//itemstack.damageItem(1, player);
return EnumActionResult.SUCCESS;
} else return EnumActionResult.FAIL;
}

View File

@@ -1,7 +1,13 @@
package nmd.primal.forgecraft.proxy;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import nmd.primal.forgecraft.ModInfo;
@@ -19,12 +25,18 @@ import nmd.primal.forgecraft.tiles.TilePistonBellows;
*/
public class ClientProxy implements CommonProxy {
@Override
public void preInit(){
ModItems.registerCustomRenders();
}
@Override
public void init() {
//OBJLoader.INSTANCE.addDomain(ModInfo.MOD_ID);
//Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.stonetongs, 0, new ModelResourceLocation("stonetongs", "inventory"));
ModItems.registerRenders();
ModBlocks.registerRenders();
//this.registerModelBakeryStuff();
this.registerTileRendering();
}
@@ -36,5 +48,10 @@ public class ClientProxy implements CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileBloomery.class, new TileBloomeryRender());
}
@Override
public void registerModelBakeryVariants(){
//ModelBakery.registerItemVariants(ModItems.stonetongs, new ResourceLocation(ModInfo.MOD_ID, "stonetongs_default"),
// new ResourceLocation(ModInfo.MOD_ID, "stonetongs_emptyhot"));
}
}

View File

@@ -5,6 +5,10 @@ package nmd.primal.forgecraft.proxy;
*/
public interface CommonProxy {
public void preInit();
public void init();
public void registerModelBakeryVariants();
}

View File

@@ -5,8 +5,17 @@ package nmd.primal.forgecraft.proxy;
*/
public class ServerProxy implements CommonProxy {
@Override
public void init() {
public void preInit() {
}
public void init(){
}
public void registerModelBakeryVariants(){
}
}

View File

@@ -1,7 +1,8 @@
{
"forge_marker": 1,
"defaults": {
"model": "forgecraft:stonetongs.obj"
//"model": "forgecraft:stonetongs.obj"
"model": "forgecraft:item/stonetongs"
},
"variants": {
"inventory": [
@@ -41,3 +42,6 @@
]
}
}

View File

@@ -0,0 +1,9 @@
{
"forge_marker":1,
"textures": {
"particle": "blocks/planks_oak",
"texture": "blocks/planks_oak",
"texture1": "forgecraft:blocks/stone_slab"
},
"parent": "forgecraft:item/stonetongs"
}

View File

@@ -1,9 +1,9 @@
{
"__comment": "Designed by Kitsushadow with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "blocks/e_particle",
"texture": "blocks/checker_test",
"texture1": "blocks/stone_slab"
"particle": "blocks/planks_oak",
"texture": "blocks/planks_oak",
"texture1": "forgecraft:blocks/stone_slab"
},
"elements": [
{
@@ -65,10 +65,10 @@
"from": [ 6.5, 0, 7.5 ],
"to": [ 7.5, 1, 16 ],
"faces": {
"down": { "uv": [ 6, 0.5, 7, 9 ], "texture": "#texture" },
"up": { "uv": [ 6, 2.5, 7, 11 ], "texture": "#texture" },
"north": { "uv": [ 9, 15, 10, 16 ], "texture": "#texture" },
"south": { "uv": [ 7, 15, 8, 16 ], "texture": "#texture" },
"down": { "uv": [ 6.5, 0, 7.5, 8.5 ], "texture": "#texture" },
"up": { "uv": [ 6.5, 7.5, 7.5, 16 ], "texture": "#texture" },
"north": { "uv": [ 8.5, 15, 9.5, 16 ], "texture": "#texture" },
"south": { "uv": [ 6.5, 15, 7.5, 16 ], "texture": "#texture" },
"west": { "uv": [ 7.5, 15, 16, 16 ], "texture": "#texture" },
"east": { "uv": [ 0, 15, 8.5, 16 ], "texture": "#texture" }
}
@@ -78,10 +78,10 @@
"from": [ 8.5, 0, 7.5 ],
"to": [ 9.5, 1, 16 ],
"faces": {
"down": { "uv": [ 8, 0.5, 9, 9 ], "texture": "#texture" },
"up": { "uv": [ 8, 6.5, 9, 15 ], "texture": "#texture" },
"north": { "uv": [ 7, 15, 8, 16 ], "texture": "#texture" },
"south": { "uv": [ 9, 15, 10, 16 ], "texture": "#texture" },
"down": { "uv": [ 8.5, 0, 9.5, 8.5 ], "texture": "#texture" },
"up": { "uv": [ 8.5, 7.5, 9.5, 16 ], "texture": "#texture" },
"north": { "uv": [ 6.5, 15, 7.5, 16 ], "texture": "#texture" },
"south": { "uv": [ 8.5, 15, 9.5, 16 ], "texture": "#texture" },
"west": { "uv": [ 7.5, 15, 16, 16 ], "texture": "#texture" },
"east": { "uv": [ 0, 15, 8.5, 16 ], "texture": "#texture" }
}

View File

@@ -1,8 +0,0 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Material__65
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
d 1.000000
map_Kd forgecraft:items/stonetongs