2021-12-13 21:57:39 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: LemonCaramel <admin@caramel.moe>
|
|
|
|
Date: Fri, 16 Jul 2021 00:39:03 +0900
|
|
|
|
Subject: [PATCH] Add more Campfire API
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
|
2024-04-24 18:15:59 +02:00
|
|
|
index e858d32c7e8e228a1f0327a33054671ad105c2eb..24563a43f25d4621291b1ba6f24773cccedddbfe 100644
|
2021-12-13 21:57:39 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
|
2024-04-24 18:15:59 +02:00
|
|
|
@@ -47,6 +47,7 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
|
2021-12-13 21:57:39 +01:00
|
|
|
public final int[] cookingProgress;
|
|
|
|
public final int[] cookingTime;
|
2022-06-08 14:33:46 +02:00
|
|
|
private final RecipeManager.CachedCheck<Container, CampfireCookingRecipe> quickCheck;
|
2024-01-18 22:00:40 +01:00
|
|
|
+ public final boolean[] stopCooking; // Paper - Add more Campfire API
|
2021-12-13 21:57:39 +01:00
|
|
|
|
|
|
|
public CampfireBlockEntity(BlockPos pos, BlockState state) {
|
|
|
|
super(BlockEntityType.CAMPFIRE, pos, state);
|
2024-04-24 18:15:59 +02:00
|
|
|
@@ -54,6 +55,7 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
|
2021-12-13 21:57:39 +01:00
|
|
|
this.cookingProgress = new int[4];
|
|
|
|
this.cookingTime = new int[4];
|
2022-06-08 14:33:46 +02:00
|
|
|
this.quickCheck = RecipeManager.createCheck(RecipeType.CAMPFIRE_COOKING);
|
2024-01-18 22:00:40 +01:00
|
|
|
+ this.stopCooking = new boolean[4]; // Paper - Add more Campfire API
|
2021-12-13 21:57:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void cookTick(Level world, BlockPos pos, BlockState state, CampfireBlockEntity campfire) {
|
2024-04-24 18:15:59 +02:00
|
|
|
@@ -64,7 +66,9 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
|
2021-12-13 21:57:39 +01:00
|
|
|
|
|
|
|
if (!itemstack.isEmpty()) {
|
|
|
|
flag = true;
|
2024-01-18 22:00:40 +01:00
|
|
|
+ if (!campfire.stopCooking[i]) { // Paper - Add more Campfire API
|
2021-12-13 21:57:39 +01:00
|
|
|
int j = campfire.cookingProgress[i]++;
|
2024-01-18 22:00:40 +01:00
|
|
|
+ } // Paper - Add more Campfire API
|
2021-12-13 21:57:39 +01:00
|
|
|
|
|
|
|
if (campfire.cookingProgress[i] >= campfire.cookingTime[i]) {
|
|
|
|
SimpleContainer inventorysubcontainer = new SimpleContainer(new ItemStack[]{itemstack});
|
2024-04-24 18:15:59 +02:00
|
|
|
@@ -177,6 +181,16 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
|
2021-12-13 21:57:39 +01:00
|
|
|
System.arraycopy(aint, 0, this.cookingTime, 0, Math.min(this.cookingTime.length, aint.length));
|
|
|
|
}
|
|
|
|
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper start - Add more Campfire API
|
2021-12-13 21:57:39 +01:00
|
|
|
+ if (nbt.contains("Paper.StopCooking", org.bukkit.craftbukkit.util.CraftMagicNumbers.NBT.TAG_BYTE_ARRAY)) {
|
|
|
|
+ byte[] abyte = nbt.getByteArray("Paper.StopCooking");
|
|
|
|
+ boolean[] cookingState = new boolean[4];
|
|
|
|
+ for (int index = 0; index < abyte.length; index++) {
|
|
|
|
+ cookingState[index] = abyte[index] == 1;
|
|
|
|
+ }
|
|
|
|
+ System.arraycopy(cookingState, 0, this.stopCooking, 0, Math.min(this.stopCooking.length, abyte.length));
|
|
|
|
+ }
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper end - Add more Campfire API
|
2021-12-13 21:57:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-04-24 18:15:59 +02:00
|
|
|
@@ -185,6 +199,13 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
|
|
|
|
ContainerHelper.saveAllItems(nbt, this.items, true, registryLookup);
|
2021-12-13 21:57:39 +01:00
|
|
|
nbt.putIntArray("CookingTimes", this.cookingProgress);
|
|
|
|
nbt.putIntArray("CookingTotalTimes", this.cookingTime);
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper start - Add more Campfire API
|
2021-12-13 21:57:39 +01:00
|
|
|
+ byte[] cookingState = new byte[4];
|
|
|
|
+ for (int index = 0; index < cookingState.length; index++) {
|
|
|
|
+ cookingState[index] = (byte) (this.stopCooking[index] ? 1 : 0);
|
|
|
|
+ }
|
|
|
|
+ nbt.putByteArray("Paper.StopCooking", cookingState);
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper end - Add more Campfire API
|
2021-12-13 21:57:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java
|
2024-04-24 18:15:59 +02:00
|
|
|
index 4850cbf2c326f1155e04a204abed2d200c02342d..a776bba2ec51c6aecce98a3abceb2c235522d99d 100644
|
2021-12-13 21:57:39 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java
|
2024-04-24 18:15:59 +02:00
|
|
|
@@ -62,4 +62,40 @@ public class CraftCampfire extends CraftBlockEntityState<CampfireBlockEntity> im
|
|
|
|
public CraftCampfire copy(Location location) {
|
|
|
|
return new CraftCampfire(this, location);
|
2021-12-13 21:57:39 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public void stopCooking() {
|
|
|
|
+ for (int i = 0; i < getSnapshot().stopCooking.length; ++i)
|
|
|
|
+ this.stopCooking(i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void startCooking() {
|
|
|
|
+ for (int i = 0; i < getSnapshot().stopCooking.length; ++i)
|
|
|
|
+ this.startCooking(i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean stopCooking(int index) {
|
|
|
|
+ org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
|
|
|
+ boolean previous = this.isCookingDisabled(index);
|
|
|
|
+ getSnapshot().stopCooking[index] = true;
|
|
|
|
+ return previous;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean startCooking(int index) {
|
|
|
|
+ org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
|
|
|
+ boolean previous = this.isCookingDisabled(index);
|
|
|
|
+ getSnapshot().stopCooking[index] = false;
|
|
|
|
+ return previous;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCookingDisabled(int index) {
|
|
|
|
+ org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
|
|
|
+ return getSnapshot().stopCooking[index];
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|