-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
447 additions
and
44 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
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
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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/pancake/surviving_the_aftermath/api/IAftermathEvent.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,9 @@ | ||
package com.pancake.surviving_the_aftermath.api; | ||
|
||
import dev.latvian.mods.kubejs.event.EventJS; | ||
import net.minecraftforge.eventbus.api.Event; | ||
|
||
public interface IAftermathEvent { | ||
Event getForge(); | ||
EventJS getKubeJS(); | ||
} |
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
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
85 changes: 85 additions & 0 deletions
85
src/main/java/com/pancake/surviving_the_aftermath/common/event/AftermathEvent.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,85 @@ | ||
package com.pancake.surviving_the_aftermath.common.event; | ||
|
||
import com.pancake.surviving_the_aftermath.api.IAftermath; | ||
import com.pancake.surviving_the_aftermath.api.IAftermathEvent; | ||
import com.pancake.surviving_the_aftermath.api.base.BaseAftermath; | ||
import com.pancake.surviving_the_aftermath.api.base.BaseAftermathModule; | ||
import com.pancake.surviving_the_aftermath.api.module.IAftermathModule; | ||
import dev.latvian.mods.kubejs.event.EventJS; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraftforge.eventbus.api.Cancelable; | ||
import net.minecraftforge.eventbus.api.Event; | ||
|
||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
public abstract class AftermathEvent extends Event implements IAftermathEvent { | ||
private final IAftermath aftermath; | ||
private final IAftermathModule module; | ||
private final Set<UUID> players; | ||
private final ServerLevel level; | ||
|
||
public AftermathEvent(IAftermath aftermath, Set<UUID> players, ServerLevel level) { | ||
this.aftermath = aftermath; | ||
this.module = aftermath.getModule(); | ||
this.players = players; | ||
this.level = level; | ||
} | ||
|
||
@Override | ||
public Event getForge() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public EventJS getKubeJS() { | ||
return null; | ||
} | ||
|
||
@Cancelable | ||
public static class Start extends AftermathEvent { | ||
public Start(IAftermath aftermath, Set<UUID> players, ServerLevel level) { | ||
super(aftermath,players, level); | ||
} | ||
} | ||
public static class End extends AftermathEvent { | ||
|
||
public End(IAftermath aftermath, Set<UUID> players, ServerLevel level) { | ||
super(aftermath, players, level); | ||
} | ||
} | ||
@Cancelable | ||
public static class Ready extends AftermathEvent { | ||
|
||
public Ready(IAftermath aftermath, Set<UUID> players, ServerLevel level) { | ||
super(aftermath, players, level); | ||
} | ||
} | ||
|
||
public static class Ongoing extends AftermathEvent { | ||
|
||
public Ongoing(IAftermath aftermath, Set<UUID> players, ServerLevel level) { | ||
super(aftermath, players, level); | ||
} | ||
} | ||
public static class Victory extends AftermathEvent { | ||
|
||
public Victory(IAftermath aftermath, Set<UUID> players, ServerLevel level) { | ||
super(aftermath, players, level); | ||
} | ||
} | ||
public static class Lose extends AftermathEvent { | ||
|
||
public Lose(IAftermath aftermath, Set<UUID> players, ServerLevel level) { | ||
super(aftermath, players, level); | ||
} | ||
} | ||
@Cancelable | ||
public static class Celebrating extends AftermathEvent { | ||
public Celebrating(IAftermath aftermath, Set<UUID> players, ServerLevel level) { | ||
super(aftermath, players, level); | ||
} | ||
} | ||
|
||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...in/java/com/pancake/surviving_the_aftermath/common/event/subscriber/ClientForgeEvent.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,48 @@ | ||
package com.pancake.surviving_the_aftermath.common.event.subscriber; | ||
|
||
import com.pancake.surviving_the_aftermath.SurvivingTheAftermath; | ||
import com.pancake.surviving_the_aftermath.api.AftermathManager; | ||
import net.minecraft.client.gui.components.LerpingBossEvent; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
@Mod.EventBusSubscriber(modid = SurvivingTheAftermath.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) | ||
public class ClientForgeEvent { | ||
@SubscribeEvent | ||
public static void netherRaidProgress(CustomizeGuiOverlayEvent.BossEventProgress event) { | ||
LerpingBossEvent bossEvent = event.getBossEvent(); | ||
AftermathManager manager = AftermathManager.getInstance(); | ||
manager.getAftermath(bossEvent.getId()).ifPresent(aftermath -> { | ||
event.setCanceled(true); | ||
var graphics = event.getGuiGraphics(); | ||
ResourceLocation resource = aftermath.getBarsResource(); | ||
int[] offset = aftermath.getBarsOffset(); | ||
|
||
if (resource == null || offset == null) { | ||
return; | ||
} | ||
|
||
int frameWidth = offset[0]; | ||
int frameHeight = offset[1]; | ||
int barWidth = offset[2]; | ||
int barHeight = offset[3]; | ||
int frameOffset = offset[4]; | ||
int barOffset = offset[5]; | ||
|
||
//渲染进度条框 | ||
graphics.blit(resource, (graphics.guiWidth() - frameWidth) / 2, event.getY() - 10, | ||
0, frameOffset, frameWidth, frameHeight); | ||
//渲染进度条 | ||
graphics.blit(resource, (graphics.guiWidth() - barWidth) / 2, event.getY() - 10 + barOffset, | ||
0, 0, (int) (barWidth * event.getBossEvent().getProgress()), barHeight); | ||
event.setIncrement(frameHeight); | ||
}); | ||
} | ||
} |
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.