Search in sources :

Example 91 with TranslatableText

use of net.minecraft.text.TranslatableText in project LevelZ by Globox1997.

the class EnchantingTableBlockMixin method onUseMixin.

@Inject(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;openHandledScreen(Lnet/minecraft/screen/NamedScreenHandlerFactory;)Ljava/util/OptionalInt;"), cancellable = true)
private void onUseMixin(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> info) {
    ArrayList<Object> levelList = LevelLists.enchantingTableList;
    if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, true)) {
        player.sendMessage(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)), true);
        info.setReturnValue(ActionResult.FAIL);
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 92 with TranslatableText

use of net.minecraft.text.TranslatableText in project LevelZ by Globox1997.

the class GrindstoneBlockMixin method onUseMixin.

@Inject(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;openHandledScreen(Lnet/minecraft/screen/NamedScreenHandlerFactory;)Ljava/util/OptionalInt;"), cancellable = true)
private void onUseMixin(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> info) {
    ArrayList<Object> levelList = LevelLists.grindstoneList;
    if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, true)) {
        player.sendMessage(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)), true);
        info.setReturnValue(ActionResult.FAIL);
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 93 with TranslatableText

use of net.minecraft.text.TranslatableText in project LevelZ by Globox1997.

the class LecternBlockMixin method onUseMixin.

@Inject(method = "onUse", at = @At(value = "HEAD"), cancellable = true)
private void onUseMixin(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> info) {
    ArrayList<Object> levelList = LevelLists.lecternList;
    if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, true)) {
        player.sendMessage(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)), true);
        info.setReturnValue(ActionResult.FAIL);
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 94 with TranslatableText

use of net.minecraft.text.TranslatableText in project LevelZ by Globox1997.

the class PumpkinBlockMixin method onUseMixin.

@Inject(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;playSound(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundCategory;FF)V"), cancellable = true)
private void onUseMixin(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> info) {
    ArrayList<Object> levelList = LevelLists.pumpkinList;
    if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, true)) {
        player.sendMessage(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)), true);
        info.setReturnValue(ActionResult.FAIL);
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 95 with TranslatableText

use of net.minecraft.text.TranslatableText in project LevelZ by Globox1997.

the class SmokerBlockMixin method openScreenMixin.

@Inject(method = "openScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;openHandledScreen(Lnet/minecraft/screen/NamedScreenHandlerFactory;)Ljava/util/OptionalInt;"), cancellable = true)
protected void openScreenMixin(World world, BlockPos pos, PlayerEntity player, CallbackInfo info) {
    ArrayList<Object> levelList = LevelLists.smokerList;
    if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, true)) {
        player.sendMessage(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)), true);
        info.cancel();
    }
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

TranslatableText (net.minecraft.text.TranslatableText)345 Inject (org.spongepowered.asm.mixin.injection.Inject)58 LiteralText (net.minecraft.text.LiteralText)57 Text (net.minecraft.text.Text)56 ButtonWidget (net.minecraft.client.gui.widget.ButtonWidget)42 MinecraftClient (net.minecraft.client.MinecraftClient)40 Screen (net.minecraft.client.gui.screen.Screen)38 ItemStack (net.minecraft.item.ItemStack)38 ArrayList (java.util.ArrayList)31 Environment (net.fabricmc.api.Environment)28 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)22 MatrixStack (net.minecraft.client.util.math.MatrixStack)21 BlockPos (net.minecraft.util.math.BlockPos)20 List (java.util.List)19 Identifier (net.minecraft.util.Identifier)19 EnvType (net.fabricmc.api.EnvType)18 TextFieldWidget (net.minecraft.client.gui.widget.TextFieldWidget)17 ConfirmScreen (net.minecraft.client.gui.screen.ConfirmScreen)16 NbtCompound (net.minecraft.nbt.NbtCompound)15 Formatting (net.minecraft.util.Formatting)15