aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpariator <97362524+pariator@users.noreply.github.com>2022-02-23 10:10:00 -0700
committerGitHub <noreply@github.com>2022-02-23 18:10:00 +0100
commit8d8100a2c370f0b41f3e1bc80182fb7a3988a974 (patch)
treefde3344c9f6bede647a72ee8d86f4edeb9467fd1
parent603da93d5f05f9cab491f036caef8e81bbd003c7 (diff)
downloadGT5-Unofficial-8d8100a2c370f0b41f3e1bc80182fb7a3988a974.tar.gz
GT5-Unofficial-8d8100a2c370f0b41f3e1bc80182fb7a3988a974.tar.bz2
GT5-Unofficial-8d8100a2c370f0b41f3e1bc80182fb7a3988a974.zip
Minor bugfix/cleanup (#941)
* Fixes slime spawn handling variances After testing, I was able to see 2 separate problems. 1: event.getResult() was occasionally returning ALLOW for some of the world spawned slimes. Slime spawn denial is done regardless of the ALLOW/DENY flag. This does not impact slimes spawned via eggs or powered spawners or slimes spawning after a slime is killed which apparently return DEFAULT for getResult(). 2: Slimes don't seem to properly handle a getResult() value of DENY. The checkSpawn event is not cancellable. To fix this, the entity is also destroyed by setting isDead to true. This does occasionally cause slimes to appear on the minimap briefly before disappearing. Lastly, with a forge update this could be handled much better by using the EntitySlime.spawnReason enum. That is not present in the current forge version, so I would consider this a temporary workaround and this method could/should be reworked if/when forge is updated. * Make repellators stop slimes. While testing, this was used to name the slimes as they were being generated. It turns out to also make the slimes behave properly in addition to the other changes. * Minor Cleanup Moved the slime handling out of the rest of the method and takes an approach of setting it to DEFAULT of it is ALLOW and then also adding a custom name tag if it doesn't have one. If it does have a custom name tag and ALLOW, then the slime spawn will be allowed. * Moved the setCustomNameTag method This method is still required to properly stop ALL slime spawns but it should only alter the customNameTag when a slime is intended to be stopped from spawning. * Fixed likely exception Check for instance of EntitySlime before casting it. This method is only required to stop slimes from spawning so is only being called against slimes. Co-authored-by: Randy Braunm <randy@unseencolor.com>
-rw-r--r--src/main/java/gregtech/api/util/GT_SpawnEventHandler.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java b/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java
index 2191c119cb..9edb64a196 100644
--- a/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java
+++ b/src/main/java/gregtech/api/util/GT_SpawnEventHandler.java
@@ -24,7 +24,6 @@ public class GT_SpawnEventHandler {
@SubscribeEvent
public void denyMobSpawn(CheckSpawn event) {
if (event.entityLiving instanceof EntitySlime && !(((EntitySlime) event.entityLiving).getCustomNameTag().length() > 0)) {
- ((EntitySlime) event.entityLiving).setCustomNameTag("DoNotSpawnSlimes");
if(event.getResult() == Event.Result.ALLOW) event.setResult(Event.Result.DEFAULT);
}
@@ -42,6 +41,7 @@ public class GT_SpawnEventHandler {
double dy = rep[1] + 0.5F - event.entity.posY;
double dz = rep[2] + 0.5F - event.entity.posZ;
if ((dx * dx + dz * dz + dy * dy) <= Math.pow(r, 2)) {
+ if(event.entityLiving instanceof EntitySlime) ((EntitySlime) event.entityLiving).setCustomNameTag("DoNotSpawnSlimes");
event.setResult(Event.Result.DENY);
}
}