mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Fixed clouds, mostly
This commit is contained in:
parent
2db782422b
commit
b5aca42ba6
5 changed files with 88 additions and 55 deletions
|
@ -26,14 +26,14 @@ public class CloudEntityRenderer extends MobEntityRenderer<CloudEntity, CloudEnt
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(CloudEntity entity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
|
||||
public void render(CloudEntity entity, float f, float g, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int i) {
|
||||
|
||||
if (entity.removed) {
|
||||
return;
|
||||
}
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.translate(0, -entity.getHeight()/entity.getCloudSize() + 0.3F, 0);
|
||||
matrices.push();
|
||||
matrices.translate(0, -entity.getHeight() + 0.3F, 0);
|
||||
|
||||
//GlStateManager.disableLighting();
|
||||
//GlStateManager.enableBlend();
|
||||
|
@ -44,13 +44,13 @@ public class CloudEntityRenderer extends MobEntityRenderer<CloudEntity, CloudEnt
|
|||
|
||||
//GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
super.render(entity, f, g, matrixStack, vertexConsumerProvider, i);
|
||||
super.render(entity, f, g, matrices, vertexConsumerProvider, i);
|
||||
|
||||
//GlStateManager.disableBlend();
|
||||
//GlStateManager.enableLighting();
|
||||
//GlStateManager.color4f(1, 1, 1, 1);
|
||||
|
||||
matrixStack.pop();
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,7 @@ public final class RenderLayers extends RenderLayer {
|
|||
super(name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent, startAction, endAction);
|
||||
}
|
||||
|
||||
private static final RenderLayer MAGIC = RenderLayer.of("mlp_magic_glow", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, 7, 256, RenderLayer.MultiPhaseParameters.builder()
|
||||
private static final RenderLayer MAGIC = of("mlp_magic_glow", VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, 7, 256, RenderLayer.MultiPhaseParameters.builder()
|
||||
.texture(NO_TEXTURE)
|
||||
.writeMaskState(COLOR_MASK)
|
||||
.transparency(LIGHTNING_TRANSPARENCY)
|
||||
|
@ -22,26 +22,26 @@ public final class RenderLayers extends RenderLayer {
|
|||
.build(false));
|
||||
|
||||
public static RenderLayer entityNoLighting(Identifier tex) {
|
||||
return RenderLayer.of("entity_cutout_no_cull_no_lighting", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, false, RenderLayer.MultiPhaseParameters.builder()
|
||||
return of("entity_cutout_no_cull_no_lighting", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, false, RenderLayer.MultiPhaseParameters.builder()
|
||||
.texture(new RenderPhase.Texture(tex, false, false))
|
||||
.transparency(RenderLayer.NO_TRANSPARENCY)
|
||||
.diffuseLighting(RenderLayer.ENABLE_DIFFUSE_LIGHTING)
|
||||
.alpha(RenderLayer.ONE_TENTH_ALPHA)
|
||||
.cull(RenderLayer.DISABLE_CULLING)
|
||||
.lightmap(RenderLayer.DISABLE_LIGHTMAP)
|
||||
.overlay(RenderLayer.ENABLE_OVERLAY_COLOR)
|
||||
.transparency(NO_TRANSPARENCY)
|
||||
.diffuseLighting(ENABLE_DIFFUSE_LIGHTING)
|
||||
.alpha(ONE_TENTH_ALPHA)
|
||||
.cull(DISABLE_CULLING)
|
||||
.lightmap(DISABLE_LIGHTMAP)
|
||||
.overlay(ENABLE_OVERLAY_COLOR)
|
||||
.build(true));
|
||||
}
|
||||
|
||||
public static RenderLayer cloud(Identifier tex) {
|
||||
return RenderLayer.of("cloud", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, false, RenderLayer.MultiPhaseParameters.builder()
|
||||
return of("cloud", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, false, RenderLayer.MultiPhaseParameters.builder()
|
||||
.texture(new RenderPhase.Texture(tex, false, false))
|
||||
.transparency(RenderLayer.TRANSLUCENT_TRANSPARENCY)
|
||||
.diffuseLighting(RenderLayer.ENABLE_DIFFUSE_LIGHTING)
|
||||
.alpha(RenderLayer.ONE_TENTH_ALPHA)
|
||||
.cull(RenderLayer.DISABLE_CULLING)
|
||||
.lightmap(RenderLayer.DISABLE_LIGHTMAP)
|
||||
.overlay(RenderLayer.ENABLE_OVERLAY_COLOR)
|
||||
.transparency(TRANSLUCENT_TRANSPARENCY)
|
||||
.diffuseLighting(ENABLE_DIFFUSE_LIGHTING)
|
||||
.alpha(ONE_TENTH_ALPHA)
|
||||
.lightmap(DISABLE_LIGHTMAP)
|
||||
.overlay(DISABLE_OVERLAY_COLOR)
|
||||
.cull(DISABLE_CULLING)
|
||||
.build(true));
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
|
|||
|
||||
private static final TrackedData<Boolean> 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<? extends CloudEntity> 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);
|
||||
|
||||
|
@ -684,14 +690,18 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
|
|||
return dataTracker.get(SCALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScaleFactor() {
|
||||
return getCloudSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDimensions getDimensions(EntityPose pose) {
|
||||
return super.getDimensions(pose).scaled(getCloudSize());
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -18,21 +18,34 @@ import net.minecraft.world.biome.PlainsBiome;
|
|||
import net.minecraft.world.biome.RiverBiome;
|
||||
|
||||
public interface UEntities {
|
||||
EntityType<SpellbookEntity> SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellbookEntity::new).size(EntityDimensions.changing(0.6f, 0.6f)));
|
||||
EntityType<SpellcastEntity> MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellcastEntity::new).size(EntityDimensions.changing(0.6F, 0.25F)));
|
||||
EntityType<CloudEntity> CLOUD = register("cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, CloudEntity::new));
|
||||
EntityType<WildCloudEntity> WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, WildCloudEntity::new));
|
||||
EntityType<RacingCloudEntity> RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, RacingCloudEntity::new));
|
||||
EntityType<ConstructionCloudEntity> CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, ConstructionCloudEntity::new));
|
||||
EntityType<SpellbookEntity> SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellbookEntity::new)
|
||||
.size(EntityDimensions.changing(0.6F, 0.6F)));
|
||||
EntityType<SpellcastEntity> MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellcastEntity::new)
|
||||
.size(EntityDimensions.changing(0.6F, 0.25F)));
|
||||
EntityType<CloudEntity> CLOUD = register("cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, CloudEntity::new)
|
||||
.size(CloudEntity.BASE_DIMENSIONS));
|
||||
EntityType<WildCloudEntity> WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, WildCloudEntity::new)
|
||||
.size(CloudEntity.BASE_DIMENSIONS));
|
||||
EntityType<RacingCloudEntity> RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, RacingCloudEntity::new)
|
||||
.size(CloudEntity.BASE_DIMENSIONS));
|
||||
EntityType<ConstructionCloudEntity> CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, ConstructionCloudEntity::new)
|
||||
.size(CloudEntity.BASE_DIMENSIONS));
|
||||
|
||||
EntityType<RainbowEntity> RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, RainbowEntity::new));
|
||||
EntityType<RainbowEntity> RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, RainbowEntity::new)
|
||||
.size(EntityDimensions.fixed(1, 1)));
|
||||
|
||||
EntityType<CuccoonEntity> CUCCOON = register("cuccoon", FabricEntityTypeBuilder.create(EntityCategory.MISC, CuccoonEntity::new).size(EntityDimensions.changing(1.5F, 1.6F)));
|
||||
EntityType<CuccoonEntity> CUCCOON = register("cuccoon", FabricEntityTypeBuilder.create(EntityCategory.MISC, CuccoonEntity::new)
|
||||
.size(EntityDimensions.changing(1.5F, 1.6F)));
|
||||
|
||||
EntityType<ButterflyEntity> BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, ButterflyEntity::new).size(EntityDimensions.fixed(1, 1)));
|
||||
EntityType<ButterflyEntity> BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, ButterflyEntity::new)
|
||||
.size(EntityDimensions.fixed(1, 1)));
|
||||
|
||||
EntityType<ProjectileEntity> THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.<ProjectileEntity>create(EntityCategory.MISC, ProjectileEntity::new).trackable(100, 2));
|
||||
EntityType<SpearEntity> THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.<SpearEntity>create(EntityCategory.MISC, SpearEntity::new).trackable(100, 2));
|
||||
EntityType<ProjectileEntity> THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.<ProjectileEntity>create(EntityCategory.MISC, ProjectileEntity::new)
|
||||
.trackable(100, 2)
|
||||
.size(EntityDimensions.fixed(0.25F, 0.25F)));
|
||||
EntityType<SpearEntity> THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.<SpearEntity>create(EntityCategory.MISC, SpearEntity::new)
|
||||
.trackable(100, 2)
|
||||
.size(EntityDimensions.fixed(0.6F, 0.6F)));
|
||||
|
||||
static <T extends Entity> EntityType<T> register(String name, FabricEntityTypeBuilder<T> builder) {
|
||||
return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), builder.build());
|
||||
|
|
Loading…
Reference in a new issue