-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
19 changed files
with
125 additions
and
76 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
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
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/cstav/genshinstrument/event/ServerEvents.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,37 @@ | ||
package com.cstav.genshinstrument.event; | ||
|
||
import com.cstav.genshinstrument.item.InstrumentItem; | ||
import com.cstav.genshinstrument.util.CommonUtil; | ||
import com.cstav.genshinstrument.util.InstrumentEntityData; | ||
import com.cstav.genshinstrument.util.ServerUtil; | ||
|
||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
|
||
public abstract class ServerEvents { | ||
|
||
public static void register() { | ||
ServerTickEvents.START_WORLD_TICK.register(ServerEvents::onServerTick); | ||
} | ||
|
||
public static void onServerTick(final Level level) { | ||
level.players().forEach(ServerEvents::handleAbruptInstrumentClose); | ||
} | ||
|
||
private static void handleAbruptInstrumentClose(final Player player) { | ||
if (!InstrumentEntityData.isOpen(player)) | ||
return; | ||
|
||
if (InstrumentEntityData.isItem(player)) { | ||
// This is done like so because there is no event (that I know of) for when an item is moved/removed | ||
if (CommonUtil.getItemInHands(InstrumentItem.class, player).isEmpty()) | ||
ServerUtil.setInstrumentClosed(player); | ||
} else { | ||
// Close an instrument block if the player is too far away | ||
if (InstrumentEntityData.getBlockPos(player).closerToCenterThan(player.position(), 5)) | ||
ServerUtil.setInstrumentClosed(player); | ||
} | ||
} | ||
|
||
} |
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/cstav/genshinstrument/item/ItemPoseModifier.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,26 @@ | ||
package com.cstav.genshinstrument.item; | ||
|
||
import com.cstav.genshinstrument.event.PosePlayerArmEvent; | ||
import com.cstav.genshinstrument.event.PosePlayerArmEvent.PosePlayerArmEventArgs; | ||
import com.cstav.genshinstrument.util.CommonUtil; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
|
||
public interface ItemPoseModifier { | ||
|
||
@Environment(EnvType.CLIENT) | ||
public static void register() { | ||
PosePlayerArmEvent.EVENT.register((args) -> { | ||
|
||
CommonUtil.getItemInHands(ItemPoseModifier.class, args.player).ifPresent((item) -> | ||
item.onPosePlayerArm(args) | ||
); | ||
|
||
}); | ||
} | ||
|
||
@Environment(EnvType.CLIENT) | ||
void onPosePlayerArm(final PosePlayerArmEventArgs args); | ||
|
||
} |
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
Oops, something went wrong.