diff --git a/src/main/java/WayofTime/bloodmagic/api/Constants.java b/src/main/java/WayofTime/bloodmagic/api/Constants.java index fe4ece7e..2c3c7481 100644 --- a/src/main/java/WayofTime/bloodmagic/api/Constants.java +++ b/src/main/java/WayofTime/bloodmagic/api/Constants.java @@ -195,16 +195,19 @@ public class Constants @Getter private final String regName; - BloodMagicItem(String regName) { + BloodMagicItem(String regName) + { this.regName = regName; } - public Item getItem() { + public Item getItem() + { return BloodMagicAPI.getItem(getRegName()); } } - public enum BloodMagicBlock { + public enum BloodMagicBlock + { ALCHEMY_ARRAY("BlockAlchemyArray"), ALTAR("BlockAltar"), BLOOD_LIGHT("BlockBloodLight"), @@ -222,16 +225,19 @@ public class Constants RITUAL_STONE("BlockRitualStone"), SOUL_FORGE("BlockSoulForge"), SPECTRAL("BlockSpectral"), - TELEPOSER("BlockTeleposer"); + TELEPOSER("BlockTeleposer"), + INCENSE_ALTAR("BlockIncenseAltar"); @Getter private final String regName; - BloodMagicBlock(String regName) { + BloodMagicBlock(String regName) + { this.regName = regName; } - public Block getBlock() { + public Block getBlock() + { return BloodMagicAPI.getBlock(getRegName()); } } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java b/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java new file mode 100644 index 00000000..81435c20 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/block/BlockIncenseAltar.java @@ -0,0 +1,48 @@ +package WayofTime.bloodmagic.block; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.tile.TileIncenseAltar; + +public class BlockIncenseAltar extends BlockContainer +{ + public BlockIncenseAltar() + { + super(Material.rock); + + setUnlocalizedName(Constants.Mod.MODID + ".incenseAltar"); + setRegistryName(Constants.BloodMagicBlock.INCENSE_ALTAR.getRegName()); + setCreativeTab(BloodMagic.tabBloodMagic); + setHardness(2.0F); + setResistance(5.0F); + setHarvestLevel("pickaxe", 0); + } + + @Override + public int getRenderType() + { + return 3; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) + { + return new TileIncenseAltar(); + } + + @Override + public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) + { + TileIncenseAltar TileIncenseAltar = (TileIncenseAltar) world.getTileEntity(blockPos); + if (TileIncenseAltar != null) + TileIncenseAltar.dropItems(); + + super.breakBlock(world, blockPos, blockState); + } +} diff --git a/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarComponent.java b/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarComponent.java new file mode 100644 index 00000000..0a6bdde3 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarComponent.java @@ -0,0 +1,63 @@ +package WayofTime.bloodmagic.incense; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; + +public class IncenseAltarComponent +{ + public final BlockPos offsetPos; + public final Block block; + public final IBlockState state; + + public IncenseAltarComponent(BlockPos offsetPos, Block block, IBlockState state) + { + this.offsetPos = offsetPos; + this.block = block; + this.state = state; + } + + public boolean doesBlockMatch(Block block, IBlockState state) + { + return this.block == block && block.getMetaFromState(state) == this.block.getMetaFromState(this.state); + } + + /** + * Base rotation is north. + */ + public BlockPos getOffset(EnumFacing rotation) + { + return new BlockPos(this.getX(rotation), offsetPos.getY(), this.getZ(rotation)); + } + + public int getX(EnumFacing direction) + { + switch (direction) + { + case EAST: + return -this.offsetPos.getZ(); + case SOUTH: + return -this.offsetPos.getX(); + case WEST: + return this.offsetPos.getZ(); + default: + return this.offsetPos.getX(); + } + } + + public int getZ(EnumFacing direction) + { + switch (direction) + { + case EAST: + return this.offsetPos.getX(); + case SOUTH: + return -this.offsetPos.getZ(); + case WEST: + return -this.offsetPos.getX(); + default: + return this.offsetPos.getZ(); + } + } +} diff --git a/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarHandler.java b/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarHandler.java new file mode 100644 index 00000000..e9b38053 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/incense/IncenseAltarHandler.java @@ -0,0 +1,74 @@ +package WayofTime.bloodmagic.incense; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public class IncenseAltarHandler +{ + public static Map> incenseComponentMap = new TreeMap>(); + //Incense bonus maximum applied for the tier of blocks. + public static double[] incenseBonuses = new double[] { 0.2 }; + + public static void registerIncenseComponent(int altarLevel, IncenseAltarComponent component) + { + if (incenseComponentMap.containsKey(altarLevel)) + { + incenseComponentMap.get(altarLevel).add(component); + } else + { + List list = new ArrayList(); + list.add(component); + incenseComponentMap.put(altarLevel, list); + } + } + + public static void registerIncenseComponent(int altarLevel, BlockPos offsetPos, Block block, IBlockState state) + { + registerIncenseComponent(altarLevel, new IncenseAltarComponent(offsetPos, block, state)); + } + + public static double getIncenseBonusFromComponents(World world, BlockPos pos) + { + double accumulatedBonus = 0; + for (int i = 0; i < incenseBonuses.length; i++) + { + double previousBonus = (i <= 0 ? 0 : incenseBonuses[i - 1]); + double nextBonus = incenseBonuses[i]; + if (!incenseComponentMap.containsKey(i)) + { + accumulatedBonus += (nextBonus - previousBonus); + } else + { + boolean hasAllComponentsThisTier = true; + for (IncenseAltarComponent component : incenseComponentMap.get(i)) + { + BlockPos offsetPos = pos.add(component.getOffset(EnumFacing.NORTH)); + IBlockState state = world.getBlockState(offsetPos); + Block block = state.getBlock(); + if (component.doesBlockMatch(block, state)) + { + hasAllComponentsThisTier = false; + } else + { + accumulatedBonus += (nextBonus - previousBonus) / incenseComponentMap.get(i).size(); + } + } + + if (!hasAllComponentsThisTier) + { + break; + } + } + } + + return accumulatedBonus; + } +} diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java index ee2fc467..a3e1094c 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java @@ -13,6 +13,7 @@ import WayofTime.bloodmagic.block.BlockBloodLight; import WayofTime.bloodmagic.block.BlockBloodRune; import WayofTime.bloodmagic.block.BlockBloodStoneBrick; import WayofTime.bloodmagic.block.BlockCrystal; +import WayofTime.bloodmagic.block.BlockIncenseAltar; import WayofTime.bloodmagic.block.BlockInputRoutingNode; import WayofTime.bloodmagic.block.BlockItemRoutingNode; import WayofTime.bloodmagic.block.BlockLifeEssence; @@ -35,6 +36,7 @@ import WayofTime.bloodmagic.item.block.ItemBlockRitualStone; import WayofTime.bloodmagic.tile.TileAlchemyArray; import WayofTime.bloodmagic.tile.TileAltar; import WayofTime.bloodmagic.tile.TileImperfectRitualStone; +import WayofTime.bloodmagic.tile.TileIncenseAltar; import WayofTime.bloodmagic.tile.TileMasterRitualStone; import WayofTime.bloodmagic.tile.TilePhantomBlock; import WayofTime.bloodmagic.tile.TilePlinth; @@ -61,6 +63,7 @@ public class ModBlocks public static Block spectralBlock; public static Block phantomBlock; public static Block soulForge; + public static Block incenseAltar; public static Block lifeEssence; @@ -95,6 +98,7 @@ public class ModBlocks inputRoutingNode = registerBlock(new BlockInputRoutingNode()); outputRoutingNode = registerBlock(new BlockOutputRoutingNode()); itemRoutingNode = registerBlock(new BlockItemRoutingNode()); + incenseAltar = registerBlock(new BlockIncenseAltar()); initTiles(); } @@ -114,6 +118,7 @@ public class ModBlocks GameRegistry.registerTileEntity(TileInputRoutingNode.class, Constants.Mod.MODID + ":" + TileInputRoutingNode.class.getSimpleName()); GameRegistry.registerTileEntity(TileOutputRoutingNode.class, Constants.Mod.MODID + ":" + TileOutputRoutingNode.class.getSimpleName()); GameRegistry.registerTileEntity(TileItemRoutingNode.class, Constants.Mod.MODID + ":" + TileItemRoutingNode.class.getSimpleName()); + GameRegistry.registerTileEntity(TileIncenseAltar.class, Constants.Mod.MODID + ":" + TileIncenseAltar.class.getSimpleName()); } public static void initRenders() @@ -151,6 +156,7 @@ public class ModBlocks renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(outputRoutingNode)); renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(inputRoutingNode)); renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(itemRoutingNode)); + renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(incenseAltar)); } private static Block registerBlock(Block block, Class itemBlock, String name) @@ -163,7 +169,8 @@ public class ModBlocks private static Block registerBlock(Block block, Class itemBlock) { - if (block.getRegistryName() == null) { + if (block.getRegistryName() == null) + { BloodMagic.instance.getLogger().error("Attempted to register Block {} without setting a registry name. Block will not be registered. Please report this.", block.getClass().getCanonicalName()); return block; } @@ -184,7 +191,8 @@ public class ModBlocks private static Block registerBlock(Block block) { - if (block.getRegistryName() == null) { + if (block.getRegistryName() == null) + { BloodMagic.instance.getLogger().error("Attempted to register Block {} without setting a registry name. Block will not be registered. Please report this.", block.getClass().getCanonicalName()); return null; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java b/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java index ed91e047..36390c76 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java @@ -24,6 +24,9 @@ public class TileIncenseAltar extends TileInventory implements ITickable public static int maxCheckRange = 5; public Map tranquilityMap = new HashMap(); + public double incenseAddition = 0; //Self-sacrifice is multiplied by 1 plus this value. + public int roadDistance = 0; //Number of road blocks laid down + public TileIncenseAltar() { super(1, "incenseAltar"); @@ -110,6 +113,10 @@ public class TileIncenseAltar extends TileInventory implements ITickable } } } + } else + { + roadDistance = currentDistance - 2; + break; } } @@ -126,5 +133,10 @@ public class TileIncenseAltar extends TileInventory implements ITickable return; } + double appliedTranquility = 0; + for (Entry entry : tranquilityMap.entrySet()) + { + appliedTranquility += Math.pow(entry.getValue(), 0.9); + } } } diff --git a/src/main/resources/assets/bloodmagic/blockstates/BlockIncenseAltar.json b/src/main/resources/assets/bloodmagic/blockstates/BlockIncenseAltar.json new file mode 100644 index 00000000..76048efc --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/BlockIncenseAltar.json @@ -0,0 +1,6 @@ +{ + "variants": { + "normal": { "model": "bloodmagic:BlockIncenseAltar" } + } +} + diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index 96779a40..100edee0 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -162,6 +162,7 @@ tile.BloodMagic.crystal.brick.name=Crystal Cluster Brick tile.BloodMagic.bloodLight.name=Blood Light tile.BloodMagic.spectralBlock.name=Spectral Block tile.BloodMagic.phantomBlock.name=Phantom Block +tile.BloodMagic.incenseAltar.name=Incense Altar tile.BloodMagic.teleposer.name=Teleposer tile.BloodMagic.soulForge.name=Hellfire Forge diff --git a/src/main/resources/assets/bloodmagic/models/block/BlockIncenseAltar.json b/src/main/resources/assets/bloodmagic/models/block/BlockIncenseAltar.json new file mode 100644 index 00000000..5525b347 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/block/BlockIncenseAltar.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "bloodmagic:blocks/IncenseAltar" + } +} + diff --git a/src/main/resources/assets/bloodmagic/models/item/BlockIncenseAltar.json b/src/main/resources/assets/bloodmagic/models/item/BlockIncenseAltar.json new file mode 100644 index 00000000..b884e1e8 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/item/BlockIncenseAltar.json @@ -0,0 +1,12 @@ +{ + "parent": "bloodmagic:block/BlockIncenseAltar", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} + + diff --git a/src/main/resources/assets/bloodmagic/textures/blocks/IncenseAltar.png b/src/main/resources/assets/bloodmagic/textures/blocks/IncenseAltar.png new file mode 100644 index 00000000..3346481a Binary files /dev/null and b/src/main/resources/assets/bloodmagic/textures/blocks/IncenseAltar.png differ