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