Expanded custom villagers to Zombies and world gen.
Fixed edge cases where custom professiosn wernt being used correctly. Closes #2862
This commit is contained in:
parent
0a5daa194b
commit
9a23cf76d2
5 changed files with 274 additions and 42 deletions
|
@ -0,0 +1,25 @@
|
||||||
|
--- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderZombie.java
|
||||||
|
+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderZombie.java
|
||||||
|
@@ -69,21 +69,7 @@
|
||||||
|
{
|
||||||
|
if (p_110775_1_.func_82231_m())
|
||||||
|
{
|
||||||
|
- switch (p_110775_1_.func_184736_de())
|
||||||
|
- {
|
||||||
|
- case 0:
|
||||||
|
- return field_188330_l;
|
||||||
|
- case 1:
|
||||||
|
- return field_188331_m;
|
||||||
|
- case 2:
|
||||||
|
- return field_188332_n;
|
||||||
|
- case 3:
|
||||||
|
- return field_188333_o;
|
||||||
|
- case 4:
|
||||||
|
- return field_188329_p;
|
||||||
|
- default:
|
||||||
|
- return field_110864_q;
|
||||||
|
- }
|
||||||
|
+ return p_110775_1_.getVillagerTypeForge().getZombieSkin();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
|
@ -1,6 +1,14 @@
|
||||||
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityZombie.java
|
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityZombie.java
|
||||||
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityZombie.java
|
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityZombie.java
|
||||||
@@ -102,7 +102,7 @@
|
@@ -61,6 +61,7 @@
|
||||||
|
private static final AttributeModifier field_110188_br = new AttributeModifier(field_110187_bq, "Baby speed boost", 0.5D, 1);
|
||||||
|
private static final DataParameter<Boolean> field_184737_bv = EntityDataManager.<Boolean>func_187226_a(EntityZombie.class, DataSerializers.field_187198_h);
|
||||||
|
private static final DataParameter<Integer> field_184738_bw = EntityDataManager.<Integer>func_187226_a(EntityZombie.class, DataSerializers.field_187192_b);
|
||||||
|
+ private static final DataParameter<String> VILLAGER_TYPE_STR = EntityDataManager.<String>func_187226_a(EntityZombie.class, DataSerializers.field_187194_d);
|
||||||
|
private static final DataParameter<Boolean> field_184739_bx = EntityDataManager.<Boolean>func_187226_a(EntityZombie.class, DataSerializers.field_187198_h);
|
||||||
|
private static final DataParameter<Boolean> field_184740_by = EntityDataManager.<Boolean>func_187226_a(EntityZombie.class, DataSerializers.field_187198_h);
|
||||||
|
private final EntityAIBreakDoor field_146075_bs = new EntityAIBreakDoor(this);
|
||||||
|
@@ -102,7 +103,7 @@
|
||||||
this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.23000000417232513D);
|
this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.23000000417232513D);
|
||||||
this.func_110148_a(SharedMonsterAttributes.field_111264_e).func_111128_a(3.0D);
|
this.func_110148_a(SharedMonsterAttributes.field_111264_e).func_111128_a(3.0D);
|
||||||
this.func_110148_a(SharedMonsterAttributes.field_188791_g).func_111128_a(2.0D);
|
this.func_110148_a(SharedMonsterAttributes.field_188791_g).func_111128_a(2.0D);
|
||||||
|
@ -9,7 +17,68 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void func_70088_a()
|
protected void func_70088_a()
|
||||||
@@ -260,12 +260,24 @@
|
@@ -110,6 +111,7 @@
|
||||||
|
super.func_70088_a();
|
||||||
|
this.func_184212_Q().func_187214_a(field_184737_bv, Boolean.valueOf(false));
|
||||||
|
this.func_184212_Q().func_187214_a(field_184738_bw, Integer.valueOf(0));
|
||||||
|
+ this.func_184212_Q().func_187214_a(VILLAGER_TYPE_STR, "");
|
||||||
|
this.func_184212_Q().func_187214_a(field_184739_bx, Boolean.valueOf(false));
|
||||||
|
this.func_184212_Q().func_187214_a(field_184740_by, Boolean.valueOf(false));
|
||||||
|
}
|
||||||
|
@@ -183,18 +185,33 @@
|
||||||
|
|
||||||
|
public boolean func_82231_m()
|
||||||
|
{
|
||||||
|
- return ((Integer)this.func_184212_Q().func_187225_a(field_184738_bw)).intValue() > 0;
|
||||||
|
+ return getVillagerTypeForge() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ @Deprecated // Use Forge Variant
|
||||||
|
public int func_184736_de()
|
||||||
|
{
|
||||||
|
return ((Integer)this.func_184212_Q().func_187225_a(field_184738_bw)).intValue() - 1;
|
||||||
|
}
|
||||||
|
+ private net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof;
|
||||||
|
+ @Nullable
|
||||||
|
+ public net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession getVillagerTypeForge()
|
||||||
|
+ {
|
||||||
|
+ return this.prof;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
+ @Deprecated //Use Forge version below
|
||||||
|
public void func_184735_a(int p_184735_1_)
|
||||||
|
{
|
||||||
|
this.func_184212_Q().func_187227_b(field_184738_bw, Integer.valueOf(p_184735_1_ + 1));
|
||||||
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, p_184735_1_);
|
||||||
|
}
|
||||||
|
+ public void setVillagerType(@Nullable net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession type)
|
||||||
|
+ {
|
||||||
|
+ this.prof = type;
|
||||||
|
+ this.func_184212_Q().func_187227_b(VILLAGER_TYPE_STR, type == null ? "" : type.getRegistryName().toString());
|
||||||
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, type);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
public void func_184732_df()
|
||||||
|
{
|
||||||
|
@@ -207,6 +224,17 @@
|
||||||
|
{
|
||||||
|
this.func_146071_k(this.func_70631_g_());
|
||||||
|
}
|
||||||
|
+ else if (field_184738_bw.equals(p_184206_1_))
|
||||||
|
+ {
|
||||||
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, this.func_184212_Q().func_187225_a(field_184738_bw) - 1);
|
||||||
|
+ }
|
||||||
|
+ else if (VILLAGER_TYPE_STR.equals(p_184206_1_))
|
||||||
|
+ {
|
||||||
|
+ String name = this.func_184212_Q().func_187225_a(VILLAGER_TYPE_STR);
|
||||||
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession p =
|
||||||
|
+ "".equals(name) ? null : net.minecraftforge.fml.common.registry.ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation(name));
|
||||||
|
+ this.setVillagerType(p);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
super.func_184206_a(p_184206_1_);
|
||||||
|
}
|
||||||
|
@@ -260,12 +288,24 @@
|
||||||
entitylivingbase = (EntityLivingBase)p_70097_1_.func_76346_g();
|
entitylivingbase = (EntityLivingBase)p_70097_1_.func_76346_g();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +108,7 @@
|
||||||
|
|
||||||
for (int l = 0; l < 50; ++l)
|
for (int l = 0; l < 50; ++l)
|
||||||
{
|
{
|
||||||
@@ -273,14 +285,14 @@
|
@@ -273,14 +313,14 @@
|
||||||
int j1 = j + MathHelper.func_76136_a(this.field_70146_Z, 7, 40) * MathHelper.func_76136_a(this.field_70146_Z, -1, 1);
|
int j1 = j + MathHelper.func_76136_a(this.field_70146_Z, 7, 40) * MathHelper.func_76136_a(this.field_70146_Z, -1, 1);
|
||||||
int k1 = k + MathHelper.func_76136_a(this.field_70146_Z, 7, 40) * MathHelper.func_76136_a(this.field_70146_Z, -1, 1);
|
int k1 = k + MathHelper.func_76136_a(this.field_70146_Z, 7, 40) * MathHelper.func_76136_a(this.field_70146_Z, -1, 1);
|
||||||
|
|
||||||
|
@ -56,7 +125,43 @@
|
||||||
entityzombie.func_180482_a(this.field_70170_p.func_175649_E(new BlockPos(entityzombie)), (IEntityLivingData)null);
|
entityzombie.func_180482_a(this.field_70170_p.func_175649_E(new BlockPos(entityzombie)), (IEntityLivingData)null);
|
||||||
this.func_110148_a(field_110186_bp).func_111121_a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
|
this.func_110148_a(field_110186_bp).func_111121_a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
|
||||||
entityzombie.func_110148_a(field_110186_bp).func_111121_a(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
|
entityzombie.func_110148_a(field_110186_bp).func_111121_a(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
|
||||||
@@ -486,7 +498,7 @@
|
@@ -394,6 +434,7 @@
|
||||||
|
{
|
||||||
|
p_70014_1_.func_74757_a("IsVillager", true);
|
||||||
|
p_70014_1_.func_74768_a("VillagerProfession", this.func_184736_de());
|
||||||
|
+ p_70014_1_.func_74778_a("VillagerProfessionName", this.getVillagerTypeForge() == null ? "" : this.getVillagerTypeForge().getRegistryName().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
p_70014_1_.func_74768_a("ConversionTime", this.func_82230_o() ? this.field_82234_d : -1);
|
||||||
|
@@ -417,8 +458,17 @@
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
- this.func_184735_a(this.field_70170_p.field_73012_v.nextInt(5));
|
||||||
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.setRandomProfession(this, this.field_70170_p.field_73012_v);
|
||||||
|
}
|
||||||
|
+ String name = p_70037_1_.func_74779_i("VillagerProfessionName");
|
||||||
|
+ if (!"".equals(name))
|
||||||
|
+ {
|
||||||
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession p =
|
||||||
|
+ net.minecraftforge.fml.common.registry.ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation(name));
|
||||||
|
+ if (p == null)
|
||||||
|
+ p = net.minecraftforge.fml.common.registry.ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation("minecraft:farmer"));
|
||||||
|
+ this.setVillagerType(p);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_70037_1_.func_150297_b("ConversionTime", 99) && p_70037_1_.func_74762_e("ConversionTime") > -1)
|
||||||
|
@@ -445,7 +495,7 @@
|
||||||
|
entityzombie.func_82149_j(p_70074_1_);
|
||||||
|
this.field_70170_p.func_72900_e(p_70074_1_);
|
||||||
|
entityzombie.func_180482_a(this.field_70170_p.func_175649_E(new BlockPos(entityzombie)), new EntityZombie.GroupData(false, true));
|
||||||
|
- entityzombie.func_184735_a(entityvillager.func_70946_n());
|
||||||
|
+ entityzombie.setVillagerType(entityvillager.getProfessionForge());
|
||||||
|
entityzombie.func_82227_f(p_70074_1_.func_70631_g_());
|
||||||
|
entityzombie.func_94061_f(entityvillager.func_175446_cd());
|
||||||
|
|
||||||
|
@@ -486,7 +536,7 @@
|
||||||
|
|
||||||
if (p_180482_2_ == null)
|
if (p_180482_2_ == null)
|
||||||
{
|
{
|
||||||
|
@ -65,3 +170,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_180482_2_ instanceof EntityZombie.GroupData)
|
if (p_180482_2_ instanceof EntityZombie.GroupData)
|
||||||
|
@@ -495,7 +545,7 @@
|
||||||
|
|
||||||
|
if (entityzombie$groupdata.field_142046_b)
|
||||||
|
{
|
||||||
|
- this.func_184735_a(this.field_70146_Z.nextInt(5));
|
||||||
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.setRandomProfession(this, this.field_70146_Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entityzombie$groupdata.field_142048_a)
|
||||||
|
@@ -629,7 +679,10 @@
|
||||||
|
|
||||||
|
this.field_70170_p.func_72900_e(this);
|
||||||
|
entityvillager.func_94061_f(this.func_175446_cd());
|
||||||
|
- entityvillager.func_70938_b(this.func_184736_de());
|
||||||
|
+ if (this.getVillagerTypeForge() != null)
|
||||||
|
+ entityvillager.setProfession(this.getVillagerTypeForge());
|
||||||
|
+ else
|
||||||
|
+ entityvillager.func_70938_b(0);
|
||||||
|
|
||||||
|
if (this.func_145818_k_())
|
||||||
|
{
|
||||||
|
|
|
@ -55,15 +55,16 @@
|
||||||
this.field_70956_bz = p_70037_1_.func_74762_e("Riches");
|
this.field_70956_bz = p_70037_1_.func_74762_e("Riches");
|
||||||
this.field_175563_bv = p_70037_1_.func_74762_e("Career");
|
this.field_175563_bv = p_70037_1_.func_74762_e("Career");
|
||||||
this.field_175562_bw = p_70037_1_.func_74762_e("CareerLevel");
|
this.field_175562_bw = p_70037_1_.func_74762_e("CareerLevel");
|
||||||
@@ -328,6 +340,7 @@
|
@@ -328,13 +340,52 @@
|
||||||
public void func_70938_b(int p_70938_1_)
|
public void func_70938_b(int p_70938_1_)
|
||||||
{
|
{
|
||||||
this.field_70180_af.func_187227_b(field_184752_bw, Integer.valueOf(p_70938_1_));
|
this.field_70180_af.func_187227_b(field_184752_bw, Integer.valueOf(p_70938_1_));
|
||||||
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, p_70938_1_);
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, p_70938_1_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ @Deprecated //Use Forge Variant below
|
||||||
public int func_70946_n()
|
public int func_70946_n()
|
||||||
@@ -335,6 +348,43 @@
|
{
|
||||||
return Math.max(((Integer)this.field_70180_af.func_187225_a(field_184752_bw)).intValue() % 5, 0);
|
return Math.max(((Integer)this.field_70180_af.func_187225_a(field_184752_bw)).intValue() % 5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@
|
||||||
public boolean func_70941_o()
|
public boolean func_70941_o()
|
||||||
{
|
{
|
||||||
return this.field_70952_f;
|
return this.field_70952_f;
|
||||||
@@ -534,15 +584,13 @@
|
@@ -534,15 +585,13 @@
|
||||||
|
|
||||||
private void func_175554_cu()
|
private void func_175554_cu()
|
||||||
{
|
{
|
||||||
|
@ -124,7 +125,7 @@
|
||||||
this.field_175562_bw = 1;
|
this.field_175562_bw = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,13 +601,11 @@
|
@@ -553,13 +602,11 @@
|
||||||
|
|
||||||
int i = this.field_175563_bv - 1;
|
int i = this.field_175563_bv - 1;
|
||||||
int j = this.field_175562_bw - 1;
|
int j = this.field_175562_bw - 1;
|
||||||
|
@ -141,23 +142,30 @@
|
||||||
{
|
{
|
||||||
entityvillager$itradelist.func_179401_a(this.field_70963_i, this.field_70146_Z);
|
entityvillager$itradelist.func_179401_a(this.field_70963_i, this.field_70146_Z);
|
||||||
}
|
}
|
||||||
@@ -648,9 +694,14 @@
|
@@ -648,9 +695,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ if (s1 == null)
|
- if (s1 != null)
|
||||||
+ s1 = this.getProfessionForge().getCareer(this.field_175563_bv).getName();
|
+ s1 = "entity.Villager." + this.getProfessionForge().getCareer(this.field_175563_bv).getName();
|
||||||
+ else
|
|
||||||
+ s1 = "entity.Villager." + s1;
|
|
||||||
+
|
|
||||||
if (s1 != null)
|
|
||||||
{
|
{
|
||||||
- TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("entity.Villager." + s1, new Object[0]);
|
- TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("entity.Villager." + s1, new Object[0]);
|
||||||
+ TextComponentTranslation textcomponenttranslation = new TextComponentTranslation(s1, new Object[0]);
|
+ TextComponentTranslation textcomponenttranslation = new TextComponentTranslation(s1, new Object[0]);
|
||||||
textcomponenttranslation.func_150256_b().func_150209_a(this.func_174823_aP());
|
textcomponenttranslation.func_150256_b().func_150209_a(this.func_174823_aP());
|
||||||
textcomponenttranslation.func_150256_b().func_179989_a(this.func_189512_bd());
|
textcomponenttranslation.func_150256_b().func_179989_a(this.func_189512_bd());
|
||||||
|
|
||||||
@@ -710,7 +761,7 @@
|
@@ -661,10 +708,6 @@
|
||||||
|
|
||||||
|
return textcomponenttranslation;
|
||||||
|
}
|
||||||
|
- else
|
||||||
|
- {
|
||||||
|
- return super.func_145748_c_();
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -710,7 +753,7 @@
|
||||||
public IEntityLivingData func_180482_a(DifficultyInstance p_180482_1_, @Nullable IEntityLivingData p_180482_2_)
|
public IEntityLivingData func_180482_a(DifficultyInstance p_180482_1_, @Nullable IEntityLivingData p_180482_2_)
|
||||||
{
|
{
|
||||||
p_180482_2_ = super.func_180482_a(p_180482_1_, p_180482_2_);
|
p_180482_2_ = super.func_180482_a(p_180482_1_, p_180482_2_);
|
||||||
|
@ -166,7 +174,7 @@
|
||||||
this.func_175552_ct();
|
this.func_175552_ct();
|
||||||
return p_180482_2_;
|
return p_180482_2_;
|
||||||
}
|
}
|
||||||
@@ -1030,4 +1081,6 @@
|
@@ -1030,4 +1073,6 @@
|
||||||
return ((Integer)this.func_76341_a()).intValue() >= ((Integer)this.func_76340_b()).intValue() ? ((Integer)this.func_76341_a()).intValue() : ((Integer)this.func_76341_a()).intValue() + p_179412_1_.nextInt(((Integer)this.func_76340_b()).intValue() - ((Integer)this.func_76341_a()).intValue() + 1);
|
return ((Integer)this.func_76341_a()).intValue() >= ((Integer)this.func_76340_b()).intValue() ? ((Integer)this.func_76341_a()).intValue() : ((Integer)this.func_76341_a()).intValue() + p_179412_1_.nextInt(((Integer)this.func_76340_b()).intValue() - ((Integer)this.func_76341_a()).intValue() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1660,6 +1670,9 @@
|
@@ -1647,19 +1657,27 @@
|
||||||
|
EntityVillager entityvillager = new EntityVillager(p_74893_1_);
|
||||||
|
entityvillager.func_70012_b((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F);
|
||||||
|
entityvillager.func_180482_a(p_74893_1_.func_175649_E(new BlockPos(entityvillager)), (IEntityLivingData)null);
|
||||||
|
- entityvillager.func_70938_b(this.func_180779_c(i, entityvillager.func_70946_n()));
|
||||||
|
+ entityvillager.setProfession(this.chooseForgeProfession(i, entityvillager.getProfessionForge()));
|
||||||
|
p_74893_1_.func_72838_d(entityvillager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ @Deprecated // Use Forge version below.
|
||||||
|
protected int func_180779_c(int p_180779_1_, int p_180779_2_)
|
||||||
|
{
|
||||||
|
return p_180779_2_;
|
||||||
|
}
|
||||||
|
+ protected net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession chooseForgeProfession(int count, net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof)
|
||||||
|
+ {
|
||||||
|
+ return net.minecraftforge.fml.common.registry.VillagerRegistry.getById(func_180779_c(count, net.minecraftforge.fml.common.registry.VillagerRegistry.getId(prof)));
|
||||||
|
+ }
|
||||||
|
|
||||||
protected IBlockState func_175847_a(IBlockState p_175847_1_)
|
protected IBlockState func_175847_a(IBlockState p_175847_1_)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,31 +12,17 @@
|
||||||
|
|
||||||
package net.minecraftforge.fml.common.registry;
|
package net.minecraftforge.fml.common.registry;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
|
import net.minecraft.entity.monster.EntityZombie;
|
||||||
import net.minecraft.entity.passive.EntityVillager;
|
import net.minecraft.entity.passive.EntityVillager;
|
||||||
import net.minecraft.entity.passive.EntityVillager.EmeraldForItems;
|
|
||||||
import net.minecraft.entity.passive.EntityVillager.ITradeList;
|
import net.minecraft.entity.passive.EntityVillager.ITradeList;
|
||||||
import net.minecraft.entity.passive.EntityVillager.ItemAndEmeraldToItem;
|
|
||||||
import net.minecraft.entity.passive.EntityVillager.ListEnchantedBookForEmeralds;
|
|
||||||
import net.minecraft.entity.passive.EntityVillager.ListEnchantedItemForEmeralds;
|
|
||||||
import net.minecraft.entity.passive.EntityVillager.ListItemForEmeralds;
|
|
||||||
import net.minecraft.entity.passive.EntityVillager.PriceInfo;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.init.Items;
|
|
||||||
import net.minecraft.item.EnumDyeColor;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.gen.structure.StructureComponent;
|
import net.minecraft.world.gen.structure.StructureComponent;
|
||||||
|
@ -45,8 +31,6 @@ import net.minecraft.world.gen.structure.StructureVillagePieces.PieceWeight;
|
||||||
import net.minecraft.world.gen.structure.StructureVillagePieces.Village;
|
import net.minecraft.world.gen.structure.StructureVillagePieces.Village;
|
||||||
/**
|
/**
|
||||||
* Registry for villager trading control
|
* Registry for villager trading control
|
||||||
*
|
|
||||||
* @author cpw
|
|
||||||
*/
|
*/
|
||||||
public class VillagerRegistry
|
public class VillagerRegistry
|
||||||
{
|
{
|
||||||
|
@ -151,7 +135,9 @@ public class VillagerRegistry
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VillagerProfession prof = new VillagerProfession("minecraft:farmer", "minecraft:textures/entity/villager/farmer.png");
|
VillagerProfession prof = new VillagerProfession("minecraft:farmer",
|
||||||
|
"minecraft:textures/entity/villager/farmer.png",
|
||||||
|
"minecraft:textures/entity/zombie_villager/zombie_farmer.png");
|
||||||
{
|
{
|
||||||
register(prof, 0);
|
register(prof, 0);
|
||||||
(new VillagerCareer(prof, "farmer")).init(VanillaTrades.trades[0][0]);
|
(new VillagerCareer(prof, "farmer")).init(VanillaTrades.trades[0][0]);
|
||||||
|
@ -159,24 +145,32 @@ public class VillagerRegistry
|
||||||
(new VillagerCareer(prof, "shepherd")).init(VanillaTrades.trades[0][2]);
|
(new VillagerCareer(prof, "shepherd")).init(VanillaTrades.trades[0][2]);
|
||||||
(new VillagerCareer(prof, "fletcher")).init(VanillaTrades.trades[0][3]);
|
(new VillagerCareer(prof, "fletcher")).init(VanillaTrades.trades[0][3]);
|
||||||
}
|
}
|
||||||
prof = new VillagerProfession("minecraft:librarian", "minecraft:textures/entity/villager/librarian.png");
|
prof = new VillagerProfession("minecraft:librarian",
|
||||||
|
"minecraft:textures/entity/villager/librarian.png",
|
||||||
|
"minecraft:textures/entity/zombie_villager/zombie_librarian.png");
|
||||||
{
|
{
|
||||||
register(prof, 1);
|
register(prof, 1);
|
||||||
(new VillagerCareer(prof, "librarian")).init(VanillaTrades.trades[1][0]);
|
(new VillagerCareer(prof, "librarian")).init(VanillaTrades.trades[1][0]);
|
||||||
}
|
}
|
||||||
prof = new VillagerProfession("minecraft:priest", "minecraft:textures/entity/villager/priest.png");
|
prof = new VillagerProfession("minecraft:priest",
|
||||||
|
"minecraft:textures/entity/villager/priest.png",
|
||||||
|
"minecraft:textures/entity/zombie_villager/zombie_priest.png");
|
||||||
{
|
{
|
||||||
register(prof, 2);
|
register(prof, 2);
|
||||||
(new VillagerCareer(prof, "cleric")).init(VanillaTrades.trades[2][0]);
|
(new VillagerCareer(prof, "cleric")).init(VanillaTrades.trades[2][0]);
|
||||||
}
|
}
|
||||||
prof = new VillagerProfession("minecraft:smith", "minecraft:textures/entity/villager/smith.png");
|
prof = new VillagerProfession("minecraft:smith",
|
||||||
|
"minecraft:textures/entity/villager/smith.png",
|
||||||
|
"minecraft:textures/entity/zombie_villager/zombie_smith.png");
|
||||||
{
|
{
|
||||||
register(prof, 3);
|
register(prof, 3);
|
||||||
(new VillagerCareer(prof, "armor")).init(VanillaTrades.trades[3][0]);
|
(new VillagerCareer(prof, "armor")).init(VanillaTrades.trades[3][0]);
|
||||||
(new VillagerCareer(prof, "weapon")).init(VanillaTrades.trades[3][1]);
|
(new VillagerCareer(prof, "weapon")).init(VanillaTrades.trades[3][1]);
|
||||||
(new VillagerCareer(prof, "tool")).init(VanillaTrades.trades[3][2]);
|
(new VillagerCareer(prof, "tool")).init(VanillaTrades.trades[3][2]);
|
||||||
}
|
}
|
||||||
prof = new VillagerProfession("minecraft:butcher", "minecraft:textures/entity/villager/butcher.png");
|
prof = new VillagerProfession("minecraft:butcher",
|
||||||
|
"minecraft:textures/entity/villager/butcher.png",
|
||||||
|
"minecraft:textures/entity/zombie_villager/zombie_butcher.png");
|
||||||
{
|
{
|
||||||
register(prof, 4);
|
register(prof, 4);
|
||||||
(new VillagerCareer(prof, "butcher")).init(VanillaTrades.trades[4][0]);
|
(new VillagerCareer(prof, "butcher")).init(VanillaTrades.trades[4][0]);
|
||||||
|
@ -188,12 +182,19 @@ public class VillagerRegistry
|
||||||
{
|
{
|
||||||
private ResourceLocation name;
|
private ResourceLocation name;
|
||||||
private ResourceLocation texture;
|
private ResourceLocation texture;
|
||||||
|
private ResourceLocation zombie;
|
||||||
private List<VillagerCareer> careers = Lists.newArrayList();
|
private List<VillagerCareer> careers = Lists.newArrayList();
|
||||||
|
|
||||||
|
@Deprecated //Use Zombie texture
|
||||||
public VillagerProfession(String name, String texture)
|
public VillagerProfession(String name, String texture)
|
||||||
|
{
|
||||||
|
this (name, texture, "minecraft:textures/entity/zombie_villager/zombie_villager.png");
|
||||||
|
}
|
||||||
|
public VillagerProfession(String name, String texture, String zombie)
|
||||||
{
|
{
|
||||||
this.name = new ResourceLocation(name);
|
this.name = new ResourceLocation(name);
|
||||||
this.texture = new ResourceLocation(texture);
|
this.texture = new ResourceLocation(texture);
|
||||||
|
this.zombie = new ResourceLocation(zombie);
|
||||||
this.setRegistryName(this.name);
|
this.setRegistryName(this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +207,7 @@ public class VillagerRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getSkin() { return this.texture; }
|
public ResourceLocation getSkin() { return this.texture; }
|
||||||
|
public ResourceLocation getZombieSkin() { return this.zombie; }
|
||||||
public VillagerCareer getCareer(int id)
|
public VillagerCareer getCareer(int id)
|
||||||
{
|
{
|
||||||
for (VillagerCareer car : this.careers)
|
for (VillagerCareer car : this.careers)
|
||||||
|
@ -302,10 +304,22 @@ public class VillagerRegistry
|
||||||
*/
|
*/
|
||||||
public static void setRandomProfession(EntityVillager entity, Random rand)
|
public static void setRandomProfession(EntityVillager entity, Random rand)
|
||||||
{
|
{
|
||||||
Set<ResourceLocation> entries = INSTANCE.professions.getKeys();
|
List<VillagerProfession> entries = INSTANCE.professions.getValues();
|
||||||
entity.setProfession(rand.nextInt(entries.size()));
|
entity.setProfession(entries.get(rand.nextInt(entries.size())));
|
||||||
|
}
|
||||||
|
public static void setRandomProfession(EntityZombie entity, Random rand)
|
||||||
|
{
|
||||||
|
List<VillagerProfession> entries = INSTANCE.professions.getValues();
|
||||||
|
entity.setVillagerType(entries.get(rand.nextInt(entries.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Below this is INTERNAL USE ONLY DO NOT USE MODDERS
|
||||||
public static void onSetProfession(EntityVillager entity, VillagerProfession prof)
|
public static void onSetProfession(EntityVillager entity, VillagerProfession prof)
|
||||||
{
|
{
|
||||||
int network = INSTANCE.professions.getId(prof);
|
int network = INSTANCE.professions.getId(prof);
|
||||||
|
@ -329,6 +343,46 @@ public class VillagerRegistry
|
||||||
entity.setProfession(prof);
|
entity.setProfession(prof);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static void onSetProfession(EntityZombie entity, VillagerProfession prof)
|
||||||
|
{
|
||||||
|
if (prof == null)
|
||||||
|
{
|
||||||
|
if (entity.getVillagerType() != 0)
|
||||||
|
entity.setVillagerType(-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int network = INSTANCE.professions.getId(prof);
|
||||||
|
if (network == -1 || prof != INSTANCE.professions.getObjectById(network))
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (network != entity.getVillagerType())
|
||||||
|
entity.setVillagerType(network);
|
||||||
|
}
|
||||||
|
public static void onSetProfession(EntityZombie entity, int network)
|
||||||
|
{
|
||||||
|
if (network == -1)
|
||||||
|
{
|
||||||
|
if (entity.getVillagerTypeForge() != null)
|
||||||
|
entity.setVillagerType(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
VillagerProfession prof = INSTANCE.professions.getObjectById(network);
|
||||||
|
if (prof == null && network != 0 || INSTANCE.professions.getId(prof) != network)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prof != entity.getVillagerTypeForge())
|
||||||
|
entity.setVillagerType(prof);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated public static VillagerProfession getById(int network){ return INSTANCE.professions.getObjectById(network); }
|
||||||
|
@Deprecated public static int getId(VillagerProfession prof){ return INSTANCE.professions.getId(prof); }
|
||||||
|
|
||||||
//TODO: Figure out a good generic system for this. Put on hold for Patches.
|
//TODO: Figure out a good generic system for this. Put on hold for Patches.
|
||||||
|
|
||||||
private static class VanillaTrades
|
private static class VanillaTrades
|
||||||
|
|
Loading…
Reference in a new issue