-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8992f6f
commit faf6ecc
Showing
22 changed files
with
261 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/teammetallurgy/atum/client/render/entity/mobs/AtumVillagerRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.teammetallurgy.atum.client.render.entity.mobs; | ||
|
||
import com.mojang.blaze3d.matrix.MatrixStack; | ||
import com.teammetallurgy.atum.entity.villager.AtumVillagerEntity; | ||
import net.minecraft.client.renderer.entity.EntityRendererManager; | ||
import net.minecraft.client.renderer.entity.MobRenderer; | ||
import net.minecraft.client.renderer.entity.layers.VillagerLevelPendantLayer; | ||
import net.minecraft.client.renderer.entity.model.PlayerModel; | ||
import net.minecraft.resources.IReloadableResourceManager; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class AtumVillagerRenderer extends MobRenderer<AtumVillagerEntity, PlayerModel<AtumVillagerEntity>> { | ||
private static final ResourceLocation VILLAGER_TEXTURES = new ResourceLocation("textures/entity/villager/villager.png"); | ||
|
||
public AtumVillagerRenderer(EntityRendererManager renderManager, IReloadableResourceManager resourceManager) { | ||
super(renderManager, new PlayerModel<>(0.0F, false), 0.5F); | ||
//this.addLayer(new VillagerLevelPendantLayer(this, resourceManager, "villager")); //TODO Add custom ones | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public ResourceLocation getEntityTexture(@Nonnull AtumVillagerEntity entity) { | ||
return VILLAGER_TEXTURES; | ||
} | ||
|
||
@Override | ||
protected void preRenderCallback(AtumVillagerEntity atumVillagerEntity, @Nonnull MatrixStack matrixStack, float partialTickTime) { | ||
float f = 0.9375F; | ||
if (atumVillagerEntity.isChild()) { | ||
f = (float) ((double) f * 0.5D); | ||
this.shadowSize = 0.25F; | ||
} else { | ||
this.shadowSize = 0.5F; | ||
} | ||
matrixStack.scale(f, f, f); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 47 additions & 4 deletions
51
src/main/java/com/teammetallurgy/atum/entity/villager/AtumVillagerData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,76 @@ | ||
package com.teammetallurgy.atum.entity.villager; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.entity.merchant.villager.VillagerData; | ||
import net.minecraft.entity.merchant.villager.VillagerProfession; | ||
import net.minecraft.entity.villager.VillagerType; | ||
import net.minecraft.util.IStringSerializable; | ||
import net.minecraft.util.registry.Registry; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class AtumVillagerData extends VillagerData { //Same as vanilla VillagerData, but makes sure VillagerType is not used | ||
public static final Codec<AtumVillagerData> CODEC = RecordCodecBuilder.create((dataInstance) -> { | ||
return dataInstance.group(Registry.VILLAGER_PROFESSION.fieldOf("profession").orElseGet(() -> { | ||
return VillagerProfession.NONE; | ||
}).forGetter((data) -> { | ||
return data.profession; | ||
}), Codec.INT.fieldOf("level").orElse(1).forGetter((data) -> { | ||
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 VillagerProfession profession; | ||
private final int level; | ||
private final Race race; | ||
private final boolean isFemale; | ||
|
||
public AtumVillagerData(VillagerProfession profession, int level) { | ||
public AtumVillagerData(VillagerProfession profession, int level, Race race, boolean isFemale) { | ||
super(null, profession, level); | ||
this.profession = profession; | ||
this.level = level; | ||
this.race = race; | ||
this.isFemale = isFemale; | ||
} | ||
|
||
public Race getRace() { | ||
return this.race; | ||
} | ||
|
||
public boolean isFemale() { | ||
return this.isFemale; | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public VillagerData withProfession(@Nonnull VillagerProfession profession) { | ||
return new AtumVillagerData(profession, this.getLevel()); | ||
return new AtumVillagerData(profession, this.getLevel(), this.getRace(), this.isFemale()); | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public VillagerData withType(@Nullable VillagerType type) { | ||
return new AtumVillagerData(this.getProfession(), this.getLevel()); | ||
return new AtumVillagerData(this.getProfession(), this.getLevel(), this.getRace(), this.isFemale()); | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public VillagerData withLevel(int level) { | ||
return new AtumVillagerData(this.getProfession(), level); | ||
return new AtumVillagerData(this.getProfession(), level, this.getRace(), this.isFemale()); | ||
} | ||
|
||
@Nonnull | ||
public VillagerData withRace(Race race) { | ||
return new AtumVillagerData(this.getProfession(), this.getLevel(), race, this.isFemale()); | ||
} | ||
|
||
@Nonnull | ||
public VillagerData withGender(boolean isFemale) { | ||
return new AtumVillagerData(this.getProfession(), this.getLevel(), this.getRace(), isFemale); | ||
} | ||
} |
Oops, something went wrong.