ItemTool class
Пакет: com.hypixel.hytale.server.core.asset.type.item.config
Файл: com/hypixel/hytale/server/core/asset/type/item/config/ItemTool.java
implements: NetworkSerializable<com.hypixel.hytale.protocol.ItemTool>
Поля (13)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
BuilderCodec<ItemTool> |
CODEC |
|
public static final BuilderCodec<ItemTool.DurabilityLossBlockTypes> |
CODEC |
|
protected int[] |
blockSetIndexes |
|
protected String[] |
blockSets |
|
protected int[] |
blockTypeIndexes |
|
protected String[] |
blockTypes |
|
protected double |
durabilityLossOnHit |
|
com.hypixel.hytale.protocol.ItemTool |
var1 |
|
int[] |
var1 |
|
String |
var2 |
|
int |
var3 |
|
String |
var3 |
|
int |
var4 |
Методы (26)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
protected |
DurabilityLossBlockTypesprotected DurabilityLossBlockTypes() |
|
public |
DurabilityLossBlockTypespublic DurabilityLossBlockTypes(String[] var1, String[] var2, double var3) |
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Unknown key! " + var2) |
abstract |
throw new |
IllegalArgumentExceptionthrow new IllegalArgumentException("Unknown key! " + var3) |
|
|
for for(int var1 = 0; var1 < var0.blockSets.length; var1++) |
|
|
for for(int var2 = 0; var2 < this.blockTypes.length; var2++) |
|
public int[] |
getBlockSetIndexespublic int[] getBlockSetIndexes() |
|
public String[] |
getBlockSetspublic String[] getBlockSets() |
|
public int[] |
getBlockTypeIndexespublic int[] getBlockTypeIndexes() |
|
public String[] |
getBlockTypespublic String[] getBlockTypes() |
public |
ItemTool.DurabilityLossBlockTypes[] |
getDurabilityLossBlockTypesItemTool.DurabilityLossBlockTypes[] getDurabilityLossBlockTypes() |
|
public double |
getDurabilityLossOnHitpublic double getDurabilityLossOnHit() |
public |
int |
getHitSoundLayerIndexint getHitSoundLayerIndex() |
public |
int |
getIncorrectMaterialSoundLayerIndexint getIncorrectMaterialSoundLayerIndex() |
public |
ItemToolSpec[] |
getSpecsItemToolSpec[] getSpecs() |
public |
float |
getSpeedfloat getSpeed() |
|
|
if if(this.hitSoundLayerId != null) |
|
|
if if(this.incorrectMaterialSoundLayerId != null) |
|
|
if if(this.specs != null && this.specs.length > 0) |
|
|
if if(this.breakShape != null) |
|
|
if if(var0.blockSets != null) |
|
|
if if(var3 == Integer.MIN_VALUE) |
|
|
if if(this.blockTypes != null && this.blockTypeIndexes == null) |
|
|
if if(var4 == Integer.MIN_VALUE) |
protected |
void |
processConfigvoid processConfig() |
|
public String |
toStringpublic String toString() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.item.config;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.common.util.ArrayUtil;
class="kw">import com.hypixel.hytale.server.core.asset.type.blockset.config.BlockSet;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.config.SoundEvent;
class="kw">import com.hypixel.hytale.server.core.asset.type.soundevent.validator.SoundEventValidators;
class="kw">import com.hypixel.hytale.server.core.io.NetworkSerializable;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.breakshape.BreakShape;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class ItemTool class="kw">implements NetworkSerializable<com.hypixel.hytale.protocol.ItemTool> {
class="kw">public class="kw">static class="kw">final BuilderCodec<ItemTool> CODEC = BuilderCodec.builder(ItemTool.class, ItemTool::new)
.append(new KeyedCodec<>("Specs", new ArrayCodec<>(ItemToolSpec.CODEC, ItemToolSpec[]::new)), (var0, var1) -> var0.specs = var1, var0 -> var0.specs)
.add()
.append(new KeyedCodec<>("Speed", Codec.DOUBLE), (var0, var1) -> var0.speed = var1.floatValue(), var0 -> (double)var0.speed)
.add()
.append(
new KeyedCodec<>("DurabilityLossBlockTypes", new ArrayCodec<>(ItemTool.DurabilityLossBlockTypes.CODEC, ItemTool.DurabilityLossBlockTypes[]::new)),
(var0, var1) -> var0.durabilityLossBlockTypes = var1,
var0 -> var0.durabilityLossBlockTypes
)
.add()
.<BreakShape>append(new KeyedCodec<>("BreakShape", BreakShape.CODEC), (var0, var1) -> var0.breakShape = var1, var0 -> var0.breakShape)
.documentation(
"Optional break shape. When set, breaking with this tool affects the set of blocks the shape covers (oriented to the user's view) instead of only the targeted block."
)
.add()
.<BreakShapeDurabilityMode>append(
new KeyedCodec<>("BreakShapeDurabilityMode", BreakShapeDurabilityMode.CODEC),
(var0, var1) -> var0.breakShapeDurabilityMode = var1,
var0 -> var0.breakShapeDurabilityMode
)
.addValidator(Validators.nonNull())
.documentation("How durability is consumed when a break shape affects multiple blocks: once per swing, or once per block broken.")
.add()
.<String>appendInherited(
new KeyedCodec<>("HitSoundLayer", Codec.STRING),
(var0, var1) -> var0.hitSoundLayerId = var1,
var0 -> var0.hitSoundLayerId,
(var0, var1) -> var0.hitSoundLayerId = var1.hitSoundLayerId
)
.addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
.addValidator(SoundEventValidators.MONO)
.documentation("Sound to play in addition to the block breaking sound when hitting a block this tool is designed to break.")
.add()
.<String>appendInherited(
new KeyedCodec<>("IncorrectMaterialSoundLayer", Codec.STRING),
(var0, var1) -> var0.incorrectMaterialSoundLayerId = var1,
var0 -> var0.incorrectMaterialSoundLayerId,
(var0, var1) -> var0.incorrectMaterialSoundLayerId = var1.incorrectMaterialSoundLayerId
)
.addValidator(SoundEvent.VALIDATOR_CACHE.getValidator())
.addValidator(SoundEventValidators.MONO)
.documentation("Sound to play in addition to the block breaking sound when hitting a block this tool cannot break.")
.add()
.afterDecode(ItemTool::processConfig)
.build();
class="kw">protected ItemToolSpec[] specs;
class="kw">protected float speed;
class="kw">protected ItemTool.DurabilityLossBlockTypes[] durabilityLossBlockTypes;
@Nullable
class="kw">protected BreakShape breakShape;
@Nonnull
class="kw">protected BreakShapeDurabilityMode breakShapeDurabilityMode = BreakShapeDurabilityMode.PerSwing;
@Nullable
class="kw">protected String hitSoundLayerId;
class="kw">protected class="kw">transient int hitSoundLayerIndex = 0;
@Nullable
class="kw">protected String incorrectMaterialSoundLayerId;
class="kw">protected class="kw">transient int incorrectMaterialSoundLayerIndex = 0;
class="kw">public ItemTool(ItemToolSpec[] var1, float var2, ItemTool.DurabilityLossBlockTypes[] var3) {
this.specs = var1;
this.speed = var2;
this.durabilityLossBlockTypes = var3;
}
class="kw">protected ItemTool() {
}
class="kw">protected void processConfig() {
if (this.hitSoundLayerId != null) {
this.hitSoundLayerIndex = SoundEvent.getAssetMap().getIndex(this.hitSoundLayerId);
}
if (this.incorrectMaterialSoundLayerId != null) {
this.incorrectMaterialSoundLayerIndex = SoundEvent.getAssetMap().getIndex(this.incorrectMaterialSoundLayerId);
}
}
@Nonnull
class="kw">public com.hypixel.hytale.protocol.ItemTool toPacket() {
com.hypixel.hytale.protocol.ItemTool var1 = new com.hypixel.hytale.protocol.ItemTool();
if (this.specs != null && this.specs.length > 0) {
var1.specs = ArrayUtil.copyAndMutate(this.specs, ItemToolSpec::toPacket, com.hypixel.hytale.protocol.ItemToolSpec[]::new);
}
var1.speed = this.speed;
if (this.breakShape != null) {
var1.breakShape = this.breakShape.toPacket();
}
class="kw">return var1;
}
class="kw">public ItemToolSpec[] getSpecs() {
class="kw">return this.specs;
}
@Nullable
class="kw">public BreakShape getBreakShape() {
class="kw">return this.breakShape;
}
@Nonnull
class="kw">public BreakShapeDurabilityMode getBreakShapeDurabilityMode() {
class="kw">return this.breakShapeDurabilityMode;
}
class="kw">public float getSpeed() {
class="kw">return this.speed;
}
class="kw">public ItemTool.DurabilityLossBlockTypes[] getDurabilityLossBlockTypes() {
class="kw">return this.durabilityLossBlockTypes;
}
class="kw">public int getHitSoundLayerIndex() {
class="kw">return this.hitSoundLayerIndex;
}
class="kw">public int getIncorrectMaterialSoundLayerIndex() {
class="kw">return this.incorrectMaterialSoundLayerIndex;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "ItemTool{specs="
+ Arrays.toString(this.specs)
+ ", speed="
+ this.speed
+ ", durabilityLossBlockTypes="
+ Arrays.toString(this.durabilityLossBlockTypes)
+ ", hitSoundLayerId='"
+ this.hitSoundLayerId
+ "', hitSoundLayerIndex="
+ this.hitSoundLayerIndex
+ ", incorrectMaterialSoundLayerId='"
+ this.incorrectMaterialSoundLayerId
+ "', incorrectMaterialSoundLayerIndex="
+ this.incorrectMaterialSoundLayerIndex
+ "}";
}
class="kw">public class="kw">static class DurabilityLossBlockTypes {
class="kw">public class="kw">static class="kw">final BuilderCodec<ItemTool.DurabilityLossBlockTypes> CODEC = BuilderCodec.builder(
ItemTool.DurabilityLossBlockTypes.class, ItemTool.DurabilityLossBlockTypes::new
)
.append(new KeyedCodec<>("BlockTypes", new ArrayCodec<>(Codec.STRING, String[]::new)), (var0, var1) -> var0.blockTypes = var1, var0 -> var0.blockTypes)
.add()
.append(new KeyedCodec<>("BlockSets", Codec.STRING_ARRAY), (var0, var1) -> var0.blockSets = var1, var0 -> var0.blockSets)
.add()
.append(new KeyedCodec<>("DurabilityLossOnHit", Codec.DOUBLE), (var0, var1) -> var0.durabilityLossOnHit = var1, var0 -> var0.durabilityLossOnHit)
.add()
.afterDecode(var0 -> {
if (var0.blockSets != null) {
var0.blockSetIndexes = new int[var0.blockSets.length];
for (int var1 = 0; var1 < var0.blockSets.length; var1++) {
String var2 = var0.blockSets[var1];
int var3 = BlockSet.getAssetMap().getIndex(var2);
if (var3 == Integer.MIN_VALUE) {
throw new IllegalArgumentException("Unknown key! " + var2);
}
var0.blockSetIndexes[var1] = var3;
}
}
})
.build();
class="kw">protected String[] blockTypes;
class="kw">protected String[] blockSets;
class="kw">protected double durabilityLossOnHit;
class="kw">protected int[] blockTypeIndexes;
class="kw">protected int[] blockSetIndexes;
class="kw">protected DurabilityLossBlockTypes() {
}
class="kw">public DurabilityLossBlockTypes(String[] var1, String[] var2, double var3) {
this.blockTypes = var1;
this.blockSets = var2;
this.durabilityLossOnHit = var3;
}
class="kw">public String[] getBlockTypes() {
class="kw">return this.blockTypes;
}
class="kw">public String[] getBlockSets() {
class="kw">return this.blockSets;
}
class="kw">public double getDurabilityLossOnHit() {
class="kw">return this.durabilityLossOnHit;
}
class="kw">public int[] getBlockTypeIndexes() {
if (this.blockTypes != null && this.blockTypeIndexes == null) {
int[] var1 = new int[this.blockTypes.length];
for (int var2 = 0; var2 < this.blockTypes.length; var2++) {
String var3 = this.blockTypes[var2];
int var4 = BlockType.getAssetMap().getIndex(var3);
if (var4 == Integer.MIN_VALUE) {
throw new IllegalArgumentException("Unknown key! " + var3);
}
var1[var2] = var4;
}
this.blockTypeIndexes = var1;
}
class="kw">return this.blockTypeIndexes;
}
class="kw">public int[] getBlockSetIndexes() {
class="kw">return this.blockSetIndexes;
}
@Nonnull
@Override
class="kw">public String toString() {
class="kw">return "DurabilityLossBlockTypes{blockTypes="
+ Arrays.toString(this.blockTypes)
+ ", blockSets="
+ Arrays.toString(this.blockSets)
+ ", durabilityLossOnHit="
+ this.durabilityLossOnHit
+ "}";
}
}
}