Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the plugin from overriding the MobSpawnerAbstract field of sp…
…awners as it may conflict with other plugins
- Loading branch information
1 parent
40065e6
commit 843922a
Showing
21 changed files
with
508 additions
and
833 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 0 additions & 110 deletions
110
.../src/main/java/com/bgsoftware/superiorskyblock/nms/v117/spawners/BaseSpawnerNotifier.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
.../com/bgsoftware/superiorskyblock/nms/v117/spawners/TickingSpawnerBlockEntityNotifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.bgsoftware.superiorskyblock.nms.v117.spawners; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BaseSpawner; | ||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity; | ||
import net.minecraft.world.level.block.entity.TickingBlockEntity; | ||
|
||
import java.util.function.IntFunction; | ||
|
||
public class TickingSpawnerBlockEntityNotifier implements TickingBlockEntity { | ||
|
||
private final SpawnerBlockEntity spawnerBlockEntity; | ||
private final TickingBlockEntity tickingBlockEntity; | ||
private final IntFunction<Integer> delayChangeCallback; | ||
|
||
public TickingSpawnerBlockEntityNotifier(SpawnerBlockEntity spawnerBlockEntity, TickingBlockEntity tickingBlockEntity, | ||
IntFunction<Integer> delayChangeCallback) { | ||
this.spawnerBlockEntity = spawnerBlockEntity; | ||
this.tickingBlockEntity = tickingBlockEntity; | ||
this.delayChangeCallback = delayChangeCallback; | ||
updateDelay(); | ||
} | ||
|
||
@Override | ||
public void tick() { | ||
BaseSpawner baseSpawner = this.spawnerBlockEntity.getSpawner(); | ||
int startDelay = baseSpawner.spawnDelay; | ||
try { | ||
tickingBlockEntity.tick(); | ||
} finally { | ||
int newDelay = baseSpawner.spawnDelay; | ||
if (newDelay > startDelay) | ||
updateDelay(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isRemoved() { | ||
return tickingBlockEntity.isRemoved(); | ||
} | ||
|
||
@Override | ||
public BlockPos getPos() { | ||
return tickingBlockEntity.getPos(); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return tickingBlockEntity.getType(); | ||
} | ||
|
||
public void updateDelay() { | ||
BaseSpawner baseSpawner = spawnerBlockEntity.getSpawner(); | ||
baseSpawner.spawnDelay = delayChangeCallback.apply(baseSpawner.spawnDelay); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.