Skip to content

Commit

Permalink
add new model, new events and sort classes
Browse files Browse the repository at this point in the history
  • Loading branch information
IAFEnvoy committed Jan 18, 2025
1 parent 49d43e3 commit e5c09d6
Show file tree
Hide file tree
Showing 30 changed files with 1,814 additions and 225 deletions.
1 change: 1 addition & 0 deletions common/src/main/java/com/iafenvoy/sow/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public final class Constants {
public static final Identifier BEACON_TELEPORT = Identifier.of(SongsOfWar.MOD_ID, "beacon_teleport");
public static final Identifier POWER_KEYBINDING_SYNC = Identifier.of(SongsOfWar.MOD_ID, "keybinding_sync");
public static final Identifier POWER_STATE_CHANGE = Identifier.of(SongsOfWar.MOD_ID, "power_state_change");
public static final Identifier JUMP_PRESS = Identifier.of(SongsOfWar.MOD_ID, "jump_press");
public static final UUID PROTESPHERE_UUID = UUID.fromString("babda2da-13e9-4096-baba-933bb695e319");
public static final UUID MOBILIGLIDE_UUID = UUID.fromString("3db28b1d-3fec-4a31-9f50-6c04f30e33f1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.iafenvoy.sow.network.ClientNetworkHelper;
import com.iafenvoy.sow.registry.SowKeybindings;
import com.iafenvoy.sow.registry.SowRenderers;
import com.iafenvoy.sow.render.util.GeneratorReloader;
import com.iafenvoy.sow.render.generator.GeneratorReloader;
import com.iafenvoy.sow.world.sound.ClientSongCubeSoundManager;
import dev.architectury.event.events.client.ClientTickEvent;
import dev.architectury.registry.ReloadListenerRegistry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.iafenvoy.sow.mixin;

import com.iafenvoy.sow.render.power.MobiliumElytraFeatureRenderer;
import com.iafenvoy.sow.render.power.ProteArmorFeatureRenderer;
import com.iafenvoy.sow.render.power.ProtisiumSphereFeatureRenderer;
import com.iafenvoy.sow.render.power.feature.MobiliBurstFeatureRenderer;
import com.iafenvoy.sow.render.power.feature.MobiliumElytraFeatureRenderer;
import com.iafenvoy.sow.render.power.feature.ProteArmorFeatureRenderer;
import com.iafenvoy.sow.render.power.feature.ProteSphereFeatureRenderer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.network.AbstractClientPlayerEntity;
Expand All @@ -26,8 +27,9 @@ 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 ProtisiumSphereFeatureRenderer<>(this));
this.addFeature(new ProteSphereFeatureRenderer<>(this));
this.addFeature(new ProteArmorFeatureRenderer<>(this, new ArmorEntityModel<>(ctx.getPart(slim ? EntityModelLayers.PLAYER_SLIM_INNER_ARMOR : EntityModelLayers.PLAYER_INNER_ARMOR))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@

import com.iafenvoy.sow.Constants;
import com.iafenvoy.sow.data.BeaconData;
import com.iafenvoy.sow.power.ClientPowerEvents;
import com.iafenvoy.sow.power.type.AbstractSongPower;
import com.iafenvoy.sow.screen.BeaconTeleportScreen;
import dev.architectury.networking.NetworkManager;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

@Environment(EnvType.CLIENT)
public class ClientNetworkHelper {
public static void init() {
NetworkManager.registerReceiver(NetworkManager.Side.S2C, Constants.BEACON_TELEPORT, (buf, context) -> {
BlockPos pos = buf.readBlockPos();
BeaconData data = BeaconData.readNbt(buf.readNbt());
context.queue(() -> MinecraftClient.getInstance().setScreen(new BeaconTeleportScreen(data, pos, 0)));
});
NetworkManager.registerReceiver(NetworkManager.Side.S2C, Constants.POWER_STATE_CHANGE, (buf, context) -> {
World world = MinecraftClient.getInstance().world;
assert world != null;
PlayerEntity player = world.getPlayerByUuid(buf.readUuid());
AbstractSongPower<?> power = AbstractSongPower.byId(buf.readString());
boolean enable = buf.readBoolean();
if (!power.isEmpty())
(enable ? ClientPowerEvents.POWER_ENABLE : ClientPowerEvents.POWER_DISABLE).invoker().onChange(player, power);
});
}
}
20 changes: 20 additions & 0 deletions common/src/main/java/com/iafenvoy/sow/power/ClientPowerEvents.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.iafenvoy.sow.power;

import com.iafenvoy.sow.power.type.AbstractSongPower;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.player.PlayerEntity;

@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
public interface PowerStateChange {
void onChange(PlayerEntity player, AbstractSongPower<?> songPower);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.iafenvoy.sow.power.type;

import com.iafenvoy.neptune.network.PacketBufferUtils;
import com.iafenvoy.neptune.object.SoundUtil;
import com.iafenvoy.sow.Constants;
import com.iafenvoy.sow.SongsOfWar;
import com.iafenvoy.sow.item.block.AbstractSongCubeBlock;
import com.iafenvoy.sow.power.PowerCategory;
import com.iafenvoy.sow.power.SongPowerData;
import com.iafenvoy.sow.power.SongPowerDataHolder;
import dev.architectury.networking.NetworkManager;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -143,10 +149,21 @@ public boolean isPersist() {
}

public boolean apply(SongPowerData.SinglePowerData data) {
return this.applyInternal(new SongPowerDataHolder(data));
boolean success = this.applyInternal(new SongPowerDataHolder(data));
if (success) this.sendApplyMessage(data.getPlayer(), true);
return success;
}

public void unapply(SongPowerData.SinglePowerData data) {
this.sendApplyMessage(data.getPlayer(), false);
}

public void sendApplyMessage(PlayerEntity player, boolean enable) {
if (player instanceof ServerPlayerEntity serverPlayer) {
PacketByteBuf buf = PacketBufferUtils.create();
buf.writeUuid(player.getUuid()).writeString(this.id).writeBoolean(enable);
NetworkManager.sendToPlayer(serverPlayer, Constants.POWER_STATE_CHANGE, buf);
}
}

public boolean isEmpty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void unapply(SongPowerData.SinglePowerData data) {
playSound(holder, this.unapplySound);
this.unapply.accept(holder);
holder.cooldown();
super.unapply(data);
}

public boolean tick(SongPowerData.SinglePowerData data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.iafenvoy.sow.render.block.WallsOfTimeBlockEntityRenderer;
import com.iafenvoy.sow.render.entity.ArdoniEntityRenderer;
import com.iafenvoy.sow.render.entity.MagnoriteEntityRenderer;
import com.iafenvoy.sow.render.power.*;
import com.iafenvoy.sow.render.power.entity.*;
import dev.architectury.registry.client.level.entity.EntityRendererRegistry;
import dev.architectury.registry.client.particle.ParticleProviderRegistry;
import dev.architectury.registry.client.rendering.BlockEntityRendererRegistry;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.iafenvoy.sow.render;

import com.iafenvoy.sow.SongsOfWar;
import net.minecraft.util.Identifier;

public class RenderConstants {
public static final Identifier WHITE_TEXTURE = Identifier.of(SongsOfWar.MOD_ID, "textures/white.png");
public static final Identifier STONE_TEXTURE = Identifier.of(Identifier.DEFAULT_NAMESPACE, "textures/block/stone.png");
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.iafenvoy.neptune.util.Color4i;
import com.iafenvoy.sow.item.block.entity.ArdoniGraveBlockEntity;
import com.iafenvoy.sow.render.ImageRenderUtils;
import com.iafenvoy.sow.render.util.ArdoniMarkerGenerator;
import com.iafenvoy.sow.render.RenderConstants;
import com.iafenvoy.sow.render.generator.ArdoniMarkerGenerator;
import com.mojang.blaze3d.platform.TextureUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.model.*;
Expand Down Expand Up @@ -33,7 +33,7 @@ public void render(ArdoniGraveBlockEntity entity, float tickDelta, MatrixStack m
matrices.translate(0.5, 1.5, 0.5);
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(entity.getRotationDegree()));
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180));
part.render(matrices, vertexConsumers.getBuffer(RenderLayer.getEntityCutout(ImageRenderUtils.STONE_TEXTURE)), light, overlay);
part.render(matrices, vertexConsumers.getBuffer(RenderLayer.getEntityCutout(RenderConstants.STONE_TEXTURE)), light, overlay);
Color4i color = entity.activated() ? entity.getArdoniType().getColor(seed) : new Color4i(0x20, 0x20, 0x20, 0xFF);
part.render(matrices, vertexConsumers.getBuffer(RenderLayer.getEntityTranslucentEmissive(texture)), light, overlay, color.getR(), color.getG(), color.getB(), color.getA());
matrices.pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.iafenvoy.sow.entity.magnorite.AbstractMagnoriteEntity;
import com.iafenvoy.sow.entity.magnorite.MagnoriteEntity;
import com.iafenvoy.sow.render.entity.feature.MagnoriteMarkerFeatureRenderer;
import com.iafenvoy.sow.render.util.MagnoriteSkinGenerator;
import com.iafenvoy.sow.render.generator.MagnoriteSkinGenerator;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.BipedEntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
import com.iafenvoy.neptune.util.Color4i;
import com.iafenvoy.sow.entity.ardoni.AbstractArdoniEntity;
import com.iafenvoy.sow.entity.ardoni.random.ArdoniEntity;
import com.iafenvoy.sow.render.util.ArdoniMarkerGenerator;
import com.iafenvoy.sow.render.generator.ArdoniMarkerGenerator;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.iafenvoy.sow.entity.magnorite.AbstractMagnoriteEntity;
import com.iafenvoy.sow.entity.magnorite.MagnoriteEntity;
import com.iafenvoy.sow.render.util.MagnoriteSkinGenerator;
import com.iafenvoy.sow.render.generator.MagnoriteSkinGenerator;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.render.OverlayTexture;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.iafenvoy.sow.render.util;
package com.iafenvoy.sow.render.generator;

import com.iafenvoy.sow.SongsOfWar;
import com.iafenvoy.sow.render.ImageRenderUtils;
import com.iafenvoy.sow.render.util.ImageRenderUtils;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.texture.NativeImage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iafenvoy.sow.render.util;
package com.iafenvoy.sow.render.generator;

import com.iafenvoy.sow.render.block.ArdoniGraveBlockEntityRenderer;
import net.fabricmc.api.EnvType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.iafenvoy.sow.render.util;
package com.iafenvoy.sow.render.generator;

import com.iafenvoy.neptune.util.Color4i;
import com.iafenvoy.sow.SongsOfWar;
import com.iafenvoy.sow.render.ImageRenderUtils;
import com.iafenvoy.sow.render.util.ImageRenderUtils;
import com.iafenvoy.sow.util.PerlinNoise;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.texture.NativeImage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.iafenvoy.sow.render.power;
package com.iafenvoy.sow.render.power.entity;

import com.iafenvoy.sow.entity.power.AggroDetonateEntity;
import com.iafenvoy.sow.render.ImageRenderUtils;
import com.iafenvoy.sow.render.RenderConstants;
import com.iafenvoy.sow.render.power.model.DetonateModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down Expand Up @@ -39,6 +39,6 @@ public void render(AggroDetonateEntity entity, float yaw, float tickDelta, Matri

@Override
public Identifier getTexture(AggroDetonateEntity entity) {
return ImageRenderUtils.WHITE_TEXTURE;
return RenderConstants.WHITE_TEXTURE;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iafenvoy.sow.render.power;
package com.iafenvoy.sow.render.power.entity;

import com.iafenvoy.sow.entity.power.AggroShardEntity;
import com.iafenvoy.sow.render.power.model.ShardModel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.iafenvoy.sow.render.power;
package com.iafenvoy.sow.render.power.entity;

import com.iafenvoy.sow.entity.power.AggroSphereEntity;
import com.iafenvoy.sow.render.ImageRenderUtils;
import com.iafenvoy.sow.render.RenderConstants;
import com.iafenvoy.sow.render.power.model.SphereModel;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand All @@ -27,14 +27,14 @@ public AggroSphereRenderer(EntityRendererFactory.Context ctx) {
public void render(AggroSphereEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
matrices.push();
matrices.scale(0.5f, 0.5f, 0.5f);
matrices.translate(0, -0.5, 0);
matrices.translate(0, -1, 0);
VertexConsumer consumer = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucentEmissive(this.getTexture(entity)));
this.sphereModel.render(matrices, consumer, light, OverlayTexture.DEFAULT_UV, 1, 0, 0, 0.3f);
matrices.pop();
}

@Override
public Identifier getTexture(AggroSphereEntity entity) {
return ImageRenderUtils.WHITE_TEXTURE;
return RenderConstants.WHITE_TEXTURE;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.iafenvoy.sow.render.power;
package com.iafenvoy.sow.render.power.entity;

import com.iafenvoy.sow.entity.power.ProteCloneEntity;
import com.iafenvoy.sow.render.ImageRenderUtils;
import com.iafenvoy.sow.render.RenderConstants;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
Expand Down Expand Up @@ -31,6 +31,6 @@ public void render(ProteCloneEntity entity, float yaw, float tickDelta, MatrixSt

@Override
public Identifier getTexture(ProteCloneEntity entity) {
return ImageRenderUtils.WHITE_TEXTURE;
return RenderConstants.WHITE_TEXTURE;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iafenvoy.sow.render.power;
package com.iafenvoy.sow.render.power.entity;

import com.iafenvoy.sow.entity.power.SupporoSpikeEntity;
import net.minecraft.client.render.OverlayTexture;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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.power.test.MobiliBurstModel;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
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;

public MobiliBurstFeatureRenderer(FeatureRendererContext<T, M> context) {
super(context);
this.model = new MobiliBurstModel<>(MobiliBurstModel.getTexturedModelData().createModel());
}

@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;
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));
matrices.pop();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.iafenvoy.sow.render.power;
package com.iafenvoy.sow.render.power.feature;

import com.iafenvoy.sow.SongsOfWar;
import com.iafenvoy.sow.power.SongPowerData;
Expand All @@ -21,7 +21,7 @@

@Environment(EnvType.CLIENT)
public class MobiliumElytraFeatureRenderer<T extends PlayerEntity, M extends PlayerEntityModel<T>> extends FeatureRenderer<T, M> {
private static final Identifier SKIN = Identifier.of(SongsOfWar.MOD_ID, "textures/entity/elytra.png");
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) {
Expand All @@ -36,7 +36,7 @@ public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsume
matrixStack.translate(0.0F, 0.0F, 0.125F);
this.getContextModel().copyStateTo(this.elytra);
this.elytra.setAngles(entity, f, g, j, k, l);
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityTranslucentEmissive(SKIN));
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityTranslucentEmissive(TEXTURE));
this.elytra.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1, 1, 0, 0.5f);
matrixStack.pop();
}
Expand Down
Loading

0 comments on commit e5c09d6

Please sign in to comment.