Created
March 1, 2025 13:32
-
-
Save EvanHsieh0415/2e897a84e3402f1412c659b4d5ca2718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ItemEntity = Java.loadClass("net.minecraft.world.entity.item.ItemEntity"); | |
global.recipes = global.recipes || {}; | |
/** @type {[ingredient: $Ingredient_, result: $ItemStack_][]} */ | |
global.recipes["portal_to_alfheim"] = [ | |
["#c:raw_materials/gold", "2x minecraft:gold_ingot"], | |
["#c:raw_materials/iron", "2x minecraft:iron_ingot"], | |
["#c:raw_materials/copper", "2x minecraft:copper_ingot"], | |
["nether_star", "nether_star"], | |
]; | |
global.functions = global.functions || {}; | |
/** @param {$Entity_} entity @returns {$SHOULDTP_} */ | |
global.functions["portal_to_alfheim"] = (entity) => { | |
if (entity instanceof ItemEntity) { | |
let { item } = entity; | |
for (let [ingredient, output] of global.recipes["portal_to_alfheim"]) { | |
if (Ingredient.of(ingredient).test(item)) { | |
let outputStack = Item.of(output); | |
entity.item = outputStack.withCount(item.count * outputStack.count); | |
break; | |
} | |
} | |
} | |
return ShouldTP.CANCEL; | |
}; | |
PortalEvents.register((event) => { | |
event | |
.create() | |
.frameBlock("minecraft:cherry_log") | |
.lightWithWater() | |
.tint(Color.LIME_DYE.rgb) | |
.beforeTeleportation((entity) => global.functions["portal_to_alfheim"](entity)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment