use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.
the class ItemHoldingGem method addRecipes.
@Override
public void addRecipes(RecipeMaker recipes) {
for (EnumGem gem : EnumGem.values()) {
ItemStack stack = new ItemStack(this);
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setShort(NBT_GEM_ID, (short) gem.ordinal());
recipes.addShapedOre("holding_gem_" + gem.name(), stack, "gcg", "s s", "gcg", 'g', "ingotGold", 'c', ModItems.craftingMaterial.chaosEssenceEnriched, 's', gem.getItemOreName());
}
}
use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.
the class ToolRandomizer method randomizeArmor.
public ItemStack randomizeArmor(ItemStack armor, float superChance) {
if (!ToolHelper.hasNoConstruction(armor))
return armor;
IArmor itool = (IArmor) armor.getItem();
// Regular or super?
boolean superTier = SilentGems.random.nextFloat() < superChance;
// How many gems?
boolean gem2 = SilentGems.random.nextFloat() < SECOND_GEM_CHANCE;
boolean gem3 = gem2 && SilentGems.random.nextFloat() < THIRD_GEM_CHANCE;
boolean gem4 = gem3 && SilentGems.random.nextFloat() < FOURTH_GEM_CHANCE;
// Gem array
EnumGem[] gems;
if (gem4) {
gems = new EnumGem[] { EnumGem.getRandom(), EnumGem.getRandom(), EnumGem.getRandom(), EnumGem.getRandom() };
} else if (gem3) {
EnumGem g1 = EnumGem.getRandom();
gems = new EnumGem[] { g1, EnumGem.getRandom(), EnumGem.getRandom(), g1 };
} else if (gem2) {
EnumGem g1 = EnumGem.getRandom();
EnumGem g2 = EnumGem.getRandom();
gems = new EnumGem[] { g1, g2, g1, g2 };
} else {
EnumGem g1 = EnumGem.getRandom();
gems = new EnumGem[] { g1, g1, g1, g1 };
}
// Crafting stack array
ItemStack[] craftingStacks = new ItemStack[gems.length];
for (int i = 0; i < craftingStacks.length; ++i) {
craftingStacks[i] = superTier ? gems[i].getItemSuper() : gems[i].getItem();
}
ItemStack frame = ModItems.armorFrame.getFrameForArmorPiece((ItemArmor) armor.getItem(), superTier ? EnumMaterialTier.SUPER : EnumMaterialTier.REGULAR);
ItemStack temp = ArmorHelper.constructArmor(armor.getItem(), frame, craftingStacks);
// Set name
String ownerName = nameAdjectives.get(SilentGems.random.nextInt(nameAdjectives.size())) + " " + nameNouns.get(SilentGems.random.nextInt(nameNouns.size()));
ToolHelper.setOriginalOwner(temp, TextFormatting.AQUA + ownerName);
armor.setTagCompound(temp.getTagCompound());
return temp;
}
use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.
the class ToolRandomizer method randomize.
public ItemStack randomize(ItemStack tool, float superChance) {
if (tool.getItem() instanceof IArmor)
return randomizeArmor(tool, superChance);
if (!(tool.getItem() instanceof ITool) || !ToolHelper.hasNoConstruction(tool))
return tool;
ITool itool = (ITool) tool.getItem();
// Regular or super?
boolean superTier = !itool.getValidTiers().contains(EnumMaterialTier.REGULAR) || (SilentGems.random.nextFloat() < superChance && itool.getValidTiers().contains(EnumMaterialTier.SUPER));
// How many gems?
boolean gem2 = SilentGems.random.nextFloat() < SECOND_GEM_CHANCE;
boolean gem3 = gem2 && SilentGems.random.nextFloat() < THIRD_GEM_CHANCE;
// Gem array
EnumGem[] gems;
if (gem3) {
// 3 gems
gems = new EnumGem[] { EnumGem.getRandom(), EnumGem.getRandom(), EnumGem.getRandom() };
} else if (gem2) {
// 2 gems (3rd = 1st)
EnumGem g1 = EnumGem.getRandom();
EnumGem g2 = EnumGem.getRandom();
if (tool.getItem() == ModItems.sword)
gems = new EnumGem[] { g1, g2 };
else
gems = new EnumGem[] { g1, g2, g1 };
} else {
// 1 gem
EnumGem g1 = EnumGem.getRandom();
gems = new EnumGem[] { g1, g1, g1 };
}
// Crafting stack array
ItemStack[] craftingStacks = new ItemStack[gems.length];
for (int i = 0; i < craftingStacks.length; ++i) {
craftingStacks[i] = superTier ? gems[i].getItemSuper() : gems[i].getItem();
}
// Select rod
ItemStack rod;
if (superTier) {
ItemStack[] choices = new ItemStack[] { ModItems.craftingMaterial.toolRodGold, ModItems.craftingMaterial.toolRodSilver, ModItems.craftingMaterial.toolRodIron };
rod = choices[SilentGems.random.nextInt(choices.length)];
} else {
ItemStack[] choices = new ItemStack[] { new ItemStack(Items.STICK), new ItemStack(Items.BONE), ModItems.craftingMaterial.toolRodIron };
rod = choices[SilentGems.random.nextInt(choices.length)];
}
ItemStack temp = ToolHelper.constructTool(tool.getItem(), rod, craftingStacks);
if (temp.getItem() instanceof ItemGemKatana)
temp = ((ItemGemKatana) temp.getItem()).addDefaultGrip(temp);
// Set name
String ownerName = nameAdjectives.get(SilentGems.random.nextInt(nameAdjectives.size())) + " " + nameNouns.get(SilentGems.random.nextInt(nameNouns.size()));
ToolHelper.setOriginalOwner(temp, TextFormatting.AQUA + ownerName);
tool.setTagCompound(temp.getTagCompound());
return temp;
}
use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.
the class GemsWorldGenerator method selectState.
/**
* Selects an IBlockState for the config. For gems, it will normally choose one randomly each call. For essence ores,
* it selects the appropriate ore.
*
* @param config
* @param random
* @return
*/
protected IBlockState selectState(ConfigOptionOreGen config, Random random, World world, int posX, int posZ) {
if (config == GemsConfig.WORLD_GEN_GEMS) {
EnumGem gem;
if (GemsConfig.GEM_REGIONS_ENABLED) {
// Gem Regions
long dimension = (long) world.provider.getDimension();
long cx = (long) posX / 16 / GemsConfig.GEM_REGIONS_SIZE;
long cz = (long) posZ / 16 / GemsConfig.GEM_REGIONS_SIZE;
long seed = (world.getSeed() << 40L) | ((dimension & 0xFF) << 32L) | ((cz & 0xFFFF) << 16L) | (cx & 0xFFFF);
Random regionRandom = new Random(seed);
EnumGem firstGem = EnumGem.values()[regionRandom.nextInt(16)];
EnumGem secondGem = EnumGem.values()[regionRandom.nextInt(16)];
if (regionRandom.nextFloat() < GemsConfig.GEM_REGIONS_SECOND_GEM_CHANCE && random.nextBoolean()) {
gem = secondGem;
} else {
gem = firstGem;
}
} else {
// Classic logic
int meta = ((WeightedRandomItemSG) WeightedRandom.getRandomItem(random, GemsConfig.GEM_WEIGHTS)).getMeta();
gem = EnumGem.values()[meta];
}
return ModBlocks.gemOre.getDefaultState().withProperty(EnumGem.VARIANT_GEM, gem);
} else if (config == GemsConfig.WORLD_GEN_CHAOS) {
return ModBlocks.essenceOre.getDefaultState().withProperty(BlockEssenceOre.VARIANT, BlockEssenceOre.Type.CHAOS);
} else if (config == GemsConfig.WORLD_GEN_GEMS_DARK) {
int meta = ((WeightedRandomItemSG) WeightedRandom.getRandomItem(random, GemsConfig.GEM_WEIGHTS_DARK)).getMeta();
EnumGem gem = EnumGem.values()[meta];
return ModBlocks.gemOreDark.getDefaultState().withProperty(EnumGem.VARIANT_GEM, gem);
} else if (config == GemsConfig.WORLD_GEN_ENDER) {
return ModBlocks.essenceOre.getDefaultState().withProperty(BlockEssenceOre.VARIANT, BlockEssenceOre.Type.ENDER);
} else if (config == GemsConfig.WORLD_GEN_GEMS_LIGHT) {
int meta = ((WeightedRandomItemSG) WeightedRandom.getRandomItem(random, GemsConfig.GEM_WEIGHTS_LIGHT)).getMeta();
EnumGem gem = EnumGem.values()[meta];
return ModBlocks.gemOreLight.getDefaultState().withProperty(EnumGem.VARIANT_GEM, gem);
} else {
SilentGems.logHelper.severe("GemsWorldGenerator - Unknown ore config: " + config.name);
return null;
}
}
use of net.silentchaos512.gems.lib.EnumGem in project SilentGems by SilentChaos512.
the class ModuleEntityRandomEquipment method generateRandomMeleeWeapon.
public static ItemStack generateRandomMeleeWeapon(EntityLivingBase entity, Random rand) {
EnumDifficulty worldDiff = entity.world.getDifficulty();
DifficultyInstance localDiff = entity.world.getDifficultyForLocation(entity.getPosition());
boolean superTier = selectBasedOnDifficulty(SUPER_CHANCE, worldDiff, localDiff, rand);
boolean genKatana = superTier && rand.nextFloat() < KATANA_CHANCE;
boolean genMachete = !genKatana && rand.nextFloat() < MACHETE_CHANCE;
ItemGemSword item;
int maxGemCount;
if (genMachete) {
item = ModItems.machete;
maxGemCount = 3;
} else if (genKatana) {
item = ModItems.katana;
maxGemCount = 3;
} else {
item = ModItems.sword;
maxGemCount = rand.nextFloat() < SWORD_EXTRA_GEM_CHANCE ? 3 : 2;
}
Set<EnumGem> gemSet = selectRandomGems(maxGemCount, rand);
List<EnumGem> gemList = expandGemsSet(gemSet, maxGemCount, rand);
List<ItemStack> mats = Lists.newArrayList();
for (EnumGem gem : gemList) mats.add(superTier ? gem.getItemSuper() : gem.getItem());
// SilentGems.logHelper.debug(superTier, gemList);
return item.constructTool(superTier, mats.toArray(new ItemStack[mats.size()]));
}
Aggregations