Fix more warnings and do some small optimizations (#1356)
* Fix more warnings and do some small optimizations * Fix more warnings in ValueConversions * Clean up some decompiler names and fix an unnecessary transformation around commands * Use (way) more compact data structure for slot map * Minor tweaks Such as map directly in the collector * I hate vanilla javac Revert map changes in latest commit
This commit is contained in:
1 parent
e4dc080657
commit
f18cfb09d2
18 files changed
+116
-139
No files matched your search
@@ -68,31 +68,20 @@ public class MobAI
|
||||
{
|
||||
Set<TrackingType> availableOptions = new HashSet<>();
|
||||
for (TrackingType type: TrackingType.values())
|
||||
for (EntityType<?> etype: type.types)
|
||||
if (etype == entityType)
|
||||
availableOptions.add(type);
|
||||
return availableOptions.stream().map(t -> t.name).collect(Collectors.toList());
|
||||
if (type.types.contains(entityType))
|
||||
availableOptions.add(type);
|
||||
return availableOptions.stream().map(t -> t.name().toLowerCase()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public enum TrackingType
|
||||
{
|
||||
IRON_GOLEM_SPAWNING("iron_golem_spawning", Sets.newHashSet(EntityType.VILLAGER)),
|
||||
VILLAGER_BREEDING("breeding", Sets.newHashSet(EntityType.VILLAGER));
|
||||
IRON_GOLEM_SPAWNING(Set.of(EntityType.VILLAGER)),
|
||||
BREEDING(Set.of(EntityType.VILLAGER));
|
||||
public final Set<EntityType<?>> types;
|
||||
public final String name;
|
||||
TrackingType(String name, Set<EntityType<?>> applicableTypes)
|
||||
TrackingType(Set<EntityType<?>> applicableTypes)
|
||||
{
|
||||
this.name = name;
|
||||
types = applicableTypes;
|
||||
}
|
||||
|
||||
public static TrackingType byName(String aspect)
|
||||
{
|
||||
for (TrackingType type: values())
|
||||
if (type.name.equalsIgnoreCase(aspect))
|
||||
return type;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,8 +3,12 @@ package carpet.utils;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.HopperCounter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -17,6 +21,8 @@ import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
/**
|
||||
* A series of utility functions and variables for dealing predominantly with hopper counters and determining which counter
|
||||
* to add their items to, as well as helping dealing with carpet functionality.
|
||||
@@ -27,38 +33,32 @@ public class WoolTool
|
||||
* A map of the {@link MaterialColor} to the {@link DyeColor} which is used in {@link WoolTool#getWoolColorAtPosition}
|
||||
* to get the colour of wool at a position.
|
||||
*/
|
||||
private static final HashMap<MaterialColor,DyeColor> Material2Dye = new HashMap<>();
|
||||
private static final Map<MaterialColor,DyeColor> Material2Dye = Arrays.stream(DyeColor.values())
|
||||
.collect(Collectors.toUnmodifiableMap(DyeColor::getMaterialColor, Function.identity()));
|
||||
|
||||
/**
|
||||
* A map of all the wool colours to their respective colours in the {@link Messenger#m} format so the name of the counter
|
||||
* gets printed in colour.
|
||||
*/
|
||||
|
||||
public static final HashMap<MaterialColor,String> Material2DyeName = new HashMap<MaterialColor, String>(){{
|
||||
put(MaterialColor.SNOW, "w ");
|
||||
put(MaterialColor.COLOR_ORANGE, "#F9801D ");
|
||||
put(MaterialColor.COLOR_MAGENTA, "m ");
|
||||
put(MaterialColor.COLOR_LIGHT_BLUE, "t ");
|
||||
put(MaterialColor.COLOR_YELLOW, "y ");
|
||||
put(MaterialColor.COLOR_LIGHT_GREEN, "l ");
|
||||
put(MaterialColor.COLOR_PINK, "#FFACCB ");
|
||||
put(MaterialColor.COLOR_GRAY, "f ");
|
||||
put(MaterialColor.COLOR_LIGHT_GRAY, "g ");
|
||||
put(MaterialColor.COLOR_CYAN, "c ");
|
||||
put(MaterialColor.COLOR_PURPLE, "p ");
|
||||
put(MaterialColor.COLOR_BLUE, "v ");
|
||||
put(MaterialColor.COLOR_BROWN, "#835432 ");
|
||||
put(MaterialColor.COLOR_GREEN, "e ");
|
||||
put(MaterialColor.COLOR_RED, "r ");
|
||||
put(MaterialColor.COLOR_BLACK, "k ");
|
||||
}};
|
||||
static
|
||||
{
|
||||
for (DyeColor color: DyeColor.values())
|
||||
{
|
||||
Material2Dye.put(color.getMaterialColor(),color);
|
||||
}
|
||||
}
|
||||
public static final Map<MaterialColor,String> Material2DyeName = Map.ofEntries(
|
||||
entry(MaterialColor.SNOW, "w "),
|
||||
entry(MaterialColor.COLOR_ORANGE, "#F9801D "),
|
||||
entry(MaterialColor.COLOR_MAGENTA, "m "),
|
||||
entry(MaterialColor.COLOR_LIGHT_BLUE, "t "),
|
||||
entry(MaterialColor.COLOR_YELLOW, "y "),
|
||||
entry(MaterialColor.COLOR_LIGHT_GREEN, "l "),
|
||||
entry(MaterialColor.COLOR_PINK, "#FFACCB "),
|
||||
entry(MaterialColor.COLOR_GRAY, "f "),
|
||||
entry(MaterialColor.COLOR_LIGHT_GRAY, "g "),
|
||||
entry(MaterialColor.COLOR_CYAN, "c "),
|
||||
entry(MaterialColor.COLOR_PURPLE, "p "),
|
||||
entry(MaterialColor.COLOR_BLUE, "v "),
|
||||
entry(MaterialColor.COLOR_BROWN, "#835432 "),
|
||||
entry(MaterialColor.COLOR_GREEN, "e "),
|
||||
entry(MaterialColor.COLOR_RED, "r "),
|
||||
entry(MaterialColor.COLOR_BLACK, "k ")
|
||||
);
|
||||
|
||||
/**
|
||||
* The method which gets triggered when a player places a carpet, and decides what to do based on the carpet's colour:
|
||||
@@ -69,10 +69,10 @@ public class WoolTool
|
||||
*/
|
||||
public static void carpetPlacedAction(DyeColor color, Player placer, BlockPos pos, ServerLevel worldIn)
|
||||
{
|
||||
if (!CarpetSettings.carpets)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!CarpetSettings.carpets)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (color)
|
||||
{
|
||||
case PINK:
|
||||
@@ -100,7 +100,7 @@ public class WoolTool
|
||||
if (!"false".equals(CarpetSettings.commandInfo))
|
||||
Messenger.send(placer, BlockInfo.blockInfo(pos.below(), worldIn));
|
||||
break;
|
||||
case GREEN:
|
||||
case GREEN:
|
||||
if (CarpetSettings.hopperCounters)
|
||||
{
|
||||
DyeColor under = getWoolColorAtPosition(worldIn, pos.below());
|
||||
@@ -109,8 +109,8 @@ public class WoolTool
|
||||
if (counter != null)
|
||||
Messenger.send(placer, counter.format(worldIn.getServer(), false, false));
|
||||
}
|
||||
break;
|
||||
case RED:
|
||||
break;
|
||||
case RED:
|
||||
if (CarpetSettings.hopperCounters)
|
||||
{
|
||||
DyeColor under = getWoolColorAtPosition(worldIn, pos.below());
|
||||
@@ -122,7 +122,7 @@ public class WoolTool
|
||||
res.add(Messenger.s(String.format("%s counter reset",under.toString())));
|
||||
Messenger.send(placer, res);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user