1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
package jp.plusplus.fbs.alchemy.characteristic;
import com.mojang.realmsclient.gui.ChatFormatting;
import jp.plusplus.fbs.alchemy.AlchemyRegistry;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
/**
* Created by plusplus_F on 2015/09/08.
* 錬金術の素材・生成品の「特性」
*/
public abstract class CharacteristicBase {
protected int value;
protected String uName="";
public CharacteristicBase(){}
/**
* 特性の強さの単位を得る
* @return 特性の強さの単位
*/
public abstract Type getType();
/**
* 生成品のMP価格への倍率補正を返す
* @return 価格倍率
*/
public float getMPScale(){
return 1.f;
}
/**
* この特性を持つアイテムをplayerが使用した際に行う処理
* @param world
* @param entity
*/
public void affectEntity(World world, EntityLivingBase entity){}
/**
* ツールチップでの表示色を返す
* @return 表示色
*/
public ChatFormatting getNameColor(){
return ChatFormatting.GRAY;
}
public void writeToNBT(NBTTagCompound nbt){
nbt.setInteger("value", getValue());
}
public void readFromNBT(NBTTagCompound nbt){
value=nbt.getInteger("value");
}
public int getValue(){ return getType().getCorrectedValue(value); }
/**
* 効果の強さを設定する
* @param value
*/
public void setValue(int value){
this.value=value;
}
public int getId(){
return AlchemyRegistry.GetCharacteristicId(this.getClass());
}
public void setUnlocalizedName(String u){ uName=u; }
public String getUnlocalizedName(){
return "alchemy.chara."+uName;
}
public String getLocalizedName(){
return StatCollector.translateToLocal(getUnlocalizedName());
}
public String getUnlocalizedEffectValue(){
return getType().getUnlocalizedName(value);
}
public String getLocalizedEffectValue(){
return StatCollector.translateToLocal(getUnlocalizedEffectValue());
}
/**
* 特性の持つ、効果の強さの単位
* 特性はvalueが大きい順に優先される
*/
public enum Type{
SCALE("fbs.small", "fbs.medium", "fbs.large"),
LENGTH("fbs.short", "fbs.medium", "fbs.long"),
LOOK("fbs.look.beautiful", "fbs.look.good", "fbs.look.dirty", "fbs.look.strange"),
WEIGHT("fbs.light", "fbs.heavy"),
QUALITY("fbs.great", "fbs.good", "fbs.bad"),
NONE();
private String[] str;
Type(String ... name){
str=name;
}
public String getUnlocalizedName(int value){
if(str==null || str.length==0) return "";
value=getCorrectedValue(value);
return "alchemy.effect."+str[value];
}
public int getCorrectedValue(int value){
if(value<0 || value>=str.length) value=0;
return value;
}
}
}
|