-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathPokedexEntry.java
2048 lines (1790 loc) · 69.6 KB
/
PokedexEntry.java
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package pokecube.api.data;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.minecraft.ChatFormatting;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.fml.ModLoadingContext;
import pokecube.api.PokecubeAPI;
import pokecube.api.data.abilities.Ability;
import pokecube.api.data.abilities.AbilityManager;
import pokecube.api.data.effects.materials.IMaterialAction;
import pokecube.api.data.pokedex.DefaultFormeHolder;
import pokecube.api.data.pokedex.EvolutionDataLoader;
import pokecube.api.data.pokedex.InteractsAndEvolutions.Action;
import pokecube.api.data.pokedex.InteractsAndEvolutions.Evolution;
import pokecube.api.data.pokedex.InteractsAndEvolutions.FormeItem;
import pokecube.api.data.pokedex.InteractsAndEvolutions.Interact;
import pokecube.api.data.pokedex.conditions.PokemobCondition;
import pokecube.api.data.spawns.SpawnBiomeMatcher;
import pokecube.api.data.spawns.SpawnCheck;
import pokecube.api.entity.pokemob.ICanEvolve;
import pokecube.api.entity.pokemob.IPokemob;
import pokecube.api.entity.pokemob.IPokemob.FormeHolder;
import pokecube.api.events.pokemobs.SpawnEvent;
import pokecube.api.events.pokemobs.SpawnEvent.SpawnContext;
import pokecube.api.events.pokemobs.SpawnEvent.Variance;
import pokecube.api.moves.Battle;
import pokecube.api.stats.SpecialCaseRegister;
import pokecube.api.utils.PokeType;
import pokecube.api.utils.Tools;
import pokecube.core.PokecubeCore;
import pokecube.core.PokecubeItems;
import pokecube.core.database.Database;
import pokecube.core.database.pokedex.JsonPokedexEntry;
import pokecube.core.database.pokedex.PokedexEntryLoader.Drop;
import pokecube.core.database.tags.Tags;
import pokecube.core.entity.pokemobs.DispenseBehaviourInteract;
import pokecube.core.entity.pokemobs.PokemobType;
import pokecube.core.eventhandlers.PokemobEventsHandler.MegaEvoTicker;
import pokecube.core.moves.MovesUtils;
import pokecube.core.utils.TimePeriod;
import thut.api.Tracker;
import thut.api.entity.multipart.GenericPartEntity.BodyNode;
import thut.api.item.ItemList;
import thut.api.level.terrain.BiomeType;
import thut.api.maths.Vector3;
import thut.api.maths.vecmath.Vec3f;
import thut.api.util.JsonUtil;
import thut.core.common.ThutCore;
import thut.lib.RegHelper;
import thut.lib.TComponent;
/** @author Manchou */
public class PokedexEntry
{
// Annotation used to specify which fields should be shared to all gender
// formes.
@Retention(RetentionPolicy.RUNTIME)
public static @interface CopyToGender
{
}
@Retention(RetentionPolicy.RUNTIME)
public static @interface Required
{
}
public static class EvolutionData implements Comparable<EvolutionData>
{
public PokemobCondition _condition;
public PokedexEntry result;
public final Evolution data;
public final PokedexEntry evolution;
public String FX = "";
public List<String> evoMoves = Lists.newArrayList();
public EvolutionData(final PokedexEntry evol, Evolution data)
{
this.evolution = evol;
this.data = data;
}
public Entity getEvolution(final LevelAccessor world)
{
if (this.evolution == null) return null;
final Entity ret = PokecubeCore.createPokemob(this.evolution, (Level) world);
return ret;
}
@OnlyIn(Dist.CLIENT)
public List<MutableComponent> getEvoClauses()
{
final List<MutableComponent> comps = Lists.newArrayList();
if (this._condition != null)
{
if ("eevee".equals(data.user)) ThutCore.conf.debug = true;
List<Component> baseComps = PokemobCondition.getDescriptions(_condition);
if ("eevee".equals(data.user)) ThutCore.conf.debug = false;
for (var c : baseComps) comps.add(TComponent.translatable("pokemob.description.tabbed", c));
}
return comps;
}
@OnlyIn(Dist.CLIENT)
public MutableComponent getEvoString()
{
/*
* //@formatter:off
*
* It should work as follows:
*
* X evolves into Y under the following circumstances:
* - Upon reaching level L
* - When sufficiently Happy
* - When Raining
* - Etc
*
*
*/
// @formatter:on
final PokedexEntry entry = this.data.getUser();
final PokedexEntry nex = this.data.getResult();
final MutableComponent subEvo = TComponent.translatable("pokemob.description.evolve.to",
entry.getTranslatedName(), nex.getTranslatedName());
final List<MutableComponent> list = this.getEvoClauses();
for (final MutableComponent item : list) subEvo.append("\n").append(item);
return subEvo;
}
private void parse(final Evolution data)
{
// This is what we will actually use for the tests.
this._condition = data.toCondition();
if (data.animation != null) this.FX = data.animation;
this.evoMoves.clear();
if (data.evoMoves != null && !data.evoMoves.isEmpty())
{
final String[] vals = data.evoMoves.split(",");
for (final String s : vals) this.evoMoves.add(s.trim());
}
}
public void postInit()
{
if (this.data != null) this.parse(this.data);
}
public boolean shouldEvolve(final IPokemob mob)
{
return this.shouldEvolve(mob, mob.getHeldItem());
}
public boolean shouldEvolve(final IPokemob mob, final ItemStack mobs)
{
if (ItemList.is(ICanEvolve.EVERSTONE, mob.getHeldItem())) return false;
if (ItemList.is(ICanEvolve.EVERSTONE, mobs)) return false;
ItemStack old = mob.getEvolutionStack();
if (ItemList.is(ICanEvolve.EVERSTONE, old)) return false;
mob.setEvolutionStack(mobs);
boolean matched = _condition.matches(mob);
mob.setEvolutionStack(old);
return matched;
}
@Override
public int compareTo(EvolutionData o)
{
return this.data.compareTo(o.data);
}
}
public static class InteractionLogic
{
private static final ResourceLocation SHEARS = new ResourceLocation(PokecubeCore.MODID, "shears");
public static Predicate<ItemStack> isShears = (s) -> ItemList.is(InteractionLogic.SHEARS, s);
public static class Interaction
{
public PokedexEntry forme;
public List<ItemStack> stacks = Lists.newArrayList();
public ResourceLocation lootTable;
public boolean male = true;
public boolean female = true;
public int cooldown = 100;
public int variance = 1;
public int hunger = 100;
public Interaction()
{}
}
static HashMap<PokeType, List<Interact>> defaults = new HashMap<>();
private static void cleanInteract(final Interact interact)
{
final Interact defs = new Interact();
for (final Field f : Interact.class.getDeclaredFields())
{
f.setAccessible(true);
try
{
if (f.get(interact) == null) f.set(interact, f.get(defs));
}
catch (IllegalArgumentException | IllegalAccessException e)
{
e.printStackTrace();
}
}
}
public static void initDefaults()
{
final Interact fire = new Interact();
fire.key = new Drop();
fire.action = new Action();
fire.key.values.put("id", "minecraft:stick");
fire.action.values.put("type", "item");
final Drop firedrop = new Drop();
firedrop.values.put("id", "minecraft:torch");
fire.action.drops.add(firedrop);
final Interact water = new Interact();
water.key = new Drop();
water.action = new Action();
water.key.values.put("id", "minecraft:bucket");
water.action.values.put("type", "item");
final Drop waterdrop = new Drop();
waterdrop.values.put("id", "minecraft:water_bucket");
water.action.drops.add(waterdrop);
if (PokecubeCore.getConfig().defaultInteractions)
{
InteractionLogic.defaults.put(PokeType.getType("fire"), Lists.newArrayList(fire));
InteractionLogic.defaults.put(PokeType.getType("water"), Lists.newArrayList(water));
}
}
public static void initForEntry(final PokedexEntry entry)
{
// Here we deal with the defaulted interactions for this type.
final List<Interact> val = Lists.newArrayList();
for (final PokeType t : InteractionLogic.defaults.keySet())
if (entry.isType(t)) val.addAll(InteractionLogic.defaults.get(t));
if (!val.isEmpty()) InteractionLogic.initForEntry(entry, val, false);
}
public static void initForEntry(final PokedexEntry entry, final List<Interact> data, final boolean replace)
{
if (data == null || data.isEmpty())
{
InteractionLogic.initForEntry(entry);
return;
}
for (final Interact interact : data)
{
InteractionLogic.cleanInteract(interact);
final Drop key = interact.key;
final Action action = interact.action;
final boolean isForme = action.values.get("type").equals("forme");
Map<String, String> values = key.getValues();
final Interaction interaction = new Interaction();
if (interact.isTag)
{
final ResourceLocation tag = new ResourceLocation(key.id);
if (!replace && entry.interactionLogic.canInteract(tag)) continue;
entry.interactionLogic.tagActions.put(tag, interaction);
DispenseBehaviourInteract.registerBehavior(tag);
}
else
{
final ItemStack keyStack = Tools.getStack(values);
if (!replace && entry.interactionLogic.canInteract(keyStack)) continue;
entry.interactionLogic.stackActions.put(keyStack, interaction);
DispenseBehaviourInteract.registerBehavior(keyStack);
}
interaction.male = interact.male;
interaction.female = interact.female;
interaction.cooldown = interact.cooldown;
interaction.variance = Math.max(1, interact.variance);
interaction.hunger = interact.baseHunger;
if (isForme)
{
final PokedexEntry forme = Database.getEntry(action.values.get("forme"));
if (forme != null) interaction.forme = forme;
}
else
{
final List<ItemStack> stacks = Lists.newArrayList();
for (final Drop d : action.drops)
{
values = d.getValues();
final ItemStack stack = Tools.getStack(values);
if (stack != ItemStack.EMPTY) stacks.add(stack);
}
interaction.stacks = stacks;
if (action.lootTable != null) interaction.lootTable = new ResourceLocation(action.lootTable);
}
}
}
public HashMap<ItemStack, Interaction> stackActions = Maps.newHashMap();
public HashMap<ResourceLocation, Interaction> tagActions = Maps.newHashMap();
boolean canInteract(final ItemStack key)
{
return this.getFor(key) != null;
}
boolean canInteract(final ResourceLocation tag)
{
return this.tagActions.containsKey(tag);
}
public Interaction getFor(final ItemStack held)
{
for (final ItemStack stack : this.stackActions.keySet())
if (Tools.isSameStack(stack, held)) return this.stackActions.get(stack);
for (final ResourceLocation loc : this.tagActions.keySet())
if (ItemList.is(loc, held)) return this.tagActions.get(loc);
return null;
}
public boolean applyInteraction(final Player player, final IPokemob pokemob, final boolean consumeInput)
{
final Mob entity = pokemob.getEntity();
final ItemStack held = player.getMainHandItem();
final CompoundTag data = entity.getPersistentData();
final Interaction action = this.getFor(held);
ItemStack result = null;
if (action.lootTable != null)
{
final LootTable loottable = pokemob.getEntity().getLevel().getServer().getLootTables()
.get(action.lootTable);
final LootContext.Builder lootcontext$builder = new LootContext.Builder(
(ServerLevel) pokemob.getEntity().getLevel()).withParameter(LootContextParams.THIS_ENTITY,
pokemob.getEntity());
for (final ItemStack itemstack : loottable
.getRandomItems(lootcontext$builder.create(loottable.getParamSet())))
if (!itemstack.isEmpty())
{
result = itemstack;
break;
}
}
else
{
final List<ItemStack> results = action.stacks;
final int index = player.getRandom().nextInt(results.size());
result = results.get(index).copy();
}
if (result.isEmpty()) return false;
final long dt = (long) ((action.cooldown + ThutCore.newRandom().nextInt(action.variance))
* PokecubeCore.getConfig().interactDelayScale);
final long now = Tracker.instance().getTick();
final long timer = dt + now;
data.putLong("lastInteract", timer);
pokemob.applyHunger((int) (action.hunger * PokecubeCore.getConfig().interactHungerScale));
if (consumeInput && !player.isCreative()) held.shrink(1);
if (held.isEmpty()) player.getInventory().setItem(player.getInventory().selected, result);
else if (!player.getInventory().add(result)) player.drop(result, false);
if (player != pokemob.getOwner()) Battle.createOrAddToBattle(entity, player);
return true;
}
boolean interact(final Player player, final IPokemob pokemob, final boolean doInteract)
{
final Mob entity = pokemob.getEntity();
final ItemStack held = player.getMainHandItem();
final Interaction action = this.getFor(held);
if (action == null || action.stacks.isEmpty())
{
if (action == null) return false;
if (!doInteract) return true;
final PokedexEntry forme = action.forme;
pokemob.changeForm(forme);
return true;
}
final CompoundTag data = entity.getPersistentData();
if (data.contains("lastInteract"))
{
final long now = Tracker.instance().getTick();
final long time = data.getLong("lastInteract");
final long diff = now - time;
if (diff < 0) return false;
}
if (!action.male && pokemob.getSexe() == IPokemob.MALE) return false;
if (!action.female && pokemob.getSexe() == IPokemob.FEMALE) return false;
if (action.stacks.isEmpty() && action.lootTable == null) return false;
if (InteractionLogic.isShears.test(held))
{
if (pokemob.isSheared()) return true;
if (doInteract) pokemob.shear(held);
return true;
}
if (!doInteract) return true;
return this.applyInteraction(player, pokemob, true);
}
}
public static enum MovementType
{
FLYING(8), FLOATING(4), WATER(2), NORMAL(1);
public final int mask;
private MovementType(final int mask)
{
this.mask = mask;
}
public boolean is(final int test)
{
return (this.mask & test) != 0;
}
public static MovementType getType(final String type)
{
for (final MovementType t : MovementType.values()) if (t.toString().equalsIgnoreCase(type)) return t;
return NORMAL;
}
}
public static class SpawnData
{
public static class SpawnEntry
{
public int max = 4;
public int min = 2;
public int minY = Integer.MIN_VALUE;
public int maxY = Integer.MAX_VALUE;
public float rate = 0.0f;
public int level = -1;
public Variance variance = null;
}
final PokedexEntry entry;
public Map<SpawnBiomeMatcher, SpawnEntry> matchers = Maps.newHashMap();
public SpawnData(final PokedexEntry entry)
{
this.entry = entry;
}
public PokedexEntry entry()
{
return this.entry;
}
public int getLevel(final SpawnBiomeMatcher matcher)
{
final SpawnEntry entry = this.matchers.get(matcher);
return entry == null ? -1 : entry.level;
}
public SpawnBiomeMatcher getMatcher(final SpawnContext context, final SpawnCheck checker)
{
return this.getMatcher(context, checker, true);
}
public SpawnBiomeMatcher getMatcher(final SpawnContext context)
{
SpawnCheck checker = new SpawnCheck(context.location(), context.level());
return this.getMatcher(context, checker, true);
}
public SpawnBiomeMatcher getMatcher(final SpawnContext context, final SpawnCheck checker,
final boolean forSpawn)
{
List<SpawnBiomeMatcher> matchers = Lists.newArrayList(this.matchers.keySet());
Collections.shuffle(matchers);
for (var matcher : matchers)
{
final SpawnEvent.Check evt = new SpawnEvent.Check(context, forSpawn);
PokecubeAPI.POKEMOB_BUS.post(evt);
if (evt.isCanceled()) continue;
if (evt.getResult() == Result.ALLOW) return matcher;
if (matcher.matches(checker)) return matcher;
}
return null;
}
public SpawnBiomeMatcher getMatcher(final ServerLevel world, final Vector3 location,
@Nullable ServerPlayer player)
{
SpawnContext context = new SpawnContext(player, world, entry, location);
final SpawnCheck checker = new SpawnCheck(location, world);
return this.getMatcher(context, checker);
}
public int getMax(final SpawnBiomeMatcher matcher)
{
final SpawnEntry entry = this.matchers.get(matcher);
return entry == null ? 4 : entry.max;
}
public int getMin(final SpawnBiomeMatcher matcher)
{
final SpawnEntry entry = this.matchers.get(matcher);
return entry == null ? 2 : entry.min;
}
public Variance getVariance(final SpawnBiomeMatcher matcher)
{
final SpawnEntry entry = this.matchers.get(matcher);
return entry == null ? new Variance() : entry.variance;
}
public float getWeight(final SpawnBiomeMatcher matcher)
{
final SpawnEntry entry = this.matchers.get(matcher);
return entry == null ? 0 : entry.rate;
}
public float getWeight(final SpawnContext context, SpawnCheck checker, boolean forSpawn)
{
final SpawnEntry entry = this.matchers.get(getMatcher(context, checker, forSpawn));
float rate = entry == null ? 0 : entry.rate;
if (entry != null)
{
if (context.location().y > entry.maxY) rate = 0;
if (context.location().y < entry.minY) rate = 0;
}
SpawnEvent.Check.Rate event = new SpawnEvent.Check.Rate(context, forSpawn, rate);
PokecubeAPI.POKEMOB_BUS.post(event);
return event.getRate();
}
public boolean isValid(final ResourceLocation biome)
{
for (final SpawnBiomeMatcher matcher : this.matchers.keySet())
if (matcher.getValidBiomes().contains(TagKey.create(Registry.BIOME_REGISTRY, biome))) return true;
return false;
}
public boolean isValid(final Biome biome)
{
return isValid(RegHelper.getKey(biome));
}
public boolean isValid(final ResourceKey<Biome> biome)
{
return isValid(biome.location());
}
public boolean isValid(final BiomeType biome)
{
for (final SpawnBiomeMatcher matcher : this.matchers.keySet())
if (matcher._validSubBiomes.contains(biome)) return true;
return false;
}
/**
* Only checks one biome type for vailidity
*
* @param b
* @return
*/
public boolean isValid(final SpawnContext context, SpawnCheck checker)
{
return this.getMatcher(context, checker) != null;
}
public void postInit()
{
for (final SpawnBiomeMatcher matcher : this.matchers.keySet()) matcher.reset();
}
}
public static final String TEXTUREPATH = "textures/entity/pokemob/";
public static final String MODELPATH = "models/entity/pokemob/";
public static TimePeriod dawn = new TimePeriod(0.85, 0.05);
public static TimePeriod day = new TimePeriod(0.05, 0.45);
public static TimePeriod dusk = new TimePeriod(0.45, 0.6);
public static TimePeriod night = new TimePeriod(0.6, 0.85);
private static final PokedexEntry BLANK = new PokedexEntry(true);
public static final ResourceLocation MODELNO = new ResourceLocation(PokecubeCore.MODID, MODELPATH + "missingno");
public static final ResourceLocation TEXNO = new ResourceLocation(PokecubeCore.MODID,
TEXTUREPATH + "missingno.png");
public static final ResourceLocation ANIMNO = new ResourceLocation(PokecubeCore.MODID, MODELPATH + "missingno.xml");
private static void addFromEvolution(final PokedexEntry a, final PokedexEntry b)
{
for (final EvolutionData d : a.evolutions)
{
d.postInit();
final PokedexEntry c = d.evolution;
if (c == null) continue;
b.addRelation(c);
c.addRelation(b);
}
}
// Core Values
@CopyToGender
@Required
public int pokedexNb = -1;
@Required
public String name = null;
/**
* if True, this is considered the "main" form for the type, this is what is
* returned from any number based lookups.
*/
public boolean base = false;
/**
* If True, this form won't be registered, this is used for mobs with a
* single base template form, and then a bunch of alternate ones for things
* to be copied from.
*/
public boolean dummy = false;
/**
* This is true for any pokemob which is supposed to be an EntityPokemob,
* with a DefaultPokemob IPokemob, this can be set false by addons to make
* their own custom pokemob implementations
*/
public boolean stock = true;
public boolean generated = false;
// Values in Stats
@CopyToGender
@Required
public int[] stats = null;
/** The abilities available to the pokedex entry. */
@CopyToGender
public ArrayList<String> abilities = Lists.newArrayList();
/** The abilities available to the pokedex entry. */
@CopyToGender
public ArrayList<String> abilitiesHidden = Lists.newArrayList();
// Simple values from Stats
/** base xp given from defeating */
@CopyToGender
@Required
public int baseXP = -1;
@CopyToGender
@Required
public int catchRate = -1;
/** Initial Happiness of the pokemob */
@CopyToGender
@Required
public int baseHappiness = -1;
/** The relation between xp and level */
@CopyToGender
@Required
public int evolutionMode = -1;
@CopyToGender
@Required
public int sexeRatio = -1;
/** Mass of the pokemon in kg. */
@CopyToGender
@Required
public double mass = -1;
/**
* If the forme is supposed to have a custom sound, rather than using base,
* it will be set to this.
*/
public String customSound = null;
@CopyToGender
private PokedexEntry baseForme = null;
@CopyToGender
public String baseName;
@CopyToGender
public boolean breeds = true;
@CopyToGender
public boolean canSitShoulder = false;
@CopyToGender
public PokedexEntry _childNb = null;
/**
* Default value of specialInfo, used to determine default colour of
* recolourable parts
*/
@CopyToGender
public int defaultSpecial = 0;
/**
* Default value of specialInfo for shiny variants, used to determine
* default colour of recolourable parts
*/
@CopyToGender
public int defaultSpecials = 0;
/**
* If the IPokemob supports this, then this will be the loot table used for
* its drops.
*/
@CopyToGender
public ResourceLocation lootTable = null;
/**
* indicatees of the specified special texture exists. Index 4 is used for
* if the mob can be dyed
*/
@CopyToGender
public boolean dyeable = false;
/** A Set of valid dye colours, if empty, any dye is valid. */
@CopyToGender
public Set<DyeColor> validDyes = Sets.newHashSet();
@CopyToGender
public SoundEvent soundEvent;
@CopyToGender
public SoundEvent replacedEvent;
/** The list of pokemon this can evolve into */
@CopyToGender
public List<EvolutionData> evolutions = new ArrayList<>();
@CopyToGender
public EvolutionData _evolvesBy = null;
/** Who this pokemon evolves from. */
@CopyToGender
public PokedexEntry _evolvesFrom = null;
@CopyToGender
public byte[] evs;
public PokedexEntry female = null;
/** Inital list of species which are prey */
@CopyToGender
public String[] food;
/**
* light,<br>
* rock,<br>
* power (near redstone blocks),<br>
* grass,<br>
* never hungry,<br>
* berries,<br>
* water (filter feeds from water)
*/
@CopyToGender
public boolean[] foods =
{ false, false, false, false, false, true, false };
@CopyToGender
public HashMap<ItemStack, FormeItem> formeItems = Maps.newHashMap();
public PokedexEntry noItemForm = null;
/** Map of forms assosciated with this one. */
@CopyToGender
public Map<String, PokedexEntry> forms = new HashMap<>();
/**
* Used to stop gender formes from spawning, spawning rate is done by gender
* ratio of base forme instead.
*/
public boolean isGenderForme = false;
@CopyToGender
public boolean hasShiny = true;
/** Materials which will hurt or make it despawn. */
@CopyToGender
public List<IMaterialAction> materialActions = Lists.newArrayList();
@CopyToGender
public float height = -1;
@CopyToGender
public boolean ridable = true;
/**
* This is a loot table to be used for held item. if this isn't null, the
* above held is ignored.
*/
@CopyToGender
public ResourceLocation heldTable = null;
/** Interactions with items from when player right clicks. */
@CopyToGender
public InteractionLogic interactionLogic = new InteractionLogic();
public boolean isFemaleForme = false;
public boolean isMaleForme = false;
@CopyToGender
public boolean isShadowForme = false;
/** Will it protect others. */
@CopyToGender
public boolean isSocial = true;
public boolean isStarter = false;
@CopyToGender
public boolean isStationary = false;
@CopyToGender
public boolean legendary = false;
@CopyToGender
public float width = -1;
@CopyToGender
public float length = -1;
/** Map of Level to Moves learned. */
@CopyToGender
private Map<Integer, ArrayList<String>> lvlUpMoves;
public PokedexEntry male = null;
/** Movement type for this mob, this is a bitmask for MovementType */
@CopyToGender
public int mobType = 0;
/** Mod which owns the pokemob, used for texture location. */
@CopyToGender
private String modId;
/** Particle Effects. */
@CopyToGender
public String[] particleData;
/** Offset between top of hitbox and where player sits */
@CopyToGender
public double[][] passengerOffsets =
{
{ 0, 0.75, 0 } };
/** All possible moves */
@CopyToGender
private List<String> possibleMoves;
/** If the above is floating, how high does it try to float */
@CopyToGender
public double preferedHeight = 1.25;
/** Pokemobs with these entries will be hunted. */
@CopyToGender
private final List<PokedexEntry> prey = new ArrayList<>();
/**
* This list will contain all pokemon that are somehow related to this one
* via evolution chains
*/
@CopyToGender
public final List<PokedexEntry> related = new ArrayList<>();
@CopyToGender
public PokedexEntry shadowForme = null;
@CopyToGender
public boolean shouldDive = false;
@CopyToGender
public boolean shouldFly = false;
@CopyToGender
public boolean shouldSurf = false;
@CopyToGender
public boolean isHeatProof = false;
@CopyToGender
public boolean isMega = false;
@CopyToGender
public ResourceLocation sound;
@CopyToGender
/**
* This is copied to the gender as it will allow specifying where that
* gender spawns in pokedex.
*/
private SpawnData spawns;
/**
* Array used for animated or gender based textures. Index 0 is the male
* textures, index 1 is the females
*/
@CopyToGender
public String[][] textureDetails =
{
{ "" }, null };
public DefaultFormeHolder _default_holder = null;
public DefaultFormeHolder _male_holder = null;
public DefaultFormeHolder _female_holder = null;
public FormeHolder default_holder = null;
public FormeHolder male_holder = null;
public FormeHolder female_holder = null;
// Icons for the entry, ordering is male/maleshiny, female/female shiny.
// genderless fills the male slot.
private final ResourceLocation[][] icons =
{
{ null, null },
{ null, null } };
@CopyToGender
public String texturePath = PokedexEntry.TEXTUREPATH;
@CopyToGender
public String modelPath = PokedexEntry.MODELPATH;
@CopyToGender
public PokeType type1;
@CopyToGender
public PokeType type2;
@CopyToGender
public EntityType<? extends Mob> entity_type;
// This is the actual size of the model, if not null, will be used for
// scaling of rendering in guis, order is length, height, width
public Vec3f modelSize = null;
/** Cached trimmed name. */
private String trimmedName;
private ResourceLocation _base_description = new ResourceLocation("null");
private Map<ResourceLocation, MutableComponent> _descriptions = new HashMap<>();
// "" for automatic assignment
public String modelExt = "";
public ResourceLocation model = PokedexEntry.MODELNO;
public ResourceLocation texture = PokedexEntry.TEXNO;
public ResourceLocation animation = PokedexEntry.ANIMNO;
public Map<String, BodyNode> poseShapes = null;
// Here we have things that need to wait until loaded for initialization, so
// we cache them.
public List<Interact> _loaded_interactions = Lists.newArrayList();
public List<FormeItem> _forme_items = Lists.newArrayList();
/** Times not included here the pokemob will go to sleep when idle. */
@CopyToGender
public List<TimePeriod> activeTimes = new ArrayList<>();
public JsonPokedexEntry _root_json;
/**
* This constructor is used for making blank entry for copy comparisons.
*
* @param blank
*/
private PokedexEntry(final boolean blank)
{
// Nothing
}
public PokedexEntry(final int nb, final String name, boolean isExtraForm)
{
this.name = name;