Getting ready to complete crafing, see comment in anvil class

This commit is contained in:
Mohammad-Ali Minaie
2017-03-05 22:22:28 -05:00
parent 240c1b9626
commit 282275fd66
12 changed files with 612 additions and 57 deletions

View File

@@ -5,9 +5,12 @@ To-Dos
- [x] Stone Anvil Inventory
- [x] Stone Anvil Tile
- [ ] Stone Anvil Crafting
- [ ] Stone Anvil Bounding Box
- [x] TESR Inventory Rendering for Anvil
- [ ] StoneTongs Iron Chunks
- [x] Iron Chunk Item Model
- [x] Anvil Item Model
- [x] StoneTongs Iron Chunks
- [ ] Hammer Crafting
- [ ] Iron Chunking
@@ -15,8 +18,8 @@ To-Dos
*** Backlog ***
- [ ] Anvil
- [ ] Anvil Recipe Handler
- [ ] Stone Anvil Bounding Box
- [ ] Casting Table
- [ ] Block

View File

@@ -17,6 +17,8 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.core.api.PrimalBlocks;
import nmd.primal.core.api.PrimalItems;
import nmd.primal.forgecraft.CommonUtils;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.init.ModItems;
@@ -28,9 +30,34 @@ import nmd.primal.forgecraft.tiles.TileForge;
*/
public class Anvil extends CustomContainerFacing {
double[] normalMin = {0.0625,0.25,0.4375,0.625,0.8125};
public double getNormalMin(Integer x) {
return normalMin[x];
}
double[] normalMax = {0.1875,0.375,0.5625,0.75,0.9375};
public double getNormalMax(Integer x) {
return normalMax[x];
}
double[] reverseMin = {0.8125,0.625,0.4375,0.25,0.0625};
public double getReverseMin(Integer x) {
return reverseMin[x];
}
double[] reverseMax = {0.9375,0.75,0.5625,0.375,0.1875};
public double getReverseMax(Integer x) {
return reverseMax[x];
}
public Anvil(Material material, String registryName, Float hardness) {
super(material);
setUnlocalizedName(ModInfo.ForgecraftBlocks.BLOOMERY.getUnlocalizedName());
setUnlocalizedName(registryName);
setRegistryName(registryName);
//setRegistryName(ModInfo.ForgecraftBlocks.FIREBOX.getRegistryName());
setCreativeTab(ModInfo.TAB_FORGECRAFT);
@@ -45,93 +72,197 @@ public class Anvil extends CustomContainerFacing {
TileAnvil tile = (TileAnvil) world.getTileEntity(pos);
if (tile != null) {
ItemStack pItem = player.inventory.getCurrentItem();
// ***************************************************************************** //
// Crafting
// ***************************************************************************** //
if(pItem.getItem() == PrimalItems.STONE_GALLAGHER){
/*
Loop through stacks in slot and create unique id from slots with stacks
if unique ID matches then do crafting
*/
}
// ***************************************************************************** //
// Adding and Removing Inventory
// ***************************************************************************** //
if(pItem.getItem().equals(ModItems.stonetongs)){
if(pItem.getTagCompound().getInteger("type") == 6){
if( (pItem.getTagCompound().getInteger("type") == 6) || (pItem.getTagCompound().getInteger("type") == 7) || (pItem.getTagCompound().getInteger("type") == 0) ) {
if(state.getValue(FACING) == EnumFacing.NORTH){
for(int i = 1; i < 15; i+=3){
if(hitx >= (double)i/16.0) {
if(hitx <= (double)(i+3)/16.0){
for(int a = 1; a < 15; a+=3) {
if(hitz >= (double)a/16.0) {
if(hitz <= (double)(a+3)/16.0) {
int row = (int)(((i-1.0)/3.0));
int column = (int)(((a-1.0)/3.0)*5);
//System.out.println(row+column);
tile.setSlotStack((row+column), new ItemStack(ModItems.ironingotballhot, 1));
if(state.getValue(FACING) == EnumFacing.NORTH) {
int counter = 0;
for(int z=0; z<5; z++){
for(int x=0; x<5; x++){
if(hitx >= this.getNormalMin(x) && hitx <= this.getNormalMax(x)){
if(hitz >= this.getNormalMin(z) && hitz <= this.getNormalMax(z)) {
if(!tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 0) {
if(tile.getSlotStack(counter).getItem().equals(ModItems.ironingotballhot)){
pItem.getTagCompound().setInteger("type", 6);
tile.setSlotStack(counter, ItemStack.EMPTY);
return true;
}
if(tile.getSlotStack(counter).getItem().equals(ModItems.ironchunkhot)){
pItem.getTagCompound().setInteger("type", 7);
tile.setSlotStack(counter, ItemStack.EMPTY);
System.out.println(counter);
return true;
}
}
}
if(tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 6) {
tile.setSlotStack((counter), new ItemStack(ModItems.ironingotballhot, 1));
pItem.getTagCompound().setInteger("type", 0);
System.out.println(tile.getSlotStack(row+column));
return true;
}
if (pItem.getTagCompound().getInteger("type") == 7) {
tile.setSlotStack((counter), new ItemStack(ModItems.ironchunkhot, 1));
pItem.getTagCompound().setInteger("type", 0);
System.out.println(counter);
return true;
}
}
}
}
counter++;
}
}
}
if(state.getValue(FACING) == EnumFacing.SOUTH){
for(int i = 1; i < 15; i+=3){
if(hitx >= (double)i/16.0) {
if(hitx <= (double)(i+3)/16.0){
for(int a = 1; a < 15; a+=3) {
if(hitz >= (double)a/16.0) {
if(hitz <= (double)(a+3)/16.0) {
int row = (int)(((i-1.0)/3.0));
int column = (int)(((a-1.0)/3.0)*5);
System.out.println((int)Math.abs(24-(row+column)));
if(state.getValue(FACING) == EnumFacing.SOUTH) {
int counter = 0;
for(int z=0; z<5; z++){
for(int x=0; x<5; x++){
if(hitx >= this.getReverseMin(x) && hitx <= this.getReverseMax(x)){
if(hitz >= this.getReverseMin(z) && hitz <= this.getReverseMax(z)) {
if(!tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 0) {
if(tile.getSlotStack(counter).getItem().equals(ModItems.ironingotballhot)){
pItem.getTagCompound().setInteger("type", 6);
tile.setSlotStack(counter, ItemStack.EMPTY);
return true;
}
if(tile.getSlotStack(counter).getItem().equals(ModItems.ironchunkhot)){
pItem.getTagCompound().setInteger("type", 7);
tile.setSlotStack(counter, ItemStack.EMPTY);
System.out.println(counter);
return true;
}
}
}
if(tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 6) {
tile.setSlotStack((counter), new ItemStack(ModItems.ironingotballhot, 1));
pItem.getTagCompound().setInteger("type", 0);
return true;
}
if (pItem.getTagCompound().getInteger("type") == 7) {
tile.setSlotStack((counter), new ItemStack(ModItems.ironchunkhot, 1));
pItem.getTagCompound().setInteger("type", 0);
System.out.println(counter);
return true;
}
}
}
}
counter++;
}
}
}
if(state.getValue(FACING) == EnumFacing.WEST){
for(int i = 1; i < 15; i+=3){
if(hitz >= (double)i/16.0) {
if(hitz <= (double)(i+3)/16.0){
for(int a = 1; a < 15; a+=3) {
if(hitx >= (double)a/16.0) {
if(hitx <= (double)(a+3)/16.0) {
int row = (int)Math.abs(((i-1.0)/3.0)-4);
int column = (int)(((a-1.0)/3.0)*5);
System.out.println("Row: " + row + " | Column: " + column);
System.out.println(row+column);
if(state.getValue(FACING) == EnumFacing.WEST) {
int counter = 0;
for(int x=0; x<5; x++){
for(int z=0; z<5; z++){
if(hitx >= this.getNormalMin(x) && hitx <= this.getNormalMax(x)){
if(hitz >= this.getReverseMin(z) && hitz <= this.getReverseMax(z)) {
if(!tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 0) {
if(tile.getSlotStack(counter).getItem().equals(ModItems.ironingotballhot)){
pItem.getTagCompound().setInteger("type", 6);
tile.setSlotStack(counter, ItemStack.EMPTY);
return true;
}
if(tile.getSlotStack(counter).getItem().equals(ModItems.ironchunkhot)){
pItem.getTagCompound().setInteger("type", 7);
tile.setSlotStack(counter, ItemStack.EMPTY);
System.out.println(counter);
return true;
}
}
}
if(tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 6) {
tile.setSlotStack((counter), new ItemStack(ModItems.ironingotballhot, 1));
pItem.getTagCompound().setInteger("type", 0);
return true;
}
if (pItem.getTagCompound().getInteger("type") == 7) {
tile.setSlotStack((counter), new ItemStack(ModItems.ironchunkhot, 1));
pItem.getTagCompound().setInteger("type", 0);
System.out.println(counter);
return true;
}
}
}
}
counter++;
}
}
}
if(state.getValue(FACING) == EnumFacing.EAST){
for(int i = 1; i < 15; i+=3){
if(hitz >= (double)i/16.0) {
if(hitz <= (double)(i+3)/16.0){
for(int a = 1; a < 15; a+=3) {
if(hitx >= (double)a/16.0) {
if(hitx <= (double)(a+3)/16.0) {
int row = (int)(((i-1.0)/3.0));
int column = (int)(Math.abs(((a-1.0)/3.0)-4)*5);
System.out.println("Row: " + row + " | Column: " + column);
System.out.println(row+column);
if(state.getValue(FACING) == EnumFacing.EAST) {
int counter = 0;
for(int x=0; x<5; x++){
for(int z=0; z<5; z++){
if(hitx >= this.getReverseMin(x) && hitx <= this.getReverseMax(x)){
if(hitz >= this.getNormalMin(z) && hitz <= this.getNormalMax(z)) {
if(!tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 0) {
if(tile.getSlotStack(counter).getItem().equals(ModItems.ironingotballhot)){
pItem.getTagCompound().setInteger("type", 6);
tile.setSlotStack(counter, ItemStack.EMPTY);
return true;
}
if(tile.getSlotStack(counter).getItem().equals(ModItems.ironchunkhot)){
pItem.getTagCompound().setInteger("type", 7);
tile.setSlotStack(counter, ItemStack.EMPTY);
System.out.println(counter);
return true;
}
}
}
if(tile.getSlotStack(counter).isEmpty()) {
if (pItem.getTagCompound().getInteger("type") == 6) {
tile.setSlotStack((counter), new ItemStack(ModItems.ironingotballhot, 1));
pItem.getTagCompound().setInteger("type", 0);
return true;
}
if (pItem.getTagCompound().getInteger("type") == 7) {
tile.setSlotStack((counter), new ItemStack(ModItems.ironchunkhot, 1));
pItem.getTagCompound().setInteger("type", 0);
System.out.println(counter);
return true;
}
}
}
}
counter++;
}
}
}
}
}
return false;
}
}
return false;
}

View File

@@ -0,0 +1,106 @@
package nmd.primal.forgecraft.crafting;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
/**
* Created by mminaie on 3/5/17.
*/
public class AnvilCrafting {
// ***************************************************************************** //
// Recipe Handler AnvilCrafting
// ***************************************************************************** //
private static ArrayList<AnvilCrafting> anvilRecipes = new ArrayList<>();
private static int input;
private static ItemStack slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24;
private static ItemStack [] slots = {slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24};
private static Integer [] pickaxeHead = {
0,0,0,0,0,
0,1,1,1,0,
1,0,0,0,1,
0,0,0,0,0,
0,0,0,0,0
};
public static ItemStack getSlots(Integer x) {
return slots[x];
}
public static ItemStack[] getSlots() {
return slots;
}
private ItemStack output;
public AnvilCrafting(Integer input, ItemStack slot0, ItemStack slot1, ItemStack slot2, ItemStack slot3, ItemStack slot4, ItemStack slot5, ItemStack slot6, ItemStack slot7, ItemStack slot8, ItemStack slot9, ItemStack slot10, ItemStack slot11, ItemStack slot12, ItemStack slot13, ItemStack slot14, ItemStack slot15, ItemStack slot16, ItemStack slot17, ItemStack slot18, ItemStack slot19, ItemStack slot20, ItemStack slot21, ItemStack slot22, ItemStack slot23, ItemStack slot24, ItemStack output){
this.input = input;
this.slot0 = slot0;
this.slot1 = slot1;
this.slot2 = slot2;
this.slot3 = slot3;
this.slot4 = slot4;
this.slot5 = slot5;
this.slot6 = slot6;
this.slot7 = slot7;
this.slot8 = slot8;
this.slot9 = slot9;
this.slot10 = slot10;
this.slot11 = slot11;
this.slot12 = slot12;
this.slot13 = slot13;
this.slot14 = slot14;
this.slot15 = slot15;
this.slot16 = slot16;
this.slot17 = slot17;
this.slot18 = slot18;
this.slot19 = slot19;
this.slot20 = slot20;
this.slot21 = slot21;
this.slot22 = slot22;
this.slot23 = slot23;
this.slot24 = slot24;
this.output = output;
}
// ***************************************************************************** //
// Recipe Methods
// ***************************************************************************** //
public static void addRecipe(Integer input, ItemStack slot0, ItemStack slot1, ItemStack slot2, ItemStack slot3, ItemStack slot4, ItemStack slot5, ItemStack slot6, ItemStack slot7, ItemStack slot8, ItemStack slot9, ItemStack slot10, ItemStack slot11, ItemStack slot12, ItemStack slot13, ItemStack slot14, ItemStack slot15, ItemStack slot16, ItemStack slot17, ItemStack slot18, ItemStack slot19, ItemStack slot20, ItemStack slot21, ItemStack slot22, ItemStack slot23, ItemStack slot24, ItemStack output)
{
anvilRecipes.add(new AnvilCrafting(input, slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24, output));
}
public static boolean isRecipeItem(ItemStack stack)
{
for(AnvilCrafting recipe : anvilRecipes) {
for(int i=0; i<25; i++){
if (AnvilCrafting.getSlots(i).equals(stack))
return true;
}
}
return false;
}
public static AnvilCrafting getRecipe(ItemStack stack)
{
for(AnvilCrafting recipe : anvilRecipes) {
if (stack.equals(recipe.output))
return recipe;
}
return null;
}
}

View File

@@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nmd.primal.forgecraft.blocks.Bloomery;
import nmd.primal.forgecraft.blocks.IngotBall;
import nmd.primal.forgecraft.crafting.AnvilCrafting;
import nmd.primal.forgecraft.crafting.BloomeryCrafting;
import nmd.primal.forgecraft.crafting.ForgeCrafting;
@@ -113,6 +114,10 @@ public class ModCrafting {
0.5f
);
// ***************************************************************************** //
// FORGING
// ***************************************************************************** //
//Makes a Hot Iron Ingot
ForgeCrafting.addRecipe(
ModBlocks.ironball,
@@ -127,5 +132,32 @@ public class ModCrafting {
1.0f
);
//Makes a Hot Iron Chunk
ForgeCrafting.addRecipe(
ModBlocks.ironchunk,
ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, false),
ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, true),
new ItemStack(ModBlocks.ironchunk, 1),
ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, false),
800,
170,
400,
1.0f,
1.0f
);
// ***************************************************************************** //
// ANVILING
// ***************************************************************************** //
AnvilCrafting.addRecipe(6781014, ItemStack.EMPTY, ItemStack.EMPTY, ItemStack.EMPTY, ItemStack.EMPTY, ItemStack.EMPTY,
ItemStack.EMPTY, new ItemStack(ModItems.ironchunkhot, 1), new ItemStack(ModItems.ironchunkhot, 1), new ItemStack(ModItems.ironchunkhot, 1), ItemStack.EMPTY,
ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,
ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,
ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,
new ItemStack(Blocks.OBSIDIAN, 1)
);
}
}

View File

@@ -35,6 +35,7 @@ public class ModItems {
public static Item stonetongs;
//public static Item ironingotballcool;
public static Item ironingotballhot;
public static Item ironchunkhot;
//public static Item forgingmanual;
public static void init() {
@@ -59,6 +60,22 @@ public class ModItems {
return EnumActionResult.FAIL;
}
};
ironchunkhot = new BaseMultiItem("ironchunkhot") {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!world.isRemote) {
ItemStack itemstack = player.getHeldItem(hand);
if (world.getBlockState(pos).getBlock() != ModBlocks.firebox) {
BlockPos tempPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ());
if(world.getBlockState(tempPos).getBlock() == Blocks.AIR){
world.setBlockState(tempPos, ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
itemstack.shrink(1);
return EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.FAIL;
}
};
//forgingmanual = new ItemForgingManual();
}
@@ -68,6 +85,7 @@ public class ModItems {
GameRegistry.register(stonetongs);
//GameRegistry.register(ironingotballcool);
GameRegistry.register(ironingotballhot);
GameRegistry.register(ironchunkhot);
//GameRegistry.register(forgingmanual);
}
@@ -77,6 +95,7 @@ public class ModItems {
registerRender(softcrucible);
//registerRender(ironingotballcool);
registerRender(ironingotballhot);
registerRender(ironchunkhot);
//registerRender(forgingmanual);
}
@@ -90,7 +109,8 @@ public class ModItems {
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_hotiron"),
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_hotironcooked"),
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_hotironfailed"),
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_ingot")
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_ingot"),
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_chunk")
);
ModelLoader.setCustomMeshDefinition(ModItems.stonetongs, new ItemMeshDefinition() {
@@ -118,6 +138,9 @@ public class ModItems {
else if (stack.getTagCompound().getInteger("type") == 6 ) {
return new ModelResourceLocation(stack.getItem().getRegistryName() + "_ingot", "inventory");
}
else if (stack.getTagCompound().getInteger("type") == 7 ) {
return new ModelResourceLocation(stack.getItem().getRegistryName() + "_chunk", "inventory");
}
else return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory");
}
return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory");

View File

@@ -54,7 +54,8 @@ public class ItemStoneTongs extends Item {
4 | Hot Cooked Iron Crucible
5 | Hot Failed Iron Crucible
6 | Hot Iron Ingot
7 |
7 | Hit Iron Chunk
8 |
*/
if(!world.isRemote) {
@@ -75,6 +76,15 @@ public class ItemStoneTongs extends Item {
return EnumActionResult.SUCCESS;
}
}
if (world.getBlockState(pos).getBlock() == ModBlocks.ironchunk) {
if(world.getBlockState(pos).getValue(IngotBall.ACTIVE) == true) {
itemstack.getTagCompound().setInteger("type", 7);
//itemstack.getTagCompound().setInteger("cooldown", tileCrucible.countdown);
world.setBlockToAir(pos);
//System.out.println(itemstack.getTagCompound().getInteger("type"));
return EnumActionResult.SUCCESS;
}
}
}
}
@@ -168,6 +178,10 @@ public class ItemStoneTongs extends Item {
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 7:
world.setBlockState(tempPos, ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
itemstack.getTagCompound().setInteger("type", 0);
return EnumActionResult.SUCCESS;
case 8:
return EnumActionResult.FAIL;
}
}
@@ -204,9 +218,11 @@ public class ItemStoneTongs extends Item {
}
else return EnumActionResult.FAIL;
System.out.println(itemstack.getTagCompound().getInteger("type"));
//System.out.println(itemstack.getTagCompound().getInteger("type"));
}
return EnumActionResult.FAIL;
//System.out.println(player.getHeldItem(hand).getTagCompound().getInteger("type"));
return EnumActionResult.SUCCESS;
}
}

View File

@@ -3,9 +3,11 @@ package nmd.primal.forgecraft.proxy;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.renders.TileAnvilRender;
import nmd.primal.forgecraft.renders.TileBloomeryRender;
import nmd.primal.forgecraft.renders.TileForgeRender;
import nmd.primal.forgecraft.renders.TilePistonBellowsRender;
import nmd.primal.forgecraft.tiles.TileAnvil;
import nmd.primal.forgecraft.tiles.TileBloomery;
import nmd.primal.forgecraft.tiles.TileForge;
import nmd.primal.forgecraft.tiles.TilePistonBellows;
@@ -36,6 +38,7 @@ public class ClientProxy implements CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileForge.class, new TileForgeRender());
ClientRegistry.bindTileEntitySpecialRenderer(TilePistonBellows.class, new TilePistonBellowsRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileBloomery.class, new TileBloomeryRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileAnvil.class, new TileAnvilRender());
}
@Override

View File

@@ -0,0 +1,198 @@
package nmd.primal.forgecraft.renders;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nmd.primal.forgecraft.blocks.Anvil;
import nmd.primal.forgecraft.init.ModBlocks;
import nmd.primal.forgecraft.tiles.TileAnvil;
import nmd.primal.forgecraft.tiles.TileBloomery;
import org.lwjgl.opengl.GL11;
/**
* Created by mminaie on 3/5/17.
*/
public class TileAnvilRender extends TileEntitySpecialRenderer<TileAnvil>
{
private RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
;
@Override
public void renderTileEntityAt(TileAnvil tile, double x, double y, double z, float partialTicks, int destroyStage)
{
GL11.glPushMatrix();
GL11.glTranslated(x, y + 1.5D, z);
//GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
float prevLGTX = OpenGlHelper.lastBrightnessX;
float prevLGTY = OpenGlHelper.lastBrightnessY;
BlockPos pos = tile.getPos();
IBlockState state = this.getWorld().getBlockState(pos);
int bright = tile.getWorld().getCombinedLight(pos.up(), 0);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, bright % 65536, bright / 65536);
/*
NORTH
SLOT | X | Y
0 | 2/16 | 2/16
1 | 5/16 | 2/16
2 | 8/16 | 2/16
3 | 11/16 | 2/16
4 | 14/16 | 2/16
--------------------
5 | 2/16 | 5/16
6 | 5/16 | 5/16
7 | 8/16 | 5/16
8 | 11/16 | 5/16
9 | 14/16 | 5/16
--------------------
10 | 2/16 | 8/16
11 | 5/16 | 8/16
12 | 8/16 | 8/16
13 | 11/16 | 8/16
14 | 14/16 | 8/16
--------------------
15 | 2/16 | 11/16
16 | 5/16 | 11/16
17 | 8/16 | 11/16
18 | 11/16 | 11/16
19 | 14/16 | 11/16
--------------------
20 | 2/16 | 14/16
21 | 5/16 | 14/16
22 | 8/16 | 14/16
23 | 11/16 | 14/16
24 | 14/16 | 14/16
*/
if(state.getValue(Anvil.FACING) == EnumFacing.NORTH){
int counter = 0;
for(int i=0; i < 5; i++){
for(int a=0; a<5; a++){
if(!tile.getSlotStack(counter).isEmpty()){
GL11.glPushMatrix();
double scale = 1.0D;
GL11.glScaled(scale, scale, scale);
GL11.glTranslated( tile.getNormalX(a), 0.0D, tile.getNormalZ(i) );
renderItem.renderItem(tile.getSlotStack(counter), renderItem.getItemModelMesher().getItemModel(tile.getSlotStack(counter)));
GL11.glPopMatrix();
}
counter++;
}
}
}
if(state.getValue(Anvil.FACING) == EnumFacing.SOUTH){
int counter = 0;
for(int i=0; i < 5; i++){
for(int a=0; a<5; a++){
if(!tile.getSlotStack(counter).isEmpty()){
GL11.glPushMatrix();
double scale = 1.0D;
GL11.glScaled(scale, scale, scale);
GL11.glTranslated( tile.getReverseX(a), 0.0D, tile.getReverseZ(i) );
renderItem.renderItem(tile.getSlotStack(counter), renderItem.getItemModelMesher().getItemModel(tile.getSlotStack(counter)));
GL11.glPopMatrix();
}
counter++;
}
}
}
if(state.getValue(Anvil.FACING) == EnumFacing.WEST){
int counter = 0;
for(int a=0; a < 5; a++){
for(int i=0; i<5; i++){
if(!tile.getSlotStack(counter).isEmpty()){
GL11.glPushMatrix();
double scale = 1.0D;
GL11.glScaled(scale, scale, scale);
GL11.glTranslated( tile.getNormalX(a), 0.0D, tile.getReverseZ(i) );
renderItem.renderItem(tile.getSlotStack(counter), renderItem.getItemModelMesher().getItemModel(tile.getSlotStack(counter)));
GL11.glPopMatrix();
}
counter++;
}
}
}
if(state.getValue(Anvil.FACING) == EnumFacing.EAST){
int counter = 0;
for(int a=0; a < 5; a++){
for(int i=0; i<5; i++){
if(!tile.getSlotStack(counter).isEmpty()){
GL11.glPushMatrix();
double scale = 1.0D;
GL11.glScaled(scale, scale, scale);
GL11.glTranslated( tile.getReverseX(a), 0.0D, tile.getNormalZ(i) );
renderItem.renderItem(tile.getSlotStack(counter), renderItem.getItemModelMesher().getItemModel(tile.getSlotStack(counter)));
GL11.glPopMatrix();
}
counter++;
}
}
}
/*if(!stack0.isEmpty()){
GL11.glPushMatrix();
//System.out.println("Should render " + stack0.getItem());
double scale = 1.0D;
GL11.glScaled(scale, scale, scale);
GL11.glTranslated( (double)2/(double)16, 0.0D, (double)2/(double)16 );
renderItem.renderItem(stack0, renderItem.getItemModelMesher().getItemModel(stack0));
GL11.glPopMatrix();
}
/*if (!stack0.isEmpty()) {
boolean is_block = stack0.getItem() instanceof ItemBlock;
float scale = is_block ? 0.1725F : 0.3F;
double xTrans = is_block ? -1.6D : -0.45D;
double yTrans = is_block ? -1.26D : -0.7D;
int stackRotation = stack0.getCount();
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F);
renderItem.renderItem(stack0, renderItem.getItemModelMesher().getItemModel(stack0));
GL11.glPopMatrix();
for(int i = 0; i < Math.ceil(stackRotation/8) + 1; i++){
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
GL11.glRotated(45.0F * i, 0.0F, 1.0F, 0.0F);
GL11.glRotated(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslated(xTrans, yTrans, 0.0D);
renderItem.renderItem(stack0, renderItem.getItemModelMesher().getItemModel(stack0));
GL11.glPopMatrix();
}
}
if(!stack1.isEmpty()){
GL11.glPushMatrix();
GL11.glTranslated(0, 0.50D, 0);
renderItem.renderItem(stack1, renderItem.getItemModelMesher().getItemModel(stack1));
GL11.glPopMatrix();
}*/
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevLGTX, prevLGTY);
GL11.glPopMatrix();
}
}

View File

@@ -8,6 +8,31 @@ import net.minecraft.util.NonNullList;
*/
public class TileAnvil extends TileBaseSlot {
private NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(25, ItemStack.EMPTY);
double[] normalX = {0.125,0.3125,0.5,0.6875,0.875};
public double getNormalX(Integer x) {
return normalX[x];
}
double[] normalZ = {0.125,0.3125,0.5,0.6875,0.875};
public double getNormalZ(Integer z) {
return normalZ[z];
}
double[] reverseX = {0.875,0.6875,0.5,0.3125,0.125};
public double getReverseX(Integer x) {
return reverseX[x];
}
double[] reverseZ = {0.875,0.6875,0.5,0.3125,0.125};
public double getReverseZ(Integer z) {
return reverseZ[z];
}
public NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(100, ItemStack.EMPTY);
}

View File

@@ -12,7 +12,7 @@ import java.util.List;
*/
public abstract class TileBaseSlot extends BaseTile {
private NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(4, ItemStack.EMPTY);
public NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(100, ItemStack.EMPTY);
// ***************************************************************************** //
// Controls

View File

@@ -0,0 +1,8 @@
{
"forge_marker":1,
"textures": {
"particle": "forgecraft:blocks/iron_ingot_hot",
"texture": "forgecraft:blocks/iron_ingot_hot"
},
"parent": "forgecraft:block/ironchunk"
}

View File

@@ -0,0 +1,10 @@
{
"forge_marker":1,
"textures": {
"particle": "forgecraft:blocks/stone",
"texture": "forgecraft:blocks/stone",
"texture1": "forgecraft:blocks/anvil_base",
"texture2": "forgecraft:blocks/anvil_base_top"
},
"parent": "forgecraft:block/stoneanvil"
}