A flying pegasus can fit through a 1-block gap

This commit is contained in:
Sollace 2018-09-26 00:03:14 +02:00
parent a4bcfedabc
commit 2d46cf5c9a
3 changed files with 43 additions and 1 deletions

View file

@ -156,7 +156,6 @@ public class Unicopia {
public static void onBlockHarvested(BlockEvent.HarvestDropsEvent event) {
if (event.getState().getBlock() == Blocks.STONE) {
int fortuneFactor = 1 + event.getFortuneLevel() * 15;
System.out.println(event.getFortuneLevel());
if (event.getWorld().rand.nextInt(500 / fortuneFactor) == 0) {
for (int i = 0; i < 1 + event.getFortuneLevel(); i++) {

View file

@ -0,0 +1,34 @@
package com.minelittlepony.unicopia.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MoverType;
import net.minecraft.util.math.AxisAlignedBB;
// pseudo code for things forge can't do.
// @Mixin(Entity.class)
public interface MixinEntity {
// @Accessor("setSize")
static void setSize(Entity self, float width, float height) {
if (self.width != width || self.height != height) {
float f = self.width;
self.width = width;
self.height = height;
if (self.width < f) {
double d0 = width / 2;
self.setEntityBoundingBox(new AxisAlignedBB(
self.posX - d0, self.posY, self.posZ - d0,
self.posX + d0, self.posY + self.height, self.posZ + d0));
return;
}
AxisAlignedBB axisalignedbb = self.getEntityBoundingBox();
self.setEntityBoundingBox(new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ, axisalignedbb.minX + (double)self.width, axisalignedbb.minY + (double)self.height, axisalignedbb.minZ + (double)self.width));
if (self.width > f/* && !self.firstUpdate*/ && !self.world.isRemote) {
self.move(MoverType.SELF, (double)(f - self.width), 0, (double)(f - self.width));
}
}
}
}

View file

@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.player;
import com.minelittlepony.unicopia.InbtSerialisable;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.mixin.MixinEntity;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
@ -35,6 +36,7 @@ class PlayerGravityDelegate implements IUpdatable<EntityPlayer>, IGravity, InbtS
@Override
public void onUpdate(EntityPlayer entity) {
entity.capabilities.allowFlying = entity.capabilities.isCreativeMode || player.getPlayerSpecies().canFly();
if (!entity.capabilities.isCreativeMode) {
@ -43,6 +45,13 @@ class PlayerGravityDelegate implements IUpdatable<EntityPlayer>, IGravity, InbtS
isFlying = entity.capabilities.isFlying && !entity.capabilities.isCreativeMode;
if (isFlying) {
MixinEntity.setSize(entity, entity.width, 0.5F);
entity.eyeHeight = entity.height / 2;
} else {
entity.eyeHeight = entity.getDefaultEyeHeight();
}
if (!entity.capabilities.isCreativeMode && !entity.isElytraFlying()) {
if (isFlying && !entity.isRiding()) {