From 8b024e17033223756fd38ad04b2c4a7fff427e4b Mon Sep 17 00:00:00 2001 From: WayofTime Date: Thu, 7 Jan 2016 16:36:52 -0500 Subject: [PATCH] Added Soul Forge block and WIP model --- .../bloodmagic/block/BlockSoulForge.java | 34 ++-- .../bloodmagic/item/soul/ItemSoulSword.java | 60 ++++++- .../bloodmagic/registry/ModBlocks.java | 3 + .../blockstates/BlockSoulForge.json | 20 +++ .../assets/bloodmagic/lang/en_US.lang | 1 + .../models/block/BlockSoulForge.json | 9 + .../models/block/sub/BlockSoulForge.json | 160 ++++++++++++++++++ .../models/item/BlockSoulForge.json | 13 ++ 8 files changed, 287 insertions(+), 13 deletions(-) create mode 100644 src/main/resources/assets/bloodmagic/blockstates/BlockSoulForge.json create mode 100644 src/main/resources/assets/bloodmagic/models/block/BlockSoulForge.json create mode 100644 src/main/resources/assets/bloodmagic/models/block/sub/BlockSoulForge.json create mode 100644 src/main/resources/assets/bloodmagic/models/item/BlockSoulForge.json diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java b/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java index 412b8396..3bb7b4b0 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockSoulForge.java @@ -1,14 +1,9 @@ package WayofTime.bloodmagic.block; -import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.api.Constants; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; public class BlockSoulForge extends Block { @@ -16,7 +11,7 @@ public class BlockSoulForge extends Block { super(Material.iron); - setUnlocalizedName(Constants.Mod.MODID + ".soulforge."); + setUnlocalizedName(Constants.Mod.MODID + ".soulforge"); setHardness(2.0F); setResistance(5.0F); setStepSound(soundTypeMetal); @@ -25,11 +20,26 @@ public class BlockSoulForge extends Block } @Override - public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean isOpaqueCube() { - if (world.isRemote) - return false; - return false; } + + @Override + public boolean isFullCube() + { + return false; + } + + @Override + public boolean isVisuallyOpaque() + { + return false; + } + + @Override + public int getRenderType() + { + return 3; + } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSword.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSword.java index c18e77d9..79381ff3 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSword.java @@ -19,6 +19,7 @@ import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.soul.ISoul; import WayofTime.bloodmagic.api.soul.ISoulWeapon; +import WayofTime.bloodmagic.api.soul.PlayerSoulHandler; import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.registry.ModItems; import WayofTime.bloodmagic.util.helper.TextHelper; @@ -28,6 +29,10 @@ import com.google.common.collect.Multimap; public class ItemSoulSword extends ItemSword implements ISoulWeapon { + public int[] soulBracket = new int[] { 16 }; + public double[] damageAdded = new double[] { 1 }; + public double[] soulDrainPerSwing = new double[] { 0.1 }; + public ItemSoulSword() { super(ModItems.soulToolMaterial); @@ -46,12 +51,33 @@ public class ItemSoulSword extends ItemSword implements ISoulWeapon if (getActivated(stack)) { - setDamageOfActivatedSword(stack, 7); + double soulsRemaining = PlayerSoulHandler.getTotalSouls(player); + int level = getLevel(stack, soulsRemaining); + + double drain = level >= 0 ? soulDrainPerSwing[level] : 0; + double extraDamage = level >= 0 ? damageAdded[level] : 0; + + setDrainOfActivatedSword(stack, drain); + setDamageOfActivatedSword(stack, 7 + extraDamage); } return stack; } + private int getLevel(ItemStack stack, double soulsRemaining) + { + int lvl = -1; + for (int i = 0; i < soulBracket.length; i++) + { + if (soulsRemaining >= soulBracket[i]) + { + lvl = i; + } + } + + return lvl; + } + @Override public EnumAction getItemUseAction(ItemStack stack) { @@ -78,6 +104,21 @@ public class ItemSoulSword extends ItemSword implements ISoulWeapon { if (getActivated(stack)) { + double drain = this.getDrainOfActivatedSword(stack); + if (drain > 0) + { + double soulsRemaining = PlayerSoulHandler.getTotalSouls(player); + + if (drain > soulsRemaining) + { + setActivated(stack, false); + return false; + } else + { + PlayerSoulHandler.consumeSouls(player, drain); + } + } + return super.onLeftClickEntity(stack, player, entity); } @@ -128,6 +169,23 @@ public class ItemSoulSword extends ItemSword implements ISoulWeapon tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage); } + public double getDrainOfActivatedSword(ItemStack stack) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN); + } + + public void setDrainOfActivatedSword(ItemStack stack, double drain) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain); + } + @Override public Multimap getAttributeModifiers(ItemStack stack) { diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java index 7ac880f8..41eb38a1 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java @@ -25,6 +25,7 @@ public class ModBlocks public static Block alchemyArray; public static Block spectralBlock; public static Block phantomBlock; + public static Block soulForge; public static Block lifeEssence; @@ -47,6 +48,7 @@ public class ModBlocks alchemyArray = registerBlock(new BlockAlchemyArray()); spectralBlock = registerBlock(new BlockSpectral()); phantomBlock = registerBlock(new BlockPhantom()); + soulForge = registerBlock(new BlockSoulForge()); crystal = registerBlock(new BlockCrystal(), ItemBlockCrystal.class); bloodStoneBrick = registerBlock(new BlockBloodStoneBrick(), ItemBlockBloodStoneBrick.class); @@ -95,6 +97,7 @@ public class ModBlocks renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(alchemyArray)); renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(spectralBlock)); renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(phantomBlock)); + renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(soulForge)); } private static Block registerBlock(Block block, Class itemBlock, String name) diff --git a/src/main/resources/assets/bloodmagic/blockstates/BlockSoulForge.json b/src/main/resources/assets/bloodmagic/blockstates/BlockSoulForge.json new file mode 100644 index 00000000..cd0357e7 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/BlockSoulForge.json @@ -0,0 +1,20 @@ +{ + "forge_marker": 1, + "defaults": { + "textures": { + "base": "minecraft:blocks/iron_block", + "base_bottom": "minecraft:blocks/gold_block", + "glass": "minecraft:blocks/glass", + "attachment": "minecraft:blocks/stone" + }, + "uvlock": true + }, + "variants": { + "normal": { + "model": "bloodmagic:sub/BlockSoulForge", + "submodel": { + + } + } + } +} diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index 0a10d2b5..1b82cc3b 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -147,6 +147,7 @@ tile.BloodMagic.spectralBlock.name=Spectral Block tile.BloodMagic.phantomBlock.name=Phantom Block tile.BloodMagic.teleposer.name=Teleposer +tile.BloodMagic.soulforge.name=Soul Forge # Tooltips tooltip.BloodMagic.orb.desc=Stores raw Life Essence diff --git a/src/main/resources/assets/bloodmagic/models/block/BlockSoulForge.json b/src/main/resources/assets/bloodmagic/models/block/BlockSoulForge.json new file mode 100644 index 00000000..cd179dad --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/block/BlockSoulForge.json @@ -0,0 +1,9 @@ +{ + "parent": "bloodmagic:block/sub/BlockSoulForge", + "textures": { + "base": "minecraft:blocks/iron_block", + "base_bottom": "minecraft:blocks/gold_block", + "glass": "minecraft:blocks/glass", + "attachment": "minecraft:blocks/stone" + } +} diff --git a/src/main/resources/assets/bloodmagic/models/block/sub/BlockSoulForge.json b/src/main/resources/assets/bloodmagic/models/block/sub/BlockSoulForge.json new file mode 100644 index 00000000..6d674e78 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/block/sub/BlockSoulForge.json @@ -0,0 +1,160 @@ +{ + "textures": { + "particle": "#base" + }, + "elements": [ + { + "from": [ 2, 0, 2 ], + "to": [ 6, 3, 6 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + }, + "__comment": "These are the feet of the model" + }, + { + "from": [ 10, 0, 10 ], + "to": [ 14, 3, 14 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + } + }, + { + "from": [ 2, 0, 10 ], + "to": [ 6, 3, 14 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + } + }, + { + "from": [ 10, 0, 2 ], + "to": [ 14, 3, 6 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + } + }, + { + "from": [ 3, 3, 3 ], + "to": [ 13, 5, 13 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + }, + "__comment": "Base of the model" + }, + { + "from": [ 1, 5, 1 ], + "to": [ 15, 8, 15 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + }, + "__comment": "Base of the model" + }, + { + "from": [ 0, 8, 0 ], + "to": [ 16, 10, 16 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + }, + "__comment": "Base of the model" + }, + { + "from": [ 0, 10, 0 ], + "to": [ 4, 12, 4 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + }, + "__comment": "Space for the item" + }, + { + "from": [ 12, 10, 12 ], + "to": [ 16, 12, 16 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + }, + "__comment": "Space for the item" + }, + { + "from": [ 0, 10, 12 ], + "to": [ 4, 12, 16 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + }, + "__comment": "Space for the item" + }, + { + "from": [ 12, 10, 0 ], + "to": [ 16, 12, 4 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base" } + }, + "__comment": "Space for the item" + }, + { + "from": [ 4, 10, 4 ], + "to": [ 12, 11, 12 ], + "faces": { + "down": { "uv": [ 3, 0, 4.5, 1.5 ], "texture": "#base_bottom" }, + "up": { "uv": [ 1.5, 0, 3, 1.5 ], "texture": "#base_bottom" }, + "north": { "uv": [ 1.5, 1.5, 3, 3 ], "texture": "#base_bottom" }, + "south": { "uv": [ 4.5, 1.5, 6, 3 ], "texture": "#base_bottom" }, + "west": { "uv": [ 3, 1.5, 4.5, 3 ], "texture": "#base_bottom" }, + "east": { "uv": [ 0, 1.5, 1.5, 3 ], "texture": "#base_bottom" } + }, + "__comment": "Space for the item" + } + ] +} diff --git a/src/main/resources/assets/bloodmagic/models/item/BlockSoulForge.json b/src/main/resources/assets/bloodmagic/models/item/BlockSoulForge.json new file mode 100644 index 00000000..d8a89294 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/item/BlockSoulForge.json @@ -0,0 +1,13 @@ +{ + "parent": "bloodmagic:block/BlockSoulForge", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} + + +