Skip to content

Commit

Permalink
Merge pull request #61 from HiveGamesOSS/develop
Browse files Browse the repository at this point in the history
1.1.3
  • Loading branch information
clankstar authored Sep 30, 2024
2 parents 06917aa + d24dc3f commit ac2a40f
Show file tree
Hide file tree
Showing 42 changed files with 521 additions and 85 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4

- name: Mark Gradle as Executable
run: chmod +x gradlew
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4

- name: Build with Gradle Wrapper
run: ./gradlew build -x test
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4

- name: Mark Gradle as Executable
run: chmod +x gradlew
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_test_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4

- name: Mark Gradle as Executable
run: chmod +x gradlew
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-submission.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
distribution: 'temurin'

- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4.0.1
uses: gradle/actions/dependency-submission@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4

- name: Mark Gradle as Executable
run: chmod +x gradlew
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4

- name: Build with Gradle Wrapper
run: ./gradlew build -x test
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4

- name: Mark Gradle as Executable
run: chmod +x gradlew
Expand Down
4 changes: 2 additions & 2 deletions app/electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chunker-electron",
"version": "1.1.2",
"version": "1.1.3",
"description": "Convert worlds between Java and Bedrock.",
"private": true,
"main": "src/index.js",
Expand All @@ -14,7 +14,7 @@
"author": "Hive Games Limited",
"license": "MIT",
"devDependencies": {
"electron": "32.0.2",
"electron": "32.1.0",
"electron-builder": "25.0.5",
"git-last-commit": "^1.0.1"
},
Expand Down
28 changes: 13 additions & 15 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"author": "Hive Games Limited",
"license": "MIT",
"devDependencies": {
"concurrently": "^9.0.0",
"concurrently": "^9.0.1",
"cross-env": "^7.0.3",
"wait-on": "^8.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion app/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2",
"react-scripts": "^5.0.1",
"react-select": "^5.8.0",
"react-select": "^5.8.1",
"react-syntax-highlighter": "^15.5.0",
"seedrandom": "^3.0.5"
},
Expand Down
2 changes: 1 addition & 1 deletion cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
}

group = "com.hivemc.chunker"
version = "1.1.2"
version = "1.1.3"
description = "chunker"
base.archivesName = "chunker-cli"
java.sourceCompatibility = JavaVersion.VERSION_17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.hivemc.chunker.conversion.intermediate.column.blockentity.UnknownBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.chunk.ChunkerChunk;
import com.hivemc.chunker.conversion.intermediate.column.chunk.identifier.ChunkerBlockIdentifier;
import com.hivemc.chunker.conversion.intermediate.column.chunk.identifier.ChunkerItemStackIdentifierType;
import com.hivemc.chunker.conversion.intermediate.column.chunk.identifier.type.block.ChunkerBlockType;
import com.hivemc.chunker.conversion.intermediate.column.chunk.itemstack.ChunkerItemStack;
import com.hivemc.chunker.conversion.intermediate.column.chunk.palette.Palette;
Expand Down Expand Up @@ -188,6 +189,31 @@ public <T extends BlockEntity> T updateBeforeProcess(ChunkerColumn column, int x
return blockEntity;
}

/**
* Update any block entities which need updating before the item stack is processed.
*
* @param itemCompoundTag the compound tag of the item which was used to make the block entity.
* @param chunkerItemStack the output item stack.
* @param blockEntity the block entity.
* @param <T> the type of the block entity.
* @return the new block entity which should replace the old one.
*/
public <T extends BlockEntity> T updateBeforeProcess(CompoundTag itemCompoundTag, ChunkerItemStack chunkerItemStack, T blockEntity) {
Optional<TypeHandler<R, String, D, ? extends BlockEntity>> lastHandler = getFromTypeHandler(blockEntity);
if (lastHandler.isEmpty()) return blockEntity; // Don't update

// Find the handlers to call
Collection<UpdateBeforeProcessBlockEntityHandler<R, T>> handlers = getInterfaceHandlers(UpdateBeforeProcessBlockEntityHandler.class, lastHandler.get());
if (handlers.isEmpty()) return blockEntity; // Don't update

// Run each handler
for (UpdateBeforeProcessBlockEntityHandler<R, T> handler : handlers) {
blockEntity = handler.updateBeforeProcess(resolvers, itemCompoundTag, chunkerItemStack, blockEntity);
}

return blockEntity;
}

/**
* Update any block entities which need updating before the column is written.
*
Expand Down Expand Up @@ -215,6 +241,31 @@ public <T extends BlockEntity> T updateBeforeWrite(ChunkerColumn column, int x,
return blockEntity;
}

/**
* Update any block entities which need updating before an item stack is written.
*
* @param itemCompoundTag the output compound tag of the item which is about to be written.
* @param chunkerItemStack the input item stack.
* @param blockEntity the block entity.
* @param <T> the type of the block entity.
* @return the new block entity which should replace the old one.
*/
public <T extends BlockEntity> T updateBeforeWrite(CompoundTag itemCompoundTag, ChunkerItemStack chunkerItemStack, T blockEntity) {
Optional<TypeHandler<R, String, D, ? extends BlockEntity>> lastHandler = getFromTypeHandler(blockEntity);
if (lastHandler.isEmpty()) return blockEntity; // Don't update

// Find the handlers to call
Collection<UpdateBeforeWriteBlockEntityHandler<R, T>> handlers = getInterfaceHandlers(UpdateBeforeWriteBlockEntityHandler.class, lastHandler.get());
if (handlers.isEmpty()) return blockEntity; // Don't update

// Run each handler
for (UpdateBeforeWriteBlockEntityHandler<R, T> handler : handlers) {
blockEntity = handler.updateBeforeWrite(resolvers, itemCompoundTag, chunkerItemStack, blockEntity);
}

return blockEntity;
}

/**
* Attempt to use block entity specific handlers to read NBT, run after normal decoding.
*
Expand Down Expand Up @@ -420,4 +471,8 @@ public Optional<BlockEntity> to(D input) {
// Otherwise return the original
return result;
}

public Optional<Class<? extends BlockEntity>> getBlockEntityClass(ChunkerItemStackIdentifierType itemStackType) {
return itemStackType.getBlockEntityClass();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.hivemc.chunker.conversion.intermediate.column.ChunkerColumn;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.BlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.chunk.itemstack.ChunkerItemStack;
import com.hivemc.chunker.nbt.tags.collection.CompoundTag;
import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -12,7 +14,7 @@
*/
public interface UpdateBeforeProcessBlockEntityHandler<R, T extends BlockEntity> {
/**
* Update a block entity before processing.
* Update a block entity before processing (when it's in the world).
*
* @param resolvers the resolvers which can be used by this type.
* @param column the column which the block entity is inside.
Expand All @@ -23,4 +25,15 @@ public interface UpdateBeforeProcessBlockEntityHandler<R, T extends BlockEntity>
* @return the updated copy of the block entity.
*/
T updateBeforeProcess(@NotNull R resolvers, ChunkerColumn column, int x, int y, int z, T blockEntity);

/**
* Update a block entity before processing (when it's an item).
*
* @param resolvers the resolvers which can be used by this type.
* @param itemCompoundTag the compound tag of the item which was used to make the block entity.
* @param chunkerItemStack the output item stack.
* @param blockEntity the block entity.
* @return the updated copy of the block entity.
*/
T updateBeforeProcess(@NotNull R resolvers, CompoundTag itemCompoundTag, ChunkerItemStack chunkerItemStack, T blockEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.hivemc.chunker.conversion.intermediate.column.ChunkerColumn;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.BlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.chunk.itemstack.ChunkerItemStack;
import com.hivemc.chunker.nbt.tags.collection.CompoundTag;
import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -12,7 +14,7 @@
*/
public interface UpdateBeforeWriteBlockEntityHandler<R, T extends BlockEntity> {
/**
* Update a block entity before writing.
* Update a block entity before writing (when it's in the world).
*
* @param resolvers the resolvers which can be used by this type.
* @param column the column which the block entity is inside.
Expand All @@ -24,6 +26,17 @@ public interface UpdateBeforeWriteBlockEntityHandler<R, T extends BlockEntity> {
*/
T updateBeforeWrite(@NotNull R resolvers, ChunkerColumn column, int x, int y, int z, T blockEntity);

/**
* Update a block entity before writing (when it's an item).
*
* @param resolvers the resolvers which can be used by this type.
* @param itemCompoundTag the output compound tag of the item which is about to be written.
* @param chunkerItemStack the input item stack.
* @param blockEntity the block entity being updated.
* @return the updated copy of the block entity.
*/
T updateBeforeWrite(@NotNull R resolvers, CompoundTag itemCompoundTag, ChunkerItemStack chunkerItemStack, T blockEntity);

/**
* Get an additional type that is handled by this block entity. This is registered to the type handlers so that
* format specific block entities are still handled as every block entity needs a final type handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
import com.hivemc.chunker.conversion.intermediate.column.blockentity.container.EnderChestBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.container.HopperBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.container.SmokerBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.container.randomizable.BarrelBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.container.randomizable.DispenserBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.container.randomizable.DropperBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.container.randomizable.TrappedChestBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.container.randomizable.*;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.end.EndPortalBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.sculksensor.CalibratedSculkSensorBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.blockentity.sign.HangingSignBlockEntity;
import com.hivemc.chunker.conversion.intermediate.column.chunk.identifier.ChunkerItemStackIdentifierType;
import com.hivemc.chunker.conversion.intermediate.column.chunk.identifier.type.block.ChunkerVanillaBlockType;
import com.hivemc.chunker.nbt.tags.collection.CompoundTag;

import java.util.Optional;
Expand Down Expand Up @@ -150,4 +149,13 @@ protected CompoundTag constructDataType(String key) {
public Optional<String> getKey(CompoundTag input) {
return input.getOptionalValue("id", String.class);
}

@Override
public Optional<Class<? extends BlockEntity>> getBlockEntityClass(ChunkerItemStackIdentifierType itemStackType) {
// Bedrock doesn't have trapped chest
if (itemStackType == ChunkerVanillaBlockType.TRAPPED_CHEST) {
return Optional.of(ChestBlockEntity.class);
}
return super.getBlockEntityClass(itemStackType);
}
}
Loading

0 comments on commit ac2a40f

Please sign in to comment.