From cc1e11f09fef1459beef07588b16176614469c63 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Tue, 26 Jan 2016 19:39:39 -0500 Subject: [PATCH] Added some rudimentary path blocks for the tranquility altar - textures pending. --- .../WayofTime/bloodmagic/api/Constants.java | 3 +- .../api/util/helper/IncenseHelper.java | 8 ++-- .../util/helper/PlayerSacrificeHelper.java | 18 ++++---- .../WayofTime/bloodmagic/block/BlockPath.java | 44 +++++++++++++++++++ .../item/ItemSacrificialDagger.java | 6 +-- .../bloodmagic/item/block/ItemBlockPath.java | 27 ++++++++++++ .../bloodmagic/registry/ModBlocks.java | 7 +++ .../bloodmagic/registry/ModPotions.java | 4 ++ .../bloodmagic/tile/TileIncenseAltar.java | 26 +++++++++-- .../java/WayofTime/bloodmagic/util/Utils.java | 15 +++++++ .../bloodmagic/blockstates/BlockPath.json | 28 ++++++++++++ .../bloodmagic/models/block/BlockPath0.json | 7 +++ .../bloodmagic/models/block/BlockPath1.json | 7 +++ .../bloodmagic/models/block/BlockPath2.json | 7 +++ .../bloodmagic/models/item/BlockPath0.json | 10 +++++ .../bloodmagic/models/item/BlockPath1.json | 11 +++++ .../bloodmagic/models/item/BlockPath2.json | 11 +++++ 17 files changed, 216 insertions(+), 23 deletions(-) create mode 100644 src/main/java/WayofTime/bloodmagic/block/BlockPath.java create mode 100644 src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPath.java create mode 100644 src/main/resources/assets/bloodmagic/blockstates/BlockPath.json create mode 100644 src/main/resources/assets/bloodmagic/models/block/BlockPath0.json create mode 100644 src/main/resources/assets/bloodmagic/models/block/BlockPath1.json create mode 100644 src/main/resources/assets/bloodmagic/models/block/BlockPath2.json create mode 100644 src/main/resources/assets/bloodmagic/models/item/BlockPath0.json create mode 100644 src/main/resources/assets/bloodmagic/models/item/BlockPath1.json create mode 100644 src/main/resources/assets/bloodmagic/models/item/BlockPath2.json diff --git a/src/main/java/WayofTime/bloodmagic/api/Constants.java b/src/main/java/WayofTime/bloodmagic/api/Constants.java index 2c3c7481..12b0e378 100644 --- a/src/main/java/WayofTime/bloodmagic/api/Constants.java +++ b/src/main/java/WayofTime/bloodmagic/api/Constants.java @@ -226,7 +226,8 @@ public class Constants SOUL_FORGE("BlockSoulForge"), SPECTRAL("BlockSpectral"), TELEPOSER("BlockTeleposer"), - INCENSE_ALTAR("BlockIncenseAltar"); + INCENSE_ALTAR("BlockIncenseAltar"), + PATH("BlockPath"); @Getter private final String regName; diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java index 69d2cf69..4fd64661 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/IncenseHelper.java @@ -6,20 +6,20 @@ import net.minecraft.nbt.NBTTagCompound; public class IncenseHelper { - public static float getCurrentIncense(EntityPlayer player) + public static double getCurrentIncense(EntityPlayer player) { NBTTagCompound data = player.getEntityData(); if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) { - return data.getFloat(Constants.NBT.CURRENT_INCENSE); + return data.getDouble(Constants.NBT.CURRENT_INCENSE); } return 0; } - public static void setCurrentIncense(EntityPlayer player, float amount) + public static void setCurrentIncense(EntityPlayer player, double amount) { NBTTagCompound data = player.getEntityData(); - data.setFloat(Constants.NBT.CURRENT_INCENSE, amount); + data.setDouble(Constants.NBT.CURRENT_INCENSE, amount); } } \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java index ef83b088..5a9a2d5d 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerSacrificeHelper.java @@ -10,29 +10,29 @@ import net.minecraft.world.World; public class PlayerSacrificeHelper { - public static float scalingOfSacrifice = 0.001f; + public static float scalingOfSacrifice = 1f; public static int soulFrayDuration = 400; public static Potion soulFrayId; - public static float getPlayerIncense(EntityPlayer player) + public static double getPlayerIncense(EntityPlayer player) { return IncenseHelper.getCurrentIncense(player); } - public static void setPlayerIncense(EntityPlayer player, float amount) + public static void setPlayerIncense(EntityPlayer player, double amount) { IncenseHelper.setCurrentIncense(player, amount); } - public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment) + public static boolean incrementIncense(EntityPlayer player, double min, double incenseAddition, double increment) { - float amount = getPlayerIncense(player); - if (amount < min || amount >= max) + double amount = getPlayerIncense(player); + if (amount < min || amount >= incenseAddition) { return false; } - amount = amount + Math.min(increment, max - amount); + amount = amount + Math.min(increment, incenseAddition - amount); setPlayerIncense(player, amount); // System.out.println("Amount of incense: " + amount + ", Increment: " + @@ -48,7 +48,7 @@ public class PlayerSacrificeHelper return false; } - float amount = getPlayerIncense(player); + double amount = getPlayerIncense(player); if (amount >= 0) { @@ -73,7 +73,7 @@ public class PlayerSacrificeHelper return false; } - public static float getModifier(float amount) + public static double getModifier(double amount) { return 1 + amount * scalingOfSacrifice; } diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockPath.java b/src/main/java/WayofTime/bloodmagic/block/BlockPath.java new file mode 100644 index 00000000..51223a13 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/block/BlockPath.java @@ -0,0 +1,44 @@ +package WayofTime.bloodmagic.block; + +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.incense.IIncensePath; +import WayofTime.bloodmagic.block.base.BlockString; + +public class BlockPath extends BlockString implements IIncensePath +{ + public static final String[] names = { "wood", "stone", "wornStone" }; + + public BlockPath() + { + super(Material.rock, names); + + setUnlocalizedName(Constants.Mod.MODID + ".path."); + setRegistryName(Constants.BloodMagicBlock.PATH.getRegName()); + setCreativeTab(BloodMagic.tabBloodMagic); + setHardness(2.0F); + setResistance(5.0F); + setStepSound(soundTypeStone); + setHarvestLevel("pickaxe", 0); + } + + @Override + public int getLevelOfPath(World world, BlockPos pos, IBlockState state) + { + switch (this.getMetaFromState(state)) + { + case 0: + return 2; + case 1: + return 4; + case 2: + return 6; + default: + return 0; + } + } +} diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java b/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java index 9996f8da..17329c3d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java @@ -116,13 +116,9 @@ public class ItemSacrificialDagger extends Item double posY = player.posY; double posZ = player.posZ; world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); - float f = 1.0F; - float f1 = f * 0.6F + 0.4F; - float f2 = f * f * 0.7F - 0.5F; - float f3 = f * f * 0.6F - 0.7F; for (int l = 0; l < 8; ++l) - world.spawnParticle(EnumParticleTypes.REDSTONE, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3); + world.spawnParticle(EnumParticleTypes.REDSTONE, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), 0, 0, 0); if (!world.isRemote && PlayerHelper.isFakePlayer(player)) return stack; diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPath.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPath.java new file mode 100644 index 00000000..a2e8c966 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPath.java @@ -0,0 +1,27 @@ +package WayofTime.bloodmagic.item.block; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import WayofTime.bloodmagic.block.BlockPath; + +public class ItemBlockPath extends ItemBlock +{ + public ItemBlockPath(Block block) + { + super(block); + setHasSubtypes(true); + } + + @Override + public String getUnlocalizedName(ItemStack stack) + { + return super.getUnlocalizedName(stack) + BlockPath.names[stack.getItemDamage()]; + } + + @Override + public int getMetadata(int meta) + { + return meta; + } +} \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java index a3e1094c..c68b6b31 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java @@ -19,6 +19,7 @@ import WayofTime.bloodmagic.block.BlockItemRoutingNode; import WayofTime.bloodmagic.block.BlockLifeEssence; import WayofTime.bloodmagic.block.BlockMasterRoutingNode; import WayofTime.bloodmagic.block.BlockOutputRoutingNode; +import WayofTime.bloodmagic.block.BlockPath; import WayofTime.bloodmagic.block.BlockPedestal; import WayofTime.bloodmagic.block.BlockPhantom; import WayofTime.bloodmagic.block.BlockRitualController; @@ -30,6 +31,7 @@ import WayofTime.bloodmagic.block.BlockTestSpellBlock; import WayofTime.bloodmagic.item.block.ItemBlockBloodRune; import WayofTime.bloodmagic.item.block.ItemBlockBloodStoneBrick; import WayofTime.bloodmagic.item.block.ItemBlockCrystal; +import WayofTime.bloodmagic.item.block.ItemBlockPath; import WayofTime.bloodmagic.item.block.ItemBlockPedestal; import WayofTime.bloodmagic.item.block.ItemBlockRitualController; import WayofTime.bloodmagic.item.block.ItemBlockRitualStone; @@ -69,6 +71,7 @@ public class ModBlocks public static Block crystal; public static Block bloodStoneBrick; + public static Block pathBlock; public static Block masterRoutingNode; public static Block inputRoutingNode; @@ -99,6 +102,7 @@ public class ModBlocks outputRoutingNode = registerBlock(new BlockOutputRoutingNode()); itemRoutingNode = registerBlock(new BlockItemRoutingNode()); incenseAltar = registerBlock(new BlockIncenseAltar()); + pathBlock = registerBlock(new BlockPath(), ItemBlockPath.class); initTiles(); } @@ -157,6 +161,9 @@ public class ModBlocks renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(inputRoutingNode)); renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(itemRoutingNode)); renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(incenseAltar)); + renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(pathBlock), 0); + renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(pathBlock), 1); + renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(pathBlock), 2); } private static Block registerBlock(Block block, Class itemBlock, String name) diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java b/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java index b56aa605..2f63b90f 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModPotions.java @@ -2,6 +2,7 @@ package WayofTime.bloodmagic.registry; import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; +import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper; import WayofTime.bloodmagic.potion.PotionBloodMagic; import WayofTime.bloodmagic.potion.PotionEventHandlers; @@ -13,6 +14,7 @@ public class ModPotions public static Potion whirlwind; public static Potion planarBinding; public static Potion soulSnare; + public static Potion soulFray; public static void init() { @@ -33,6 +35,8 @@ public class ModPotions whirlwind = new PotionBloodMagic("Whirlwind", new ResourceLocation("whirlwind"), false, 0, 0, 0); planarBinding = new PotionBloodMagic("Planar Binding", new ResourceLocation("planarBinding"), false, 0, 0, 0); soulSnare = new PotionBloodMagic("Soul Snare", new ResourceLocation("soulSnare"), false, 0xFFFFFF, 0, 0); + soulFray = new PotionBloodMagic("Soul Fray", new ResourceLocation("soulFray"), true, 0xFFFFFF, 0, 0); + PlayerSacrificeHelper.soulFrayId = soulFray; // heavyHeart = new PotionBloodMagic("Heavy Heart", new // ResourceLocation(resourceLocation + // heavyHeart.getName().toLowerCase()), true, 0, 0, 0); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java b/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java index 17c81b7b..acb248d9 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileIncenseAltar.java @@ -17,6 +17,8 @@ import WayofTime.bloodmagic.api.incense.IIncensePath; import WayofTime.bloodmagic.api.incense.IncenseTranquilityRegistry; import WayofTime.bloodmagic.api.incense.TranquilityStack; import WayofTime.bloodmagic.api.ritual.AreaDescriptor; +import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper; +import WayofTime.bloodmagic.incense.IncenseAltarHandler; public class TileIncenseAltar extends TileInventory implements ITickable { @@ -42,12 +44,21 @@ public class TileIncenseAltar extends TileInventory implements ITickable return; } + if (worldObj.getTotalWorldTime() % 100 == 0) + { + recheckConstruction(); + } + + for (EntityPlayer player : playerList) + { + PlayerSacrificeHelper.incrementIncense(player, 0, incenseAddition, incenseAddition / 100); //TODO: Figure out what the hell you are doing. + } } public void recheckConstruction() { //TODO: Check the physical construction of the incense altar to determine the maximum length. - int maxLength = 3; //Max length of the path. The path starts two blocks away from the center block. + int maxLength = 11; //Max length of the path. The path starts two blocks away from the center block. int yOffset = 0; Map tranquilityMap = new HashMap(); @@ -56,12 +67,12 @@ public class TileIncenseAltar extends TileInventory implements ITickable { boolean canFormRoad = false; - level: for (int i = -maxCheckRange + yOffset; i <= maxCheckRange + yOffset; i++) + for (int i = -maxCheckRange + yOffset; i <= maxCheckRange + yOffset; i++) { BlockPos verticalPos = pos.add(0, i, 0); canFormRoad = true; - for (EnumFacing horizontalFacing : EnumFacing.HORIZONTALS) + level: for (EnumFacing horizontalFacing : EnumFacing.HORIZONTALS) { BlockPos facingOffsetPos = verticalPos.offset(horizontalFacing, currentDistance); for (int j = -1; j <= 1; j++) @@ -80,6 +91,7 @@ public class TileIncenseAltar extends TileInventory implements ITickable if (canFormRoad) { yOffset = i; + break; } } @@ -94,7 +106,7 @@ public class TileIncenseAltar extends TileInventory implements ITickable break; //TODO: Can make this just set j to currentDistance to speed it up. } - for (int y = -1 + yOffset; y <= 1 + yOffset; y++) + for (int y = 0 + yOffset; y <= 2 + yOffset; y++) { BlockPos offsetPos = pos.add(i, yOffset, j); IBlockState state = worldObj.getBlockState(offsetPos); @@ -138,5 +150,11 @@ public class TileIncenseAltar extends TileInventory implements ITickable { appliedTranquility += Math.sqrt(entry.getValue()); } + +// System.out.println("Tranquility: " + appliedTranquility); + + double bonus = IncenseAltarHandler.getIncenseBonusFromComponents(worldObj, pos, appliedTranquility); +// System.out.println("Incense bonus: " + bonus); + incenseAddition = bonus; } } diff --git a/src/main/java/WayofTime/bloodmagic/util/Utils.java b/src/main/java/WayofTime/bloodmagic/util/Utils.java index 1501680a..a1c9062f 100644 --- a/src/main/java/WayofTime/bloodmagic/util/Utils.java +++ b/src/main/java/WayofTime/bloodmagic/util/Utils.java @@ -12,6 +12,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumFacing; @@ -24,6 +25,20 @@ import net.minecraftforge.fluids.IFluidBlock; public class Utils { + public static NBTTagCompound getPersistentDataTag(EntityPlayer player) + { + NBTTagCompound forgeData = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + NBTTagCompound beaconData = forgeData.getCompoundTag("BloodMagic"); + + //Creates/sets the tags if they don't exist + if (!forgeData.hasKey("BloodMagic")) + forgeData.setTag("BloodMagic", beaconData); + if (!player.getEntityData().hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + player.getEntityData().setTag(EntityPlayer.PERSISTED_NBT_TAG, forgeData); + + return beaconData; + } + public static boolean isInteger(String integer) { try diff --git a/src/main/resources/assets/bloodmagic/blockstates/BlockPath.json b/src/main/resources/assets/bloodmagic/blockstates/BlockPath.json new file mode 100644 index 00000000..72aab233 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/BlockPath.json @@ -0,0 +1,28 @@ +{ + "forge_marker": 1, + "defaults": { + "textures": { }, + "model": "cube_all", + "uvlock": true + }, + "variants": { + "type": { + "wood": { + "textures": { + "all": "bloodmagic:blocks/LargeBloodStoneBrick" + } + }, + "stone": { + "textures": { + "all": "bloodmagic:blocks/BloodStoneBrick" + } + }, + "wornStone": { + "textures": { + "all": "bloodmagic:blocks/BloodStoneBrick" + } + } + } + } +} + diff --git a/src/main/resources/assets/bloodmagic/models/block/BlockPath0.json b/src/main/resources/assets/bloodmagic/models/block/BlockPath0.json new file mode 100644 index 00000000..03b1e662 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/block/BlockPath0.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "bloodmagic:blocks/LargeBloodStoneBrick" + } +} + diff --git a/src/main/resources/assets/bloodmagic/models/block/BlockPath1.json b/src/main/resources/assets/bloodmagic/models/block/BlockPath1.json new file mode 100644 index 00000000..b969d7f3 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/block/BlockPath1.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "bloodmagic:blocks/BloodStoneBrick" + } +} + diff --git a/src/main/resources/assets/bloodmagic/models/block/BlockPath2.json b/src/main/resources/assets/bloodmagic/models/block/BlockPath2.json new file mode 100644 index 00000000..b969d7f3 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/block/BlockPath2.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "bloodmagic:blocks/BloodStoneBrick" + } +} + diff --git a/src/main/resources/assets/bloodmagic/models/item/BlockPath0.json b/src/main/resources/assets/bloodmagic/models/item/BlockPath0.json new file mode 100644 index 00000000..ce8cdb83 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/item/BlockPath0.json @@ -0,0 +1,10 @@ +{ + "parent": "bloodmagic:block/BlockPath0", + "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/models/item/BlockPath1.json b/src/main/resources/assets/bloodmagic/models/item/BlockPath1.json new file mode 100644 index 00000000..27715321 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/item/BlockPath1.json @@ -0,0 +1,11 @@ +{ + "parent": "bloodmagic:block/BlockPath1", + "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/models/item/BlockPath2.json b/src/main/resources/assets/bloodmagic/models/item/BlockPath2.json new file mode 100644 index 00000000..6a23c1fe --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/item/BlockPath2.json @@ -0,0 +1,11 @@ +{ + "parent": "bloodmagic:block/BlockPath2", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} +