Skip to content

Instantly share code, notes, and snippets.

@Kaupenjoe
Last active October 8, 2021 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kaupenjoe/68b70945bca5b5b6b2b16f0c30725421 to your computer and use it in GitHub Desktop.
Save Kaupenjoe/68b70945bca5b5b6b2b16f0c30725421 to your computer and use it in GitHub Desktop.
"item.tutorialmod.buff_zombie_spawn_egg": "Buff Zombie Spawn Egg",
"item.tutorialmod.pigeon_spawn_egg": "Pigeon Spawn Egg",
public static final RegistryObject<ModSpawnEggItem> BUFF_ZOMBIE_SPAWN_EGG = ITEMS.register("buff_zombie_spawn_egg",
() -> new ModSpawnEggItem(ModEntityTypes.BUFF_ZOMBIE, 0x464F56, 0x1D6336,
new Item.Properties().group(ModItemGroup.TUTORIAL_GROUP)));
public static final RegistryObject<ModSpawnEggItem> PIGEON_SPAWN_EGG = ITEMS.register("pigeon_spawn_egg",
() -> new ModSpawnEggItem(ModEntityTypes.PIGEON, 0x879995, 0x576ABC,
new Item.Properties().group(ModItemGroup.TUTORIAL_GROUP)));
// add to the bottom of the biomeLoadingEvent method
ModEntityGeneration.onEntitySpawn(event);
// Call in Constructor
ModEntityTypes.register(eventBus);
// add this to your doClientStuff OUTSIDE the enqueueWork runnable, NOT INSIDE!
RenderingRegistry.registerEntityRenderingHandler(ModEntityTypes.BUFF_ZOMBIE.get(), BuffZombieRenderer::new);
RenderingRegistry.registerEntityRenderingHandler(ModEntityTypes.PIGEON.get(), PigeonRenderer::new);
{
"parent": "item/template_spawn_egg"
}
public class BuffZombieEntity extends ZombieEntity {
public BuffZombieEntity(EntityType<? extends ZombieEntity> type, World worldIn) {
super(type, worldIn);
}
public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
return MobEntity.func_233666_p_()
.createMutableAttribute(Attributes.MAX_HEALTH, 20.0D)
.createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.33D)
.createMutableAttribute(Attributes.ATTACK_DAMAGE, 13.0D)
.createMutableAttribute(Attributes.FOLLOW_RANGE, 50.0D)
.createMutableAttribute(Attributes.ZOMBIE_SPAWN_REINFORCEMENTS);
}
@Override
protected void registerGoals() {
super.registerGoals();
this.goalSelector.addGoal( 1, new NearestAttackableTargetGoal<>( this, PlayerEntity.class, true ) );
this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0D, false));
this.goalSelector.addGoal(7, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
this.targetSelector.addGoal(1, (new HurtByTargetGoal(this)).setCallsForHelp(ZombifiedPiglinEntity.class));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillagerEntity.class, false));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolemEntity.class, true));
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, TurtleEntity.class, 10, true, false, TurtleEntity.TARGET_DRY_BABY));
}
@Override
protected int getExperiencePoints(PlayerEntity player)
{
return 3 + this.world.rand.nextInt(5);
}
@Override
protected SoundEvent getAmbientSound()
{
return SoundEvents.ENTITY_HOGLIN_AMBIENT;
}
@Override
protected SoundEvent getDeathSound()
{
return SoundEvents.ENTITY_HOGLIN_DEATH;
}
@Override
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
{
return SoundEvents.ENTITY_IRON_GOLEM_HURT;
}
@Override
protected void playStepSound(BlockPos pos, BlockState blockIn)
{
this.playSound(SoundEvents.ENTITY_HOGLIN_STEP, 0.20F, 0.5F);
}
@Override
public boolean attackEntityAsMob(Entity entityIn) {
if (!super.attackEntityAsMob(entityIn)) {
return false;
} else {
if (entityIn instanceof LivingEntity) {
((LivingEntity)entityIn).addPotionEffect(new EffectInstance(Effects.SLOWNESS, 200,3));
((LivingEntity)entityIn).addPotionEffect(new EffectInstance(Effects.WEAKNESS, 200));
((LivingEntity)entityIn).addPotionEffect(new EffectInstance(Effects.NAUSEA, 200));
}
return true;
}
}
}
public class BuffZombieModel <T extends BuffZombieEntity> extends EntityModel<T> {
private final ModelRenderer head;
private final ModelRenderer body;
private final ModelRenderer rightLeg;
private final ModelRenderer rightArm;
private final ModelRenderer bone2;
private final ModelRenderer rightArm_r1;
private final ModelRenderer cube_r1_r1;
private final ModelRenderer bone3;
private final ModelRenderer rightArm_r2;
private final ModelRenderer cube_r1_r3;
private final ModelRenderer leftLeg;
private final ModelRenderer leftArm;
private final ModelRenderer bone;
private final ModelRenderer cube_r1_r2;
private final ModelRenderer leftArm_r1;
public BuffZombieModel() {
textureWidth = 128;
textureHeight = 128;
head = new ModelRenderer(this);
head.setRotationPoint(0.5F, -4.0F, 0.0F);
head.setTextureOffset(0, 28).addBox(-6.0F, -12.0F, -6.0F, 11.0F, 12.0F, 13.0F, 0.0F, false);
body = new ModelRenderer(this);
body.setRotationPoint(0.0F, 26.0F, 0.0F);
body.setTextureOffset(0, 0).addBox(-9.0F, -31.0F, -4.0F, 18.0F, 18.0F, 9.0F, 0.0F, false);
rightLeg = new ModelRenderer(this);
rightLeg.setRotationPoint(-4.0F, 11.0F, 1.0F);
rightLeg.setTextureOffset(55, 0).addBox(-4.0F, 0.0F, -4.0F, 7.0F, 13.0F, 7.0F, 0.0F, false);
rightArm = new ModelRenderer(this);
rightArm.setRotationPoint(-8.0F, -1.0F, -4.0F);
bone2 = new ModelRenderer(this);
bone2.setRotationPoint(-17.0F, 27.0F, 0.0F);
rightArm.addChild(bone2);
rightArm_r1 = new ModelRenderer(this);
rightArm_r1.setRotationPoint(25.0F, 0.0F, 0.0F);
bone2.addChild(rightArm_r1);
setRotationAngle(rightArm_r1, -1.5708F, 0.0F, 0.0F);
rightArm_r1.setTextureOffset(42, 47).addBox(-16.0F, -6.0F, -30.0F, 7.0F, 19.0F, 7.0F, 0.0F, false);
cube_r1_r1 = new ModelRenderer(this);
cube_r1_r1.setRotationPoint(0.0F, 0.0F, -4.0F);
bone2.addChild(cube_r1_r1);
setRotationAngle(cube_r1_r1, 0.3491F, 0.0F, 0.0F);
cube_r1_r1.setTextureOffset(35, 28).addBox(9.3F, -31.2F, -7.9F, 1.0F, -1.0F, 4.0F, 0.0F, false);
cube_r1_r1.setTextureOffset(35, 28).addBox(12.1F, -31.2F, -7.9F, 1.0F, -1.0F, 4.0F, 0.0F, false);
cube_r1_r1.setTextureOffset(35, 28).addBox(14.8F, -31.2F, -7.9F, 1.0F, -1.0F, 4.0F, 0.0F, false);
bone3 = new ModelRenderer(this);
bone3.setRotationPoint(-17.0F, 27.0F, 0.0F);
rightArm.addChild(bone3);
bone3.setTextureOffset(44, 78).addBox(12.1F, -28.0F, -19.0F, 1.0F, -1.0F, 13.0F, 0.0F, false);
bone3.setTextureOffset(42, 75).addBox(14.8F, -28.0F, -19.0F, 1.0F, -1.0F, 13.0F, 0.0F, false);
bone3.setTextureOffset(42, 81).addBox(9.3F, -28.0F, -19.0F, 1.0F, -1.0F, 13.0F, 0.0F, false);
rightArm_r2 = new ModelRenderer(this);
rightArm_r2.setRotationPoint(25.0F, 0.0F, 0.0F);
bone3.addChild(rightArm_r2);
setRotationAngle(rightArm_r2, -1.5708F, 0.0F, 0.0F);
rightArm_r2.setTextureOffset(42, 47).addBox(-16.0F, -6.0F, -30.0F, 7.0F, 19.0F, 7.0F, 0.0F, false);
cube_r1_r3 = new ModelRenderer(this);
cube_r1_r3.setRotationPoint(0.0F, 0.0F, -4.0F);
bone3.addChild(cube_r1_r3);
setRotationAngle(cube_r1_r3, 0.3491F, 0.0F, 0.0F);
leftLeg = new ModelRenderer(this);
leftLeg.setRotationPoint(4.0F, 11.0F, 0.0F);
leftLeg.setTextureOffset(0, 54).addBox(-3.0F, 0.0F, -3.0F, 7.0F, 13.0F, 7.0F, 0.0F, false);
leftArm = new ModelRenderer(this);
leftArm.setRotationPoint(8.0F, -1.0F, 0.0F);
bone = new ModelRenderer(this);
bone.setRotationPoint(-8.0F, 27.0F, 0.0F);
leftArm.addChild(bone);
bone.setTextureOffset(44, 82).addBox(14.8F, -28.0F, -23.0F, 1.0F, -1.0F, 13.0F, 0.0F, false);
bone.setTextureOffset(44, 82).addBox(12.1F, -28.0F, -23.0F, 1.0F, -1.0F, 13.0F, 0.0F, false);
bone.setTextureOffset(41, 78).addBox(9.3F, -28.0F, -23.0F, 1.0F, -1.0F, 13.0F, 0.0F, false);
cube_r1_r2 = new ModelRenderer(this);
cube_r1_r2.setRotationPoint(0.0F, 0.0F, 0.0F);
bone.addChild(cube_r1_r2);
setRotationAngle(cube_r1_r2, 0.3491F, 0.0F, 0.0F);
cube_r1_r2.setTextureOffset(3, 28).addBox(14.8F, -34.2F, -15.5F, 1.0F, -1.0F, 4.0F, 0.0F, false);
cube_r1_r2.setTextureOffset(1, 28).addBox(12.1F, -34.2F, -15.5F, 1.0F, -1.0F, 4.0F, 0.0F, false);
cube_r1_r2.setTextureOffset(0, 32).addBox(9.3F, -34.2F, -15.5F, 1.0F, -1.0F, 4.0F, 0.0F, false);
leftArm_r1 = new ModelRenderer(this);
leftArm_r1.setRotationPoint(0.0F, 0.0F, 0.0F);
bone.addChild(leftArm_r1);
setRotationAngle(leftArm_r1, -1.5708F, 0.0F, 0.0F);
leftArm_r1.setTextureOffset(49, 21).addBox(9.0F, -3.0F, -30.0F, 7.0F, 19.0F, 7.0F, 0.0F, false);
}
@Override
public void setRotationAngles(T entityIn, float limbSwing, float limbSwingAmount,
float ageInTicks, float netHeadYaw, float headPitch) {
this.head.rotateAngleX = headPitch * ((float)Math.PI / 180F);
this.head.rotateAngleY = netHeadYaw * ((float)Math.PI / 180F);
this.rightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount;
this.leftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
}
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight,
int packedOverlay, float red, float green, float blue, float alpha) {
head.render(matrixStack, buffer, packedLight, packedOverlay);
body.render(matrixStack, buffer, packedLight, packedOverlay);
rightLeg.render(matrixStack, buffer, packedLight, packedOverlay);
rightArm.render(matrixStack, buffer, packedLight, packedOverlay);
leftLeg.render(matrixStack, buffer, packedLight, packedOverlay);
leftArm.render(matrixStack, buffer, packedLight, packedOverlay);
}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
public class BuffZombieRenderer extends MobRenderer<BuffZombieEntity, BuffZombieModel<BuffZombieEntity>>
{
protected static final ResourceLocation TEXTURE =
new ResourceLocation(TutorialMod.MOD_ID, "textures/entity/buff_zombie.png");
public BuffZombieRenderer(EntityRendererManager renderManagerIn) {
super(renderManagerIn, new BuffZombieModel<>(), 0.7F);
}
@Override
public ResourceLocation getEntityTexture(BuffZombieEntity entity) {
return TEXTURE;
}
}
public class ModEntityGeneration {
public static void onEntitySpawn(final BiomeLoadingEvent event) {
addEntityToAllBiomes(event.getSpawns(), ModEntityTypes.BUFF_ZOMBIE.get(), 40, 2, 4);
addEntityToAllBiomesExceptThese(event, ModEntityTypes.PIGEON.get(), 50, 4, 10,
Biomes.PLAINS, Biomes.BEACH, Biomes.BIRCH_FOREST);
}
private static void addEntityToAllBiomesExceptThese(BiomeLoadingEvent event, EntityType<?> type,
int weight, int minCount, int maxCount, RegistryKey<Biome>... biomes) {
// Goes through each entry in the biomes and sees if it matches the current biome we are loading
boolean isBiomeSelected = Arrays.stream(biomes).map(RegistryKey::getLocation)
.map(Object::toString).anyMatch(s -> s.equals(event.getName().toString()));
if(!isBiomeSelected) {
addEntityToAllBiomes(event.getSpawns(), type, weight, minCount, maxCount);
}
}
private static void addEntityToSpecificBiomes(BiomeLoadingEvent event, EntityType<?> type,
int weight, int minCount, int maxCount, RegistryKey<Biome>... biomes) {
// Goes through each entry in the biomes and sees if it matches the current biome we are loading
boolean isBiomeSelected = Arrays.stream(biomes).map(RegistryKey::getLocation)
.map(Object::toString).anyMatch(s -> s.equals(event.getName().toString()));
if(isBiomeSelected) {
addEntityToAllBiomes(event.getSpawns(), type, weight, minCount, maxCount);
}
}
private static void addEntityToAllBiomes(MobSpawnInfoBuilder spawns, EntityType<?> type,
int weight, int minCount, int maxCount) {
List<MobSpawnInfo.Spawners> base = spawns.getSpawner(type.getClassification());
base.add(new MobSpawnInfo.Spawners(type,weight, minCount, maxCount));
}
}
public class ModEntityTypes {
public static DeferredRegister<EntityType<?>> ENTITY_TYPES
= DeferredRegister.create(ForgeRegistries.ENTITIES, TutorialMod.MOD_ID);
public static final RegistryObject<EntityType<BuffZombieEntity>> BUFF_ZOMBIE =
ENTITY_TYPES.register("buff_zombie",
() -> EntityType.Builder.create(BuffZombieEntity::new,
EntityClassification.MONSTER).size(1f, 3f)
.build(new ResourceLocation(TutorialMod.MOD_ID, "buff_zombie").toString()));
public static final RegistryObject<EntityType<PigeonEntity>> PIGEON =
ENTITY_TYPES.register("pigeon",
() -> EntityType.Builder.create(PigeonEntity::new,
EntityClassification.CREATURE).size(0.4f, 0.3f)
.build(new ResourceLocation(TutorialMod.MOD_ID, "pigeon").toString()));
public static void register(IEventBus eventBus) {
ENTITY_TYPES.register(eventBus);
}
}
@Mod.EventBusSubscriber(modid = TutorialMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModEventBusEvents {
@SubscribeEvent
public static void addEntityAttributes(EntityAttributeCreationEvent event) {
event.put(ModEntityTypes.BUFF_ZOMBIE.get(), BuffZombieEntity.setCustomAttributes().create());
event.put(ModEntityTypes.PIGEON.get(), PigeonEntity.setCustomAttributes().create());
}
@SubscribeEvent
public static void onRegisterEntities(RegistryEvent.Register<EntityType<?>> event) {
ModSpawnEggItem.initSpawnEggs();
}
}
public class ModSpawnEggItem extends SpawnEggItem {
protected static final List<ModSpawnEggItem> UNADDED_EGGS = new ArrayList<>();
private final Lazy<? extends EntityType<?>> entityTypeSupplier;
public ModSpawnEggItem(final RegistryObject<? extends EntityType<?>> entityTypeSupplier,
int primaryColorIn, int secondaryColorIn, Properties builder) {
super(null, primaryColorIn, secondaryColorIn, builder);
this.entityTypeSupplier = Lazy.of(entityTypeSupplier::get);
UNADDED_EGGS.add(this);
}
public static void initSpawnEggs() {
final Map<EntityType<?>, SpawnEggItem> EGGS = ObfuscationReflectionHelper.getPrivateValue(
SpawnEggItem.class, null, "field_195987_b");
DefaultDispenseItemBehavior dispenseItemBehavior = new DefaultDispenseItemBehavior() {
@Override
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack){
Direction direction = source.getBlockState().get(DispenserBlock.FACING);
EntityType<?> type = ((SpawnEggItem) stack.getItem()).getType(stack.getTag());
type.spawn(source.getWorld(), stack, null,source.getBlockPos(), SpawnReason.DISPENSER,
direction != Direction.UP, false);
stack.shrink(1);
return stack;
}
};
for(final SpawnEggItem spawnEgg : UNADDED_EGGS) {
EGGS.put(spawnEgg.getType(null), spawnEgg);
DispenserBlock.registerDispenseBehavior(spawnEgg, dispenseItemBehavior);
}
UNADDED_EGGS.clear();
}
@Override
public EntityType<?> getType(CompoundNBT nbt) {
return this.entityTypeSupplier.get();
}
}
{
"parent": "item/template_spawn_egg"
}
public class PigeonEntity extends ParrotEntity {
public PigeonEntity(EntityType<? extends ParrotEntity> type, World worldIn) {
super(type, worldIn);
this.moveController = new PigeonFlyingMovementController(this, 10, false);
}
public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
return MobEntity.func_233666_p_()
.createMutableAttribute(Attributes.MAX_HEALTH,3.0D)
.createMutableAttribute(Attributes.FLYING_SPEED, 1.3D)
.createMutableAttribute(Attributes.MOVEMENT_SPEED,1.6D);
}
@Override
protected void registerGoals() {
super.registerGoals();
this.goalSelector.addGoal(0, new SwimGoal(this));
this.goalSelector.addGoal(1,new PanicGoal(this,1.25D));
this.goalSelector.addGoal(2,new WaterAvoidingRandomWalkingGoal(this,1.0D));
this.goalSelector.addGoal(3,new LookAtGoal(this, PlayerEntity.class, 6.0F));
this.goalSelector.addGoal(7,new LookRandomlyGoal(this));
}
@Override
protected int getExperiencePoints(PlayerEntity player)
{
return 1 + this.world.rand.nextInt(4);
}
@Override
public SoundEvent getAmbientSound() {
this.playSound(SoundEvents.ENTITY_CHICKEN_AMBIENT, 0.2F, 1.0F);
return null;
}
@Override
protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
this.playSound(SoundEvents.ENTITY_RABBIT_HURT, 1.0F, 1.7F);
return null;
}
@Override
protected SoundEvent getDeathSound() {
this.playSound(SoundEvents.ENTITY_PARROT_DEATH, 0.7F, 2.0F);
return null;
}
@Override
public Vector3d getLeashStartPosition() {
return new Vector3d(5.0D, (5.5F * this.getEyeHeight()), (this.getWidth() * 5.4F));
}
}
public class PigeonFlyingMovementController extends FlyingMovementController
{
private int field_226323_i_ = 0;
private boolean field_226324_j_ = false;
public PigeonFlyingMovementController(MobEntity p_i225710_1_, int p_i225710_2_, boolean p_i225710_3_)
{
super(p_i225710_1_, p_i225710_2_, p_i225710_3_);
this.field_226323_i_ = field_226323_i_;
this.field_226324_j_ = field_226324_j_;
}
@Override
public void tick()
{
if (this.action == Action.MOVE_TO)
{
this.action = Action.WAIT;
this.mob.setNoGravity(true);
double d0 = this.posX - this.mob.getPosX();
double d1 = this.posY - this.mob.getPosY();
double d2 = this.posZ - this.mob.getPosZ();
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 < (double)2.5000003E-7F)
{
this.mob.setMoveVertical(2.0F);
this.mob.setMoveForward(2.0F);
return;
}
float f = (float)(MathHelper.atan2(d2, d0) * (double)(180F / (float)Math.PI)) - 90.0F;
this.mob.rotationYaw = this.limitAngle(this.mob.rotationYaw, f, 90.0F);
float f1;
if (this.mob.isOnGround())
{
f1 = (float)(this.speed * this.mob.getAttributeValue(Attributes.MOVEMENT_SPEED));
}
else
{
f1 = (float)(this.speed * this.mob.getAttributeValue(Attributes.FLYING_SPEED));
}
this.mob.setAIMoveSpeed(f1);
double d4 = MathHelper.sqrt(d0 * d0 + d2 * d2);
float f2 = (float)(-(MathHelper.atan2(d1, d4) * (double)(180F / (float)Math.PI)));
this.mob.rotationPitch = this.limitAngle(this.mob.rotationPitch, f2, (float)this.field_226323_i_);
this.mob.setMoveVertical(d1 > 0.0D ? f1 : -f1);
}
else
{
if (!this.field_226324_j_)
{
this.mob.setNoGravity(false);
}
this.mob.setMoveVertical(2.0F);
this.mob.setMoveForward(2.0F);
}
}
}
public class PigeonModel<T extends PigeonEntity> extends EntityModel<T> {
private final ModelRenderer legs;
private final ModelRenderer body;
private final ModelRenderer head;
private final ModelRenderer rightWing;
private final ModelRenderer cube_r1;
private final ModelRenderer leftWing;
private final ModelRenderer cube_r2;
public PigeonModel() {
textureWidth = 32;
textureHeight = 32;
legs = new ModelRenderer(this);
legs.setRotationPoint(0.0F, 24.0F, 0.0F);
legs.setTextureOffset(0, 8).addBox(-2.0F, -2.0F, 0.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
legs.setTextureOffset(0, 0).addBox(0.0F, -2.0F, 0.0F, 1.0F, 2.0F, 1.0F, 0.0F, false);
body = new ModelRenderer(this);
body.setRotationPoint(0.0F, 24.0F, 0.0F);
body.setTextureOffset(0, 8).addBox(-2.0F, -4.0F, -1.0F, 3.0F, 2.0F, 5.0F, 0.0F, false);
body.setTextureOffset(16, 0).addBox(-2.0F, -3.0F, 4.0F, 3.0F, 1.0F, 2.0F, 0.0F, false);
body.setTextureOffset(0, 0).addBox(-3.0F, -5.0F, -2.0F, 5.0F, 2.0F, 5.0F, 0.0F, false);
body.setTextureOffset(12, 8).addBox(-2.0F, -6.0F, -2.0F, 3.0F, 1.0F, 3.0F, 0.0F, false);
head = new ModelRenderer(this);
head.setRotationPoint(-0.5F, 18.25F, -0.75F);
head.setTextureOffset(6, 16).addBox(-0.5F, -1.25F, -2.25F, 1.0F, 1.0F, 1.0F, 0.0F, false);
head.setTextureOffset(9, 21).addBox(-1.0F, -2.25F, -1.25F, 2.0F, 2.0F, 2.0F, 0.0F, false);
rightWing = new ModelRenderer(this);
rightWing.setRotationPoint(-2.9509F, 20.0419F, -0.8627F);
cube_r1 = new ModelRenderer(this);
cube_r1.setRotationPoint(2.9509F, 3.9581F, 0.8627F);
rightWing.addChild(cube_r1);
setRotationAngle(cube_r1, -0.3491F, 0.0873F, 0.1309F);
cube_r1.setTextureOffset(23, 16).addBox(-4.0F, -3.0F, 2.0F, 1.0F, 2.0F, 2.0F, 0.0F, false);
cube_r1.setTextureOffset(18, 21).addBox(-4.0F, -4.0F, 0.0F, 1.0F, 3.0F, 2.0F, 0.0F, false);
cube_r1.setTextureOffset(0, 16).addBox(-4.0F, -5.0F, -3.0F, 1.0F, 4.0F, 3.0F, 0.0F, false);
leftWing = new ModelRenderer(this);
leftWing.setRotationPoint(2.0491F, 20.0419F, -0.8627F);
cube_r2 = new ModelRenderer(this);
cube_r2.setRotationPoint(0.0F, 0.5F, 1.1667F);
leftWing.addChild(cube_r2);
setRotationAngle(cube_r2, -0.3491F, -0.0873F, -0.1309F);
cube_r2.setTextureOffset(14, 13).addBox(-0.5F, -2.0F, -2.0F, 1.0F, 4.0F, 3.0F, 0.0F, false);
cube_r2.setTextureOffset(23, 11).addBox(-0.5F, 0.0F, 3.0F, 1.0F, 2.0F, 2.0F, 0.0F, false);
cube_r2.setTextureOffset(22, 4).addBox(-0.5F, -1.0F, 1.0F, 1.0F, 3.0F, 2.0F, 0.0F, false);
}
@Override
public void setRotationAngles(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks,
float netHeadYaw, float headPitch) {
this.head.rotateAngleX = headPitch * ((float)Math.PI / 180F);
this.head.rotateAngleY = netHeadYaw * ((float)Math.PI / 180F);
this.rightWing.rotateAngleY = MathHelper.cos(limbSwing * 2.6662F + (float)Math.PI) * 2.4F * limbSwingAmount;
this.leftWing.rotateAngleY = MathHelper.cos(limbSwing * 2.6662F) * 2.4F * limbSwingAmount;
}
@Override
public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight,
int packedOverlay, float red, float green, float blue, float alpha) {
legs.render(matrixStack, buffer, packedLight, packedOverlay);
body.render(matrixStack, buffer, packedLight, packedOverlay);
head.render(matrixStack, buffer, packedLight, packedOverlay);
rightWing.render(matrixStack, buffer, packedLight, packedOverlay);
leftWing.render(matrixStack, buffer, packedLight, packedOverlay);
}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
public class PigeonRenderer extends MobRenderer<PigeonEntity, PigeonModel<PigeonEntity>>
{
protected static final ResourceLocation TEXTURE =
new ResourceLocation(TutorialMod.MOD_ID, "textures/entity/pigeon.png");
public PigeonRenderer(EntityRendererManager renderManagerIn) {
super(renderManagerIn, new PigeonModel<>(), 0.2F);
}
@Override
public ResourceLocation getEntityTexture(PigeonEntity entity) {
return TEXTURE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment