Added different types of Demon Will crystals. Obtainment method still TBD
This commit is contained in:
parent
8077962e08
commit
19fec96bfd
src/main
java/WayofTime/bloodmagic
api/soul
block
item/block
registry
tile
resources/assets/bloodmagic
|
@ -1,13 +1,18 @@
|
|||
package WayofTime.bloodmagic.api.soul;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum EnumDemonWillType
|
||||
public enum EnumDemonWillType implements IStringSerializable
|
||||
{
|
||||
DEFAULT("Default");
|
||||
DEFAULT("Default"),
|
||||
CORROSIVE("Corrosive"),
|
||||
DESTRUCTIVE("Destructive"),
|
||||
VENGEFUL("Vengeful"),
|
||||
STEADFAST("Steadfast");
|
||||
|
||||
public final String name;
|
||||
}
|
||||
|
|
|
@ -1,28 +1,39 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.tile.TileDemonCrystal;
|
||||
|
||||
public class BlockDemonCrystal extends Block
|
||||
public class BlockDemonCrystal extends BlockContainer
|
||||
{
|
||||
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 6);
|
||||
public static final PropertyEnum<EnumDemonWillType> TYPE = PropertyEnum.<EnumDemonWillType>create("type", EnumDemonWillType.class);
|
||||
|
||||
public BlockDemonCrystal()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumDemonWillType.DEFAULT));
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".demonCrystal");
|
||||
setRegistryName(Constants.BloodMagicBlock.DEMON_CRYSTAL.getRegName());
|
||||
|
@ -32,6 +43,21 @@ public class BlockDemonCrystal extends Block
|
|||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
TileDemonCrystal tile = (TileDemonCrystal) world.getTileEntity(pos);
|
||||
return state.withProperty(AGE, tile.getCrystalCountForRender());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List<ItemStack> list)
|
||||
{
|
||||
for (int i = 0; i < EnumDemonWillType.values().length; i++)
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
|
@ -67,7 +93,8 @@ public class BlockDemonCrystal extends Block
|
|||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
|
||||
System.out.println("Meta: " + meta + ", " + EnumDemonWillType.values()[meta]);
|
||||
return this.getDefaultState().withProperty(TYPE, EnumDemonWillType.values()[meta]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,13 +103,19 @@ public class BlockDemonCrystal extends Block
|
|||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((Integer) state.getValue(AGE)).intValue();
|
||||
return ((EnumDemonWillType) state.getValue(TYPE)).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] { AGE });
|
||||
return new BlockState(this, new IProperty[] { TYPE, AGE });
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta)
|
||||
{
|
||||
return new TileDemonCrystal();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,9 +126,14 @@ public class BlockDemonCrystal extends Block
|
|||
return true;
|
||||
}
|
||||
|
||||
int meta = getMetaFromState(state);
|
||||
int nextMeta = Math.min(meta + 1, 6);
|
||||
world.setBlockState(pos, this.getStateFromMeta(nextMeta));
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileDemonCrystal)
|
||||
{
|
||||
int crystals = ((TileDemonCrystal) tile).getCrystalCount();
|
||||
int next = Math.min(7, crystals + 1);
|
||||
((TileDemonCrystal) tile).setCrystalCount(next);
|
||||
world.markBlockForUpdate(pos);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -121,10 +159,4 @@ public class BlockDemonCrystal extends Block
|
|||
// }
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||
{
|
||||
return 0xffffff;
|
||||
}
|
||||
}
|
|
@ -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.api.soul.EnumDemonWillType;
|
||||
|
||||
public class ItemBlockDemonCrystal extends ItemBlock
|
||||
{
|
||||
public ItemBlockDemonCrystal(Block block)
|
||||
{
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
return super.getUnlocalizedName(stack) + EnumDemonWillType.values()[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ import WayofTime.bloodmagic.item.block.ItemBlockBloodRune;
|
|||
import WayofTime.bloodmagic.item.block.ItemBlockBloodStoneBrick;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockBloodTank;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockCrystal;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockDemonCrystal;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockPath;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockPedestal;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockRitualController;
|
||||
|
@ -46,6 +47,7 @@ import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
|||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.tile.TileBloodTank;
|
||||
import WayofTime.bloodmagic.tile.TileDemonCrucible;
|
||||
import WayofTime.bloodmagic.tile.TileDemonCrystal;
|
||||
import WayofTime.bloodmagic.tile.TileDemonCrystallizer;
|
||||
import WayofTime.bloodmagic.tile.TileDemonPylon;
|
||||
import WayofTime.bloodmagic.tile.TileDimensionalPortal;
|
||||
|
@ -124,7 +126,7 @@ public class ModBlocks
|
|||
demonCrucible = registerBlock(new BlockDemonCrucible());
|
||||
demonPylon = registerBlock(new BlockDemonPylon());
|
||||
demonCrystallizer = registerBlock(new BlockDemonCrystallizer());
|
||||
demonCrystal = registerBlock(new BlockDemonCrystal());
|
||||
demonCrystal = registerBlock(new BlockDemonCrystal(), ItemBlockDemonCrystal.class);
|
||||
|
||||
dimensionalPortal = registerBlock(new BlockDimensionalPortal());
|
||||
bloodTank = registerBlock(new BlockBloodTank(), ItemBlockBloodTank.class);
|
||||
|
@ -157,6 +159,7 @@ public class ModBlocks
|
|||
GameRegistry.registerTileEntity(TileDemonCrucible.class, Constants.Mod.MODID + ":" + TileDemonCrucible.class.getSimpleName());
|
||||
GameRegistry.registerTileEntity(TileDemonPylon.class, Constants.Mod.MODID + ":" + TileDemonPylon.class.getSimpleName());
|
||||
GameRegistry.registerTileEntity(TileDemonCrystallizer.class, Constants.Mod.MODID + ":" + TileDemonCrystallizer.class.getSimpleName());
|
||||
GameRegistry.registerTileEntity(TileDemonCrystal.class, Constants.Mod.MODID + ":" + TileDemonCrystal.class.getSimpleName());
|
||||
|
||||
GameRegistry.registerTileEntity(TileDimensionalPortal.class, Constants.Mod.MODID + ":" + TileDimensionalPortal.class.getSimpleName());
|
||||
GameRegistry.registerTileEntity(TileBloodTank.class, Constants.Mod.MODID + ":" + TileBloodTank.class.getSimpleName());
|
||||
|
|
160
src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java
Normal file
160
src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java
Normal file
|
@ -0,0 +1,160 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillConduit;
|
||||
|
||||
public class TileDemonCrystal extends TileEntity implements ITickable, IDemonWillConduit
|
||||
{
|
||||
public DemonWillHolder holder = new DemonWillHolder();
|
||||
public final int maxWill = 100;
|
||||
public final double drainRate = 1;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public int crystalCount = 1;
|
||||
|
||||
public TileDemonCrystal()
|
||||
{
|
||||
this.crystalCount = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldObj.getWorldTime() % 200 == 0)
|
||||
{
|
||||
crystalCount = Math.min(crystalCount + 1, 7);
|
||||
worldObj.markBlockForUpdate(pos);
|
||||
|
||||
System.out.println("" + crystalCount);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCrystalCountForRender()
|
||||
{
|
||||
return MathHelper.clamp_int(crystalCount - 1, 0, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readFromNBT(tag);
|
||||
|
||||
holder.readFromNBT(tag, "Will");
|
||||
crystalCount = tag.getInteger("crystalCount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeToNBT(tag);
|
||||
|
||||
holder.writeToNBT(tag, "Will");
|
||||
tag.setInteger("crystalCount", crystalCount);
|
||||
}
|
||||
|
||||
// IDemonWillConduit
|
||||
|
||||
@Override
|
||||
public int getWeight()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill)
|
||||
{
|
||||
if (amount <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!canFill(type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!doFill)
|
||||
{
|
||||
return Math.min(maxWill - holder.getWill(type), amount);
|
||||
}
|
||||
|
||||
return holder.addWill(type, amount, maxWill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain)
|
||||
{
|
||||
double drained = amount;
|
||||
double current = holder.getWill(type);
|
||||
if (current < drained)
|
||||
{
|
||||
drained = current;
|
||||
}
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
return holder.drainWill(type, amount);
|
||||
}
|
||||
|
||||
return drained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumDemonWillType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumDemonWillType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCurrentWill(EnumDemonWillType type)
|
||||
{
|
||||
return holder.getWill(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
|
||||
{
|
||||
return oldState.getBlock() != newState.getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
|
||||
{
|
||||
super.onDataPacket(net, pkt);
|
||||
readFromNBT(pkt.getNbtCompound());
|
||||
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"textures": { "#crystal" : "bloodmagic:models/crystal" },
|
||||
"textures": { "#crystal" : "bloodmagic:models/DefaultCrystal" },
|
||||
"model": "bloodmagic:crystal/Crystal1.obj",
|
||||
"custom": { "flip-v": true },
|
||||
"transform": {
|
||||
|
@ -9,9 +9,38 @@
|
|||
}
|
||||
},
|
||||
"variants": {
|
||||
"type": {
|
||||
"default": {
|
||||
"textures": {
|
||||
"#crystal" : "bloodmagic:models/DefaultCrystal"
|
||||
}
|
||||
},
|
||||
"corrosive": {
|
||||
"textures": {
|
||||
"#crystal" : "bloodmagic:models/CorrosiveCrystal"
|
||||
}
|
||||
},
|
||||
"destructive": {
|
||||
"textures": {
|
||||
"#crystal" : "bloodmagic:models/DestructiveCrystal"
|
||||
}
|
||||
},
|
||||
"vengeful": {
|
||||
"textures": {
|
||||
"#crystal" : "bloodmagic:models/VengefulCrystal"
|
||||
}
|
||||
},
|
||||
"steadfast": {
|
||||
"textures": {
|
||||
"#crystal" : "bloodmagic:models/SteadfastCrystal"
|
||||
}
|
||||
}
|
||||
},
|
||||
"age": {
|
||||
"0": {
|
||||
|
||||
textures": {
|
||||
"#crystal" : "bloodmagic:models/VengefulCrystal"
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"submodel": "bloodmagic:crystal/Crystal2.obj"
|
||||
|
|
Binary file not shown.
After ![]() (image error) Size: 761 B |
Binary file not shown.
After ![]() (image error) Size: 740 B |
Binary file not shown.
After ![]() (image error) Size: 765 B |
Binary file not shown.
After ![]() (image error) Size: 751 B |
Binary file not shown.
After ![]() (image error) Size: 796 B |
Binary file not shown.
Before ![]() (image error) Size: 885 B |
Loading…
Reference in a new issue