Skip to content

Commit 6aad880

Browse files
committed
compile fixes and equipOnInteract
1 parent cab3010 commit 6aad880

File tree

7 files changed

+73
-5
lines changed

7 files changed

+73
-5
lines changed

paper-api/src/main/java/io/papermc/paper/datacomponent/item/Equippable.java

+17
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ static Equippable.Builder equippable(final EquipmentSlot slot) {
9696
@Contract(pure = true)
9797
boolean damageOnHurt();
9898

99+
/**
100+
* Checks if the item should be equipped when interacting with an entity.
101+
*
102+
* @return true if it equips on interact, false otherwise
103+
*/
104+
@Contract(pure = true)
105+
boolean equipOnInteract();
106+
99107
/**
100108
* Builder for {@link Equippable}.
101109
*/
@@ -165,5 +173,14 @@ interface Builder extends DataComponentBuilder<Equippable> {
165173
*/
166174
@Contract(value = "_ -> this", mutates = "this")
167175
Builder damageOnHurt(boolean damageOnHurt);
176+
177+
/**
178+
* Sets whether the item should be equipped when interacting with an entity.
179+
*
180+
* @param equipOnInteract true if it equips on interact
181+
* @return the builder for chaining
182+
*/
183+
@Contract(value = "_ -> this", mutates = "this")
184+
Builder equipOnInteract(boolean equipOnInteract);
168185
}
169186
}

paper-api/src/main/java/org/bukkit/inventory/meta/components/EquippableComponent.java

+14
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,18 @@ public interface EquippableComponent extends ConfigurationSerializable {
150150
* @param damage whether the item will be damaged
151151
*/
152152
void setDamageOnHurt(boolean damage);
153+
154+
/**
155+
* Gets if the item should be equipped when interacting with an entity.
156+
*
157+
* @return whether the item equips on interact
158+
*/
159+
boolean isEquipOnInteract();
160+
161+
/**
162+
* Sets if the item should be equipped when interacting with an entity.
163+
*
164+
* @param equip whether the item equips on interact
165+
*/
166+
void setEquipOnInteract(boolean equip);
153167
}

paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch

+13
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,19 @@
553553
BlockPos blockPos = this.mainSupportingBlockPos.get();
554554
if (!(yOffset > 1.0E-5F)) {
555555
return blockPos;
556+
@@ -1338,6 +_,12 @@
557+
|| this.level().isRainingAt(BlockPos.containing(blockPos.getX(), this.getBoundingBox().maxY, blockPos.getZ()));
558+
}
559+
560+
+ // Paper start - Bubble Column API
561+
+ public boolean isInBubbleColumn() {
562+
+ return this.getInBlockState().is(Blocks.BUBBLE_COLUMN);
563+
+ }
564+
+ // Paper end - Bubble Column API
565+
+
566+
public boolean isInWaterOrRain() {
567+
return this.isInWater() || this.isInRain();
568+
}
556569
@@ -1519,6 +_,7 @@
557570
this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F);
558571
this.yRotO = this.getYRot();

paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperEquippable.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ public boolean damageOnHurt() {
8080
return this.impl.damageOnHurt();
8181
}
8282

83+
@Override
84+
public boolean equipOnInteract() {
85+
return this.impl.equipOnInteract();
86+
}
87+
8388
@Override
8489
public Builder toBuilder() {
8590
return new BuilderImpl(this.slot())
@@ -89,7 +94,8 @@ public Builder toBuilder() {
8994
.allowedEntities(this.allowedEntities())
9095
.dispensable(this.dispensable())
9196
.swappable(this.swappable())
92-
.damageOnHurt(this.damageOnHurt());
97+
.damageOnHurt(this.damageOnHurt())
98+
.equipOnInteract(this.equipOnInteract());
9399
}
94100

95101

@@ -103,6 +109,7 @@ static final class BuilderImpl implements Builder {
103109
private boolean dispensable = true;
104110
private boolean swappable = true;
105111
private boolean damageOnHurt = true;
112+
private boolean equipOnInteract;
106113

107114
BuilderImpl(final EquipmentSlot equipmentSlot) {
108115
this.equipmentSlot = CraftEquipmentSlot.getNMS(equipmentSlot);
@@ -155,6 +162,12 @@ public Builder damageOnHurt(final boolean damageOnHurt) {
155162
return this;
156163
}
157164

165+
@Override
166+
public Builder equipOnInteract(final boolean equipOnInteract) {
167+
this.equipOnInteract = equipOnInteract;
168+
return this;
169+
}
170+
158171
@Override
159172
public Equippable build() {
160173
return new PaperEquippable(
@@ -166,7 +179,8 @@ public Equippable build() {
166179
this.allowedEntities,
167180
this.dispensable,
168181
this.swappable,
169-
this.damageOnHurt
182+
this.damageOnHurt,
183+
this.equipOnInteract
170184
)
171185
);
172186
}

paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,7 @@ public com.destroystokyo.paper.profile.PlayerProfile createProfile(@NotNull UUID
31173117
}
31183118

31193119
@Override
3120-
public com.destroystokyo.paper.profile.PlayerProfile createProfile(@NonnNotNullull String name) {
3120+
public com.destroystokyo.paper.profile.PlayerProfile createProfile(@NotNull String name) {
31213121
return createProfile(null, name);
31223122
}
31233123

paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1158,12 +1158,12 @@ public boolean isInWaterOrRain() {
11581158

11591159
@Override
11601160
public boolean isInWaterOrBubbleColumn() {
1161-
return getHandle().isInWaterOrBubble();
1161+
return getHandle().isInBubbleColumn() || getHandle().isInWater();
11621162
}
11631163

11641164
@Override
11651165
public boolean isInWaterOrRainOrBubbleColumn() {
1166-
return getHandle().isInWaterRainOrBubble();
1166+
return getHandle().isInBubbleColumn() || getHandle().isInWaterOrRain();
11671167
}
11681168

11691169
@Override

paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftEquippableComponent.java

+10
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ public void setDamageOnHurt(boolean damage) {
207207
this.handle = new Equippable(this.handle.slot(), this.handle.equipSound(), this.handle.assetId(), this.handle.cameraOverlay(), this.handle.allowedEntities(), this.handle.dispensable(), this.handle.swappable(), damage, this.handle.equipOnInteract());
208208
}
209209

210+
@Override
211+
public boolean isEquipOnInteract() {
212+
return this.handle.equipOnInteract();
213+
}
214+
215+
@Override
216+
public void setEquipOnInteract(final boolean equip) {
217+
this.handle = new Equippable(this.handle.slot(), this.handle.equipSound(), this.handle.assetId(), this.handle.cameraOverlay(), this.handle.allowedEntities(), this.handle.dispensable(), this.handle.swappable(), this.handle.damageOnHurt(), equip);
218+
}
219+
210220
@Override
211221
public int hashCode() {
212222
int hash = 7;

0 commit comments

Comments
 (0)