Fix crop drops being able to roll 0
This commit is contained in:
@@ -292,7 +292,7 @@ interface CropDrops {
|
||||
young?: Items;
|
||||
// fully grown, like wheat's wheat
|
||||
mature?: Items;
|
||||
// fully grown, 0 to 3 more of this, like the extra seeds from wheat (minecraft's binomial with 3 tries at 57%)
|
||||
// fully grown, 1 to 4 of this, like the seeds from wheat (minecraft's loot tables: 1 plus 3 tries at 57%)
|
||||
bonus?: string;
|
||||
}
|
||||
|
||||
@@ -371,9 +371,9 @@ function register_farming(ctx: ServerContext) {
|
||||
const drop = (x: number, y: number, z: number, drops: CropDrops | undefined, mature: boolean) => {
|
||||
for (const id of list(mature ? drops?.mature : drops?.young)) ctx.world.drop_item(x, y, z, { id, count: 1 });
|
||||
if (mature && drops?.bonus) {
|
||||
let count = 0;
|
||||
let count = 1;
|
||||
for (let i = 0; i < 3; i++) if (Math.random() < 0.5714) count++;
|
||||
if (count > 0) ctx.world.drop_item(x, y, z, { id: drops.bonus, count });
|
||||
ctx.world.drop_item(x, y, z, { id: drops.bonus, count });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user