Updated commands. Only trees remain
This commit is contained in:
parent
c54f209808
commit
47ba320312
4 changed files with 36 additions and 75 deletions
|
@ -7,11 +7,6 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.common.command;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Streams;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
|
@ -19,62 +14,44 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|||
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.ISuggestionProvider;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class BiomeArgument implements ArgumentType<Biome>
|
||||
{
|
||||
private static final Collection<String> EXAMPLES;
|
||||
public static final DynamicCommandExceptionType INVALID_BIOME_EXCEPTION;
|
||||
|
||||
public BiomeArgument()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S> Biome parse(StringReader reader) throws CommandSyntaxException
|
||||
{
|
||||
ResourceLocation location = ResourceLocation.read(reader);
|
||||
Biome biome = Registry.BIOME.getByValue(location);
|
||||
if (biome == null)
|
||||
throw INVALID_BIOME_EXCEPTION.create(location);
|
||||
else return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder suggestionsBuilder)
|
||||
{
|
||||
return ISuggestionProvider.func_212476_a(Streams.stream(Registry.BIOME).map(biome -> Registry.BIOME.getByValueKey((Biome)biome)), suggestionsBuilder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getExamples()
|
||||
{
|
||||
return EXAMPLES;
|
||||
}
|
||||
public static final DynamicCommandExceptionType INVALID_BIOME_EXCEPTION = new DynamicCommandExceptionType((biome) -> {
|
||||
return new TranslationTextComponent("argument.biomesoplenty.biome.invalid", new Object[]{biome});
|
||||
});
|
||||
|
||||
public static BiomeArgument createArgument()
|
||||
{
|
||||
return new BiomeArgument();
|
||||
}
|
||||
|
||||
public static Biome getValue(CommandContext<CommandSource> context, String name)
|
||||
public static Biome getValue(CommandContext<CommandSource> context, String name) throws CommandSyntaxException
|
||||
{
|
||||
return context.getArgument(name, Biome.class);
|
||||
}
|
||||
|
||||
static
|
||||
@Override
|
||||
public Biome parse(StringReader reader) throws CommandSyntaxException
|
||||
{
|
||||
EXAMPLES = (Collection)Streams.stream(Registry.BIOME).map(biome -> {
|
||||
return Registry.BIOME.getByValueKey((Biome)biome).toString();
|
||||
}).collect(Collectors.toList());
|
||||
INVALID_BIOME_EXCEPTION = new DynamicCommandExceptionType((biome) -> {
|
||||
return new TextComponentTranslation("argument.biomesoplenty.biome.invalid", new Object[]{biome});
|
||||
ResourceLocation location = ResourceLocation.read(reader);
|
||||
return Registry.BIOME.getValue(location).orElseThrow(() ->
|
||||
{
|
||||
return INVALID_BIOME_EXCEPTION.create(location);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder suggestionsBuilder)
|
||||
{
|
||||
return ISuggestionProvider.suggestIterable(Registry.BIOME.keySet(), suggestionsBuilder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,20 +7,19 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.common.command;
|
||||
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
|
||||
import biomesoplenty.common.util.biome.BiomeUtil;
|
||||
import biomesoplenty.common.util.block.BlockUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
|
||||
public class CommandTpBiome
|
||||
{
|
||||
|
@ -30,12 +29,13 @@ public class CommandTpBiome
|
|||
.requires(cs->cs.hasPermissionLevel(0)) //permission
|
||||
.then(Commands.argument("biome", BiomeArgument.createArgument())
|
||||
.executes(ctx -> {
|
||||
EntityPlayerMP player = ctx.getSource().asPlayer();
|
||||
ServerPlayerEntity player = ctx.getSource().asPlayer();
|
||||
return findTeleportBiome(ctx.getSource(), player, BiomeArgument.getValue(ctx, "biome"));
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
private static int findTeleportBiome(CommandSource cs, EntityPlayerMP player, Biome biome)
|
||||
private static int findTeleportBiome(CommandSource cs, ServerPlayerEntity player, Biome biome)
|
||||
{
|
||||
World world = player.world;
|
||||
BlockPos closestBiomePos = biome == null ? null : BiomeUtil.spiralOutwardsLookingForBiome(world, biome, player.posX, player.posZ);
|
||||
|
@ -53,11 +53,11 @@ public class CommandTpBiome
|
|||
}
|
||||
|
||||
player.connection.setPlayerLocation(x, y, z, player.rotationYaw, player.rotationPitch);
|
||||
cs.sendFeedback(new TextComponentTranslation("commands.biomesoplenty.tpbiome.success", player.getName(), biomeName, x, y, z), true);
|
||||
cs.sendFeedback(new TranslationTextComponent("commands.biomesoplenty.tpbiome.success", player.getName(), biomeName, x, y, z), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendFeedback(new TextComponentTranslation("commands.biomesoplenty.tpbiome.error", biomeName), true);
|
||||
cs.sendFeedback(new TranslationTextComponent("commands.biomesoplenty.tpbiome.error", biomeName), true);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -65,7 +65,7 @@ public class CommandTpBiome
|
|||
|
||||
public static BlockPos getTopBlockNonOverworld(World world, BlockPos pos)
|
||||
{
|
||||
Chunk chunk = world.getChunk(pos);
|
||||
IChunk chunk = world.getChunk(pos);
|
||||
BlockPos blockpos;
|
||||
BlockPos blockpos1;
|
||||
BlockPos blockpos2 = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ());
|
||||
|
|
|
@ -32,12 +32,12 @@ public class EntityMudball extends ProjectileItemEntity
|
|||
|
||||
public EntityMudball(World world, double x, double y, double z)
|
||||
{
|
||||
super(BOPEntities.mudball, x, y, z, world);
|
||||
super((EntityType<? extends EntityMudball>)BOPEntities.mudball, x, y, z, world);
|
||||
}
|
||||
|
||||
public EntityMudball(World world, LivingEntity thrower)
|
||||
{
|
||||
super(BOPEntities.mudball, thrower, world);
|
||||
super((EntityType<? extends EntityMudball>)BOPEntities.mudball, thrower, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,31 +7,15 @@
|
|||
******************************************************************************/
|
||||
package biomesoplenty.init;
|
||||
|
||||
import static biomesoplenty.api.item.BOPItems.bop_icon;
|
||||
import static biomesoplenty.api.item.BOPItems.cherry_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.dead_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.ethereal_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.fir_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.hellbark_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.jacaranda_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.magic_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.mahogany_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.mud_brick;
|
||||
import static biomesoplenty.api.item.BOPItems.mudball;
|
||||
import static biomesoplenty.api.item.BOPItems.palm_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.record_wanderer;
|
||||
import static biomesoplenty.api.item.BOPItems.redwood_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.umbran_boat;
|
||||
import static biomesoplenty.api.item.BOPItems.willow_boat;
|
||||
|
||||
import biomesoplenty.api.sound.BOPSounds;
|
||||
import biomesoplenty.common.entity.item.EntityBoatBOP;
|
||||
import biomesoplenty.common.item.ItemMudball;
|
||||
import biomesoplenty.common.item.ItemRecordBOP;
|
||||
import biomesoplenty.common.util.inventory.ItemGroupBOP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import static biomesoplenty.api.item.BOPItems.*;
|
||||
|
||||
public class ModItems
|
||||
{
|
||||
public static void init()
|
||||
|
@ -41,7 +25,7 @@ public class ModItems
|
|||
|
||||
record_wanderer = registerItem(new ItemRecordBOP(BOPSounds.records_wanderer), "record_wanderer");
|
||||
|
||||
fir_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.FIR, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "fir_boat");
|
||||
/*fir_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.FIR, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "fir_boat");
|
||||
redwood_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.REDWOOD, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "redwood_boat");
|
||||
cherry_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.CHERRY, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "cherry_boat");
|
||||
mahogany_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.MAHOGANY, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "mahogany_boat");
|
||||
|
@ -52,7 +36,7 @@ public class ModItems
|
|||
magic_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.MAGIC, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "magic_boat");
|
||||
umbran_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.UMBRAN, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "umbran_boat");
|
||||
hellbark_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.HELLBARK, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "hellbark_boat");
|
||||
ethereal_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.ETHEREAL, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "ethereal_boat");
|
||||
ethereal_boat = registerItem(new ItemBoatBOP(EntityBoatBOP.Type.ETHEREAL, (new Item.Properties()).maxStackSize(1).group(ItemGroupBOP.instance)), "ethereal_boat");*/
|
||||
|
||||
bop_icon = registerItem(new Item(new Item.Properties()), "bop_icon");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue