22w13a
This commit is contained in:
1 parent
79f994f2da
commit
ef3e71b9b6
5 files changed
+30
-15
No files matched your search
@@ -14,6 +14,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
@@ -107,13 +109,15 @@ public class SpawnCommand
|
||||
dispatcher.register(literalargumentbuilder);
|
||||
}
|
||||
|
||||
private static final Map<String, MobCategory> MOB_CATEGORY_MAP = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(MobCategory::getName, Function.identity()));
|
||||
|
||||
private static MobCategory getCategory(String string) throws CommandSyntaxException
|
||||
{
|
||||
if (!Arrays.stream(MobCategory.values()).map(MobCategory::getName).collect(Collectors.toSet()).contains(string))
|
||||
{
|
||||
throw new SimpleCommandExceptionType(Messenger.c("r Wrong mob type: "+string+" should be "+ Arrays.stream(MobCategory.values()).map(MobCategory::getName).collect(Collectors.joining(", ")))).create();
|
||||
}
|
||||
return MobCategory.byName(string.toLowerCase(Locale.ROOT));
|
||||
return MOB_CATEGORY_MAP.get(string.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import net.minecraft.world.level.levelgen.heightproviders.ConstantHeight;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureType;
|
||||
import net.minecraft.world.level.levelgen.structure.TerrainAdjustment;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
||||
import net.minecraft.world.level.levelgen.feature.treedecorators.BeehiveDecorator;
|
||||
@@ -259,11 +260,12 @@ public class FeatureGenerator
|
||||
PlacementUtils.inlinePlaced(Feature.CORAL_MUSHROOM, FeatureConfiguration.NONE)
|
||||
))));
|
||||
put("bastion_remnant_units", spawnCustomStructure(
|
||||
new JigsawStructure(
|
||||
new JigsawStructure( new Structure.StructureSettings(
|
||||
BuiltinRegistries.BIOME.getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
false,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
@@ -278,11 +280,12 @@ public class FeatureGenerator
|
||||
)
|
||||
));
|
||||
put("bastion_remnant_hoglin_stable", spawnCustomStructure(
|
||||
new JigsawStructure(
|
||||
new JigsawStructure( new Structure.StructureSettings(
|
||||
BuiltinRegistries.BIOME.getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
false,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
@@ -297,11 +300,12 @@ public class FeatureGenerator
|
||||
)
|
||||
));
|
||||
put("bastion_remnant_treasure", spawnCustomStructure(
|
||||
new JigsawStructure(
|
||||
new JigsawStructure( new Structure.StructureSettings(
|
||||
BuiltinRegistries.BIOME.getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
false,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
@@ -316,11 +320,12 @@ public class FeatureGenerator
|
||||
)
|
||||
));
|
||||
put("bastion_remnant_bridge", spawnCustomStructure(
|
||||
new JigsawStructure(
|
||||
new JigsawStructure( new Structure.StructureSettings(
|
||||
BuiltinRegistries.BIOME.getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
|
||||
Map.of(),
|
||||
GenerationStep.Decoration.SURFACE_STRUCTURES,
|
||||
false,
|
||||
TerrainAdjustment.NONE
|
||||
),
|
||||
Holder.direct(new StructureTemplatePool(
|
||||
new ResourceLocation("bastion/starts"),
|
||||
new ResourceLocation("empty"),
|
||||
|
||||
@@ -107,9 +107,9 @@ public class EntityPlayerMPFake extends ServerPlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void equipEventAndSound(ItemStack stack)
|
||||
protected void equipEventAndSound(ItemStack stack, boolean sendGameEvent)
|
||||
{
|
||||
if (!isUsingItem()) super.equipEventAndSound(stack);
|
||||
if (!isUsingItem()) super.equipEventAndSound(stack, sendGameEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,14 +12,20 @@ import carpet.script.value.StringValue;
|
||||
import carpet.script.value.Value;
|
||||
import carpet.utils.SpawnReporter;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.NaturalSpawner;
|
||||
|
||||
public class Monitoring {
|
||||
private static final Map<String, MobCategory> MOB_CATEGORY_MAP = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(MobCategory::getName, Function.identity()));
|
||||
|
||||
public static void apply(Expression expression)
|
||||
{
|
||||
@@ -62,7 +68,7 @@ public class Monitoring {
|
||||
return MapValue.wrap(retDict);
|
||||
}
|
||||
String catString = lv.get(0).getString();
|
||||
MobCategory cat = MobCategory.byName(catString.toLowerCase(Locale.ROOT));
|
||||
MobCategory cat = MOB_CATEGORY_MAP.get(catString.toLowerCase(Locale.ROOT));
|
||||
if (cat == null) throw new InternalExpressionException("Unreconized mob category: "+catString);
|
||||
return ListValue.of(
|
||||
new NumericValue(mobcounts.getInt(cat)),
|
||||
|
||||
Reference in new issue
Block a user