Fixed the cuccoon

This commit is contained in:
Sollace 2020-05-05 18:48:24 +02:00
parent 9f8194dc12
commit 136519fb47
4 changed files with 53 additions and 79 deletions

View file

@ -1,17 +1,10 @@
package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.client.render.model.CuccoonEntityModel;
import com.minelittlepony.unicopia.entity.CuccoonEntity;
import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.util.Identifier;
public class CuccoonEntityRenderer extends LivingEntityRenderer<CuccoonEntity, CuccoonEntityModel> {
@ -33,21 +26,7 @@ public class CuccoonEntityRenderer extends LivingEntityRenderer<CuccoonEntity, C
}
@Override
public void render(CuccoonEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertices, int light) {
if (entity.hasPassengers()) {
Entity rider = entity.getPassengerList().get(0);
if (!(rider == MinecraftClient.getInstance().player) || InteractionManager.instance().getViewMode() != 0) {
RenderSystem.enableAlphaTest();
RenderSystem.enableBlend();
renderManager.render(rider, rider.getX(), rider.getY() + rider.getMountedHeightOffset(), rider.getZ(), rider.yaw, tickDelta, matrices, vertices, light);
RenderSystem.disableBlend();
RenderSystem.disableAlphaTest();
}
}
super.render(entity, yaw, tickDelta, matrices, vertices, light);
protected boolean hasLabel(CuccoonEntity mobEntity) {
return super.hasLabel(mobEntity) && (mobEntity.shouldRenderName() || mobEntity.hasCustomName() && mobEntity == renderManager.targetedEntity);
}
}

View file

@ -1,11 +1,8 @@
package com.minelittlepony.unicopia.client.render.model;
import com.minelittlepony.unicopia.entity.CuccoonEntity;
import com.mojang.blaze3d.platform.GlStateManager.DstFactor;
import com.mojang.blaze3d.platform.GlStateManager.SrcFactor;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.util.math.MatrixStack;
@ -17,6 +14,7 @@ public class CuccoonEntityModel extends EntityModel<CuccoonEntity> {
private float breatheAmount;
public CuccoonEntityModel() {
super(RenderLayer::getEntityTranslucentCull);
body = new ModelPart(this, 0, 0);
body.setTextureSize(250, 250);
@ -35,12 +33,6 @@ public class CuccoonEntityModel extends EntityModel<CuccoonEntity> {
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
matrices.push();
RenderSystem.enableBlend();
RenderSystem.enableAlphaTest();
RenderSystem.enableRescaleNormal();
RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA);
matrices.scale(1 - breatheAmount, 1 + breatheAmount, 1 - breatheAmount);
matrices.translate(0, -breatheAmount * 1.3F, 0);
@ -51,10 +43,6 @@ public class CuccoonEntityModel extends EntityModel<CuccoonEntity> {
body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
RenderSystem.disableRescaleNormal();
RenderSystem.disableAlphaTest();
RenderSystem.disableBlend();
matrices.pop();
}

View file

@ -1,10 +1,9 @@
package com.minelittlepony.unicopia.entity;
import java.util.List;
import java.util.Collections;
import javax.annotation.Nullable;
import com.google.common.collect.Lists;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
@ -12,6 +11,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import net.fabricmc.fabric.api.tools.FabricToolTags;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
@ -44,8 +44,6 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
private static final TrackedData<Integer> STRUGGLE_COUNT = DataTracker.registerData(CuccoonEntity.class, TrackedDataHandlerRegistry.INTEGER);
private final List<ItemStack> armour = Lists.newArrayList();
private boolean captiveLastSneakState;
public CuccoonEntity(EntityType<CuccoonEntity> type, World world) {
@ -81,8 +79,12 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
public boolean damage(DamageSource source, float amount) {
if (EquinePredicates.PLAYER_CHANGELING.test(source.getSource())) {
PlayerEntity player = (PlayerEntity)source.getSource();
if (!FabricToolTags.SHOVELS.contains(player.getMainHandStack().getItem())) {
amount = 0;
}
}
return super.damage(source, amount);
}
@ -93,6 +95,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
&& !entity.isSneaking()
&& !hasPassengers()
&& entity instanceof LivingEntity
&& !(entity instanceof CuccoonEntity)
&& !EquinePredicates.PLAYER_CHANGELING.test(entity);
}
@ -106,6 +109,12 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
return 0;
}
@Override
@Nullable
public Entity getPrimaryPassenger() {
return getPassengerList().isEmpty() ? null : getPassengerList().get(0);
}
@Override
public void tick() {
super.tick();
@ -150,11 +159,9 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
public ActionResult interactAt(PlayerEntity player, Vec3d vec, Hand hand) {
if (hand == Hand.MAIN_HAND && EquinePredicates.PLAYER_CHANGELING.test(player)) {
if (hasPassengers()) {
Entity passenger = getPrimaryPassenger();
if (player.canConsume(false) || player.getHealth() < player.getMaximumHealth()) {
if (passenger != null && (player.canConsume(false) || player.getHealth() < player.getMaximumHealth())) {
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player);
Pony.of(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7);
@ -184,7 +191,6 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
return ActionResult.SUCCESS;
}
}
}
return super.interactAt(player, vec, hand);
}
@ -196,7 +202,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
@Override
public boolean isAttackable() {
return false;
return true;
}
public boolean attemptDismount(Entity captive) {
@ -284,7 +290,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
@Override
public Iterable<ItemStack> getArmorItems() {
return armour;
return Collections.emptyList();
}
@Override

View file

@ -165,13 +165,14 @@
"curse.siphon": "Siphoning",
"curse.siphon.tagline": "Energy III",
"entity.racing_cloud.name": "Bucking Bronco",
"entity.construction_cloud.name": "Construction Cloud",
"entity.cloud.name": "Cloud",
"entity.spell.name": "Magic",
"entity.spellbook.name": "Spellbook",
"entity.butterfly.name": "Butterfly",
"entity.spear.name": "Spear",
"entity.unicopia.racing_cloud": "Bucking Bronco",
"entity.unicopia.construction_cloud": "Construction Cloud",
"entity.unicopia.cloud": "Cloud",
"entity.unicopia.spell": "Magic",
"entity.unicopia.spellbook": "Spellbook",
"entity.unicopia.butterfly": "Butterfly",
"entity.unicopia.spear": "Spear",
"entity.unicopia.cuccoon": "Cuccoon",
"toxicity.safe.name": "Safe",
"toxicity.mild.name": "Mildly Toxic",