Skip to content

Commit

Permalink
ref: applied to signal angel
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Sep 22, 2024
1 parent cb571e4 commit 9d986d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ private static void transform(final BakedQuad quad, final Matrix4f quaterion) {
}
}

private static BakedModelPair transform(final SignalModelLoaderInfo info,
final ModelBakery bakery, final ResourceLocation location,
final Function<Material, TextureAtlasSprite> function,
private BakedModelPair transform(final SignalModelLoaderInfo info, final ModelBakery bakery,
final ResourceLocation location, final Function<Material, TextureAtlasSprite> function,
final Map<String, Either<Material, String>> material, final Quaternion rotation) {
final Transformation transformation = new Transformation(
new Vector3f(info.x, info.y, info.z), null, null, null);
Expand All @@ -113,7 +112,8 @@ private static BakedModelPair transform(final SignalModelLoaderInfo info,
model.getQuads(null, direction, RANDOM, EmptyModelData.INSTANCE)
.forEach(quad -> transform(quad, matrix));
}
locationToModel.put(new ResourceLocation(OpenSignalsMain.MODID, info.name), model);
if (angel.equals(SignalAngel.ANGEL0))
locationToModel.put(new ResourceLocation(OpenSignalsMain.MODID, info.name), model);
return new BakedModelPair(info.state, model);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Quaternion;
import com.troblecodings.signals.OpenSignalsMain;
import com.troblecodings.signals.blocks.Signal;
import com.troblecodings.signals.core.RenderAnimationInfo;
import com.troblecodings.signals.core.RenderOverlayInfo;
import com.troblecodings.signals.core.SignalAngel;
import com.troblecodings.signals.models.SignalCustomModel;

import net.minecraft.client.renderer.ItemBlockRenderTypes;
Expand Down Expand Up @@ -39,28 +41,34 @@ public void render(final SignalTileEntity tile, final float tick, final PoseStac

// @SuppressWarnings("deprecation")
public void renderAnimation(final RenderAnimationInfo info, final SignalTileEntity tile) {

final BlockState state = tile.getBlockState();
final SignalAngel angel = state.getValue(Signal.ANGEL);

info.stack.pushPose(); // erst Berechnungen ausführen, dann Block rendern
info.stack.translate(1, 1, 0.5f); // Block verschieben

info.stack.mulPose(
Quaternion.fromXYZ(0, 0, tile.animProgress * 0.005f));
info.stack.translate(0.5f, 0, 0.5f);
info.stack.mulPose(angel.getQuaternion());

info.stack.translate(0.5f, 7.5f, -0.5f); // Block verschieben
info.stack.mulPose(Quaternion.fromXYZ(0, 0, -tile.animProgress * 0.005f));
tile.updateAnim(); // Progress aktualisieren

info.stack.translate(-1, 0, -0.5f); // Pivot Punkt verschieben
info.stack.translate(-1, -4.5f, 0); // Pivot Punkt verschieben

// info.dispatcher.renderSingleBlock(Blocks.GLASS.defaultBlockState(),
// info.stack, info.source,
// info.lightColor, info.overlayTexture); // Block rendern
// info.lightColor, info.overlayTexture); // Block render
final BakedModel model = SignalCustomModel.getModelFromLocation(
new ResourceLocation(OpenSignalsMain.MODID, "semaphore_signals/sema_main_wing1"));
final BlockState state = tile.getBlockState();
info.dispatcher.getModelRenderer().renderModel(info.stack.last(),
info.source
.getBuffer(ItemBlockRenderTypes.getRenderType(tile.getBlockState(), false)),
state, model, 0, 0, 0, info.lightColor, info.overlayTexture, tile.getModelData());

info.stack.popPose();

if (tile.animProgress > 100)
if (tile.animProgress > 180)
tile.animProgress = 0;
}
}

0 comments on commit 9d986d0

Please sign in to comment.