本文整理匯總了Java中net.minecraft.util.NonNullList.create方法的典型用法代碼示例。如果您正苦於以下問題:Java NonNullList.create方法的具體用法?Java NonNullList.create怎麽用?Java NonNullList.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.NonNullList
的用法示例。
在下文中一共展示了NonNullList.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isValidPosition
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
protected boolean isValidPosition(BlockPos pos) {
IBlockState blockState = worldCache.getBlockState(pos);
Block block = blockState.getBlock();
if (!worldCache.isAirBlock(pos) && !ignoreBlock(block)) {
NonNullList<ItemStack> droppedStacks = NonNullList.create();
if (block.canSilkHarvest(drone.world(), pos, blockState, drone.getFakePlayer())) {
droppedStacks.add(getSilkTouchBlock(block, blockState));
} else {
block.getDrops(droppedStacks, drone.world(), pos, blockState, 0);
}
for (ItemStack droppedStack : droppedStacks) {
if (widget.isItemValidForFilters(droppedStack, blockState)) {
swapBestItemToFirstSlot(pos);
return true;
}
}
}
return false;
}
示例2: isBlockValidForFilter
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static boolean isBlockValidForFilter(IBlockAccess worldCache, IDroneBase drone, BlockPos pos, ProgWidgetAreaItemBase widget) {
IBlockState blockState = worldCache.getBlockState(pos);
Block block = blockState.getBlock();
if (!block.isAir(blockState, worldCache, pos)) {
NonNullList<ItemStack> droppedStacks = NonNullList.create();
if (block.canSilkHarvest(drone.world(), pos, blockState, drone.getFakePlayer())) {
droppedStacks.add(getSilkTouchBlock(block, blockState));
} else {
block.getDrops(droppedStacks, drone.world(), pos, blockState, 0);
}
for (ItemStack droppedStack : droppedStacks) {
if (widget.isItemValidForFilters(droppedStack, blockState)) {
return true;
}
}
}
return false;
}
示例3: createSubItems
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static NonNullList<ItemStack> createSubItems(Item item, CreativeTabs creativeTab, Attribute<String> tabLabels, int[] subtypes)
{
NonNullList<ItemStack> list = NonNullList.create();
if (item.getHasSubtypes())
{
for (int meta : subtypes)
{
tabLabels.get(meta)
.ifPresent(tabLabel ->
{
if (creativeTab == null || creativeTab == CreativeTabs.SEARCH || Objects.equals(tabLabel, getTabLabel(creativeTab)))
{
list.add(new ItemStack(item, 1, meta));
}
});
}
} else
{
list.add(new ItemStack(item, 1, 0));
}
return list;
}
示例4: retrieveOrderItems
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static EntityDrone retrieveOrderItems(AmadronOffer offer, int times, World itemWorld, BlockPos itemPos, World liquidWorld, BlockPos liquidPos) {
if (offer.getInput() instanceof ItemStack) {
if (itemWorld == null || itemPos == null) return null;
ItemStack queryingItems = (ItemStack) offer.getInput();
int amount = queryingItems.getCount() * times;
NonNullList<ItemStack> stacks = NonNullList.create();
while (amount > 0) {
ItemStack stack = queryingItems.copy();
stack.setCount(Math.min(amount, stack.getMaxStackSize()));
stacks.add(stack);
amount -= stack.getCount();
}
return (EntityDrone) DroneRegistry.getInstance().retrieveItemsAmazonStyle(itemWorld, itemPos, stacks.toArray(new ItemStack[stacks.size()]));
} else {
if (liquidWorld == null || liquidPos == null) return null;
FluidStack queryingFluid = ((FluidStack) offer.getInput()).copy();
queryingFluid.amount *= times;
return (EntityDrone) DroneRegistry.getInstance().retrieveFluidAmazonStyle(liquidWorld, liquidPos, queryingFluid);
}
}
示例5: initGui
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public void initGui() {
super.initGui();
this.guiLeft=this.width/2-146;
this.guiTop=this.height/2-120;
this.buttonsItem=new GuiButtonToggleItem[16*6];
itemsToRender=NonNullList.<ItemStack>create();
TF2weapons.tabweapontf2.displayAllRelevantItems(itemsToRender);
TF2weapons.tabutilitytf2.displayAllRelevantItems(itemsToRender);
TF2weapons.tabsurvivaltf2.displayAllRelevantItems(itemsToRender);
for (int x = 0; x < 16; x++)
for (int y = 0; y < 6; y++) {
if(x+y*16<itemsToRender.size()) {
GuiButtonToggleItem button=buttonsItem[x + y * 16]=new GuiButtonToggleItem(x + y * 16,
this.guiLeft + 4 + x * 18, this.guiTop + 34 + y * 18, 18, 18);
this.buttonList.add(button);
}
}
this.buttonList.add(new GuiButton(96, this.guiLeft+200, this.guiTop+14, "Back"));
//this.buttonList.get(96).visible=false;
this.setButtons();
}
示例6: parse
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public IRecipe parse(JsonContext context, JsonObject json)
{
String group = JsonUtils.getString(json, "group", "");
NonNullList<Ingredient> ings = NonNullList.create();
for(JsonElement ele : JsonUtils.getJsonArray(json, "ingredients"))
ings.add(CraftingHelper.getIngredient(ele, context));
if(ings.isEmpty())
throw new JsonParseException("No ingredients for shapeless recipe");
if(ings.size() > 9)
throw new JsonParseException("Too many ingredients for shapeless recipe");
ItemStack itemstack = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
return new RecipeTorchGun(group, itemstack, ings);
}
示例7: createInput
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
/**
* Creates a list of ingredients based on an Object[]. Valid types are {@link String}, {@link ItemStack}, {@link Item}, and {@link Block}.
* Used for shapeless recipes.
*/
private static NonNullList<Ingredient> createInput(Object[] input)
{
if (input[0] instanceof List)
input = ((List<?>) input[0]).toArray();
else if (input[0] instanceof Object[])
input = (Object[]) input[0];
NonNullList<Ingredient> inputL = NonNullList.create();
for (int i = 0; i < input.length; i++)
{
Object k = input[i];
if (k instanceof String)
inputL.add(i, new OreIngredient((String) k));
else if (k instanceof ItemStack && !((ItemStack) k).isEmpty())
inputL.add(i, Ingredient.fromStacks((ItemStack) k));
else if (k instanceof IForgeRegistryEntry)
inputL.add(i, Ingredient.fromStacks(makeStack((IForgeRegistryEntry<?>) k)));
else
throw new UnsupportedOperationException(
"Attempted to add invalid shapeless recipe. Complain to the author of " + MODNAME);
}
return inputL;
}
示例8: getBlocksFromString
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static ArrayList<Block> getBlocksFromString(String blockName)
{
ArrayList<Block> blocks = new ArrayList<>();
if(!HarshenUtils.toArray(Blocks.AIR, null).contains(Block.getBlockFromName(blockName)))
blocks.add(Block.getBlockFromName(blockName));
for(ItemStack oreStack : OreDictionary.getOres(blockName))
if(oreStack.getItem() instanceof ItemBlock)
blocks.add(((ItemBlock)oreStack.getItem()).getBlock());
ArrayList<Block> finalBlocks = new ArrayList<>();
for(Block b : blocks)
{
NonNullList<ItemStack> items = NonNullList.create();
b.getSubBlocks(CreativeTabs.SEARCH, items);
for(ItemStack stack : items)
if(!stack.isEmpty())
finalBlocks.add(Block.getBlockFromItem(stack.getItem()));
else
finalBlocks.add(b);
}
return finalBlocks;
}
示例9: registerItemModel
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public void registerItemModel(Item item) {
ResourceLocation loc = Item.REGISTRY.getNameForObject(item);
if (item instanceof ItemBlockEquivalentState) {
NonNullList<ItemStack> subItems = NonNullList.create();
item.getSubItems(ThermionicsWorld.TAB_THERMIONICS_WORLD, subItems);
for(ItemStack stack : subItems) {
Item stackItem = stack.getItem();
if (stackItem!=item) continue; //The contract of getSubItems prohibits this condition.
String keys = ((ItemBlockEquivalentState)item).getStateStringForItem(stack);
//System.out.println("Registering model for "+loc+"#"+keys+" == meta:"+stack.getItemDamage());
ModelLoader.setCustomModelResourceLocation(stackItem, stack.getItemDamage(),
new ModelResourceLocation(loc, keys)
);
}
} else if (item instanceof ItemBlockGemrock) {
for(int i=0; i<16; i++) {
ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(loc,"variant="+i));
}
} else if (item instanceof ItemBlockVarieties) {
for(int i=0; i<16; i++) {
ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(loc,"variant="+i));
}
} else {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(loc, "inventory"));
}
}
示例10: getItemsUsedForInput
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static NonNullList<ItemStack> getItemsUsedForInput(NBTTagCompound tag) {
NonNullList<ItemStack> list = NonNullList.create();
NBTTagList tagList = tag.getTagList("itemsUsed", NBT.TAG_COMPOUND);
tagList.forEach(nbt -> {
NBTTagCompound itemTag = (NBTTagCompound) nbt;
list.add(new ItemStack(itemTag));
});
return list;
}
示例11: getSubItems
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
if (this.isInCreativeTab(tab)) {
super.getSubItems(tab, list);
NonNullList<ItemStack> potions = NonNullList.create();
Items.POTIONITEM.getSubItems(tab, potions);
for (ItemStack potion : potions) {
ItemStack ammo = new ItemStack(this);
setPotion(ammo, potion);
list.add(ammo);
}
}
}
示例12: getMatchingStacks
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public ItemStack[] getMatchingStacks()
{
if (foodArray == null || foodArray.length != foodItems.size())
{
NonNullList<ItemStack> lst = NonNullList.create();
for (Item item : foodItems)
{
ItemStack stack = new ItemStack(item);
lst.add(stack);
}
foodArray = lst.toArray(new ItemStack[lst.size()]);
}
return foodArray;
}
示例13: getAllBlocks
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static Collection<ItemStack> getAllBlocks(Block block) {
NonNullList<ItemStack> list = NonNullList.create();
if(block != null) {
block.getSubBlocks(null, list);
}
return Collections.unmodifiableCollection(list);
}
示例14: parse
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public IRecipe parse(JsonContext context, JsonObject json)
{
String group = JsonUtils.getString(json, "group", "");
NonNullList<Ingredient> ings = NonNullList.create();
for (JsonElement ele : JsonUtils.getJsonArray(json, "ingredients"))
ings.add(CraftingHelper.getIngredient(ele, context));
if (ings.isEmpty())
throw new JsonParseException("No ingredients for shapeless recipe");
ItemStack itemstack = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
int[] damage = new int[ings.size()];
if (JsonUtils.hasField(json, "damage"))
{
JsonArray array = JsonUtils.getJsonArray(json, "damage");
if (array.size() > damage.length)
throw new JsonParseException("Too many values for damage array: got " + array.size() + ", expected " + damage.length);
for (int i = 0; i < array.size(); i++)
{
JsonElement element = array.get(i);
if (!element.isJsonPrimitive() || !element.getAsJsonPrimitive().isNumber())
throw new JsonSyntaxException("Entry in damage array is not a number, got " + element);
damage[i] = element.getAsJsonPrimitive().getAsInt();
}
}
return new DamageableShapelessOreRecipe(group.isEmpty() ? null : new ResourceLocation(group), damage, ings, itemstack);
}
示例15: doHarvestOperation
import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public List<ItemStack> doHarvestOperation(World world, BlockPos pos, IBlockState blockState) {
NonNullList<ItemStack> stacks = NonNullList.create();
blockState.getBlock().getDrops(stacks, world, pos, blockState, 0);
world.setBlockToAir(pos);
return stacks;
}