-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add methods for CreakingHeart #12095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
c1f8d36
3359c43
7588ff9
c898ee0
16cecff
58888fe
5a54251
433bc1e
0306df1
47b97d0
a6681d7
0f0986a
de1eeb0
1fa85b6
6b38857
64a5272
63714bd
f1d7c36
083707c
3c9e92f
1ea7432
9d00d07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,61 @@ | ||
package org.bukkit.block; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.entity.Creaking; | ||
import org.jspecify.annotations.NullMarked; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
/** | ||
* Represents a captured state of a creaking heart. | ||
*/ | ||
@NullMarked | ||
public interface CreakingHeart extends TileState { | ||
|
||
/** | ||
* Gets the creaking protecting this creaking heart. | ||
* | ||
* @return the creaking or null if this creaking heart don't have protector. | ||
*/ | ||
@Nullable | ||
Creaking getCreaking(); | ||
|
||
/** | ||
* Sets the creaking protecting this creaking heart. | ||
* | ||
* @param creaking the creaking or null for make this creaking heart don't have protector | ||
* @throws IllegalArgumentException if the creaking passed it's in another world | ||
*/ | ||
void setCreaking(@Nullable Creaking creaking); | ||
|
||
/** | ||
* Gets the max distance between the Creaking Heart and the Creaking before to remove. | ||
* | ||
* @return the max distance | ||
*/ | ||
int getMaxDistanceForCreaking(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not like this method name.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the lasts ones not like just becauuse that value its not for spawn.. its for limit the max distance where a creaking can "live" maybe the first can work.. but not sure.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The last ones were for the new API regarding the replacement for scaling, sorry xD There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getCreakingRemovalDistance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
not sounds bad... maybe can use that then (based in not another comments xd) |
||
|
||
/** | ||
* Sets the max distance between the Creaking Heart and the Creaking before to remove. | ||
* | ||
* @param distance the max distance | ||
* @throws IllegalArgumentException if the distance is negative | ||
*/ | ||
void setMaxDistanceForCreaking(int distance); | ||
|
||
/** | ||
* Attempts to spawn a creaking for protect this creaking heart. | ||
* | ||
* @return the {@link Creaking} for protect the creaking heart or null if fails | ||
Doc94 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
@Nullable | ||
Creaking spawnCreaking(); | ||
|
||
/** | ||
* Attempts to spread resin to adjacent blocks. | ||
* | ||
* @apiNote This method triggers events related to a block being modified | ||
* @return the location of spread resin or null if it cannot spread | ||
Doc94 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
@Nullable | ||
Location spreadResin(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- a/net/minecraft/world/level/block/entity/CreakingHeartBlockEntity.java | ||
+++ b/net/minecraft/world/level/block/entity/CreakingHeartBlockEntity.java | ||
@@ -120,7 +_,7 @@ | ||
Optional<Creaking> creakingProtector = creakingHeart.getCreakingProtector(); | ||
if (creakingProtector.isPresent()) { | ||
Creaking creaking = creakingProtector.get(); | ||
- if (!CreakingHeartBlock.isNaturalNight(level) || creakingHeart.distanceToCreaking() > 34.0 || creaking.playerIsStuckInYou()) { | ||
+ if (!CreakingHeartBlock.isNaturalNight(level) || creakingHeart.distanceToCreaking() > creakingHeart.getDistanceCreakingTooFar() || creaking.playerIsStuckInYou()) { // Paper - custom distance for creaking | ||
creakingHeart.removeProtector(null); | ||
return; | ||
} | ||
@@ -187,9 +_,10 @@ | ||
|
||
@Nullable | ||
public static Creaking spawnProtector(ServerLevel level, CreakingHeartBlockEntity creakingHeart) { | ||
+ if (creakingHeart.getDistanceCreakingTooFar() <= 0) return null; // Paper - avoid spawn if the max distance is 0 | ||
Doc94 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
BlockPos blockPos = creakingHeart.getBlockPos(); | ||
Optional<Creaking> optional = SpawnUtil.trySpawnMob( | ||
- EntityType.CREAKING, EntitySpawnReason.SPAWNER, level, blockPos, 5, 16, 8, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER_NO_LEAVES, true | ||
+ EntityType.CREAKING, EntitySpawnReason.SPAWNER, level, blockPos, 5, Math.min(SPAWN_RANGE_XZ, creakingHeart.getDistanceCreakingTooFar()), Math.min(SPAWN_RANGE_Y, creakingHeart.getDistanceCreakingTooFar()), SpawnUtil.Strategy.ON_TOP_OF_COLLIDER_NO_LEAVES, true // Paper - handle too far distance for avoid spawn out of limits | ||
Doc94 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
if (optional.isEmpty()) { | ||
return null; | ||
@@ -335,6 +_,7 @@ | ||
} else { | ||
this.clearCreakingInfo(); | ||
} | ||
+ this.distanceCreakingTooFar = tag.contains(PAPER_CREAKING_MAX_DISTANCE_TAG, net.minecraft.nbt.Tag.TAG_ANY_NUMERIC) ? tag.getInt(PAPER_CREAKING_MAX_DISTANCE_TAG) : DISTANCE_CREAKING_TOO_FAR; // Paper - Custom max distance for Creaking | ||
} | ||
|
||
@Override | ||
@@ -343,5 +_,23 @@ | ||
if (this.creakingInfo != null) { | ||
tag.putUUID("creaking", this.creakingInfo.map(Entity::getUUID, uuid -> (UUID)uuid)); | ||
} | ||
- } | ||
+ if (this.distanceCreakingTooFar != DISTANCE_CREAKING_TOO_FAR) tag.putInt(PAPER_CREAKING_MAX_DISTANCE_TAG, this.distanceCreakingTooFar); // Paper - Custom max distance for Creaking | ||
+ } | ||
+ | ||
+ // Paper start - Custom Properties | ||
+ private final String PAPER_CREAKING_MAX_DISTANCE_TAG = "Paper.CreakingMaxDistance"; | ||
+ private int distanceCreakingTooFar = DISTANCE_CREAKING_TOO_FAR; | ||
+ | ||
+ public int getDistanceCreakingTooFar() { | ||
+ return this.distanceCreakingTooFar; | ||
+ } | ||
+ | ||
+ public void setDistanceCreakingTooFar(int distance) { | ||
+ this.distanceCreakingTooFar = distance; | ||
+ } | ||
+ | ||
+ public void resetEffectRange() { | ||
+ this.distanceCreakingTooFar = DISTANCE_CREAKING_TOO_FAR; | ||
+ } | ||
+ // Paper end | ||
} |
Uh oh!
There was an error while loading. Please reload this page.