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);
}
}
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);
}
}
}
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);
}
}
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);
}
}
}
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));
}
Aggregations