-
Notifications
You must be signed in to change notification settings - Fork 28
Correction de la bulle de corruption du Cube (Jump Boost) #1287
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
Open
iambibi
wants to merge
1
commit into
ServerOpenMC:master
Choose a base branch
from
iambibi:fix/cube-bubble
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
26 changes: 26 additions & 0 deletions
26
src/main/java/fr/openmc/core/features/cube/events/CubeActivateBubbleEvent.java
This file contains hidden or 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,26 @@ | ||
| package fr.openmc.core.features.cube.events; | ||
|
|
||
| import fr.openmc.core.features.cube.Cube; | ||
| import lombok.Getter; | ||
| import org.bukkit.event.Event; | ||
| import org.bukkit.event.HandlerList; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| @Getter | ||
| public class CubeActivateBubbleEvent extends Event { | ||
| private static final HandlerList HANDLERS = new HandlerList(); | ||
| private final Cube cube; | ||
|
|
||
| public CubeActivateBubbleEvent(Cube cube) { | ||
| this.cube = cube; | ||
| } | ||
|
|
||
| public static HandlerList getHandlerList() { | ||
| return HANDLERS; | ||
| } | ||
|
|
||
| @Override | ||
| public @NotNull HandlerList getHandlers() { | ||
| return HANDLERS; | ||
| } | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
src/main/java/fr/openmc/core/features/cube/events/CubeDesactivateBubbleEvent.java
This file contains hidden or 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,26 @@ | ||
| package fr.openmc.core.features.cube.events; | ||
|
|
||
| import fr.openmc.core.features.cube.Cube; | ||
| import lombok.Getter; | ||
| import org.bukkit.event.Event; | ||
| import org.bukkit.event.HandlerList; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| @Getter | ||
| public class CubeDesactivateBubbleEvent extends Event { | ||
|
Contributor
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. Desactivate -> Disable |
||
| private static final HandlerList HANDLERS = new HandlerList(); | ||
| private final Cube cube; | ||
|
|
||
| public CubeDesactivateBubbleEvent(Cube cube) { | ||
| this.cube = cube; | ||
| } | ||
|
|
||
| public static HandlerList getHandlerList() { | ||
| return HANDLERS; | ||
| } | ||
|
|
||
| @Override | ||
| public @NotNull HandlerList getHandlers() { | ||
| return HANDLERS; | ||
| } | ||
| } | ||
This file contains hidden or 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
73 changes: 73 additions & 0 deletions
73
src/main/java/fr/openmc/core/features/cube/tasks/CorruptedBubbleTask.java
This file contains hidden or 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,73 @@ | ||
| package fr.openmc.core.features.cube.tasks; | ||
|
|
||
| import fr.openmc.core.OMCPlugin; | ||
| import fr.openmc.core.features.cube.Cube; | ||
| import fr.openmc.core.features.cube.events.CubeDesactivateBubbleEvent; | ||
| import fr.openmc.core.features.dream.DreamUtils; | ||
| import org.bukkit.Bukkit; | ||
| import org.bukkit.Location; | ||
| import org.bukkit.Material; | ||
| import org.bukkit.block.Block; | ||
| import org.bukkit.scheduler.BukkitRunnable; | ||
|
|
||
| public class CorruptedBubbleTask extends BukkitRunnable { | ||
| private final Cube cube; | ||
| private final int radiusBubble; | ||
| private final int totalTicks; | ||
| private final int interval; | ||
| private int elapsed = 0; | ||
|
|
||
| public CorruptedBubbleTask(Cube cube, int radiusBubble, int intervalCorruption, int totalTicks) { | ||
| this.cube = cube; | ||
| this.radiusBubble = radiusBubble; | ||
| this.totalTicks = totalTicks; | ||
| this.interval = intervalCorruption; | ||
| } | ||
|
|
||
| @Override | ||
| public void run() { | ||
| if (elapsed >= totalTicks) { | ||
| cancel(); | ||
| cube.corruptedBubbleTask = null; | ||
| Bukkit.getScheduler().runTask(OMCPlugin.getInstance(), () -> | ||
| Bukkit.getPluginManager().callEvent(new CubeDesactivateBubbleEvent(cube))); | ||
| return; | ||
| } | ||
|
|
||
| for (int i = 0; i < 30; i++) { | ||
| double theta = Math.random() * 2 * Math.PI; | ||
| double phi = Math.random() * Math.PI; | ||
| double r = Math.random() * radiusBubble; | ||
|
|
||
| double x = r * Math.sin(phi) * Math.cos(theta); | ||
| double y = r * Math.cos(phi); | ||
| double z = r * Math.sin(phi) * Math.sin(theta); | ||
|
|
||
| if (cube.isPartOf(new Location(cube.getCenter().getWorld(), x, y, z))) continue; | ||
|
|
||
| Location loc = cube.getCenter().clone().add(x, y, z); | ||
| Block block = loc.getBlock(); | ||
| Material type = block.getType(); | ||
|
|
||
| if (!DreamUtils.isDreamWorld(loc)) { | ||
| switch (type) { | ||
| case DIRT, GRASS_BLOCK, SAND, GRAVEL -> block.setType(Material.WARPED_NYLIUM); | ||
| case OAK_LOG, BIRCH_LOG, SPRUCE_LOG, JUNGLE_LOG, DARK_OAK_LOG, | ||
| ACACIA_LOG, MANGROVE_LOG -> block.setType(Material.WARPED_STEM); | ||
| case AIR, LAPIS_BLOCK -> { | ||
| } | ||
| default -> block.setType(Material.SCULK); | ||
| } | ||
| } else { | ||
| switch (type) { | ||
| case MUD -> block.setType(Material.SAND); | ||
| case AIR, LAPIS_BLOCK -> { | ||
| } | ||
| default -> block.setType(Material.GRASS_BLOCK); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| elapsed += interval; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Activate -> Enable