lilliputian
This commit is contained in:
parent
772d94cd9e
commit
bf35952778
12 changed files with 95 additions and 20 deletions
|
@ -39,8 +39,6 @@ dependencies {
|
|||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.1'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.1'
|
||||
|
||||
compileOnly "com.github.Virtuoel:Pehkui:${pehkuiVersion}"
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
@ -5,15 +5,14 @@ import at.petrak.hexcasting.api.spell.SpellDatum
|
|||
import at.petrak.hexcasting.api.spell.asSpellResult
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.getChecked
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||
import net.minecraft.world.entity.Entity
|
||||
import virtuoel.pehkui.api.ScaleTypes
|
||||
|
||||
object OpGetScale : ConstManaOperator {
|
||||
override val argc = 1
|
||||
|
||||
override fun execute(args: List<SpellDatum<*>>, ctx: CastingContext): List<SpellDatum<*>> {
|
||||
val target = args.getChecked<Entity>(0)
|
||||
val data = ScaleTypes.BASE.getScaleData(target)
|
||||
return data.scale.toDouble().asSpellResult
|
||||
return IXplatAbstractions.INSTANCE.pehkuiApi.getScale(target).toDouble().asSpellResult
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ package at.petrak.hexcasting.interop.pehkui
|
|||
|
||||
import at.petrak.hexcasting.api.spell.*
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||
import net.minecraft.world.entity.Entity
|
||||
import virtuoel.pehkui.api.ScaleTypes
|
||||
|
||||
object OpSetScale : SpellOperator {
|
||||
override val argc = 2
|
||||
|
@ -24,10 +24,7 @@ object OpSetScale : SpellOperator {
|
|||
|
||||
private data class Spell(val target: Entity, val scale: Double) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
val scaleType = ScaleTypes.BASE
|
||||
val data = scaleType.getScaleData(target)
|
||||
|
||||
data.scale = scale.toFloat()
|
||||
IXplatAbstractions.INSTANCE.pehkuiApi.setScale(target, scale.toFloat())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,30 @@
|
|||
package at.petrak.hexcasting.interop.pehkui;
|
||||
|
||||
import at.petrak.hexcasting.api.PatternRegistry;
|
||||
import at.petrak.hexcasting.api.spell.math.HexDir;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
public class PehkuiInterop {
|
||||
public static void init() {
|
||||
/*
|
||||
try {
|
||||
PatternRegistry.mapPattern(HexPattern.fromAngles("aawawwawwa", HexDir.NORTH_WEST),
|
||||
modLoc("interop/pehkui/get"), OpGetScale.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.fromAngles("ddwdwwdwwd", HexDir.NORTH_EAST),
|
||||
modLoc("interop/pehkui/set"), OpSetScale.INSTANCE);
|
||||
} catch (PatternRegistry.RegisterPatternException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Pehkui doesn't publish an API jar so we do this BS
|
||||
*/
|
||||
public interface ApiAbstraction {
|
||||
float getScale(Entity e);
|
||||
|
||||
void setScale(Entity e, float scale);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import at.petrak.hexcasting.api.player.Sentinel;
|
|||
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.interop.pehkui.PehkuiInterop;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -141,6 +142,10 @@ public interface IXplatAbstractions {
|
|||
|
||||
LootItemCondition.Builder isShearsCondition();
|
||||
|
||||
// interop
|
||||
|
||||
PehkuiInterop.ApiAbstraction getPehkuiApi();
|
||||
|
||||
///
|
||||
|
||||
IXplatAbstractions INSTANCE = find();
|
||||
|
|
|
@ -357,6 +357,8 @@
|
|||
|
||||
"hexcasting.spell.hexcasting:interop/gravity/get": "Gravitational Purification",
|
||||
"hexcasting.spell.hexcasting:interop/gravity/set": "Alter Gravity",
|
||||
"hexcasting.spell.hexcasting:interop/pehkui/get": "Gulliver's Purification",
|
||||
"hexcasting.spell.hexcasting:interop/pehkui/set": "Alter Scale",
|
||||
|
||||
"hexcasting.mishap.invalid_pattern": "That pattern isn't associated with any action",
|
||||
"hexcasting.mishap.unescaped": "Expected to evaluate a pattern, but evaluated %s instead",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "hexcasting.entry.interop.pehkui",
|
||||
"icon": "minecraft:iron_nugget",
|
||||
"icon": "minecraft:red_mushroom",
|
||||
"category": "hexcasting:interop",
|
||||
"advancement": "hexcasting:root",
|
||||
"flag": "never",
|
||||
"flag": "mod:pehkui",
|
||||
"pages": [
|
||||
"hexcasting.page.interop.pehkui.1",
|
||||
{
|
||||
|
|
|
@ -74,9 +74,9 @@ dependencies {
|
|||
modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:$reiVersion"
|
||||
|
||||
modImplementation "maven.modrinth:fusions-gravity-api:$gravityApiVersion"
|
||||
// modApi("com.github.Virtuoel:Pehkui:${pehkuiVersion}", {
|
||||
// exclude group: "net.fabricmc.fabric-api"
|
||||
// })
|
||||
modApi("com.github.Virtuoel:Pehkui:${pehkuiVersion}", {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
})
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import at.petrak.hexcasting.fabric.cc.HexCardinalComponents;
|
|||
import at.petrak.hexcasting.fabric.interop.gravity.GravityApiInterop;
|
||||
import at.petrak.hexcasting.fabric.recipe.FabricUnsealedIngredient;
|
||||
import at.petrak.hexcasting.interop.HexInterop;
|
||||
import at.petrak.hexcasting.interop.pehkui.PehkuiInterop;
|
||||
import at.petrak.hexcasting.ktxt.AccessorWrappers;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import at.petrak.hexcasting.xplat.IXplatTags;
|
||||
|
@ -37,6 +38,7 @@ import net.minecraft.server.level.ServerLevel;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
|
@ -56,6 +58,7 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
|||
import net.minecraft.world.level.storage.loot.predicates.MatchTool;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import virtuoel.pehkui.api.ScaleTypes;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
@ -330,4 +333,28 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
HexItemTags.create(new ResourceLocation("c", "shears"))))
|
||||
);
|
||||
}
|
||||
|
||||
private static PehkuiInterop.ApiAbstraction PEHKUI_API = null;
|
||||
|
||||
@Override
|
||||
public PehkuiInterop.ApiAbstraction getPehkuiApi() {
|
||||
if (!this.isModPresent(HexInterop.PEHKUI_ID)) {
|
||||
throw new IllegalArgumentException("cannot get the pehkui api without pehkui");
|
||||
}
|
||||
|
||||
if (PEHKUI_API == null) {
|
||||
PEHKUI_API = new PehkuiInterop.ApiAbstraction() {
|
||||
@Override
|
||||
public float getScale(Entity e) {
|
||||
return ScaleTypes.BASE.getScaleData(e).getScale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(Entity e, float scale) {
|
||||
ScaleTypes.BASE.getScaleData(e).setScale(scale);
|
||||
}
|
||||
};
|
||||
}
|
||||
return PEHKUI_API;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ dependencies {
|
|||
testCompileOnly fg.deobf("at.petra-k.paucal:paucal-forge-$minecraftVersion:$paucalVersion")
|
||||
testCompileOnly fg.deobf("vazkii.patchouli:Patchouli:$minecraftVersion-$patchouliVersion")
|
||||
|
||||
api fg.deobf("com.github.Virtuoel:Pehkui:${pehkuiVersion}")
|
||||
api fg.deobf("com.github.Virtuoel:Pehkui:${pehkuiVersion}-${minecraftVersion}-forge")
|
||||
}
|
||||
|
||||
mixin {
|
||||
|
|
|
@ -72,8 +72,6 @@ public class ForgeHexInitializer {
|
|||
initConfig();
|
||||
initRegistry();
|
||||
initListeners();
|
||||
|
||||
HexInterop.init();
|
||||
}
|
||||
|
||||
private static void initConfig() {
|
||||
|
@ -132,6 +130,8 @@ public class ForgeHexInitializer {
|
|||
HexComposting.setup();
|
||||
HexStrippables.init();
|
||||
RegisterPatterns.registerPatterns();
|
||||
|
||||
HexInterop.init();
|
||||
}));
|
||||
|
||||
// We have to do these at some point when the registries are still open
|
||||
|
|
|
@ -20,6 +20,8 @@ import at.petrak.hexcasting.forge.cap.HexCapabilities;
|
|||
import at.petrak.hexcasting.forge.network.ForgePacketHandler;
|
||||
import at.petrak.hexcasting.forge.network.MsgBrainsweepAck;
|
||||
import at.petrak.hexcasting.forge.recipe.ForgeUnsealedIngredient;
|
||||
import at.petrak.hexcasting.interop.HexInterop;
|
||||
import at.petrak.hexcasting.interop.pehkui.PehkuiInterop;
|
||||
import at.petrak.hexcasting.ktxt.AccessorWrappers;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import at.petrak.hexcasting.xplat.IXplatTags;
|
||||
|
@ -37,6 +39,7 @@ import net.minecraft.server.level.ServerLevel;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
|
@ -70,6 +73,7 @@ import net.minecraftforge.fml.loading.FMLLoader;
|
|||
import net.minecraftforge.network.NetworkDirection;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import virtuoel.pehkui.api.ScaleTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -379,6 +383,31 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
return CanToolPerformAction.canToolPerformAction(ToolActions.SHEARS_DIG);
|
||||
}
|
||||
|
||||
// it's literally the EXACT SAME on fabric aaa
|
||||
private static PehkuiInterop.ApiAbstraction PEHKUI_API = null;
|
||||
|
||||
@Override
|
||||
public PehkuiInterop.ApiAbstraction getPehkuiApi() {
|
||||
if (!this.isModPresent(HexInterop.PEHKUI_ID)) {
|
||||
throw new IllegalArgumentException("cannot get the pehkui api without pehkui");
|
||||
}
|
||||
|
||||
if (PEHKUI_API == null) {
|
||||
PEHKUI_API = new PehkuiInterop.ApiAbstraction() {
|
||||
@Override
|
||||
public float getScale(Entity e) {
|
||||
return ScaleTypes.BASE.getScaleData(e).getScale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(Entity e, float scale) {
|
||||
ScaleTypes.BASE.getScaleData(e).setScale(scale);
|
||||
}
|
||||
};
|
||||
}
|
||||
return PEHKUI_API;
|
||||
}
|
||||
|
||||
public static final String TAG_BRAINSWEPT = "hexcasting:brainswept";
|
||||
public static final String TAG_SENTINEL_EXISTS = "hexcasting:sentinel_exists";
|
||||
public static final String TAG_SENTINEL_GREATER = "hexcasting:sentinel_extends_range";
|
||||
|
|
Loading…
Reference in a new issue