Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build & Publish Bedrock Addon

permissions:
contents: write

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Package mcaddon
run: |
VERSION=${{ github.event.release.tag_name }}
OUTPUT="Canopy-${VERSION}.mcaddon"

mkdir build
cp -r "Canopy [BP]" "build/Canopy[BP]"
cp -r "Canopy [RP]" "build/Canopy[RP]"
cp LICENSE "build/Canopy[BP]"
cp LICENSE "build/Canopy[RP]"

cd build
zip -r "$OUTPUT" "Canopy[BP]" "Canopy[RP]"
mv "$OUTPUT" ..
cd ..

- name: Upload asset to GitHub Release
uses: softprops/action-gh-release@e798e6a1ede8d07b74ac4cdac6bdfa4cc1653907
with:
files: Canopy-${{ github.event.release.tag_name }}.mcaddon
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload to CurseForge
run: |
VERSION=${{ github.event.release.tag_name }}

# Read the game version from manifest.json
MIN_ENGINE_VERSION=$(jq -r '.header.min_engine_version | @csv' "Canopy [BP]/manifest.json")
IFS=',' read -r LEADING MAJOR MINOR <<< "$MIN_ENGINE_VERSION"
ENGINE_PREFIX="${MAJOR}.${MINOR}"

# Fetch all Bedrock versions from CurseForge API
CF_VERSIONS_JSON=$(curl -s -H "X-Api-Token: ${{ secrets.CF_API_TOKEN }}" \
"https://minecraft-bedrock.curseforge.com/api/game/versions")

# Extract all game version IDs whose name matches the game version from the manifest.json
GAME_VERSION_IDS=$(echo "$CF_VERSIONS_JSON" | jq -c --arg prefix "$ENGINE_PREFIX" '
[ .[] | select(.name | startswith($prefix)) | .id ]
')
if [ -z "$GAME_VERSION_IDS" ]; then
echo "No matching CurseForge versions found for engine prefix $ENGINE_PREFIX"
exit 1
fi
echo "Found CurseForge version IDs for game version $ENGINE_PREFIX: $GAME_VERSION_IDS"

# Use the Github release body as the changelog
CHANGELOG=$(jq -Rs . <<< "${{ github.event.release.body }}")
ADDON_FILENAME=Canopy-$VERSION.mcaddon

# Upload the addon
RESPONSE=$(curl -s -X POST \
-H "X-Api-Token: ${{ secrets.CF_API_TOKEN }}" \
-F "metadata={
\"changelog\": $CHANGELOG,
\"changelogType\": \"markdown\",
\"displayName\": \"$ADDON_FILENAME\",
\"releaseType\": \"release\",
\"gameVersions\": $GAME_VERSION_IDS
}" \
-F "file=@$ADDON_FILENAME" \
https://minecraft-bedrock.curseforge.com/api/projects/1062078/upload-file
)

UPLOADED_ID=$(echo "$RESPONSE" | jq -r '.id // empty')
if [ -n "$UPLOADED_ID" ]; then
echo "Successfully uploaded release. File ID: $UPLOADED_ID"
else
echo "Upload failed. Response:"
echo "$RESPONSE"
exit 1
fi
6 changes: 3 additions & 3 deletions Canopy [BP]/manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"format_version": 2,
"header": {
"name": "Canopy [BP] v1.5.3",
"name": "Canopy [BP] v1.5.4",
"description": "Technical informatics & features addon by §aForestOfLight§r.",
"uuid": "7f6b23df-a583-476b-b0e4-87457e65f7c0",
"version": [1, 5, 3],
"version": [1, 5, 4],
"min_engine_version": [1, 26, 0]
},
"modules": [
Expand Down Expand Up @@ -38,7 +38,7 @@
},
{
"uuid": "bcf34368-ed0c-4cf7-938e-582cccf9950d",
"version": [1, 5, 3]
"version": [1, 5, 4]
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion Canopy [BP]/scripts/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const PACK_VERSION = '1.5.3';
const PACK_VERSION = '1.5.4';
const MC_VERSION = '1.26.0.2';

export { PACK_VERSION, MC_VERSION };
1 change: 1 addition & 0 deletions Canopy [BP]/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import './src/rules/chunkBorders'
import './src/rules/echoShardsEnableShriekers'
import './src/rules/collisionBoxes'
import './src/rules/potionBoostedBreeding'
import './src/rules/serverSideCollisionBoxes'

// Load Time Processes
import './src/onStart'
Expand Down
6 changes: 3 additions & 3 deletions Canopy [BP]/scripts/src/classes/BiomeEdgeRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class BiomeEdgeRenderer {
changeInFinalAxis[finalAxis] = quadHeight;
const bound = new Vector(...changeInMiddleAxis).add(new Vector(...changeInFinalAxis));

const worldLocation = Vector.from(this.blockVolume.getMin()).add(bound.multiply(0.5)).add(new Vector(...localLocation));
const worldLocation = Vector.from(this.blockVolume.getMin()).add(new Vector(...localLocation));
worldLocation.dimension = this.dimension;
const sidedBox = new DebugBox(worldLocation);
sidedBox.bound = bound;
Expand Down Expand Up @@ -168,7 +168,7 @@ export class BiomeEdgeRenderer {
}

renderAnalysisLocation(location) {
const dimensionLocation = Vector.from(location).add(new Vector(0.5, 0.5, 0.5));
const dimensionLocation = Vector.from(location);
dimensionLocation.dimension = this.dimension;
const tempBox = new DebugBox(dimensionLocation);
tempBox.color = { red: 1, green: 1, blue: 1 };
Expand All @@ -181,7 +181,7 @@ export class BiomeEdgeRenderer {
drawAnalysisBoundingBox() {
if (this.analysisBoundingBoxShape)
this.analysisBoundingBoxShape.remove();
const dimensionLocation = Vector.from(this.blockVolume.getMin()).add(Vector.from(this.blockVolume.getSpan()).multiply(0.5));
const dimensionLocation = Vector.from(this.blockVolume.getMin());
dimensionLocation.dimension = this.dimension;
const boundingBox = new DebugBox(dimensionLocation);
boundingBox.bound = this.blockVolume.getSpan();
Expand Down
22 changes: 12 additions & 10 deletions Canopy [BP]/scripts/src/classes/GeneratorChannel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ItemCounterChannel from "./ItemCounterChannel";
import { world, ItemStack } from "@minecraft/server";
import { world, BlockComponentTypes, ItemStack } from "@minecraft/server";

class GeneratorChannel extends ItemCounterChannel {
constructor(color) {
Expand All @@ -22,17 +22,19 @@ class GeneratorChannel extends ItemCounterChannel {
const generatedItems = [];
for (const hopperGenerator of this.hopperList) {
const hopper = world.getDimension(hopperGenerator.dimensionId).getBlock(hopperGenerator.location);
if (!hopper) continue;
const hopperContainer = hopper.getComponent('minecraft:inventory').container;
const itemStack = hopperContainer?.getItem(0);
if (itemStack) {
hopperGenerator.outputItemType = itemStack.typeId;
hopperGenerator.outputItemAmount = itemStack.amount;
if (!hopper)
continue;
const hopperContainer = hopper.getComponent(BlockComponentTypes.Inventory)?.container;
const itemStackToClone = hopperContainer?.getItem(0);
if (itemStackToClone) {
hopperGenerator.outputItemStack = itemStackToClone;
} else {
if (hopperGenerator.outputItemType === null)
if (!(hopperGenerator.outputItemStack instanceof ItemStack))
continue;
hopperContainer.setItem(0, new ItemStack(hopperGenerator.outputItemType));
generatedItems.push({ typeId: hopperGenerator.outputItemType, amount: 1 });
const generatedItemStack = hopperGenerator.outputItemStack.clone();
generatedItemStack.amount = 1;
hopperContainer.setItem(0, generatedItemStack);
generatedItems.push({ typeId: generatedItemStack.typeId, amount: 1 });
}
}
return generatedItems;
Expand Down
2 changes: 1 addition & 1 deletion Canopy [BP]/scripts/src/classes/HSSFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class HSSFinder {
const top = this.findStructureTop(dimension, flooredLocation, "minecraft:fortress");
const height = top.y - bottom.y + 1;

const dimensionLocation = bottom.add(new Vector(0.5, height * 0.5, 0.5));
const dimensionLocation = bottom;
dimensionLocation.dimension = dimension;
const box = new DebugBox(dimensionLocation);
box.bound = new Vector(1, height, 1);
Expand Down
4 changes: 2 additions & 2 deletions Canopy [BP]/scripts/src/classes/HSSRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class HSSRenderer {
}

renderBoundingBox() {
const dimensionLocation = this.structureBounds.getCenterpoint();
const dimensionLocation = this.structureBounds.getMin();
dimensionLocation.dimension = this.dimension;
const box = new DebugBox(dimensionLocation);
box.bound = this.structureBounds.getSize();
Expand All @@ -37,7 +37,7 @@ export class HSSRenderer {
}

renderSingleHSS(location) {
const bottom = new Vector(location.x + 0.5, this.structureBounds.getCenterpoint().y, location.z + 0.5);
const bottom = new Vector(location.x, this.structureBounds.getMin().y, location.z);
bottom.dimension = this.dimension;
const box = new DebugBox(bottom);
box.bound = new Vector(1, this.structureBounds.getSize().y, 1);
Expand Down
8 changes: 6 additions & 2 deletions Canopy [BP]/scripts/src/classes/debugdisplay/AttackBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export class AttackBox extends DebugDisplayShapeElement {
if (isProjectile) {
const marginFromCenter = this.getProjectileMargin();
return {
location: new Vector(0, AABB.extent.y, 0),
location: Vector.from(AABB.center).subtract(marginFromCenter),
size: marginFromCenter.multiply(2)
};
}
const marginFromCollisionBox = new Vector(0.8, 0, 0.8);
return {
location: new Vector(0, AABB.extent.y, 0),
location: new Vector(-AABB.extent.x, 0, -AABB.extent.z).subtract(marginFromCollisionBox),
size: Vector.from(AABB.extent).add(marginFromCollisionBox).multiply(2)
};
}
Expand All @@ -53,4 +53,8 @@ export class AttackBox extends DebugDisplayShapeElement {
return true;
return meleeMobs.includes(this.entity.typeId.replace("minecraft:", ""));
}

getClientSideLocation() {
return this.getAttackBox().location;
}
}
6 changes: 5 additions & 1 deletion Canopy [BP]/scripts/src/classes/debugdisplay/CollisionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ export class CollisionBox extends DebugDisplayShapeElement {
getCollisionBox() {
const AABB = this.entity.getAABB();
return {
location: new Vector(0, AABB.extent.y, 0),
location: new Vector(-AABB.extent.x, 0, -AABB.extent.z),
size: Vector.from(AABB.extent).multiply(2)
};
}

getClientSideLocation() {
return this.getCollisionBox().location;
}
}
15 changes: 15 additions & 0 deletions Canopy [BP]/scripts/src/classes/debugdisplay/DebugDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ export class DebugDisplay {
return entityToDebugDisplayMap[entity.id];
}

static refreshAllElements() {
for (const debugDisplay of Object.values(entityToDebugDisplayMap)) {
const propertiesToRefresh = [];
for (const element of debugDisplay.getEnabledElements()) {
const property = Object.entries(debugableProperties).find(([, cls]) => element instanceof cls)?.[0];
if (property)
propertiesToRefresh.push(property);
}
for (const property of propertiesToRefresh) {
debugDisplay.removeElement(property);
debugDisplay.addElement(property);
}
};
}

static getDebugableProperties() {
return Object.keys(debugableProperties);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { debugDrawer } from "@minecraft/debug-utilities";
import { DebugDisplayElement } from "./DebugDisplayElement";
import { system } from "@minecraft/server";
import { Rules } from "../../../lib/canopy/Canopy";

export class DebugDisplayShapeElement extends DebugDisplayElement {
shapes = [];
visibleToPlayer;
serverSidePositionRunner = void 0;

constructor(entity, visibleToPlayer = void 0) {
super(entity);
Expand All @@ -15,6 +18,7 @@ export class DebugDisplayShapeElement extends DebugDisplayElement {

destroy() {
this.clearShapes();
this.stopServerSidePositionRendering();
}

createShapes() {
Expand All @@ -23,10 +27,11 @@ export class DebugDisplayShapeElement extends DebugDisplayElement {

clearShapes() {
this.shapes.forEach(shape => debugDrawer.removeShape(shape));
this.shapes.length = 0;
}

drawShape(debugShape) {
debugShape.attachedTo = this.entity;
this.setupPosition(debugShape);
if (this.visibleToPlayer)
debugShape.visibleTo = [this.visibleToPlayer];
this.shapes.push(debugShape);
Expand All @@ -36,4 +41,30 @@ export class DebugDisplayShapeElement extends DebugDisplayElement {
update() {
throw new Error("Method 'update()' must be implemented.");
}

getClientSideLocation() {
throw new Error("Method 'getClientSideLocation()' must be implemented.");
}

setupPosition(debugShape) {
if (Rules.getNativeValue('serverSideCollisionBoxes')) {
this.serverSidePositionRunner = system.runInterval(() => this.updateServerSidePosition());
} else {
this.stopServerSidePositionRendering();
debugShape.attachedTo = this.entity;
}
}

updateServerSidePosition() {
const dimensionLocation = this.getClientSideLocation().add(this.entity.location);
dimensionLocation.dimension = this.entity.dimension;
this.shapes.forEach((debugShape) => debugShape.setLocation(dimensionLocation));
}

stopServerSidePositionRendering() {
if (this.serverSidePositionRunner !== void 0) {
system.clearRun(this.serverSidePositionRunner);
this.serverSidePositionRunner = void 0;
}
}
}
6 changes: 5 additions & 1 deletion Canopy [BP]/scripts/src/classes/debugdisplay/EyeLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ export class EyeLevel extends DebugDisplayShapeElement {
getEyeLevelBoxBounds() {
const AABB = this.entity.getAABB();
return {
location: new Vector(0, this.entity.getHeadLocation().y - this.entity.location.y, 0),
location: new Vector(-AABB.extent.x, this.entity.getHeadLocation().y - this.entity.location.y, -AABB.extent.z),
size: new Vector(AABB.extent.x * 2, 0, AABB.extent.z * 2)
}
}

getClientSideLocation() {
return this.getEyeLevelBoxBounds().location;
}
}
6 changes: 5 additions & 1 deletion Canopy [BP]/scripts/src/classes/debugdisplay/HitBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class HitBox extends DebugDisplayShapeElement {
const AABB = this.entity.getAABB();
const marginFromCollisionBox = this.getMargin();
return {
location: new Vector(0, AABB.extent.y, 0),
location: new Vector(-AABB.extent.x, 0, -AABB.extent.z).subtract(marginFromCollisionBox),
size: Vector.from(AABB.extent).add(marginFromCollisionBox).multiply(2)
};
}
Expand All @@ -36,4 +36,8 @@ export class HitBox extends DebugDisplayShapeElement {
return new Vector(1, 1, 1);
return new Vector(0.1, 0.1, 0.1);
}

getClientSideLocation() {
return this.getHitBox().location;
}
}
Loading
Loading