Fix a few IDE warnings (#1345)

This commit is contained in:
altrisi authored and GitHub committed 2022-02-20 19:16:12 +01:00
1 parent e011f65e75
commit b1c934da28
19 files changed
+225 -350

No files matched your search

@@ -4,6 +4,7 @@ import carpet.CarpetSettings;
import carpet.settings.SettingsManager;
import carpet.utils.Messenger;
import com.google.common.collect.Lists;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.arguments.IntegerArgumentType;
@@ -79,12 +80,6 @@ public class DrawCommand
dispatcher.register(command);
}
@FunctionalInterface
private interface OptionalBlockSelector
{
Integer apply(final CommandContext<CommandSourceStack> ctx) throws CommandSyntaxException;
}
@FunctionalInterface
private interface ArgumentExtractor<T>
{
@@ -92,13 +87,13 @@ public class DrawCommand
}
private static RequiredArgumentBuilder<CommandSourceStack, BlockInput>
drawShape(OptionalBlockSelector drawer)
drawShape(Command<CommandSourceStack> drawer)
{
return argument("block", BlockStateArgument.block()).
executes(drawer::apply)
executes(drawer)
.then(literal("replace")
.then(argument("filter", BlockPredicateArgument.blockPredicate())
.executes(drawer::apply)));
.executes(drawer)));
}
private static class ErrorHandled extends RuntimeException {}
@@ -229,7 +229,7 @@ public class OptimizedExplosion
if (damagesTerrain)
{
ObjectArrayList<Pair<ItemStack, BlockPos>> objectArrayList = new ObjectArrayList();
ObjectArrayList<Pair<ItemStack, BlockPos>> objectArrayList = new ObjectArrayList<>();
Collections.shuffle(e.getToBlow(), world.random);
for (BlockPos blockpos : e.getToBlow())
@@ -291,7 +291,7 @@ public class OptimizedExplosion
int i = objectArrayList.size();
for(int j = 0; j < i; ++j) {
Pair<ItemStack, BlockPos> pair = (Pair)objectArrayList.get(j);
Pair<ItemStack, BlockPos> pair = objectArrayList.get(j);
ItemStack itemStack2 = pair.getLeft();
if (ItemEntity.areMergable(itemStack2, itemStack)) {
ItemStack itemStack3 = ItemEntity.merge(itemStack2, itemStack, 16);
@@ -50,7 +50,6 @@ public class ParticleDisplay
if (lineLengthSq == 0) return;
Vec3 incvec = to.subtract(from).normalize();// multiply(50/sqrt(lineLengthSq));
int pcount = 0;
for (Vec3 delta = new Vec3(0.0,0.0,0.0);
delta.lengthSqr()<lineLengthSq;
delta = delta.add(incvec.scale(player.level.random.nextFloat())))
@@ -291,7 +291,7 @@ public class NaturalSpawnerMixin
{
SpawnReporter.first_chunk_marker.add(entityCategory);
//first chunk with spawn eligibility for that category
Pair key = Pair.of(dim, entityCategory);
var key = Pair.of(dim, entityCategory);
int spawnTries = SpawnReporter.spawn_tries.get(entityCategory);
@@ -12,7 +12,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Iterator;
import java.util.Set;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -94,10 +93,7 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
set.add(blockPos_1.relative(direction));
}
Iterator var10 = set.iterator();
while (var10.hasNext()) {
BlockPos blockPos = (BlockPos) var10.next();
for (BlockPos blockPos : set) {
world_1.updateNeighborsAt(blockPos, blockState_1.getBlock());
}
}
@@ -53,7 +53,7 @@ public abstract class ServerChunkCacheMixin implements ServerChunkManagerInterfa
SpawnReporter.first_chunk_marker = new HashSet<>();
for (MobCategory cat : MobCategory.values())
{
Pair key = Pair.of(dim, cat);
var key = Pair.of(dim, cat);
SpawnReporter.overall_spawn_ticks.put(key,
SpawnReporter.overall_spawn_ticks.get(key)+
SpawnReporter.spawn_tries.get(cat));
@@ -73,7 +73,7 @@ public abstract class ServerChunkCacheMixin implements ServerChunkManagerInterfa
for (MobCategory cat: MobCategory.values())
{
ResourceKey<Level> dim = level.dimension(); // getDimensionType;
Pair key = Pair.of(dim, cat);
var key = Pair.of(dim, cat);
int spawnTries = SpawnReporter.spawn_tries.get(cat);
if (!SpawnReporter.local_spawns.containsKey(cat))
{
@@ -870,13 +870,13 @@ public class CarpetEventServer
{
return stat.getType().getRegistry().getKey(stat.getValue());
}
private final Set<ResourceLocation> skippedStats = new HashSet<ResourceLocation>(){{
add(Stats.TIME_SINCE_DEATH);
add(Stats.TIME_SINCE_REST);
//add(Stats.PLAY_ONE_MINUTE);
add(Stats.PLAY_TIME);
add(Stats.TOTAL_WORLD_TIME);
}};
private final Set<ResourceLocation> skippedStats = Set.of(
Stats.TIME_SINCE_DEATH,
Stats.TIME_SINCE_REST,
//Stats.PLAY_ONE_MINUTE,
Stats.PLAY_TIME,
Stats.TOTAL_WORLD_TIME
);
@Override
public void onPlayerStatistic(ServerPlayer player, Stat<?> stat, int amount)
{
@@ -1,56 +0,0 @@
package carpet.script.annotation;
import carpet.logging.HUDController;
import carpet.script.annotation.Param.AllowSingleton;
import carpet.script.exception.InternalExpressionException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
/* There is no worse example to use for 1.17 compatibility
import static net.minecraft.network.packet.s2c.play.TitleS2CPacket.Action;
public class FunctionsTestClass {
@ScarpetFunction(maxParams = 6)
public Integer display_title2(@AllowSingleton List<ServerPlayerEntity> targets, String actionString, Optional<Text> content, Integer... times) {
TitleS2CPacket.Action action;
switch (actionString.toLowerCase(Locale.ROOT))
{
case "title":
action = Action.TITLE;
break;
case "subtitle":
action = Action.SUBTITLE;
break;
case "actionbar":
action = Action.ACTIONBAR;
break;
case "clear":
action = Action.CLEAR;
break;
case "player_list_header":
case "player_list_footer":
action = null;
break;
default:
throw new InternalExpressionException("'display_title' requires 'title', 'subtitle', 'actionbar', 'player_list_header', 'player_list_footer' or 'clear' as second argument");
}
if (action == null) // Player list
{
Map<String, BaseText> map = actionString.equals("player_list_header") ? HUDController.scarpet_headers : HUDController.scarpet_footers;
if (!content.isPresent()) // null
for (ServerPlayerEntity p : targets)
map.remove(p.getEntityName());
else
for (ServerPlayerEntity p : targets)
map.put(p.getEntityName(), (BaseText) content.get());
return targets.size();
}
targets.forEach(p -> {
if (times.length == 3) p.networkHandler.sendPacket(new TitleS2CPacket(Action.TIMES, null, times[0], times[1], times[2]));
p.networkHandler.sendPacket(new TitleS2CPacket(action, content.orElse(null)));
});
return targets.size();
}
}
*/
@@ -16,7 +16,6 @@ import carpet.script.value.FormattedTextValue;
import carpet.script.value.FunctionValue;
import carpet.script.value.ListValue;
import carpet.script.value.NBTSerializableValue;
import carpet.script.value.NullValue;
import carpet.script.value.NumericValue;
import carpet.script.value.ScreenValue;
import carpet.script.value.StringValue;
@@ -12,7 +12,6 @@ import carpet.script.utils.InputValidator;
import carpet.script.value.BooleanValue;
import carpet.script.value.EntityValue;
import carpet.script.value.ListValue;
import carpet.script.value.NullValue;
import carpet.script.value.NumericValue;
import carpet.script.value.StringValue;
import carpet.script.value.FormattedTextValue;
@@ -607,7 +607,7 @@ public class WorldAccess {
for (long key : levelTickets.keySet())
{
ChunkPos chpos = new ChunkPos(key);
for (Ticket ticket : levelTickets.get(key))
for (Ticket<?> ticket : levelTickets.get(key))
{
res.add(ListValue.of(
new StringValue(ticket.getType().toString()),
@@ -625,7 +625,7 @@ public class WorldAccess {
SortedArraySet<Ticket<?>> tickets = levelTickets.get(new ChunkPos(pos).toLong());
if (tickets != null)
{
for (Ticket ticket : tickets)
for (Ticket<?> ticket : tickets)
{
res.add(ListValue.of(
new StringValue(ticket.getType().toString()),
@@ -1297,7 +1297,7 @@ public class WorldAccess {
if (structureName == null) return Value.NULL;
LongSet structureReferences = references.get(structureName);
if (structureReferences == null || structureReferences.isEmpty()) return ListValue.of();
return ListValue.wrap(structureReferences.stream().map(l -> ListValue.of(
return ListValue.wrap(structureReferences.longStream().mapToObj(l -> ListValue.of(
new NumericValue(16*ChunkPos.getX(l)),
Value.ZERO,
new NumericValue(16*ChunkPos.getZ(l)))).collect(Collectors.toList()));
@@ -1509,7 +1509,6 @@ public class WorldAccess {
if (first instanceof ListValue)
{
List<Value> listVal = ((ListValue) first).getItems();
int offset = 0;
BlockArgument locator = BlockArgument.findIn(cc, listVal, 0);
requestedChunks.add(new ChunkPos(locator.block.getPos()));
while (listVal.size() > locator.offset)
@@ -1561,8 +1560,8 @@ public class WorldAccess {
}
}*/
result[0] = MapValue.wrap(report.entrySet().stream().collect(Collectors.toMap(
e -> new StringValue((String)((Map.Entry) e).getKey()),
e -> new NumericValue((Integer)((Map.Entry) e).getValue())
e -> new StringValue(e.getKey()),
e -> new NumericValue(e.getValue())
)));
});
return result[0];
@@ -1599,7 +1598,7 @@ public class WorldAccess {
BlockPos pos = locator.block.getPos();
if (lv.size() != locator.offset+2) throw new InternalExpressionException("'add_chunk_ticket' requires block position, ticket type and radius");
String type = lv.get(locator.offset).getString();
TicketType ticket = ticketTypes.get(type.toLowerCase(Locale.ROOT));
TicketType<?> ticket = ticketTypes.get(type.toLowerCase(Locale.ROOT));
if (ticket == null) throw new InternalExpressionException("Unknown ticket type: "+type);
int radius = NumericValue.asNumber(lv.get(locator.offset+1)).getInt();
if (radius < 1 || radius > 32) throw new InternalExpressionException("Ticket radius should be between 1 and 32 chunks");
@@ -4,7 +4,6 @@ import carpet.script.CarpetContext;
import carpet.script.exception.InternalExpressionException;
import carpet.script.value.BlockValue;
import carpet.script.value.ListValue;
import carpet.script.value.NullValue;
import carpet.script.value.NumericValue;
import carpet.script.value.StringValue;
import carpet.script.value.Value;
@@ -99,56 +98,6 @@ public class BlockArgument extends Argument
}
}
public static BlockArgument findInValues(CarpetContext c, List<Value> params, int offset, boolean acceptString, boolean optional)
{
try
{
Value v1 = params.get(0 + offset);
//add conditional from string name
if (optional && v1.isNull())
{
return new BlockArgument(null, 1+offset);
}
if (acceptString && v1 instanceof StringValue)
{
return new BlockArgument(BlockValue.fromString(v1.getString()), 1+offset);
}
if (v1 instanceof BlockValue)
{
return new BlockArgument(((BlockValue) v1), 1+offset);
}
if (v1 instanceof ListValue)
{
List<Value> args = ((ListValue) v1).getItems();
int xpos = (int) NumericValue.asNumber(args.get(0)).getLong();
int ypos = (int) NumericValue.asNumber(args.get(1)).getLong();
int zpos = (int) NumericValue.asNumber(args.get(2)).getLong();
return new BlockArgument(
new BlockValue(
null,
c.s.getLevel(),
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
),
1+offset);
}
int xpos = (int) NumericValue.asNumber(v1).getLong();
int ypos = (int) NumericValue.asNumber( params.get(1 + offset)).getLong();
int zpos = (int) NumericValue.asNumber( params.get(2 + offset)).getLong();
return new BlockArgument(
new BlockValue(
null,
c.s.getLevel(),
new BlockPos(c.origin.getX() + xpos, c.origin.getY() + ypos, c.origin.getZ() + zpos)
),
3+offset
);
}
catch (IndexOutOfBoundsException e)
{
throw handleError(optional, acceptString);
}
}
private static InternalExpressionException handleError(boolean optional, boolean acceptString)
{
String message = "Block-type argument should be defined either by three coordinates (a triple or by three arguments), or a block value";
@@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map;
public class Operators {
public static final Map<String, Integer> precedence = new HashMap<String,Integer>() {{
public static final Map<String, Integer> precedence = new HashMap<String, Integer>() {{
put("attribute~:", 80);
put("unary+-!...", 60);
put("exponent^", 40);
@@ -11,7 +11,6 @@ import carpet.script.value.BooleanValue;
import carpet.script.value.FunctionValue;
import carpet.script.value.ListValue;
import carpet.script.value.MapValue;
import carpet.script.value.NullValue;
import carpet.script.value.NumericValue;
import carpet.script.value.StringValue;
import carpet.script.value.Value;
@@ -1,7 +1,6 @@
package carpet.script.utils;
import carpet.script.exception.InternalExpressionException;
import org.lwjgl.system.CallbackI;
import java.util.Locale;
import net.minecraft.ResourceLocationException;
@@ -4,7 +4,6 @@ import carpet.CarpetServer;
import carpet.CarpetSettings;
import carpet.fakes.ScreenHandlerInterface;
import carpet.script.CarpetContext;
import carpet.script.CarpetScriptHost;
import carpet.script.CarpetScriptServer;
import carpet.script.Context;
+193 -193
View File
@@ -1,7 +1,6 @@
package carpet.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.core.BlockPos;
@@ -23,203 +22,204 @@ import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.Vec3;
import static java.util.Map.entry;
public class BlockInfo
{
public static final Map<SoundType, String> soundName = new HashMap<SoundType, String>() {{
put(SoundType.WOOD, "wood" );
put(SoundType.GRAVEL, "gravel");
put(SoundType.GRASS, "grass" );
put(SoundType.LILY_PAD, "lily_pad");
put(SoundType.STONE, "stone" );
put(SoundType.METAL, "metal" );
put(SoundType.GLASS , "glass" );
put(SoundType.WOOL , "wool" );
put(SoundType.SAND , "sand" );
put(SoundType.SNOW , "snow" );
put(SoundType.POWDER_SNOW , "powder_snow" );
put(SoundType.LADDER, "ladder");
put(SoundType.ANVIL , "anvil" );
put(SoundType.SLIME_BLOCK , "slime" );
put(SoundType.HONEY_BLOCK , "honey" );
put(SoundType.WET_GRASS , "sea_grass" );
put(SoundType.CORAL_BLOCK , "coral" );
put(SoundType.BAMBOO , "bamboo" );
put(SoundType.BAMBOO_SAPLING , "shoots" );
put(SoundType.SCAFFOLDING , "scaffolding" );
put(SoundType.SWEET_BERRY_BUSH , "berry" );
put(SoundType.CROP , "crop" );
put(SoundType.HARD_CROP , "stem" );
put(SoundType.VINE , "vine" );
put(SoundType.NETHER_WART , "wart" );
put(SoundType.LANTERN , "lantern" );
put(SoundType.STEM, "fungi_stem");
put(SoundType.NYLIUM, "nylium");
put(SoundType.FUNGUS, "fungus");
put(SoundType.ROOTS, "roots");
put(SoundType.SHROOMLIGHT, "shroomlight");
put(SoundType.WEEPING_VINES, "weeping_vine");
put(SoundType.TWISTING_VINES, "twisting_vine");
put(SoundType.SOUL_SAND, "soul_sand");
put(SoundType.SOUL_SOIL, "soul_soil");
put(SoundType.BASALT, "basalt");
put(SoundType.WART_BLOCK, "wart");
put(SoundType.NETHERRACK, "netherrack");
put(SoundType.NETHER_BRICKS, "nether_bricks");
put(SoundType.NETHER_SPROUTS, "nether_sprouts");
put(SoundType.NETHER_ORE, "nether_ore");
put(SoundType.BONE_BLOCK, "bone");
put(SoundType.NETHERITE_BLOCK, "netherite");
put(SoundType.ANCIENT_DEBRIS, "ancient_debris");
put(SoundType.LODESTONE, "lodestone");
put(SoundType.CHAIN, "chain");
put(SoundType.NETHER_GOLD_ORE, "nether_gold_ore");
put(SoundType.GILDED_BLACKSTONE, "gilded_blackstone");
put(SoundType.CANDLE, "candle");
put(SoundType.AMETHYST, "amethyst");
put(SoundType.AMETHYST_CLUSTER, "amethyst_cluster");
put(SoundType.SMALL_AMETHYST_BUD, "small_amethyst_bud");
put(SoundType.MEDIUM_AMETHYST_BUD, "medium_amethyst_bud");
put(SoundType.LARGE_AMETHYST_BUD, "large_amethyst_bud");
public static final Map<SoundType, String> soundName = Map.ofEntries(
entry(SoundType.WOOD, "wood" ),
entry(SoundType.GRAVEL, "gravel"),
entry(SoundType.GRASS, "grass" ),
entry(SoundType.LILY_PAD, "lily_pad"),
entry(SoundType.STONE, "stone" ),
entry(SoundType.METAL, "metal" ),
entry(SoundType.GLASS , "glass" ),
entry(SoundType.WOOL , "wool" ),
entry(SoundType.SAND , "sand" ),
entry(SoundType.SNOW , "snow" ),
entry(SoundType.POWDER_SNOW , "powder_snow" ),
entry(SoundType.LADDER, "ladder"),
entry(SoundType.ANVIL , "anvil" ),
entry(SoundType.SLIME_BLOCK , "slime" ),
entry(SoundType.HONEY_BLOCK , "honey" ),
entry(SoundType.WET_GRASS , "sea_grass" ),
entry(SoundType.CORAL_BLOCK , "coral" ),
entry(SoundType.BAMBOO , "bamboo" ),
entry(SoundType.BAMBOO_SAPLING , "shoots" ),
entry(SoundType.SCAFFOLDING , "scaffolding" ),
entry(SoundType.SWEET_BERRY_BUSH , "berry" ),
entry(SoundType.CROP , "crop" ),
entry(SoundType.HARD_CROP , "stem" ),
entry(SoundType.VINE , "vine" ),
entry(SoundType.NETHER_WART , "wart" ),
entry(SoundType.LANTERN , "lantern" ),
entry(SoundType.STEM, "fungi_stem"),
entry(SoundType.NYLIUM, "nylium"),
entry(SoundType.FUNGUS, "fungus"),
entry(SoundType.ROOTS, "roots"),
entry(SoundType.SHROOMLIGHT, "shroomlight"),
entry(SoundType.WEEPING_VINES, "weeping_vine"),
entry(SoundType.TWISTING_VINES, "twisting_vine"),
entry(SoundType.SOUL_SAND, "soul_sand"),
entry(SoundType.SOUL_SOIL, "soul_soil"),
entry(SoundType.BASALT, "basalt"),
entry(SoundType.WART_BLOCK, "wart"),
entry(SoundType.NETHERRACK, "netherrack"),
entry(SoundType.NETHER_BRICKS, "nether_bricks"),
entry(SoundType.NETHER_SPROUTS, "nether_sprouts"),
entry(SoundType.NETHER_ORE, "nether_ore"),
entry(SoundType.BONE_BLOCK, "bone"),
entry(SoundType.NETHERITE_BLOCK, "netherite"),
entry(SoundType.ANCIENT_DEBRIS, "ancient_debris"),
entry(SoundType.LODESTONE, "lodestone"),
entry(SoundType.CHAIN, "chain"),
entry(SoundType.NETHER_GOLD_ORE, "nether_gold_ore"),
entry(SoundType.GILDED_BLACKSTONE, "gilded_blackstone"),
entry(SoundType.CANDLE, "candle"),
entry(SoundType.AMETHYST, "amethyst"),
entry(SoundType.AMETHYST_CLUSTER, "amethyst_cluster"),
entry(SoundType.SMALL_AMETHYST_BUD, "small_amethyst_bud"),
entry(SoundType.MEDIUM_AMETHYST_BUD, "medium_amethyst_bud"),
entry(SoundType.LARGE_AMETHYST_BUD, "large_amethyst_bud"),
put(SoundType.TUFF, "tuff");
put(SoundType.CALCITE, "calcite");
put(SoundType.DRIPSTONE_BLOCK, "dripstone");
put(SoundType.POINTED_DRIPSTONE, "pointed_dripstone");
put(SoundType.COPPER, "copper");
put(SoundType.CAVE_VINES, "cave_vine");
put(SoundType.SPORE_BLOSSOM, "spore_blossom");
put(SoundType.AZALEA, "azalea");
put(SoundType.FLOWERING_AZALEA, "flowering_azalea");
put(SoundType.MOSS_CARPET, "moss_carpet");
put(SoundType.MOSS, "moss");
put(SoundType.BIG_DRIPLEAF, "big_dripleaf");
put(SoundType.SMALL_DRIPLEAF, "small_dripleaf");
put(SoundType.ROOTED_DIRT, "rooted_dirt");
put(SoundType.HANGING_ROOTS, "hanging_roots");
put(SoundType.AZALEA_LEAVES, "azalea_leaves");
put(SoundType.SCULK_SENSOR, "sculk_sensor");
put(SoundType.GLOW_LICHEN, "glow_lichen");
put(SoundType.DEEPSLATE, "deepslate");
put(SoundType.DEEPSLATE_BRICKS, "deepslate_bricks");
put(SoundType.DEEPSLATE_TILES, "deepslate_tiles");
put(SoundType.POLISHED_DEEPSLATE, "polished_deepslate");
}};
entry(SoundType.TUFF, "tuff"),
entry(SoundType.CALCITE, "calcite"),
entry(SoundType.DRIPSTONE_BLOCK, "dripstone"),
entry(SoundType.POINTED_DRIPSTONE, "pointed_dripstone"),
entry(SoundType.COPPER, "copper"),
entry(SoundType.CAVE_VINES, "cave_vine"),
entry(SoundType.SPORE_BLOSSOM, "spore_blossom"),
entry(SoundType.AZALEA, "azalea"),
entry(SoundType.FLOWERING_AZALEA, "flowering_azalea"),
entry(SoundType.MOSS_CARPET, "moss_carpet"),
entry(SoundType.MOSS, "moss"),
entry(SoundType.BIG_DRIPLEAF, "big_dripleaf"),
entry(SoundType.SMALL_DRIPLEAF, "small_dripleaf"),
entry(SoundType.ROOTED_DIRT, "rooted_dirt"),
entry(SoundType.HANGING_ROOTS, "hanging_roots"),
entry(SoundType.AZALEA_LEAVES, "azalea_leaves"),
entry(SoundType.SCULK_SENSOR, "sculk_sensor"),
entry(SoundType.GLOW_LICHEN, "glow_lichen"),
entry(SoundType.DEEPSLATE, "deepslate"),
entry(SoundType.DEEPSLATE_BRICKS, "deepslate_bricks"),
entry(SoundType.DEEPSLATE_TILES, "deepslate_tiles"),
entry(SoundType.POLISHED_DEEPSLATE, "polished_deepslate")
);
public static final Map<MaterialColor, String> mapColourName = new HashMap<MaterialColor, String>() {{
put(MaterialColor.NONE , "air" );
put(MaterialColor.GRASS , "grass" );
put(MaterialColor.SAND , "sand" );
put(MaterialColor.WOOL , "wool" );
put(MaterialColor.FIRE , "tnt" );
put(MaterialColor.ICE , "ice" );
put(MaterialColor.METAL , "iron" );
put(MaterialColor.PLANT , "foliage" );
put(MaterialColor.SNOW , "snow" );
put(MaterialColor.CLAY , "clay" );
put(MaterialColor.DIRT , "dirt" );
put(MaterialColor.STONE , "stone" );
put(MaterialColor.WATER , "water" );
put(MaterialColor.WOOD , "wood" );
put(MaterialColor.QUARTZ , "quartz" );
put(MaterialColor.COLOR_ORANGE , "adobe" );
put(MaterialColor.COLOR_MAGENTA , "magenta" );
put(MaterialColor.COLOR_LIGHT_BLUE, "light_blue");
put(MaterialColor.COLOR_YELLOW , "yellow" );
put(MaterialColor.COLOR_LIGHT_GREEN , "lime" );
put(MaterialColor.COLOR_PINK , "pink" );
put(MaterialColor.COLOR_GRAY , "gray" );
put(MaterialColor.COLOR_LIGHT_GRAY, "light_gray");
put(MaterialColor.COLOR_CYAN , "cyan" );
put(MaterialColor.COLOR_PURPLE , "purple" );
put(MaterialColor.COLOR_BLUE , "blue" );
put(MaterialColor.COLOR_BROWN , "brown" );
put(MaterialColor.COLOR_GREEN , "green" );
put(MaterialColor.COLOR_RED , "red" );
put(MaterialColor.COLOR_BLACK , "black" );
put(MaterialColor.GOLD , "gold" );
put(MaterialColor.DIAMOND , "diamond" );
put(MaterialColor.LAPIS , "lapis" );
put(MaterialColor.EMERALD , "emerald" );
put(MaterialColor.PODZOL , "obsidian" );
put(MaterialColor.NETHER , "netherrack"); //TODO fix these
put(MaterialColor.TERRACOTTA_WHITE , "white_terracotta" );
put(MaterialColor.TERRACOTTA_ORANGE , "orange_terracotta" );
put(MaterialColor.TERRACOTTA_MAGENTA , "magenta_terracotta" );
put(MaterialColor.TERRACOTTA_LIGHT_BLUE, "light_blue_terracotta" );
put(MaterialColor.TERRACOTTA_YELLOW , "yellow_terracotta" );
put(MaterialColor.TERRACOTTA_LIGHT_GREEN , "lime_terracotta" );
put(MaterialColor.TERRACOTTA_PINK , "pink_terracotta" );
put(MaterialColor.TERRACOTTA_GRAY , "gray_terracotta" );
put(MaterialColor.TERRACOTTA_LIGHT_GRAY, "light_gray_terracotta" );
put(MaterialColor.TERRACOTTA_CYAN , "cyan_terracotta" );
put(MaterialColor.TERRACOTTA_PURPLE , "purple_terracotta" );
put(MaterialColor.TERRACOTTA_BLUE , "blue_terracotta" );
put(MaterialColor.TERRACOTTA_BROWN , "brown_terracotta" );
put(MaterialColor.TERRACOTTA_GREEN , "green_terracotta" );
put(MaterialColor.TERRACOTTA_RED , "red_terracotta" );
put(MaterialColor.TERRACOTTA_BLACK , "black_terracotta" );
put(MaterialColor.CRIMSON_NYLIUM , "crimson_nylium" );
put(MaterialColor.CRIMSON_STEM , "crimson_stem" );
put(MaterialColor.CRIMSON_HYPHAE , "crimson_hyphae" );
put(MaterialColor.WARPED_NYLIUM , "warped_nylium" );
put(MaterialColor.WARPED_STEM , "warped_stem" );
put(MaterialColor.WARPED_HYPHAE , "warped_hyphae" );
put(MaterialColor.WARPED_WART_BLOCK , "warped_wart" );
put(MaterialColor.DEEPSLATE , "deepslate" );
put(MaterialColor.RAW_IRON , "raw_iron" );
put(MaterialColor.GLOW_LICHEN , "glow_lichen" );
public static final Map<MaterialColor, String> mapColourName = Map.ofEntries(
entry(MaterialColor.NONE , "air" ),
entry(MaterialColor.GRASS , "grass" ),
entry(MaterialColor.SAND , "sand" ),
entry(MaterialColor.WOOL , "wool" ),
entry(MaterialColor.FIRE , "tnt" ),
entry(MaterialColor.ICE , "ice" ),
entry(MaterialColor.METAL , "iron" ),
entry(MaterialColor.PLANT , "foliage" ),
entry(MaterialColor.SNOW , "snow" ),
entry(MaterialColor.CLAY , "clay" ),
entry(MaterialColor.DIRT , "dirt" ),
entry(MaterialColor.STONE , "stone" ),
entry(MaterialColor.WATER , "water" ),
entry(MaterialColor.WOOD , "wood" ),
entry(MaterialColor.QUARTZ , "quartz" ),
entry(MaterialColor.COLOR_ORANGE , "adobe" ),
entry(MaterialColor.COLOR_MAGENTA , "magenta" ),
entry(MaterialColor.COLOR_LIGHT_BLUE, "light_blue"),
entry(MaterialColor.COLOR_YELLOW , "yellow" ),
entry(MaterialColor.COLOR_LIGHT_GREEN , "lime" ),
entry(MaterialColor.COLOR_PINK , "pink" ),
entry(MaterialColor.COLOR_GRAY , "gray" ),
entry(MaterialColor.COLOR_LIGHT_GRAY, "light_gray"),
entry(MaterialColor.COLOR_CYAN , "cyan" ),
entry(MaterialColor.COLOR_PURPLE , "purple" ),
entry(MaterialColor.COLOR_BLUE , "blue" ),
entry(MaterialColor.COLOR_BROWN , "brown" ),
entry(MaterialColor.COLOR_GREEN , "green" ),
entry(MaterialColor.COLOR_RED , "red" ),
entry(MaterialColor.COLOR_BLACK , "black" ),
entry(MaterialColor.GOLD , "gold" ),
entry(MaterialColor.DIAMOND , "diamond" ),
entry(MaterialColor.LAPIS , "lapis" ),
entry(MaterialColor.EMERALD , "emerald" ),
entry(MaterialColor.PODZOL , "obsidian" ),
entry(MaterialColor.NETHER , "netherrack"), //TODO fix these
entry(MaterialColor.TERRACOTTA_WHITE , "white_terracotta" ),
entry(MaterialColor.TERRACOTTA_ORANGE , "orange_terracotta" ),
entry(MaterialColor.TERRACOTTA_MAGENTA , "magenta_terracotta" ),
entry(MaterialColor.TERRACOTTA_LIGHT_BLUE, "light_blue_terracotta" ),
entry(MaterialColor.TERRACOTTA_YELLOW , "yellow_terracotta" ),
entry(MaterialColor.TERRACOTTA_LIGHT_GREEN , "lime_terracotta" ),
entry(MaterialColor.TERRACOTTA_PINK , "pink_terracotta" ),
entry(MaterialColor.TERRACOTTA_GRAY , "gray_terracotta" ),
entry(MaterialColor.TERRACOTTA_LIGHT_GRAY, "light_gray_terracotta" ),
entry(MaterialColor.TERRACOTTA_CYAN , "cyan_terracotta" ),
entry(MaterialColor.TERRACOTTA_PURPLE , "purple_terracotta" ),
entry(MaterialColor.TERRACOTTA_BLUE , "blue_terracotta" ),
entry(MaterialColor.TERRACOTTA_BROWN , "brown_terracotta" ),
entry(MaterialColor.TERRACOTTA_GREEN , "green_terracotta" ),
entry(MaterialColor.TERRACOTTA_RED , "red_terracotta" ),
entry(MaterialColor.TERRACOTTA_BLACK , "black_terracotta" ),
entry(MaterialColor.CRIMSON_NYLIUM , "crimson_nylium" ),
entry(MaterialColor.CRIMSON_STEM , "crimson_stem" ),
entry(MaterialColor.CRIMSON_HYPHAE , "crimson_hyphae" ),
entry(MaterialColor.WARPED_NYLIUM , "warped_nylium" ),
entry(MaterialColor.WARPED_STEM , "warped_stem" ),
entry(MaterialColor.WARPED_HYPHAE , "warped_hyphae" ),
entry(MaterialColor.WARPED_WART_BLOCK , "warped_wart" ),
entry(MaterialColor.DEEPSLATE , "deepslate" ),
entry(MaterialColor.RAW_IRON , "raw_iron" ),
entry(MaterialColor.GLOW_LICHEN , "glow_lichen" )
);
}};
public static final Map<Material, String> materialName = new HashMap<Material, String>() {{
put(Material.AIR , "air" );
put(Material.STRUCTURAL_AIR , "void" );
put(Material.PORTAL , "portal" );
put(Material.CLOTH_DECORATION , "carpet" );
put(Material.PLANT , "plant" );
put(Material.WATER_PLANT, "water_plant" );
put(Material.REPLACEABLE_PLANT, "vegetation" );
put(Material.REPLACEABLE_FIREPROOF_PLANT, "nether_shoots" );
put(Material.REPLACEABLE_WATER_PLANT, "sea_grass" );
put(Material.WATER , "water" );
put(Material.BUBBLE_COLUMN , "bubble_column");
put(Material.LAVA , "lava" );
put(Material.TOP_SNOW , "snow_layer" );
put(Material.FIRE , "fire" );
put(Material.DECORATION , "decoration" );
put(Material.WEB , "cobweb" );
put(Material.SCULK , "sculk" );
put(Material.BUILDABLE_GLASS , "redstone_lamp");
put(Material.CLAY, "clay" );
put(Material.DIRT , "dirt" );
put(Material.GRASS , "grass" );
put(Material.ICE_SOLID , "packed_ice" );
put(Material.SAND , "sand" );
put(Material.SPONGE , "sponge" );
put(Material.SHULKER_SHELL , "shulker" );
put(Material.WOOD , "wood" );
put(Material.NETHER_WOOD , "nether_wood" );
put(Material.BAMBOO_SAPLING , "shoots" );
put(Material.BAMBOO , "bamboo" );
put(Material.WOOL , "wool" );
put(Material.EXPLOSIVE , "tnt" );
put(Material.LEAVES , "leaves" );
put(Material.GLASS , "glass" );
put(Material.ICE , "ice" );
put(Material.CACTUS , "cactus" );
put(Material.STONE , "stone" );
put(Material.METAL , "metal" );
put(Material.SNOW , "snow" );
put(Material.HEAVY_METAL , "anvil" );
put(Material.BARRIER , "barrier" );
put(Material.PISTON , "piston" );
put(Material.MOSS , "moss" );
put(Material.VEGETABLE , "gourd" );
put(Material.EGG , "dragon_egg" );
put(Material.CAKE , "cake" );
put(Material.AMETHYST , "amethyst" );
put(Material.POWDER_SNOW , "powder_snow");
}};
public static final Map<Material, String> materialName = Map.ofEntries(
entry(Material.AIR , "air" ),
entry(Material.STRUCTURAL_AIR , "void" ),
entry(Material.PORTAL , "portal" ),
entry(Material.CLOTH_DECORATION , "carpet" ),
entry(Material.PLANT , "plant" ),
entry(Material.WATER_PLANT, "water_plant" ),
entry(Material.REPLACEABLE_PLANT, "vegetation" ),
entry(Material.REPLACEABLE_FIREPROOF_PLANT, "nether_shoots" ),
entry(Material.REPLACEABLE_WATER_PLANT, "sea_grass" ),
entry(Material.WATER , "water" ),
entry(Material.BUBBLE_COLUMN , "bubble_column"),
entry(Material.LAVA , "lava" ),
entry(Material.TOP_SNOW , "snow_layer" ),
entry(Material.FIRE , "fire" ),
entry(Material.DECORATION , "decoration" ),
entry(Material.WEB , "cobweb" ),
entry(Material.SCULK , "sculk" ),
entry(Material.BUILDABLE_GLASS , "redstone_lamp"),
entry(Material.CLAY, "clay" ),
entry(Material.DIRT , "dirt" ),
entry(Material.GRASS , "grass" ),
entry(Material.ICE_SOLID , "packed_ice" ),
entry(Material.SAND , "sand" ),
entry(Material.SPONGE , "sponge" ),
entry(Material.SHULKER_SHELL , "shulker" ),
entry(Material.WOOD , "wood" ),
entry(Material.NETHER_WOOD , "nether_wood" ),
entry(Material.BAMBOO_SAPLING , "shoots" ),
entry(Material.BAMBOO , "bamboo" ),
entry(Material.WOOL , "wool" ),
entry(Material.EXPLOSIVE , "tnt" ),
entry(Material.LEAVES , "leaves" ),
entry(Material.GLASS , "glass" ),
entry(Material.ICE , "ice" ),
entry(Material.CACTUS , "cactus" ),
entry(Material.STONE , "stone" ),
entry(Material.METAL , "metal" ),
entry(Material.SNOW , "snow" ),
entry(Material.HEAVY_METAL , "anvil" ),
entry(Material.BARRIER , "barrier" ),
entry(Material.PISTON , "piston" ),
entry(Material.MOSS , "moss" ),
entry(Material.VEGETABLE , "gourd" ),
entry(Material.EGG , "dragon_egg" ),
entry(Material.CAKE , "cake" ),
entry(Material.AMETHYST , "amethyst" ),
entry(Material.POWDER_SNOW , "powder_snow")
);
public static List<BaseComponent> blockInfo(BlockPos pos, ServerLevel world)
{
+7 -7
View File
@@ -18,7 +18,7 @@ import net.minecraft.world.phys.Vec3;
public class MobAI
{
private static Map<EntityType,Set<TrackingType>> aiTrackers = new HashMap<>();
private static Map<EntityType<?>, Set<TrackingType>> aiTrackers = new HashMap<>();
public static void resetTrackers()
{
@@ -48,7 +48,7 @@ public class MobAI
}
}
public static void startTracking(EntityType e, TrackingType type)
public static void startTracking(EntityType<?> e, TrackingType type)
{
aiTrackers.putIfAbsent(e,Sets.newHashSet());
aiTrackers.get(e).add(type);
@@ -56,7 +56,7 @@ public class MobAI
public static List<String> availbleTypes()
{
Set<EntityType> types = new HashSet<>();
Set<EntityType<?>> types = new HashSet<>();
for (TrackingType type: TrackingType.values())
{
types.addAll(type.types);
@@ -68,7 +68,7 @@ public class MobAI
{
Set<TrackingType> availableOptions = new HashSet<>();
for (TrackingType type: TrackingType.values())
for (EntityType etype: type.types)
for (EntityType<?> etype: type.types)
if (etype == entityType)
availableOptions.add(type);
return availableOptions.stream().map(t -> t.name).collect(Collectors.toList());
@@ -78,9 +78,9 @@ public class MobAI
{
IRON_GOLEM_SPAWNING("iron_golem_spawning", Sets.newHashSet(EntityType.VILLAGER)),
VILLAGER_BREEDING("breeding", Sets.newHashSet(EntityType.VILLAGER));
public Set<EntityType> types;
public String name;
TrackingType(String name, Set<EntityType> applicableTypes)
public final Set<EntityType<?>> types;
public final String name;
TrackingType(String name, Set<EntityType<?>> applicableTypes)
{
this.name = name;
types = applicableTypes;
@@ -368,13 +368,11 @@ public class SpawnReporter
for (MobCategory enumcreaturetype : MobCategory.values())
{
//String type_code = String.format("%s", enumcreaturetype);
boolean there_are_mobs_to_list = false;
for (ResourceKey<Level> dim : worldIn.getServer().levelKeys()) //String world_code: new String[] {"", " (N)", " (E)"})
{
Pair<ResourceKey<Level>, MobCategory> code = Pair.of(dim, enumcreaturetype);
if (spawn_ticks_spawns.get(code) > 0L)
{
there_are_mobs_to_list = true;
double hours = overall_spawn_ticks.get(code)/72000.0;
report.add(Messenger.s(String.format(" > %s%s (%.1f min), %.1f m/t, %%{%.1fF %.1f- %.1f+}; %.2f s/att",
enumcreaturetype.getName().substring(0,3), getWorldCode(dim),
@@ -479,7 +477,7 @@ public class SpawnReporter
float f1 = (float)z + 0.5F;
mob.moveTo((double)f, (double)y, (double)f1, worldIn.random.nextFloat() * 360.0F, 0.0F);
fits1 = worldIn.noCollision(mob);
EntityType etype = mob.getType();
EntityType<?> etype = mob.getType();
for (int i = 0; i < 20; ++i)
{