mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Added air balloons (wip)
This commit is contained in:
parent
0b8afe4994
commit
2e472a7982
5 changed files with 194 additions and 5 deletions
|
@ -13,11 +13,7 @@ import com.minelittlepony.unicopia.client.particle.RaindropsParticle;
|
|||
import com.minelittlepony.unicopia.client.particle.RunesParticle;
|
||||
import com.minelittlepony.unicopia.client.particle.SphereParticle;
|
||||
import com.minelittlepony.unicopia.client.render.*;
|
||||
import com.minelittlepony.unicopia.client.render.entity.ButterflyEntityRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.entity.CastSpellEntityRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.entity.FairyEntityRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.entity.MagicBeamEntityRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.entity.SpellbookEntityRenderer;
|
||||
import com.minelittlepony.unicopia.client.render.entity.*;
|
||||
import com.minelittlepony.unicopia.entity.UEntities;
|
||||
import com.minelittlepony.unicopia.item.ChameleonItem;
|
||||
import com.minelittlepony.unicopia.item.GemstoneItem;
|
||||
|
@ -75,6 +71,7 @@ public interface URenderers {
|
|||
EntityRendererRegistry.register(UEntities.CAST_SPELL, CastSpellEntityRenderer::new);
|
||||
EntityRendererRegistry.register(UEntities.TWITTERMITE, FairyEntityRenderer::new);
|
||||
EntityRendererRegistry.register(UEntities.SPELLBOOK, SpellbookEntityRenderer::new);
|
||||
EntityRendererRegistry.register(UEntities.AIR_BALLOON, AirBalloonEntityRenderer::new);
|
||||
|
||||
ColorProviderRegistry.ITEM.register((stack, i) -> i > 0 ? -1 : ((DyeableItem)stack.getItem()).getColor(stack), UItems.FRIENDSHIP_BRACELET);
|
||||
BuiltinItemRendererRegistry.INSTANCE.register(UItems.FILLED_JAR, (stack, mode, matrices, vertexConsumers, light, overlay) -> {
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package com.minelittlepony.unicopia.client.render.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.AirBalloonEntity;
|
||||
|
||||
import net.minecraft.client.model.*;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
public class AirBalloonEntityModel extends EntityModel<AirBalloonEntity> {
|
||||
|
||||
private final ModelPart root;
|
||||
|
||||
private final ModelPart burner;
|
||||
private final ModelPart balloon;
|
||||
private final ModelPart basket;
|
||||
|
||||
public AirBalloonEntityModel(ModelPart root) {
|
||||
this.root = root;
|
||||
burner = root.getChild("burner");
|
||||
balloon = root.getChild("balloon");
|
||||
basket = root.getChild("basket");
|
||||
}
|
||||
|
||||
public static TexturedModelData getTexturedModelData() {
|
||||
ModelData modelData = new ModelData();
|
||||
ModelPartData root = modelData.getRoot();
|
||||
|
||||
ModelPartData burner = root.addChild("burner", ModelPartBuilder.create().uv(8, 107).cuboid(-6, -47, -6, 11, 15, 11, Dilation.NONE), ModelTransform.pivot(0, 24, 0));
|
||||
burner.addChild("rope_d_r1", ModelPartBuilder.create().uv(0, 107).cuboid(-2, -68, 0, 2, 68, 2, Dilation.NONE), ModelTransform.of(-5, -46, -6, 0.7854F, 0, -0.7854F));
|
||||
burner.addChild("rope_c_r1", ModelPartBuilder.create().uv(0, 107).cuboid(-2, -68, 0, 2, 68, 2, Dilation.NONE), ModelTransform.of(-4, -44, 3, -0.7854F, 0, -0.7854F));
|
||||
burner.addChild("rope_b_r1", ModelPartBuilder.create().uv(0, 107).cuboid(-2, -68, 0, 2, 68, 2, Dilation.NONE), ModelTransform.of(5, -46, 1, -0.7854F, 0, 0.7854F));
|
||||
burner.addChild("rope_a_r1", ModelPartBuilder.create().uv(0, 107).cuboid(-2, -68, 0, 2, 68, 2, Dilation.NONE), ModelTransform.of(5, -45, -6, 0.7854F, 0, 0.7854F));
|
||||
|
||||
ModelPartData balloon = root.addChild("balloon", ModelPartBuilder.create().uv(64, 1).cuboid(-54, -178, -59, 112, 120, 112, Dilation.NONE), ModelTransform.pivot(0, 24, 0));
|
||||
balloon.addChild("rope_d_r2", ModelPartBuilder.create().uv(0, 107).cuboid(-2, -68, 0, 2, 68, 2, Dilation.NONE), ModelTransform.of(-14, -11, -16, 0.4363F, 0, -0.4363F));
|
||||
balloon.addChild("rope_c_r2", ModelPartBuilder.create().uv(0, 107).cuboid(-2, -68, 0, 2, 68, 2, Dilation.NONE), ModelTransform.of(-14, -11, 11, -0.4363F, 0, -0.4363F));
|
||||
balloon.addChild("rope_b_r2", ModelPartBuilder.create().uv(0, 107).cuboid(-2, -68, 0, 2, 68, 2, Dilation.NONE), ModelTransform.of(17, -11, 11, -0.4363F, 0, 0.4363F));
|
||||
balloon.addChild("rope_a_r2", ModelPartBuilder.create().uv(0, 107).cuboid(-2, -68, 0, 2, 68, 2, Dilation.NONE), ModelTransform.of(17, -11, -16, 0.4363F, 0, 0.4363F));
|
||||
|
||||
ModelPartData basket = root.addChild("basket", ModelPartBuilder.create().uv(0, 0).cuboid(-16, -1, -16, 32, 2, 30, Dilation.NONE), ModelTransform.pivot(0, 24, 0));
|
||||
basket.addChild("walls", ModelPartBuilder.create().uv(0, 66).cuboid(-17, -12, -16, 2, 11, 30, Dilation.NONE)
|
||||
.uv(64, 68).cuboid(15, -12, -16, 2, 11, 30, Dilation.NONE)
|
||||
.uv(80, 38).cuboid(-16, -12, -17, 32, 11, 2, Dilation.NONE)
|
||||
.uv(0, 32).cuboid(8, -12, 13, 8, 11, 2, Dilation.NONE)
|
||||
.uv(0, 6).cuboid(-16, -12, 13, 8, 11, 2, Dilation.NONE), ModelTransform.pivot(0, 0, 0));
|
||||
basket.addChild("rim", ModelPartBuilder.create().uv(40, 34).cuboid(-18, -13, -17, 4, 2, 32, Dilation.NONE)
|
||||
.uv(0, 32).cuboid(14, -13, -17, 4, 2, 32, Dilation.NONE)
|
||||
.uv(80, 32).cuboid(-17, -13, -18, 34, 2, 4, Dilation.NONE)
|
||||
.uv(0, 19).cuboid(7, -13, 12, 10, 2, 4, Dilation.NONE)
|
||||
.uv(0, 0).cuboid(-17, -13, 12, 10, 2, 4, Dilation.NONE), ModelTransform.pivot(0, 0, 0));
|
||||
return TexturedModelData.of(modelData, 512, 512);
|
||||
}
|
||||
@Override
|
||||
public void setAngles(AirBalloonEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float r, float g, float b, float a) {
|
||||
root.render(matrices, vertexConsumer, light, overlay, r, g, b, a);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.minelittlepony.unicopia.client.render.entity;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.entity.AirBalloonEntity;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class AirBalloonEntityRenderer extends LivingEntityRenderer<AirBalloonEntity, AirBalloonEntityModel> {
|
||||
private static final Identifier TEXTURE = Unicopia.id("textures/entity/spellbook/normal.png");
|
||||
|
||||
public AirBalloonEntityRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, new AirBalloonEntityModel(AirBalloonEntityModel.getTexturedModelData().createModel()), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(AirBalloonEntity entity) {
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getLyingAngle(AirBalloonEntity entity) {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.minelittlepony.unicopia.entity;
|
||||
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.mob.FlyingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AirBalloonEntity extends FlyingEntity {
|
||||
|
||||
public AirBalloonEntity(EntityType<? extends AirBalloonEntity> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataTracker() {
|
||||
super.initDataTracker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
if (!world.isClient) {
|
||||
|
||||
float xSpeed = 0;//-0.015F * (this.age % 1000 < 500 ? -1 : 1);
|
||||
|
||||
addVelocity(xSpeed, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
for (var e : this.world.getOtherEntities(this, getBoundingBox().expand(0.2, 1.0E-7, 0.2))) {
|
||||
if (!(e instanceof PlayerEntity)) {
|
||||
e.setVelocity(e.getVelocity().multiply(0.3).add(getVelocity().multiply(0.84)));
|
||||
|
||||
double diff = (getBoundingBox().maxY + getVelocity().y) - e.getBoundingBox().minY;
|
||||
|
||||
if (diff > 0) {
|
||||
e.addVelocity(0, diff, 0);
|
||||
}
|
||||
}
|
||||
|
||||
e.distanceTraveled = 0;
|
||||
e.horizontalSpeed = 0;
|
||||
if (e instanceof LivingEntity l) {
|
||||
l.limbAngle = 0;
|
||||
l.limbDistance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.tick();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerCollision(PlayerEntity player) {
|
||||
player.setVelocity(player.getVelocity().multiply(0.9).add(getVelocity().multiply(0.56)));
|
||||
|
||||
double diff = (getBoundingBox().maxY + getVelocity().y) - player.getBoundingBox().minY;
|
||||
|
||||
if (diff > 0) {
|
||||
player.addVelocity(0, diff, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushAwayFrom(Entity entity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushAway(Entity entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Box getVisibilityBoundingBox() {
|
||||
return getBoundingBox().expand(30, 100, 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomDataFromNbt(NbtCompound compound) {
|
||||
super.readCustomDataFromNbt(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomDataToNbt(NbtCompound compound) {
|
||||
super.writeCustomDataToNbt(compound);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.EntityDimensions;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.entity.mob.FlyingEntity;
|
||||
import net.minecraft.tag.BiomeTags;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
@ -46,6 +47,9 @@ public interface UEntities {
|
|||
EntityType<SpellbookEntity> SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(SpawnGroup.MISC, SpellbookEntity::new)
|
||||
.trackRangeBlocks(200)
|
||||
.dimensions(EntityDimensions.fixed(0.9F, 0.5F)));
|
||||
EntityType<AirBalloonEntity> AIR_BALLOON = register("air_balloon", FabricEntityTypeBuilder.create(SpawnGroup.MISC, AirBalloonEntity::new)
|
||||
.trackRangeBlocks(1000)
|
||||
.dimensions(EntityDimensions.fixed(3, 0.1F)));
|
||||
|
||||
static <T extends Entity> EntityType<T> register(String name, FabricEntityTypeBuilder<T> builder) {
|
||||
EntityType<T> type = builder.build();
|
||||
|
@ -56,6 +60,7 @@ public interface UEntities {
|
|||
FabricDefaultAttributeRegistry.register(BUTTERFLY, ButterflyEntity.createButterflyAttributes());
|
||||
FabricDefaultAttributeRegistry.register(SPELLBOOK, SpellbookEntity.createMobAttributes());
|
||||
FabricDefaultAttributeRegistry.register(TWITTERMITE, FairyEntity.createMobAttributes());
|
||||
FabricDefaultAttributeRegistry.register(AIR_BALLOON, FlyingEntity.createMobAttributes());
|
||||
|
||||
final Predicate<BiomeSelectionContext> butterflySpawnable = BiomeSelectors.foundInOverworld()
|
||||
.and(ctx -> ctx.getBiome().getPrecipitation() == Biome.Precipitation.RAIN);
|
||||
|
|
Loading…
Reference in a new issue