Search in sources :

Example 41 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project ImmersiveEngineering by BluSunrize.

the class ActuallyAdditionsHelper method postInit.

@Override
public void postInit() {
    Item coffeeSeeds = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions:itemCoffeeSeed"));
    Item coffeeBeans = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions:itemCoffeeBeans"));
    Block coffeeBlock = Block.REGISTRY.getObject(new ResourceLocation("actuallyadditions:blockCoffee"));
    if (coffeeSeeds != null && coffeeBeans != null && coffeeBlock != null)
        BelljarHandler.cropHandler.register(new ItemStack(coffeeSeeds), new ItemStack[] { new ItemStack(coffeeBeans, 3), new ItemStack(coffeeSeeds) }, new ItemStack(Blocks.DIRT), coffeeBlock.getDefaultState());
    Item riceSeeds = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions:itemRiceSeed"));
    Item food = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions:itemFood"));
    Block riceBlock = Block.REGISTRY.getObject(new ResourceLocation("actuallyadditions:blockRice"));
    if (riceSeeds != null && food != null && riceBlock != null)
        BelljarHandler.cropHandler.register(new ItemStack(riceSeeds), new ItemStack[] { new ItemStack(food, 2, 16), new ItemStack(riceSeeds) }, new ItemStack(Blocks.DIRT), riceBlock.getDefaultState());
    Item canolaSeeds = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions:itemCanolaSeed"));
    Item misc = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions:itemMisc"));
    Block canolaBlock = Block.REGISTRY.getObject(new ResourceLocation("actuallyadditions:blockCanola"));
    if (canolaSeeds != null && misc != null && canolaBlock != null)
        BelljarHandler.cropHandler.register(new ItemStack(canolaSeeds), new ItemStack[] { new ItemStack(misc, 3, 13), new ItemStack(canolaSeeds) }, new ItemStack(Blocks.DIRT), canolaBlock.getDefaultState());
    Item flaxSeeds = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions:itemFlaxSeed"));
    Block flaxBlock = Block.REGISTRY.getObject(new ResourceLocation("actuallyadditions:blockFlax"));
    if (flaxSeeds != null && flaxBlock != null)
        BelljarHandler.cropHandler.register(new ItemStack(flaxSeeds), new ItemStack[] { new ItemStack(Items.STRING, 4), new ItemStack(flaxSeeds) }, new ItemStack(Blocks.DIRT), flaxBlock.getDefaultState());
}
Also used : Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 42 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project ImmersiveEngineering by BluSunrize.

the class AttainedDropsHelper method addType.

static void addType(String type, ItemStack out) {
    Block soilBlock = Block.REGISTRY.getObject(new ResourceLocation("attaineddrops:" + type + "_soil"));
    Block bulbBlock = Block.REGISTRY.getObject(new ResourceLocation("attaineddrops:" + type + "_bulb"));
    if (soilBlock != null && bulbBlock != null) {
        ComparableItemStack comp = new ComparableItemStack(new ItemStack(soilBlock));
        soilOutputMap.put(comp, new ItemStack[] { out });
        bulbMap.put(comp, bulbBlock.getDefaultState());
    }
}
Also used : ComparableItemStack(blusunrize.immersiveengineering.api.ComparableItemStack) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ComparableItemStack(blusunrize.immersiveengineering.api.ComparableItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 43 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project ImmersiveEngineering by BluSunrize.

the class AttainedDropsHelper method init.

@Override
public void init() {
    Block blockPlant = Block.REGISTRY.getObject(new ResourceLocation("attaineddrops:plant"));
    final Item itemSeed = Item.REGISTRY.getObject(new ResourceLocation("attaineddrops:itemseed"));
    if (blockPlant == null || itemSeed == null)
        return;
    final IBlockState blockstatePlant = blockPlant.getDefaultState();
    IProperty propertyAge = null;
    for (IProperty prop : blockstatePlant.getPropertyNames()) if ("age".equals(prop.getName()) && prop instanceof PropertyInteger)
        propertyAge = prop;
    final IProperty propertyAge_final = propertyAge;
    addType("slimeball", new ItemStack(Items.SLIME_BALL));
    addType("bone", new ItemStack(Items.BONE));
    addType("string", new ItemStack(Items.STRING));
    addType("rottenflesh", new ItemStack(Items.ROTTEN_FLESH));
    addType("ghasttear", new ItemStack(Items.GHAST_TEAR));
    addType("spidereye", new ItemStack(Items.SPIDER_EYE));
    addType("prismarine", new ItemStack(Items.PRISMARINE_SHARD));
    addType("blaze", new ItemStack(Items.BLAZE_ROD));
    addType("gunpowder", new ItemStack(Items.GUNPOWDER));
    addType("witherskull", new ItemStack(Items.SKULL, 1, 1));
    addType("enderpearl", new ItemStack(Items.ENDER_PEARL));
    BelljarHandler.registerHandler(new IPlantHandler() {

        @Override
        public boolean isCorrectSoil(ItemStack seed, ItemStack soil) {
            return soil != null && soilOutputMap.containsKey(new ComparableItemStack(soil));
        }

        @Override
        public float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render) {
            return (growth < .5 ? .003125f : .0015625f) * fertilizer;
        }

        @Override
        public float resetGrowth(ItemStack seed, ItemStack soil, float growth, TileEntity tile, boolean render) {
            return .5f;
        }

        @Override
        public ItemStack[] getOutput(ItemStack seed, ItemStack soil, TileEntity tile) {
            ItemStack[] out = soilOutputMap.get(new ComparableItemStack(soil));
            if (out == null)
                return new ItemStack[0];
            return out;
        }

        @Override
        public boolean isValid(ItemStack seed) {
            return seed != null && seed.getItem() == itemSeed;
        }

        @Override
        @SideOnly(Side.CLIENT)
        public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
            return new IBlockState[0];
        }

        @Override
        @SideOnly(Side.CLIENT)
        public float getRenderSize(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
            return .875f;
        }

        @Override
        @SideOnly(Side.CLIENT)
        public boolean overrideRender(ItemStack seed, ItemStack soil, float growth, TileEntity tile, BlockRendererDispatcher blockRenderer) {
            IBlockState state = blockstatePlant.withProperty(propertyAge_final, growth >= .5 ? 7 : Math.min(7, Math.round(7 * growth * 2)));
            IBakedModel model = blockRenderer.getModelForState(state);
            GlStateManager.pushMatrix();
            blockRenderer.getBlockModelRenderer().renderModelBrightness(model, state, 1, true);
            GlStateManager.popMatrix();
            if (growth >= .5) {
                state = bulbMap.get(new ComparableItemStack(soil));
                model = blockRenderer.getModelForState(state);
                GlStateManager.pushMatrix();
                float scale = (growth - .5f) * 2f;
                GlStateManager.translate(.5 - scale / 2, 1, -.5 + scale / 2);
                GlStateManager.scale(scale, scale, scale);
                blockRenderer.getBlockModelRenderer().renderModelBrightness(model, state, 1, true);
                GlStateManager.popMatrix();
            }
            return true;
        }
    });
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PropertyInteger(net.minecraft.block.properties.PropertyInteger) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) IPlantHandler(blusunrize.immersiveengineering.api.tool.BelljarHandler.IPlantHandler) TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) ComparableItemStack(blusunrize.immersiveengineering.api.ComparableItemStack) IProperty(net.minecraft.block.properties.IProperty) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ComparableItemStack(blusunrize.immersiveengineering.api.ComparableItemStack) ItemStack(net.minecraft.item.ItemStack) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 44 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project ImmersiveEngineering by BluSunrize.

the class BetterWithModsHelper method init.

@Override
public void init() {
    Item hempSeeds = Item.REGISTRY.getObject(new ResourceLocation("betterwithmods:hemp"));
    Item material = Item.REGISTRY.getObject(new ResourceLocation("betterwithmods:material"));
    Block hempBlock = Block.REGISTRY.getObject(new ResourceLocation("betterwithmods:hemp"));
    if (hempSeeds != null && material != null && hempBlock != null)
        BelljarHandler.cropHandler.register(new ItemStack(hempSeeds), new ItemStack[] { new ItemStack(material, 1, 2), new ItemStack(hempSeeds, 1) }, new ItemStack(Blocks.DIRT), hempBlock.getDefaultState());
}
Also used : Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 45 with ResourceLocation

use of net.minecraft.util.ResourceLocation in project ImmersiveEngineering by BluSunrize.

the class MysticalAgricultureHelper method addType.

static void addType(String type) {
    Item itemSeeds = Item.REGISTRY.getObject(new ResourceLocation("mysticalagriculture:" + type + "_seeds"));
    Item itemEssence = Item.REGISTRY.getObject(new ResourceLocation("mysticalagriculture:" + type + "_essence"));
    Block blockCrop = Block.REGISTRY.getObject(new ResourceLocation("mysticalagriculture:" + type + "_crop"));
    if (itemSeeds != null && itemEssence != null && blockCrop != null)
        BelljarHandler.cropHandler.register(new ItemStack(itemSeeds), new ItemStack[] { new ItemStack(itemEssence), new ItemStack(itemSeeds) }, new ItemStack(Blocks.DIRT), blockCrop.getDefaultState());
}
Also used : Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ResourceLocation (net.minecraft.util.ResourceLocation)272 ItemStack (net.minecraft.item.ItemStack)51 Block (net.minecraft.block.Block)47 Item (net.minecraft.item.Item)32 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)31 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)30 IBlockState (net.minecraft.block.state.IBlockState)17 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)15 ArrayList (java.util.ArrayList)14 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)14 Map (java.util.Map)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)11 ShaderLayer (blusunrize.immersiveengineering.api.shader.ShaderCase.ShaderLayer)10 IOException (java.io.IOException)10 TileEntity (net.minecraft.tileentity.TileEntity)9 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)8 EnumFacing (net.minecraft.util.EnumFacing)8 BlockPos (net.minecraft.util.math.BlockPos)8 Random (java.util.Random)7 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7