Skip to content

Package net.minecraft.util.random

Part 1/1


SimpleWeightedRandomList

  • Full name: net.minecraft.util.random.SimpleWeightedRandomList
  • Package: net.minecraft.util.random
  • Source: commonnet/minecraft/util/random/SimpleWeightedRandomList.java
  • Type: class
  • Modifiers: public
  • Extends: WeightedRandomList<WeightedEntry.Wrapper<E>>

net.minecraft.util.random.SimpleWeightedRandomList#builder()

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:23
  • Modifiers: public static
  • Return: SimpleWeightedRandomList.Builder<E>

คืออะไร

ดำเนินการ builder ตาม implementation ของ SimpleWeightedRandomList

ทำงานยังไง

สร้างออบเจ็กต์: SimpleWeightedRandomList.Builder<>. คืนค่า: new SimpleWeightedRandomList.Builder<>().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

SimpleWeightedRandomList.Builder<E> result = SimpleWeightedRandomList.builder();

net.minecraft.util.random.SimpleWeightedRandomList#empty()

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:27
  • Modifiers: public static
  • Return: SimpleWeightedRandomList<E>

คืออะไร

ดำเนินการ empty ตาม implementation ของ SimpleWeightedRandomList

ทำงานยังไง

เรียกต่อ: of(). สร้างออบเจ็กต์: SimpleWeightedRandomList<>. คืนค่า: new SimpleWeightedRandomList<>(List.of()).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

SimpleWeightedRandomList<E> result = SimpleWeightedRandomList.empty();

net.minecraft.util.random.SimpleWeightedRandomList#getRandomValue(RandomSource)

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:35
  • Modifiers: public
  • Return: Optional<E>

คืออะไร

อ่านค่า Random Value

ทำงานยังไง

เรียกต่อ: getRandom(), map(). คืนค่า: this.getRandom(randomSource).map(WeightedEntry.Wrapper::data).

Parameters

  • RandomSource randomSource

ตัวอย่างใช้งาน

SimpleWeightedRandomList instance = ...;
RandomSource randomSource = ...;
Optional<E> result = instance.getRandomValue(randomSource);

net.minecraft.util.random.SimpleWeightedRandomList#single(E)

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:31
  • Modifiers: public static
  • Return: SimpleWeightedRandomList<E>

คืออะไร

ดำเนินการ single ตาม implementation ของ SimpleWeightedRandomList

ทำงานยังไง

เรียกต่อ: of(), wrap(). สร้างออบเจ็กต์: SimpleWeightedRandomList<>. คืนค่า: new SimpleWeightedRandomList<>(List.of(WeightedEntry.wrap(object, 1))).

Parameters

  • E object

ตัวอย่างใช้งาน

E object = ...;
SimpleWeightedRandomList<E> result = SimpleWeightedRandomList.single(object);

net.minecraft.util.random.SimpleWeightedRandomList#wrappedCodec(Codec<E>)

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:15
  • Modifiers: public static
  • Return: Codec<SimpleWeightedRandomList<E>>

คืออะไร

ดำเนินการ wrappedCodec ตาม implementation ของ SimpleWeightedRandomList

ทำงานยังไง

เรียกต่อ: nonEmptyList(), codec(), listOf(), xmap(). คืนค่า: ExtraCodecs.nonEmptyList(WeightedEntry.Wrapper.codec(codec).listOf()).xmap(SimpleWeightedRandomList::new, WeightedRandomList::unwrap).

Parameters

  • Codec<E> codec

ตัวอย่างใช้งาน

Codec<E> codec = ...;
Codec<SimpleWeightedRandomList<E>> result = SimpleWeightedRandomList.wrappedCodec(codec);

net.minecraft.util.random.SimpleWeightedRandomList#wrappedCodecAllowingEmpty(Codec<E>)

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:11
  • Modifiers: public static
  • Return: Codec<SimpleWeightedRandomList<E>>

คืออะไร

ดำเนินการ wrappedCodecAllowingEmpty ตาม implementation ของ SimpleWeightedRandomList

ทำงานยังไง

เรียกต่อ: codec(), listOf(), xmap(). คืนค่า: WeightedEntry.Wrapper.codec(codec).listOf().xmap(SimpleWeightedRandomList::new, WeightedRandomList::unwrap).

Parameters

  • Codec<E> codec

ตัวอย่างใช้งาน

Codec<E> codec = ...;
Codec<SimpleWeightedRandomList<E>> result = SimpleWeightedRandomList.wrappedCodecAllowingEmpty(codec);

SimpleWeightedRandomList$Builder

  • Full name: net.minecraft.util.random.SimpleWeightedRandomList$Builder
  • Package: net.minecraft.util.random
  • Source: commonnet/minecraft/util/random/SimpleWeightedRandomList.java
  • Type: class
  • Modifiers: public static

net.minecraft.util.random.SimpleWeightedRandomList$Builder#add(E)

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:42
  • Modifiers: public
  • Return: SimpleWeightedRandomList.Builder<E>

คืออะไร

เพิ่ม add

ทำงานยังไง

คืนค่า: this.add(object, 1).

Parameters

  • E object

ตัวอย่างใช้งาน

SimpleWeightedRandomList.Builder instance = ...;
E object = ...;
SimpleWeightedRandomList.Builder<E> result = instance.add(object);

net.minecraft.util.random.SimpleWeightedRandomList$Builder#add(E,int)

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:46
  • Modifiers: public
  • Return: SimpleWeightedRandomList.Builder<E>

คืออะไร

เพิ่ม add

ทำงานยังไง

เรียกต่อ: wrap(). คืนค่า: this.

Parameters

  • E object
  • int i

ตัวอย่างใช้งาน

SimpleWeightedRandomList.Builder instance = ...;
E object = ...;
SimpleWeightedRandomList.Builder<E> result = instance.add(object, 0);

net.minecraft.util.random.SimpleWeightedRandomList$Builder#build()

  • Origin: common
  • Source: net/minecraft/util/random/SimpleWeightedRandomList.java:51
  • Modifiers: public
  • Return: SimpleWeightedRandomList<E>

คืออะไร

สร้าง build

ทำงานยังไง

สร้างออบเจ็กต์: SimpleWeightedRandomList<>. คืนค่า: new SimpleWeightedRandomList<>(this.result.build()).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

SimpleWeightedRandomList.Builder instance = ...;
SimpleWeightedRandomList<E> result = instance.build();

Weight

  • Full name: net.minecraft.util.random.Weight
  • Package: net.minecraft.util.random
  • Source: commonnet/minecraft/util/random/Weight.java
  • Type: class
  • Modifiers: public

net.minecraft.util.random.Weight#asInt()

  • Origin: common
  • Source: net/minecraft/util/random/Weight.java:28
  • Modifiers: public
  • Return: int

คืออะไร

ดำเนินการ asInt ตาม implementation ของ Weight

ทำงานยังไง

คืนค่า: this.value.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

Weight instance = ...;
int result = instance.asInt();

net.minecraft.util.random.Weight#equals(Object)

  • Origin: common
  • Source: net/minecraft/util/random/Weight.java:52
  • Modifiers: public
  • Return: boolean

คืออะไร

เปรียบเทียบความเท่ากัน equals

ทำงานยังไง

แก้ state: value. คืนค่า: this == object ? true : object instanceof Weight && this.value == ((Weight)object).value.

Parameters

  • Object object

ตัวอย่างใช้งาน

Weight instance = ...;
Object object = ...;
boolean result = instance.equals(object);

net.minecraft.util.random.Weight#hashCode()

  • Origin: common
  • Source: net/minecraft/util/random/Weight.java:47
  • Modifiers: public
  • Return: int

คืออะไร

ดำเนินการ hashCode ตาม implementation ของ Weight

ทำงานยังไง

คืนค่า: Integer.hashCode(this.value).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

Weight instance = ...;
int result = instance.hashCode();

net.minecraft.util.random.Weight#of(int)

  • Origin: common
  • Source: net/minecraft/util/random/Weight.java:19
  • Modifiers: public static
  • Return: Weight

คืออะไร

ดำเนินการ of ตาม implementation ของ Weight

ทำงานยังไง

ตรวจเงื่อนไขด้วย if. เรียกต่อ: validateWeight(). สร้างออบเจ็กต์: Weight. มีจุด return อย่างน้อย 2 จุด.

Parameters

  • int i

ตัวอย่างใช้งาน

Weight result = Weight.of(0);

net.minecraft.util.random.Weight#toString()

  • Origin: common
  • Source: net/minecraft/util/random/Weight.java:42
  • Modifiers: public
  • Return: String

คืออะไร

ดำเนินการ toString ตาม implementation ของ Weight

ทำงานยังไง

คืนค่า: Integer.toString(this.value).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

Weight instance = ...;
String result = instance.toString();

WeightedEntry

  • Full name: net.minecraft.util.random.WeightedEntry
  • Package: net.minecraft.util.random
  • Source: commonnet/minecraft/util/random/WeightedEntry.java
  • Type: interface
  • Modifiers: public

net.minecraft.util.random.WeightedEntry#getWeight()

  • Origin: common
  • Source: net/minecraft/util/random/WeightedEntry.java:9
  • Modifiers: ``
  • Return: Weight

คืออะไร

อ่านค่า Weight

ทำงานยังไง

ไม่มี body ใน source declaration นี้

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

WeightedEntry instance = ...;
Weight result = instance.getWeight();

net.minecraft.util.random.WeightedEntry#wrap(T,int)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedEntry.java:11
  • Modifiers: static
  • Return: WeightedEntry.Wrapper<T>

คืออะไร

ดำเนินการ wrap ตาม implementation ของ WeightedEntry

ทำงานยังไง

เรียกต่อ: of(). สร้างออบเจ็กต์: WeightedEntry.Wrapper<>. คืนค่า: new WeightedEntry.Wrapper<>(object, Weight.of(i)).

Parameters

  • T object
  • int i

ตัวอย่างใช้งาน

T object = ...;
WeightedEntry.Wrapper<T> result = WeightedEntry.wrap(object, 0);

WeightedRandom

  • Full name: net.minecraft.util.random.WeightedRandom
  • Package: net.minecraft.util.random
  • Source: commonnet/minecraft/util/random/WeightedRandom.java
  • Type: class
  • Modifiers: public

net.minecraft.util.random.WeightedRandom#getRandomItem(RandomSource,List<T>)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandom.java:50
  • Modifiers: public static
  • Return: Optional<T>

คืออะไร

อ่านค่า Random Item

ทำงานยังไง

เรียกต่อ: getTotalWeight(). คืนค่า: getRandomItem(randomSource, list, getTotalWeight(list)).

Parameters

  • RandomSource randomSource
  • List<T> list

ตัวอย่างใช้งาน

RandomSource randomSource = ...;
List<T> list = ...;
Optional<T> result = WeightedRandom.getRandomItem(randomSource, list);

net.minecraft.util.random.WeightedRandom#getRandomItem(RandomSource,List<T>,int)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandom.java:26
  • Modifiers: public static
  • Return: Optional<T>

คืออะไร

อ่านค่า Random Item

ทำงานยังไง

ตรวจเงื่อนไขด้วย if. เรียกต่อ: pauseInIde(), empty(), nextInt(), getWeightedItem(). สร้างออบเจ็กต์: IllegalArgumentException. มีจุด return อย่างน้อย 2 จุด.

Parameters

  • RandomSource randomSource
  • List<T> list
  • int i

ตัวอย่างใช้งาน

RandomSource randomSource = ...;
List<T> list = ...;
Optional<T> result = WeightedRandom.getRandomItem(randomSource, list, 0);

net.minecraft.util.random.WeightedRandom#getTotalWeight(List<? extends WeightedEntry>)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandom.java:12
  • Modifiers: public static
  • Return: int

คืออะไร

อ่านค่า Total Weight

ทำงานยังไง

ตรวจเงื่อนไขด้วย if ; มีการวนลูป. เรียกต่อ: getWeight(), asInt(). สร้างออบเจ็กต์: IllegalArgumentException. คืนค่า: (int)l.

Parameters

  • List<? extends WeightedEntry> list

ตัวอย่างใช้งาน

List<? extends WeightedEntry> list = ...;
int result = WeightedRandom.getTotalWeight(list);

net.minecraft.util.random.WeightedRandom#getWeightedItem(List<T>,int)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandom.java:39
  • Modifiers: public static
  • Return: Optional<T>

คืออะไร

อ่านค่า Weighted Item

ทำงานยังไง

ตรวจเงื่อนไขด้วย if ; มีการวนลูป. เรียกต่อ: getWeight(), asInt(), of(), empty(). มีจุด return อย่างน้อย 2 จุด.

Parameters

  • List<T> list
  • int i

ตัวอย่างใช้งาน

List<T> list = ...;
Optional<T> result = WeightedRandom.getWeightedItem(list, 0);

WeightedRandomList

  • Full name: net.minecraft.util.random.WeightedRandomList
  • Package: net.minecraft.util.random
  • Source: commonnet/minecraft/util/random/WeightedRandomList.java
  • Type: class
  • Modifiers: public

net.minecraft.util.random.WeightedRandomList#codec(Codec<E>)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:50
  • Modifiers: public static
  • Return: Codec<WeightedRandomList<E>>

คืออะไร

ดำเนินการ codec ตาม implementation ของ WeightedRandomList

ทำงานยังไง

เรียกต่อ: listOf(), xmap(). คืนค่า: codec.listOf().xmap(WeightedRandomList::create, WeightedRandomList::unwrap).

Parameters

  • Codec<E> codec

ตัวอย่างใช้งาน

Codec<E> codec = ...;
Codec<WeightedRandomList<E>> result = WeightedRandomList.codec(codec);

net.minecraft.util.random.WeightedRandomList#create()

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:20
  • Modifiers: public static
  • Return: WeightedRandomList<E>

คืออะไร

สร้าง create

ทำงานยังไง

เรียกต่อ: of(). สร้างออบเจ็กต์: WeightedRandomList<>. คืนค่า: new WeightedRandomList<>(ImmutableList.of()).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

WeightedRandomList<E> result = WeightedRandomList.create();

net.minecraft.util.random.WeightedRandomList#create(E[])

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:24
  • Modifiers: public static
  • Return: WeightedRandomList<E>

คืออะไร

สร้าง create

ทำงานยังไง

เรียกต่อ: copyOf(). สร้างออบเจ็กต์: WeightedRandomList<>. คืนค่า: new WeightedRandomList<>(ImmutableList.copyOf(weightedEntrys)).

Parameters

  • E[] weightedEntrys

ตัวอย่างใช้งาน

E[] weightedEntrys = ...;
WeightedRandomList<E> result = WeightedRandomList.create(weightedEntrys);

net.minecraft.util.random.WeightedRandomList#create(List<E>)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:29
  • Modifiers: public static
  • Return: WeightedRandomList<E>

คืออะไร

สร้าง create

ทำงานยังไง

สร้างออบเจ็กต์: WeightedRandomList<>. คืนค่า: new WeightedRandomList<>(list).

Parameters

  • List<E> list

ตัวอย่างใช้งาน

List<E> list = ...;
WeightedRandomList<E> result = WeightedRandomList.create(list);

net.minecraft.util.random.WeightedRandomList#equals(Object)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:54
  • Modifiers: public
  • Return: boolean

คืออะไร

เปรียบเทียบความเท่ากัน equals

ทำงานยังไง

ตรวจเงื่อนไขด้วย if. แก้ state: totalWeight. เรียกต่อ: getClass(). มีจุด return อย่างน้อย 3 จุด.

Parameters

  • Object object

ตัวอย่างใช้งาน

WeightedRandomList instance = ...;
Object object = ...;
boolean result = instance.equals(object);

net.minecraft.util.random.WeightedRandomList#getRandom(RandomSource)

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:37
  • Modifiers: public
  • Return: Optional<E>

คืออะไร

อ่านค่า Random

ทำงานยังไง

ตรวจเงื่อนไขด้วย if. แก้ state: totalWeight. เรียกต่อ: empty(), nextInt(), getWeightedItem(). มีจุด return อย่างน้อย 2 จุด.

Parameters

  • RandomSource randomSource

ตัวอย่างใช้งาน

WeightedRandomList instance = ...;
RandomSource randomSource = ...;
Optional<E> result = instance.getRandom(randomSource);

net.minecraft.util.random.WeightedRandomList#hashCode()

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:66
  • Modifiers: public
  • Return: int

คืออะไร

ดำเนินการ hashCode ตาม implementation ของ WeightedRandomList

ทำงานยังไง

เรียกต่อ: hash(). คืนค่า: Objects.hash(this.totalWeight, this.items).

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

WeightedRandomList instance = ...;
int result = instance.hashCode();

net.minecraft.util.random.WeightedRandomList#isEmpty()

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:33
  • Modifiers: public
  • Return: boolean

คืออะไร

ตรวจสอบสถานะ Empty

ทำงานยังไง

คืนค่า: this.items.isEmpty().

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

WeightedRandomList instance = ...;
boolean result = instance.isEmpty();

net.minecraft.util.random.WeightedRandomList#unwrap()

  • Origin: common
  • Source: net/minecraft/util/random/WeightedRandomList.java:46
  • Modifiers: public
  • Return: List<E>

คืออะไร

ดำเนินการ unwrap ตาม implementation ของ WeightedRandomList

ทำงานยังไง

คืนค่า: this.items.

Parameters

  • ไม่มี

ตัวอย่างใช้งาน

WeightedRandomList instance = ...;
List<E> result = instance.unwrap();