mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Fix indentation
This commit is contained in:
parent
c1d5203926
commit
e8dd55ee20
1 changed files with 88 additions and 88 deletions
|
@ -20,134 +20,134 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
public class ItemApple extends ItemFood implements IMultiItem, IEdible {
|
public class ItemApple extends ItemFood implements IMultiItem, IEdible {
|
||||||
|
|
||||||
private int[] typeRarities = new int[0];
|
private int[] typeRarities = new int[0];
|
||||||
|
|
||||||
private String[] subTypes = new String[0];
|
private String[] subTypes = new String[0];
|
||||||
|
|
||||||
private String[] variants = subTypes;
|
private String[] variants = subTypes;
|
||||||
|
|
||||||
public ItemStack getRandomApple(Random rand, Object variant) {
|
public ItemStack getRandomApple(Random rand, Object variant) {
|
||||||
|
|
||||||
int[] rarity = typeRarities;
|
int[] rarity = typeRarities;
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
for (int i = 0; i < rarity.length && i < subTypes.length; i++) {
|
for (int i = 0; i < rarity.length && i < subTypes.length; i++) {
|
||||||
if (rand.nextInt(rarity[i]) == 0) {
|
if (rand.nextInt(rarity[i]) == 0) {
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variant == BlockPlanks.EnumType.JUNGLE) {
|
if (variant == BlockPlanks.EnumType.JUNGLE) {
|
||||||
result = oneOr(result, 0, 1);
|
result = oneOr(result, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variant == BlockPlanks.EnumType.BIRCH) {
|
if (variant == BlockPlanks.EnumType.BIRCH) {
|
||||||
result = oneOr(result, 0, 2);
|
result = oneOr(result, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variant == BlockPlanks.EnumType.SPRUCE) {
|
if (variant == BlockPlanks.EnumType.SPRUCE) {
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
return new ItemStack(UItems.rotten_apple, 1);
|
return new ItemStack(UItems.rotten_apple, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variant == BlockPlanks.EnumType.DARK_OAK) {
|
if (variant == BlockPlanks.EnumType.DARK_OAK) {
|
||||||
if (result == 1) {
|
if (result == 1) {
|
||||||
return new ItemStack(UItems.zap_apple, 1);
|
return new ItemStack(UItems.zap_apple, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variant == BlockPlanks.EnumType.ACACIA) {
|
if (variant == BlockPlanks.EnumType.ACACIA) {
|
||||||
result = oneOr(result, 0, 4);
|
result = oneOr(result, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ItemStack(this, 1, result);
|
return new ItemStack(this, 1, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int oneOr(int initial, int a, int b) {
|
int oneOr(int initial, int a, int b) {
|
||||||
if (initial == a) {
|
if (initial == a) {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initial == b) {
|
if (initial == b) {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
return initial;
|
return initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemApple(String domain, String name) {
|
public ItemApple(String domain, String name) {
|
||||||
super(4, 3, false);
|
super(4, 3, false);
|
||||||
setTranslationKey(name);
|
setTranslationKey(name);
|
||||||
|
|
||||||
if (!"minecraft".contentEquals(domain)) {
|
if (!"minecraft".contentEquals(domain)) {
|
||||||
setRegistryName(domain, name);
|
setRegistryName(domain, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemApple setSubTypes(String... types) {
|
public ItemApple setSubTypes(String... types) {
|
||||||
setHasSubtypes(types.length > 0);
|
setHasSubtypes(types.length > 0);
|
||||||
setMaxDamage(0);
|
setMaxDamage(0);
|
||||||
|
|
||||||
subTypes = types;
|
subTypes = types;
|
||||||
variants = new String[subTypes.length];
|
variants = new String[subTypes.length];
|
||||||
|
|
||||||
setTranslationKey(variants[0] = types[0]);
|
setTranslationKey(variants[0] = types[0]);
|
||||||
|
|
||||||
for (int i = 1; i < variants.length; i++) {
|
for (int i = 1; i < variants.length; i++) {
|
||||||
variants[i] = variants[0] + "_" + subTypes[i % subTypes.length];
|
variants[i] = variants[0] + "_" + subTypes[i % subTypes.length];
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemApple setTypeRarities(int ... rarity) {
|
public ItemApple setTypeRarities(int ... rarity) {
|
||||||
typeRarities = rarity;
|
typeRarities = rarity;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getVariants() {
|
public String[] getVariants() {
|
||||||
return variants;
|
return variants;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||||
if (isInCreativeTab(tab)) {
|
if (isInCreativeTab(tab)) {
|
||||||
items.add(new ItemStack(this, 1, 0));
|
items.add(new ItemStack(this, 1, 0));
|
||||||
|
|
||||||
for (int i = 1; i < subTypes.length; i++) {
|
for (int i = 1; i < subTypes.length; i++) {
|
||||||
items.add(new ItemStack(this, 1, i));
|
items.add(new ItemStack(this, 1, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||||
tooltip.add(getToxicityLevel(stack).getTooltip());
|
tooltip.add(getToxicityLevel(stack).getTooltip());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetadata(ItemStack stack) {
|
public int getMetadata(ItemStack stack) {
|
||||||
if (getHasSubtypes()) {
|
if (getHasSubtypes()) {
|
||||||
return super.getMetadata(stack) % subTypes.length;
|
return super.getMetadata(stack) % subTypes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getMetadata(stack);
|
return super.getMetadata(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTranslationKey(ItemStack stack) {
|
public String getTranslationKey(ItemStack stack) {
|
||||||
if (getHasSubtypes()) {
|
if (getHasSubtypes()) {
|
||||||
int meta = Math.max(0, stack.getMetadata() % subTypes.length);
|
int meta = Math.max(0, stack.getMetadata() % subTypes.length);
|
||||||
|
|
||||||
if (meta > 0) {
|
if (meta > 0) {
|
||||||
return super.getTranslationKey(stack) + "." + subTypes[meta];
|
return super.getTranslationKey(stack) + "." + subTypes[meta];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getTranslationKey(stack);
|
return super.getTranslationKey(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Toxicity getToxicityLevel(ItemStack stack) {
|
public Toxicity getToxicityLevel(ItemStack stack) {
|
||||||
|
|
Loading…
Reference in a new issue