de.pewpewproject.lasertag.mixin.gui.CreateWorldScreenMixin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A setArenaDefaults(Screen,DataPackSettings,MoreOptionsDialog,CallbackInfo) 0 11 1
1
package de.pewpewproject.lasertag.mixin.gui;
2
3
import net.minecraft.client.gui.screen.Screen;
4
import net.minecraft.client.gui.screen.world.CreateWorldScreen;
5
import net.minecraft.client.gui.screen.world.MoreOptionsDialog;
6
import net.minecraft.client.resource.language.I18n;
7
import net.minecraft.resource.DataPackSettings;
8
import net.minecraft.world.Difficulty;
9
import org.spongepowered.asm.mixin.Mixin;
10
import org.spongepowered.asm.mixin.injection.At;
11
import org.spongepowered.asm.mixin.injection.Inject;
12
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13
14
/**
15
 * Mixin into the CreateWorldScreen.class to set the cheats enabled by default.
16
 *
17
 * @author Étienne Muser
18
 */
19
@Mixin(CreateWorldScreen.class)
20
public abstract class CreateWorldScreenMixin {
21
22
    /**
23
     * Overwrites the create world default values.
24
     * Sets cheats enabled to true, new world name to "New Arena World" and difficulty to peaceful.
25
     */
26
    @Inject(method = "<init>(Lnet/minecraft/client/gui/screen/Screen;Lnet/minecraft/resource/DataPackSettings;Lnet/minecraft/client/gui/screen/world/MoreOptionsDialog;)V", at = @At("TAIL"))
27
    private void setArenaDefaults(Screen parent, DataPackSettings dataPackSettings, MoreOptionsDialog moreOptionsDialog, CallbackInfo ci) {
28
29
        // Get this create world screen
30
        var createWorldScreen = ((CreateWorldScreen)(Object)this);
31
32
        // Overwrite the default values
33
        createWorldScreen.cheatsEnabled = true;
34
        createWorldScreen.tweakedCheats = true;
35
        createWorldScreen.levelName = I18n.translate("selectWorld.newArena");
36
        createWorldScreen.currentDifficulty = Difficulty.PEACEFUL;
37
    }
38
}
39