Added more framework for the incense altar.
This commit is contained in:
parent
fd29ac8e7f
commit
c8ded3c6dd
|
@ -195,16 +195,19 @@ public class Constants
|
||||||
@Getter
|
@Getter
|
||||||
private final String regName;
|
private final String regName;
|
||||||
|
|
||||||
BloodMagicItem(String regName) {
|
BloodMagicItem(String regName)
|
||||||
|
{
|
||||||
this.regName = regName;
|
this.regName = regName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item getItem() {
|
public Item getItem()
|
||||||
|
{
|
||||||
return BloodMagicAPI.getItem(getRegName());
|
return BloodMagicAPI.getItem(getRegName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BloodMagicBlock {
|
public enum BloodMagicBlock
|
||||||
|
{
|
||||||
ALCHEMY_ARRAY("BlockAlchemyArray"),
|
ALCHEMY_ARRAY("BlockAlchemyArray"),
|
||||||
ALTAR("BlockAltar"),
|
ALTAR("BlockAltar"),
|
||||||
BLOOD_LIGHT("BlockBloodLight"),
|
BLOOD_LIGHT("BlockBloodLight"),
|
||||||
|
@ -222,16 +225,19 @@ public class Constants
|
||||||
RITUAL_STONE("BlockRitualStone"),
|
RITUAL_STONE("BlockRitualStone"),
|
||||||
SOUL_FORGE("BlockSoulForge"),
|
SOUL_FORGE("BlockSoulForge"),
|
||||||
SPECTRAL("BlockSpectral"),
|
SPECTRAL("BlockSpectral"),
|
||||||
TELEPOSER("BlockTeleposer");
|
TELEPOSER("BlockTeleposer"),
|
||||||
|
INCENSE_ALTAR("BlockIncenseAltar");
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String regName;
|
private final String regName;
|
||||||
|
|
||||||
BloodMagicBlock(String regName) {
|
BloodMagicBlock(String regName)
|
||||||
|
{
|
||||||
this.regName = regName;
|
this.regName = regName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlock() {
|
public Block getBlock()
|
||||||
|
{
|
||||||
return BloodMagicAPI.getBlock(getRegName());
|
return BloodMagicAPI.getBlock(getRegName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<Integer, List<IncenseAltarComponent>> incenseComponentMap = new TreeMap<Integer, List<IncenseAltarComponent>>();
|
||||||
|
//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<IncenseAltarComponent> list = new ArrayList<IncenseAltarComponent>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ import WayofTime.bloodmagic.block.BlockBloodLight;
|
||||||
import WayofTime.bloodmagic.block.BlockBloodRune;
|
import WayofTime.bloodmagic.block.BlockBloodRune;
|
||||||
import WayofTime.bloodmagic.block.BlockBloodStoneBrick;
|
import WayofTime.bloodmagic.block.BlockBloodStoneBrick;
|
||||||
import WayofTime.bloodmagic.block.BlockCrystal;
|
import WayofTime.bloodmagic.block.BlockCrystal;
|
||||||
|
import WayofTime.bloodmagic.block.BlockIncenseAltar;
|
||||||
import WayofTime.bloodmagic.block.BlockInputRoutingNode;
|
import WayofTime.bloodmagic.block.BlockInputRoutingNode;
|
||||||
import WayofTime.bloodmagic.block.BlockItemRoutingNode;
|
import WayofTime.bloodmagic.block.BlockItemRoutingNode;
|
||||||
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
||||||
|
@ -35,6 +36,7 @@ import WayofTime.bloodmagic.item.block.ItemBlockRitualStone;
|
||||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||||
import WayofTime.bloodmagic.tile.TileAltar;
|
import WayofTime.bloodmagic.tile.TileAltar;
|
||||||
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
|
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
|
||||||
|
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
||||||
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
||||||
import WayofTime.bloodmagic.tile.TilePhantomBlock;
|
import WayofTime.bloodmagic.tile.TilePhantomBlock;
|
||||||
import WayofTime.bloodmagic.tile.TilePlinth;
|
import WayofTime.bloodmagic.tile.TilePlinth;
|
||||||
|
@ -61,6 +63,7 @@ public class ModBlocks
|
||||||
public static Block spectralBlock;
|
public static Block spectralBlock;
|
||||||
public static Block phantomBlock;
|
public static Block phantomBlock;
|
||||||
public static Block soulForge;
|
public static Block soulForge;
|
||||||
|
public static Block incenseAltar;
|
||||||
|
|
||||||
public static Block lifeEssence;
|
public static Block lifeEssence;
|
||||||
|
|
||||||
|
@ -95,6 +98,7 @@ public class ModBlocks
|
||||||
inputRoutingNode = registerBlock(new BlockInputRoutingNode());
|
inputRoutingNode = registerBlock(new BlockInputRoutingNode());
|
||||||
outputRoutingNode = registerBlock(new BlockOutputRoutingNode());
|
outputRoutingNode = registerBlock(new BlockOutputRoutingNode());
|
||||||
itemRoutingNode = registerBlock(new BlockItemRoutingNode());
|
itemRoutingNode = registerBlock(new BlockItemRoutingNode());
|
||||||
|
incenseAltar = registerBlock(new BlockIncenseAltar());
|
||||||
|
|
||||||
initTiles();
|
initTiles();
|
||||||
}
|
}
|
||||||
|
@ -114,6 +118,7 @@ public class ModBlocks
|
||||||
GameRegistry.registerTileEntity(TileInputRoutingNode.class, Constants.Mod.MODID + ":" + TileInputRoutingNode.class.getSimpleName());
|
GameRegistry.registerTileEntity(TileInputRoutingNode.class, Constants.Mod.MODID + ":" + TileInputRoutingNode.class.getSimpleName());
|
||||||
GameRegistry.registerTileEntity(TileOutputRoutingNode.class, Constants.Mod.MODID + ":" + TileOutputRoutingNode.class.getSimpleName());
|
GameRegistry.registerTileEntity(TileOutputRoutingNode.class, Constants.Mod.MODID + ":" + TileOutputRoutingNode.class.getSimpleName());
|
||||||
GameRegistry.registerTileEntity(TileItemRoutingNode.class, Constants.Mod.MODID + ":" + TileItemRoutingNode.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()
|
public static void initRenders()
|
||||||
|
@ -151,6 +156,7 @@ public class ModBlocks
|
||||||
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(outputRoutingNode));
|
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(outputRoutingNode));
|
||||||
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(inputRoutingNode));
|
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(inputRoutingNode));
|
||||||
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(itemRoutingNode));
|
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(itemRoutingNode));
|
||||||
|
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(incenseAltar));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Block registerBlock(Block block, Class<? extends ItemBlock> itemBlock, String name)
|
private static Block registerBlock(Block block, Class<? extends ItemBlock> itemBlock, String name)
|
||||||
|
@ -163,7 +169,8 @@ public class ModBlocks
|
||||||
|
|
||||||
private static Block registerBlock(Block block, Class<? extends ItemBlock> itemBlock)
|
private static Block registerBlock(Block block, Class<? extends ItemBlock> 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());
|
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;
|
return block;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +191,8 @@ public class ModBlocks
|
||||||
|
|
||||||
private static Block registerBlock(Block block)
|
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());
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ public class TileIncenseAltar extends TileInventory implements ITickable
|
||||||
public static int maxCheckRange = 5;
|
public static int maxCheckRange = 5;
|
||||||
public Map<EnumTranquilityType, Double> tranquilityMap = new HashMap<EnumTranquilityType, Double>();
|
public Map<EnumTranquilityType, Double> tranquilityMap = new HashMap<EnumTranquilityType, Double>();
|
||||||
|
|
||||||
|
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()
|
public TileIncenseAltar()
|
||||||
{
|
{
|
||||||
super(1, "incenseAltar");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double appliedTranquility = 0;
|
||||||
|
for (Entry<EnumTranquilityType, Double> entry : tranquilityMap.entrySet())
|
||||||
|
{
|
||||||
|
appliedTranquility += Math.pow(entry.getValue(), 0.9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"normal": { "model": "bloodmagic:BlockIncenseAltar" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -162,6 +162,7 @@ tile.BloodMagic.crystal.brick.name=Crystal Cluster Brick
|
||||||
tile.BloodMagic.bloodLight.name=Blood Light
|
tile.BloodMagic.bloodLight.name=Blood Light
|
||||||
tile.BloodMagic.spectralBlock.name=Spectral Block
|
tile.BloodMagic.spectralBlock.name=Spectral Block
|
||||||
tile.BloodMagic.phantomBlock.name=Phantom Block
|
tile.BloodMagic.phantomBlock.name=Phantom Block
|
||||||
|
tile.BloodMagic.incenseAltar.name=Incense Altar
|
||||||
|
|
||||||
tile.BloodMagic.teleposer.name=Teleposer
|
tile.BloodMagic.teleposer.name=Teleposer
|
||||||
tile.BloodMagic.soulForge.name=Hellfire Forge
|
tile.BloodMagic.soulForge.name=Hellfire Forge
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "bloodmagic:blocks/IncenseAltar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 551 B |
Loading…
Reference in a new issue