diff --git a/1.11/src/main/java/nmd/primal/forgecraft/blocks/CastingForm.java b/1.11/src/main/java/nmd/primal/forgecraft/blocks/CastingForm.java index 38a2a116..b9a58020 100644 --- a/1.11/src/main/java/nmd/primal/forgecraft/blocks/CastingForm.java +++ b/1.11/src/main/java/nmd/primal/forgecraft/blocks/CastingForm.java @@ -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; } diff --git a/1.11/src/main/java/nmd/primal/forgecraft/proxy/ClientProxy.java b/1.11/src/main/java/nmd/primal/forgecraft/proxy/ClientProxy.java index 427a0534..8fa2ffbf 100644 --- a/1.11/src/main/java/nmd/primal/forgecraft/proxy/ClientProxy.java +++ b/1.11/src/main/java/nmd/primal/forgecraft/proxy/ClientProxy.java @@ -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 diff --git a/1.11/src/main/java/nmd/primal/forgecraft/renders/blocks/TileAnvilRender.java b/1.11/src/main/java/nmd/primal/forgecraft/renders/blocks/TileAnvilRender.java index 277f1c3c..202a0b80 100644 --- a/1.11/src/main/java/nmd/primal/forgecraft/renders/blocks/TileAnvilRender.java +++ b/1.11/src/main/java/nmd/primal/forgecraft/renders/blocks/TileAnvilRender.java @@ -34,8 +34,6 @@ public class TileAnvilRender extends TileEntitySpecialRenderer private RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); - ; - @Override public void renderTileEntityAt(TileAnvil tile, double x, double y, double z, float partialTicks, int destroyStage) { diff --git a/1.11/src/main/java/nmd/primal/forgecraft/renders/blocks/TileCastingformRender.java b/1.11/src/main/java/nmd/primal/forgecraft/renders/blocks/TileCastingformRender.java new file mode 100644 index 00000000..5fd3ec70 --- /dev/null +++ b/1.11/src/main/java/nmd/primal/forgecraft/renders/blocks/TileCastingformRender.java @@ -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 { + + 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(); + } + } +} diff --git a/1.11/src/main/java/nmd/primal/forgecraft/tiles/TileCastingForm.java b/1.11/src/main/java/nmd/primal/forgecraft/tiles/TileCastingForm.java index 03353b81..c27077e8 100644 --- a/1.11/src/main/java/nmd/primal/forgecraft/tiles/TileCastingForm.java +++ b/1.11/src/main/java/nmd/primal/forgecraft/tiles/TileCastingForm.java @@ -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]; diff --git a/1.11/src/main/java/nmd/primal/forgecraft/util/CastingFormHandler.java b/1.11/src/main/java/nmd/primal/forgecraft/util/CastingFormHandler.java index 6fcb3918..ad84312d 100644 --- a/1.11/src/main/java/nmd/primal/forgecraft/util/CastingFormHandler.java +++ b/1.11/src/main/java/nmd/primal/forgecraft/util/CastingFormHandler.java @@ -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++; diff --git a/1.11/src/main/resources/assets/forgecraft/models/block/ironball.json b/1.11/src/main/resources/assets/forgecraft/models/block/ironball.json index 15e1fc02..979584ce 100644 --- a/1.11/src/main/resources/assets/forgecraft/models/block/ironball.json +++ b/1.11/src/main/resources/assets/forgecraft/models/block/ironball.json @@ -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 ] diff --git a/1.11/src/main/resources/assets/forgecraft/models/block/ironchunk.json b/1.11/src/main/resources/assets/forgecraft/models/block/ironchunk.json index e0569bed..5d3852dd 100644 --- a/1.11/src/main/resources/assets/forgecraft/models/block/ironchunk.json +++ b/1.11/src/main/resources/assets/forgecraft/models/block/ironchunk.json @@ -37,4 +37,5 @@ "translation": [ 0, 7, 0 ] } } -} \ No newline at end of file +} + diff --git a/1.11/src/main/resources/assets/forgecraft/models/item/castingform.json b/1.11/src/main/resources/assets/forgecraft/models/item/castingform.json new file mode 100644 index 00000000..bb141438 --- /dev/null +++ b/1.11/src/main/resources/assets/forgecraft/models/item/castingform.json @@ -0,0 +1,4 @@ +{ + "forge_marker":1, + "parent": "forgecraft:block/castingform" +} \ No newline at end of file diff --git a/1.11/src/main/resources/assets/forgecraft/models/item/castingmud.json b/1.11/src/main/resources/assets/forgecraft/models/item/castingmud.json index cfcf840c..b824e63c 100644 --- a/1.11/src/main/resources/assets/forgecraft/models/item/castingmud.json +++ b/1.11/src/main/resources/assets/forgecraft/models/item/castingmud.json @@ -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 ] diff --git a/1.11/src/main/resources/assets/forgecraft/models/item/castingmud2.json b/1.11/src/main/resources/assets/forgecraft/models/item/castingmud2.json new file mode 100644 index 00000000..18304714 --- /dev/null +++ b/1.11/src/main/resources/assets/forgecraft/models/item/castingmud2.json @@ -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 ] + } + } +} \ No newline at end of file