HexCasting/Common/src/main/java/at/petrak/hexcasting/xplat/IXplatAbstractions.java

199 lines
6.4 KiB
Java
Raw Normal View History

2022-04-25 16:40:32 +02:00
package at.petrak.hexcasting.xplat;
import at.petrak.hexcasting.api.HexAPI;
2022-06-13 23:45:22 +02:00
import at.petrak.hexcasting.api.addldata.ADHexHolder;
import at.petrak.hexcasting.api.addldata.ADIotaHolder;
import at.petrak.hexcasting.api.addldata.ADMediaHolder;
import at.petrak.hexcasting.api.casting.ActionRegistryEntry;
2023-01-22 00:35:41 +01:00
import at.petrak.hexcasting.api.casting.castables.SpecialHandler;
import at.petrak.hexcasting.api.casting.eval.ResolvedPattern;
import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound;
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage;
2023-02-04 18:35:26 +01:00
import at.petrak.hexcasting.api.casting.eval.vm.CastingVM;
import at.petrak.hexcasting.api.casting.iota.IotaType;
import at.petrak.hexcasting.api.pigment.ColorProvider;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
2023-02-18 01:06:12 +01:00
import at.petrak.hexcasting.api.player.AltioraAbility;
import at.petrak.hexcasting.api.player.FlightAbility;
import at.petrak.hexcasting.api.player.Sentinel;
2022-04-27 22:56:59 +02:00
import at.petrak.hexcasting.common.network.IMessage;
2022-06-02 09:11:48 +02:00
import at.petrak.hexcasting.interop.pehkui.PehkuiInterop;
2022-05-05 19:37:52 +02:00
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.network.protocol.Packet;
import net.minecraft.server.level.ServerLevel;
2022-04-27 22:56:59 +02:00
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
2022-10-01 18:52:37 +02:00
import net.minecraft.world.entity.Entity;
2022-05-09 20:23:39 +02:00
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.player.Player;
2022-05-01 00:57:15 +02:00
import net.minecraft.world.item.CreativeModeTab;
2022-05-09 20:23:39 +02:00
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tier;
2022-05-01 19:38:58 +02:00
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
2022-05-01 00:57:15 +02:00
import net.minecraft.world.level.block.Block;
2022-05-05 19:37:52 +02:00
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
2022-05-24 00:01:22 +02:00
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
2022-04-25 16:40:32 +02:00
import java.util.List;
2022-04-25 16:40:32 +02:00
import java.util.ServiceLoader;
2022-05-05 19:37:52 +02:00
import java.util.function.BiFunction;
2022-04-25 16:40:32 +02:00
import java.util.stream.Collectors;
/**
* more like IHexplatAbstracts lmaooooooo
*/
2022-04-25 16:40:32 +02:00
public interface IXplatAbstractions {
Platform platform();
boolean isModPresent(String id);
boolean isPhysicalClient();
2022-04-25 16:40:32 +02:00
void initPlatformSpecific();
void sendPacketToPlayer(ServerPlayer target, IMessage packet);
void sendPacketNear(Vec3 pos, double radius, ServerLevel dimension, IMessage packet);
// https://github.com/VazkiiMods/Botania/blob/13b7bcd9cbb6b1a418b0afe455662d29b46f1a7f/Xplat/src/main/java/vazkii/botania/xplat/IXplatAbstractions.java#L157
Packet<?> toVanillaClientboundPacket(IMessage message);
double getReachDistance(Player player);
2022-05-09 20:23:39 +02:00
// Things that used to be caps
/**
* Doesn't actually knock out its AI or anything anymore, just sets caps/ccs
*/
// heheheheh addled data
void setBrainsweepAddlData(Mob mob);
boolean isBrainswept(Mob mob);
2022-04-27 22:56:59 +02:00
void setColorizer(Player target, FrozenPigment colorizer);
void setSentinel(Player target, @Nullable Sentinel sentinel);
2023-02-17 21:11:16 +01:00
void setFlight(ServerPlayer target, @Nullable FlightAbility flight);
2023-02-18 04:44:16 +01:00
void setAltiora(Player target, @Nullable AltioraAbility altiora);
2023-02-18 01:06:12 +01:00
void setStaffcastImage(ServerPlayer target, @Nullable CastingImage image);
void setPatterns(ServerPlayer target, List<ResolvedPattern> patterns);
2023-02-17 21:11:16 +01:00
@Nullable FlightAbility getFlight(ServerPlayer player);
2022-04-27 22:56:59 +02:00
2023-02-18 02:30:41 +01:00
@Nullable AltioraAbility getAltiora(Player player);
2023-02-18 01:06:12 +01:00
FrozenPigment getColorizer(Player player);
@Nullable Sentinel getSentinel(Player player);
2023-02-19 02:19:49 +01:00
CastingVM getStaffcastVM(ServerPlayer player, InteractionHand hand);
2023-01-21 18:53:23 +01:00
List<ResolvedPattern> getPatternsSavedInUi(ServerPlayer player);
void clearCastingData(ServerPlayer player);
@Nullable
2022-11-10 01:50:37 +01:00
ADMediaHolder findMediaHolder(ItemStack stack);
@Nullable
ADMediaHolder findMediaHolder(ServerPlayer player);
@Nullable
2022-06-13 23:45:22 +02:00
ADIotaHolder findDataHolder(ItemStack stack);
2022-10-01 18:52:37 +02:00
@Nullable
2022-11-06 04:19:04 +01:00
ADIotaHolder findDataHolder(Entity entity);
2022-10-01 18:52:37 +02:00
@Nullable
2022-06-13 23:45:22 +02:00
ADHexHolder findHexHolder(ItemStack stack);
// coooollooorrrs
boolean isColorizer(ItemStack stack);
ColorProvider getColorProvider(FrozenPigment colorizer);
2022-05-09 20:23:39 +02:00
// Items
/**
* No-op on forge (use a SoftImplement)
*/
Item.Properties addEquipSlotFabric(EquipmentSlot slot);
2022-05-09 20:23:39 +02:00
2022-05-01 00:57:15 +02:00
// Blocks
2022-05-05 19:37:52 +02:00
<T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
2022-12-30 19:07:21 +01:00
Block... blocks);
2022-05-05 19:37:52 +02:00
boolean tryPlaceFluid(Level level, InteractionHand hand, BlockPos pos, Fluid fluid);
boolean drainAllFluid(Level level, BlockPos pos);
2022-05-01 00:57:15 +02:00
// misc
CreativeModeTab getTab();
2022-04-27 22:56:59 +02:00
boolean isCorrectTierForDrops(Tier tier, BlockState bs);
2022-04-25 16:40:32 +02:00
2022-05-01 19:38:58 +02:00
Ingredient getUnsealedIngredient(ItemStack stack);
2022-05-23 21:21:13 +02:00
IXplatTags tags();
2022-05-24 00:01:22 +02:00
LootItemCondition.Builder isShearsCondition();
2022-06-02 03:51:12 +02:00
String getModName(String namespace);
2022-12-30 19:43:38 +01:00
/**
* Registry for actions.
* <p>
* There's some internal caching (so we can directly look up signatures in a map, for example)
* but this registry is the source of truth.
*/
Registry<ActionRegistryEntry> getActionRegistry();
Registry<SpecialHandler.Factory<?>> getSpecialHandlerRegistry();
2022-12-30 19:43:38 +01:00
Registry<IotaType<?>> getIotaTypeRegistry();
2022-11-22 00:55:36 +01:00
Registry<EvalSound> getEvalSoundRegistry();
2022-07-03 05:23:28 +02:00
boolean isBreakingAllowed(Level world, BlockPos pos, BlockState state, Player player);
boolean isPlacingAllowed(Level world, BlockPos pos, ItemStack blockStack, Player player);
2022-06-02 09:11:48 +02:00
// interop
PehkuiInterop.ApiAbstraction getPehkuiApi();
2022-05-23 21:21:13 +02:00
///
2022-04-25 16:40:32 +02:00
IXplatAbstractions INSTANCE = find();
private static IXplatAbstractions find() {
var providers = ServiceLoader.load(IXplatAbstractions.class).stream().toList();
if (providers.size() != 1) {
var names = providers.stream().map(p -> p.type().getName()).collect(Collectors.joining(",", "[", "]"));
throw new IllegalStateException(
"There should be exactly one IXplatAbstractions implementation on the classpath. Found: " + names);
} else {
var provider = providers.get(0);
HexAPI.LOGGER.debug("Instantiating xplat impl: " + provider.type().getName());
return provider.get();
}
}
2022-05-05 19:37:52 +02:00
2022-04-25 16:40:32 +02:00
}