mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
A flying pegasus can fit through a 1-block gap
This commit is contained in:
parent
a4bcfedabc
commit
2d46cf5c9a
3 changed files with 43 additions and 1 deletions
|
@ -156,7 +156,6 @@ public class Unicopia {
|
||||||
public static void onBlockHarvested(BlockEvent.HarvestDropsEvent event) {
|
public static void onBlockHarvested(BlockEvent.HarvestDropsEvent event) {
|
||||||
if (event.getState().getBlock() == Blocks.STONE) {
|
if (event.getState().getBlock() == Blocks.STONE) {
|
||||||
int fortuneFactor = 1 + event.getFortuneLevel() * 15;
|
int fortuneFactor = 1 + event.getFortuneLevel() * 15;
|
||||||
System.out.println(event.getFortuneLevel());
|
|
||||||
|
|
||||||
if (event.getWorld().rand.nextInt(500 / fortuneFactor) == 0) {
|
if (event.getWorld().rand.nextInt(500 / fortuneFactor) == 0) {
|
||||||
for (int i = 0; i < 1 + event.getFortuneLevel(); i++) {
|
for (int i = 0; i < 1 + event.getFortuneLevel(); i++) {
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.player;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.InbtSerialisable;
|
import com.minelittlepony.unicopia.InbtSerialisable;
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
|
import com.minelittlepony.unicopia.mixin.MixinEntity;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
|
@ -35,6 +36,7 @@ class PlayerGravityDelegate implements IUpdatable<EntityPlayer>, IGravity, InbtS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(EntityPlayer entity) {
|
public void onUpdate(EntityPlayer entity) {
|
||||||
|
|
||||||
entity.capabilities.allowFlying = entity.capabilities.isCreativeMode || player.getPlayerSpecies().canFly();
|
entity.capabilities.allowFlying = entity.capabilities.isCreativeMode || player.getPlayerSpecies().canFly();
|
||||||
|
|
||||||
if (!entity.capabilities.isCreativeMode) {
|
if (!entity.capabilities.isCreativeMode) {
|
||||||
|
@ -43,6 +45,13 @@ class PlayerGravityDelegate implements IUpdatable<EntityPlayer>, IGravity, InbtS
|
||||||
|
|
||||||
isFlying = entity.capabilities.isFlying && !entity.capabilities.isCreativeMode;
|
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 (!entity.capabilities.isCreativeMode && !entity.isElytraFlying()) {
|
||||||
if (isFlying && !entity.isRiding()) {
|
if (isFlying && !entity.isRiding()) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue