add first patch
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
const starvationPrevention = (entity, affectionPenaltyMult) => {
|
||||
let entityNbt = entity.getNbt();
|
||||
const day = global.getDay(entity.level);
|
||||
if (day - entity.persistentData.getInt("ageLastFed") > 1) {
|
||||
entityNbt.EggLayTime = 20400;
|
||||
} else if (Math.random() > entity.persistentData.getInt("affection") / 1000) {
|
||||
entityNbt.EggLayTime = entityNbt.EggLayTime + 1000 * affectionPenaltyMult;
|
||||
} else if (entityNbt.EggLayTime > 12000) entityNbt.EggLayTime = 10240;
|
||||
entity.setNbt(entityNbt);
|
||||
};
|
||||
|
||||
EntityJSEvents.modifyEntity((event) => {
|
||||
event.modify("minecraft:chicken", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 1000 === 0) {
|
||||
starvationPrevention(entity, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
event.modify("untitledduckmod:duck", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 1000 === 0) {
|
||||
starvationPrevention(entity, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
event.modify("untitledduckmod:goose", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 1000 === 0) {
|
||||
starvationPrevention(entity, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
event.modify("autumnity:turkey", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 1000 === 0) {
|
||||
starvationPrevention(entity, 2);
|
||||
}
|
||||
});
|
||||
});
|
||||
event.modify("etcetera:chapple", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 1000 === 0) {
|
||||
let entityNbt = entity.getNbt();
|
||||
const day = global.getDay(entity.level);
|
||||
if (day - entity.persistentData.getInt("ageLastFed") > 1) {
|
||||
entityNbt.AppleLayTime = 20400;
|
||||
} else if (entityNbt.AppleLayTime > 12000) entityNbt.AppleLayTime = 10240;
|
||||
entity.setNbt(entityNbt);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,137 @@
|
||||
global.handleHayGolem = (entity) => {
|
||||
const { level } = entity;
|
||||
const entities = level
|
||||
.getEntitiesWithin(entity.boundingBox.inflate(8))
|
||||
.filter((e) => e.type == "golemoverhaul:hay_golem");
|
||||
const radius = 4;
|
||||
const { x, y, z } = entity;
|
||||
let scanBlock;
|
||||
if (entities.length <= 1) {
|
||||
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);
|
||||
if (rnd10() && scanBlock.hasTag("society:hay_golem_improvable")) {
|
||||
if (scanBlock.id.equals("minecraft:farmland")) {
|
||||
scanBlock.set(
|
||||
"dew_drop_farmland_growth:low_quality_fertilized_farmland",
|
||||
scanBlock.getProperties()
|
||||
);
|
||||
} else if (
|
||||
scanBlock.id.equals(
|
||||
"dew_drop_farmland_growth:low_quality_fertilized_farmland"
|
||||
)
|
||||
) {
|
||||
scanBlock.set(
|
||||
"dew_drop_farmland_growth:high_quality_fertilized_farmland",
|
||||
scanBlock.getProperties()
|
||||
);
|
||||
}
|
||||
if (level.server) {
|
||||
level.server.runCommandSilent(
|
||||
`playsound ribbits:entity.ribbit.magic block @a ${scanBlock.x} ${scanBlock.y} ${scanBlock.z}`
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
global.handleKelpGolem = (entity) => {
|
||||
const { level } = entity;
|
||||
const { x, y, z } = entity;
|
||||
const radius = 4;
|
||||
let scanBlock;
|
||||
let blockProperties;
|
||||
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);
|
||||
if (scanBlock.id === "dew_drop_farmland_growth:garden_pot") {
|
||||
blockProperties = scanBlock.getProperties();
|
||||
blockProperties.moisture = "7";
|
||||
scanBlock.set(scanBlock.id, blockProperties);
|
||||
}
|
||||
}
|
||||
if (level.server) {
|
||||
level.server.runCommandSilent(
|
||||
`playsound minecraft:block.water.ambient block @a ${x} ${y} ${z}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
global.handleTerracottaGolem = (entity) => {
|
||||
const { level } = entity;
|
||||
const { x, y, z } = entity;
|
||||
const radius = 4;
|
||||
let scanBlock;
|
||||
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);
|
||||
if (scanBlock.id.equals("minecraft:coarse_dirt")) {
|
||||
scanBlock.set("minecraft:clay");
|
||||
if (level.server) {
|
||||
level.server.runCommandSilent(
|
||||
`playsound twigs:block.silt.break block @a ${scanBlock.x} ${scanBlock.y} ${scanBlock.z}`
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
global.handleSlimeGolem = (entity) => {
|
||||
const { level } = entity;
|
||||
const entities = level
|
||||
.getEntitiesWithin(entity.boundingBox.inflate(8))
|
||||
.filter((e) => e.type == "splendid_slimes:splendid_slime");
|
||||
|
||||
const golems = level
|
||||
.getEntitiesWithin(entity.boundingBox.inflate(8))
|
||||
.filter((e) => e.type == "golemoverhaul:slime_golem");
|
||||
if (golems.length <= 1) {
|
||||
entities.forEach((slime) => {
|
||||
let nbt = slime.getNbt();
|
||||
nbt.Happiness = nbt.Happiness + 5;
|
||||
slime.setNbt(nbt);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
EntityJSEvents.modifyEntity((event) => {
|
||||
event.modify("golemoverhaul:hay_golem", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 3600 === 0) {
|
||||
global.handleHayGolem(entity);
|
||||
}
|
||||
});
|
||||
});
|
||||
event.modify("golemoverhaul:kelp_golem", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 1200 === 0) {
|
||||
global.handleKelpGolem(entity);
|
||||
}
|
||||
});
|
||||
});
|
||||
event.modify("golemoverhaul:terracotta_golem", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 200 === 0) {
|
||||
global.handleTerracottaGolem(entity);
|
||||
}
|
||||
});
|
||||
});
|
||||
event.modify("golemoverhaul:slime_golem", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 1200 === 0) {
|
||||
global.handleSlimeGolem(entity);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
global.getLongwingSize = (size) => {
|
||||
let resolvedSize = Math.min(1.0, Math.max(0.5, 0.5 + (Math.random() / 2.0)));
|
||||
if (size == "normal") resolvedSize = Math.min(1.15, Math.max(0.85, 0.85 + (Math.random() / 5.0)));
|
||||
if (size == "larger") resolvedSize = Math.min(1.15, Math.max(0.85, 0.85 + (Math.random() / 3.0)));
|
||||
return resolvedSize;
|
||||
}
|
||||
|
||||
global.getLongwingFromEgg = (parent, coparent) => {
|
||||
if (parent === coparent) return parent;
|
||||
|
||||
let parent1;
|
||||
let parent2;
|
||||
global.longwings.forEach((wing, index) => {
|
||||
if (wing.variant == parent) parent1 = index;
|
||||
if (wing.variant == coparent) parent2 = index;
|
||||
});
|
||||
|
||||
let child = parent1 + parent2;
|
||||
if (global.longwings.length - 1 < child) child -= global.longwings.length;
|
||||
|
||||
let maxAllowedRarity = Math.min(global.longwings[parent1].rarity, global.longwings[parent2].rarity) - 1;
|
||||
let initialChild = child;
|
||||
|
||||
while (global.longwings[child].rarity < maxAllowedRarity) {
|
||||
child++;
|
||||
if (child >= global.longwings.length) child = 0;
|
||||
if (child === initialChild) break;
|
||||
}
|
||||
|
||||
return global.longwings[child].variant;
|
||||
};
|
||||
|
||||
global.handleLongwings = (entity, item) => {
|
||||
const { level } = entity;
|
||||
const entities = level
|
||||
.getEntitiesWithin(entity.boundingBox.inflate(8))
|
||||
.filter((e) => e !== entity && global.checkEntityTag(e, "society:longwing"));
|
||||
const radius = 4;
|
||||
const { x, y, z } = entity;
|
||||
let scanBlock;
|
||||
let scannedBlocks = 0;
|
||||
let scannedFlowers = [];
|
||||
let stolenBlock;
|
||||
if (global.susFunctionLogging) console.log("[SOCIETY-SUSFN] modifyLongwings.js");
|
||||
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);
|
||||
if (scanBlock.hasTag("minecraft:flowers") && !scannedFlowers.includes(scanBlock.id)) {
|
||||
scannedFlowers.push(scanBlock.id);
|
||||
scannedBlocks++;
|
||||
if (!stolenBlock) stolenBlock = scanBlock;
|
||||
}
|
||||
}
|
||||
const chance = Math.min(1, scannedBlocks * 0.15 - entities.length * 0.1);
|
||||
if (chance > 0 && Math.random() <= chance) {
|
||||
let drop = level.createEntity("minecraft:item");
|
||||
drop.item = item;
|
||||
drop.x = x + 0.5;
|
||||
drop.y = y;
|
||||
drop.z = z + 0.5;
|
||||
drop.spawn();
|
||||
if (Math.random <= 0.08) {
|
||||
stolenBlock.set("minecraft:air");
|
||||
}
|
||||
}
|
||||
if (entities.length > 0 && true && chance > 0 && Math.random() <= (chance / 4)) {
|
||||
entities.sort((a, b) => a.distanceToSqr(entity) - b.distanceToSqr(entity));
|
||||
let coparent = entities[0];
|
||||
let eggs = level.createEntity("minecraft:item");
|
||||
let parentVariant = entity.getNbt().Variant;
|
||||
let coparentVariant = coparent.getNbt().Variant
|
||||
eggs.item = Item.of(
|
||||
"1x society:caterpillar_eggs",
|
||||
`{parent:"${parentVariant}",coparent:"${coparentVariant}",child:"${global.getLongwingFromEgg(parentVariant, coparentVariant)}",size:${Math.max(0.25, Math.round((((entity.getNbt().size + coparent.getNbt().size) + Math.random()) / 2) * 100) / 100)}}`);
|
||||
if (Math.random() <= 0.001) {
|
||||
eggs.item = Item.of("society:the_metamorphosize")
|
||||
}
|
||||
eggs.x = x + 0.5;
|
||||
eggs.y = y;
|
||||
eggs.z = z + 0.5;
|
||||
eggs.spawn();
|
||||
}
|
||||
};
|
||||
|
||||
EntityJSEvents.modifyEntity((event) => {
|
||||
event.modify("longwings:moth", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 6000 === 0) {
|
||||
global.handleLongwings(entity, "society:moth_pollen");
|
||||
}
|
||||
});
|
||||
});
|
||||
event.modify("longwings:butterfly", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 6000 === 0) {
|
||||
global.handleLongwings(entity, "society:butterfly_amber");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
global.handleRibbit = (entity) => {
|
||||
const nbt = entity.nbt.toString();
|
||||
|
||||
if (nbt.includes("gardener")) {
|
||||
let freshVillager = entity.level.createEntity("ribbits:ribbit");
|
||||
let villagerNbt = freshVillager.getNbt();
|
||||
villagerNbt.Brain.memories = entity.nbt.Brain.memories;
|
||||
freshVillager.customName = entity.customName;
|
||||
villagerNbt.Pos = [Number(entity.x), Number(entity.y), Number(entity.z)];
|
||||
freshVillager.setNbt(villagerNbt);
|
||||
villagerNbt.RibbitData = {
|
||||
umbrella: "ribbits:umbrella_3",
|
||||
instrument: "ribbits:none",
|
||||
profession: "ribbits:fisherman",
|
||||
};
|
||||
freshVillager.setNbt(villagerNbt);
|
||||
freshVillager.spawn();
|
||||
entity.setRemoved("unloaded_to_chunk");
|
||||
}
|
||||
};
|
||||
|
||||
EntityJSEvents.modifyEntity((event) => {
|
||||
event.modify("ribbits:ribbit", (modifyBuilder) => {
|
||||
modifyBuilder.tick((entity) => {
|
||||
if (entity.level.time % 1200 === 0) {
|
||||
global.handleRibbit(entity);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user