Skip to content

Commit

Permalink
Merge branch 'main' into iotacastapi
Browse files Browse the repository at this point in the history
  • Loading branch information
object-Object authored Mar 20, 2024
2 parents c927496 + 65a0757 commit 4de3c09
Show file tree
Hide file tree
Showing 63 changed files with 535 additions and 346 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 @@ -16,6 +16,7 @@
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -65,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 All @@ -77,14 +80,29 @@ public final ServerLevel getWorld() {
return this.world;
}

public int maxOpCount() {
return HexConfig.server().maxOpCount();
}

/**
* Get the caster. Might be null!
* <p>
* Implementations should NOT rely on this in general, use the methods on this class instead.
* This is mostly for spells (flight, etc)
* @deprecated as of build 0.11.1-7-pre-619 you are recommended to use {@link #getCastingEntity}
*/
@Deprecated(since="0.11.1-7-pre-619")
@Nullable
public ServerPlayer getCaster() {
return getCastingEntity() instanceof ServerPlayer sp ? sp : null;
};

/**
* Gets the caster. Can be null if {@link #getCaster()} is also null
* @return the entity casting
*/
@Nullable
public abstract ServerPlayer getCaster();
public abstract LivingEntity getCastingEntity();

/**
* Get an interface used to do mishaps
Expand All @@ -96,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 @@ -111,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 @@ -168,15 +194,15 @@ public void postExecution(CastResult result) {
* Return whether this env can cast great spells.
*/
public boolean isEnlightened() {
var caster = this.getCaster();
if (caster == null)
return false;

var adv = this.world.getServer().getAdvancements().getAdvancement(modLoc("enlightenment"));
if (adv == null)
return false;

return caster.getAdvancements().getOrStartProgress(adv).isDone();
var caster = this.getCastingEntity();
if (caster instanceof ServerPlayer player)
return player.getAdvancements().getOrStartProgress(adv).isDone();

return false;
}

/**
Expand All @@ -186,9 +212,12 @@ public boolean isEnlightened() {
* positive.
*/
public long extractMedia(long cost) {
for (var extractMediaComponent : extractMedias)
for (var extractMediaComponent : preMediaExtract)
cost = extractMediaComponent.onExtractMedia(cost);
cost = extractMediaEnvironment(cost);
for (var extractMediaComponent : postMediaExtract)
cost = extractMediaComponent.onExtractMedia(cost);
return extractMediaEnvironment(cost);
return cost;
}

/**
Expand Down Expand Up @@ -243,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 @@ -274,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
Loading

0 comments on commit 4de3c09

Please sign in to comment.