diff options
Diffstat (limited to 'src/main/java/gregtech/common')
6 files changed, 122 insertions, 5 deletions
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 4b2c227413..c80414843b 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -646,6 +646,16 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { public boolean costlyCableConnection = false; public boolean crashOnNullRecipeInput = false; + public enum OreDropSystem { + Block, + PerDimBlock, + UnifiedBlock, + FortuneItem, + Item + } + + public OreDropSystem oreDropSystem = OreDropSystem.FortuneItem; + /** * This enables ambient-occlusion smooth lighting on tiles */ diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java index 1bfd24f75c..015baa2319 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java @@ -10,9 +10,12 @@ import java.util.Arrays; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; @@ -126,4 +129,26 @@ public class GT_Block_Ores extends GT_Block_Ores_Abstract { .build(); return rTextures; } + + @Override + public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) { + + if (EnchantmentHelper.getSilkTouchModifier(player)) { + GT_TileEntity_Ores.shouldSilkTouch = true; + super.harvestBlock(worldIn, player, x, y, z, meta); + + if (GT_TileEntity_Ores.shouldSilkTouch) { + GT_TileEntity_Ores.shouldSilkTouch = false; + } + return; + } + + if (!(player instanceof FakePlayer)) { + GT_TileEntity_Ores.shouldFortune = true; + } + super.harvestBlock(worldIn, player, x, y, z, meta); + if (GT_TileEntity_Ores.shouldFortune) { + GT_TileEntity_Ores.shouldFortune = false; + } + } } diff --git a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java index eb9ae2d694..f3d247a265 100644 --- a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java @@ -30,6 +30,8 @@ import gregtech.api.util.GT_Utility; public class GT_TileEntity_Ores extends TileEntity implements IAllSidedTexturedTileEntity { public short mMetaData = 0; + protected static boolean shouldFortune = false; + protected static boolean shouldSilkTouch = false; public boolean mNatural = false; public boolean mBlocked = true; public boolean mBlockedChecked = false; @@ -300,11 +302,74 @@ public class GT_TileEntity_Ores extends TileEntity implements IAllSidedTexturedT rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); return rList; } + Materials aOreMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)]; if (this.mMetaData < 16000) { - rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); + boolean tIsRich = false; + + // For Sake of god of balance! + + // Dense ore + + // NetherOre + if (GT_Mod.gregtechproxy.mNetherOreYieldMultiplier && !tIsRich) { + tIsRich = (this.mMetaData >= 1000 && this.mMetaData < 2000); + } + // EndOre + if (GT_Mod.gregtechproxy.mEndOreYieldMultiplier && !tIsRich) { + tIsRich = (this.mMetaData >= 2000 && this.mMetaData < 3000); + } + + // Silk Touch + if (shouldSilkTouch) { + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); + + } else { + switch (GT_Mod.gregtechproxy.oreDropSystem) { + case Item -> { + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, (tIsRich ? 2 : 1))); + } + // TODO: Test + case FortuneItem -> { + // if shouldFortune and isNatural then get fortune drops + // if not shouldFortune or not isNatural then get normal drops + // if not shouldFortune and isNatural then get normal drops + // if shouldFortune and not isNatural then get normal drops + if (shouldFortune && this.mNatural && aFortune > 0) { + int aMinAmount = 1; + // Max applicable fortune + if (aFortune > 3) aFortune = 3; + long amount = (long) new Random().nextInt(aFortune * (tIsRich ? 2 : 1)) + aMinAmount; + for (int i = 0; i < amount; i++) { + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } else { + for (int i = 0; i < (tIsRich ? 2 : 1); i++) { + rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } + } + case UnifiedBlock -> { + // Unified ore + for (int i = 0; i < (tIsRich ? 2 : 1); i++) { + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData % 1000)); + } + } + case PerDimBlock -> { + // Per Dimension ore + if (tIsRich) { + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); + } else { + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData % 1000)); + } + } + case Block -> { + // Regular ore + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); + } + } + } return rList; } - Materials aOreMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)]; // Everyone gets a free small fortune boost aFortune += 1; diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_03.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_03.java index 26a2d1777e..3a0c4a95d8 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_03.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_03.java @@ -46,7 +46,8 @@ public class GT_MetaGenerated_Item_03 extends GT_MetaGenerated_Item_X32 { OrePrefixes.crateGtIngot, OrePrefixes.crateGtGem, OrePrefixes.crateGtPlate, - OrePrefixes.nanite); + OrePrefixes.nanite, + OrePrefixes.rawOre); INSTANCE = this; Object[] o = new Object[0]; @@ -1078,6 +1079,9 @@ public class GT_MetaGenerated_Item_03 extends GT_MetaGenerated_Item_X32 { public boolean doesShowInCreative(OrePrefixes aPrefix, Materials aMaterial, boolean aDoShowAllItems) { return aDoShowAllItems || (aPrefix.toString() .toLowerCase() - .contains("nanite")); + .contains("nanite")) + || (aPrefix.toString() + .toLowerCase() + .contains("rawore")); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java index 9ea42c6a00..27998e97e1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_IntegratedOreFactory.java @@ -163,6 +163,10 @@ public class GT_MetaTileEntity_IntegratedOreFactory extends for (ItemStack stack : OreDictionary.getOres(name)) { isOre.add(GT_Utility.stackToInt(stack)); } + } else if (name.startsWith("rawOre")) { + for (ItemStack stack : OreDictionary.getOres(name)) { + isOre.add(GT_Utility.stackToInt(stack)); + } } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index 045374823f..9c15d2b6eb 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -503,7 +503,16 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile final int blockMeta = getBaseMetaTileEntity().getMetaID(posX, posY, posZ); if (oreBlock.canSilkHarvest(getBaseMetaTileEntity().getWorld(), null, posX, posY, posZ, blockMeta)) { return Collections.singleton(new ItemStack(oreBlock, 1, blockMeta)); - } else return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, mTier + 3); + } + if (oreBlock instanceof GT_Block_Ores_Abstract) { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(posX, posY, posZ); + if (tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mMetaData >= 16000) { + // GT_Log.out.println("Running Small Ore"); + return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, mTier + 3); + } + } + // GT_Log.out.println("Running Normal Ore"); + return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, 0); } private boolean tryConsumeDrillingFluid(boolean simulate) { |