Search in sources :

Example 1 with BlockCustomWorkbench

use of com.axanthic.loi.blocks.BlockCustomWorkbench in project Lands-of-Icaria by Axanthic-Game-Studios.

the class GuiHandlerLOI method getClientGuiElement.

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    if (ID != getGuiID()) {
        System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID);
    }
    BlockPos xyz = new BlockPos(x, y, z);
    TileEntity tileEntity = world.getTileEntity(xyz);
    if (tileEntity instanceof TileEntityVase) {
        TileEntityVase tileEntityInventoryBasic = (TileEntityVase) tileEntity;
        return new GuiInventoryVase(player.inventory, tileEntityInventoryBasic);
    }
    if (tileEntity instanceof TileEntityKiln) {
        TileEntityKiln tileEntityInventoryBasic = (TileEntityKiln) tileEntity;
        return new GuiInventoryKiln(player.inventory, tileEntityInventoryBasic);
    }
    if (tileEntity instanceof TileEntityGrinder) {
        TileEntityGrinder tileEntityInventoryBasic = (TileEntityGrinder) tileEntity;
        return new GuiInventoryGrinder(player.inventory, tileEntityInventoryBasic);
    }
    if (tileEntity instanceof TileEntityForge) {
        TileEntityForge tileEntityInventoryBasic = (TileEntityForge) tileEntity;
        return new GuiInventoryForge(player.inventory, tileEntityInventoryBasic);
    }
    if (world.getBlockState(xyz).getBlock() instanceof BlockCustomWorkbench) {
        return new GuiCustomCrafting(player.inventory, world, xyz);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityVase(com.axanthic.loi.tileentity.TileEntityVase) TileEntityGrinder(com.axanthic.loi.tileentity.TileEntityGrinder) TileEntityKiln(com.axanthic.loi.tileentity.TileEntityKiln) TileEntityForge(com.axanthic.loi.tileentity.TileEntityForge) BlockPos(net.minecraft.util.math.BlockPos) BlockCustomWorkbench(com.axanthic.loi.blocks.BlockCustomWorkbench)

Example 2 with BlockCustomWorkbench

use of com.axanthic.loi.blocks.BlockCustomWorkbench in project Lands-of-Icaria by Axanthic-Game-Studios.

the class GuiHandlerLOI method getServerGuiElement.

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    if (ID != getGuiID()) {
        System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID);
    }
    BlockPos xyz = new BlockPos(x, y, z);
    TileEntity tileEntity = world.getTileEntity(xyz);
    if (tileEntity instanceof TileEntityVase) {
        TileEntityVase tileEntityInventoryBasic = (TileEntityVase) tileEntity;
        return new ContainerVase(player.inventory, tileEntityInventoryBasic);
    }
    if (tileEntity instanceof TileEntityKiln) {
        TileEntityKiln tileEntityInventoryBasic = (TileEntityKiln) tileEntity;
        return new ContainerKiln(player.inventory, tileEntityInventoryBasic);
    }
    if (tileEntity instanceof TileEntityGrinder) {
        TileEntityGrinder tileEntityInventoryBasic = (TileEntityGrinder) tileEntity;
        return new ContainerGrinder(player.inventory, tileEntityInventoryBasic);
    }
    if (tileEntity instanceof TileEntityForge) {
        TileEntityForge tileEntityInventoryBasic = (TileEntityForge) tileEntity;
        return new ContainerForge(player.inventory, tileEntityInventoryBasic);
    }
    if (world.getBlockState(xyz).getBlock() instanceof BlockCustomWorkbench) {
        return new ContainerCustomWorkbench(player.inventory, world, xyz);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityVase(com.axanthic.loi.tileentity.TileEntityVase) TileEntityGrinder(com.axanthic.loi.tileentity.TileEntityGrinder) TileEntityKiln(com.axanthic.loi.tileentity.TileEntityKiln) TileEntityForge(com.axanthic.loi.tileentity.TileEntityForge) BlockPos(net.minecraft.util.math.BlockPos) BlockCustomWorkbench(com.axanthic.loi.blocks.BlockCustomWorkbench)

Example 3 with BlockCustomWorkbench

use of com.axanthic.loi.blocks.BlockCustomWorkbench in project Lands-of-Icaria by Axanthic-Game-Studios.

the class ClientProxy method registerModels.

@SubscribeEvent
public void registerModels(ModelRegistryEvent event) {
    for (ItemBlock block : Resources.blocks) {
        if (block.getBlock() instanceof BlockFlower || block.getBlock() instanceof BlockTallGrass || block.getBlock() instanceof BlockHerb) {
            for (int i = 0; i < ((IBlockMeta) block.getBlock()).getNames().length; i++) {
                ModelLoader.setCustomModelResourceLocation(block, i, new ModelResourceLocation(block.getRegistryName() + "_inv", "type=" + ((IBlockMeta) block.getBlock()).getNames()[i]));
            }
        } else if (block.getBlock() instanceof BlockLeafOlives) {
            // olive leaves are weird
            ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "check_decay=false,decayable=false,type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(0)));
            ModelLoader.setCustomModelResourceLocation(block, 1, new ModelResourceLocation(block.getRegistryName(), "check_decay=false,decayable=false,type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(1)));
        } else if (block instanceof ItemBlockMeta) {
            ModelLoader.setCustomMeshDefinition(block, new ItemMeshDefinition() {

                @Override
                public ModelResourceLocation getModelLocation(ItemStack stack) {
                    return new ModelResourceLocation(block.getRegistryName(), "type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(stack.getMetadata()));
                }
            });
        } else if (block.getBlock() instanceof BlockLeaf || block.getBlock() instanceof BlockSapling || block.getBlock() instanceof BlockCustomWorkbench) {
            String[] path = block.getRegistryName().getResourcePath().split("_");
            if (block.getBlock() instanceof BlockSapling)
                ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), "inv_" + path[0]));
            else
                ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), path[0]));
            ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {

                @Override
                public ModelResourceLocation getModelResourceLocation(IBlockState state) {
                    return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), path[0]);
                }
            });
        } else if (block.getBlock() instanceof BlockLog) {
            String[] path = block.getRegistryName().getResourcePath().split("_");
            ResourceLocation loc = new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]);
            ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(loc, path[0] + "_y"));
            ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {

                @Override
                public ModelResourceLocation getModelResourceLocation(IBlockState state) {
                    String axis = "bark";
                    int meta = ((BlockLog) block.getBlock()).getMetaFromState(state);
                    if (meta == 0) {
                        axis = "y";
                    } else if (meta == 4) {
                        axis = "x";
                    } else if (meta == 8) {
                        axis = "z";
                    }
                    return new ModelResourceLocation(loc, path[0] + "_" + axis);
                }
            });
        } else if (block.getBlock() instanceof BlockFluidCustom) {
            ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "normal"));
            ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {

                @Override
                public ModelResourceLocation getModelResourceLocation(IBlockState state) {
                    return new ModelResourceLocation(block.getRegistryName(), "normal");
                }
            });
        } else
            ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
    }
    for (Item item : Resources.items) {
        if (item instanceof IItemMeta) {
            for (int i = 0; i < ((IItemMeta) item).getNames().length; i++) {
                ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(item.getRegistryName(), "type=" + ((IItemMeta) item).getNames()[i]));
            }
        } else if (item instanceof ItemTool || item instanceof ItemSword || item instanceof ItemCustomArmor) {
            String[] path = item.getRegistryName().getResourcePath().split("_");
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "tool_" + path[1]), path[0]));
        } else if (item instanceof ItemSpell) {
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "spell"), ((ItemSpell) item).getName()));
        } else if (item instanceof ItemScroll) {
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "spell_scroll"), ((ItemScroll) item).getName()));
        } else if (item instanceof ItemConcoctionFlask) {
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "concoction_flask_filled"), "inventory"));
        } else
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }
    // register special item renderers here
    Resources.saltedFood.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.grinder.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadRevenant.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadArachne.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadArachneDrone.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadMyrmeke.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadCerver.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadArganHound.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagPlane.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagPopulus.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagCypress.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagFir.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagOlive.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagLaurel.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadForesthagDroughtroot.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadAeternae.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadCatoblepas.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    Resources.mobHeadSow.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
    for (ItemScroll scroll : Resources.scrolls) scroll.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) BlockLeaf(com.axanthic.loi.blocks.BlockLeaf) IBlockMeta(com.axanthic.loi.blocks.IBlockMeta) BlockLeafOlives(com.axanthic.loi.blocks.BlockLeafOlives) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) BlockCustomWorkbench(com.axanthic.loi.blocks.BlockCustomWorkbench) Item(net.minecraft.item.Item) ItemSpell(com.axanthic.loi.items.ItemSpell) BlockSapling(com.axanthic.loi.blocks.BlockSapling) BlockHerb(com.axanthic.loi.blocks.BlockHerb) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ItemConcoctionFlask(com.axanthic.loi.items.ItemConcoctionFlask) ItemSword(net.minecraft.item.ItemSword) ItemTool(net.minecraft.item.ItemTool) IBlockState(net.minecraft.block.state.IBlockState) BlockLog(com.axanthic.loi.blocks.BlockLog) IItemMeta(com.axanthic.loi.items.IItemMeta) ItemBlock(net.minecraft.item.ItemBlock) BlockFlower(com.axanthic.loi.blocks.BlockFlower) ItemCustomArmor(com.axanthic.loi.items.ItemCustomArmor) ItemMeshDefinition(net.minecraft.client.renderer.ItemMeshDefinition) BlockTallGrass(com.axanthic.loi.blocks.BlockTallGrass) ItemBlockMeta(com.axanthic.loi.items.ItemBlockMeta) ItemStack(net.minecraft.item.ItemStack) ItemScroll(com.axanthic.loi.items.ItemScroll) BlockFluidCustom(com.axanthic.loi.blocks.BlockFluidCustom) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

BlockCustomWorkbench (com.axanthic.loi.blocks.BlockCustomWorkbench)3 TileEntityForge (com.axanthic.loi.tileentity.TileEntityForge)2 TileEntityGrinder (com.axanthic.loi.tileentity.TileEntityGrinder)2 TileEntityKiln (com.axanthic.loi.tileentity.TileEntityKiln)2 TileEntityVase (com.axanthic.loi.tileentity.TileEntityVase)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 BlockFlower (com.axanthic.loi.blocks.BlockFlower)1 BlockFluidCustom (com.axanthic.loi.blocks.BlockFluidCustom)1 BlockHerb (com.axanthic.loi.blocks.BlockHerb)1 BlockLeaf (com.axanthic.loi.blocks.BlockLeaf)1 BlockLeafOlives (com.axanthic.loi.blocks.BlockLeafOlives)1 BlockLog (com.axanthic.loi.blocks.BlockLog)1 BlockSapling (com.axanthic.loi.blocks.BlockSapling)1 BlockTallGrass (com.axanthic.loi.blocks.BlockTallGrass)1 IBlockMeta (com.axanthic.loi.blocks.IBlockMeta)1 IItemMeta (com.axanthic.loi.items.IItemMeta)1 ItemBlockMeta (com.axanthic.loi.items.ItemBlockMeta)1 ItemConcoctionFlask (com.axanthic.loi.items.ItemConcoctionFlask)1 ItemCustomArmor (com.axanthic.loi.items.ItemCustomArmor)1