Search in sources :

Example 1 with ThrasherEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity in project upgrade-aquatic by team-abnormals.

the class RenderOverlays method renderScuteOverAir.

@SubscribeEvent
public static void renderScuteOverAir(RenderGameOverlayEvent.Pre event) {
    if (event.getType() == RenderGameOverlayEvent.ElementType.AIR) {
        int scaledWidth = MC.getMainWindow().getScaledWidth();
        int scaledHeight = MC.getMainWindow().getScaledHeight();
        ClientPlayerEntity player = MC.player;
        boolean inWater = player.areEyesInFluid(FluidTags.WATER);
        if (inWater) {
            ItemStack turtleHelmet = ItemStack.EMPTY;
            for (ItemStack stack : player.getArmorInventoryList()) {
                if (stack.getItem() == Items.TURTLE_HELMET) {
                    turtleHelmet = stack;
                }
            }
            if (!turtleHelmet.isEmpty()) {
                event.setCanceled(true);
                MatrixStack stack = event.getMatrixStack();
                stack.push();
                RenderSystem.enableBlend();
                int left = scaledWidth / 2 + 91;
                int top = scaledHeight - ForgeIngameGui.right_height;
                int durability = turtleHelmet.getDamage();
                int maxDurability = turtleHelmet.getMaxDamage();
                MC.textureManager.bindTexture(new ResourceLocation(UpgradeAquatic.MODID, "textures/gui/overlay/scute_bubble_depleted.png"));
                for (int i = 0; i < 10; i++) {
                    int l = left - (i * 8) - 9;
                    int l2 = l + 9;
                    int t = top;
                    int t2 = t + 9;
                    Tessellator tessellator = Tessellator.getInstance();
                    BufferBuilder bufferbuilder = tessellator.getBuffer();
                    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
                    bufferbuilder.pos(l, t2, 0).tex(0, 1).endVertex();
                    bufferbuilder.pos(l2, t2, 0).tex(1, 1).endVertex();
                    bufferbuilder.pos(l2, t, 0).tex(1, 0).endVertex();
                    bufferbuilder.pos(l, t, 0).tex(0, 0).endVertex();
                    tessellator.draw();
                }
                MC.textureManager.bindTexture(new ResourceLocation(UpgradeAquatic.MODID, "textures/gui/overlay/scute_bubble.png"));
                double amount = MathHelper.clamp(10 - Math.floor((double) durability / maxDurability * 10.0), 1, 10);
                for (int i = 0; i < amount; i++) {
                    int l = left - (i * 8) - 9;
                    int l2 = l + 9;
                    int t = top;
                    int t2 = t + 9;
                    Tessellator tessellator = Tessellator.getInstance();
                    BufferBuilder bufferbuilder = tessellator.getBuffer();
                    bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
                    bufferbuilder.pos(l, t2, 0).tex(0, 1).endVertex();
                    bufferbuilder.pos(l2, t2, 0).tex(1, 1).endVertex();
                    bufferbuilder.pos(l2, t, 0).tex(1, 0).endVertex();
                    bufferbuilder.pos(l, t, 0).tex(0, 0).endVertex();
                    tessellator.draw();
                }
                ForgeIngameGui.right_height += 10;
                RenderSystem.disableBlend();
                stack.pop();
            }
        }
    }
    if (event.getType() == ElementType.TEXT && MC.player.isPassenger() && MC.player.getRidingEntity() instanceof ThrasherEntity && MC.ingameGUI.overlayMessage.getString().equals(I18n.format("mount.onboard", I18n.format("key.keyboard.left.shift")))) {
        MC.ingameGUI.setOverlayMessage(new StringTextComponent(""), false);
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) ThrasherEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity) ResourceLocation(net.minecraft.util.ResourceLocation) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) StringTextComponent(net.minecraft.util.text.StringTextComponent) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with ThrasherEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity in project upgrade-aquatic by team-abnormals.

the class ClientEvents method onEntityRenderPre.

@SubscribeEvent
public static void onEntityRenderPre(RenderLivingEvent.Pre<?, ?> event) {
    if (event.getEntity() instanceof ClientPlayerEntity) {
        ClientPlayerEntity clientPlayer = (ClientPlayerEntity) event.getEntity();
        if (clientPlayer.getRidingEntity() instanceof ThrasherEntity) {
            ThrasherEntity thrasher = (ThrasherEntity) clientPlayer.getRidingEntity();
            ObfuscationReflectionHelper.setPrivateValue(LivingEntity.class, clientPlayer, 1.0F, "field_205017_bL");
            ObfuscationReflectionHelper.setPrivateValue(LivingEntity.class, clientPlayer, 1.0F, "field_205018_bM");
            clientPlayer.rotationPitch = 0.0F;
            clientPlayer.rotationYaw = thrasher.rotationYaw + (90.0F % 360);
            clientPlayer.renderYawOffset = thrasher.renderYawOffset + (90.0F % 360);
        }
    }
}
Also used : ThrasherEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with ThrasherEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity in project upgrade-aquatic by team-abnormals.

the class ClientEvents method onPlayerRenderPre.

@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onPlayerRenderPre(RenderPlayerEvent.Pre event) {
    MatrixStack stack = event.getMatrixStack();
    stack.push();
    if (event.getEntityLiving().getRidingEntity() instanceof ThrasherEntity) {
        ThrasherEntity thrasher = (ThrasherEntity) event.getEntityLiving().getRidingEntity();
        double dx = Math.cos((MathHelper.lerp(event.getPartialRenderTick(), thrasher.prevRotationYaw, thrasher.rotationYaw)) * Math.PI / 180.0D);
        double dz = Math.sin((MathHelper.lerp(event.getPartialRenderTick(), thrasher.prevRotationYaw, thrasher.rotationYaw)) * Math.PI / 180.0D);
        stack.translate((float) dx, 0.0F, (float) dz);
    }
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) ThrasherEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 4 with ThrasherEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity in project upgrade-aquatic by team-abnormals.

the class EntityEvents method onPlayerMount.

@SubscribeEvent
public static void onPlayerMount(EntityMountEvent event) {
    Entity mountingEntity = event.getEntityMounting();
    Entity entityBeingMounted = event.getEntityBeingMounted();
    if (mountingEntity instanceof PlayerEntity && entityBeingMounted instanceof ThrasherEntity) {
        PlayerEntity player = (PlayerEntity) mountingEntity;
        ThrasherEntity thrasher = (ThrasherEntity) entityBeingMounted;
        if (event.isDismounting() && player.isAlive() && !player.isCreative() && !player.isSpectator() && thrasher.isAlive()) {
            event.setCanceled(true);
        }
    }
}
Also used : PikeEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity) DolphinEntity(net.minecraft.entity.passive.DolphinEntity) PhantomEntity(net.minecraft.entity.monster.PhantomEntity) WaterMobEntity(net.minecraft.entity.passive.WaterMobEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ThrasherEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity) SquidEntity(net.minecraft.entity.passive.SquidEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) AbstractFishEntity(net.minecraft.entity.passive.fish.AbstractFishEntity) LionfishEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.LionfishEntity) DrownedEntity(net.minecraft.entity.monster.DrownedEntity) CreatureEntity(net.minecraft.entity.CreatureEntity) TurtleEntity(net.minecraft.entity.passive.TurtleEntity) TropicalFishEntity(net.minecraft.entity.passive.fish.TropicalFishEntity) MobEntity(net.minecraft.entity.MobEntity) Entity(net.minecraft.entity.Entity) ThrasherEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 5 with ThrasherEntity

use of com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity in project upgrade-aquatic by team-abnormals.

the class NautilusEntity method registerGoals.

@Override
protected void registerGoals() {
    this.goalSelector.addGoal(0, new PanicGoal(this, 1.65D));
    this.goalSelector.addGoal(2, new AvoidEntityGoal<PlayerEntity>(this, PlayerEntity.class, 9.0F, 1.5D, 1.2D, EntityPredicates.NOT_SPECTATING::test) {

        @Override
        public void startExecuting() {
            ((NautilusEntity) this.entity).setFleeing(true);
            super.startExecuting();
        }

        @Override
        public void resetTask() {
            ((NautilusEntity) this.entity).setFleeing(false);
            super.resetTask();
        }
    });
    this.goalSelector.addGoal(2, new AvoidEntityGoal<SquidEntity>(this, SquidEntity.class, 9.0F, 1.5D, 1.2D, EntityPredicates.NOT_SPECTATING::test) {

        @Override
        public void startExecuting() {
            ((NautilusEntity) this.entity).setFleeing(true);
            super.startExecuting();
        }

        @Override
        public void resetTask() {
            ((NautilusEntity) this.entity).setFleeing(false);
            super.resetTask();
        }
    });
    this.goalSelector.addGoal(2, new AvoidEntityGoal<ThrasherEntity>(this, ThrasherEntity.class, 9.0F, 1.5D, 1.2D, EntityPredicates.NOT_SPECTATING::test) {

        @Override
        public void startExecuting() {
            ((NautilusEntity) this.entity).setFleeing(true);
            super.startExecuting();
        }

        @Override
        public void resetTask() {
            ((NautilusEntity) this.entity).setFleeing(false);
            super.resetTask();
        }
    });
    this.goalSelector.addGoal(4, new NautilusEntity.SwimGoal(this));
}
Also used : SquidEntity(net.minecraft.entity.passive.SquidEntity) EntityPredicates(net.minecraft.util.EntityPredicates) ThrasherEntity(com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity) PanicGoal(net.minecraft.entity.ai.goal.PanicGoal) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

ThrasherEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.thrasher.ThrasherEntity)5 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)4 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)2 SquidEntity (net.minecraft.entity.passive.SquidEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 LionfishEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.LionfishEntity)1 PikeEntity (com.minecraftabnormals.upgrade_aquatic.common.entities.pike.PikeEntity)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 CreatureEntity (net.minecraft.entity.CreatureEntity)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 MobEntity (net.minecraft.entity.MobEntity)1 PanicGoal (net.minecraft.entity.ai.goal.PanicGoal)1 DrownedEntity (net.minecraft.entity.monster.DrownedEntity)1 PhantomEntity (net.minecraft.entity.monster.PhantomEntity)1 DolphinEntity (net.minecraft.entity.passive.DolphinEntity)1 TurtleEntity (net.minecraft.entity.passive.TurtleEntity)1 WaterMobEntity (net.minecraft.entity.passive.WaterMobEntity)1