-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: LoomModule + CartographyModule + SmithingModule
- Loading branch information
1 parent
3ec26c1
commit 02b5310
Showing
4 changed files
with
121 additions
and
0 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
37 changes: 37 additions & 0 deletions
37
src/main/java/io/github/sakurawald/module/initializer/cartography/CartographyModule.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 io.github.sakurawald.module.initializer.cartography; | ||
|
||
import com.mojang.brigadier.Command; | ||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import io.github.sakurawald.module.initializer.ModuleInitializer; | ||
import io.github.sakurawald.util.CommandUtil; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.screen.CartographyTableScreenHandler; | ||
import net.minecraft.screen.LoomScreenHandler; | ||
import net.minecraft.screen.ScreenHandlerContext; | ||
import net.minecraft.screen.SimpleNamedScreenHandlerFactory; | ||
import net.minecraft.server.command.CommandManager; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.stat.Stats; | ||
import net.minecraft.text.Text; | ||
|
||
public class CartographyModule extends ModuleInitializer { | ||
@Override | ||
public void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) { | ||
dispatcher.register(CommandManager.literal("cartography").executes(this::$cartography)); | ||
} | ||
|
||
private int $cartography(CommandContext<ServerCommandSource> ctx) { | ||
return CommandUtil.playerOnlyCommand(ctx, player -> { | ||
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, inventory, p) -> new CartographyTableScreenHandler(i, inventory, ScreenHandlerContext.create(p.getWorld(), p.getBlockPos())) { | ||
@Override | ||
public boolean canUse(PlayerEntity player) { | ||
return true; | ||
} | ||
}, Text.translatable("container.cartography_table"))); | ||
player.incrementStat(Stats.INTERACT_WITH_CARTOGRAPHY_TABLE); | ||
return Command.SINGLE_SUCCESS; | ||
}); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/io/github/sakurawald/module/initializer/loom/LoomModule.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,34 @@ | ||
package io.github.sakurawald.module.initializer.loom; | ||
|
||
import com.mojang.brigadier.Command; | ||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import io.github.sakurawald.module.initializer.ModuleInitializer; | ||
import io.github.sakurawald.util.CommandUtil; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.screen.*; | ||
import net.minecraft.server.command.CommandManager; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.stat.Stats; | ||
import net.minecraft.text.Text; | ||
|
||
public class LoomModule extends ModuleInitializer { | ||
@Override | ||
public void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) { | ||
dispatcher.register(CommandManager.literal("loom").executes(this::$loom)); | ||
} | ||
|
||
private int $loom(CommandContext<ServerCommandSource> ctx) { | ||
return CommandUtil.playerOnlyCommand(ctx, player -> { | ||
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, inventory, p) -> new LoomScreenHandler(i, inventory, ScreenHandlerContext.create(p.getWorld(), p.getBlockPos())) { | ||
@Override | ||
public boolean canUse(PlayerEntity player) { | ||
return true; | ||
} | ||
}, Text.translatable("container.loom"))); | ||
player.incrementStat(Stats.INTERACT_WITH_LOOM); | ||
return Command.SINGLE_SUCCESS; | ||
}); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/io/github/sakurawald/module/initializer/smithing/SmithInitializer.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,35 @@ | ||
package io.github.sakurawald.module.initializer.smithing; | ||
|
||
import com.mojang.brigadier.Command; | ||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import io.github.sakurawald.module.initializer.ModuleInitializer; | ||
import io.github.sakurawald.util.CommandUtil; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.screen.*; | ||
import net.minecraft.server.command.CommandManager; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.stat.Stats; | ||
import net.minecraft.text.Text; | ||
|
||
public class SmithInitializer extends ModuleInitializer { | ||
|
||
@Override | ||
public void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) { | ||
dispatcher.register(CommandManager.literal("smithing").executes(this::$smithing)); | ||
} | ||
|
||
private int $smithing(CommandContext<ServerCommandSource> ctx) { | ||
return CommandUtil.playerOnlyCommand(ctx, player -> { | ||
player.openHandledScreen(new SimpleNamedScreenHandlerFactory((i, inventory, p) -> new SmithingScreenHandler(i, inventory, ScreenHandlerContext.create(p.getWorld(), p.getBlockPos())) { | ||
@Override | ||
public boolean canUse(PlayerEntity player) { | ||
return true; | ||
} | ||
}, Text.translatable("block.minecraft.smithing_table"))); | ||
player.incrementStat(Stats.INTERACT_WITH_SMITHING_TABLE); | ||
return Command.SINGLE_SUCCESS; | ||
}); | ||
} | ||
} |