diff options
author | Jordan Byrne <draknyte1@hotmail.com> | 2017-12-29 13:17:13 +1000 |
---|---|---|
committer | Jordan Byrne <draknyte1@hotmail.com> | 2017-12-29 13:17:13 +1000 |
commit | d1963f3f97fb6478fdfb0a5c64dd7c5a2d156c93 (patch) | |
tree | 61717e0cf32788a531053249080c7fd2d2a089ab | |
parent | d9bb6aa63908828d5844c29c1b76956ea2079cf2 (diff) | |
download | GT5-Unofficial-d1963f3f97fb6478fdfb0a5c64dd7c5a2d156c93.tar.gz GT5-Unofficial-d1963f3f97fb6478fdfb0a5c64dd7c5a2d156c93.tar.bz2 GT5-Unofficial-d1963f3f97fb6478fdfb0a5c64dd7c5a2d156c93.zip |
+ Added dehydrator recipes for denser ore types.
$ Fixed Ore Blocks not generating as intended.
% Improved Ore Generator.
3 files changed, 184 insertions, 49 deletions
diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index c0847c798d..abcccd1005 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -12,9 +12,9 @@ import gregtech.api.interfaces.tileentity.ITexturedTileEntity; import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; -import gtPlusPlus.core.item.base.itemblock.ItemBlockGtBlock; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockOre; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; @@ -27,64 +27,43 @@ import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -public class BlockBaseOre extends BlockBaseModular implements ITexturedTileEntity { +public class BlockBaseOre extends BasicBlock implements ITexturedTileEntity { - @SuppressWarnings("unused") - private IIcon base; - @SuppressWarnings("unused") - private IIcon overlay; - - protected Material blockMaterial; - - protected int blockColour; - protected BlockTypes thisBlock; + private final Material blockMaterial; public BlockBaseOre(final Material material, final BlockTypes blockType, final int colour) { - this(material.getUnlocalizedName(), material.getLocalizedName(), net.minecraft.block.material.Material.iron, blockType, colour, 3); - blockMaterial = material; - } - - public BlockBaseOre(final String unlocalizedName, final String blockMaterial, final BlockTypes blockType, final int colour) { - this(unlocalizedName, blockMaterial, net.minecraft.block.material.Material.iron, blockType, colour, 2); - } + super(Utils.sanitizeString(material.getUnlocalizedName()), net.minecraft.block.material.Material.rock); + this.blockMaterial = material; + this.setHardness(2.0f); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHarvestLevel("pickaxe", 3); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setStepSound(soundTypeStone); + this.setBlockName(Utils.sanitizeString(Utils.sanitizeString(material.getUnlocalizedName()))); - public BlockBaseOre(final String unlocalizedName, final String blockMaterial, final net.minecraft.block.material.Material vanillaMaterial, final BlockTypes blockType, final int colour, final int miningLevel) { - super(unlocalizedName, blockMaterial, vanillaMaterial, blockType, colour, miningLevel); - try { - if (blockMaterial == null){ - Logger.DEBUG_MATERIALS("Failed to generate "+unlocalizedName+" due to invalid material variable."); - } - this.blockColour = colour; - this.thisBlock = blockType; - - if (this == null || this.blockMaterial == null){ - Logger.DEBUG_MATERIALS("Issue during Ore construction, Material or Block is null."); - } + //this.setBlockTextureName(CORE.MODID+":"+blockType.getTexture()); + //this.setBlockName(this.blockMaterial.getLocalizedName()+" Ore"); - GameRegistry.registerBlock(this, ItemBlockGtBlock.class, Utils.sanitizeString("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); + try { + GameRegistry.registerBlock(this, ItemBlockOre.class, Utils.sanitizeString("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); GT_OreDictUnificator.registerOre("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()), ItemUtils.getSimpleStack(this)); - LanguageRegistry.addName(this, blockMaterial+ " Ore"); + LanguageRegistry.addName(this, blockMaterial.getLocalizedName()+ " Ore"); } catch (Throwable t){ t.printStackTrace(); } } - /** - * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha - */ - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass(){ - return 0; - } - @Override public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { return false; } + + public Material getMaterialEx(){ + return this.blockMaterial; + } @Override public int getRenderType() { diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java new file mode 100644 index 0000000000..cb3455f0c5 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockOre.java @@ -0,0 +1,72 @@ +package gtPlusPlus.core.item.base.itemblock; + +import java.util.List; + +import gtPlusPlus.core.block.base.BlockBaseOre; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.ORES; +import gtPlusPlus.core.material.nuclear.FLUORIDES; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.entity.EntityUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ItemBlockOre extends ItemBlock{ + + private final BlockBaseOre mThisOre; + private final Material mThisMaterial; + private final int mThisRadiation; + private final int mThisColour; + + public ItemBlockOre(final Block block) { + super(block); + if (block instanceof BlockBaseOre){ + this.mThisOre = (BlockBaseOre) block; + this.mThisMaterial = this.mThisOre.getMaterialEx(); + this.mThisRadiation = this.mThisMaterial.vRadiationLevel; + this.mThisColour = this.mThisMaterial.getRgbAsHex(); + } + else { + this.mThisOre = null; + this.mThisMaterial = null; + this.mThisRadiation = 0; + this.mThisColour = Utils.rgbtoHexValue(255, 255, 255); + } + } + + public int getRenderColor(final int aMeta) { + return this.mThisColour; + } + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + //Radioactive? + if (this.mThisRadiation > 0){ + list.add(CORE.GT_Tooltip_Radioactive); + } + + /** + * Tooltip Handler for Ores + */ + if (this.mThisMaterial == FLUORIDES.FLUORITE){ + list.add("Mined from Sandstone and Limestone."); + } + else if (this.mThisMaterial != FLUORIDES.FLUORITE){ + list.add("Mined from the Dark Dimension."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { + if (this.mThisRadiation > 0){ + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.mThisRadiation, world, entityHolding); + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index d9e67c16f6..928cc82302 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -2,9 +2,10 @@ package gtPlusPlus.xmod.gregtech.loaders; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.state.MaterialState; @@ -43,7 +44,7 @@ public class RecipeGen_Ore implements Runnable{ bonusA = material.getComposites().get(0).getStackMaterial(); } else { - return ; + return; } if (material.getComposites().size() >= 1 && material.getComposites().get(1) != null){ bonusB = material.getComposites().get(1).getStackMaterial(); @@ -52,7 +53,8 @@ public class RecipeGen_Ore implements Runnable{ bonusB = material.getComposites().get(0).getStackMaterial(); } else { - return; + //Ultra Bonus + bonusB = ELEMENT.getInstance().GALLIUM; } AutoMap<Pair<Integer, Material>> componentMap = new AutoMap<Pair<Integer, Material>>(); @@ -88,7 +90,7 @@ public class RecipeGen_Ore implements Runnable{ */ //Wash into Purified Crushed if (GT_Values.RA.addOreWasherRecipe(material.getCrushed(1), material.getCrushedPurified(1), bonusA.getTinyDust(1), dustStone, FluidUtils.getWater(1000), 25*20, 16)){ - Logger.MATERIALS("[OreWasher] Added Recipe: 'Wash Crushed oer into Purified Crushed ore'"); + Logger.MATERIALS("[OreWasher] Added Recipe: 'Wash Crushed ore into Purified Crushed ore'"); } /** @@ -237,8 +239,90 @@ public class RecipeGen_Ore implements Runnable{ t.printStackTrace(); } } - else if (componentMap.size() > 6){ - Logger.MATERIALS("[Issue][Electrolyzer] "+material.getLocalizedName()+" is composed of over 6 materials, so a recipe for processing cannot be generated."); + else if (componentMap.size() > 6 && componentMap.size() <= 9){ + Logger.MATERIALS("[Issue][Electrolyzer] "+material.getLocalizedName()+" is composed of over 6 materials, so an electrolyzer recipe for processing cannot be generated. Trying to create one for the Dehydrator instead."); + + ItemStack mInternalOutputs[] = new ItemStack[9]; + int mChances[] = new int[9]; + int mCellCount = 0; + + int mTotalCount = 0; + + int mCounter = 0; + for (Pair<Integer, Material> f : componentMap){ + if (f.getValue().getState() != MaterialState.SOLID){ + Logger.MATERIALS("[Dehydrator] Found Fluid Component, adding "+f.getKey()+" cells of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getCell(f.getKey()); + mCellCount += f.getKey(); + mTotalCount += f.getKey(); + Logger.MATERIALS("[Dehydrator] In total, adding "+mCellCount+" cells for "+material.getLocalizedName()+" processing."); + } + else { + Logger.MATERIALS("[Dehydrator] Found Solid Component, adding "+f.getKey()+" dusts of "+f.getValue().getLocalizedName()+"."); + mInternalOutputs[mCounter++] = f.getValue().getDust(f.getKey()); + mTotalCount += f.getKey(); + } + } + + //Build Output Array + for (int g=0;g<mInternalOutputs.length;g++){ + Logger.MATERIALS("[Dehydrator] Is output["+g+"] valid with a chance? "+(mInternalOutputs[g] != null ? 10000 : 0)); + mChances[g] = (mInternalOutputs[g] != null ? 10000 : 0); + } + + ItemStack emptyCell = null; + if (mCellCount > 0){ + emptyCell = ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", mCellCount); + Logger.MATERIALS("[Dehydrator] Recipe now requires "+mCellCount+" empty cells as input."); + } + + ItemStack mainDust = material.getDust(material.smallestStackSizeWhenProcessing); + if (mainDust != null){ + Logger.MATERIALS("[Dehydrator] Recipe now requires "+material.smallestStackSizeWhenProcessing+"x "+mainDust.getDisplayName()+" as input."); + } + else { + mainDust = material.getDust(mTotalCount); + Logger.MATERIALS("[Dehydrator] Could not find valid input dust, trying alternative."); + if (mainDust != null){ + Logger.MATERIALS("[Dehydrator] Recipe now requires "+mTotalCount+"x "+mainDust.getDisplayName()+" as input."); + } + else { + Logger.MATERIALS("[Dehydrator] Could not find valid input dust, exiting."); + } + } + + for (int j=0;j<mInternalOutputs.length;j++){ + if (mInternalOutputs[j] == null){ + mInternalOutputs[j] = GT_Values.NI; + Logger.MATERIALS("[Dehydrator] Set slot "+j+" to null."); + } + else { + Logger.MATERIALS("[Dehydrator] Set slot "+j+" to "+mInternalOutputs[j].getDisplayName()+"."); + } + } + + try{ + + + if (CORE.RA.addDehydratorRecipe( + new ItemStack[]{mainDust, emptyCell}, + null, + null, + mInternalOutputs, + mChances, + 20*1*(tVoltageMultiplier/10), + tVoltageMultiplier)){ + Logger.MATERIALS("[Dehydrator] Generated Dehydrator recipe for "+material.getDust(1).getDisplayName()); + } + else { + Logger.MATERIALS("[Dehydrator] Failed to generate Dehydrator recipe for "+material.getDust(1).getDisplayName()); + } + } + catch(Throwable t){ + t.printStackTrace(); + } + + } |