Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom wood types #1008

Open
Beelover20 opened this issue Feb 26, 2025 · 4 comments
Open

Custom wood types #1008

Beelover20 opened this issue Feb 26, 2025 · 4 comments
Labels
question Further information is requested

Comments

@Beelover20
Copy link

I'm trying to add a custom wood type, and I have the log and the stripped log, is there a way to have the axe automatically strip the log

@Beelover20 Beelover20 added the question Further information is requested label Feb 26, 2025
@MinecraftBedrockArabic
Copy link
Contributor

you can use the Scripting API along with block permutation and item custom components.
use BAO server https://discord.gg/7fNyT533 for directly providing help.

@Beelover20
Copy link
Author

Beelover20 commented Feb 26, 2025 via email

@Beelover20
Copy link
Author

Beelover20 commented Feb 27, 2025 via email

@Beelover20
Copy link
Author

can you check this code to see that it`ll allow me to strip my wood:
let system = server.registerSystem(0, 0);

system.initialize = function() {
// Map of custom log types to their stripped counterparts
this.logMappings = {
"bee:endergrove_log": "bee:stripped_endergrove_log",
// Add more custom log types and their stripped versions here
"bee:another_custom_log": "bee:stripped_another_custom_log"
};

// Listen for block interaction events
this.listenForEvent("minecraft:block_interact", (eventData) => this.onBlockInteract(eventData));

};

system.onBlockInteract = function(eventData) {
// Get the item the player is holding and the block the player is interacting with
let item_in_hand = eventData.data.item;
let block_pos = eventData.data.block_position;

// Get the block name the player is interacting with
let block_state = this.getBlockStateAt(block_pos);

// Check if the player is holding an axe and interacting with a custom log block
if (item_in_hand && this.isAxe(item_in_hand) && block_state) {
    let logBlock = block_state.name;

    // Check if there's a mapping for this custom log type to its stripped version
    if (this.logMappings[logBlock]) {
        // Replace the block with the stripped version
        this.setBlockState(block_pos, this.logMappings[logBlock]);
    }
}

};

// Check if the item in hand is an axe (checks for axe in the item id)
system.isAxe = function(item) {
return item.id.includes("axe");
};

// Get the block state at a specific position
system.getBlockStateAt = function(position) {
let block = this.getBlockAt(position);
return block ? block.getComponent("minecraft:description") : null;
};

// Set a new block state at a specific position
system.setBlockState = function(position, block_identifier) {
let block = this.createBlockState(block_identifier);
this.setBlockAt(position, block);
};

// Helper to set the block at a position
system.setBlockAt = function(position, block) {
this.world.setBlock(position, block);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants