-
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.
finish timer task and use item event callback. update gui background.
- Loading branch information
Showing
4 changed files
with
137 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package top.mpt.ingotfly.ingotfly; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
|
||
import java.util.TimerTask; | ||
|
||
/** | ||
* @author You_M | ||
*/ | ||
public class TimeTask extends TimerTask { | ||
|
||
private Long time; | ||
private final PlayerEntity player; | ||
public TimeTask(Long time, PlayerEntity player) { | ||
this.time = time; | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
if(time<=3L) Util.sendMessage("距离飞行时间结束还有"+time+"秒"); | ||
if(time == 0L) { | ||
Util.sendMessage("飞行时间已结束"); | ||
player.getAbilities().allowFlying = false; | ||
player.getAbilities().flying = false; | ||
this.cancel(); | ||
} | ||
time--; | ||
} | ||
} |
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,20 @@ | ||
package top.mpt.ingotfly.ingotfly; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.text.Text; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* @author You_M | ||
*/ | ||
public class Util { | ||
public static void sendMessage(Object message){ | ||
if (MinecraftClient.getInstance().player != null) { | ||
MinecraftClient.getInstance().player.sendMessage(Text.of(message.toString())); | ||
} | ||
} | ||
public static void sendMessage(Object ...message){ | ||
Arrays.stream(message).forEach(Util::sendMessage); | ||
} | ||
} |