Skip to content

Commit

Permalink
Include use_cooldown by default for custom items
Browse files Browse the repository at this point in the history
  • Loading branch information
SoSeDiK committed Dec 29, 2024
1 parent f535385 commit c6954d0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <[email protected]>
Date: Sat, 26 Feb 2022 16:43:33 -0800
Subject: [PATCH] Add Paper PR - FillBottleEvents for player and dispenser
Subject: [PATCH] Paper PR - Add FillBottleEvents for player and dispenser

Adds 2 events, PlayerFillBottleEvent and BlockFillBottleEvent. These
events do not have a common superclass due to needing to extend
Expand Down
7 changes: 4 additions & 3 deletions patches/server/0018-Data-driven-items.patch
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ index b1710da835cee3333bfb1c238b37ec0c4d16ba09..cadbf29c4667a74d79fdc538e0cca9cc
}
diff --git a/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java b/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java
new file mode 100644
index 0000000000000000000000000000000000000000..b570e05a15274f7582f3363990d077a9e927e3c6
index 0000000000000000000000000000000000000000..5c665a7b431314c3dcb16c4d11643434181a8763
--- /dev/null
+++ b/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java
@@ -0,0 +1,129 @@
@@ -0,0 +1,130 @@
+package me.sosedik.kiterino.registry.data;
+
+import io.papermc.paper.datacomponent.DataComponentType;
Expand Down Expand Up @@ -130,7 +130,8 @@ index 0000000000000000000000000000000000000000..b570e05a15274f7582f3363990d077a9
+
+ @Override
+ public @NonNull Object constructItemProperties() {
+ return new Item.Properties().setId(ResourceKey.create(Registries.ITEM, this.itemKey));
+ return new Item.Properties()
+ .setId(ResourceKey.create(Registries.ITEM, this.itemKey));
+ }
+
+ protected void parseValues(@NonNull Item item) {
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0019-Data-driven-blocks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ index 0000000000000000000000000000000000000000..4f9365a06cd4d61218b48aba812763ca
+
+}
diff --git a/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java b/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java
index b570e05a15274f7582f3363990d077a9e927e3c6..01b2058573b0104a3618b42586b27bfb1a528154 100644
index 5c665a7b431314c3dcb16c4d11643434181a8763..53885600bdd389949aca90a01a039737e4dd3a0b 100644
--- a/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java
+++ b/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java
@@ -1,5 +1,7 @@
Expand All @@ -130,8 +130,8 @@ index b570e05a15274f7582f3363990d077a9e927e3c6..01b2058573b0104a3618b42586b27bfb
import io.papermc.paper.datacomponent.DataComponentType;
import io.papermc.paper.datacomponent.PaperDataComponentType;
import io.papermc.paper.registry.PaperRegistryBuilder;
@@ -63,6 +65,16 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
return new Item.Properties().setId(ResourceKey.create(Registries.ITEM, this.itemKey));
@@ -64,6 +66,16 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
.setId(ResourceKey.create(Registries.ITEM, this.itemKey));
}

+ @Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,41 @@ index 0000000000000000000000000000000000000000..16242986d124173007c4e18dd6219e5d
+
+}
diff --git a/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java b/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java
index 01b2058573b0104a3618b42586b27bfb1a528154..255adb3a27c38cf8a9c7a759588c824c3b9d9622 100644
index 53885600bdd389949aca90a01a039737e4dd3a0b..2a60bf487fe0a5e6cb7be88fef2d68078e9af3ce 100644
--- a/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java
+++ b/src/main/java/me/sosedik/kiterino/registry/data/KiterinoItemRegistryEntity.java
@@ -1,5 +1,10 @@
@@ -1,5 +1,12 @@
package me.sosedik.kiterino.registry.data;

+import me.sosedik.kiterino.modifier.item.KiterinoItemModifier;
+import me.sosedik.kiterino.modifier.item.KiterinoItemModifierImpl;
+import net.minecraft.core.component.DataComponents;
+import org.bukkit.inventory.ItemStack;
+import net.minecraft.world.item.component.UseCooldown;
+import java.util.Optional;
+
import net.minecraft.core.registries.BuiltInRegistries;

import io.papermc.paper.datacomponent.DataComponentType;
@@ -23,6 +28,7 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
@@ -23,6 +30,7 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
protected Map<DataComponentType, Object> components = new HashMap<>();
protected @Nullable Float compostChance;
protected @Nullable Item nmsItem;
+ protected @Nullable KiterinoItemModifier modifier;

protected final Conversions conversions;
public ResourceLocation itemKey;
@@ -75,6 +81,11 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
@@ -63,7 +71,8 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
@Override
public @NonNull Object constructItemProperties() {
return new Item.Properties()
- .setId(ResourceKey.create(Registries.ITEM, this.itemKey));
+ .setId(ResourceKey.create(Registries.ITEM, this.itemKey))
+ .component(DataComponents.USE_COOLDOWN, new UseCooldown(0F, Optional.of(this.itemKey)));
}

@Override
@@ -76,6 +85,11 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
return BuiltInRegistries.BLOCK.getValueOrThrow(ResourceKey.create(Registries.BLOCK, this.itemKey));
}

Expand All @@ -101,7 +113,7 @@ index 01b2058573b0104a3618b42586b27bfb1a528154..255adb3a27c38cf8a9c7a759588c824c
protected void parseValues(@NonNull Item item) {
// Does it make sense to parse?
// DataComponentMap components = item.components();
@@ -113,6 +124,33 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
@@ -114,6 +128,33 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
return this;
}

Expand Down Expand Up @@ -135,7 +147,7 @@ index 01b2058573b0104a3618b42586b27bfb1a528154..255adb3a27c38cf8a9c7a759588c824c
@SuppressWarnings("unchecked")
@Override
public @NonNull Item build() {
@@ -129,6 +167,7 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
@@ -130,6 +171,7 @@ public class KiterinoItemRegistryEntity implements ItemRegistryEntity {
item = new Item(properties);
}
if (this.compostChance != null) ComposterBlock.add(this.compostChance, item);
Expand Down

0 comments on commit c6954d0

Please sign in to comment.