Jump to content

Recommended Posts

Posted (edited)

Minecraft crashes each time I load into a world already created or not.

Does anyone has an idea on how to fix this ?

 

This is my crash log :

  Reveal hidden contents
Edited by Natank25
Posted

Because i don't know how to do git repo, i send the Command class

 

SwitchDimCommand:

package io.github.Natank25.customdim.commom.command.impl;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;

import io.github.Natank25.customdim.commom.command.BaseCommand;
import io.github.Natank25.customdim.core.init.DimensionInit;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.arguments.EntityArgument;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.world.World;

public class SwitchDimCommand extends BaseCommand {

	public SwitchDimCommand(String name, int permissionLevel, boolean enabled) {
		super(name, permissionLevel, enabled);
	}

	@Override
	public LiteralArgumentBuilder<CommandSource> setExecution() {
		return builder.then(Commands.argument("null", null)
				.executes(source -> execute(source.getSource(), EntityArgument.getPlayer(source, "player"))));
	}

	private int execute(CommandSource source, ServerPlayerEntity player) {
		if (source.getLevel() == source.getServer().getLevel(World.OVERWORLD)) {
			player.teleportTo(source.getServer().getLevel(DimensionInit.EMPTY_DIM),0,4,0,0,0);

		} else if (source.getLevel() == source.getServer().getLevel(DimensionInit.EMPTY_DIM)) {
			player.teleportTo(source.getServer().getLevel(World.OVERWORLD),-268,76,276,0,0);
		}
		return Command.SINGLE_SUCCESS;
	}

}

 

BaseCommand:

package io.github.Natank25.customdim.commom.command;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;

import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;

public class BaseCommand {
	protected LiteralArgumentBuilder<CommandSource> builder;
	boolean enabled;
	
	public BaseCommand(String name, int permissionLevel, boolean enabled) {
		this.builder = Commands.literal(name).requires(source -> source.hasPermission(permissionLevel));
		this.enabled = enabled;
		
	}
	
	public LiteralArgumentBuilder<CommandSource> getBuilder() { 
		return builder;		
	}
	
	public boolean isEnabled() {
		return enabled;
	}
	
	public LiteralArgumentBuilder<CommandSource> setExecution() { 
		return null;		
	}
}

 

Posted

True, i modified it from

Commands.argument("player", EntityArgument.player())

to

Commands.argument("null", null)

to remove the argument and it didn't worked (Do you have any ideas on how to do it ?).

I tried to launch minecraft again, and it work, thank you for your help

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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