mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-19 23:00:19 +00:00
refactor Pairs
This commit is contained in:
@@ -23,6 +23,8 @@ import com.dfsek.tectonic.exception.ConfigException;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair.Mutable;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
@@ -40,7 +42,6 @@ import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.fabric.config.PostLoadCompatibilityOptions;
|
||||
@@ -54,7 +55,7 @@ public final class FabricAddon implements BaseAddon {
|
||||
private final PlatformImpl terraFabricPlugin;
|
||||
private static final Logger logger = LoggerFactory.getLogger(FabricAddon.class);
|
||||
|
||||
private final Map<ConfigPack, Pair<PreLoadCompatibilityOptions, PostLoadCompatibilityOptions>> templates = new HashMap<>();
|
||||
private final Map<ConfigPack, Mutable<PreLoadCompatibilityOptions, PostLoadCompatibilityOptions>> templates = new HashMap<>();
|
||||
|
||||
public FabricAddon(PlatformImpl terraFabricPlugin) {
|
||||
this.terraFabricPlugin = terraFabricPlugin;
|
||||
@@ -88,7 +89,7 @@ public final class FabricAddon implements BaseAddon {
|
||||
}
|
||||
});
|
||||
}
|
||||
templates.put(event.getPack(), Pair.of(template, null));
|
||||
templates.put(event.getPack(), Mutable.of(template, null));
|
||||
})
|
||||
.global();
|
||||
|
||||
@@ -143,7 +144,7 @@ public final class FabricAddon implements BaseAddon {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<ConfigPack, Pair<PreLoadCompatibilityOptions, PostLoadCompatibilityOptions>> getTemplates() {
|
||||
public Map<ConfigPack, Mutable<PreLoadCompatibilityOptions, PostLoadCompatibilityOptions>> getTemplates() {
|
||||
return templates;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,52 +35,52 @@ import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.Property;
|
||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||
import com.dfsek.terra.api.util.generic.Construct;
|
||||
import com.dfsek.terra.api.util.generic.pair.ImmutablePair;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.fabric.mixin.access.StateAccessor;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
|
||||
|
||||
public class FabricBlockState implements BlockState {
|
||||
private static final Map<Property<?>, ImmutablePair<net.minecraft.state.property.Property<?>, Function<Object, Object>>>
|
||||
private static final Map<Property<?>, Pair<net.minecraft.state.property.Property<?>, Function<Object, Object>>>
|
||||
PROPERTY_DELEGATES_T2M = Construct.construct(() -> {
|
||||
Map<Property<?>, ImmutablePair<net.minecraft.state.property.Property<?>, Function<Object, Object>>> map = new HashMap<>();
|
||||
map.put(Properties.AXIS, ImmutablePair.of(net.minecraft.state.property.Properties.AXIS,
|
||||
Map<Property<?>, Pair<net.minecraft.state.property.Property<?>, Function<Object, Object>>> map = new HashMap<>();
|
||||
map.put(Properties.AXIS, Pair.of(net.minecraft.state.property.Properties.AXIS,
|
||||
a -> FabricAdapter.adapt((net.minecraft.util.math.Direction.Axis) a)));
|
||||
|
||||
map.put(Properties.NORTH, ImmutablePair.of(net.minecraft.state.property.Properties.NORTH, Function.identity()));
|
||||
map.put(Properties.SOUTH, ImmutablePair.of(net.minecraft.state.property.Properties.SOUTH, Function.identity()));
|
||||
map.put(Properties.EAST, ImmutablePair.of(net.minecraft.state.property.Properties.EAST, Function.identity()));
|
||||
map.put(Properties.WEST, ImmutablePair.of(net.minecraft.state.property.Properties.WEST, Function.identity()));
|
||||
map.put(Properties.NORTH, Pair.of(net.minecraft.state.property.Properties.NORTH, Function.identity()));
|
||||
map.put(Properties.SOUTH, Pair.of(net.minecraft.state.property.Properties.SOUTH, Function.identity()));
|
||||
map.put(Properties.EAST, Pair.of(net.minecraft.state.property.Properties.EAST, Function.identity()));
|
||||
map.put(Properties.WEST, Pair.of(net.minecraft.state.property.Properties.WEST, Function.identity()));
|
||||
|
||||
map.put(Properties.NORTH_CONNECTION, ImmutablePair.of(net.minecraft.state.property.Properties.NORTH_WIRE_CONNECTION,
|
||||
map.put(Properties.NORTH_CONNECTION, Pair.of(net.minecraft.state.property.Properties.NORTH_WIRE_CONNECTION,
|
||||
c -> FabricAdapter.adapt((WireConnection) c)));
|
||||
map.put(Properties.SOUTH_CONNECTION, ImmutablePair.of(net.minecraft.state.property.Properties.SOUTH_WIRE_CONNECTION,
|
||||
map.put(Properties.SOUTH_CONNECTION, Pair.of(net.minecraft.state.property.Properties.SOUTH_WIRE_CONNECTION,
|
||||
c -> FabricAdapter.adapt((WireConnection) c)));
|
||||
map.put(Properties.EAST_CONNECTION, ImmutablePair.of(net.minecraft.state.property.Properties.EAST_WIRE_CONNECTION,
|
||||
map.put(Properties.EAST_CONNECTION, Pair.of(net.minecraft.state.property.Properties.EAST_WIRE_CONNECTION,
|
||||
c -> FabricAdapter.adapt((WireConnection) c)));
|
||||
map.put(Properties.WEST_CONNECTION, ImmutablePair.of(net.minecraft.state.property.Properties.WEST_WIRE_CONNECTION,
|
||||
map.put(Properties.WEST_CONNECTION, Pair.of(net.minecraft.state.property.Properties.WEST_WIRE_CONNECTION,
|
||||
c -> FabricAdapter.adapt((WireConnection) c)));
|
||||
|
||||
|
||||
map.put(Properties.NORTH_HEIGHT,
|
||||
ImmutablePair.of(net.minecraft.state.property.Properties.NORTH_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h)));
|
||||
Pair.of(net.minecraft.state.property.Properties.NORTH_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h)));
|
||||
map.put(Properties.SOUTH_HEIGHT,
|
||||
ImmutablePair.of(net.minecraft.state.property.Properties.SOUTH_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h)));
|
||||
Pair.of(net.minecraft.state.property.Properties.SOUTH_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h)));
|
||||
map.put(Properties.EAST_HEIGHT,
|
||||
ImmutablePair.of(net.minecraft.state.property.Properties.EAST_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h)));
|
||||
Pair.of(net.minecraft.state.property.Properties.EAST_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h)));
|
||||
map.put(Properties.WEST_HEIGHT,
|
||||
ImmutablePair.of(net.minecraft.state.property.Properties.WEST_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h)));
|
||||
Pair.of(net.minecraft.state.property.Properties.WEST_WALL_SHAPE, h -> FabricAdapter.adapt((WallShape) h)));
|
||||
|
||||
map.put(Properties.DIRECTION,
|
||||
ImmutablePair.of(net.minecraft.state.property.Properties.FACING, d -> FabricAdapter.adapt((Direction) d)));
|
||||
Pair.of(net.minecraft.state.property.Properties.FACING, d -> FabricAdapter.adapt((Direction) d)));
|
||||
|
||||
map.put(Properties.WATERLOGGED, ImmutablePair.of(net.minecraft.state.property.Properties.WATERLOGGED, Function.identity()));
|
||||
map.put(Properties.WATERLOGGED, Pair.of(net.minecraft.state.property.Properties.WATERLOGGED, Function.identity()));
|
||||
|
||||
map.put(Properties.RAIL_SHAPE,
|
||||
ImmutablePair.of(net.minecraft.state.property.Properties.RAIL_SHAPE, s -> FabricAdapter.adapt((RailShape) s)));
|
||||
Pair.of(net.minecraft.state.property.Properties.RAIL_SHAPE, s -> FabricAdapter.adapt((RailShape) s)));
|
||||
|
||||
map.put(Properties.HALF,
|
||||
ImmutablePair.of(net.minecraft.state.property.Properties.BLOCK_HALF, h -> FabricAdapter.adapt((BlockHalf) h)));
|
||||
Pair.of(net.minecraft.state.property.Properties.BLOCK_HALF, h -> FabricAdapter.adapt((BlockHalf) h)));
|
||||
|
||||
return map;
|
||||
});
|
||||
@@ -110,7 +110,7 @@ public class FabricBlockState implements BlockState {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T get(Property<T> property) {
|
||||
ImmutablePair<net.minecraft.state.property.Property<?>, Function<Object, Object>> pair = PROPERTY_DELEGATES_T2M.get(property);
|
||||
Pair<net.minecraft.state.property.Property<?>, Function<Object, Object>> pair = PROPERTY_DELEGATES_T2M.get(property);
|
||||
return (T) pair.getRight().apply(delegate.get(pair.getLeft()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user