改變時間和前進的速度必須單獨完成。日
速度(節拍率)
當天的速度是基於ticks
量,這是一個大的環,其控制時間。 ticks
也控制遊戲中的所有內容。當蜱的數量增加或重置時,遊戲的各個方面會向前移動一點,包括怪物,對象和玩家統計數據。根據Minecraft Wiki,Minecraft以固定的20 t/s(ticks per second)運行,這也意味着1 t/0.05秒;遊戲中的一天持續24000個滴答聲,或實時20分鐘。由於此循環直接編入Minecraft的代碼,因此更改滴答速率可能會使遊戲變得糟糕。如果在計算機無法處理時讓滴答速度過快,那麼您會得到經典的[Server thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running Xms behind, skipping Y tick(s)
,然後可能會發生崩潰,因爲系統時間實際上是DID更改(一次),所以請注意加快遊戲速度太難。
像這樣的工作(retreived和here編輯):
public class ChangeTickRate implements IFMLLoadingPlugin, IFMLCallHook {
// Stored client-side tickrate (default at 20TPS)
private Field clientTimer = null;
@SideOnly(Side.CLIENT)
public static void updateClientTickrate(float tickrate) {
Minecraft mc = Minecraft.getMinecraft();
if(mc == null) return; // Oops! Try again!
try {
if(clientTimer == null) {
for(Field f : mc.getClass().getDeclaredFields()) {
if(f.getType() == Timer.class) {
clientTimer = f;
clientTimer.setAccessible(true);
break;
}
}
}
clientTimer.set(mc, new Timer(tickrate));
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
請記住,包括所有的進口。如果您在運行之前或運行時遇到任何錯誤,請進行評論。 注意:這隻會改變客戶端側滴答率,所以它會導致服務器上的問題沒有適當的方法。
球員運動
由於球員動作稍有基於蜱,你已經改變了TPS,它可能只是爲了更好地給他們迅捷的無限藥水:
int PotionAmp = 1; //base amplifier of the effect
while(FastForwardEnabled){
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 0, 1));
}
這個隱藏氣泡效果並使用標準效果級別或放大器。如果您想對球員的速度更多的控制權,然後嘗試這樣的事情,而不是(可能是作爲一個覆蓋):
//play around with this number
private static final float FFSpeed = 0.2f
@Override //probably
public boolean onTickInGame(float f, Minecraft minecraft){
minecraft.thePlayer.speedOnGround=0.02f;
return true; //tell it that this is handled
}
結論現在
,你已經創建了自己的GUI類和按鈕後,所有您需要要做的就是在你的GUI類中這樣稱呼它
//see https://bedrockminer.jimdo.com/modding-tutorials/advanced-modding/gui-screen/ for some reference
private static boolean FastForwardEnabled = false;
protected void actionPerformed(GuiButton button) throws IOException {
if (button == AdvanceButton) { //Example GUI Button used as an enable/disable
FastForwardEnabled = !FastForwardEnabled;
while (FastForwardEnabled){
//Example value used; increases game speed 2x
ChangeTickRate.updateClientTickrate(40);
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 0, 1));
}
}
}
我正在投票結束這個問題,因爲它太籠統,而不是編程。 – timgeb
那麼,如果你有辦法訪問我的世界代碼,那就是編程。如果你知道可以用mods創建工具來完成它,那也是關於編程的。如果你知道如何加快linux的進程,它不是編程,但仍然是信息。 – user2329273
@ user2329273 - 你知道Java嗎? –