Implement furnace cook speed multiplier API

Fixed an issue where a furnace's cook-speed multiplier rounds down
to the nearest Integer when updating its current cook time.

== AT ==
public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity getTotalCookTime(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity;)I

Co-authored-by: Eric Su <ericsu@alumni.usc.edu>
This commit is contained in:
Tassu
2018-09-13 08:45:21 +03:00
parent ac503c148a
commit 4bea989f34
2 changed files with 88 additions and 16 deletions

View File

@@ -88,4 +88,20 @@ public abstract class CraftFurnace<T extends AbstractFurnaceBlockEntity> extends
@Override
public abstract CraftFurnace<T> copy(Location location);
// Paper start - cook speed multiplier API
@Override
public double getCookSpeedMultiplier() {
return this.getSnapshot().cookSpeedMultiplier;
}
@Override
public void setCookSpeedMultiplier(double multiplier) {
com.google.common.base.Preconditions.checkArgument(multiplier >= 0, "Furnace speed multiplier cannot be negative");
com.google.common.base.Preconditions.checkArgument(multiplier <= 200, "Furnace speed multiplier cannot more than 200");
T snapshot = this.getSnapshot();
snapshot.cookSpeedMultiplier = multiplier;
snapshot.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(this.isPlaced() ? this.world.getHandle() : null, snapshot, snapshot.recipeType, snapshot.cookSpeedMultiplier); // Update the snapshot's current total cook time to scale with the newly set multiplier
}
// Paper end
}