Skip to content

Commit

Permalink
add mobiliburst render
Browse files Browse the repository at this point in the history
  • Loading branch information
IAFEnvoy committed Jan 18, 2025
1 parent e5c09d6 commit 654fa10
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 128 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.iafenvoy.sow.mixin;

import com.iafenvoy.sow.render.power.feature.MobiliBurstFeatureRenderer;
import com.iafenvoy.sow.render.power.feature.MobiliumElytraFeatureRenderer;
import com.iafenvoy.sow.render.power.feature.MobiliWingsFeatureRenderer;
import com.iafenvoy.sow.render.power.feature.ProteArmorFeatureRenderer;
import com.iafenvoy.sow.render.power.feature.ProteSphereFeatureRenderer;
import net.fabricmc.api.EnvType;
Expand All @@ -28,7 +28,7 @@ public PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntity
@Inject(method = "<init>", at = @At("RETURN"))
private void addCustomRenderer(EntityRendererFactory.Context ctx, boolean slim, CallbackInfo ci) {
this.addFeature(new MobiliBurstFeatureRenderer<>(this));
this.addFeature(new MobiliumElytraFeatureRenderer<>(this, ctx.getModelLoader()));
this.addFeature(new MobiliWingsFeatureRenderer<>(this, ctx.getModelLoader()));
this.addFeature(new ProteSphereFeatureRenderer<>(this));
this.addFeature(new ProteArmorFeatureRenderer<>(this, new ArmorEntityModel<>(ctx.getPart(slim ? EntityModelLayers.PLAYER_SLIM_INNER_ARMOR : EntityModelLayers.PLAYER_INNER_ARMOR))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
@Environment(EnvType.CLIENT)
public class ClientPowerEvents {
public static final Event<PowerStateChange> POWER_ENABLE = EventFactory.of(callbacks -> (player, songPower) -> callbacks.forEach(x -> x.onChange(player, songPower)));
//Note: Disable only invoke for persist song power
public static final Event<PowerStateChange> POWER_DISABLE = EventFactory.of(callbacks -> (player, songPower) -> callbacks.forEach(x -> x.onChange(player, songPower)));

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.iafenvoy.sow.power.component;

import com.iafenvoy.sow.power.SongPowerData;
import com.iafenvoy.sow.registry.power.MobiliumPowers;
import com.iafenvoy.sow.util.Serializable;
import com.iafenvoy.sow.util.SowMath;
import com.iafenvoy.sow.util.Tickable;
Expand Down Expand Up @@ -55,7 +56,7 @@ public void tick() {
if (this.player.getVelocity().length() <= 0.1) this.tick = 0;
else {
Vec3d pos = this.player.getPos();
double r = 1;
double r = 1.5;
List<Entity> entities = this.player.getWorld().getOtherEntities(this.player, new Box(pos.add(new Vec3d(r, r, r)), pos.subtract(new Vec3d(r, r, r))), entity -> true);
entities.forEach(entity -> {
Vec3d dir = entity.getPos().subtract(this.player.getPos()).add(this.player.getVelocity());
Expand All @@ -68,6 +69,7 @@ public void tick() {
if (this.tick == 0) {
this.activate = false;
SongPowerData.byPlayer(this.player).removeComponent(ID);
MobiliumPowers.MOBILIBURST.sendApplyMessage(this.player, false);
}
this.tick--;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.iafenvoy.sow.render.power;

import com.iafenvoy.sow.power.ClientPowerEvents;
import com.iafenvoy.sow.registry.power.MobiliumPowers;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.player.PlayerEntity;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

@Environment(EnvType.CLIENT)
public class PowerAnimationManager {
private static final Set<UUID> MOBILIBURST_RENDER = new HashSet<>();

public static boolean enableMobiliburst(PlayerEntity player) {
return MOBILIBURST_RENDER.contains(player.getUuid());
}

static {
ClientPowerEvents.POWER_ENABLE.register((player, songPower) -> {
if (songPower == MobiliumPowers.MOBILIBURST)
MOBILIBURST_RENDER.add(player.getUuid());
});
ClientPowerEvents.POWER_DISABLE.register((player, songPower) -> {
if (songPower == MobiliumPowers.MOBILIBURST)
MOBILIBURST_RENDER.remove(player.getUuid());
});
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.iafenvoy.sow.render.power.feature;

import com.iafenvoy.sow.SongsOfWar;
import com.iafenvoy.sow.power.SongPowerData;
import com.iafenvoy.sow.registry.power.MobiliumPowers;
import com.iafenvoy.sow.render.RenderConstants;
import com.iafenvoy.sow.render.power.PowerAnimationManager;
import com.iafenvoy.sow.render.power.test.MobiliBurstModel;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
Expand All @@ -12,10 +11,8 @@
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

public class MobiliBurstFeatureRenderer<T extends PlayerEntity, M extends PlayerEntityModel<T>> extends FeatureRenderer<T, M> {
private static final Identifier TEXTURE = Identifier.of(SongsOfWar.MOD_ID, "textures/block/mobilibounce_platform.png");
private final MobiliBurstModel<T> model;
private float alpha = 0;

Expand All @@ -27,11 +24,10 @@ public MobiliBurstFeatureRenderer(FeatureRendererContext<T, M> context) {
@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
matrices.push();
if (SongPowerData.byPlayer(entity).powerEnabled(MobiliumPowers.MOBILIBURST))
this.alpha += 0.05f;
if (PowerAnimationManager.enableMobiliburst(entity)) this.alpha += 0.005f;
else this.alpha = 0;
if (this.alpha > 0)
this.model.render(matrices, vertexConsumers.getBuffer(RenderLayer.getEntityTranslucentEmissive(TEXTURE)), light, OverlayTexture.DEFAULT_UV, 1, 1, 1, Math.min(this.alpha, 1));
this.model.render(matrices, vertexConsumers.getBuffer(RenderLayer.getEntityTranslucentEmissive(RenderConstants.WHITE_TEXTURE)), light, OverlayTexture.DEFAULT_UV, 1, 1, 0, Math.min(this.alpha, 0.1f));
matrices.pop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import net.minecraft.util.Identifier;

@Environment(EnvType.CLIENT)
public class MobiliumElytraFeatureRenderer<T extends PlayerEntity, M extends PlayerEntityModel<T>> extends FeatureRenderer<T, M> {
public class MobiliWingsFeatureRenderer<T extends PlayerEntity, M extends PlayerEntityModel<T>> extends FeatureRenderer<T, M> {
private static final Identifier TEXTURE = Identifier.of(SongsOfWar.MOD_ID, "textures/entity/elytra.png");
private final ElytraEntityModel<T> elytra;

public MobiliumElytraFeatureRenderer(FeatureRendererContext<T, M> context, EntityModelLoader loader) {
public MobiliWingsFeatureRenderer(FeatureRendererContext<T, M> context, EntityModelLoader loader) {
super(context);
this.elytra = new ElytraEntityModel<>(loader.getModelPart(EntityModelLayers.ELYTRA));
}
Expand Down
Loading

0 comments on commit 654fa10

Please sign in to comment.