updated models and slot code, need to add recipe handler

This commit is contained in:
Mohammad-Ali Minaie
2017-06-21 09:01:26 -04:00
parent 431b93bf31
commit 10b7e8d75b
11 changed files with 337 additions and 23 deletions

View File

@@ -42,7 +42,9 @@ public class CastingForm extends CustomContainerFacing implements CastingFormHan
if (!world.isRemote) {
TileCastingForm tile = (TileCastingForm) world.getTileEntity(pos);
doInventoryManager(player.getActiveItemStack(), world, tile, pos, hitx, hity, hitz, state, player);
ItemStack pItem = player.inventory.getCurrentItem();
doInventoryManager(pItem, world, tile, pos, hitx, hity, hitz, state, player);
return true;
}
return false;
}

View File

@@ -34,6 +34,7 @@ public class ClientProxy implements CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileBloomery.class, new TileBloomeryRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileAnvil.class, new TileAnvilRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileBreaker.class, new TileBreakerRender());
ClientRegistry.bindTileEntitySpecialRenderer(TileCastingForm.class, new TileCastingformRender());
}
@Override

View File

@@ -34,8 +34,6 @@ 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) {

View File

@@ -0,0 +1,162 @@
package nmd.primal.forgecraft.renders.blocks;
import net.minecraft.block.Block;
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.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import nmd.primal.core.api.PrimalItems;
import nmd.primal.forgecraft.blocks.Anvil.AnvilBase;
import nmd.primal.forgecraft.blocks.Anvil.AnvilStone;
import nmd.primal.forgecraft.blocks.CastingForm;
import nmd.primal.forgecraft.blocks.CustomContainerFacing;
import nmd.primal.forgecraft.blocks.IngotBall;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.items.BaseMultiItem;
import nmd.primal.forgecraft.tiles.TileCastingForm;
import org.lwjgl.opengl.GL11;
/**
* Created by mminaie on 6/21/17.
*/
public class TileCastingformRender extends TileEntitySpecialRenderer <TileCastingForm> {
private RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
@Override
public void renderTileEntityAt(TileCastingForm tile, double x, double y, double z, float partialTicks, int destroyStage) {
BlockPos pos = tile.getPos();
IBlockState state = this.getWorld().getBlockState(pos);
if (state.getBlock() instanceof CastingForm) {
GL11.glPushMatrix();
GL11.glTranslated(x+2/16D, y+0.25D, z+2/16D);
//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;
int bright = tile.getWorld().getCombinedLight(pos.up(), 0);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, bright % 65536, bright / 65536);
/*
NORTH
SLOT | X | Y
0 | 3/16 | 3/16
1 | 5/16 | 3/16
2 | 7/16 | 3/16
3 | 9/16 | 3/16
4 | 11/16 | 3/16
--------------------
5 | 3/16 | 5/16
6 | 5/16 | 5/16
7 | 7/16 | 5/16
8 | 9/16 | 5/16
9 | 11/16 | 5/16
--------------------
10 | 3/16 | 8/16
11 | 5/16 | 8/16
12 | 7/16 | 8/16
13 | 9/16 | 8/16
14 | 11/16 | 8/16
--------------------
15 | 3/16 | 11/16
16 | 5/16 | 11/16
17 | 7/16 | 11/16
18 | 9/16 | 11/16
19 | 11/16 | 11/16
--------------------
20 | 3/16 | 14/16
21 | 5/16 | 14/16
22 | 7/16 | 14/16
23 | 9/16 | 14/16
24 | 11/16 | 14/16
*/
if (state.getValue(CustomContainerFacing.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()) {
Item item = tile.getSlotStack(counter).getItem();
if (item.equals(ModItems.castingmud)) {
GL11.glPushMatrix();
GL11.glTranslated(tile.getNormalX(a), 0.0D, tile.getNormalZ(i));
renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED);
GL11.glPopMatrix();
}
}
counter++;
}
}
}
if (state.getValue(CustomContainerFacing.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()) {
Item item = tile.getSlotStack(counter).getItem();
if (item.equals(ModItems.castingmud)) {
GL11.glPushMatrix();
GL11.glTranslated(tile.getReverseX(a), 0.0D, tile.getReverseZ(i));
renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED);
GL11.glPopMatrix();
}
}
counter++;
}
}
}
if (state.getValue(CustomContainerFacing.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()) {
Item item = tile.getSlotStack(counter).getItem();
if (item.equals(ModItems.castingmud)) {
GL11.glPushMatrix();
GL11.glTranslated(tile.getNormalX(a), 0.0D, tile.getReverseZ(i));
renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED);
GL11.glPopMatrix();
}
}
counter++;
}
}
}
if (state.getValue(CustomContainerFacing.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()) {
Item item = tile.getSlotStack(counter).getItem();
if (item.equals(ModItems.castingmud)) {
GL11.glPushMatrix();
GL11.glTranslated(tile.getReverseX(a), 0.0D, tile.getNormalZ(i));
renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED);
GL11.glPopMatrix();
}
}
counter++;
}
}
}
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevLGTX, prevLGTY);
GL11.glPopMatrix();
}
}
}

View File

@@ -8,25 +8,25 @@ import net.minecraft.util.NonNullList;
*/
public class TileCastingForm extends TileBaseSlot {
double[] normalX = {0.125,0.3125,0.5,0.6875,0.875};
double[] normalX = {2/16D, 4/16D, 6/16D, 8/16D, 10/16D};
public double getNormalX(Integer x) {
return normalX[x];
}
double[] normalZ = {0.125,0.3125,0.5,0.6875,0.875};
double[] normalZ = {2/16D, 4/16D, 6/16D, 8/16D, 10/16D};
public double getNormalZ(Integer z) {
return normalZ[z];
}
double[] reverseX = {0.875,0.6875,0.5,0.3125,0.125};
double[] reverseX = {10/16D, 8/16D, 6/16D, 4/16D, 2/16D};
public double getReverseX(Integer x) {
return reverseX[x];
}
double[] reverseZ = {0.875,0.6875,0.5,0.3125,0.125};
double[] reverseZ = {10/16D, 8/16D, 6/16D, 4/16D, 2/16D};
public double getReverseZ(Integer z) {
return reverseZ[z];

View File

@@ -6,6 +6,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nmd.primal.core.common.helper.PlayerHelper;
import nmd.primal.forgecraft.init.ModItems;
import nmd.primal.forgecraft.tiles.TileCastingForm;
import static nmd.primal.forgecraft.blocks.CustomContainerFacing.FACING;
@@ -47,14 +49,37 @@ public interface CastingFormHandler {
default boolean doInventoryManager(ItemStack pItem, World world, TileCastingForm tile, BlockPos pos, float hitx, float hity, float hitz, IBlockState state, EntityPlayer player) {
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)) {
System.out.println("North Facing: " + tile.getSlotStack(counter));
return true;
if(player.isSneaking()) {
if (pItem.getItem() != ModItems.castingmud) {
System.out.println("Level 1 a");
if (!tile.getSlotStack(counter).isEmpty()) {
System.out.println("Level 1 b");
ItemStack dropStack = new ItemStack(ModItems.castingmud, 1);
tile.setSlotStack(counter, ItemStack.EMPTY);
PlayerHelper.spawnItemOnGround(world, pos, dropStack);
return true;
}
}
}
if (pItem.getItem() == ModItems.castingmud) {
System.out.println("Level 2 a");
if (tile.getSlotStack(counter).isEmpty()) {
System.out.println("Level 2 b");
ItemStack castStack = new ItemStack(ModItems.castingmud, 1);
pItem.shrink(1);
tile.setSlotStack(counter, castStack);
return true;
}
}
}
}
counter++;
@@ -68,7 +93,29 @@ public interface CastingFormHandler {
if (hitx >= this.getReverseMin(x) && hitx <= this.getReverseMax(x)) {
if (hitz >= this.getReverseMin(z) && hitz <= this.getReverseMax(z)) {
return true;
if(player.isSneaking()) {
if (pItem.getItem() != ModItems.castingmud) {
System.out.println("Level 1 a");
if (!tile.getSlotStack(counter).isEmpty()) {
System.out.println("Level 1 b");
ItemStack dropStack = new ItemStack(ModItems.castingmud, 1);
tile.setSlotStack(counter, ItemStack.EMPTY);
PlayerHelper.spawnItemOnGround(world, pos, dropStack);
return true;
}
}
}
if (pItem.getItem() == ModItems.castingmud) {
System.out.println("Level 2 a");
if (tile.getSlotStack(counter).isEmpty()) {
System.out.println("Level 2 b");
ItemStack castStack = new ItemStack(ModItems.castingmud, 1);
pItem.shrink(1);
tile.setSlotStack(counter, castStack);
return true;
}
}
}
}
counter++;
@@ -82,7 +129,29 @@ public interface CastingFormHandler {
if (hitx >= this.getNormalMin(x) && hitx <= this.getNormalMax(x)) {
if (hitz >= this.getReverseMin(z) && hitz <= this.getReverseMax(z)) {
return true;
if(player.isSneaking()) {
if (pItem.getItem() != ModItems.castingmud) {
System.out.println("Level 1 a");
if (!tile.getSlotStack(counter).isEmpty()) {
System.out.println("Level 1 b");
ItemStack dropStack = new ItemStack(ModItems.castingmud, 1);
tile.setSlotStack(counter, ItemStack.EMPTY);
PlayerHelper.spawnItemOnGround(world, pos, dropStack);
return true;
}
}
}
if (pItem.getItem() == ModItems.castingmud) {
System.out.println("Level 2 a");
if (tile.getSlotStack(counter).isEmpty()) {
System.out.println("Level 2 b");
ItemStack castStack = new ItemStack(ModItems.castingmud, 1);
pItem.shrink(1);
tile.setSlotStack(counter, castStack);
return true;
}
}
}
}
counter++;
@@ -96,7 +165,29 @@ public interface CastingFormHandler {
if (hitx >= this.getReverseMin(x) && hitx <= this.getReverseMax(x)) {
if (hitz >= this.getNormalMin(z) && hitz <= this.getNormalMax(z)) {
return true;
if(player.isSneaking()) {
if (pItem.getItem() != ModItems.castingmud) {
System.out.println("Level 1 a");
if (!tile.getSlotStack(counter).isEmpty()) {
System.out.println("Level 1 b");
ItemStack dropStack = new ItemStack(ModItems.castingmud, 1);
tile.setSlotStack(counter, ItemStack.EMPTY);
PlayerHelper.spawnItemOnGround(world, pos, dropStack);
return true;
}
}
}
if (pItem.getItem() == ModItems.castingmud) {
System.out.println("Level 2 a");
if (tile.getSlotStack(counter).isEmpty()) {
System.out.println("Level 2 b");
ItemStack castStack = new ItemStack(ModItems.castingmud, 1);
pItem.shrink(1);
tile.setSlotStack(counter, castStack);
return true;
}
}
}
}
counter++;

View File

@@ -27,8 +27,9 @@
"translation": [ 0, 7.35, 0 ]
},
"gui": {
"translation": [ 0, 2, 0 ],
"rotation": [ 30, 225, 0 ],
"scale": [ 0.625, 0.625, 0.625 ]
"scale": [ 1.25, 1.25, 1.25 ]
},
"ground": {
"translation": [ 0, 4, 0 ]

View File

@@ -0,0 +1,4 @@
{
"forge_marker":1,
"parent": "forgecraft:block/castingform"
}

View File

@@ -1,8 +1,8 @@
{
"__comment": "Designed by Kitsushadow with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "blocks/e_particle",
"texture": "blocks/e_texture"
"particle": "primal:items/parts/adobebrick_mix",
"texture": "primal:items/parts/adobebrick_mix"
},
"elements": [
{
@@ -10,12 +10,12 @@
"from": [ 7, 0, 7 ],
"to": [ 9, 2, 9 ],
"faces": {
"down": { "uv": [ 7, 7, 9, 9 ], "texture": "#texture" },
"up": { "uv": [ 7, 7, 9, 9 ], "texture": "#texture" },
"north": { "uv": [ 7, 7, 9, 9 ], "texture": "#texture" },
"south": { "uv": [ 7, 7, 9, 9 ], "texture": "#texture" },
"west": { "uv": [ 7, 7, 9, 9 ], "texture": "#texture" },
"east": { "uv": [ 7, 7, 9, 9 ], "texture": "#texture" }
"down": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"up": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"north": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"south": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"west": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"east": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" }
}
}
],
@@ -40,7 +40,8 @@
},
"gui": {
"rotation": [ 30, 225, 0 ],
"translation": [ 0, 5, 0 ]
"translation": [ 0, 5, 0 ],
"scale": [ 1.5, 1.5, 1.5 ]
},
"ground": {
"translation": [ 0, 4, 0 ]

View File

@@ -0,0 +1,53 @@
{
"__comment": "Designed by Kitsushadow with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "items/parts/adobebrick_mix",
"texture": "items/parts/adobebrick_mix"
},
"elements": [
{
"__comment": "Box1",
"from": [ 7, 0, 7 ],
"to": [ 9, 2, 9 ],
"faces": {
"down": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"up": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"north": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"south": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"west": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" },
"east": { "uv": [ 5, 5, 11, 11 ], "texture": "#texture" }
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [ 0, -90, 55 ],
"translation": [ 0, 4, -5 ],
"scale": [ 0.85, 0.85, 0.85 ]
},
"thirdperson_lefthand": {
"rotation": [ 0, -90, 55 ],
"translation": [ 0, 4, -5 ],
"scale": [ 0.85, 0.85, 0.85 ]
},
"firstperson_righthand": {
"rotation": [ 0, -90, 25 ],
"translation": [ 0, 4, -5 ]
},
"firstperson_lefthand": {
"rotation": [ 0, -90, 25 ],
"translation": [ 0, 4, -5 ]
},
"gui": {
"rotation": [ 30, 225, 0 ],
"translation": [ 0, 5, 0 ],
"scale": [ 1.5, 1.5, 1.5 ]
},
"ground": {
"translation": [ 0, 4, 0 ]
},
"fixed": {
"translation": [ 0, 6, 0 ]
}
}
}