From 9007ccadee5d6d605991fd6a7abafbab777eb0ee Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 11 Sep 2016 14:51:52 +0200 Subject: [PATCH] Added crystallized canola seeds to make crystal oil --- .../api/ActuallyAdditionsAPI.java | 1 - .../mod/fluids/InitFluids.java | 2 +- .../actuallyadditions/mod/items/ItemMisc.java | 29 +++++++++++++++++++ .../mod/items/lens/LensRecipeHandler.java | 5 +++- .../mod/items/metalists/TheMiscItems.java | 1 + .../assets/actuallyadditions/lang/en_US.lang | 1 + 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index 1c22b44a0..50b24481a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -20,7 +20,6 @@ import de.ellpeck.actuallyadditions.api.recipe.*; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java index 8e64f0abc..dd09fcbba 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java @@ -48,7 +48,7 @@ public final class InitFluids{ FluidRegistry.registerFluid(fluid); FluidRegistry.addBucketForFluid(fluid); - return fluid; + return FluidRegistry.getFluid(fluid.getName()); } private static Block registerFluidBlock(Fluid fluid, Material material, String name){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java index 49f9c5063..0af3b3ea3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java @@ -11,14 +11,21 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.util.StringUtil; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -66,4 +73,26 @@ public class ItemMisc extends ItemBase{ ActuallyAdditions.proxy.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(name), "inventory"); } } + + @Override + public boolean onEntityItemUpdate(EntityItem entity){ + if(!entity.worldObj.isRemote){ + ItemStack stack = entity.getEntityItem(); + if(stack != null && stack.getItemDamage() == TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal()){ + BlockPos pos = entity.getPosition(); + IBlockState state = entity.worldObj.getBlockState(pos); + Block block = state.getBlock(); + + if(block instanceof IFluidBlock && block.getMetaFromState(state) == 0){ + Fluid fluid = ((IFluidBlock)block).getFluid(); + if(fluid != null && fluid == InitFluids.fluidOil){ + entity.setDead(); + entity.worldObj.setBlockState(pos, InitFluids.blockCrystalOil.getDefaultState()); + } + } + } + } + + return super.onEntityItemUpdate(entity); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java index cc4189fea..fe734af9b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java @@ -40,6 +40,7 @@ public final class LensRecipeHandler{ public static LensConversionRecipe recipeLeather; public static LensConversionRecipe recipeNetherWart; public static LensConversionRecipe recipePrismarine; + public static LensConversionRecipe recipeCrystallizedCanolaSeed; public static void init(){ //Crystal Blocks @@ -99,6 +100,9 @@ public final class LensRecipeHandler{ recipePrismarine = RecipeUtil.lastReconstructorRecipe(); } + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemCanolaSeed), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal()), 2000); + recipeCrystallizedCanolaSeed = RecipeUtil.lastReconstructorRecipe(); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.QUARTZ_BLOCK), new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), 10); recipeWhiteWall = RecipeUtil.lastReconstructorRecipe(); ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10); @@ -113,7 +117,6 @@ public final class LensRecipeHandler{ ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.CARPET), changer); ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLamp), changer); ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLampOn), changer); - } public static ArrayList getRecipesFor(ItemStack input){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java index 944806dae..d3fb3635e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java @@ -38,6 +38,7 @@ public enum TheMiscItems{ SPAWNER_SHARD("SpawnerShard", EnumRarity.EPIC), BIOMASS("Biomass", EnumRarity.UNCOMMON), BIOCOAL("Biocoal", EnumRarity.RARE), + CRYSTALLIZED_CANOLA_SEED("CrystallizedCanolaSeed", EnumRarity.UNCOMMON), YOUTUBE_ICON("YoutubeIcon", Util.FALLBACK_RARITY); public final String name; diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 366b1d52a..7134c261c 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -504,6 +504,7 @@ item.actuallyadditions.itemPlayerProbe.name=Player Probe item.actuallyadditions.itemWorm.name=Worm item.actuallyadditions.itemBag.name=Traveler's Sack item.actuallyadditions.itemVoidBag.name=Void Sack +item.actuallyadditions.itemMiscCrystallizedCanolaSeed.name=Crystallized Canola Seed #Tooltips tooltip.actuallyadditions.onSuffix.desc=On