Skip to content

Commit

Permalink
Merge branch 'main' into pattern-conflict-checking-466
Browse files Browse the repository at this point in the history
  • Loading branch information
object-Object authored Mar 20, 2024
2 parents d6c0b9a + 65a0757 commit 9c29ab1
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 22 deletions.
68 changes: 68 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Bug Report
description: Report an issue with Hex Casting
labels:
- bug
- unconfirmed

body:
- type: dropdown
attributes:
label: Modloader
options:
- Forge
- Fabric
- Quilt
validations:
required: true

- type: input
attributes:
label: Minecraft version
placeholder: eg. 1.19.2
validations:
required: true

- type: input
attributes:
label: Hex Casting version
placeholder: eg. 0.11.1-7-pre-609
validations:
required: true

- type: input
attributes:
label: Modloader version
description: |
List the version of the mod loader you are using.
If on Fabric, post the versions of both Fabric Loader and Fabric API.
placeholder: "eg. Forge: 36.2.9 / Fabric: Loader 0.10.6 + API 0.42.1"

- type: input
attributes:
label: Modpack info
description: If playing a modpack, post the link to it!

- type: input
attributes:
label: The latest.log file
description: Please use https://mclo.gs/ if possible. Sites like https://gist.github.com/ or https://pastebin.com/ are also acceptable.

- type: textarea
attributes:
label: Issue description
placeholder: A description of the issue.
validations:
required: true

- type: textarea
attributes:
label: Steps to reproduce
placeholder: |
1. First step
2. Second step
3. etc...
- type: textarea
attributes:
label: Other information
description: Any other relevant information that is related to this issue, such as other mods and their versions.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Feature Request
description: Suggest an improvement or a new feature
labels:
- enhancement
- unconfirmed

body:
- type: textarea
attributes:
label: Describe the feature
validations:
required: true

- type: textarea
attributes:
label: Additional context
description: Any other relevant information (eg. use cases, alternative solutions)
37 changes: 37 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# mirror of the Jenkins pipeline, used for requiring PRs to build successfully before merging
# this uses Actions because it's easier to integrate with GitHub PRs, and to allow running the build on forks

name: Build pull request

on:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17.0.1"
- uses: gradle/actions/setup-gradle@v3

- name: Clean
run: |
chmod +x gradlew
./gradlew clean
- name: Build
run: ./gradlew build

- name: Run Datagen
run: ./gradlew runAllDatagen

- name: Check Datagen
run: |
git add --intent-to-add .
git diff --name-only --exit-code -- ":!:*/src/generated/resources/.cache/*"
6 changes: 1 addition & 5 deletions Common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ repositories {
url = "https://modmaven.dev"
}

// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
flatDir {
dir 'libs'
}
}

dependencies {
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'

compileOnly "${modID}:paucal-common-$minecraftVersion:$paucalVersion"
compileOnly "at.petra-k.paucal:paucal-common-$minecraftVersion:$paucalVersion"
compileOnly "vazkii.patchouli:Patchouli-xplat:$minecraftVersion-$patchouliVersion-SNAPSHOT"

compileOnly "org.jetbrains:annotations:$jetbrainsAnnotationsVersion"
Expand Down
Binary file removed Common/libs/paucal-common-1.20.1-0.6.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public final void triggerCreateEvent() {

protected Map<CastingEnvironmentComponent.Key<?>, @NotNull CastingEnvironmentComponent> componentMap = new HashMap<>();
private final List<PostExecution> postExecutions = new ArrayList<>();
private final List<ExtractMedia> extractMedias = new ArrayList<>();
private final List<ExtractMedia.Pre> preMediaExtract = new ArrayList<>();
private final List<ExtractMedia.Post> postMediaExtract = new ArrayList<>();

private final List<IsVecInRange> isVecInRanges = new ArrayList<>();
private final List<HasEditPermissionsAt> hasEditPermissionsAts = new ArrayList<>();

Expand Down Expand Up @@ -112,7 +114,11 @@ public <T extends CastingEnvironmentComponent> void addExtension(@NotNull T exte
if (extension instanceof PostExecution postExecution)
postExecutions.add(postExecution);
if (extension instanceof ExtractMedia extractMedia)
extractMedias.add(extractMedia);
if (extension instanceof ExtractMedia.Pre pre) {
preMediaExtract.add(pre);
} else if (extension instanceof ExtractMedia.Post post) {
postMediaExtract.add(post);
}
if (extension instanceof IsVecInRange isVecInRange)
isVecInRanges.add(isVecInRange);
if (extension instanceof HasEditPermissionsAt hasEditPermissionsAt)
Expand All @@ -127,7 +133,11 @@ public void removeExtension(@NotNull CastingEnvironmentComponent.Key<?> key) {
if (extension instanceof PostExecution postExecution)
postExecutions.remove(postExecution);
if (extension instanceof ExtractMedia extractMedia)
extractMedias.remove(extractMedia);
if (extension instanceof ExtractMedia.Pre pre) {
preMediaExtract.remove(pre);
} else if (extension instanceof ExtractMedia.Post post) {
postMediaExtract.remove(post);
}
if (extension instanceof IsVecInRange isVecInRange)
isVecInRanges.remove(isVecInRange);
if (extension instanceof HasEditPermissionsAt hasEditPermissionsAt)
Expand Down Expand Up @@ -202,9 +212,12 @@ public boolean isEnlightened() {
* positive.
*/
public long extractMedia(long cost) {
for (var extractMediaComponent : extractMedias)
for (var extractMediaComponent : preMediaExtract)
cost = extractMediaComponent.onExtractMedia(cost);
return extractMediaEnvironment(cost);
cost = extractMediaEnvironment(cost);
for (var extractMediaComponent : postMediaExtract)
cost = extractMediaComponent.onExtractMedia(cost);
return cost;
}

/**
Expand Down Expand Up @@ -259,7 +272,7 @@ public final boolean isVecInAmbit(Vec3 vec) {
}

public final boolean isEntityInRange(Entity e) {
return e instanceof Player || this.isVecInRange(e.position());
return (e instanceof Player && HexConfig.server().trueNameHasAmbit()) || (this.isVecInWorld(e.position()) && this.isVecInRange(e.position()));
}

/**
Expand Down Expand Up @@ -290,6 +303,9 @@ public final boolean canEditBlockAt(BlockPos vec) {
* Convenience function to throw if the entity is out of the caster's range or the world
*/
public final void assertEntityInRange(Entity e) throws MishapEntityTooFarAway {
if (e instanceof ServerPlayer && HexConfig.server().trueNameHasAmbit()) {
return;
}
if (!this.isVecInWorld(e.position())) {
throw new MishapEntityTooFarAway(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@ interface ExtractMedia extends CastingEnvironmentComponent {
/**
* Receives the cost that is being extracted, should return the
* remaining cost after deducting whatever cost source this component
* is responsible for (should be >= 0). All Components are executed
* before the CastingEnvironment's extractMedia is executed.
* is responsible for (should be &gt;= 0)
*/
long onExtractMedia(long cost);

/**
* ExtractMedia component that extracts media BEFORE the call to {@link CastingEnvironment#extractMediaEnvironment(long)}
*/
interface Pre extends ExtractMedia {}

/**
* ExtractMedia component that extracts media AFTER the call to {@link CastingEnvironment#extractMediaEnvironment(long)}
* if the input is &lt;= 0 you should also probably return 0 (since media cost was already paid off)
*/
interface Post extends ExtractMedia {}
}

interface IsVecInRange extends CastingEnvironmentComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) {

continuation = image2.continuation
lastResolutionType = image2.resolutionType
performSideEffects(info, image2.sideEffects)
try {
performSideEffects(info, image2.sideEffects)
} catch (e: Exception) {
e.printStackTrace()
performSideEffects(info, listOf(OperatorSideEffect.DoMishap(MishapInternalException(e), Mishap.Context(null, null))))
}
info.earlyExit = info.earlyExit || !lastResolutionType.success
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public interface ServerConfigAccess {
// fun fact, although dimension keys are a RegistryHolder, they aren't a registry, so i can't do tags
boolean canTeleportInThisDimension(ResourceKey<Level> dimension);

boolean trueNameHasAmbit();

int DEFAULT_MAX_OP_COUNT = 1_000_000;
int DEFAULT_MAX_SPELL_CIRCLE_LENGTH = 1024;
int DEFAULT_OP_BREAK_HARVEST_LEVEL = 3;
Expand All @@ -77,6 +79,8 @@ public interface ServerConfigAccess {

List<String> DEFAULT_DIM_TP_DENYLIST = List.of("twilightforest:twilight_forest");

boolean DEFAULT_TRUE_NAME_HAS_AMBIT = true;

default Tier opBreakHarvestLevel() {
return switch (this.opBreakHarvestLevelBecauseForgeThoughtItWasAGoodIdeaToImplementHarvestTiersUsingAnHonestToGodTopoSort()) {
case 0 -> Tiers.WOOD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import net.minecraft.world.entity.Entity
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.animal.Animal
import net.minecraft.world.entity.animal.WaterAnimal
import net.minecraft.world.entity.boss.EnderDragonPart
import net.minecraft.world.entity.item.ItemEntity
import net.minecraft.world.entity.monster.Enemy
import net.minecraft.world.entity.player.Player
Expand Down Expand Up @@ -51,6 +52,6 @@ class OpGetEntitiesBy(val checker: Predicate<Entity>, val negate: Boolean) : Con
fun isPlayer(e: Entity): Boolean = e is Player

@JvmStatic
fun isLiving(e: Entity): Boolean = e is LivingEntity
fun isLiving(e: Entity): Boolean = (e is LivingEntity) || (e is EnderDragonPart)
}
}
2 changes: 1 addition & 1 deletion Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dependencies {
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
compileOnly project(":Common")

modImplementation "${modID}:paucal-fabric-$minecraftVersion:$paucalVersion"
modImplementation "at.petra-k.paucal:paucal-fabric-$minecraftVersion:$paucalVersion"
modImplementation "vazkii.patchouli:Patchouli:$minecraftVersion-$patchouliVersion-FABRIC-SNAPSHOT"

modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:$cardinalComponentsVersion"
Expand Down
Binary file removed Fabric/libs/paucal-fabric-1.20.1-0.6.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public static final class Server implements HexConfig.ServerConfigAccess, Config
private List<String> circleActionDenyList = List.of();
@ConfigEntry.Gui.Tooltip
private boolean villagersOffendedByMindMurder = DEFAULT_VILLAGERS_DISLIKE_MIND_MURDER;
@ConfigEntry.Gui.Tooltip
private boolean doesTrueNameHaveAmbit = DEFAULT_TRUE_NAME_HAS_AMBIT;


@ConfigEntry.Gui.Tooltip
private List<String> tpDimDenylist = DEFAULT_DIM_TP_DENYLIST;
Expand Down Expand Up @@ -250,6 +253,11 @@ public boolean canTeleportInThisDimension(ResourceKey<Level> dimension) {
return noneMatch(tpDimDenylist, dimension.location());
}

@Override
public boolean trueNameHasAmbit() {
return doesTrueNameHaveAmbit;
}

/**
* Returns -1 if none is found
*/
Expand Down
4 changes: 2 additions & 2 deletions Forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ dependencies {

annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

compileOnly fg.deobf("${modID}:paucal-forge-$minecraftVersion:$paucalVersion")
runtimeOnly fg.deobf("${modID}:paucal-forge-$minecraftVersion:$paucalVersion")
compileOnly fg.deobf("at.petra-k.paucal:paucal-forge-$minecraftVersion:$paucalVersion")
runtimeOnly fg.deobf("at.petra-k.paucal:paucal-forge-$minecraftVersion:$paucalVersion")
compileOnly fg.deobf("vazkii.patchouli:Patchouli:$minecraftVersion-$patchouliVersion-FORGE-SNAPSHOT")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:$minecraftVersion-$patchouliVersion-FORGE-SNAPSHOT")

Expand Down
Binary file removed Forge/libs/paucal-forge-1.20.1-0.6.0.jar
Binary file not shown.
11 changes: 11 additions & 0 deletions Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public static class Server implements HexConfig.ServerConfigAccess {

private static ForgeConfigSpec.ConfigValue<List<? extends String>> tpDimDenyList;

private static ForgeConfigSpec.BooleanValue doesTrueNameHaveAmbit;

private static ForgeConfigSpec.ConfigValue<List<? extends String>> fewScrollTables;
private static ForgeConfigSpec.ConfigValue<List<? extends String>> someScrollTables;
private static ForgeConfigSpec.ConfigValue<List<? extends String>> manyScrollTables;
Expand Down Expand Up @@ -170,6 +172,10 @@ public Server(ForgeConfigSpec.Builder builder) {

tpDimDenyList = builder.comment("Resource locations of dimensions you can't Blink or Greater Teleport in.")
.defineList("tpDimDenyList", DEFAULT_DIM_TP_DENYLIST, Server::isValidReslocArg);

doesTrueNameHaveAmbit = builder.comment(
"when false makes player reference iotas behave as normal entity reference iotas")
.define("doesTrueNameHaveAmbit", DEFAULT_TRUE_NAME_HAS_AMBIT);
}

@Override
Expand Down Expand Up @@ -207,6 +213,11 @@ public boolean canTeleportInThisDimension(ResourceKey<Level> dimension) {
return noneMatch(tpDimDenyList.get(), dimension.location());
}

@Override
public boolean trueNameHasAmbit() {
return doesTrueNameHaveAmbit.get();
}

private static boolean isValidReslocArg(Object o) {
return o instanceof String s && ResourceLocation.isValidResourceLocation(s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public ClientCastingStack get() {
public static void tickClientPlayer(TickEvent.PlayerTickEvent evt) {
if (evt.side == LogicalSide.CLIENT && !evt.player.isDeadOrDying())
evt.player.getCapability(HexCapabilities.CLIENT_CASTING_STACK).resolve()
.get().get().tick();
.ifPresent(CastingStack -> CastingStack.get().tick());
}
}
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ pipeline {
}
stage('Publish') {
when {
anyOf {
allOf {
branch 'main'
not { changeRequest() }
}
}
stages {
Expand Down
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ subprojects {
}
}

allprojects { gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs << "-Xmaxerrs" << "1000" } } }
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000"
}
}

// disable most javadoc warnings
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
}

compileKotlin {
kotlinOptions {
Expand Down
Loading

0 comments on commit 9c29ab1

Please sign in to comment.