Fixed disguise orientation and door disguises. Fixes #259

This commit is contained in:
Sollace 2024-05-23 18:52:55 +01:00
parent c61f2ce834
commit 98f612cd13
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 10 additions and 30 deletions

View file

@ -9,7 +9,6 @@ import com.minelittlepony.unicopia.entity.behaviour.Disguise;
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
import com.minelittlepony.unicopia.mixin.MixinBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.OverlayTexture;
@ -19,10 +18,7 @@ import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;
class EntityDisguiseRenderer {
@ -90,15 +86,7 @@ class EntityDisguiseRenderer {
((MixinBlockEntity)blockEntity).setPos(e.getBlockPos());
blockEntity.setWorld(e.getWorld());
matrices.push();
BlockState state = blockEntity.getCachedState();
Direction direction = state.contains(Properties.HORIZONTAL_FACING) ? state.get(Properties.HORIZONTAL_FACING) : Direction.UP;
matrices.translate(x, y, z);
matrices.multiply(direction.getRotationQuaternion());
matrices.multiply(RotationAxis.NEGATIVE_X.rotationDegrees(90));
matrices.translate(-0.5, 0, -0.5);
r.render(blockEntity, 1, matrices, vertexConsumers, light, OverlayTexture.DEFAULT_UV);

View file

@ -34,7 +34,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.LlamaSpitEntity;
import net.minecraft.entity.projectile.thrown.SnowballEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.registry.Registry;
@ -138,12 +137,6 @@ public class EntityBehaviour<T extends Entity> {
double y = positionOffset.y + Math.floor(from.getY());
double z = positionOffset.z + Math.floor(from.getZ()) + 0.5;
BlockPos pos = BlockPos.ofFloored(x, y, z);
if (!from.getWorld().isAir(pos) && !from.getWorld().isWater(pos)) {
y++;
}
to.prevX = x;
to.prevY = y;
to.prevZ = z;

View file

@ -25,7 +25,6 @@ import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.state.property.Properties;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
@ -74,7 +73,11 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
BlockState state = entity.getBlockState();
Block block = state.getBlock();
if (state.isIn(BlockTags.DOORS) && block instanceof DoorBlock) {
if (block instanceof BlockEntityProvider bep) {
context.addBlockEntity(bep.createBlockEntity(entity.getBlockPos(), state));
}
if (block instanceof DoorBlock) {
BlockState lowerState = state.with(DoorBlock.HALF, DoubleBlockHalf.LOWER);
BlockState upperState = state.with(DoorBlock.HALF, DoubleBlockHalf.UPPER);
@ -83,10 +86,6 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
return configure(MixinFallingBlockEntity.createInstance(entity.getWorld(), entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block);
}
if (block instanceof BlockEntityProvider bep) {
context.addBlockEntity(bep.createBlockEntity(entity.getBlockPos(), state));
}
return configure(entity, block);
}
@ -100,15 +99,10 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
if (state.get(Properties.WATERLOGGED) != logged) {
entity = MixinFallingBlockEntity.createInstance(entity.getWorld(), entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged));
spell.getDisguise().setAppearance(entity);
return;
}
}
EntityAppearance disguise = spell.getDisguise();
List<Entity> attachments = disguise.getAttachments();
if (attachments.size() > 0) {
copyBaseAttributes(source.asEntity(), attachments.get(0), UP);
}
BlockEntity be = disguise.getBlockEntity();
@ -122,5 +116,10 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
ceb.tick();
be.setWorld(null);
}
List<Entity> attachments = disguise.getAttachments();
if (attachments.size() > 0) {
copyBaseAttributes(source.asEntity(), attachments.get(0), UP);
}
}
}