From e0b073b8b70e8f298c7103206680a42ae82228ee Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 22 Nov 2015 13:43:15 -0800 Subject: [PATCH 1/3] Cleanup the SoulNetwork a bit. Should work now? --- .../WayofTime/bloodmagic/api/NBTHolder.java | 2 +- .../api/event/SoulNetworkEvent.java | 2 +- .../bloodmagic/api/network/SoulNetwork.java | 107 +++++++++++++----- .../api/util/helper/NetworkHelper.java | 78 ++++++++----- .../bloodmagic/item/ItemBindable.java | 2 +- .../bloodmagic/item/ItemBloodOrb.java | 4 +- .../item/sigil/ItemSigilDivination.java | 4 +- 7 files changed, 130 insertions(+), 69 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/api/NBTHolder.java b/src/main/java/WayofTime/bloodmagic/api/NBTHolder.java index 755f45c4..ec80694c 100644 --- a/src/main/java/WayofTime/bloodmagic/api/NBTHolder.java +++ b/src/main/java/WayofTime/bloodmagic/api/NBTHolder.java @@ -13,7 +13,7 @@ public class NBTHolder { public static final String NBT_COORDX = "xCoord"; public static final String NBT_COORDY = "yCoord"; public static final String NBT_COORDZ = "zCoord"; - public static final String NBT_MAXORB = "maxOrb"; + public static final String NBT_ORBTIER = "orbTier"; public static final String NBT_CURRENTESSENCE = "currentEssence"; public static final String NBT_CURRENTRITUAL = "currentRitual"; public static final String NBT_RUNNING = "isRunning"; diff --git a/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java b/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java index ee2ee53f..e25d2da5 100644 --- a/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java +++ b/src/main/java/WayofTime/bloodmagic/api/event/SoulNetworkEvent.java @@ -7,7 +7,7 @@ import net.minecraftforge.fml.common.eventhandler.Event; public class SoulNetworkEvent extends Event { - public String ownerName; + public final String ownerName; public int syphon; public SoulNetworkEvent(String ownerName, int syphon) { diff --git a/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java b/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java index 3ae84d57..cedd2254 100644 --- a/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java +++ b/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java @@ -2,12 +2,19 @@ package WayofTime.bloodmagic.api.network; import WayofTime.bloodmagic.api.BloodMagicAPI; import WayofTime.bloodmagic.api.NBTHolder; +import WayofTime.bloodmagic.api.event.AddToNetworkEvent; import WayofTime.bloodmagic.api.event.SoulNetworkEvent; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; +import com.google.common.base.Strings; +import com.sun.istack.internal.Nullable; import lombok.Getter; import lombok.Setter; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.Event; @@ -17,33 +24,61 @@ import net.minecraftforge.fml.common.eventhandler.Event; public class SoulNetwork extends WorldSavedData { private int currentEssence; - private int maxOrb; + private int orbTier; + @Nullable private final EntityPlayer player; public SoulNetwork(String name) { super(name); currentEssence = 0; - maxOrb = 0; + orbTier = 0; player = PlayerHelper.getPlayerFromUsername(name); } @Override public void readFromNBT(NBTTagCompound nbttagcompound) { currentEssence = nbttagcompound.getInteger(NBTHolder.NBT_CURRENTESSENCE); - maxOrb = nbttagcompound.getInteger(NBTHolder.NBT_MAXORB); + orbTier = nbttagcompound.getInteger(NBTHolder.NBT_ORBTIER); } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setInteger(NBTHolder.NBT_CURRENTESSENCE, currentEssence); - nbttagcompound.setInteger(NBTHolder.NBT_MAXORB, maxOrb); + nbttagcompound.setInteger(NBTHolder.NBT_ORBTIER, orbTier); + } + + public int addLifeEssence(int toAdd, int maximum) { + AddToNetworkEvent event = new AddToNetworkEvent(mapName, toAdd, maximum); + + if(MinecraftForge.EVENT_BUS.post(event)) + return 0; + + if (MinecraftServer.getServer() == null) + return 0; + + World world = MinecraftServer.getServer().worldServers[0]; + SoulNetwork data = (SoulNetwork) world.loadItemData(SoulNetwork.class, event.ownerNetwork); + + if (data == null) { + data = new SoulNetwork(event.ownerNetwork); + world.setItemData(event.ownerNetwork, data); + } + + int currEss = data.getCurrentEssence(); + + if (currEss >= event.maximum) + return 0; + + int newEss = Math.min(event.maximum, currEss + event.addedAmount); + if(event.getResult() != Event.Result.DENY) + data.setCurrentEssence(newEss); + + return newEss - currEss; } /** - * Used to syphon LP from the network. - * - * @return - . + * Used to syphon LP from the network */ public int syphon(int syphon) { if (getCurrentEssence() >= syphon) { @@ -55,44 +90,54 @@ public class SoulNetwork extends WorldSavedData { return 0; } + /** + * If the player exists on the server, syphon the given amount of LP from the player's LP network and + * damage for any remaining LP required. + * + * Always returns false on the client side. + * + * @return - Whether the action should be performed. + */ public boolean syphonAndDamage(int toSyphon) { -// SoulNetworkEvent.PlayerDrainNetworkEvent event = new SoulNetworkEvent.PlayerDrainNetworkEvent(getPlayer(), mapName, syphon); -// -// if (MinecraftForge.EVENT_BUS.post(event)) -// return false; -// -// syphon(syphon); -// int drain = Math.max(0, getCurrentEssence() - syphon); -// -// if (drain == 0 || event.shouldDamage) -// hurtPlayer(event.syphon); -// -// return event.getResult() != Event.Result.DENY; - - if (player.worldObj.isRemote) + if (getPlayer().worldObj.isRemote) return false; - int drain = syphon(toSyphon); - hurtPlayer(toSyphon - drain); + if (!Strings.isNullOrEmpty(mapName)) { + SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, mapName, getPlayer().getHeldItem(), toSyphon); + + if(MinecraftForge.EVENT_BUS.post(event)) + return false; + + int drainAmount = syphon(event.syphon); + + if(drainAmount == 0 || event.shouldDamage) + hurtPlayer(event.syphon); + + return event.getResult() != Event.Result.DENY; + } + + int amount = syphon(toSyphon); + hurtPlayer(toSyphon - amount); return true; } public void hurtPlayer(int syphon) { + getPlayer().addPotionEffect(new PotionEffect(Potion.confusion.getId(), 20)); if (syphon < 100 && syphon > 0) { - if (!player.capabilities.isCreativeMode) { - player.setHealth((player.getHealth() - 1)); + if (!getPlayer().capabilities.isCreativeMode) { + getPlayer().setHealth((getPlayer().getHealth() - 1)); - if (player.getHealth() <= 0.0005f) - player.onDeath(BloodMagicAPI.getDamageSource()); + if (getPlayer().getHealth() <= 0.0005f) + getPlayer().onDeath(BloodMagicAPI.getDamageSource()); } } else if (syphon >= 100) { - if (!player.capabilities.isCreativeMode) { + if (!getPlayer().capabilities.isCreativeMode) { for (int i = 0; i < ((syphon + 99) / 100); i++) { - player.setHealth((player.getHealth() - 1)); + getPlayer().setHealth((getPlayer().getHealth() - 1)); - if (player.getHealth() <= 0.0005f) { - player.onDeath(BloodMagicAPI.getDamageSource()); + if (getPlayer().getHealth() <= 0.0005f) { + getPlayer().onDeath(BloodMagicAPI.getDamageSource()); break; } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java index 69eb9562..66c23679 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/NetworkHelper.java @@ -28,8 +28,47 @@ public class NetworkHelper { return network; } + public static int getCurrentMaxOrb(SoulNetwork soulNetwork) { + return soulNetwork.getOrbTier(); + } + // Syphon + /** + * Handles null-checking the player for you. + * + * @return - Whether the action should be performed. + */ + public static boolean syphonAndDamage(SoulNetwork soulNetwork, int toSyphon) { + if (soulNetwork.getPlayer() == null) { + soulNetwork.syphon(toSyphon); + return true; + } + + return soulNetwork.syphonAndDamage(toSyphon); + } + + public static boolean syphonFromContainer(ItemStack stack, SoulNetwork soulNetwork, int toSyphon) { + stack = NBTHolder.checkNBT(stack); + String ownerName = stack.getTagCompound().getString(NBTHolder.NBT_OWNER); + + if (Strings.isNullOrEmpty(ownerName)) + return false; + + SoulNetworkEvent.ItemDrainInContainerEvent event = new SoulNetworkEvent.ItemDrainInContainerEvent(stack, ownerName, toSyphon); + + return !(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) && soulNetwork.syphon(event.syphon) >= toSyphon; + } + + // Set + + public static void setMaxOrbToMax(SoulNetwork soulNetwork, int maxOrb) { + soulNetwork.setOrbTier(Math.max(maxOrb, soulNetwork.getOrbTier())); + soulNetwork.markDirty(); + } + + // TODO - Remove everything below. It is deprecated and should not be used. + /** * Master method used to syphon from the player's network, and will damage them accordingly if they do not have enough LP. * Does not drain on the client side. @@ -39,6 +78,7 @@ public class NetworkHelper { * @param syphon * @return True if the action should be executed and false if it should not. Always returns false if client-sided. */ + @Deprecated public static boolean syphonAndDamageFromNetwork(ItemStack stack, EntityPlayer player, int syphon) { if (player.worldObj.isRemote) return false; @@ -68,6 +108,7 @@ public class NetworkHelper { return true; } + @Deprecated public static boolean syphonFromNetworkWhileInContainer(ItemStack stack, int syphon) { stack = NBTHolder.checkNBT(stack); String ownerName = stack.getTagCompound().getString(NBTHolder.NBT_OWNER); @@ -83,6 +124,7 @@ public class NetworkHelper { return syphonFromNetwork(event.ownerName, event.syphon) >= syphon; } + @Deprecated public static int syphonFromNetwork(ItemStack stack, int syphon) { stack = NBTHolder.checkNBT(stack); String ownerName = stack.getTagCompound().getString(NBTHolder.NBT_OWNER); @@ -92,6 +134,7 @@ public class NetworkHelper { return 0; } + @Deprecated public static int syphonFromNetwork(String ownerName, int syphon) { if (MinecraftServer.getServer() == null) return 0; @@ -120,6 +163,7 @@ public class NetworkHelper { * * @return amount added to the network */ + @Deprecated public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) { AddToNetworkEvent event = new AddToNetworkEvent(ownerName, addedEssence, maximum); @@ -151,6 +195,7 @@ public class NetworkHelper { // Get + @Deprecated public static int getCurrentEssence(String ownerName) { if (MinecraftServer.getServer() == null) return 0; @@ -168,6 +213,7 @@ public class NetworkHelper { // Do damage + @Deprecated public static void hurtPlayer(EntityPlayer user, int energySyphoned) { if (energySyphoned < 100 && energySyphoned > 0) { if (!user.capabilities.isCreativeMode) { @@ -190,41 +236,11 @@ public class NetworkHelper { } } + @Deprecated public static void hurtPlayer(EntityPlayer user, float damage) { if (!user.capabilities.isCreativeMode) { user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); user.setHealth((user.getHealth() - damage)); } } - - public static void setMaxOrbToMax(String ownerName, int maxOrb) { - if (MinecraftServer.getServer() == null) - return; - - World world = MinecraftServer.getServer().worldServers[0]; - SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName); - - if (network == null) { - network = new SoulNetwork(ownerName); - world.setItemData(ownerName, network); - } - - network.setMaxOrb(Math.max(maxOrb, network.getMaxOrb())); - network.markDirty(); - } - - public static int getCurrentMaxOrb(String ownerName) { - if (MinecraftServer.getServer() == null) - return 0; - - World world = MinecraftServer.getServer().worldServers[0]; - SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName); - - if (network == null) { - network = new SoulNetwork(ownerName); - world.setItemData(ownerName, network); - } - - return network.getMaxOrb(); - } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBindable.java b/src/main/java/WayofTime/bloodmagic/item/ItemBindable.java index 01546785..71489232 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBindable.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBindable.java @@ -58,7 +58,7 @@ public class ItemBindable extends Item implements IBindable { public static boolean syphonBatteries(ItemStack stack, EntityPlayer player, int damageToBeDone) { if (!player.worldObj.isRemote) { - return NetworkHelper.getSoulNetwork(BindableHelper.getOwnerName(stack), player.worldObj).syphonAndDamage(damageToBeDone); + return NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(BindableHelper.getOwnerName(stack), player.worldObj), damageToBeDone); } else { double posX = player.posX; double posY = player.posY; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java index 710f0066..91499b67 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java @@ -63,9 +63,9 @@ public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable { return stack; if(stack.getTagCompound().getString(NBTHolder.NBT_OWNER).equals(PlayerHelper.getUsernameFromPlayer(player))) - NetworkHelper.setMaxOrbToMax(stack.getTagCompound().getString(NBTHolder.NBT_OWNER), getOrbLevel(stack.getItemDamage())); + NetworkHelper.setMaxOrbToMax(NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(NBTHolder.NBT_OWNER), world), getOrbLevel(stack.getItemDamage())); - NetworkHelper.addCurrentEssenceToMaximum(stack.getTagCompound().getString(NBTHolder.NBT_OWNER), 200, getMaxEssence(stack.getItemDamage())); + NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(NBTHolder.NBT_OWNER), world).addLifeEssence(200, getMaxEssence(stack.getItemDamage())); hurtPlayer(player, 200); return stack; } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java index 1bf51737..84eb3414 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java @@ -24,9 +24,9 @@ public class ItemSigilDivination extends ItemSigilBase implements ISigil, IAltar public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { super.onItemRightClick(stack, world, player); - if (!world.isRemote && syphonBatteries(stack, player, getEnergyUsed())) { + if (!world.isRemote) { MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false); - int currentEssence = NetworkHelper.getCurrentEssence(BindableHelper.getOwnerName(stack)); + int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerName(stack), world).getCurrentEssence(); if (position == null) { ChatUtil.sendNoSpam(player, new ChatComponentText(TextHelper.localize(tooltipBase + "currentEssence", currentEssence))); From a12c72092ac02ffbd6e4a7278371c8b8f81863ad Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 22 Nov 2015 14:02:56 -0800 Subject: [PATCH 2/3] TileAltar now uses new SN methods --- src/main/java/WayofTime/bloodmagic/tile/TileAltar.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java b/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java index d654abcf..7659fba4 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAltar.java @@ -110,7 +110,6 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay else tagCompound.setString("Empty", ""); - if (fluidOutput != null) tagCompound.setInteger("outputAmount", fluidOutput.amount); @@ -280,7 +279,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay if (fluid != null && fluid.amount >= 1) { int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount); - int drain = NetworkHelper.addCurrentEssenceToMaximum(ownerName, liquidDrained, (int) (item.getMaxEssence(returnedItem.getMetadata()) * this.orbCapacityMultiplier)); + int drain = NetworkHelper.getSoulNetwork(ownerName, getWorld()).addLifeEssence(liquidDrained, (int) (item.getMaxEssence(returnedItem.getMetadata()) * this.orbCapacityMultiplier)); fluid.amount = fluid.amount - drain; From cbd4f8c75fed5b7330f8338fda101288cdd359df Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 22 Nov 2015 14:03:51 -0800 Subject: [PATCH 3/3] First pass on Pedestal/Plinth I just want this out of my uncommitted file list... --- .../bloodmagic/block/BlockPedestal.java | 82 ++++++++++++++++ .../item/block/ItemBlockPedestal.java | 25 +++++ .../bloodmagic/registry/ModBlocks.java | 24 +++-- .../WayofTime/bloodmagic/tile/TilePlinth.java | 8 ++ .../bloodmagic/blockstates/BlockPedestal.json | 24 +++++ .../models/block/BlockPedestal1.json | 97 +++++++++++++++++++ .../models/item/BlockPedestal1.json | 10 ++ 7 files changed, 257 insertions(+), 13 deletions(-) create mode 100644 src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java create mode 100644 src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPedestal.java create mode 100644 src/main/java/WayofTime/bloodmagic/tile/TilePlinth.java create mode 100644 src/main/resources/assets/bloodmagic/blockstates/BlockPedestal.json create mode 100644 src/main/resources/assets/bloodmagic/models/block/BlockPedestal1.json create mode 100644 src/main/resources/assets/bloodmagic/models/item/BlockPedestal1.json diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java b/src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java new file mode 100644 index 00000000..6beffc5e --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/block/BlockPedestal.java @@ -0,0 +1,82 @@ +package WayofTime.bloodmagic.block; + +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.block.base.BlockStringContainer; +import WayofTime.bloodmagic.tile.TilePlinth; +import WayofTime.bloodmagic.util.Utils; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockPedestal extends BlockStringContainer { + + public static String[] names = { "pedestal", "plinth" }; + + public BlockPedestal() { + super(Material.rock, names); + + setUnlocalizedName(BloodMagic.MODID + "."); + setCreativeTab(BloodMagic.tabBloodMagic); + setHardness(2.0F); + setResistance(5.0F); + } + + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { + switch (getMetaFromState(state)) { + case 0: { +// TileEntity plinth = world.getTileEntity(pos); +// +// if (plinth!= null && plinth instanceof TilePlinth) { +// Utils.insertItemToTile((TilePlinth) plinth, player); +// } + } + + case 1: { + TileEntity plinth = world.getTileEntity(pos); + + if (plinth == null || player.isSneaking()) + return false; + + if (plinth instanceof TilePlinth) { + Utils.insertItemToTile((TilePlinth) plinth, player); + return true; + } + } + } + + world.markBlockForUpdate(pos); + return false; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, BlockPos pos) { + IBlockState state = blockAccess.getBlockState(pos); + + if (getMetaFromState(state) == 0) + setBlockBounds(0.5F - 0.3125F, 0.0F, 0.5F - 0.3125F, 0.5F + 0.3125F, 0.6F, 0.5F + 0.3125F); + else if (getMetaFromState(state) == 1) + setBlockBounds(0.1F, 0.0F, 0.1F, 1.0F - 0.1F, 0.8F, 1.0F - 0.1F); + + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean isFullCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return meta == 0 ? null : new TilePlinth(); + } +} diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPedestal.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPedestal.java new file mode 100644 index 00000000..99cb607b --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockPedestal.java @@ -0,0 +1,25 @@ +package WayofTime.bloodmagic.item.block; + +import WayofTime.bloodmagic.block.BlockPedestal; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class ItemBlockPedestal extends ItemBlock { + + public ItemBlockPedestal(Block block) { + super(block); + + setHasSubtypes(true); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return super.getUnlocalizedName(stack) + BlockPedestal.names[stack.getItemDamage()]; + } + + @Override + public int getMetadata(int meta) { + return meta; + } +} diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java index cf6ca9bb..79af695c 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModBlocks.java @@ -1,36 +1,33 @@ package WayofTime.bloodmagic.registry; import WayofTime.bloodmagic.block.*; -import WayofTime.bloodmagic.item.block.ItemBlockBloodStoneBrick; +import WayofTime.bloodmagic.item.block.*; +import WayofTime.bloodmagic.tile.TilePlinth; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.ConfigHandler; -import WayofTime.bloodmagic.item.block.ItemBlockBloodRune; -import WayofTime.bloodmagic.item.block.ItemBlockRitualController; -import WayofTime.bloodmagic.item.block.ItemBlockRitualStone; import WayofTime.bloodmagic.tile.TileAltar; import WayofTime.bloodmagic.tile.TileImperfectRitualStone; import WayofTime.bloodmagic.tile.TileMasterRitualStone; import WayofTime.bloodmagic.util.helper.InventoryRenderHelper; -public class ModBlocks -{ +public class ModBlocks { public static Block altar; public static Block bloodRune; public static Block ritualController; public static Block ritualStone; public static Block testSpellBlock; + public static Block pedestal; public static Block lifeEssence; public static Block crystal; public static Block bloodStoneBrick; - public static void init() - { + public static void init() { FluidRegistry.registerFluid(BlockLifeEssence.getLifeEssence()); lifeEssence = registerBlock(new BlockLifeEssence()); @@ -39,21 +36,20 @@ public class ModBlocks ritualController = registerBlock(new BlockRitualController(), ItemBlockRitualController.class); ritualStone = registerBlock(new BlockRitualStone(), ItemBlockRitualStone.class); testSpellBlock = registerBlock(new BlockTestSpellBlock()); - + pedestal = registerBlock(new BlockPedestal(), ItemBlockPedestal.class); bloodStoneBrick = registerBlock(new BlockBloodStoneBrick(), ItemBlockBloodStoneBrick.class); initTiles(); } - public static void initTiles() - { + public static void initTiles() { GameRegistry.registerTileEntity(TileAltar.class, BloodMagic.MODID + ":" + TileAltar.class.getSimpleName()); GameRegistry.registerTileEntity(TileImperfectRitualStone.class, BloodMagic.MODID + ":" + TileImperfectRitualStone.class.getSimpleName()); GameRegistry.registerTileEntity(TileMasterRitualStone.class, BloodMagic.MODID + ":" + TileMasterRitualStone.class.getSimpleName()); + GameRegistry.registerTileEntity(TilePlinth.class, BloodMagic.MODID + ":" + TilePlinth.class.getSimpleName()); } - public static void initRenders() - { + public static void initRenders() { InventoryRenderHelper renderHelper = BloodMagic.instance.getRenderHelper(); renderHelper.fluidRender(lifeEssence); @@ -78,6 +74,8 @@ public class ModBlocks renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(ritualStone), 6); renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(bloodStoneBrick), 0); renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(bloodStoneBrick), 1); + renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(pedestal), 0); + renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(pedestal), 1); } private static Block registerBlock(Block block, Class itemBlock, String name) { diff --git a/src/main/java/WayofTime/bloodmagic/tile/TilePlinth.java b/src/main/java/WayofTime/bloodmagic/tile/TilePlinth.java new file mode 100644 index 00000000..7fd93b67 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/tile/TilePlinth.java @@ -0,0 +1,8 @@ +package WayofTime.bloodmagic.tile; + +public class TilePlinth extends TileInventory { + + public TilePlinth() { + super(1, "plinth"); + } +} diff --git a/src/main/resources/assets/bloodmagic/blockstates/BlockPedestal.json b/src/main/resources/assets/bloodmagic/blockstates/BlockPedestal.json new file mode 100644 index 00000000..37be3808 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/blockstates/BlockPedestal.json @@ -0,0 +1,24 @@ +{ + "forge_marker": 1, + "defaults": { + "textures": { }, + "model": "bloodmagic:BlockPedestal1", + "uvlock": true + }, + "variants": { + "type": { + "pedestal": { + "model": "bloodmagic:BlockPedestal0", + "textures": { + "all": "bloodmagic:models/Pedestal" + } + }, + "plinth": { + "model": "bloodmagic:BlockPedestal1", + "textures": { + "all": "bloodmagic:models/Plinth" + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/models/block/BlockPedestal1.json b/src/main/resources/assets/bloodmagic/models/block/BlockPedestal1.json new file mode 100644 index 00000000..0f52434d --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/block/BlockPedestal1.json @@ -0,0 +1,97 @@ +{ + "textures": { + }, + "elements": [ + { + "name": "Base", + "from": [ 3.0, 0.0, 3.0 ], + "to": [ 13.0, 2.0, 13.0 ], + "faces": { + "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 10.0, 2.0 ] }, + "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 10.0, 2.0 ] }, + "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 10.0, 2.0 ] }, + "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 10.0, 2.0 ] }, + "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 10.0, 10.0 ] }, + "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 10.0, 10.0 ] } + } + }, + { + "name": "Leg", + "from": [ 5.0, 2.0, 5.0 ], + "to": [ 11.0, 11.0, 11.0 ], + "faces": { + "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 9.0 ] }, + "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 9.0 ] }, + "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 9.0 ] }, + "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 9.0 ] }, + "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 6.0 ] }, + "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 6.0, 6.0 ] } + } + }, + { + "name": "Plate", + "from": [ 1.0, 11.0, 1.0 ], + "to": [ 15.0, 12.0, 15.0 ], + "faces": { + "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 1.0 ] }, + "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 1.0 ] }, + "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 1.0 ] }, + "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 1.0 ] }, + "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 14.0 ] }, + "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 14.0 ] } + } + }, + { + "name": "NWall", + "from": [ 0.0, 11.0, 0.0 ], + "to": [ 16.0, 13.0, 1.0 ], + "faces": { + "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 16.0, 2.0 ] }, + "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }, + "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 16.0, 2.0 ] }, + "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }, + "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, + "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 16.0, 1.0 ] } + } + }, + { + "name": "SWall", + "from": [ 0.0, 11.0, 15.0 ], + "to": [ 16.0, 13.0, 16.0 ], + "faces": { + "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 16.0, 2.0 ] }, + "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }, + "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 16.0, 2.0 ] }, + "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }, + "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 16.0, 1.0 ] }, + "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 16.0, 1.0 ] } + } + }, + { + "name": "WWall", + "from": [ 0.0, 11.0, 1.0 ], + "to": [ 1.0, 13.0, 15.0 ], + "faces": { + "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }, + "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 2.0 ] }, + "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }, + "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 2.0 ] }, + "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 14.0 ] }, + "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 14.0 ] } + } + }, + { + "name": "EWall", + "from": [ 15.0, 11.0, 1.0 ], + "to": [ 16.0, 13.0, 15.0 ], + "faces": { + "north": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }, + "east": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 2.0 ] }, + "south": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 2.0 ] }, + "west": { "texture": "#-1", "uv": [ 0.0, 0.0, 14.0, 2.0 ] }, + "up": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 14.0 ] }, + "down": { "texture": "#-1", "uv": [ 0.0, 0.0, 1.0, 14.0 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/bloodmagic/models/item/BlockPedestal1.json b/src/main/resources/assets/bloodmagic/models/item/BlockPedestal1.json new file mode 100644 index 00000000..f8f8a3a4 --- /dev/null +++ b/src/main/resources/assets/bloodmagic/models/item/BlockPedestal1.json @@ -0,0 +1,10 @@ +{ + "parent": "bloodmagic:block/BlockPedestal1", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} \ No newline at end of file