Skip to content

Commit

Permalink
Fixed arms. Maybe.
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Mar 23, 2021
1 parent 1ccc3d1 commit 20c04c5
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ public VillagerLayer(IEntityRenderer<T, M> entityRenderer, String path) {
@Override
public void render(@Nonnull MatrixStack matrixStack, @Nonnull IRenderTypeBuffer buffer, int packedLight, T villager, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
if (!villager.isInvisible() && villager instanceof AtumVillagerEntity) {
AtumVillagerData villagerdata = ((AtumVillagerEntity) villager).getAtumVillagerData();
Race race = villagerdata.getRace();
AtumVillagerProfession profession = villagerdata.getAtumProfession();
AtumVillagerData data = ((AtumVillagerEntity) villager).getAtumVillagerData();
AtumVillagerProfession profession = data.getAtumProfession();
M m = this.getEntityModel();
if (profession != AtumVillagerProfession.NONE.get() && !villager.isChild()) {
ResourceLocation professionLocation = this.getLocation("profession", villagerdata.isFemale() ? "female" : "male", AtumRegistry.VILLAGER_PROFESSION.get().getKey(profession));
ResourceLocation professionLocation = this.getLocation("profession", ((AtumVillagerEntity) villager).isFemale() ? "female" : "male", AtumRegistry.VILLAGER_PROFESSION.get().getKey(profession));
renderCutoutModel(m, professionLocation, matrixStack, buffer, packedLight, villager, 1.0F, 1.0F, 1.0F);
if (profession != AtumVillagerProfession.NITWIT.get()) {
ResourceLocation professionLevelLocation = this.getLocation("profession_level", null, TIERS.get(MathHelper.clamp(villagerdata.getLevel(), 1, TIERS.size())));
ResourceLocation professionLevelLocation = this.getLocation("profession_level", null, TIERS.get(MathHelper.clamp(data.getLevel(), 1, TIERS.size())));
renderCutoutModel(m, professionLevelLocation, matrixStack, buffer, packedLight, villager, 1.0F, 1.0F, 1.0F);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@ public class AtumVillagerData extends VillagerData { //Same as vanilla VillagerD
return data.level;
}), IStringSerializable.createEnumCodec(Race::values, Race::getTypeFromName).fieldOf("race").orElse(Race.HUMAN).forGetter((data) -> {
return data.race;
}), Codec.BOOL.fieldOf("is_female").orElse(false).forGetter((data) -> {
return data.isFemale;
})).apply(dataInstance, AtumVillagerData::new);
});
private final AtumVillagerProfession profession;
private final int level;
private final Race race;
private final boolean isFemale;

public AtumVillagerData(AtumVillagerProfession profession, int level, Race race, boolean isFemale) {
public AtumVillagerData(AtumVillagerProfession profession, int level, Race race) {
super(null, null, level);
this.profession = profession;
this.level = level;
this.race = race;
this.isFemale = isFemale;
}

public AtumVillagerProfession getAtumProfession() {
Expand All @@ -45,29 +41,20 @@ public Race getRace() {
return this.race;
}

public boolean isFemale() {
return this.isFemale;
}

@Nonnull
public AtumVillagerData withProfession(@Nonnull AtumVillagerProfession profession) {
return new AtumVillagerData(profession, this.getLevel(), this.getRace(), this.isFemale());
return new AtumVillagerData(profession, this.getLevel(), this.getRace());
}

@Override
@Nonnull
public AtumVillagerData withLevel(int level) {
return new AtumVillagerData(this.getAtumProfession(), level, this.getRace(), this.isFemale());
return new AtumVillagerData(this.getAtumProfession(), level, this.getRace());
}

@Nonnull
public AtumVillagerData withRace(Race race) {
return new AtumVillagerData(this.getAtumProfession(), this.getLevel(), race, this.isFemale());
}

@Nonnull
public AtumVillagerData withGender(boolean isFemale) {
return new AtumVillagerData(this.getAtumProfession(), this.getLevel(), this.getRace(), isFemale);
return new AtumVillagerData(this.getAtumProfession(), this.getLevel(), race);
}

//Deprecated usage of vanilla mehtods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ public class AtumVillagerEntity extends VillagerEntity implements ITexture {

public AtumVillagerEntity(EntityType<? extends AtumVillagerEntity> type, World world) {
super(type, world, VillagerType.DESERT); //Type not used, by Atum villagers
this.setAtumVillagerData(this.getAtumVillagerData().withGender(type == AtumEntities.VILLAGER_FEMALE).withProfession(AtumVillagerProfession.NONE.get()));
this.setAtumVillagerData(this.getAtumVillagerData().withProfession(AtumVillagerProfession.NONE.get()));
}

public boolean isFemale() {
return this.getType() == AtumEntities.VILLAGER_FEMALE;
}

@Override
protected void registerData() {
super.registerData();
this.dataManager.register(ATUM_VILLAGER_DATA, new AtumVillagerData(AtumVillagerProfession.NONE.get(), 1, Race.HUMAN, false));
this.dataManager.register(ATUM_VILLAGER_DATA, new AtumVillagerData(AtumVillagerProfession.NONE.get(), 1, Race.HUMAN));
this.dataManager.register(VARIANT, 0);
}

Expand Down Expand Up @@ -301,14 +305,13 @@ private int getVariant() {
public String getTexture() {
if (this.texturePath == null) {
AtumVillagerData atumVillagerData = this.getAtumVillagerData();
String gender = atumVillagerData.isFemale() ? "female" : "male";
String gender = this.isFemale() ? "female" : "male";
this.texturePath = new ResourceLocation(Atum.MOD_ID, "textures/entity/villager/" + atumVillagerData.getRace().getName() + "/" + gender + "_" + this.getVariant()) + ".png";
}
return this.texturePath;
}

@Override

public void playWorkstationSound() {
SoundEvent soundEvent = this.getAtumVillagerData().getAtumProfession().getSound();
if (soundEvent != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ public void write(PacketBuffer buf, AtumVillagerData value) {
buf.writeString(AtumRegistry.VILLAGER_PROFESSION.get().getKey(value.getAtumProfession()).toString());
buf.writeVarInt(value.getLevel());
buf.writeEnumValue(value.getRace());
buf.writeBoolean(value.isFemale());
}

@Override
public AtumVillagerData read(PacketBuffer buf) {
return new AtumVillagerData(AtumRegistry.VILLAGER_PROFESSION.get().getValue(new ResourceLocation(buf.readString())), buf.readVarInt(), buf.readEnumValue(Race.class), buf.readBoolean());
return new AtumVillagerData(AtumRegistry.VILLAGER_PROFESSION.get().getValue(new ResourceLocation(buf.readString())), buf.readVarInt(), buf.readEnumValue(Race.class));
}

@Override
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 20c04c5

Please sign in to comment.