本文整理匯總了Java中net.minecraft.enchantment.EnchantmentData類的典型用法代碼示例。如果您正苦於以下問題:Java EnchantmentData類的具體用法?Java EnchantmentData怎麽用?Java EnchantmentData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EnchantmentData類屬於net.minecraft.enchantment包,在下文中一共展示了EnchantmentData類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performWork
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
@Override
protected float performWork() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
if (!hasBooks() || getItem().isEmpty()) return 0;
ItemStack enchantedItem = getItem();
ItemStack enchantedBook = new ItemStack(Items.ENCHANTED_BOOK);
if (ItemHandlerHelper.insertItem(outEnchanted, enchantedBook, true).isEmpty() && ItemHandlerHelper.insertItem(outItem, enchantedItem, true).isEmpty()) {
NBTTagCompound base = (NBTTagCompound) enchantedItem.getEnchantmentTagList().get(0);
((ItemEnchantedBook) Items.ENCHANTED_BOOK).addEnchantment(enchantedBook, new EnchantmentData(Enchantment.getEnchantmentByID(base.getShort("id")), base.getShort("lvl")));
enchantedItem.getEnchantmentTagList().removeTag(0);
ItemHandlerHelper.insertItem(outEnchanted, enchantedBook, false);
ItemHandlerHelper.insertItem(outItem, enchantedItem.copy(), false);
inBook.getStackInSlot(0).setCount(inBook.getStackInSlot(0).getCount() - 1);
enchantedItem.setCount(enchantedItem.getCount() - 1);
return 500;
}
return 0;
}
示例2: addEnchantmentBooksToList
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
/**
* Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
*/
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
for (Enchantment enchantment : Enchantment.enchantmentsBookList)
{
if (enchantment != null && enchantment.type != null)
{
boolean flag = false;
for (int i = 0; i < enchantmentType.length && !flag; ++i)
{
if (enchantment.type == enchantmentType[i])
{
flag = true;
}
}
if (flag)
{
itemList.add(Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
}
}
}
}
示例3: func_190888_a
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
public void func_190888_a(IMerchant p_190888_1_, MerchantRecipeList p_190888_2_, Random p_190888_3_)
{
Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(p_190888_3_);
int i = MathHelper.getInt(p_190888_3_, enchantment.getMinLevel(), enchantment.getMaxLevel());
ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
int j = 2 + p_190888_3_.nextInt(5 + i * 10) + 3 * i;
if (enchantment.isTreasureEnchantment())
{
j *= 2;
}
if (j > 64)
{
j = 64;
}
p_190888_2_.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
示例4: addEnchantmentBooksToList
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
/**
* Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
*/
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
for (Enchantment enchantment : Enchantment.REGISTRY)
{
if (enchantment != null && enchantment.type != null)
{
boolean flag = false;
for (int i = 0; i < enchantmentType.length && !flag; ++i)
{
if (enchantment.type == enchantmentType[i])
{
flag = true;
}
}
if (flag)
{
itemList.add(Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
}
}
}
}
示例5: modifyMerchantRecipeList
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
/**
* Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
*/
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random);
int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
int j = 2 + random.nextInt(5 + i * 10) + 3 * i;
if (enchantment.isTreasureEnchantment())
{
j *= 2;
}
if (j > 64)
{
j = 64;
}
recipeList.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
示例6: addEnchantmentBooksToList
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
/**
* Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
*/
@SideOnly(Side.CLIENT)
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
for (Enchantment enchantment : Enchantment.REGISTRY)
{
if (enchantment != null && enchantment.type != null)
{
boolean flag = false;
for (int i = 0; i < enchantmentType.length && !flag; ++i)
{
if (enchantment.type == enchantmentType[i])
{
flag = true;
}
}
if (flag)
{
itemList.add(Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
}
}
}
}
示例7: manipulateTradesForVillager
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random)
{
for (int i = 0; i < 4; i++)
{
switch(villager.getProfession())
{
case 0: // FARMER
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 2), new ItemStack(Items.apple, 1)));
break;
case 1: // LIBRARIAN
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 4, 15), new ItemStack(Items.paper, 1, 6)));
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 1), Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(Enchantment.flame, 1))));
break;
case 2: // PRIEST
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 6), new ItemStack(Items.apple, 2), new ItemStack(Items.apple, 2)));
break;
case 3: // BLACKSMITH
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 6 + random.nextInt(6)), new ItemStack(Items.apple, 5 + random.nextInt(4)), new ItemStack(Items.apple, 1)));
recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.ETHERNIUM, 64), new ItemStack(ItemRegister.ELLAMAYNE, 1)));
break;
default:
break;
}
}
}
示例8: testEnchantsAndAdd
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
private void testEnchantsAndAdd(int seed, Observation observation) {
for (int i = 0; i < 3; ++i) {
int level = observation.levels[i];
if (level == 0) {
tempEnchantmentData[i] = null;
continue;
}
List<EnchantmentData> list = buildEnchantmentList(seed, observation, i);
tempEnchantmentData[i] = list;
if (!list.isEmpty()) {
EnchantmentData data = list.get(rand.nextInt(list.size()));
if (Enchantment.getEnchantmentByID(observation.enchants[i]) != data.enchantmentobj ||
observation.enchantLevels[i] != data.enchantmentLevel) {
return;
}
} else {
// Real enchant has something for this slot, but we found nothing.
return;
}
}
addCandidate(seed);
tallyEnchants();
}
示例9: tallyEnchants
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
private void tallyEnchants() {
for (int i = 0; i < 3; ++i) {
ArrayList<EnchantCount> list = enchantCounts[i];
List<EnchantmentData> enchantData = tempEnchantmentData[i];
if (enchantData == null) {
continue;
}
outer: for (EnchantmentData data : enchantData) {
final int size = list.size();
for (int j = 0; j < size; ++j) {
EnchantCount pair = list.get(j);
if (EnchantCount.equals(pair.enchant, data)) {
pair.count++;
continue outer;
}
}
list.add(new EnchantCount(1, data));
}
}
}
示例10: UnderworldTower
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
public UnderworldTower(Random rand, int par2, int par3)
{
super(rand, par2, 64, par3, 11, 25, 11);
this.spawnMinY = 32;
this.spawnMaxY = 180;
ItemStack bookThor = new ItemStack(Items.ENCHANTED_BOOK), bookAura = new ItemStack(Items.ENCHANTED_BOOK);
Items.ENCHANTED_BOOK.addEnchantment(bookThor, new EnchantmentData(LCEnchantments.handOfThor, 1));
Items.ENCHANTED_BOOK.addEnchantment(bookAura, new EnchantmentData(LCEnchantments.elecAura, 1));
WeightedRandomChestContent contentBookThor = new WeightedRandomChestContent(null, 0, 1, 2, 2); contentBookThor.theItemId = bookThor;
WeightedRandomChestContent contentBookAura = new WeightedRandomChestContent(null, 0, 1, 2, 2); contentBookAura.theItemId = bookAura;
lootChests = new LootChestGroup(nChests, minStacks, maxStacks, new WeightedRandomChestContent[]
{new WeightedRandomChestContent(LCItems.material, Material.DEMON_BLOOD, 1, 3, 5), new WeightedRandomChestContent(Items.DIAMOND, 0, 1, 5, 20),
new WeightedRandomChestContent(Items.GOLD_INGOT, 0, 2, 7, 20), new WeightedRandomChestContent(Items.EMERALD, 0, 1, 3, 20),
new WeightedRandomChestContent(Items.FIRE_CHARGE, 0, 4, 6, 15), new WeightedRandomChestContent(Items.IRON_INGOT, 0, 3, 7, 20),
new WeightedRandomChestContent(LCItems.elecBoots, 0, 1, 1, 1), new WeightedRandomChestContent(LCItems.elecLegs, 0, 1, 1, 1),
new WeightedRandomChestContent(LCItems.elecHelm, 0, 1, 1, 1), new WeightedRandomChestContent(LCItems.elecChest, 0, 1, 1, 1),
new WeightedRandomChestContent(LCItems.elecSword, 0, 1, 1, 1), new WeightedRandomChestContent(LCItems.ingot, Ingot.SKY, 1, 1, 1),
new WeightedRandomChestContent(LCItems.ingot, Ingot.ELEC, 1, 5, 10), contentBookThor, contentBookAura});
}
示例11: addEnchantmentRecipe
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
public static void addEnchantmentRecipe( ItemStack[] items, EnchantmentData out, EnchantmentData in )
{
if ( items.length > 8 )
{
throw new IllegalArgumentException( "8 itemstacks must be provided!" );
}
else if ( out == null )
{
throw new IllegalArgumentException( "Enchantment must be provided for output!" );
}
Recipe r = new Recipe();
r.out = out;
r.in = in;
r.recipe = items;
if ( items.length < 8 )
{
ItemStack[] newItems = new ItemStack[ 8 ];
for ( int i = 0; i < items.length; newItems[ i ] = items[ i++ ] );
r.recipe = newItems;
}
recipes.add( r );
}
示例12: doEnchantment
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
private void doEnchantment( Enchantment ench, int level, Item mat1, int amt1, Item mat2, int amt2, EnchantmentData start )
{
for ( int i = 1; i <= level; ++i )
{
ItemStack[] items = new ItemStack[ 8 ];
int ii = 0;
for ( ; ii < amt1; ++ii )
{
items[ ii ] = new ItemStack( mat1 );
}
for ( ; ii < amt1 + amt2; ++ii )
{
items[ ii ] = new ItemStack( mat2 );
}
EnchantmentData out = new EnchantmentData( ench, i );
EnchantmentData in = ( i != 1 ) ? new EnchantmentData( ench, i - 1 ) : start;
EnchantedBookRecipes.addEnchantmentRecipe( items, out, in );
}
}
示例13: equals
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
@Override
public boolean equals (Object other) {
if (!(other instanceof EnchantmentData)) {
return false;
}
final EnchantmentData data = (EnchantmentData) other;
boolean equal = false;
if (this.enchantment.getRegistryName().equals(data.enchantment.getRegistryName())) {
equal = true;
}
if (this.enchantmentLevel == data.enchantmentLevel) {
equal = true;
}
return equal || super.equals(other);
}
示例14: doEnchantment
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
private static void doEnchantment( Enchantment ench, int level, Item mat1, int amt1, Item mat2, int amt2, EnchantmentData start )
{
for ( int i = 1; i <= level; ++i )
{
ItemStack[] items = new ItemStack[ 8 ];
int ii = 0;
for ( ; ii < amt1; ++ii )
{
items[ ii ] = new ItemStack( mat1 );
}
for ( ; ii < amt1 + amt2; ++ii )
{
items[ ii ] = new ItemStack( mat2 );
}
EnchantmentData out = new EnchantmentData( ench, i );
EnchantmentData in = ( i != 1 ) ? new EnchantmentData( ench, i - 1 ) : start;
EnchantedBookRecipes.addEnchantmentRecipe( items, out, in );
}
}
示例15: onEntityKill
import net.minecraft.enchantment.EnchantmentData; //導入依賴的package包/類
@SubscribeEvent
public void onEntityKill(LivingDropsEvent event){
if(event.entityLiving instanceof EntitySkeleton){
if(((EntitySkeleton) event.entityLiving).getSkeletonType() == 1){
if(Math.round(Marble.rand.nextFloat() * 100) < ConfigHandler.witherOneDropChance){
MiscHelper.drop(event, Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(ConfigHandler.witheringID, 1)));
}
}
}
if(event.entityLiving instanceof EntityWither){
if(Math.round(Marble.rand.nextInt()) < ConfigHandler.witherTwoDropChance){
MiscHelper.drop(event, Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(ConfigHandler.witheringID, 2)));
}
}
}