-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
197 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Common/src/main/java/dev/cammiescorner/icarus/api/client/IcarusAPIClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.cammiescorner.icarus.api.client; | ||
|
||
import dev.cammiescorner.icarus.client.IcarusClient; | ||
import net.minecraft.world.entity.LivingEntity; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class IcarusAPIClient { | ||
|
||
public static void addRenderPredicate(Predicate<LivingEntity> predicate) { | ||
IcarusClient.addRenderPredicate(predicate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...c/main/java/dev/cammiescorner/icarus/integration/figura/IcarusFiguraModelPartsPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dev.cammiescorner.icarus.integration.figura; | ||
|
||
import com.mojang.datafixers.util.Pair; | ||
import dev.cammiescorner.icarus.Icarus; | ||
import dev.cammiescorner.icarus.client.models.WingEntityModel; | ||
import net.minecraft.client.model.EntityModel; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import org.figuramc.figura.entries.FiguraVanillaPart; | ||
import org.figuramc.figura.entries.annotations.FiguraVanillaPartPlugin; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
@SuppressWarnings("unused") | ||
@FiguraVanillaPartPlugin | ||
public class IcarusFiguraModelPartsPlugin implements FiguraVanillaPart { | ||
|
||
@Override | ||
public String getID() { | ||
return Icarus.MODID; | ||
} | ||
|
||
@Override | ||
public Collection<Pair<String, Function<EntityModel<?>, ModelPart>>> getParts() { | ||
return List.of( | ||
new Pair<>("right_wing", model -> model instanceof WingEntityModel<?> wingModel ? wingModel.rightWing : null), | ||
new Pair<>("left_wing", model -> model instanceof WingEntityModel<?> wingModel ? wingModel.leftWing : null) | ||
); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
Common/src/main/java/dev/cammiescorner/icarus/integration/figura/IcarusFiguraPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package dev.cammiescorner.icarus.integration.figura; | ||
|
||
import dev.cammiescorner.icarus.Icarus; | ||
import dev.cammiescorner.icarus.api.client.IcarusAPIClient; | ||
import it.unimi.dsi.fastutil.objects.Object2BooleanMap; | ||
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import org.figuramc.figura.avatar.Avatar; | ||
import org.figuramc.figura.entries.FiguraAPI; | ||
import org.figuramc.figura.entries.annotations.FiguraAPIPlugin; | ||
import org.figuramc.figura.lua.LuaWhitelist; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@SuppressWarnings("unused") | ||
@LuaWhitelist | ||
@FiguraAPIPlugin | ||
public class IcarusFiguraPlugin implements FiguraAPI { | ||
|
||
private static final Object2BooleanMap<UUID> WINGS_VISIBLE = new Object2BooleanOpenHashMap<>(); | ||
@NotNull | ||
private final Avatar avatar; | ||
|
||
// needed because this class is instantiated via reflection. | ||
// honestly this API is pretty bad. | ||
@SuppressWarnings({"unused", "DataFlowIssue"}) | ||
public IcarusFiguraPlugin() { | ||
this.avatar = null; | ||
} | ||
|
||
static { | ||
IcarusAPIClient.addRenderPredicate(IcarusFiguraPlugin::shouldRenderWings); | ||
} | ||
|
||
public IcarusFiguraPlugin(Avatar avatar) { | ||
this.avatar = avatar; | ||
} | ||
|
||
@LuaWhitelist | ||
public boolean areWingsVisible() { | ||
return WINGS_VISIBLE.getOrDefault(avatar.owner, true); | ||
} | ||
|
||
@LuaWhitelist | ||
public void setWingsVisible(boolean visible) { | ||
WINGS_VISIBLE.put(avatar.owner, visible); | ||
} | ||
|
||
@Override | ||
public FiguraAPI build(Avatar avatar) { | ||
return new IcarusFiguraPlugin(avatar); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return Icarus.MODID; | ||
} | ||
|
||
@Override | ||
public Collection<Class<?>> getWhitelistedClasses() { | ||
return List.of(IcarusFiguraPlugin.class); | ||
} | ||
|
||
@Override | ||
public Collection<Class<?>> getDocsClasses() { | ||
return List.of(); | ||
} | ||
|
||
private static boolean shouldRenderWings(LivingEntity entity) { | ||
return WINGS_VISIBLE.getOrDefault(entity.getUUID(), true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters