Demon Crystal fixes

This commit is contained in:
Nicholas Ignoffo 2017-12-15 18:34:04 -08:00
parent 03b4b5e2d7
commit dce2817b8c
5 changed files with 50 additions and 119 deletions

View file

@ -1,10 +1,15 @@
package WayofTime.bloodmagic.api.soul;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
import WayofTime.bloodmagic.item.types.ISubItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import org.apache.commons.lang3.text.WordUtils;
import javax.annotation.Nonnull;
import java.util.Locale;
public enum EnumDemonWillType implements IStringSerializable {
public enum EnumDemonWillType implements IStringSerializable, ISubItem {
DEFAULT("default"),
CORROSIVE("corrosive"),
DESTRUCTIVE("destructive"),
@ -26,4 +31,17 @@ public enum EnumDemonWillType implements IStringSerializable {
public String getName() {
return this.toString();
}
@Nonnull
@Override
public String getInternalName() {
return "crystal" + WordUtils.capitalize(name);
}
@Nonnull
@Override
public ItemStack getStack(int count) {
return new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, count, ordinal());
}
}

View file

@ -4,6 +4,7 @@ import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
import WayofTime.bloodmagic.item.ItemDemonCrystal;
import WayofTime.bloodmagic.item.block.ItemBlockDemonCrystal;
import WayofTime.bloodmagic.tile.TileDemonCrystal;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -13,6 +14,7 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
@ -26,7 +28,7 @@ import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.Random;
public class BlockDemonCrystal extends Block {
public class BlockDemonCrystal extends Block implements IBMBlock {
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 6);
public static final PropertyEnum<EnumDemonWillType> TYPE = PropertyEnum.<EnumDemonWillType>create("type", EnumDemonWillType.class);
public static final PropertyEnum<EnumFacing> ATTACHED = PropertyEnum.<EnumFacing>create("attached", EnumFacing.class);
@ -156,6 +158,8 @@ public class BlockDemonCrystal extends Block {
}
TileDemonCrystal crystal = (TileDemonCrystal) world.getTileEntity(pos);
if (crystal == null)
return false;
if (PlayerDemonWillHandler.getTotalDemonWill(EnumDemonWillType.DEFAULT, player) > 1024) {
crystal.dropSingleCrystal();
@ -177,49 +181,13 @@ public class BlockDemonCrystal extends Block {
return new TileDemonCrystal();
}
public static ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber) {
ItemStack stack = null;
switch (type) {
case CORROSIVE:
stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_CORROSIVE);
break;
case DEFAULT:
stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DEFAULT);
break;
case DESTRUCTIVE:
stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DESTRUCTIVE);
break;
case STEADFAST:
stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_STEADFAST);
break;
case VENGEFUL:
stack = ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_VENGEFUL);
break;
}
stack.setCount(crystalNumber);
return stack;
@Nullable
@Override
public ItemBlock getItem() {
return new ItemBlockDemonCrystal(this);
}
// @Override
// public java.util.List<ItemStack> getDrops(net.minecraft.world.IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
// {
// java.util.List<ItemStack> ret = super.getDrops(world, pos, state, fortune);
// int age = ((Integer) state.getValue(AGE)).intValue();
// Random rand = world instanceof World ? ((World) world).rand : new Random();
//
// if (age >= 7)
// {
// int k = 3 + fortune;
//
// for (int i = 0; i < 3 + fortune; ++i)
// {
// if (rand.nextInt(15) <= age)
// {
// ret.add(new ItemStack(this.getSeed(), 1, 0));
// }
// }
// }
// return ret;
// }
public static ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber) {
return type.getStack(crystalNumber);
}
}

View file

@ -30,15 +30,12 @@ public class RegistrarBloodMagicRecipes {
public static void registerCrafting(IForgeRegistry<IRecipe> registry) {
for (int i = 0; i < ItemSoulGem.names.length; i++) {
for (int j = 0; j < ItemDemonCrystal.NAMES.size(); j++) {
for (EnumDemonWillType willType : EnumDemonWillType.values()) {
ItemStack baseGemStack = new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, i);
ItemStack newGemStack = new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, i);
ItemStack crystalStack = new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, j);
EnumDemonWillType willType = ((ItemDemonCrystal) RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL).getType(crystalStack);
((ItemSoulGem) RegistrarBloodMagicItems.SOUL_GEM).setCurrentType(willType, newGemStack);
ShapelessOreRecipe shapeless = new ShapelessOreRecipe(new ResourceLocation(BloodMagic.MODID, "soul_gem"), newGemStack, baseGemStack, crystalStack);
ShapelessOreRecipe shapeless = new ShapelessOreRecipe(new ResourceLocation(BloodMagic.MODID, "soul_gem"), newGemStack, baseGemStack, willType.getStack());
registry.register(shapeless.setRegistryName("soul_gem_" + willType.getName()));
}
}
@ -89,7 +86,7 @@ public class RegistrarBloodMagicRecipes {
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM), 1, 1, "dustRedstone", "ingotGold", "blockGlass", "dyeBlue");
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 1), 60, 20, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM), "gemDiamond", "blockRedstone", "blockLapis");
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 2), 240, 50, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 1), "gemDiamond", "blockGold", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 2));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 3), 1000, 100, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 2), new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 3), new ItemStack(RegistrarBloodMagicItems.BLOOD_SHARD), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DEFAULT));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 3), 1000, 100, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 2), new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 3), new ItemStack(RegistrarBloodMagicItems.BLOOD_SHARD), EnumDemonWillType.DEFAULT.getStack());
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 4), 4000, 500, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 3), Items.NETHER_STAR);
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.SENTIENT_SWORD), 0, 0, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM), new ItemStack(Items.IRON_SWORD));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicItems.SENTIENT_AXE), 0, 0, new ItemStack(RegistrarBloodMagicItems.SOUL_GEM), new ItemStack(Items.IRON_AXE));
@ -129,11 +126,11 @@ public class RegistrarBloodMagicRecipes {
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.INPUT_ROUTING_NODE), 400, 25, "dustGlowstone", "dustRedstone", "ingotGold", new ItemStack(RegistrarBloodMagicBlocks.ITEM_ROUTING_NODE));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.MASTER_ROUTING_NODE), 400, 200, "blockIron", "gemDiamond", new ItemStack(RegistrarBloodMagicItems.SLATE, 1, 2));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 0), 1200, 100, ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DEFAULT), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DEFAULT), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DEFAULT), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DEFAULT));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 1), 1200, 100, ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_CORROSIVE), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_CORROSIVE), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_CORROSIVE), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_CORROSIVE));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 2), 1200, 100, ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DESTRUCTIVE), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DESTRUCTIVE), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DESTRUCTIVE), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_DESTRUCTIVE));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 3), 1200, 100, ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_VENGEFUL), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_VENGEFUL), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_VENGEFUL), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_VENGEFUL));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 4), 1200, 100, ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_STEADFAST), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_STEADFAST), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_STEADFAST), ItemDemonCrystal.getStack(ItemDemonCrystal.CRYSTAL_STEADFAST));
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 0), 1200, 100, EnumDemonWillType.DEFAULT.getStack(), EnumDemonWillType.DEFAULT.getStack(), EnumDemonWillType.DEFAULT.getStack(), EnumDemonWillType.DEFAULT.getStack());
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 1), 1200, 100, EnumDemonWillType.CORROSIVE.getStack(), EnumDemonWillType.CORROSIVE.getStack(), EnumDemonWillType.CORROSIVE.getStack(), EnumDemonWillType.CORROSIVE.getStack());
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 2), 1200, 100, EnumDemonWillType.DESTRUCTIVE.getStack(), EnumDemonWillType.DESTRUCTIVE.getStack(), EnumDemonWillType.DESTRUCTIVE.getStack(), EnumDemonWillType.DESTRUCTIVE.getStack());
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 3), 1200, 100, EnumDemonWillType.VENGEFUL.getStack(), EnumDemonWillType.VENGEFUL.getStack(), EnumDemonWillType.VENGEFUL.getStack(), EnumDemonWillType.VENGEFUL.getStack());
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRYSTAL, 1, 4), 1200, 100, EnumDemonWillType.STEADFAST.getStack(), EnumDemonWillType.STEADFAST.getStack(), EnumDemonWillType.STEADFAST.getStack(), EnumDemonWillType.STEADFAST.getStack());
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_CRUCIBLE), 400, 100, Items.CAULDRON, "stone", "gemLapis", "gemDiamond");
registrar.addTartaricForge(new ItemStack(RegistrarBloodMagicBlocks.DEMON_PYLON), 400, 50, "blockIron", "stone", "gemLapis", RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL);

View file

@ -1,65 +1,15 @@
package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import java.util.ArrayList;
import java.util.List;
public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVariantProvider {
public static final ArrayList<String> NAMES = Lists.newArrayList();
public static final String CRYSTAL_DEFAULT = "crystalDefault";
public static final String CRYSTAL_CORROSIVE = "crystalCorrosive";
public static final String CRYSTAL_VENGEFUL = "crystalVengeful";
public static final String CRYSTAL_DESTRUCTIVE = "crystalDestructive";
public static final String CRYSTAL_STEADFAST = "crystalSteadfast";
public class ItemDemonCrystal extends ItemEnum<EnumDemonWillType> implements IDiscreteDemonWill, IVariantProvider {
public ItemDemonCrystal() {
super();
setUnlocalizedName(BloodMagic.MODID + ".demonCrystal.");
setHasSubtypes(true);
setCreativeTab(BloodMagic.TAB_BM);
buildItemList();
}
private void buildItemList() {
NAMES.add(0, CRYSTAL_DEFAULT);
NAMES.add(1, CRYSTAL_CORROSIVE);
NAMES.add(2, CRYSTAL_DESTRUCTIVE);
NAMES.add(3, CRYSTAL_VENGEFUL);
NAMES.add(4, CRYSTAL_STEADFAST);
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName(stack) + NAMES.get(stack.getItemDamage());
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
if (!isInCreativeTab(creativeTab))
return;
for (int i = 0; i < NAMES.size(); i++)
list.add(new ItemStack(this, 1, i));
super(EnumDemonWillType.class, "demonCrystal");
}
@Override
@ -89,14 +39,4 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria
public EnumDemonWillType getType(ItemStack willStack) {
return EnumDemonWillType.values()[MathHelper.clamp(willStack.getMetadata(), 0, EnumDemonWillType.values().length - 1)];
}
@Override
public void populateVariants(Int2ObjectMap<String> variants) {
for (String name : NAMES)
variants.put(NAMES.indexOf(name), "type=" + name);
}
public static ItemStack getStack(String name) {
return new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, NAMES.indexOf(name));
}
}

View file

@ -1,7 +1,9 @@
package WayofTime.bloodmagic.item.block;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.tile.TileDemonCrystal;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -14,7 +16,7 @@ import net.minecraft.world.World;
import java.util.Locale;
public class ItemBlockDemonCrystal extends ItemBlock {
public class ItemBlockDemonCrystal extends ItemBlock implements IVariantProvider {
public ItemBlockDemonCrystal(Block block) {
super(block);
setHasSubtypes(true);
@ -43,4 +45,10 @@ public class ItemBlockDemonCrystal extends ItemBlock {
return false;
}
@Override
public void populateVariants(Int2ObjectMap<String> variants) {
for (EnumDemonWillType type : EnumDemonWillType.values())
variants.put(type.ordinal(), "age=4,attached=up,type=" + type.getName());
}
}