mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Fixed the cuccoon
This commit is contained in:
parent
9f8194dc12
commit
136519fb47
4 changed files with 53 additions and 79 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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,7 +79,11 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
|
|||
public boolean damage(DamageSource source, float amount) {
|
||||
|
||||
if (EquinePredicates.PLAYER_CHANGELING.test(source.getSource())) {
|
||||
amount = 0;
|
||||
|
||||
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,39 +159,36 @@ 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)) {
|
||||
Entity passenger = getPrimaryPassenger();
|
||||
|
||||
if (hasPassengers()) {
|
||||
Entity passenger = getPrimaryPassenger();
|
||||
if (passenger != null && (player.canConsume(false) || player.getHealth() < player.getMaximumHealth())) {
|
||||
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player);
|
||||
|
||||
if (player.canConsume(false) || player.getHealth() < player.getMaximumHealth()) {
|
||||
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player);
|
||||
Pony.of(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7);
|
||||
|
||||
Pony.of(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7);
|
||||
|
||||
if (passenger instanceof LivingEntity) {
|
||||
if (player.hasStatusEffect(StatusEffects.NAUSEA)) {
|
||||
((LivingEntity)passenger).addStatusEffect(player.removeStatusEffectInternal(StatusEffects.NAUSEA));
|
||||
} else if (random.nextInt(2300) == 0) {
|
||||
((LivingEntity)passenger).addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1));
|
||||
}
|
||||
if (passenger instanceof LivingEntity) {
|
||||
if (player.hasStatusEffect(StatusEffects.NAUSEA)) {
|
||||
((LivingEntity)passenger).addStatusEffect(player.removeStatusEffectInternal(StatusEffects.NAUSEA));
|
||||
} else if (random.nextInt(2300) == 0) {
|
||||
((LivingEntity)passenger).addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1));
|
||||
}
|
||||
|
||||
if (passenger instanceof PlayerEntity) {
|
||||
if (!player.hasStatusEffect(StatusEffects.HEALTH_BOOST)) {
|
||||
player.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1));
|
||||
}
|
||||
}
|
||||
|
||||
passenger.damage(d, 5);
|
||||
|
||||
if (player.canConsume(false)) {
|
||||
player.getHungerManager().add(5, 0);
|
||||
} else {
|
||||
player.heal(5);
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (passenger instanceof PlayerEntity) {
|
||||
if (!player.hasStatusEffect(StatusEffects.HEALTH_BOOST)) {
|
||||
player.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1));
|
||||
}
|
||||
}
|
||||
|
||||
passenger.damage(d, 5);
|
||||
|
||||
if (player.canConsume(false)) {
|
||||
player.getHungerManager().add(5, 0);
|
||||
} else {
|
||||
player.heal(5);
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue