[CHORE] Cleanup API's that's unused by any mod currently

This commit is contained in:
2024-01-01 21:42:14 +02:00
parent 8aa8c3b62c
commit 8b4172cfef
125 changed files with 194 additions and 3355 deletions

View File

@@ -1,21 +0,0 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.CraterConstants;
import com.hypherionmc.craterlib.core.systems.internal.CreativeTabRegistry;
import net.minecraft.world.item.CreativeModeTab;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
@Mod.EventBusSubscriber(modid = CraterConstants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class NeoForgeCommonEvents {
@SubscribeEvent
public static void registerTabs(BuildCreativeModeTabContentsEvent event) {
CreativeModeTab tab = event.getTab();
CreativeTabRegistry.getTabItems().stream()
.filter(p -> p.getLeft().get() == tab && p.getRight() != null)
.forEach(itemPair -> event.accept(itemPair.getRight().get()));
}
}

View File

@@ -1,29 +1,15 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.api.blockentity.caps.CraterCapabilityHandler;
import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
import com.hypherionmc.craterlib.core.platform.CommonPlatform;
import com.hypherionmc.craterlib.network.NeoForgeNetworkHandler;
import net.minecraft.core.Direction;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
import net.neoforged.neoforge.server.ServerLifecycleHooks;
import org.apache.commons.lang3.function.TriFunction;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
/**
* @author HypherionSA
@@ -32,7 +18,8 @@ public class NeoForgeCommonHelper implements CommonPlatform {
public static Map<ResourceLocation, CreativeModeTab> TABS = new HashMap<>();
public NeoForgeCommonHelper() {}
public NeoForgeCommonHelper() {
}
@Override
public CraterNetworkHandler createPacketHandler(String modid, boolean requiredClient, boolean requiredServer) {
@@ -43,43 +30,4 @@ public class NeoForgeCommonHelper implements CommonPlatform {
public MinecraftServer getMCServer() {
return ServerLifecycleHooks.getCurrentServer();
}
@Override
public void openMenu(ServerPlayer player, MenuProvider menu, @Nullable Consumer<FriendlyByteBuf> initialData) {
// TODO Fix Menus
/*if (initialData != null) {
player.openMenu(menu, initialData);
} else {
player.openMenu(menu, player.getOnPos());
}*/
}
@Override
public <T extends AbstractContainerMenu> MenuType<T> createMenuType(TriFunction<Integer, Inventory, FriendlyByteBuf, T> constructor) {
return IMenuTypeExtension.create(constructor::apply);
}
@Override
public <T> Optional<T> getCapabilityHandler(BlockEntity entity, Direction side, CraterCapabilityHandler capability) {
// TODO Fix This
/*if (capability == CraterCapabilityHandler.ENERGY) {
AtomicReference<NeoForgeEnergyReader> energyReference = new AtomicReference<>();
entity.getCapability(Capabilities.ENERGY, side).ifPresent(storage -> energyReference.set(new NeoForgeEnergyReader(storage)));
return energyReference.get() != null ? (Optional<T>) Optional.of(energyReference.get()) : Optional.empty();
}
if (capability == CraterCapabilityHandler.FLUID) {
AtomicReference<ICraterFluidHandler> craterFluidHandler = new AtomicReference<>();
entity.getCapability(Capabilities.FLUID_HANDLER, side).ifPresent(iFluidHandler -> craterFluidHandler.set(new NeoForgeFluidReader(iFluidHandler)));
return craterFluidHandler.get() != null ? (Optional<T>) Optional.of(craterFluidHandler.get()) : Optional.empty();
}
if (entity instanceof ICraterCapProvider capProvider) {
return capProvider.getCapability(capability, side);
}*/
return Optional.empty();
}
}

View File

@@ -1,58 +0,0 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CraterFluidHelper;
import com.hypherionmc.craterlib.core.systems.fluid.CraterFluidTank;
import com.hypherionmc.craterlib.core.systems.fluid.FluidHolder;
import com.hypherionmc.craterlib.core.systems.fluid.ICraterFluidHandler;
import com.hypherionmc.craterlib.systems.fluid.NeoForgeFluidTankInteractor;
import com.hypherionmc.craterlib.systems.fluid.NeoForgeFluidUtils;
import com.hypherionmc.craterlib.systems.fluid.NeoForgeWrappedFluidTank;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.Fluid;
import net.neoforged.neoforge.client.extensions.common.IClientFluidTypeExtensions;
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.FluidUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
public class NeoForgeFluidHelper implements CraterFluidHelper {
@Override
public CraterFluidTank createFluidTank(int capacity) {
return new NeoForgeWrappedFluidTank(capacity);
}
@Override
public CraterFluidTank createFluidTank(int capacity, Fluid... validFluids) {
return new NeoForgeWrappedFluidTank(capacity, (variant) -> Arrays.stream(validFluids).allMatch(f -> f.isSame(variant.getFluid())));
}
@Override
public boolean interactWithFluidHandler(Player player, InteractionHand hand, ICraterFluidHandler fluidHandler) {
NeoForgeFluidTankInteractor interactor = new NeoForgeFluidTankInteractor(fluidHandler);
return FluidUtil.interactWithFluidHandler(player, hand, interactor);
}
@Override
public boolean interactWithFluidHandler(@NotNull Player player, @NotNull InteractionHand hand, @NotNull Level level, @NotNull BlockPos pos, @Nullable Direction side) {
return FluidUtil.interactWithFluidHandler(player, hand, level, pos, side);
}
@Override
public TextureAtlasSprite getFluidTexture(FluidHolder fluidHolder) {
return NeoForgeFluidUtils.getFluidTexture(new FluidStack(fluidHolder.getFluid(), 0), true);
}
@Override
public int getFluidColor(Fluid fluid) {
IClientFluidTypeExtensions props = IClientFluidTypeExtensions.of(fluid);
return props.getTintColor();
}
}

View File

@@ -15,7 +15,8 @@ import java.io.File;
*/
public class NeoForgeLoaderHelper implements ModloaderEnvironment {
public NeoForgeLoaderHelper() {}
public NeoForgeLoaderHelper() {
}
@Override
public boolean isFabric() {