add first patch
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
console.info("[SOCIETY] addBonemeal.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(["meadow:eriophorum_tall", "meadow:small_fir"], (e) => {
|
||||
const { player, item, server, block } = e;
|
||||
if (
|
||||
player.getHeldItem("main_hand") == "minecraft:bone_meal" &&
|
||||
!player.cooldowns.isOnCooldown(item)
|
||||
) {
|
||||
block.canSeeSky;
|
||||
player.getHeldItem("main_hand").count--;
|
||||
let crop = block.level.createEntity("minecraft:item");
|
||||
crop.x = block.x + Math.floor(Math.random() * 1.5) + 0.5;
|
||||
crop.y = block.y + 0.5;
|
||||
crop.z = block.z + Math.floor(Math.random() * 1.5) + 0.5;
|
||||
crop.item = Item.of(block.id);
|
||||
crop.spawn();
|
||||
block.level.spawnParticles(
|
||||
"minecraft:happy_villager",
|
||||
true,
|
||||
block.x + 0.5,
|
||||
block.y + 0.1,
|
||||
block.z + 0.5,
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
10,
|
||||
0.1
|
||||
);
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:item.bone_meal.use block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
global.addItemCooldown(player, item, 1);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
console.info("[SOCIETY] addExtractinatingRecipes.js loaded");
|
||||
|
||||
const validExtractinatorItems = [
|
||||
"society:relic_trove",
|
||||
"society:artifact_trove",
|
||||
"society:geode",
|
||||
"society:frozen_geode",
|
||||
"society:magma_geode",
|
||||
"society:omni_geode",
|
||||
];
|
||||
const processGeodeLootTable = (lootTable, block, server, doubled) => {
|
||||
let drops;
|
||||
let drop;
|
||||
("");
|
||||
lootTable.forEach((entry) => {
|
||||
if (Math.random() < entry.drop_chance) {
|
||||
drops = Ingredient.of(entry.drop).itemIds;
|
||||
drop = drops[Math.floor(Math.random() * drops.length)];
|
||||
block.popItemFromFace(Item.of(`1x ${drop}`), "up");
|
||||
if (doubled) {
|
||||
block.popItemFromFace(Item.of(`1x ${drop}`), "up");
|
||||
}
|
||||
}
|
||||
});
|
||||
server.runCommandSilent(
|
||||
`playsound twigs:block.schist_bricks.break block @a ${block.x} ${block.y} ${block.z} 0.3`
|
||||
);
|
||||
};
|
||||
|
||||
BlockEvents.rightClicked("extractinator:extractinator", (e) => {
|
||||
const { block, player, hand, item, server } = e;
|
||||
if (hand == "OFF_HAND") return;
|
||||
const heldItem = item.getId();
|
||||
if (!validExtractinatorItems.includes(heldItem)) return;
|
||||
global.extractinatorRecipes.forEach((recipe) => {
|
||||
if (heldItem == recipe.input) {
|
||||
if (player.isCrouching()) {
|
||||
for (let i = 0; i < item.count; i++) {
|
||||
server.scheduleInTicks(i * 4, () => {
|
||||
processGeodeLootTable(
|
||||
recipe.output,
|
||||
block,
|
||||
server,
|
||||
player.stages.has("the_red_and_the_black")
|
||||
);
|
||||
});
|
||||
}
|
||||
global.addItemCooldown(player, item.id, item.count);
|
||||
if (!player.isCreative()) item.count = 0;
|
||||
} else {
|
||||
processGeodeLootTable(
|
||||
recipe.output,
|
||||
block,
|
||||
server,
|
||||
player.stages.has("the_red_and_the_black")
|
||||
);
|
||||
if (!player.isCreative()) item.count--;
|
||||
global.addItemCooldown(player, item.id, 4);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
console.info("[SOCIETY] bankerBroken.js loaded");
|
||||
|
||||
BlockEvents.broken("numismatics:blaze_banker", (e) => {
|
||||
e.player.tell(Text.translatable("society.blaze_banker.break").red());
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked("numismatics:blaze_banker", (e) => {
|
||||
const { item, block, level, player } = e;
|
||||
|
||||
if (item.hasTag("minecraft:pickaxes")) {
|
||||
if (
|
||||
block.getEntityData().TrustListInv
|
||||
&& block.getEntityData().TrustListInv.Items.length > 0
|
||||
) {
|
||||
player.tell(
|
||||
Text.translatable("society.blaze_banker.break.not_empty").red()
|
||||
);
|
||||
} else level.destroyBlock(block.pos, true);
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked("create_central_kitchen:blaze_stove", (e) => {
|
||||
if (e.item.id === "create_central_kitchen:cooking_guide") e.cancel();
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
console.info("[SOCIETY] berryBushBroken.js loaded");
|
||||
|
||||
BlockEvents.leftClicked("society:berry_bush", (e) => {
|
||||
global.updateBerryBush(e.level, e.block);
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
console.info("[SOCIETY] blueprintsBlock.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("furniture:blueprints", (e) => {
|
||||
const { player, server, block } = e;
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:item.book.page_turn block @a ${block.x} ${block.y} ${block.z}`
|
||||
);
|
||||
server.runCommandSilent(
|
||||
`dialog ${player.username} show ${player.username} blueprints_choice_dialog_prompt`
|
||||
);
|
||||
e.cancel()
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
console.info("[SOCIETY] brainDamageBroken.js loaded");
|
||||
|
||||
BlockEvents.broken(
|
||||
["oreganized:lead_ore", "oreganized:deepslate_lead_ore", "oreganized:raw_lead_block"],
|
||||
(e) => {
|
||||
const { level, server, block, player } = e;
|
||||
if (player.stages.has("intro_to_algorithms"))
|
||||
server.scheduleInTicks(2, () => {
|
||||
const entities = level
|
||||
.getEntitiesWithin(AABB.ofBlock(block).inflate(2))
|
||||
.filter((f) => f.type == "minecraft:area_effect_cloud");
|
||||
entities.forEach((entity) => {
|
||||
entity.setRemoved("unloaded_to_chunk");
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
console.info("[SOCIETY] cancelTrophy.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("trofers:large_pillar", (e) => {
|
||||
if (e.player.isFake()) e.cancel();
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
// BlockEvents.rightClicked((e) => {
|
||||
// const { item, block, hand, server, player, level } = e;
|
||||
// if (player.getHeldItem("main_hand") == "whimsy_deco:paw_carpet" && hand != "OFF_HAND") {
|
||||
// let carpet = level.createEntity("whimsy_deco:paw_carpet_entity");
|
||||
// carpet.setPos(block.getX(), block.getY() + 1, block.getZ());
|
||||
|
||||
// let newNbt = carpet.getNbt();
|
||||
// newNbt.Rotation = [
|
||||
// NBT.f(global.rotationFromFacing(player.getHorizontalFacing())),
|
||||
// NBT.f(0),
|
||||
// ];
|
||||
// newNbt.CanUpdate = 0;
|
||||
// newNbt.NoGravity = 0;
|
||||
// carpet.setNbt(newNbt);
|
||||
// carpet.spawn();
|
||||
// server.runCommandSilent(
|
||||
// `playsound minecraft:block.wool.place block @a ${block.x} ${block.y} ${block.z}`
|
||||
// );
|
||||
// if (!player.isCreative()) item.shrink(1);
|
||||
// }
|
||||
// });
|
||||
@@ -0,0 +1,225 @@
|
||||
console.info("[SOCIETY] checkArtisanMachines.js loaded");
|
||||
|
||||
const idMap = new Map([
|
||||
["vinery:savanna_grape_seeds_red", "Red Savanna Grape Seeds"],
|
||||
["vinery:savanna_grape_seeds_white", "White Savanna Grape Seeds"],
|
||||
["vinery:taiga_grape_seeds_red", "Red Taiga Grape Seeds"],
|
||||
["vinery:taiga_grape_seeds_white", "White Taiga Grape Seeds"],
|
||||
["vinery:jungle_grape_seeds_red", "Red Jungle Grape Seeds"],
|
||||
["vinery:jungle_grape_seeds_white", "White Jungle Grape Seeds"],
|
||||
["minecraft:quartz", "Nether Quartz"],
|
||||
["society:canvas", "Artisan Canvas"],
|
||||
["vintagedelight:pepper_jam_mason_jar", "Pepper Preserves Jar"],
|
||||
["vintagedelight:gearo_berry_mason_jar", "Gearo Berries Preserves Jar"],
|
||||
["vintagedelight:sweet_berry_mason_jar", "Sweet Berries Preserves Jar"],
|
||||
["vintagedelight:glow_berry_mason_jar", "Glow Berries Preserves Jar"],
|
||||
["society:aged_glowing_wine", "Aged Sun-kissed Wine"],
|
||||
["society:aged_bottle_mojang_noir", "Aged Bottle of 'Mojang Noir'"],
|
||||
["society:aged_villagers_fright", "Aged Bottle of 'Villagers Fright'"],
|
||||
["society:aged_creepers_crush", "Aged Bottle of 'Creepers Crush'"],
|
||||
["society:aged_netherite_nectar", "Aged Iridium Nectar"],
|
||||
["society:aged_lilitu_wine", "Aged Miss Lilitus Wine"],
|
||||
["society:aged_whiskey_jamesons_malt", "Aged Jameson Malt Whisky"],
|
||||
["society:aged_whiskey_ak", "Aged AK Reserve"],
|
||||
["society:aged_whiskey_highland_hearth", "Aged Highland Hearth Signature"],
|
||||
["society:aged_whiskey_carrasconlabel", "Aged Carrasconlabel Heritage"],
|
||||
["society:aged_whiskey_cristelwalker", "Aged CristelWalker Original"],
|
||||
["society:aged_whiskey_lilitusinglemalt", "Aged Lilitu Single Malt"],
|
||||
["society:aged_whiskey_jojannik", "Aged JoJannik Select"],
|
||||
["society:aged_whiskey_maggoallan", "Double-Aged MaggoAllan"],
|
||||
["society:aged_whiskey_smokey_reverie", "Double-Aged Smokey Reverie"],
|
||||
["society:aged_buffalo_cheese_block", "Aged Buffalo Cheese Wheel"],
|
||||
["society:aged_amethyst_cheese_block", "Aged Amethyst Cheese Wheel"],
|
||||
["society:aged_grain_cheese_block", "Aged Grain Cheese Wheel"],
|
||||
["society:aged_sheep_cheese_block", "Aged Sheep Cheese Wheel"],
|
||||
["society:aged_warped_cheese_block", "Aged Warped Cheese Wheel"],
|
||||
["society:aged_goat_cheese_block", "Aged Goat Cheese Wheel"],
|
||||
["society:aged_cheese_block", "Aged Cheese Wheel"],
|
||||
["society:aged_beer_nettle", "Aged Nettle Beer"],
|
||||
["society:aged_beer_barley", "Aged Barley Beer"],
|
||||
["society:aged_beer_hops", "Aged Hops Beer"],
|
||||
["society:aged_beer_london", "Aged London Beer"],
|
||||
["society:aged_beer_attunecore", "Aged Attunecore Beer"],
|
||||
["society:aged_beer_haley", "Aged Haley Beer"],
|
||||
["society:aged_beer_oat", "Aged Oat Beer"],
|
||||
["society:aged_beer_wheat", "Aged Wheat Beer"],
|
||||
["society:double_aged_glowing_wine", "Double-Aged Sun-kissed Wine"],
|
||||
["society:double_aged_bottle_mojang_noir", "Double-Aged Bottle of 'Mojang Noir'"],
|
||||
["society:double_aged_villagers_fright", "Double-Aged Bottle of 'Villagers Fright'"],
|
||||
["society:double_aged_creepers_crush", "Double-Aged Bottle of 'Creepers Crush'"],
|
||||
["society:double_aged_netherite_nectar", "Double-Aged Iridium Nectar"],
|
||||
["society:double_aged_good_catawba", "Double-Aged Good Catawba"],
|
||||
["society:double_aged_lilitu_wine", "Double-Aged Miss Lilitus Wine"],
|
||||
["society:double_aged_whiskey_jamesons_malt", "Double-Aged Jameson Malt Whisky"],
|
||||
["society:double_aged_whiskey_ak", "Double-Aged AK Reserve"],
|
||||
["society:double_aged_whiskey_highland_hearth", "Double-Aged Highland Hearth Signature"],
|
||||
["society:double_aged_whiskey_carrasconlabel", "Double-Aged Carrasconlabel Heritage"],
|
||||
["society:double_aged_whiskey_cristelwalker", "Double-Aged CristelWalker Original"],
|
||||
["society:double_aged_whiskey_lilitusinglemalt", "Double-Aged Lilitu Single Malt"],
|
||||
["society:double_aged_whiskey_jojannik", "Double-Aged JoJannik Select"],
|
||||
["society:double_aged_whiskey_maggoallan", "Triple-Aged MaggoAllan"],
|
||||
["society:double_aged_whiskey_smokey_reverie", "Triple-Aged Smokey Reverie"],
|
||||
["society:double_aged_buffalo_cheese_block", "Double-Aged Buffalo Cheese Wheel"],
|
||||
["society:double_aged_amethyst_cheese_block", "Double-Aged Amethyst Cheese Wheel"],
|
||||
["society:double_aged_grain_cheese_block", "Double-Aged Grain Cheese Wheel"],
|
||||
["society:double_aged_sheep_cheese_block", "Double-Aged Sheep Cheese Wheel"],
|
||||
["society:double_aged_warped_cheese_block", "Double-Aged Warped Cheese Wheel"],
|
||||
["society:double_aged_goat_cheese_block", "Double-Aged Goat Cheese Wheel"],
|
||||
["society:double_aged_cheese_block", "Double-Aged Cheese Wheel"],
|
||||
["society:double_aged_beer_nettle", "Double-Aged Nettle Beer"],
|
||||
["society:double_aged_beer_barley", "Double-Aged Barley Beer"],
|
||||
["society:double_aged_beer_hops", "Double-Aged Hops Beer"],
|
||||
["society:double_aged_beer_london", "Double-Aged London Beer"],
|
||||
["society:double_aged_beer_haley", "Double-Aged Haley Beer"],
|
||||
["society:double_aged_beer_oat", "Double-Aged Oat Beer"],
|
||||
["society:double_aged_beer_wheat", "Double-Aged Wheat Beer"],
|
||||
]);
|
||||
|
||||
const sendProgressMessage = (clickEvent, recipes, nbt, stageCount, machineId, maxInput) => {
|
||||
const { player, block, item, server } = clickEvent;
|
||||
const blockStage = nbt.data.stage;
|
||||
const status = maxInput !== -1
|
||||
? Text.translatable("society.working_block_entity.more_input")
|
||||
: Text.translatable("society.working_block_entity.making");
|
||||
let primaryOutput;
|
||||
let recipe = nbt.data.recipe;
|
||||
let id;
|
||||
let duration;
|
||||
const isChargingRod = machineId.equals("society:charging_rod");
|
||||
if (!recipe && !isChargingRod) return;
|
||||
if (isChargingRod) {
|
||||
id = "society:battery";
|
||||
duration = stageCount;
|
||||
} else {
|
||||
id = String(Item.of(recipes.get(recipe).output[0]).id);
|
||||
primaryOutput = idMap.get(id);
|
||||
duration = recipes.get(recipe).time || stageCount;
|
||||
if (recipe === item) return;
|
||||
}
|
||||
if (
|
||||
machineId == "society:aging_cask" &&
|
||||
block.properties.get("upgraded").toLowerCase() === "true"
|
||||
) {
|
||||
duration = duration / 2;
|
||||
}
|
||||
const pipCount = maxInput !== -1 ? maxInput : Math.round(duration);
|
||||
if (!primaryOutput)
|
||||
primaryOutput = id.path.replace(/^_*(.)|_+(.)/g, (s, c, d) =>
|
||||
c ? c.toUpperCase() : " " + d.toUpperCase()
|
||||
);
|
||||
let outputString = "";
|
||||
for (let index = 0; index < pipCount; index++) {
|
||||
if (index < blockStage) outputString += "⬛";
|
||||
else outputString += "⬜";
|
||||
}
|
||||
let translatedPrimaryOutput = global.getTranslatedItemName(id, primaryOutput).noColor();
|
||||
|
||||
const upgrade = block.properties.get("upgraded").toLowerCase() == "true" ? `🡅` : "";
|
||||
global.renderUiText(
|
||||
player,
|
||||
server,
|
||||
{
|
||||
artisanMessage: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -90,
|
||||
text: `${status.toJson()}`,
|
||||
color: "#AAAAAA",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
artisanMessageShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -89,
|
||||
text: `${status.toJson()}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
artisanItemMessage: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -78,
|
||||
text: `${translatedPrimaryOutput.toJson()}`,
|
||||
color: "#FFAA00",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
artisanItemMessageShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -77,
|
||||
text: `${translatedPrimaryOutput.toJson()}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
artisanProgress: {
|
||||
type: "text",
|
||||
x: 1.5,
|
||||
y: -66,
|
||||
text: `§a${upgrade}§6 ${outputString} §a${upgrade}§r`,
|
||||
color: "#FFAA00",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
artisanProgressShadow: {
|
||||
type: "text",
|
||||
x: 1.5,
|
||||
z: -1,
|
||||
y: -66,
|
||||
text: `§a${upgrade}§0 ${"⬛".repeat(pipCount)} §a${upgrade}§r`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
},
|
||||
global.mainUiElementIds
|
||||
);
|
||||
};
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"society:bait_maker",
|
||||
"society:aging_cask",
|
||||
"society:ancient_cask",
|
||||
"society:charging_rod",
|
||||
"society:crystalarium",
|
||||
"society:wine_keg",
|
||||
"society:deluxe_worm_farm",
|
||||
"society:dehydrator",
|
||||
"society:espresso_machine",
|
||||
"society:fish_smoker",
|
||||
"society:loom",
|
||||
"society:mayonnaise_machine",
|
||||
"society:preserves_jar",
|
||||
"society:seed_maker",
|
||||
"society:tapper",
|
||||
"society:recycling_machine",
|
||||
"society:cheese_press",
|
||||
"society:oil_maker",
|
||||
"society:mushroom_log",
|
||||
],
|
||||
(e) => {
|
||||
const { block, hand, item } = e;
|
||||
if (hand == "OFF_HAND" || item !== "minecraft:air") return;
|
||||
const machine = global.artisanMachineDefinitions.filter((obj) => {
|
||||
return obj.id === block.id;
|
||||
})[0];
|
||||
if (block.properties.get("mature").toLowerCase() === "false") {
|
||||
let nbt = block.getEntityData();
|
||||
if (nbt.data.type == 0) return;
|
||||
sendProgressMessage(
|
||||
e,
|
||||
machine.recipes,
|
||||
nbt,
|
||||
machine.stageCount,
|
||||
machine.id,
|
||||
block.properties.get("working").toLowerCase() === "false" ? machine.maxInput : -1
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,83 @@
|
||||
console.info("[SOCIETY] checkAttributes.js loaded");
|
||||
|
||||
const shippingBinThrottle = ((temp) => (entity, tick, identifier) => {
|
||||
const { age, uuid } = entity;
|
||||
const key = `${uuid}${identifier}`;
|
||||
const now = temp[key];
|
||||
if (!now || age - now >= tick) {
|
||||
temp[key] = age;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})({});
|
||||
|
||||
BlockEvents.leftClicked(
|
||||
["shippingbin:shipping_bin", "shippingbin:basic_shipping_bin", "shippingbin:smart_shipping_bin"],
|
||||
(e) => {
|
||||
const { player, block, level } = e;
|
||||
let binPlayer;
|
||||
let playerAttributes;
|
||||
if (shippingBinThrottle(player, 30, "shipping-bin-throttle")) return;
|
||||
level.getServer().players.forEach((p) => {
|
||||
if (p.getUuid().toString() === block.getEntityData().data.owner) {
|
||||
playerAttributes = p.nbt.Attributes;
|
||||
binPlayer = p;
|
||||
}
|
||||
});
|
||||
if (playerAttributes) {
|
||||
let crop = playerAttributes.filter((obj) => {
|
||||
return obj.Name === "shippingbin:crop_sell_multiplier";
|
||||
});
|
||||
let gem = playerAttributes.filter((obj) => {
|
||||
return obj.Name === "shippingbin:gem_sell_multiplier";
|
||||
});
|
||||
let artisan = playerAttributes.filter((obj) => {
|
||||
return obj.Name === "shippingbin:wood_sell_multiplier";
|
||||
});
|
||||
let adventurer = playerAttributes.filter((obj) => {
|
||||
return obj.Name === "shippingbin:meat_sell_multiplier";
|
||||
});
|
||||
if (binPlayer) {
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"society.shipping_bin.owner",
|
||||
Text.of(`${binPlayer.username}`).gold()
|
||||
)
|
||||
);
|
||||
player.tell(Text.translatable("society.shipping_bin.sell_multipliers").gray());
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"society.shipping_bin.multiplier",
|
||||
Text.translatable("tooltip.society.farmer_product"),
|
||||
Text.green(`${crop[0] ? crop[0].Base : 1}`)
|
||||
)
|
||||
);
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"society.shipping_bin.multiplier",
|
||||
Text.translatable("tooltip.society.artisan_product"),
|
||||
Text.green(`${artisan[0] ? artisan[0].Base : 1}`)
|
||||
)
|
||||
);
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"society.shipping_bin.multiplier",
|
||||
Text.translatable("tooltip.society.geologist_product"),
|
||||
Text.green(`${gem[0] ? gem[0].Base : 1}`)
|
||||
)
|
||||
);
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"society.shipping_bin.multiplier",
|
||||
Text.translatable("tooltip.society.adventurer_product"),
|
||||
Text.green(`${adventurer[0] ? adventurer[0].Base : 1}`)
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
player.tell(
|
||||
Text.translatable("society.shipping_bin.offline").gray()
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,62 @@
|
||||
console.info("[SOCIETY] checkArtisanMachines.js loaded");
|
||||
|
||||
const maxManaMap = new Map([
|
||||
['society:mana_clock', 260000],
|
||||
['society:mana_sprinkler', 10000],
|
||||
['society:sparkstone_recycler', 250000],
|
||||
['society:mana_fruit_crop', 10000],
|
||||
['society:mana_milker', 4000]
|
||||
]);
|
||||
|
||||
const sendManaMessage = (clickEvent, nbt, machineId) => {
|
||||
const { player, block, server } = clickEvent;
|
||||
|
||||
const maxMana = maxManaMap.get(`${machineId}`);
|
||||
if (!maxMana) return;
|
||||
|
||||
const currentMana = nbt?.ForgeData?.mana || 0;
|
||||
const pipCount = 10;
|
||||
const filledPips = Math.min(pipCount, Math.floor((currentMana / maxMana) * pipCount));
|
||||
|
||||
let outputString = "";
|
||||
for (let index = 0; index < pipCount; index++) {
|
||||
if (index < filledPips) outputString += "⬛";
|
||||
else outputString += "⬜";
|
||||
}
|
||||
global.renderUiText(
|
||||
player,
|
||||
server,
|
||||
{
|
||||
botaniaMana: {
|
||||
type: "text",
|
||||
x: 1.5,
|
||||
y: -66,
|
||||
text: `${outputString}`,
|
||||
color: "#55FFFF",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
botaniaManaShadow: {
|
||||
type: "text",
|
||||
x: 1.5,
|
||||
z: -1,
|
||||
y: -66,
|
||||
text: `${"⬛".repeat(pipCount)}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
},
|
||||
global.mainUiElementIds
|
||||
);
|
||||
};
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
['society:mana_clock', 'society:mana_sprinkler', 'society:sparkstone_recycler', 'society:mana_fruit_crop', 'society:mana_milker'],
|
||||
(e) => {
|
||||
const { block, hand, item } = e;
|
||||
if (hand !== "MAIN_HAND" || item.id !== "botania:twig_wand") return;
|
||||
const nbt = block.getEntityData();
|
||||
sendManaMessage(e, nbt, block.id);
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,215 @@
|
||||
console.info("[SOCIETY] checkFishPond.js loaded");
|
||||
|
||||
const getRequestedItems = (type, population) => {
|
||||
let requestedItems = {};
|
||||
global.fishPondDefinitions.get(type).quests.forEach((quest) => {
|
||||
if (quest.population == population) {
|
||||
requestedItems = quest.requestedItems;
|
||||
}
|
||||
});
|
||||
return requestedItems;
|
||||
};
|
||||
|
||||
const sendFishPondMessage = (clickEvent, type, population, maxPopulation) => {
|
||||
const { player, block, server } = clickEvent;
|
||||
let fishName = type.path.replace(/^_*(.)|_+(.)/g, (s, c, d) =>
|
||||
c ? c.toUpperCase() : " " + d.toUpperCase()
|
||||
);
|
||||
if (fishName.includes("Raw ")) {
|
||||
if (fishName === "Raw Snowflake") fishName = "Frosty Fin";
|
||||
else fishName = fishName.substring(4, fishName.length);
|
||||
}
|
||||
let fishIcons = "";
|
||||
let translatedFishName = global.getTranslatedItemName(type, fishName);
|
||||
|
||||
for (let index = 0; index < maxPopulation; index++) {
|
||||
if (index < population) fishIcons += "§3⏳§r";
|
||||
else fishIcons += "§7⏳§r";
|
||||
}
|
||||
const upgrade =
|
||||
block.properties.get("upgraded").toLowerCase() == "true" ? `🡅` : "";
|
||||
const pondHeaderText = Text.empty()
|
||||
.gray()
|
||||
.append(Text.of(`==[ `))
|
||||
.append(Text.green(upgrade))
|
||||
.append(" ")
|
||||
.append(Text.translatable("block.society.fish_pond").darkAqua())
|
||||
.append(" ")
|
||||
.append(Text.green(upgrade))
|
||||
.append(Text.of(` ]==`));
|
||||
const pondHeaderTextShadow = Text.empty()
|
||||
.append(Text.of(`==[ `))
|
||||
.append(Text.of(upgrade))
|
||||
.append(" ")
|
||||
.append(Text.translatable("block.society.fish_pond"))
|
||||
.append(" ")
|
||||
.append(Text.of(upgrade))
|
||||
.append(Text.of(` ]==`));
|
||||
const fishNameText = Text.of(`${population}/${maxPopulation} `).append(translatedFishName);
|
||||
|
||||
global.renderUiText(
|
||||
player,
|
||||
server,
|
||||
{
|
||||
pondHeader: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -110,
|
||||
text: `${pondHeaderText.toJson()}`,
|
||||
color: "#AAAAAA",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
pondHeaderShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -109,
|
||||
text: `${pondHeaderTextShadow.toJson()}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
fishIcon: {
|
||||
type: "item",
|
||||
x: 8,
|
||||
y: -84,
|
||||
item: type,
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
fishName: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -78,
|
||||
text: `${fishNameText.toJson()}`,
|
||||
color: "#00AAAA",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
fishNameShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -77,
|
||||
text: `${fishNameText.toJson()}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
population: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -66,
|
||||
text: fishIcons,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
populationShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -65,
|
||||
text: `⏳`.repeat(maxPopulation),
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
},
|
||||
global.mainUiElementIds
|
||||
);
|
||||
};
|
||||
|
||||
BlockEvents.rightClicked("society:fish_pond", (e) => {
|
||||
const { item, hand, block, server, player } = e;
|
||||
if (hand == "OFF_HAND") return;
|
||||
if (!player.isCrouching()) {
|
||||
let { type, population, max_population, quest_id } =
|
||||
block.getEntityData().data;
|
||||
e.server.scheduleInTicks(1, () => {
|
||||
const properties = block.getProperties();
|
||||
const mature = properties.get("mature").toLowerCase();
|
||||
const valid = properties.get("valid").toLowerCase();
|
||||
const quest = properties.get("quest").toLowerCase();
|
||||
|
||||
if (mature == "false") {
|
||||
if (!type.equals("")) {
|
||||
sendFishPondMessage(e, type, population, max_population);
|
||||
} else if (!(item && item.hasTag("minecraft:fishes"))) {
|
||||
player.tell(
|
||||
Text.translatable("block.society.fish_pond.pond_is_empty").gray()
|
||||
);
|
||||
}
|
||||
if (!type.equals("") && item && item.hasTag("minecraft:fishes")) {
|
||||
if (type !== item.id)
|
||||
player.tell(
|
||||
Text.translatable("block.society.fish_pond.cross_type_fish").red()
|
||||
);
|
||||
}
|
||||
}
|
||||
if (mature === "false" && quest === "true") {
|
||||
let questContent = getRequestedItems(type, max_population)
|
||||
let questItem
|
||||
let checkedCount;
|
||||
if (item.id.equals('unusualfishmod:ripper_tooth')) {
|
||||
if (questContent) {
|
||||
if (questContent.length == 1) {
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"block.society.fish_pond.no_alt",
|
||||
).red()
|
||||
);
|
||||
|
||||
} else {
|
||||
let newQuest = questContent.length - 1 === Number(quest_id) ? 0 : Number(quest_id) + 1;
|
||||
questContent = questContent[newQuest];
|
||||
questItem = Item.of(questContent.item).displayName;
|
||||
checkedCount = player.stages.has("pond_house_five")
|
||||
? Math.round(questContent.count / 2)
|
||||
: questContent.count;
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"block.society.fish_pond.fish_quest_changed",
|
||||
Text.darkAqua(`${checkedCount}`)
|
||||
).green()
|
||||
);
|
||||
player.tell(questItem);
|
||||
let nbt = block.getEntityData();
|
||||
nbt.merge({
|
||||
data: {
|
||||
quest_id: Number(newQuest),
|
||||
},
|
||||
});
|
||||
global.setBlockEntityData(block, nbt)
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:entity.player.splash block @a ${block.x} ${block.y} ${block.z}`
|
||||
);
|
||||
if (!player.isCreative()) item.shrink(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
questContent = questContent[quest_id];
|
||||
if (questContent && questContent.item !== item.id) {
|
||||
questItem = Item.of(questContent.item).displayName;
|
||||
checkedCount = player.stages.has("pond_house_five")
|
||||
? Math.round(questContent.count / 2)
|
||||
: questContent.count;
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"block.society.fish_pond.fish_quest",
|
||||
Text.darkAqua(`${checkedCount}`)
|
||||
).green()
|
||||
);
|
||||
player.tell(questItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valid === "false") {
|
||||
player.tell(
|
||||
Text.translatable("block.society.fish_pond.not_valid").red()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
console.info("[SOCIETY] checkTapper.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(["society:tapper", "society:auto_tapper"], (e) => {
|
||||
const { level, block, player, server, hand } = e;
|
||||
if (hand == "OFF_HAND") return;
|
||||
let errorText;
|
||||
const attachedBlock = global.getTapperLog(level, block);
|
||||
if (global.hasMultipleTappers(level, block)) {
|
||||
errorText = Text.translatable(
|
||||
"block.society.tapper.too_many_tapper"
|
||||
).toJson();
|
||||
}
|
||||
if (!attachedBlock.hasTag("society:tappable_blocks")) {
|
||||
errorText = Text.translatable(
|
||||
"block.society.tapper.invalid_block"
|
||||
).toJson();
|
||||
}
|
||||
if (errorText) {
|
||||
global.renderUiText(
|
||||
player,
|
||||
server,
|
||||
{
|
||||
tapperMessage: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -90,
|
||||
text: `${errorText}`,
|
||||
color: "#FF5555",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
tapperMessageShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -89,
|
||||
text: `${errorText}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
},
|
||||
global.mainUiElementIds
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
console.info("[SOCIETY] compactingDrawerExploit.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"functionalstorage:compacting_drawer",
|
||||
"functionalstorage:simple_compacting_drawer",
|
||||
"functionalstorage:compacting_framed_drawer",
|
||||
"functionalstorage:framed_simple_compacting_drawer",
|
||||
],
|
||||
(e) => {
|
||||
const { item, player } = e;
|
||||
if (item.nbt && item.nbt.quality_food) {
|
||||
player.tell(Text.translatable("society.compacting_drawer.quality_item").red());
|
||||
e.cancel();
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,104 @@
|
||||
console.info("[SOCIETY] customBlockEntityBroken.js loaded");
|
||||
|
||||
const handleBrokenMachine = (block) => {
|
||||
const machine = global.artisanMachineDefinitions.filter((obj) => {
|
||||
return obj.id === block.id;
|
||||
})[0];
|
||||
if (!machine) return;
|
||||
let working = block.properties.get("working").toLowerCase() == "true";
|
||||
if (machine.upgrade && block.properties.get("upgraded").toLowerCase() == "true") {
|
||||
block.popItem(machine.upgrade);
|
||||
}
|
||||
const nbt = block.getEntityData();
|
||||
const currentRecipe = machine.recipes.get(nbt.data.recipe);
|
||||
if (block.properties.get("mature").toLowerCase() == "true") {
|
||||
currentRecipe.output.forEach((element) => {
|
||||
block.popItem(element);
|
||||
});
|
||||
if (
|
||||
block.id == "society:ancient_cask" &&
|
||||
block.properties.get("upgraded").toLowerCase() == "true"
|
||||
) block.popItem(Item.of(`3x ${Item.of(`${currentRecipe.output[0]}`).id}`));
|
||||
} else if (!["society:charging_rod", "society:tapper", "society:mushroom_log"].includes(block.id)) {
|
||||
let stage = Number(nbt.data.stage);
|
||||
if (
|
||||
currentRecipe &&
|
||||
block.id == "society:ancient_cask" &&
|
||||
block.properties.get("upgraded").toLowerCase() == "true"
|
||||
) {
|
||||
if (working) block.popItem(Item.of(`4x ${nbt.data.recipe}`));
|
||||
else block.popItem(Item.of(`${stage}x ${nbt.data.recipe}`));
|
||||
} else if (
|
||||
block.id == "society:deluxe_worm_farm" &&
|
||||
block.properties.get("upgraded").toLowerCase() == "true"
|
||||
) {
|
||||
// Do nothing because of infinity worm upgrade
|
||||
} else if (
|
||||
currentRecipe &&
|
||||
block.id == "society:preserves_jar" &&
|
||||
block.properties.get("upgraded").toLowerCase() == "true"
|
||||
) {
|
||||
if (working) block.popItem(Item.of(`3x ${nbt.data.recipe}`));
|
||||
else block.popItem(Item.of(`${stage}x ${nbt.data.recipe}`));
|
||||
} else if (currentRecipe) {
|
||||
if (nbt.data.originalInputs && nbt.data.originalInputs.length > 0) {
|
||||
nbt.data.originalInputs.forEach((item) => {
|
||||
block.popItem(Item.of(`${item.Count}x ${item.id}`));
|
||||
});
|
||||
} else {
|
||||
if (working) block.popItem(Item.of(`${machine.maxInput}x ${nbt.data.recipe}`));
|
||||
else block.popItem(Item.of(`${stage}x ${nbt.data.recipe}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
BlockEvents.broken(global.artisanMachineIds, (e) => {
|
||||
handleBrokenMachine(e.block);
|
||||
});
|
||||
|
||||
BlockEvents.broken("society:fish_pond", (e) => {
|
||||
const { block } = e;
|
||||
const nbt = block.getEntityData();
|
||||
if (nbt.data.type !== "") {
|
||||
block.popItem(
|
||||
Item.of(
|
||||
"society:fish_pond",
|
||||
`{type:"${nbt.data.type}",population:${Number(nbt.data.population)},max_population:${Number(
|
||||
nbt.data.max_population
|
||||
)},quest:${block.properties.get("quest")},quest_id:${Number(nbt.data.quest_id)}}`
|
||||
)
|
||||
);
|
||||
} else {
|
||||
block.popItem(Item.of("society:fish_pond"));
|
||||
}
|
||||
if (block.properties.get("upgraded").toLowerCase() == "true") {
|
||||
block.popItem(Item.of("society:sea_biscut"));
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.broken("society:prize_machine", (e) => {
|
||||
const nbt = e.block.getEntityData();
|
||||
e.block.popItem(Item.of("society:prize_machine", `{prize:${nbt.data.prize}}`));
|
||||
});
|
||||
|
||||
BlockEvents.broken("society:coin_leaderboard", (e) => {
|
||||
global.clearOldTextDisplay(e.block, e.level, "leaderboard");
|
||||
});
|
||||
|
||||
BlockEvents.broken("society:shipping_bin_monitor", (e) => {
|
||||
global.clearOldTextDisplay(e.block, e.level, "shipping_bin_monitor");
|
||||
});
|
||||
|
||||
BlockEvents.broken("society:fish_pond_basket", (e) => {
|
||||
const { block } = e;
|
||||
if (block.properties.get("upgraded").toLowerCase() == "true") {
|
||||
block.popItem(Item.of("minecraft:bucket"));
|
||||
}
|
||||
});
|
||||
BlockEvents.broken("society:auto_grabber", (e) => {
|
||||
const { block } = e;
|
||||
if (block.properties.get("upgraded").toLowerCase() == "true") {
|
||||
block.popItem(Item.of("society:magic_shears"));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
// DEPRECATED
|
||||
@@ -0,0 +1,13 @@
|
||||
console.info("[SOCIETY] disableDispenser.js loaded");
|
||||
|
||||
const DispenserBlock = Java.loadClass(
|
||||
"net.minecraft.world.level.block.DispenserBlock"
|
||||
);
|
||||
DispenserBlock.registerBehavior(Item.of("minecraft:bone_meal").item, () => {});
|
||||
DispenserBlock.registerBehavior(Item.of("minecraft:carrot").item, () => {});
|
||||
DispenserBlock.registerBehavior(Item.of("minecraft:potato").item, () => {});
|
||||
DispenserBlock.registerBehavior(Item.of("farm_and_charm:onion").item, () => {});
|
||||
DispenserBlock.registerBehavior(
|
||||
Item.of("veggiesdelight:sweet_potato").item,
|
||||
() => {}
|
||||
);
|
||||
@@ -0,0 +1,21 @@
|
||||
console.info("[SOCIETY] disableHoeRichSoil.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"farmersdelight:rich_soil",
|
||||
"vintagedelight:lush_grass_block",
|
||||
],
|
||||
(e) => {
|
||||
const hoes = [
|
||||
"minecraft:wooden_hoe",
|
||||
"minecraft:stone_hoe",
|
||||
"minecraft:iron_hoe",
|
||||
"minecraft:golden_hoe",
|
||||
"minecraft:diamond_hoe",
|
||||
"minecraft:netherite_hoe",
|
||||
"aquaculture:neptunium_hoe",
|
||||
'farm_and_charm:pitchfork'
|
||||
];
|
||||
if (hoes.includes(e.item.getId())) e.cancel()
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,15 @@
|
||||
console.info("[SOCIETY] disableQuarkMysticalFlowers.js loaded");
|
||||
|
||||
BlockEvents.rightClicked((e) => {
|
||||
if (e.block.hasTag("botania:mystical_flowers")) {
|
||||
e.cancel();
|
||||
}
|
||||
});
|
||||
BlockEvents.rightClicked((e) => {
|
||||
if (
|
||||
e.block.hasTag("dewdrop:waterable") &&
|
||||
e.level.getBlock(e.block.getPos().above()).hasTag("botania:mystical_flowers")
|
||||
) {
|
||||
e.cancel();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
// DEPRECATED
|
||||
@@ -0,0 +1,5 @@
|
||||
console.info("[SOCIETY] disableSaltSnowball.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("vintagedelight:salt", (e) => {
|
||||
if (e.player.isCrouching() || e.item.hasTag("forge:tools/shovels")) e.cancel();
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
console.info("[SOCIETY] disableSpawner.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("minecraft:spawner", (e) => {
|
||||
if (e.player.isCreative()) return;
|
||||
if (e.item.id.includes("spawn_egg")) e.cancel();
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked((e) => {
|
||||
if (e.player.isCreative()) return;
|
||||
if (
|
||||
e.level.dimension === "society:skull_cavern" &&
|
||||
e.block.hasTag("minecraft:rails") &&
|
||||
e.item.getId() == "create:minecart_contraption"
|
||||
) {
|
||||
e.cancel();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,197 @@
|
||||
console.info("[SOCIETY] enrichedBonemeal.js loaded");
|
||||
|
||||
const hasGreenhouseGlass = (level, cropPos) => {
|
||||
let scannedBlock;
|
||||
for (let i = 0; i < 16; i++) {
|
||||
scannedBlock = level.getBlock(cropPos.offset(0, i + 1, 0));
|
||||
if (scannedBlock.hasTag("sereneseasons:greenhouse_glass")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const rnd = (min, max) => {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
};
|
||||
|
||||
const cropDrop = [
|
||||
"herbalbrews:lavender",
|
||||
"herbalbrews:hibiscus",
|
||||
"farm_and_charm:wild_ribwort",
|
||||
"farm_and_charm:wild_nettle",
|
||||
];
|
||||
BlockEvents.rightClicked(cropDrop, (e) => {
|
||||
const { player, item, block, server } = e;
|
||||
if (
|
||||
player.getHeldItem("main_hand") == "society:enriched_bone_meal" &&
|
||||
!player.cooldowns.isOnCooldown(item)
|
||||
) {
|
||||
player.getHeldItem("main_hand").count--;
|
||||
let crop = block.level.createEntity("minecraft:item");
|
||||
crop.x = block.x + rnd(0, 0.5);
|
||||
crop.y = block.y + 0.5;
|
||||
crop.z = block.z + rnd(0, 0.5);
|
||||
crop.item = Item.of(block.id);
|
||||
crop.spawn();
|
||||
block.level.spawnParticles(
|
||||
"minecraft:happy_villager",
|
||||
true,
|
||||
block.x + 0.5,
|
||||
block.y + 0.1,
|
||||
block.z + 0.5,
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
10,
|
||||
0.1
|
||||
);
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:item.bone_meal.use block @a ${e.player.x} ${e.player.y} ${e.player.z}`
|
||||
);
|
||||
global.addItemCooldown(player, item, 1);
|
||||
}
|
||||
});
|
||||
|
||||
const cropGrowth = ["minecraft:cave_vines", "minecraft:cave_vines_plant"];
|
||||
BlockEvents.rightClicked(cropGrowth, (e) => {
|
||||
const { player, item, block, hand, server } = e;
|
||||
if (hand == "OFF_HAND") return;
|
||||
if (
|
||||
player.getHeldItem("main_hand") == "society:enriched_bone_meal" &&
|
||||
!player.cooldowns.isOnCooldown(item)
|
||||
) {
|
||||
player.getHeldItem("main_hand").count--;
|
||||
server.scheduleInTicks(1, () => {
|
||||
block.set(block.id, { berries: "true" });
|
||||
});
|
||||
block.level.spawnParticles(
|
||||
"minecraft:happy_villager",
|
||||
true,
|
||||
block.x + 0.5,
|
||||
block.y + 0.1,
|
||||
block.z + 0.5,
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
10,
|
||||
0.1
|
||||
);
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:item.bone_meal.use block @a ${e.player.x} ${e.player.y} ${e.player.z}`
|
||||
);
|
||||
global.addItemCooldown(player, item, 1);
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked("vinery:apple_leaves", (e) => {
|
||||
const { block, player, item } = e;
|
||||
const season = global.getSeasonFromLevel(player.level);
|
||||
let modifiedProperties = block.properties;
|
||||
if (
|
||||
block.properties.get("can_grow_apples").toString() == "true" &&
|
||||
block.properties.get("has_apples").toString() == "true" &&
|
||||
!player.cooldowns.isOnCooldown(item)
|
||||
) {
|
||||
if (
|
||||
season == "autumn" ||
|
||||
hasGreenhouseGlass(player.level, block.getPos())
|
||||
) {
|
||||
modifiedProperties.can_grow_apples = false;
|
||||
modifiedProperties.has_apples = false;
|
||||
modifiedProperties.age = "0";
|
||||
e.server.scheduleInTicks(5, () => {
|
||||
block.set(block.id, modifiedProperties);
|
||||
});
|
||||
} else {
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"item.society.enriched_bone_meal.tree_fruit_season",
|
||||
Text.translatable("desc.sereneseasons.autumn").gold()
|
||||
)
|
||||
);
|
||||
e.cancel();
|
||||
}
|
||||
} else if (
|
||||
player.getHeldItem("main_hand") == "society:enriched_bone_meal" &&
|
||||
!player.cooldowns.isOnCooldown(item)
|
||||
) {
|
||||
player.getHeldItem("main_hand").count--;
|
||||
modifiedProperties.can_grow_apples = true;
|
||||
modifiedProperties.has_apples = true;
|
||||
modifiedProperties.age = "3";
|
||||
block.set(block.id, modifiedProperties);
|
||||
block.level.spawnParticles(
|
||||
"minecraft:happy_villager",
|
||||
true,
|
||||
block.x + 0.5,
|
||||
block.y + 0.1,
|
||||
block.z + 0.5,
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
10,
|
||||
0.1
|
||||
);
|
||||
e.server.runCommandSilent(
|
||||
`playsound minecraft:item.bone_meal.use block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
global.addItemCooldown(player, item, 1);
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked("vinery:dark_cherry_leaves", (e) => {
|
||||
const { block, player, item } = e;
|
||||
let modifiedProperties = block.properties;
|
||||
const season = global.getSeasonFromLevel(player.level);
|
||||
if (
|
||||
block.properties.get("can_grow_cherries").toString() == "true" &&
|
||||
block.properties.get("has_cherries").toString() == "true" &&
|
||||
!player.cooldowns.isOnCooldown(item)
|
||||
) {
|
||||
if (
|
||||
season == "spring" ||
|
||||
hasGreenhouseGlass(player.level, block.getPos())
|
||||
) {
|
||||
modifiedProperties.can_grow_cherries = false;
|
||||
modifiedProperties.has_cherries = false;
|
||||
modifiedProperties.age = "0";
|
||||
e.server.scheduleInTicks(5, () => {
|
||||
block.set(block.id, modifiedProperties);
|
||||
});
|
||||
} else {
|
||||
e.player.tell(
|
||||
Text.translatable(
|
||||
"item.society.enriched_bone_meal.tree_fruit_season",
|
||||
Text.translatable("desc.sereneseasons.spring").green()
|
||||
)
|
||||
);
|
||||
e.cancel();
|
||||
}
|
||||
} else if (
|
||||
player.getHeldItem("main_hand") == "society:enriched_bone_meal" &&
|
||||
!player.cooldowns.isOnCooldown(item)
|
||||
) {
|
||||
player.getHeldItem("main_hand").count--;
|
||||
modifiedProperties.can_grow_cherries = true;
|
||||
modifiedProperties.has_cherries = true;
|
||||
modifiedProperties.age = "3";
|
||||
block.set(block.id, modifiedProperties);
|
||||
block.level.spawnParticles(
|
||||
"minecraft:happy_villager",
|
||||
true,
|
||||
block.x + 0.5,
|
||||
block.y + 0.1,
|
||||
block.z + 0.5,
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
10,
|
||||
0.1
|
||||
);
|
||||
e.server.runCommandSilent(
|
||||
`playsound minecraft:item.bone_meal.use block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
global.addItemCooldown(player, item, 1);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
console.info("[SOCIETY] checkArtisanMachines.js loaded");
|
||||
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"society:bait_maker",
|
||||
"society:aging_cask",
|
||||
"society:ancient_cask",
|
||||
"society:charging_rod",
|
||||
"society:crystalarium",
|
||||
"society:wine_keg",
|
||||
"society:deluxe_worm_farm",
|
||||
"society:dehydrator",
|
||||
"society:espresso_machine",
|
||||
"society:fish_smoker",
|
||||
"society:loom",
|
||||
"society:mayonnaise_machine",
|
||||
"society:preserves_jar",
|
||||
"society:seed_maker",
|
||||
"society:tapper",
|
||||
"society:recycling_machine",
|
||||
"society:cheese_press",
|
||||
"society:oil_maker",
|
||||
"society:mushroom_log",
|
||||
],
|
||||
(e) => {
|
||||
const { player, block, hand, item, server, level } = e;
|
||||
if (hand == "OFF_HAND" || item !== "society:fairy_dust") return;
|
||||
if (block.properties.get("working").toLowerCase() === "true" && block.properties.get("mature").toLowerCase() === "false") {
|
||||
const { x, y, z } = block;
|
||||
global.handleProgress(level, block);
|
||||
server.runCommandSilent(`playsound legendarycreatures:wisp_idle block @a ${x} ${y} ${z} 0.2 1`);
|
||||
level.spawnParticles(
|
||||
"snowyspirit:glow_light",
|
||||
true,
|
||||
x,
|
||||
y + 0.5,
|
||||
z,
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
5,
|
||||
2
|
||||
);
|
||||
if (!player.isCreative()) item.shrink(1);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,34 @@
|
||||
console.info("[SOCIETY] neptuniumHoe.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"dew_drop_farmland_growth:weak_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:strong_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:hyper_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:bountiful_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:low_quality_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:high_quality_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:pristine_quality_fertilized_farmland",
|
||||
],
|
||||
(e) => {
|
||||
const { item, player, server, block } = e;
|
||||
if (item.id === "farm_and_charm:pitchfork") {
|
||||
const blockId = String(block.getId());
|
||||
if (0.5 < Math.random()) {
|
||||
block.popItemFromFace(
|
||||
blockId.substring(0, blockId.length - 10) + "r",
|
||||
"up"
|
||||
);
|
||||
}
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:item.armor.equip_leather block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:item.hoe.till block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
player.swing();
|
||||
block.set("minecraft:dirt");
|
||||
e.cancel();
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,13 @@
|
||||
BlockEvents.rightClicked("society:fish_pond_manager", (e) => {
|
||||
const { item, hand, player, level, block } = e;
|
||||
if (hand !== "MAIN_HAND" || item !== "create:clipboard") return;
|
||||
global.addItemCooldown(player, item, 10);
|
||||
player.swing();
|
||||
const pages = global.getQuestItems(block, level);
|
||||
item.nbt = {
|
||||
Type: 1,
|
||||
PreviouslyOpenedPage: 0,
|
||||
Pages: pages,
|
||||
};
|
||||
e.cancel();
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
console.info("[SOCIETY] frozenGeode.js loaded");
|
||||
|
||||
BlockEvents.broken(["society:geode_node", "society:omni_geode_node"], (e) => {
|
||||
const { level, player, block } = e;
|
||||
const season = global.getSeasonFromLevel(level);
|
||||
if (season !== "winter") return;
|
||||
|
||||
const roll = Math.random();
|
||||
|
||||
if (roll <= 0.1) {
|
||||
let geode = level.createEntity("minecraft:item");
|
||||
geode.x = block.x;
|
||||
geode.y = block.y;
|
||||
geode.z = block.z;
|
||||
geode.item = Item.of("society:frozen_geode");
|
||||
geode.spawn();
|
||||
|
||||
e.server.runCommandSilent(
|
||||
`playsound stardew_fishing:complete block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
console.info("[SOCIETY] fruitInstaBreak.js loaded");
|
||||
|
||||
BlockEvents.leftClicked([
|
||||
"pamhc2trees:pamcinnamon",
|
||||
"pamhc2trees:pamdragonfruit",
|
||||
"pamhc2trees:pamstarfruit",
|
||||
"pamhc2trees:pamlychee",
|
||||
"pamhc2trees:pampassionfruit",
|
||||
"pamhc2trees:pammango",
|
||||
"pamhc2trees:pambanana",
|
||||
"pamhc2trees:pampawpaw",
|
||||
"pamhc2trees:pamhazelnut",
|
||||
"pamhc2trees:pamorange",
|
||||
"pamhc2trees:pamplum",
|
||||
"pamhc2trees:pampeach",
|
||||
"pamhc2trees:pamlemon",
|
||||
"pamhc2trees:pamcherry",
|
||||
"pamhc2trees:pamapple",
|
||||
], (e) => {
|
||||
const { player, block, level, server } = e;
|
||||
if (player.isFake()) return;
|
||||
if (player.getHeldItem("main_hand").hasTag("forge:shears")) {
|
||||
let fruitItem = Item.of(block.id);
|
||||
server.runCommandSilent(`playsound minecraft:entity.sheep.shear block @a ${block.x} ${block.y} ${block.z}`);
|
||||
block.popItem(fruitItem);
|
||||
level.destroyBlock(block.pos, true, player);
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
console.info("[SOCIETY] grapevinePot.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("vinery:grapevine_pot", (e) => {
|
||||
const { block } = e;
|
||||
const properties = block.getProperties();
|
||||
if (properties.get("storage") == "5") {
|
||||
if (properties.get("type").toString().includes("red")) {
|
||||
block.set(block.id, {
|
||||
stage: "3",
|
||||
storage: "6",
|
||||
type: "red",
|
||||
});
|
||||
} else if (properties.get("type").toString().includes("white")) {
|
||||
block.set(block.id, {
|
||||
stage: "3",
|
||||
storage: "6",
|
||||
type: "white",
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
// DEPRECATED
|
||||
@@ -0,0 +1,201 @@
|
||||
console.info("[SOCIETY] harvestHandling.js loaded");
|
||||
// Yeah this filename has a typo. Fixing it would be more annoying than leaving it.
|
||||
|
||||
const deniedCrops = [
|
||||
"farmersdelight:tomatoes",
|
||||
"farmersdelight:budding_tomatoes",
|
||||
"minecraft:melon_stem",
|
||||
"minecraft:pitcher_crop",
|
||||
"minecraft:torchflower_crop",
|
||||
"minecraft:pumpkin_stem",
|
||||
"minecraft:cocoa",
|
||||
"supplementaries:flax",
|
||||
"society:mana_fruit_crop"
|
||||
];
|
||||
const allowedBonemealCrops = [
|
||||
"minecraft:crimson_fungus",
|
||||
"minecraft:warped_fungus",
|
||||
];
|
||||
const reseedableCrops = [
|
||||
"minecraft:potato",
|
||||
"minecraft:carrot",
|
||||
"farm_and_charm:onion",
|
||||
"veggiesdelight:sweet_potato",
|
||||
"vintagedelight:peanut",
|
||||
"veggiesdelight:garlic_clove"
|
||||
];
|
||||
BlockEvents.rightClicked((e) => {
|
||||
const { block, player, server, hand, item, level } = e;
|
||||
if (reseedableCrops.includes(e.item.getId())) {
|
||||
if (block.hasTag("dewdrop:waterable")) {
|
||||
e.player.inventoryMenu.broadcastFullState();
|
||||
e.cancel();
|
||||
}
|
||||
}
|
||||
if (!allowedBonemealCrops.includes(block.id)) {
|
||||
if (player.isHoldingInAnyHand("farm_and_charm:fertilizer")) e.cancel();
|
||||
if (
|
||||
player.isHoldingInAnyHand("minecraft:bone_meal") ||
|
||||
player.isHoldingInAnyHand("meadow:watering_can")
|
||||
) {
|
||||
if (
|
||||
block.hasTag("minecraft:crops") ||
|
||||
block.hasTag("minecraft:saplings") ||
|
||||
block.hasTag("vinery:lattice") ||
|
||||
block.hasTag("farmersdelight:wild_crops") ||
|
||||
block.hasTag("farm_and_charm:wild_crops") ||
|
||||
block.hasTag("sereneseasons:summer_crops") ||
|
||||
block.hasTag("sereneseasons:autumn_crops") ||
|
||||
block.hasTag("sereneseasons:spring_crops") ||
|
||||
block.hasTag("sereneseasons:winter_crops") ||
|
||||
[
|
||||
"veggiesdelight:wild_bellpeppers",
|
||||
"veggiesdelight:wild_sweet_potatoes",
|
||||
"veggiesdelight:wild_garlic",
|
||||
"veggiesdelight:wild_cauliflowers",
|
||||
"atmospheric:dragon_roots",
|
||||
"atmospheric:aloe_vera",
|
||||
"atmospheric:aloe_kernels",
|
||||
"atmospheric:yucca_branch",
|
||||
"minecraft:kelp",
|
||||
"farmersdelight:tomatoes",
|
||||
"farm_and_charm:wild_nettle",
|
||||
"farm_and_charm:wild_ribwort",
|
||||
"minecraft:cocoa",
|
||||
"minecraft:cave_vines",
|
||||
"minecraft:cave_vines_plant",
|
||||
"minecraft:bamboo",
|
||||
"nethervinery:crimson_grape_bush",
|
||||
"nethervinery:warped_grape_bush",
|
||||
"vinery:savanna_grape_bush_white",
|
||||
"vinery:jungle_grape_bush_red",
|
||||
"vinery:savanna_grape_bush_red",
|
||||
"vinery:white_grape_bush",
|
||||
"vinery:red_grape_bush",
|
||||
"vinery:taiga_grape_bush_red",
|
||||
"vinery:taiga_grape_bush_white",
|
||||
"vinery:jungle_grape_bush_white",
|
||||
"vinery:grapevine_stem",
|
||||
"nethervinery:obsidian_stem",
|
||||
"farmersdelight:budding_tomatoes",
|
||||
"farmersdelight:rice",
|
||||
"farmersdelight:rice_panicles",
|
||||
"herbalbrews:lavender",
|
||||
"herbalbrews:hibiscus",
|
||||
"minecraft:torchflower",
|
||||
"atmospheric:passion_vine",
|
||||
"verdantvibes:bracket_mushroom",
|
||||
"vinery:apple_leaves",
|
||||
"vinery:dark_cherry_leaves",
|
||||
"cluttered:blue_roundhead",
|
||||
"cluttered:fly_agaric",
|
||||
"quark:glow_shroom",
|
||||
"farmersdelight:brown_mushroom_colony",
|
||||
"species:alphacene_mushroom",
|
||||
"farmersdelight:red_mushroom_colony"
|
||||
].includes(block.id)
|
||||
) {
|
||||
player.tell(Text.translatable("society.bone_meal.weak"));
|
||||
e.player.inventoryMenu.broadcastFullState();
|
||||
e.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hand == "MAIN_HAND") {
|
||||
let initialBlock = level.getBlockState(block.pos);
|
||||
let checkBlocked;
|
||||
let blockState;
|
||||
if (
|
||||
block.hasTag("minecraft:crops") &&
|
||||
!deniedCrops.includes(block.id) &&
|
||||
initialBlock.block.isMaxAge(initialBlock)
|
||||
) {
|
||||
let xpCount = 0;
|
||||
let radius = 0;
|
||||
if (item.hasTag("minecraft:hoes")) radius = 1;
|
||||
if (
|
||||
[
|
||||
"minecraft:netherite_hoe",
|
||||
"minecraft:diamond_hoe",
|
||||
"botania:elementium_hoe",
|
||||
].includes(item.id)
|
||||
)
|
||||
radius = 2;
|
||||
for (let pos of BlockPos.betweenClosed(
|
||||
new BlockPos(block.x - radius, block.y, block.z - radius),
|
||||
[block.x + radius, block.y, block.z + radius],
|
||||
)) {
|
||||
checkBlocked = level.getBlock(pos);
|
||||
blockState = level.getBlockState(pos);
|
||||
if (
|
||||
checkBlocked.hasTag("minecraft:crops") &&
|
||||
!deniedCrops.includes(checkBlocked.id)
|
||||
) {
|
||||
if (blockState.block.isMaxAge(blockState)) {
|
||||
if (player.isFake()) {
|
||||
e.cancel();
|
||||
} else {
|
||||
xpCount += blockState.block.getMaxAge();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
server.scheduleInTicks(2, () => {
|
||||
initialBlock = level.getBlockState(block.pos);
|
||||
if (!initialBlock.block.isMaxAge(initialBlock) && xpCount > 0) {
|
||||
const xp = block.createEntity("experience_orb");
|
||||
xp.mergeNbt({ Value: xpCount });
|
||||
xp.spawn();
|
||||
global.giveExperience(server, player, "farming", xpCount * 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
// Vinery grapevine leaf mechanic
|
||||
BlockEvents.rightClicked("vinery:grapevine_stem", (e) => {
|
||||
const { block } = e;
|
||||
let properties = block.getProperties();
|
||||
properties.leaves_pending = false;
|
||||
properties.leaves_done = true;
|
||||
block.set(block.id, properties);
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked((e) => {
|
||||
if (["society:mana_fruit_crop"].includes(e.item.getId())) {
|
||||
if (!e.block.hasTag("dewdrop:waterable")) {
|
||||
e.player.inventoryMenu.broadcastFullState();
|
||||
e.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked("society:mana_fruit_crop", (e) => {
|
||||
const { level, server, block, player } = e;
|
||||
let blockProperties = level.getBlock(block.pos).getProperties();
|
||||
let age = Number(blockProperties.get("age"));
|
||||
|
||||
if (age == 7) {
|
||||
blockProperties.age = "0";
|
||||
block.set(block.id, blockProperties);
|
||||
let quality = global.getCropQuality(block);
|
||||
let count = 1;
|
||||
if (player.stages.has("paradise_crop")) count += 1;
|
||||
if (player.stages.has("crop_collector")) count *= 2;
|
||||
if (quality) {
|
||||
block.popItemFromFace(
|
||||
Item.of(
|
||||
`${count}x society:mana_fruit`,
|
||||
`{quality_food:{effects:[],quality:${quality}}}`,
|
||||
),
|
||||
"up",
|
||||
);
|
||||
} else {
|
||||
block.popItemFromFace(Item.of(`${count}x society:mana_fruit`), "up");
|
||||
}
|
||||
player.swing();
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:block.grass.break block @a ${block.x} ${block.y} ${block.z} 0.5`,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
console.info("[SOCIETY] hoeAoe.js loaded");
|
||||
|
||||
const hoeTiers = new Map([
|
||||
["minecraft:stone_hoe", 0.2],
|
||||
["minecraft:iron_hoe", 0.5],
|
||||
["minecraft:golden_hoe", 1],
|
||||
["minecraft:diamond_hoe", 2],
|
||||
["oreganized:electrum_hoe", 3],
|
||||
["minecraft:netherite_hoe", 3],
|
||||
["aquaculture:neptunium_hoe", 3],
|
||||
["botania:elementium_hoe", 3],
|
||||
["botania:manasteel_hoe", 2],
|
||||
]);
|
||||
|
||||
const hoeFarmland = new Map([
|
||||
["aquaculture:neptunium_hoe", "dew_drop_farmland_growth:hydrating_farmland"],
|
||||
["botania:elementium_hoe", "dew_drop_farmland_growth:hydrating_farmland"],
|
||||
]);
|
||||
|
||||
const tryTill = (level, player, pos, farmland) => {
|
||||
if (!level.getBlock(pos).hasTag("minecraft:dirt")) return false;
|
||||
const above = level.getBlock(pos.above()).id;
|
||||
if (
|
||||
above !== "minecraft:air" &&
|
||||
above !== "minecraft:water" &&
|
||||
above !== "minecraft:flowing_water"
|
||||
)
|
||||
return false;
|
||||
|
||||
level.getBlock(pos).set(farmland || "minecraft:farmland");
|
||||
player.swing();
|
||||
player.server.runCommandSilent(
|
||||
`playsound minecraft:item.hoe.till block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
return true;
|
||||
};
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"minecraft:dirt",
|
||||
"minecraft:rooted_dirt",
|
||||
"minecraft:coarse_dirt",
|
||||
"minecraft:dirt_path",
|
||||
"minecraft:grass_block",
|
||||
],
|
||||
(e) => {
|
||||
const { item, block, player, level } = e;
|
||||
const id = `${item.id}`;
|
||||
const hoe = hoeTiers.get(id);
|
||||
if (!hoe) return;
|
||||
|
||||
const farmland = hoeFarmland.get(id);
|
||||
if (!player.crouching) {
|
||||
tryTill(level, player, block.pos, farmland);
|
||||
e.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (hoe < 1) {
|
||||
const distance = hoe > 0.2 ? 3 : 2;
|
||||
let pos = block.pos;
|
||||
for (let i = 0; i < distance; i++) {
|
||||
tryTill(level, player, pos, farmland);
|
||||
pos = global.getFacing(player.facing, pos);
|
||||
}
|
||||
} else {
|
||||
const { x, y, z } = block;
|
||||
for (let pos of BlockPos.betweenClosed(
|
||||
new BlockPos(x - hoe, y, z - hoe),
|
||||
[x + hoe, y, z + hoe]
|
||||
)) {
|
||||
tryTill(level, player, pos, farmland);
|
||||
}
|
||||
}
|
||||
global.addItemCooldown(player, item, 40);
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,51 @@
|
||||
console.info("[SOCIETY] letsDoBroken.js loaded");
|
||||
|
||||
BlockEvents.broken("furniture:iron_fish_tank", (e) => {
|
||||
if (e.block.properties.get("part").toLowerCase() == "head") {
|
||||
e.block.popItem(Item.of("furniture:iron_fish_tank"));
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.broken("furniture:copper_fish_tank", (e) => {
|
||||
if (e.block.properties.get("part").toLowerCase() == "head") {
|
||||
e.block.popItem(Item.of("furniture:copper_fish_tank"));
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.broken("brewery:barrel_main", (e) => {
|
||||
if (e.block.properties.get("half").toLowerCase() == "upper") {
|
||||
e.block.popItem(Item.of("brewery:barrel_main"));
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.broken("brewery:barrel_right", (e) => {
|
||||
if (e.block.properties.get("half").toLowerCase() == "lower") {
|
||||
e.block.popItem(Item.of("brewery:barrel_main"));
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.broken(["brewery:barrel_main_head", "brewery:barrel_head_right"], (e) => {
|
||||
e.block.popItem(Item.of("brewery:barrel_main"));
|
||||
});
|
||||
|
||||
BlockEvents.broken(
|
||||
[
|
||||
"fantasyfurniture:nordic/painting_small",
|
||||
"fantasyfurniture:dunmer/painting_small",
|
||||
"fantasyfurniture:nordic/painting_wide",
|
||||
"fantasyfurniture:dunmer/painting_wide",
|
||||
"fantasyfurniture:venthyr/painting_small",
|
||||
"fantasyfurniture:venthyr/painting_wide",
|
||||
"fantasyfurniture:bone/skeleton/painting_small",
|
||||
"fantasyfurniture:bone/skeleton/painting_wide",
|
||||
"fantasyfurniture:bone/wither/painting_small",
|
||||
"fantasyfurniture:royal/painting_wide",
|
||||
"fantasyfurniture:royal/painting_small",
|
||||
"fantasyfurniture:bone/wither/painting_wide",
|
||||
"fantasyfurniture:necrolord/painting_small",
|
||||
"fantasyfurniture:necrolord/painting_wide",
|
||||
],
|
||||
(e) => {
|
||||
e.block.popItem(Item.of(e.block.id));
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,81 @@
|
||||
console.info("[SOCIETY] magnifyingGlass.js loaded");
|
||||
|
||||
const DELAY = 10;
|
||||
const REPETITIONS = 10;
|
||||
|
||||
const magnifyingGlassBlocks = [
|
||||
{ id: "society:auto_grabber", radius: 5, includeY: true },
|
||||
{ id: "society:artisan_hopper", radius: 3, includeY: true },
|
||||
{ id: "society:mini_artisan_hopper", radius: 1, includeY: true },
|
||||
{ id: "society:auto_petter", radius: 2, includeY: true },
|
||||
{ id: "society:fish_pond_basket", radius: 1, includeY: true },
|
||||
{ id: "society:feeding_trough", radius: 6, includeY: true },
|
||||
{ id: "splendid_slimes:slime_feeder", radius: 6, includeY: true },
|
||||
{ id: "dew_drop_farmland_growth:iron_sprinkler", radius: 1 },
|
||||
{ id: "dew_drop_farmland_growth:gold_sprinkler", radius: 2 },
|
||||
{ id: "society:mana_sprinkler", radius: 2 },
|
||||
{ id: "dew_drop_farmland_growth:diamond_sprinkler", radius: 3 },
|
||||
{ id: "dew_drop_farmland_growth:netherite_sprinkler", radius: 4 },
|
||||
{ id: "society:mana_milker", radius: 10, includeY: true },
|
||||
{ id: "society:golden_clock", radius: 2, includeY: true },
|
||||
{ id: "society:mana_clock", radius: 1, includeY: true },
|
||||
{ id: "society:snow_melter", radius: 10 },
|
||||
{ id: "farmingforblockheads:chicken_nest", radius: 8, includeY: true },
|
||||
{ id: "society:growth_obelisk", radius: 3, includeY: false },
|
||||
{ id: "society:ribbit_hut", radius: 7, includeY: false },
|
||||
{ id: "society:mushroom_log", radius: 8, includeY: true },
|
||||
{ id: "society:fish_pond_manager", radius: 10, includeY: true },
|
||||
{ id: "society:drum_cornucopia", radius: 10, includeY: true },
|
||||
];
|
||||
const magnifyingGlassBlockIds = magnifyingGlassBlocks.map((x) => x.id);
|
||||
|
||||
BlockEvents.rightClicked(magnifyingGlassBlockIds, (e) => {
|
||||
const { item, hand, player, server, level, block } = e;
|
||||
let resolvedBlock = block;
|
||||
if (hand == "MAIN_HAND" && item == "society:magnifying_glass") {
|
||||
global.addItemCooldown(player, item, (DELAY * REPETITIONS) / 2);
|
||||
player.swing();
|
||||
server.runCommandSilent(
|
||||
`playsound tanukidecor:block.lantern_clock.chime block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
magnifyingGlassBlocks.forEach((hitBlock) => {
|
||||
if (hitBlock.id == block.id) {
|
||||
if (block.id === "society:ribbit_hut") {
|
||||
resolvedBlock = global.getOpposite(block.getProperties().get("facing"), block.getPos());
|
||||
}
|
||||
for (let index = 0; index < REPETITIONS; index++) {
|
||||
server.scheduleInTicks(DELAY * index, () => {
|
||||
for (let pos of BlockPos.betweenClosed(
|
||||
new BlockPos(
|
||||
resolvedBlock.x - hitBlock.radius,
|
||||
resolvedBlock.y - hitBlock.radius,
|
||||
resolvedBlock.z - hitBlock.radius
|
||||
),
|
||||
[
|
||||
resolvedBlock.x + hitBlock.radius,
|
||||
resolvedBlock.y + hitBlock.radius,
|
||||
resolvedBlock.z + hitBlock.radius,
|
||||
]
|
||||
)) {
|
||||
if (pos.y === resolvedBlock.y || hitBlock.includeY) {
|
||||
level.spawnParticles(
|
||||
"supplementaries:stasis",
|
||||
true,
|
||||
pos.x + 0.5,
|
||||
pos.y + 0.5,
|
||||
pos.z + 0.5,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0.0001
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
e.cancel();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
console.info("[SOCIETY] multiBlockHandlers.js loaded");
|
||||
|
||||
BlockEvents.placed("society:growth_obelisk", (e) => {
|
||||
const { block, level } = e;
|
||||
const above = level.getBlock(block.pos.above());
|
||||
if (above == "minecraft:air") above.set("society:growth_obelisk_upper", block.getProperties());
|
||||
});
|
||||
|
||||
BlockEvents.broken("society:growth_obelisk", (e) => {
|
||||
const { block, level } = e;
|
||||
level.destroyBlock(block.pos.above(), true);
|
||||
});
|
||||
BlockEvents.broken("society:growth_obelisk_upper", (e) => {
|
||||
const { block, level } = e;
|
||||
level.destroyBlock(block.pos.below(), true);
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
console.info("[SOCIETY] neptuniumHoe.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"minecraft:dirt",
|
||||
"minecraft:rooted_dirt",
|
||||
"minecraft:coarse_dirt",
|
||||
"minecraft:dirt_path",
|
||||
"minecraft:grass_block",
|
||||
],
|
||||
(e) => {
|
||||
const { item, block } = e;
|
||||
if (
|
||||
item.id === "aquaculture:neptunium_hoe" ||
|
||||
item.id === "botania:elementium_hoe"
|
||||
) {
|
||||
block.set("dew_drop_farmland_growth:hydrating_farmland");
|
||||
e.cancel();
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,11 @@
|
||||
console.info("[SOCIETY] openShippingBin.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
["shippingbin:basic_shipping_bin", "shippingbin:smart_shipping_bin"],
|
||||
(e) => {
|
||||
const { player, server } = e;
|
||||
server.runCommandSilent(
|
||||
`playsound shippingbin:block.shippingbin.open block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,54 @@
|
||||
console.info("[SOCIETY] pamsTreeLoot.js loaded");
|
||||
const weirdFruits = new Map([
|
||||
["pamhc2trees:pamcherry", "vinery:cherry"],
|
||||
["pamhc2trees:pamorange", "atmospheric:orange"],
|
||||
["pamhc2trees:pampassionfruit", "atmospheric:passion_fruit"],
|
||||
]);
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"pamhc2trees:pamapple",
|
||||
"pamhc2trees:pamcherry",
|
||||
"pamhc2trees:pamorange",
|
||||
"pamhc2trees:pampeach",
|
||||
"pamhc2trees:pamplum",
|
||||
"pamhc2trees:pamhazelnut",
|
||||
"pamhc2trees:pampawpaw",
|
||||
"pamhc2trees:pambanana",
|
||||
"pamhc2trees:pamcinnamon",
|
||||
"pamhc2trees:pamdragonfruit",
|
||||
"pamhc2trees:pammango",
|
||||
"pamhc2trees:pamstarfruit",
|
||||
"pamhc2trees:pamlychee",
|
||||
"pamhc2trees:pamlemon",
|
||||
"pamhc2trees:pampassionfruit",
|
||||
],
|
||||
(e) => {
|
||||
const { block, player, server } = e;
|
||||
const fruitName = `${block.id.toString().split(":")[1]}`;
|
||||
if (
|
||||
player.isHoldingInAnyHand("minecraft:bone_meal") ||
|
||||
player.isHoldingInAnyHand("farm_and_charm:fertilizer") ||
|
||||
player.isHoldingInAnyHand("meadow:watering_can")
|
||||
)
|
||||
return;
|
||||
if (Number(block.properties.get("age")) >= 7) {
|
||||
if (player.stages.has("tree_whisperer")) {
|
||||
const weirdFruit = weirdFruits.get(String(block.id));
|
||||
if (weirdFruit) {
|
||||
block.popItem(`2x ${weirdFruit}`);
|
||||
} else {
|
||||
block.popItem(`2x pamhc2trees:${fruitName.substring(3, fruitName.length)}item`);
|
||||
}
|
||||
}
|
||||
if (block.id == "pamhc2trees:pambanana" && player.stages.has("banana_karenina")) {
|
||||
block.popItem(
|
||||
`${player.stages.has("tree_whisperer") ? 5 : 3}x pamhc2trees:${fruitName.substring(
|
||||
3,
|
||||
fruitName.length
|
||||
)}item`
|
||||
);
|
||||
}
|
||||
global.giveExperience(server, player, "farming", 40);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,32 @@
|
||||
console.info("[SOCIETY] pickupDrink.js loaded");
|
||||
|
||||
BlockEvents.leftClicked(
|
||||
[
|
||||
"society:starcardi",
|
||||
"society:star_coquito",
|
||||
"society:good_catawba",
|
||||
"society:nutty_basil",
|
||||
"society:forks_of_blue",
|
||||
"society:ancient_cider",
|
||||
"society:ancient_vespertine",
|
||||
"society:dewy_star",
|
||||
"society:beer_london",
|
||||
"society:beer_attunecore",
|
||||
"society:espresso",
|
||||
"society:steamed_milk",
|
||||
"society:mocha",
|
||||
"society:latte",
|
||||
"society:dirty_chai",
|
||||
"society:bowl_of_soul",
|
||||
"society:truffle_tea",
|
||||
],
|
||||
(e) => {
|
||||
const { player, block, server } = e;
|
||||
|
||||
player.give(block.id);
|
||||
block.set("minecraft:air")
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:item.bottle.fill block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,64 @@
|
||||
console.info("[SOCIETY] placeNbtMachine.js loaded");
|
||||
|
||||
BlockEvents.placed("society:prize_machine", (e) => {
|
||||
let item = e.player.getHeldItem("main_hand");
|
||||
let prizeNbt;
|
||||
if (item.id !== "society:prize_machine") item = e.player.getHeldItem("off_hand");
|
||||
if (item.id !== "society:prize_machine") return;
|
||||
prizeNbt = item.getNbt();
|
||||
if (!prizeNbt.isEmpty()) {
|
||||
let nbt = e.block.getEntityData();
|
||||
nbt.merge({
|
||||
data: {
|
||||
prize: Number(prizeNbt.get("prize")),
|
||||
},
|
||||
});
|
||||
global.setBlockEntityData(e.block, nbt)
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.placed("society:fish_pond", (e) => {
|
||||
const { block, player } = e;
|
||||
let item = player.getHeldItem("main_hand");
|
||||
let pondNbt;
|
||||
if (item.id !== "society:fish_pond") item = player.getHeldItem("off_hand");
|
||||
if (item.id !== "society:fish_pond") return;
|
||||
pondNbt = item.getNbt();
|
||||
if (pondNbt && !pondNbt.isEmpty()) {
|
||||
block.set(block.id, {
|
||||
facing: block.getProperties().get("facing"),
|
||||
valid: true,
|
||||
mature: false,
|
||||
upgraded: false,
|
||||
quest: Boolean(pondNbt.getBoolean("quest")),
|
||||
});
|
||||
let nbt = block.getEntityData();
|
||||
nbt.merge({
|
||||
data: {
|
||||
type: pondNbt.get("type"),
|
||||
quest_id: Number(pondNbt.get("quest_id")),
|
||||
population: Number(pondNbt.get("population")),
|
||||
max_population: Number(pondNbt.get("max_population")),
|
||||
},
|
||||
});
|
||||
global.setBlockEntityData(block, nbt)
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.placed(
|
||||
[
|
||||
"shippingbin:smart_shipping_bin",
|
||||
"shippingbin:basic_shipping_bin",
|
||||
"society:artisan_hopper",
|
||||
"society:mini_artisan_hopper",
|
||||
"society:fish_pond_basket",
|
||||
"society:auto_grabber",
|
||||
"society:fish_pond_manager",
|
||||
],
|
||||
(e) => {
|
||||
const playerUUID = e.player.getUuid().toString();
|
||||
let nbt = e.block.entityData;
|
||||
nbt.merge({ data: { owner: playerUUID } });
|
||||
global.setBlockEntityData(e.block, nbt)
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,28 @@
|
||||
console.info("[SOCIETY] neptuniumHoe.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"minecraft:farmland",
|
||||
"dew_drop_farmland_growth:weak_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:strong_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:hyper_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:bountiful_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:low_quality_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:high_quality_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:pristine_quality_fertilized_farmland",
|
||||
],
|
||||
(e) => {
|
||||
const { item, player, level, server, block } = e;
|
||||
const aboveBlock = level.getBlock(block.getPos().above());
|
||||
if (aboveBlock.id === "minecraft:air") {
|
||||
if (item.id === "veggiesdelight:garlic_seed") {
|
||||
aboveBlock.set("veggiesdelight:garlic_crop");
|
||||
if (!player.isCreative()) item.shrink(1);
|
||||
player.swing();
|
||||
server.runCommandSilent(
|
||||
`playsound minecraft:block.crop.break block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,184 @@
|
||||
console.info("[SOCIETY] plushieMechanics.js loaded");
|
||||
|
||||
BlockEvents.placed(global.plushies, (e) => {
|
||||
let item = e.player.getHeldItem("main_hand");
|
||||
let plushieNbt;
|
||||
if (item.id !== e.block.id) item = e.player.getHeldItem("off_hand");
|
||||
if (item.id !== e.block.id) return;
|
||||
plushieNbt = item.getNbt();
|
||||
if (plushieNbt) {
|
||||
let nbt = e.block.getEntityData();
|
||||
nbt.merge({
|
||||
data: {
|
||||
type: plushieNbt.get("type"),
|
||||
quest_id: plushieNbt.get("quest_id"),
|
||||
affection: plushieNbt.get("affection"),
|
||||
quality: plushieNbt.get("quality_food").get("quality"),
|
||||
},
|
||||
});
|
||||
let animal = plushieNbt.get("animal");
|
||||
if (animal) {
|
||||
nbt.merge({
|
||||
data: {
|
||||
animal: animal,
|
||||
},
|
||||
});
|
||||
}
|
||||
global.setBlockEntityData(e.block, nbt)
|
||||
}
|
||||
});
|
||||
|
||||
const breakPlushie = (block, wandReset) => {
|
||||
let nbt = block.getEntityData();
|
||||
const { type, quest_id, affection, quality, animal } = nbt.data;
|
||||
let baseItem = Item.of(
|
||||
block.id,
|
||||
`{quality_food:{quality:${quality}},type:${type},quest_id:${quest_id},affection:${affection}}`
|
||||
);
|
||||
if (wandReset) {
|
||||
block.popItem(baseItem);
|
||||
} else {
|
||||
block.popItem(
|
||||
animal && !animal.isEmpty()
|
||||
? Item.of(
|
||||
block.id,
|
||||
global.getPlushieItemNbt(
|
||||
baseItem.getNbt(),
|
||||
animal.type,
|
||||
animal.name,
|
||||
animal,
|
||||
animal
|
||||
)
|
||||
)
|
||||
: baseItem
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
BlockEvents.broken(global.plushies, (e) => {
|
||||
breakPlushie(e.block)
|
||||
});
|
||||
|
||||
BlockEvents.broken("whimsy_deco:sunlit_singing_frog", (e) => {
|
||||
const { block, server } = e;
|
||||
const { x, y, z } = block;
|
||||
let nbt = block.getEntityData();
|
||||
const { type, quest_id, affection, quality, animal } = nbt.data;
|
||||
let baseItem = Item.of(
|
||||
"whimsy_deco:adv_singing_frog_plushie",
|
||||
`{quality_food:{quality:${quality}},type:${type},quest_id:${quest_id},affection:${affection}}`
|
||||
);
|
||||
server.runCommandSilent(
|
||||
`execute positioned ${x} ${y} ${z} run stopsound @e[type=player,distance=..4] block`
|
||||
);
|
||||
block.popItem(
|
||||
animal
|
||||
? Item.of(
|
||||
block.id,
|
||||
global.getPlushieItemNbt(
|
||||
baseItem.getNbt(),
|
||||
animal.type,
|
||||
animal.customName,
|
||||
animal,
|
||||
animal
|
||||
)
|
||||
)
|
||||
: baseItem
|
||||
);
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked("whimsy_deco:gatcha_machine", (e) => {
|
||||
const { item, player, block, hand, server } = e;
|
||||
if (hand == "OFF_HAND") return;
|
||||
if (hand == "MAIN_HAND") {
|
||||
if (item.id.equals("numismatics:sun")) {
|
||||
item.count -= 1;
|
||||
block.popItemFromFace(
|
||||
"society:plushie_capsule",
|
||||
block.properties.get("facing")
|
||||
);
|
||||
server.runCommandSilent(
|
||||
`playsound tanukidecor:block.cash_register.ring block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
global.addItemCooldown(player, item.id, 1);
|
||||
} else {
|
||||
player.tell(
|
||||
Text.translatable(
|
||||
"tooltip.society.gatcha_machine",
|
||||
Text.translatable("item.numismatics.sun").gold()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked(global.plushies, (e) => {
|
||||
const { item, player, block, hand, level, server } = e;
|
||||
if (hand == "OFF_HAND") return;
|
||||
if (hand == "MAIN_HAND" && item.id.equals("society:plushie_wand")) {
|
||||
let nbt = block.getEntityData();
|
||||
const { animal } = nbt.data;
|
||||
if (animal && animal.type) {
|
||||
let newAnimal = player.level.createEntity(`${animal.type}`);
|
||||
newAnimal.setX(block.getX());
|
||||
newAnimal.setY(block.getY() + 1);
|
||||
newAnimal.setZ(block.getZ());
|
||||
if (animal.name) newAnimal.customName = animal.name
|
||||
if (animal.Variant) {
|
||||
let variantNBT = newAnimal.getNbt();
|
||||
variantNBT.Variant = animal.Variant;
|
||||
newAnimal.setNbt(variantNBT);
|
||||
}
|
||||
newAnimal.spawn();
|
||||
global.setPlushieExtractedPD(newAnimal, animal)
|
||||
breakPlushie(block, true)
|
||||
block.set("minecraft:air")
|
||||
server.runCommandSilent(
|
||||
`playsound botania:babylon_spawn block @a ${block.x} ${block.y} ${block.z}`
|
||||
);
|
||||
level.spawnParticles(
|
||||
"snowyspirit:glow_light",
|
||||
true,
|
||||
block.x,
|
||||
block.y + 0.5,
|
||||
block.z,
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
20,
|
||||
2
|
||||
);
|
||||
} else {
|
||||
player.tell(
|
||||
Text.translatable("item.society.plushie_wand.no_animal").red()
|
||||
);
|
||||
}
|
||||
global.addItemCooldown(player, item.id, 5);
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.leftClicked(global.plushies, (e) => {
|
||||
const { player, block, level, server } = e;
|
||||
if (player.getHeldItem("main_hand").id.equals("society:plushie_wand") && !player.cooldowns.isOnCooldown("society:plushie_wand")) {
|
||||
breakPlushie(block)
|
||||
block.set("minecraft:air")
|
||||
server.runCommandSilent(
|
||||
`playsound botania:babylon_attack block @a ${block.x} ${block.y} ${block.z}`
|
||||
);
|
||||
level.spawnParticles(
|
||||
"snowyspirit:glow_light",
|
||||
true,
|
||||
block.x,
|
||||
block.y + 0.5,
|
||||
block.z,
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
20,
|
||||
2
|
||||
);
|
||||
global.addItemCooldown(player, "society:plushie_wand", 5);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
console.info("[SOCIETY] preventChestVoid.js loaded");
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"minecraft:chest",
|
||||
"quark:ancient_chest",
|
||||
"quark:azalea_chest",
|
||||
"quark:blossom_chest",
|
||||
"quark:oak_chest",
|
||||
"quark:spruce_chest",
|
||||
"quark:birch_chest",
|
||||
"quark:jungle_chest",
|
||||
"quark:acacia_chest",
|
||||
"quark:dark_oak_chest",
|
||||
"quark:crimson_chest",
|
||||
"quark:warped_chest",
|
||||
"quark:mangrove_chest",
|
||||
"quark:bamboo_chest",
|
||||
"quark:cherry_chest",
|
||||
"quark:nether_brick_chest",
|
||||
"quark:purpur_chest",
|
||||
"quark:prismarine_chest",
|
||||
"quark:jungle_trapped_chest",
|
||||
],
|
||||
(e) => {
|
||||
const { block, player, hand, item, server } = e;
|
||||
if (hand == "OFF_HAND") return;
|
||||
if (block.properties.get("type").toString() === "single") return;
|
||||
if (
|
||||
"sophisticatedstorage:basic_tier_upgrade" === item.id &&
|
||||
block.getEntityData().Items.length > 0
|
||||
) {
|
||||
player.tell(Text.translatable("society.chest_upgrade.void_warn").red());
|
||||
e.cancel();
|
||||
}
|
||||
}
|
||||
);
|
||||
BlockEvents.rightClicked("farm_and_charm:mincer", (e) => {
|
||||
const { block, player, hand, item, server } = e;
|
||||
if (player.isCrouching()) return;
|
||||
if (item.id !== "minecraft:air" && block.inventory.getStackInSlot(0) == item.id) {
|
||||
player.tell(Text.translatable("society.mincer.warn").red());
|
||||
player.inventoryMenu.broadcastFullState();
|
||||
e.cancel();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
console.info("[SOCIETY] placeNbtMachine.js loaded");
|
||||
|
||||
const getSideCalc = (facing, initialPos, comparePos) => {
|
||||
switch (facing) {
|
||||
case "north":
|
||||
return initialPos.x - comparePos.x + 1;
|
||||
case "south":
|
||||
return comparePos.x - initialPos.x + 1;
|
||||
case "east":
|
||||
return initialPos.z - comparePos.z + 1;
|
||||
case "west":
|
||||
return comparePos.z - initialPos.z + 1;
|
||||
}
|
||||
};
|
||||
const getDepthCalc = (facing, initialPos, comparePos) => {
|
||||
switch (facing) {
|
||||
case "north":
|
||||
return comparePos.z - initialPos.z + 1;
|
||||
case "south":
|
||||
return initialPos.z - comparePos.z + 1;
|
||||
case "east":
|
||||
return initialPos.x - comparePos.x + 1;
|
||||
case "west":
|
||||
return comparePos.x - initialPos.x + 1;
|
||||
}
|
||||
};
|
||||
const scanArea = (level, block) => {
|
||||
let scannedBlock;
|
||||
for (let pos of BlockPos.betweenClosed(
|
||||
new BlockPos(block.x - 1, block.y, block.z - 1),
|
||||
[block.x + 1, block.y + 2, block.z + 1]
|
||||
)) {
|
||||
if (!level.isLoaded(pos)) continue;
|
||||
scannedBlock = level.getBlock(pos);
|
||||
if (
|
||||
scannedBlock.id !== "minecraft:air" &&
|
||||
scannedBlock.id !== "society:ribbit_hut"
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const setRibbitHutBlocks = (level, block, player, server) => {
|
||||
let facing = block.getProperties().get("facing");
|
||||
for (let pos of BlockPos.betweenClosed(
|
||||
new BlockPos(block.x - 1, block.y, block.z - 1),
|
||||
[block.x + 1, block.y + 2, block.z + 1]
|
||||
)) {
|
||||
level.getBlock(pos).set("society:ribbit_hut_block", {
|
||||
layer: (pos.y - block.y).toString(),
|
||||
side: getSideCalc(facing, block, pos).toString(),
|
||||
depth: getDepthCalc(facing, block, pos).toString(),
|
||||
facing: facing,
|
||||
});
|
||||
}
|
||||
const hutBlock = global.getFacing(facing, block.getPos());
|
||||
level.getBlock(hutBlock).set("society:ribbit_hut", { facing: facing });
|
||||
server.scheduleInTicks(0, () => {
|
||||
server.scheduleInTicks(10, () => {
|
||||
let nbt = level.getBlock(hutBlock).getEntityData();
|
||||
nbt.merge({ data: { owner: player.getUuid().toString() } });
|
||||
level.getBlock(hutBlock).setEntityData(nbt);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
BlockEvents.placed("society:ribbit_hut", (e) => {
|
||||
const { player, level, block, server } = e;
|
||||
let space = scanArea(level, block);
|
||||
|
||||
if (!space) {
|
||||
player.tell(
|
||||
Text.translatable("block.society.ribbit_hut.not_enough_room").red()
|
||||
);
|
||||
player.inventoryMenu.broadcastFullState();
|
||||
e.cancel();
|
||||
} else {
|
||||
setRibbitHutBlocks(level, block, player, server);
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.leftClicked(["society:ribbit_hut_block"], (e) => {
|
||||
e.player.tell(Text.translatable("block.society.ribbit_hut.break").red());
|
||||
});
|
||||
|
||||
BlockEvents.broken(["society:ribbit_hut"], (e) => {
|
||||
const { level, player, block } = e;
|
||||
let centerBlock = global.getOpposite(
|
||||
block.getProperties().get("facing"),
|
||||
block.getPos()
|
||||
);
|
||||
for (let pos of BlockPos.betweenClosed(
|
||||
new BlockPos(centerBlock.x - 1, centerBlock.y, centerBlock.z - 1),
|
||||
[centerBlock.x + 1, centerBlock.y + 2, centerBlock.z + 1]
|
||||
)) {
|
||||
level.getBlock(pos).set("minecraft:air");
|
||||
}
|
||||
player.give("society:ribbit_hut");
|
||||
});
|
||||
@@ -0,0 +1,144 @@
|
||||
console.info("[SOCIETY] seedMessage.js loaded");
|
||||
|
||||
const seedMessageThrottle = ((temp) => (entity, tick, identifier) => {
|
||||
const { age, uuid } = entity;
|
||||
const key = `${uuid}${identifier}`;
|
||||
const now = temp[key];
|
||||
if (!now || age - now >= tick) {
|
||||
temp[key] = age;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})({});
|
||||
|
||||
BlockEvents.rightClicked(
|
||||
[
|
||||
"minecraft:farmland",
|
||||
"dew_drop_farmland_growth:weak_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:strong_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:hyper_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:hydrating_farmland",
|
||||
"dew_drop_farmland_growth:bountiful_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:low_quality_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:high_quality_fertilized_farmland",
|
||||
"dew_drop_farmland_growth:pristine_quality_fertilized_farmland",
|
||||
],
|
||||
(e) => {
|
||||
const { player, level, block, server } = e;
|
||||
if (!player.getHeldItem("main_hand").hasTag("forge:seeds")) return;
|
||||
let errorText;
|
||||
const biomeTags = level
|
||||
.getBiome(block.pos)
|
||||
.tags()
|
||||
.map((tagkey) => tagkey.location())
|
||||
.toList();
|
||||
if (
|
||||
biomeTags.toString().includes("sereneseasons:tropical_biomes") &&
|
||||
!player.getHeldItem("main_hand").hasTag("sereneseasons:summer_crops")
|
||||
) {
|
||||
errorText = Text.translatable("society.planting_crop.eternal_summer").toJson();
|
||||
}
|
||||
if (
|
||||
Number(level.getBiome(block.pos).get().getTemperature(block.pos)) < 0.15 &&
|
||||
!player.getHeldItem("main_hand").hasTag("sereneseasons:winter_crops")
|
||||
) {
|
||||
errorText = Text.translatable("society.planting_crop.eternal_winter").toJson();
|
||||
}
|
||||
if (biomeTags.toString().includes("sereneseasons:infertile_biomes")) {
|
||||
errorText = Text.translatable("society.planting_crop.infertile_biome").toJson();
|
||||
}
|
||||
if (!seedMessageThrottle(player, 1200, "seed_message_throttle") && errorText) {
|
||||
global.renderUiText(
|
||||
player,
|
||||
server,
|
||||
{
|
||||
seedBiomeMessage: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -90,
|
||||
text: `${errorText}`,
|
||||
color: "#FF5555",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
seedBiomeMessageShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -89,
|
||||
text: `${errorText}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
},
|
||||
global.mainUiElementIds
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
// BlockEvents.placed(
|
||||
// ([
|
||||
// "minecraft:cactus",
|
||||
// "moreminecarts:glass_cactus",
|
||||
// "minecraft:sugar_cane",
|
||||
// "nethervinery:crimson_grape_bush",
|
||||
// "nethervinery:warped_grape_bush",
|
||||
// "vinery:jungle_grape_bush_red",
|
||||
// "vinery:jungle_grape_bush_white",
|
||||
// "vinery:taiga_grape_bush_white",
|
||||
// "vinery:taiga_grape_bush_red",
|
||||
// "vinery:savanna_grape_bush_white",
|
||||
// "vinery:savanna_grape_bush_red",
|
||||
// "vinery:white_grape_bush",
|
||||
// "vinery:red_grape_bush",
|
||||
// "windswept:wild_berry_bush",
|
||||
// "minecraft:sweet_berry_bush",
|
||||
// ],
|
||||
// (e) => {
|
||||
// const { player, block, server } = e;
|
||||
// let errorText;
|
||||
// if (
|
||||
// ["minecraft:cactus", "moreminecarts:glass_cactus", "minecraft:sugar_cane"].includes(block.id)
|
||||
// ) {
|
||||
// errorText = "This must be planted on Tilled Sand to grow";
|
||||
// }
|
||||
// if (block.id.includes("jungle")) {
|
||||
// errorText = "This Seed must be planted on a Vinery Lattice to grow";
|
||||
// } else if (block.id.includes("grape")) {
|
||||
// errorText = "This must be planted on a Grapevine Stem to grow";
|
||||
// }
|
||||
// if (block.id.includes("berry")) {
|
||||
// errorText = "This berry must be planted on farmland to grow";
|
||||
// }
|
||||
|
||||
// if (errorText) {
|
||||
// global.renderUiText(
|
||||
// player,
|
||||
// server,
|
||||
// {
|
||||
// seedBiomeMessage: {
|
||||
// type: "text",
|
||||
// x: 0,
|
||||
// y: -90,
|
||||
// text: errorText,
|
||||
// color: "#FF5555",
|
||||
// alignX: "center",
|
||||
// alignY: "bottom",
|
||||
// },
|
||||
// seedBiomeMessageShadow: {
|
||||
// type: "text",
|
||||
// x: 1,
|
||||
// z: -1,
|
||||
// y: -89,
|
||||
// text: errorText,
|
||||
// color: "#000000",
|
||||
// alignX: "center",
|
||||
// alignY: "bottom",
|
||||
// },
|
||||
// },
|
||||
// global.mainUiElementIds
|
||||
// );
|
||||
// }
|
||||
// })
|
||||
// );
|
||||
@@ -0,0 +1,40 @@
|
||||
console.info("[SOCIETY] shippingBinNamed.js loaded");
|
||||
|
||||
const shippingBins = [
|
||||
"shippingbin:basic_shipping_bin",
|
||||
"shippingbin:smart_shipping_bin",
|
||||
];
|
||||
|
||||
const getCustomNameJson = (item) => {
|
||||
if (!item || !item.nbt?.display?.Name) return null;
|
||||
return String(item.nbt.display.Name);
|
||||
};
|
||||
|
||||
const getStoredCustomName = (nbt) => {
|
||||
if (!nbt || !nbt.data) return null;
|
||||
return nbt.data.customName || nbt.data.custom_name || null;
|
||||
};
|
||||
|
||||
|
||||
BlockEvents.placed(shippingBins, (e) => {
|
||||
const { player, block } = e;
|
||||
if (!player) return;
|
||||
let item = player.getHeldItem("main_hand");
|
||||
if (item.id !== block.id) item = player.getHeldItem("off_hand");
|
||||
if (item.id !== block.id) return;
|
||||
const customName = getCustomNameJson(item);
|
||||
if (!customName) return;
|
||||
let nbt = block.getEntityData();
|
||||
nbt.merge({ data: { customName: customName } });
|
||||
global.setBlockEntityData(block, nbt);
|
||||
});
|
||||
|
||||
BlockEvents.broken(shippingBins, (e) => {
|
||||
const { block } = e;
|
||||
const nbt = block.getEntityData();
|
||||
const customName = getStoredCustomName(nbt);
|
||||
const drop = customName
|
||||
? Item.of(block.id, `{display:{Name:${NBT.stringTag(String(customName))}}}`)
|
||||
: Item.of(block.id);
|
||||
block.popItem(drop);
|
||||
});
|
||||
@@ -0,0 +1,246 @@
|
||||
console.info("[SOCIETY] skullCavernBroken.js loaded");
|
||||
|
||||
const crashableHammers = [
|
||||
"botania:terra_pick",
|
||||
"justhammers:diamond_impact_hammer",
|
||||
"justhammers:gold_impact_hammer",
|
||||
"justhammers:iron_impact_hammer",
|
||||
"justhammers:stone_impact_hammer",
|
||||
"justhammers:netherite_hammer",
|
||||
"justhammers:diamond_hammer",
|
||||
"justhammers:gold_hammer",
|
||||
"justhammers:iron_hammer",
|
||||
"justhammers:stone_hammer",
|
||||
"justhammers:netherite_impact_hammer",
|
||||
];
|
||||
|
||||
const biomeAirTypeMap = new Map([
|
||||
["society:cavern_top", 0],
|
||||
["society:skull_caves", 0],
|
||||
["society:lush_caverns", 0],
|
||||
["society:frozen_caves", 1],
|
||||
["society:frozen_maelstrom", 1],
|
||||
["society:desert_caves", 2],
|
||||
["society:desert_fault", 2],
|
||||
["society:blackstone_caves", 3],
|
||||
["society:umbra_barrens", 4],
|
||||
]);
|
||||
|
||||
const scheduleFunction = (level, pos, server, rockType) => {
|
||||
if (global.susFunctionLogging)
|
||||
console.log("[SOCIETY-SUSFN] skullCavernBroken.js - Regen Air");
|
||||
server.schedule(5, () => {
|
||||
let toggleBit = level.persistentData.chunkParityMap[level.getChunkAt(pos).pos.toString()].toggleBit;
|
||||
if (!level.isLoaded(pos)) return;
|
||||
if (
|
||||
level.getBlock(pos) &&
|
||||
["minecraft:air", "minecraft:void_air", "minecraft:cave_air"].includes(
|
||||
level.getBlock(pos).id
|
||||
)
|
||||
) {
|
||||
level.getBlock(pos).set("society:cavern_air", {
|
||||
type: String(rockType),
|
||||
chunkbit: toggleBit.toString(),
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
BlockEvents.broken(
|
||||
[
|
||||
"society:stone_boulder",
|
||||
"society:ice_boulder",
|
||||
"society:sandstone_boulder",
|
||||
"society:blackstone_boulder",
|
||||
"society:end_stone_boulder",
|
||||
"minecraft:deepslate_copper_ore",
|
||||
"oreganized:lead_ore",
|
||||
"create:zinc_ore",
|
||||
"create:deepslate_zinc_ore",
|
||||
"society:geode_node",
|
||||
"society:magma_geode_node",
|
||||
"society:omni_geode_node",
|
||||
"society:earth_crystal",
|
||||
"society:fire_quartz",
|
||||
"minecraft:deepslate_emerald_ore",
|
||||
"minecraft:emerald_ore",
|
||||
"minecraft:deepslate_lapis_ore",
|
||||
"minecraft:lapis_ore",
|
||||
"minecraft:deepslate_diamond_ore",
|
||||
"minecraft:diamond_ore",
|
||||
"society:deepslate_sparkstone_ore",
|
||||
"society:sparkstone_ore",
|
||||
"society:deepslate_iridium_ore",
|
||||
"society:iridium_ore",
|
||||
"minecraft:copper_ore",
|
||||
"minecraft:deepslate_iron_ore",
|
||||
"minecraft:iron_ore",
|
||||
"minecraft:coal_ore",
|
||||
"minecraft:deepslate_coal_ore",
|
||||
"minecraft:deepslate_redstone_ore",
|
||||
"minecraft:redstone_ore",
|
||||
"oreganized:deepslate_silver_ore",
|
||||
"oreganized:silver_ore",
|
||||
"minecraft:deepslate_gold_ore",
|
||||
"minecraft:gold_ore",
|
||||
"oreganized:deepslate_lead_ore",
|
||||
"society:grimwood_supply_crate",
|
||||
"society:oak_supply_crate",
|
||||
"society:spruce_supply_crate",
|
||||
"society:palm_supply_crate",
|
||||
],
|
||||
(e) => {
|
||||
const { level, block, player, server } = e;
|
||||
const pos = block.getPos();
|
||||
if (level.dimension === "society:skull_cavern") {
|
||||
if (global.disableHammersSkullCavern && crashableHammers.includes(player.getHeldItem("main_hand").id)) {
|
||||
server.runCommandSilent(
|
||||
`dialog ${player.username} show ${player.username} ${player.getHeldItem("main_hand").id.equals("botania:terra_pick") ? "goddess_unique_skull_cavern_shatterer" : "goddess_unique_skull_cavern_hammer"}`
|
||||
);
|
||||
e.cancel();
|
||||
}
|
||||
let rockType = biomeAirTypeMap.get(`${block.biomeId.toString()}`);
|
||||
scheduleFunction(level, pos.immutable(), server, rockType);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const scheduleUnplaceableRegenFunction = (level, pos, server, id) => {
|
||||
server.scheduleInTicks(100, () => {
|
||||
if (!level.isLoaded(pos)) return;
|
||||
if (level.getBlock(pos) == "minecraft:air") {
|
||||
level.getBlock(pos).set(id);
|
||||
level.spawnParticles(
|
||||
"snowyspirit:glow_light",
|
||||
true,
|
||||
pos.x,
|
||||
pos.y + 0.5,
|
||||
pos.z,
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
5,
|
||||
2
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
// Skull Cavern unplacable tag
|
||||
BlockEvents.broken(
|
||||
[
|
||||
"atmospheric:arid_sand",
|
||||
"atmospheric:red_arid_sand",
|
||||
"minecraft:sand",
|
||||
"minecraft:basalt",
|
||||
"minecraft:end_stone",
|
||||
"minecraft:magma_block",
|
||||
"oreganized:glance",
|
||||
"oreganized:glance_bricks",
|
||||
"oreganized:polished_glance",
|
||||
"minecraft:moss_block",
|
||||
"minecraft:pale_moss_block",
|
||||
"oreganized:spotted_glance",
|
||||
"minecraft:snow_block",
|
||||
"minecraft:blue_ice",
|
||||
"minecraft:packed_ice",
|
||||
],
|
||||
(e) => {
|
||||
const { level, block, server } = e;
|
||||
const unplacablePos = block.getPos();
|
||||
if (level.dimension === "society:skull_cavern") {
|
||||
scheduleUnplaceableRegenFunction(
|
||||
level,
|
||||
unplacablePos.immutable(),
|
||||
server,
|
||||
block.getId()
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
LevelEvents.beforeExplosion((e) => {
|
||||
const { x, y, z, size, level, server } = e;
|
||||
if (level.dimension === "society:skull_cavern") {
|
||||
if (global.susFunctionLogging)
|
||||
console.log("[SOCIETY-SUSFN] skullCavernBroken.js - explosion");
|
||||
let range = Math.round(Math.floor((size * 1.3) / 0.225) * 0.5);
|
||||
let blocks = [];
|
||||
|
||||
for (let xi = Math.floor(x - range); xi <= Math.ceil(x + range); xi++) {
|
||||
for (let zi = Math.floor(z - range); zi <= Math.ceil(z + range); zi++) {
|
||||
for (let yi = Math.floor(y - range); yi <= Math.ceil(y + range); yi++) {
|
||||
let dist = Math.hypot(x - xi, y - yi, z - zi);
|
||||
if (dist <= range) {
|
||||
let block = level.getBlock(xi, yi, zi);
|
||||
if (block.hasTag("society:skull_cavern_bomb_denied")) {
|
||||
blocks.push({ xi: xi, yi: yi, zi: zi, dist: dist, id: block.id });
|
||||
} else if (block.hasTag("society:skull_cavern_regens")) {
|
||||
let rockType = biomeAirTypeMap.get(`${block.biomeId.toString()}`);
|
||||
scheduleFunction(level, block.pos.immutable(), server, rockType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blocks.sort((a, b) => a.dist - b.dist);
|
||||
|
||||
for (let i = 0; i < blocks.length; i++) {
|
||||
let { xi, yi, zi, id } = blocks[i];
|
||||
server.scheduleInTicks(i, () => {
|
||||
level.getBlock(xi, yi, zi).set(id);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.broken("society:skull_cavern_teleporter", (e) => {
|
||||
const { level } = e;
|
||||
if (level.dimension === "society:skull_cavern") e.cancel();
|
||||
});
|
||||
|
||||
BlockEvents.broken(
|
||||
[
|
||||
"society:stone_boulder",
|
||||
"society:ice_boulder",
|
||||
"society:sandstone_boulder",
|
||||
"society:blackstone_boulder",
|
||||
"society:end_stone_boulder",
|
||||
],
|
||||
(e) => {
|
||||
const { level, player, server, block } = e;
|
||||
if (player.stages.has("moon_rope_reveal") && Math.random() < 0.15) {
|
||||
const { x, y, z } = block;
|
||||
let scanBlock;
|
||||
let abovePos;
|
||||
let radius = 8;
|
||||
for (let pos of BlockPos.betweenClosed(
|
||||
new BlockPos(x - radius, y - radius, z - radius),
|
||||
[x + radius, y + radius, z + radius]
|
||||
)) {
|
||||
if (!level.isLoaded(pos)) continue;
|
||||
scanBlock = level.getBlock(pos);
|
||||
abovePos = scanBlock.getPos().above();
|
||||
if (
|
||||
scanBlock.id == "farmersdelight:rope" &&
|
||||
level.getBlock(abovePos).id != "farmersdelight:rope"
|
||||
) {
|
||||
level.spawnParticles(
|
||||
"species:spectre_pop",
|
||||
true,
|
||||
abovePos.x,
|
||||
abovePos.y + 0.5,
|
||||
abovePos.z,
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
0.1 * rnd(1, 4),
|
||||
5,
|
||||
0.01
|
||||
);
|
||||
server.runCommandSilent(
|
||||
`playsound create:peculiar_bell_use block @a ${abovePos.x} ${abovePos.y} ${abovePos.z}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,64 @@
|
||||
console.info("[SOCIETY] skullCavernPlace.js loaded");
|
||||
|
||||
BlockEvents.placed((e) => {
|
||||
const { player, block, level, server } = e;
|
||||
if (level.dimension === "society:skull_cavern") {
|
||||
if (
|
||||
block.hasTag("society:skull_cavern_unplacable") &&
|
||||
!player.isCreative()
|
||||
) {
|
||||
let message = Text.translatable(
|
||||
"society.skull_cavern.prevent_block_place"
|
||||
).toJson();
|
||||
global.renderUiText(
|
||||
player,
|
||||
server,
|
||||
{
|
||||
skullCavernPlaceBlockMessage: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -90,
|
||||
text: `${message}`,
|
||||
color: "#FF5555",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
skullCavernPlaceBlockMessageShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -89,
|
||||
text: `${message}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
},
|
||||
global.mainUiElementIds
|
||||
);
|
||||
e.player.inventoryMenu.broadcastFullState();
|
||||
e.cancel();
|
||||
} else if (global.skullCavernHardmode) {
|
||||
server.scheduleInTicks(0, () => {
|
||||
server.scheduleInTicks(
|
||||
block.id === "minecraft:torch" ? 1200 : 200,
|
||||
() => {
|
||||
level.destroyBlock(block.pos, true);
|
||||
level.spawnParticles(
|
||||
"snowyspirit:glow_light",
|
||||
true,
|
||||
block.x,
|
||||
block.y + 0.5,
|
||||
block.z,
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
5,
|
||||
2
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
console.info("[SOCIETY] skullTeleporter.js loaded");
|
||||
|
||||
BlockEvents.leftClicked("society:skull_cavern_teleporter", (e) => {
|
||||
if (e.level.dimension === "society:skull_cavern") e.cancel();
|
||||
});
|
||||
BlockEvents.rightClicked("society:skull_cavern_teleporter", (e) => {
|
||||
const { block, player, level, item, hand, server } = e;
|
||||
const { x, z } = block;
|
||||
let errorText;
|
||||
if (hand == "OFF_HAND") return;
|
||||
if (item === 'society:magic_rope') e.cancel();
|
||||
if (!player.stages.has("entered_skull_cavern")) player.stages.add("entered_skull_cavern");
|
||||
if (level.dimension === "society:skull_cavern") {
|
||||
player.persistentData.skullCavernEnterDay = -1;
|
||||
global.teleportHome(player, server, level);
|
||||
} else if (level.dimension !== "society:skull_cavern") {
|
||||
if (level.dayTime() % 24000 > 18000) {
|
||||
errorText = Text.translatable("society.skull_cavern.too_late").toJson();
|
||||
} else {
|
||||
if (!player.stages.has("skull_cavern_intro")) {
|
||||
player.stages.add("skull_cavern_intro");
|
||||
player.tell(Text.translatable("society.skull_cavern.intro").gold());
|
||||
player.tell(Text.translatable("society.new_villager.message").green());
|
||||
player.give(Item.of("gag:escape_rope"));
|
||||
let noteTitle = global.translatableWithFallback("society.skull_cavern.intro.note.title", "A Warning").getString();
|
||||
let noteAuthor = global.translatableWithFallback("society.skull_cavern.intro.note.author", "someone...").getString();
|
||||
let noteText = Text.translatable("society.skull_cavern.intro.note").toJson();
|
||||
player.give(
|
||||
global.getNotePaperItem(noteAuthor, noteText, noteTitle)
|
||||
);
|
||||
}
|
||||
player.teleportTo("society:skull_cavern", x, 512, z, 0, 0);
|
||||
player.persistentData.skullCavernEnterDay = global.getDay(level);
|
||||
let playerLevel = player.getLevel()
|
||||
if (playerLevel.dimension === "society:skull_cavern") {
|
||||
playerLevel.getBlock(x, 511, z).set("society:skull_cavern_teleporter");
|
||||
} else {
|
||||
server.scheduleInTicks(10, () => {
|
||||
player.getLevel().getBlock(x, 511, z).set("society:skull_cavern_teleporter");
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
errorText = Text.translatable("society.skull_cavern.invalid_dimension").toJson();
|
||||
}
|
||||
if (errorText) {
|
||||
global.renderUiText(
|
||||
player,
|
||||
server,
|
||||
{
|
||||
skullTeleportMessage: {
|
||||
type: "text",
|
||||
x: 0,
|
||||
y: -90,
|
||||
text: `${errorText}`,
|
||||
color: "#FF5555",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
skullTeleportMessageShadow: {
|
||||
type: "text",
|
||||
x: 1,
|
||||
z: -1,
|
||||
y: -89,
|
||||
text: `${errorText}`,
|
||||
color: "#000000",
|
||||
alignX: "center",
|
||||
alignY: "bottom",
|
||||
},
|
||||
},
|
||||
global.mainUiElementIds
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
console.info("[SOCIETY] slimeContainProtect.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("splendid_slimes:slime_incubator", (e) => {
|
||||
const { block, player, hand, item, server } = e;
|
||||
if (player.isFake() || player.isCrouching()) return;
|
||||
if (hand == "OFF_HAND") return;
|
||||
const heldItem = item.getId();
|
||||
const facing = block.getProperties().facing;
|
||||
if (block.properties.get("working") === "true") return;
|
||||
|
||||
if (Math.random() < 0.15 && heldItem == "splendid_slimes:slime_heart") {
|
||||
if (!player.stages.has("slime_contain_protect")) {
|
||||
block.popItemFromFace("society:slime_contain_protect", facing);
|
||||
server.runCommandSilent(
|
||||
`playsound stardew_fishing:complete block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
} else {
|
||||
block.popItemFromFace("splendid_slimes:slime_ticket", facing);
|
||||
server.runCommandSilent(
|
||||
`playsound stardew_fishing:complete block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
console.info("[SOCIETY] slotMachine.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("tanukidecor:slot_machine", (e) => {
|
||||
const { block, player, hand, item, server } = e;
|
||||
if (player.isFake() || player.isCrouching()) return;
|
||||
if (hand == "OFF_HAND") return;
|
||||
const coins = [
|
||||
"numismatics:spur",
|
||||
"numismatics:bevel",
|
||||
"numismatics:sprocket",
|
||||
"numismatics:cog",
|
||||
"numismatics:crown",
|
||||
"numismatics:sun",
|
||||
"numismatics:ancient_coin",
|
||||
"numismatics:neptunium_coin",
|
||||
"numismatics:prismatic_coin",
|
||||
];
|
||||
const prismaticCoins = [
|
||||
"numismatics:sun",
|
||||
"numismatics:neptunium_coin",
|
||||
"numismatics:ancient_coin",
|
||||
"numismatics:prismatic_coin",
|
||||
];
|
||||
const heldItem = item.getId();
|
||||
const facing = block.getProperties().facing;
|
||||
const half = block.getProperties().half;
|
||||
const entityHalf = half === "upper" ? block : block.up;
|
||||
|
||||
if (entityHalf.getEntityData().StartTime !== 0.0) {
|
||||
e.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.properties.get("working") === "true") return;
|
||||
block.set(block.id, {
|
||||
facing: block.properties.get("facing"),
|
||||
half: block.properties.get("half"),
|
||||
waterlogged: block.properties.get("waterlogged"),
|
||||
working: true,
|
||||
});
|
||||
|
||||
if (coins.includes(heldItem)) {
|
||||
item.count--;
|
||||
|
||||
server.scheduleInTicks(115, () => {
|
||||
const { x, y, z } = entityHalf.getEntityData().SlotRotations;
|
||||
if (x === y && y === z) {
|
||||
const itemAddition = player.stages.has("the_red_and_the_black") ? 1 : 0;
|
||||
block.popItemFromFace(`${3 + itemAddition}x ${heldItem}`, facing);
|
||||
server.runCommandSilent(
|
||||
`playsound stardew_fishing:complete block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
if (
|
||||
prismaticCoins.includes(heldItem) &&
|
||||
player.stages.has("adventuring_mastery") &&
|
||||
!player.stages.has("the_red_and_the_black") &&
|
||||
Math.random() < 0.05
|
||||
) {
|
||||
block.popItemFromFace(`1x society:the_red_and_the_black`, facing);
|
||||
server.tell(
|
||||
Text.translatable(
|
||||
"society.slot_machine.win_big",
|
||||
Text.red(`${player.username}`)
|
||||
).black()
|
||||
);
|
||||
}
|
||||
if (
|
||||
prismaticCoins.includes(heldItem) &&
|
||||
Math.random() < (heldItem === "numismatics:sun" ? 0.005 : 0.1)
|
||||
) {
|
||||
block.popItemFromFace(
|
||||
`${1 + itemAddition}x society:prismatic_shard`,
|
||||
facing
|
||||
);
|
||||
server.tell(
|
||||
Text.translatable(
|
||||
"society.slot_machine.win_big",
|
||||
Text.gold(`${player.username}`)
|
||||
).gray()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
server.runCommandSilent(
|
||||
`playsound stardew_fishing:fish_escape block @a ${player.x} ${player.y} ${player.z}`
|
||||
);
|
||||
}
|
||||
block.set(block.id, {
|
||||
facing: block.properties.get("facing"),
|
||||
half: block.properties.get("half"),
|
||||
waterlogged: block.properties.get("waterlogged"),
|
||||
working: false,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
console.info("[SOCIETY] treechopSkill.js loaded");
|
||||
|
||||
BlockEvents.broken("treechop:chopped_log", (e) => {
|
||||
const { player, block, level } = e;
|
||||
if (Math.random() <= 0.005 && !player.stages.has("wuthering_logs")) {
|
||||
block.popItem("society:wuthering_logs");
|
||||
}
|
||||
if (
|
||||
Math.random() <= 0.15 &&
|
||||
player.stages.has("wuthering_logs") &&
|
||||
block.id === "treechop:chopped_log"
|
||||
) {
|
||||
block.popItem("meadow:fire_log");
|
||||
}
|
||||
|
||||
const season = global.getSeasonFromLevel(level);
|
||||
if (
|
||||
Math.random() <= 0.005 &&
|
||||
season === "autumn" &&
|
||||
!player.stages.has("alias_moss")
|
||||
) {
|
||||
block.popItem("society:alias_moss");
|
||||
}
|
||||
if (
|
||||
Math.random() <= 0.08 &&
|
||||
(player.stages.has("alias_moss") || season === "autumn") &&
|
||||
block.id === "treechop:chopped_log"
|
||||
) {
|
||||
block.popItem("society:mossberry");
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
console.info("[SOCIETY] updateBountyBoard.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("bountiful:bountyboard", (e) => {
|
||||
const { level, block } = e;
|
||||
let seasonalBounties = ["summer", "spring", "autumn", "winter"];
|
||||
let blockNbt = block.getEntityData();
|
||||
const decrees = blockNbt.decree_inv.Items;
|
||||
let isSeasonal;
|
||||
let hasChanged;
|
||||
for (let index = 0; index < decrees.length; index++) {
|
||||
seasonalBounties.forEach((season) => {
|
||||
if (!isSeasonal)
|
||||
isSeasonal = decrees[index].tag["bountiful:decree_data"].toString().includes(season);
|
||||
});
|
||||
if (isSeasonal) {
|
||||
blockNbt.decree_inv.Items[index].tag["bountiful:decree_data"] = Object(
|
||||
`{"ids":["${global.getSeasonFromLevel(level)}"]}`
|
||||
);
|
||||
isSeasonal = false;
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
if (hasChanged) {
|
||||
global.setBlockEntityData(block, blockNbt);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
console.info("[SOCIETY] upgradeSparkstoneMachines.js loaded");
|
||||
|
||||
BlockEvents.rightClicked("society:fish_pond_basket", (e) => {
|
||||
const { player, item, block, hand, level } = e;
|
||||
const upgraded = block.properties.get("upgraded").toLowerCase() == "true";
|
||||
|
||||
if (hand == "OFF_HAND") return;
|
||||
if (hand == "MAIN_HAND" && !upgraded && item == "minecraft:bucket") {
|
||||
if (!player.isCreative()) item.count--;
|
||||
level.spawnParticles(
|
||||
"farmersdelight:star",
|
||||
true,
|
||||
block.x,
|
||||
block.y + 1,
|
||||
block.z,
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
3,
|
||||
0.01
|
||||
);
|
||||
block.set(block.id, {
|
||||
upgraded: true,
|
||||
waterlogged: block.properties.get("waterlogged"),
|
||||
});
|
||||
e.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
BlockEvents.rightClicked("society:auto_grabber", (e) => {
|
||||
const { player, item, block, hand, level } = e;
|
||||
const upgraded = block.properties.get("upgraded").toLowerCase() == "true";
|
||||
if (hand == "OFF_HAND") return;
|
||||
if (hand == "MAIN_HAND" && !upgraded && item == "society:magic_shears") {
|
||||
if (!player.isCreative()) item.count--;
|
||||
level.spawnParticles(
|
||||
"farmersdelight:star",
|
||||
true,
|
||||
block.x,
|
||||
block.y + 1,
|
||||
block.z,
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
0.2 * rnd(1, 4),
|
||||
3,
|
||||
0.01
|
||||
);
|
||||
block.set(block.id, {
|
||||
upgraded: true,
|
||||
facing: block.properties.get("facing"),
|
||||
});
|
||||
e.cancel();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user