diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/CloudEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/CloudEntityRenderer.java index d7fa5df5..eaf9b70a 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/CloudEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/CloudEntityRenderer.java @@ -26,14 +26,14 @@ public class CloudEntityRenderer extends MobEntityRenderer STATIONARY = DataTracker.registerData(CloudEntity.class, TrackedDataHandlerRegistry.BOOLEAN); + public static final EntityDimensions BASE_DIMENSIONS = EntityDimensions.changing(0.6f, 0.6f); + protected double targetAltitude; protected int directionX; @@ -75,6 +77,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate public CloudEntity(EntityType type, World world) { super(type, world); + inanimate = true; ignoreCameraFrustum = true; targetAltitude = getRandomFlyingHeight(); } @@ -355,7 +358,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate Vec3d vel = getVelocity(); - setVelocity(vel.x, vel.y - 0.002 + (Math.signum(distance) * 0.699999988079071D - vel.y) * 0.10000000149011612D, vel.z); + setVelocity(vel.x, vel.y + (Math.signum(distance) * 0.699999988079071D - vel.y) * 0.10000000149011612D, vel.z); } } } @@ -364,10 +367,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate float a = getMaximumFlyingHeight(); float b = getMinimumFlyingHeight(); - float min = Math.min(a, b); - float max = Math.max(a, b); - - return min + world.random.nextFloat() * (max - min); + return MathHelper.lerp(world.random.nextFloat(), Math.min(a, b), Math.max(a, b)); } protected float getMinimumFlyingHeight() { @@ -461,13 +461,13 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate } super.onDeath(s); - clearItemFloatingState(); + //clearItemFloatingState(); } @Override public void remove() { super.remove(); - clearItemFloatingState(); + //clearItemFloatingState(); } //@FUF(reason = "There is no TickEvent.EntityTickEvent. Waiting on mixins...") @@ -533,7 +533,8 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate if (!isConnectedThroughVehicle(entity) && floatStrength > 0) { - double boundModifier = entity.fallDistance > 80 ? 80 : MathHelper.floor(entity.fallDistance * 10) / 10; + double bounceModifier = entity.fallDistance > 80 ? 80 : MathHelper.floor(entity.fallDistance * 10) / 10; + entity.onGround = true; @@ -542,7 +543,15 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate double motionY = motion.y; double motionZ = motion.z; - motionY += (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - motionY + boundModifier * 0.7) * 0.10000000149011612D; + if (motionY <= 0) { + motionY += (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - motionY + bounceModifier * 0.7) * 0.10000000149011612D; + + motionY = Math.min(0.1F, motionY); + if (motionY < 0.002F) { + motionY = 0.001; + } + } + if (!getStationary()) { motionX += ((motionX - motionX) / getCloudSize()) - 0.002F; } @@ -551,12 +560,9 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate spawnThunderbolt(getBlockPos()); } - // @FUF(reason = "There is no TickEvents.EntityTickEvent. Waiting on mixins...") if (getStationary() && entity instanceof ItemEntity) { motionX /= 8; motionZ /= 8; - motionY /= 16; - entity.setNoGravity(true); } entity.setVelocity(motionX, motionY, motionZ); @@ -685,13 +691,17 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate } @Override - public EntityDimensions getDimensions(EntityPose pose) { - return super.getDimensions(pose).scaled(getCloudSize()); + public float getScaleFactor() { + return getCloudSize(); } + @Override + public EntityDimensions getDimensions(EntityPose pose) { + return EntityDimensions.changing(3, 0.5F).scaled(getScaleFactor()); // super.getDimensions(pose); + } + public void setCloudSize(int val) { - val = Math.max(1, val); - dataTracker.set(SCALE, val); + dataTracker.set(SCALE, Math.max(1, val)); calculateDimensions(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java index e2a0b2da..d662c740 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java @@ -1,6 +1,5 @@ package com.minelittlepony.unicopia.entity; -import com.google.common.collect.Lists; import com.minelittlepony.unicopia.EquinePredicates; import net.minecraft.client.MinecraftClient; @@ -11,13 +10,15 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; import net.minecraft.item.SpawnEggItem; -import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.BlockView; +import net.minecraft.world.RayTraceContext; import net.minecraft.world.World; public class ConstructionCloudEntity extends CloudEntity { @@ -70,14 +71,23 @@ public class ConstructionCloudEntity extends CloudEntity { float ticks = mc.getTickDelta(); - Vec3d eye = player.getCameraPosVec(ticks); - Vec3d look = player.getOppositeRotationVector(ticks); - Vec3d ray = eye.add(look.x * distance, look.y * distance, look.z * distance); + Vec3d start = player.getCameraPosVec(ticks); + Vec3d rotation = player.getRotationVec(ticks); + Vec3d end = start.add(rotation.x * distance, rotation.y * distance, rotation.z * distance); - float s = 0.5F; - Box bounds = getBoundingBox().shrink(0, s, 0).shrink(0, -s, 0); + Box box = getBoundingBox().expand(3); - BlockHitResult hit = Box.rayTrace(Lists.newArrayList(bounds), eye, ray, BlockPos.ORIGIN); + RayTraceContext ctx = new RayTraceContext(start, end, RayTraceContext.ShapeType.OUTLINE, RayTraceContext.FluidHandling.NONE, player); + + BlockHitResult hit = BlockView.rayTrace(ctx, (c, pos) -> { + if (box.contains(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)) { + return new BlockHitResult(new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), Direction.UP, pos, true); + } + + return null; + }, c -> { + return null; + }); if (hit != null) { Direction direction = hit.getSide(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java b/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java index 8198168e..69b2b1ab 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java @@ -18,21 +18,34 @@ import net.minecraft.world.biome.PlainsBiome; import net.minecraft.world.biome.RiverBiome; public interface UEntities { - EntityType SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellbookEntity::new).size(EntityDimensions.changing(0.6f, 0.6f))); - EntityType MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellcastEntity::new).size(EntityDimensions.changing(0.6F, 0.25F))); - EntityType CLOUD = register("cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, CloudEntity::new)); - EntityType WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, WildCloudEntity::new)); - EntityType RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, RacingCloudEntity::new)); - EntityType CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, ConstructionCloudEntity::new)); + EntityType SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellbookEntity::new) + .size(EntityDimensions.changing(0.6F, 0.6F))); + EntityType MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellcastEntity::new) + .size(EntityDimensions.changing(0.6F, 0.25F))); + EntityType CLOUD = register("cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, CloudEntity::new) + .size(CloudEntity.BASE_DIMENSIONS)); + EntityType WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, WildCloudEntity::new) + .size(CloudEntity.BASE_DIMENSIONS)); + EntityType RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, RacingCloudEntity::new) + .size(CloudEntity.BASE_DIMENSIONS)); + EntityType CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, ConstructionCloudEntity::new) + .size(CloudEntity.BASE_DIMENSIONS)); - EntityType RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, RainbowEntity::new)); + EntityType RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, RainbowEntity::new) + .size(EntityDimensions.fixed(1, 1))); - EntityType CUCCOON = register("cuccoon", FabricEntityTypeBuilder.create(EntityCategory.MISC, CuccoonEntity::new).size(EntityDimensions.changing(1.5F, 1.6F))); + EntityType CUCCOON = register("cuccoon", FabricEntityTypeBuilder.create(EntityCategory.MISC, CuccoonEntity::new) + .size(EntityDimensions.changing(1.5F, 1.6F))); - EntityType BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, ButterflyEntity::new).size(EntityDimensions.fixed(1, 1))); + EntityType BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, ButterflyEntity::new) + .size(EntityDimensions.fixed(1, 1))); - EntityType THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.create(EntityCategory.MISC, ProjectileEntity::new).trackable(100, 2)); - EntityType THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpearEntity::new).trackable(100, 2)); + EntityType THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.create(EntityCategory.MISC, ProjectileEntity::new) + .trackable(100, 2) + .size(EntityDimensions.fixed(0.25F, 0.25F))); + EntityType THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpearEntity::new) + .trackable(100, 2) + .size(EntityDimensions.fixed(0.6F, 0.6F))); static EntityType register(String name, FabricEntityTypeBuilder builder) { return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), builder.build());