Jump to content

modrinth

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

modrinth's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Nevermind i just figured out that i can make transparent blocks with AirBlock, that saves alot of time.
  2. New to these forums, i didn't know how to reply either way ^
  3. That's not really the problem, i have a separate item with the exact same on and off switch and it works perfectly fine. The problem is something with the loop i presume, as without it the switch works perfectly fine. I'll explain what i need the item to do, first off blocks cant be transparent (or at-least that's what i think) so i thought of setting the block behind the player to a black block with a light level of like 6 or something. I need to detect the direction the player is facing at all times so i can set the block behind them to a light block.
  4. So I'm trying to create a lighter, so On and Off. Here is my code package icelock.iceblocks.item.custom; import com.mojang.brigadier.ParseResults; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.ChatComponent; import net.minecraft.client.gui.screens.debug.GameModeSwitcherScreen; import net.minecraft.client.sounds.SoundEngine; import net.minecraft.client.telemetry.TelemetryProperty; import net.minecraft.commands.*; import net.minecraft.commands.arguments.GameModeArgument; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.commands.GameModeCommand; import net.minecraft.server.commands.OpCommand; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.server.*; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Abilities; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.storage.LevelResource; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.event.CustomizeGuiOverlayEvent; import net.minecraftforge.common.ForgeConfig; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.server.console.TerminalHandler; import net.minecraft.commands.CommandSourceStack; import java.nio.file.Path; public class FlashLight extends Item { public FlashLight(Properties pProperties) { super(pProperties); } boolean FlashSwitch = false; Vec3 pos1 = null; Vec3 pos2 = null; Direction Dir = null; boolean ON = false; @Override public InteractionResult useOn(UseOnContext pContext) { if (!pContext.getLevel().isClientSide) { Boolean ShiftDown = pContext.isSecondaryUseActive(); Player player = pContext.getPlayer(); MinecraftServer server = pContext.getPlayer().getServer(); if (FlashSwitch) { pos1 = pContext.getPlayer().getEyePosition(); FlashSwitch = !FlashSwitch; player.displayClientMessage(Component.literal("§cOff"),true); ON = false; } else if (!FlashSwitch) { FlashSwitch = !FlashSwitch; player.displayClientMessage(Component.literal("§eOn"),true); ON = true; while (ON) { Dir = pContext.getPlayer().getDirection(); if (Dir.equals(Direction.NORTH)){ player.displayClientMessage(Component.literal("§eNORTH"),true); } else if (Dir.equals(Direction.EAST)){ player.displayClientMessage(Component.literal("§eEAST"),true); } else if (Dir.equals(Direction.SOUTH)){ player.displayClientMessage(Component.literal("§eSOUTH"),true); } else if (Dir.equals(Direction.WEST)){ player.displayClientMessage(Component.literal("§eWEST"),true); } try { Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } } } } return InteractionResult.SUCCESS; } } This barely works, the switch between on and off doesnt work, and when i turn directions it doesnt display the direction im facing, please help ASAP.
  5. This is what my code looks like and it works perfectly fine. package icelock.iceblocks.item.custom; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.debug.GameModeSwitcherScreen; import net.minecraft.client.sounds.SoundEngine; import net.minecraft.client.telemetry.TelemetryProperty; import net.minecraft.commands.*; import net.minecraft.commands.arguments.GameModeArgument; import net.minecraft.server.MinecraftServer; import net.minecraft.server.commands.GameModeCommand; import net.minecraft.server.commands.OpCommand; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.server.*; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.ForgeConfig; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.server.console.TerminalHandler; import net.minecraft.commands.CommandSourceStack; public class Creative extends Item { public Creative(Properties pProperties) { super(pProperties); } @Override public InteractionResult useOn(UseOnContext pContext) { if (!pContext.getLevel().isClientSide){ Player player = pContext.getPlayer(); CommandSourceStack stack = pContext.getPlayer().getServer().createCommandSourceStack(); player.getServer().getCommands().performPrefixedCommand(stack,"gamemode creative"); } return InteractionResult.SUCCESS; }} just wondering if theres a way to make the result not output
  6. I need help creating basically command block, you input a command, press a button, and it executes it. I have no idea where to start, I've been looking into old threads but times have changed, need help asap.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.