├── .gitattributes ├── .gitignore ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── ic2 │ └── api │ ├── addons │ ├── IC2Plugin.java │ └── IModule.java │ ├── blocks │ ├── BlockRegistries.java │ ├── DyeableMap.java │ ├── ExplosionWhitelist.java │ ├── IAdvancedComparable.java │ ├── IWrenchable.java │ ├── PainterHelper.java │ ├── WrenchHelper.java │ └── wrench │ │ ├── BaseWrenchHandler.java │ │ ├── ChestWrenchHandler.java │ │ ├── DispenserWrenchHandler.java │ │ ├── HopperWrenchHandler.java │ │ ├── HorizontalWrenchHandler.java │ │ ├── InvertedHorizontalWrenchHandler.java │ │ ├── ObserverBlockWrenchHandler.java │ │ ├── PillarWrenchHandler.java │ │ ├── PistonWrenchHandler.java │ │ └── StairWrenchHandler.java │ ├── core │ ├── APIHelper.java │ └── IC2Classic.java │ ├── crops │ ├── BaseSeed.java │ ├── CropDifficulty.java │ ├── CropProperties.java │ ├── ICrop.java │ ├── ICropModifier.java │ ├── ICropRegistry.java │ ├── ICropRenderer.java │ ├── ICropSeed.java │ ├── ICropTile.java │ ├── IFarmland.java │ ├── ISeedCrop.java │ └── ISubSoil.java │ ├── energy │ ├── EnergyNet.java │ ├── IEnergyNet.java │ ├── PacketStats.java │ ├── TransferStats.java │ ├── impl │ │ ├── LinkedSink.java │ │ └── LinkedSource.java │ └── tile │ │ ├── IEnergyAcceptor.java │ │ ├── IEnergyConductor.java │ │ ├── IEnergyConductorAnchored.java │ │ ├── IEnergyConductorColored.java │ │ ├── IEnergyConductorModifiable.java │ │ ├── IEnergyEmitter.java │ │ ├── IEnergySink.java │ │ ├── IEnergySource.java │ │ ├── IEnergyTile.java │ │ ├── IMultiEnergySource.java │ │ └── IMultiEnergyTile.java │ ├── events │ ├── ArmorSlotEvent.java │ ├── FoamEvent.java │ ├── LaserEvent.java │ ├── RetextureEvent.java │ └── ScrapBoxEvent.java │ ├── items │ ├── IAutoEatable.java │ ├── IBoxableItem.java │ ├── ICoinItem.java │ ├── ICutterItem.java │ ├── IDisplayProvider.java │ ├── IDrinkContainer.java │ ├── IDrinkableFluid.java │ ├── IFoamOverrider.java │ ├── IFuelableItem.java │ ├── IRepairable.java │ ├── ITagBlock.java │ ├── ITagItem.java │ ├── ITerraformerBP.java │ ├── IUpgradeItem.java │ ├── IWindmillBlade.java │ ├── ItemRegistries.java │ ├── armor │ │ ├── IArmorHud.java │ │ ├── IArmorModule.java │ │ ├── ICustomArmor.java │ │ ├── IEnergyShieldArmor.java │ │ ├── IFoamSupplier.java │ │ └── IMetalArmor.java │ ├── electric │ │ ├── ElectricItem.java │ │ ├── ICustomElectricItem.java │ │ ├── IDamagelessElectricItem.java │ │ ├── IElectricEnchantable.java │ │ ├── IElectricItem.java │ │ ├── IElectricItemManager.java │ │ ├── IFluidScanner.java │ │ ├── IMiningDrill.java │ │ └── IScanner.java │ └── readers │ │ ├── ICropReader.java │ │ ├── IEUReader.java │ │ ├── IThermometer.java │ │ └── IWrenchTool.java │ ├── network │ ├── INetworkManager.java │ ├── IPlayerPacket.java │ ├── buffer │ │ ├── EmptyDataBuffer.java │ │ ├── IBitLevelOverride.java │ │ ├── IInputBuffer.java │ │ ├── INetworkDataBuffer.java │ │ ├── IOutputBuffer.java │ │ └── NetworkInfo.java │ ├── container │ │ └── IContainerDataEvent.java │ ├── item │ │ ├── INetworkItemBufferEvent.java │ │ └── INetworkItemEvent.java │ └── tile │ │ ├── INetworkClientEventListener.java │ │ ├── INetworkDataEventListener.java │ │ ├── INetworkEventListener.java │ │ ├── INetworkFieldNotifier.java │ │ ├── INetworkFieldProvider.java │ │ └── PacketRange.java │ ├── reactor │ ├── IChamberReactor.java │ ├── IReactor.java │ ├── IReactorChamber.java │ ├── IReactorComponent.java │ ├── IReactorPlannerComponent.java │ ├── IReactorProduct.java │ ├── ISteamReactor.java │ ├── ISteamReactorChamber.java │ ├── IUsableUranium.java │ └── planner │ │ ├── BaseDurabilitySimulatedStack.java │ │ ├── BaseHeatSimulatedStack.java │ │ ├── FloatTracker.java │ │ ├── ISimulatedReactor.java │ │ ├── SimulatedStack.java │ │ └── Tracker.java │ ├── recipes │ ├── RecipeRegistry.java │ ├── ingridients │ │ ├── generators │ │ │ ├── EmptyGenerator.java │ │ │ ├── IOutputGenerator.java │ │ │ ├── ItemGenerator.java │ │ │ └── ItemWithNBTGenerator.java │ │ ├── inputs │ │ │ ├── ArrayInput.java │ │ │ ├── EmptyInput.java │ │ │ ├── FluidInput.java │ │ │ ├── IInput.java │ │ │ ├── INullableInput.java │ │ │ ├── IngredientInput.java │ │ │ ├── ItemInput.java │ │ │ ├── ItemListInput.java │ │ │ ├── ItemStackInput.java │ │ │ ├── ItemTagInput.java │ │ │ └── SubItemInput.java │ │ ├── queue │ │ │ ├── IInputter.java │ │ │ ├── IStackOutput.java │ │ │ ├── MultiStackOutput.java │ │ │ └── SimpleStackOutput.java │ │ └── recipes │ │ │ ├── BaseRecipeOutput.java │ │ │ ├── ChanceRecipeOutput.java │ │ │ ├── IFluidRecipeOutput.java │ │ │ ├── IRecipeOutput.java │ │ │ ├── IRecipeOutputChance.java │ │ │ ├── RangeFluidOutput.java │ │ │ ├── RangeRecipeOutput.java │ │ │ ├── SawMillOutput.java │ │ │ ├── SimpleFluidOutput.java │ │ │ └── SimpleRecipeOutput.java │ ├── misc │ │ ├── ICanEffect.java │ │ ├── RecipeFlags.java │ │ ├── RecipeMods.java │ │ └── SimpleCanEffect.java │ └── registries │ │ ├── IAdvancedCraftingManager.java │ │ ├── ICannerRecipeRegistry.java │ │ ├── IElectrolyzerRecipeList.java │ │ ├── IFluidFuelRegistry.java │ │ ├── IFoodCanRegistry.java │ │ ├── IFusionRecipeList.java │ │ ├── IIngredientRegistry.java │ │ ├── IListenableRegistry.java │ │ ├── IMachineRecipeList.java │ │ ├── IPotionBrewRegistry.java │ │ ├── IRareEarthRegistry.java │ │ ├── IRecipeFilter.java │ │ ├── IRecyclerRecipeList.java │ │ ├── IRefiningRecipeList.java │ │ ├── IScrapBoxRegistry.java │ │ └── IUUMatterRegistry.java │ ├── ticks │ └── ITickScheduler.java │ ├── tiles │ ├── ArrayTube.java │ ├── FakePlayerMachine.java │ ├── IAnchorTile.java │ ├── ICopyableSettings.java │ ├── IElectrolyzerProvider.java │ ├── IEnergyStorage.java │ ├── IFluidMachine.java │ ├── IInputMachine.java │ ├── IMachine.java │ ├── INotifiableMachine.java │ ├── IRecipeMachine.java │ ├── ITerraformer.java │ ├── display │ │ ├── IDisplayInfo.java │ │ ├── IDisplayRegistry.java │ │ ├── IMonitorRenderer.java │ │ └── impl │ │ │ ├── ItemDisplayInfo.java │ │ │ ├── ProgressDisplayInfo.java │ │ │ └── StringDisplayInfo.java │ ├── readers │ │ ├── IActivityProvider.java │ │ ├── IAirSpeed.java │ │ ├── IEUProducer.java │ │ ├── IEUStorage.java │ │ ├── IFuelStorage.java │ │ ├── IProgressMachine.java │ │ ├── IPumpTile.java │ │ ├── ISpeedMachine.java │ │ ├── ISubProgressMachine.java │ │ ├── IWorkProvider.java │ │ └── ReaderProvider.java │ ├── teleporter │ │ ├── ITeleporterTarget.java │ │ ├── TargetRegistry.java │ │ └── TeleporterTarget.java │ └── tubes │ │ ├── IItemCache.java │ │ ├── ILimiterTube.java │ │ ├── IProviderTube.java │ │ ├── IRequestTube.java │ │ ├── ITube.java │ │ └── TransportedItem.java │ └── util │ ├── DirectionList.java │ ├── IC2DamageSource.java │ ├── ILocation.java │ └── SidedObject.java └── resources └── assets └── ic2 └── lang ├── advancements_en_us.json ├── advancements_ko_kr.json ├── advancements_ru_ru.json ├── advancements_uk_ua.json ├── advancements_zh_cn.json ├── blocks_en_us.json ├── blocks_ko_kr.json ├── blocks_ru_ru.json ├── blocks_uk_ua.json ├── blocks_zh_cn.json ├── crops_en_us.json ├── crops_ko_kr.json ├── crops_ru_ru.json ├── crops_uk_ua.json ├── crops_zh_cn.json ├── en_us.json ├── items_en_us.json ├── items_ko_kr.json ├── items_ru_ru.json ├── items_uk_ua.json ├── items_zh_cn.json ├── ko_kr.json ├── probe_en_us.json ├── probe_ko_kr.json ├── probe_ru_ru.json ├── probe_uk_ua.json ├── probe_zh_cn.json ├── ru_ru.json ├── stats_en_us.json ├── stats_ko_kr.json ├── stats_ru_ru.json ├── stats_uk_ua.json ├── stats_zh_cn.json ├── uk_ua.json ├── wiki_en_us.json ├── wiki_ko_kr.json ├── wiki_ru_ru.json ├── wiki_uk_ua.json ├── wiki_zh_cn.json └── zh_cn.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Disable autocrlf on generated files, they always generate with LF 2 | # Add any extra files or paths here to make git stop saying they 3 | # are changed when only line endings change. 4 | src/generated/**/.cache/cache text eol=lf 5 | src/generated/**/*.json text eol=lf 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | 24 | # Files from Forge MDK 25 | forge*changelog.txt 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### IC2Classic 1.19 API 2 | 3 | Welcome to the 1.19.2 IC2Classic API. 4 | It is sadly right now WIP. 5 | 6 | But it is feature complete. 7 | The only thing missing is the Documentation, which should be done over the next few days. -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs=-Xmx3G 4 | org.gradle.daemon=false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyModularThings/IC2Classic/b0a228712151573a22a78f8cab0016d221fe82f4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | maven { url = 'https://maven.minecraftforge.net/' } 5 | } 6 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/addons/IC2Plugin.java: -------------------------------------------------------------------------------- 1 | package ic2.api.addons; 2 | 3 | import static java.lang.annotation.ElementType.TYPE; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.Target; 8 | 9 | 10 | /** 11 | * 12 | * @author Speiger 13 | * This Annotation is used to load Plugins of IC2Classic. 14 | * Just by having the Annotation added to the class it will automatically be loaded. 15 | * It is expected that {@link IModule} is also implemented by said class. 16 | * Plugins are designed in a way, where they can be turned off by the user in the ic2 config. 17 | * Therefore, the plugin must work as an optional module and should not be required to load. 18 | * Enabling/disabling a module using the config requires a game restart. 19 | * 20 | * Current API Version: 2 21 | */ 22 | @Retention(RUNTIME) 23 | @Target(TYPE) 24 | public @interface IC2Plugin 25 | { 26 | /** @return display Name of the Plugin */ 27 | String name(); 28 | /** @return identifier of the Plugin when it needs to be looked up */ 29 | String id(); 30 | /** @return version of the Plugin */ 31 | String version(); 32 | 33 | /** @return the minimum API version required to run this Plugin. If a plugin requires a newer version then the one provided it won't load. */ 34 | int requiredAPIVersion() default 0; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/addons/IModule.java: -------------------------------------------------------------------------------- 1 | package ic2.api.addons; 2 | 3 | import net.minecraftforge.api.distmarker.Dist; 4 | import net.minecraftforge.eventbus.api.IEventBus; 5 | 6 | /** 7 | * 8 | * @author Speiger 9 | * The Module Interface that is used together with the {@link IC2Plugin} Annotation. 10 | * This Interface is used to load Plugins. 11 | */ 12 | public interface IModule 13 | { 14 | /** @return if the Plugin is able to load. Use this method to check for mod dependencies etc. */ 15 | boolean canLoad(Dist side); 16 | 17 | /** 18 | * Function to load the configs. 19 | * This is called directly after a plugin got loaded, and before the config gets saved. 20 | * IC2Classics internal config system is designed to load configs even if the plugin may not be loaded or if it is loaded late. 21 | * Which Forges Config does no longer support. So when this function is called Configs are accessible to you. 22 | * Note that: This code should only load config specific stuff and not any code that has to do with other mods. 23 | * That should be in {{@link #preInit(IEventBus)}}. 24 | */ 25 | default void loadConfigs(){} 26 | 27 | /** 28 | * Function that loads directly after the config has been saved. 29 | * This is called at the end of IC2Classics preInit phase. 30 | * @param modBus is access to the Mod Specific EventBus of IC2Classic. 31 | */ 32 | default void preInit(IEventBus modBus){} 33 | 34 | /** Called after IC2Classic has finished the FMLCommonSetupEvent */ 35 | default void postInit(){} 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/DyeableMap.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks; 2 | 3 | import java.util.Map; 4 | import java.util.Map.Entry; 5 | 6 | import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; 7 | import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; 8 | import it.unimi.dsi.fastutil.objects.ObjectSet; 9 | import it.unimi.dsi.fastutil.objects.ObjectSets; 10 | import net.minecraft.world.item.DyeColor; 11 | import net.minecraft.world.level.block.Block; 12 | 13 | public class DyeableMap 14 | { 15 | Map blockToColor = new Object2ObjectLinkedOpenHashMap<>(); 16 | Map colorToBlock = new Object2ObjectLinkedOpenHashMap<>(); 17 | ObjectSet blocks = new ObjectLinkedOpenHashSet<>(); 18 | 19 | public void addBlock(Block block, DyeColor color) 20 | { 21 | blocks.add(block); 22 | blockToColor.put(block, color); 23 | colorToBlock.put(color, block); 24 | } 25 | 26 | public void addBlocks(Map maps) 27 | { 28 | blocks.addAll(maps.keySet()); 29 | blockToColor.putAll(maps); 30 | for(Entry entry : maps.entrySet()) 31 | { 32 | colorToBlock.put(entry.getValue(), entry.getKey()); 33 | } 34 | } 35 | 36 | public void addReverseBlocks(Map maps) 37 | { 38 | blocks.addAll(maps.values()); 39 | colorToBlock.putAll(maps); 40 | for(Entry entry : maps.entrySet()) 41 | { 42 | blockToColor.put(entry.getValue(), entry.getKey()); 43 | } 44 | } 45 | 46 | public Block getBlock(DyeColor color) 47 | { 48 | return colorToBlock.get(color); 49 | } 50 | 51 | public Block getBlock(DyeColor color, Block defaultValue) 52 | { 53 | return colorToBlock.getOrDefault(color, defaultValue); 54 | } 55 | 56 | public DyeColor getColor(Block block) 57 | { 58 | return blockToColor.get(block); 59 | } 60 | 61 | public ObjectSet getBlocks() 62 | { 63 | return ObjectSets.unmodifiable(blocks); 64 | } 65 | 66 | public Block[] getBlockArray() 67 | { 68 | return blocks.toArray(Block[]::new); 69 | } 70 | 71 | public boolean contains(Block block) 72 | { 73 | return blocks.contains(block); 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/ExplosionWhitelist.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks; 2 | 3 | import java.util.Set; 4 | 5 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 6 | import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; 7 | import net.minecraft.world.level.block.Block; 8 | 9 | /** 10 | * 11 | * @author Speiger 12 | * This Registry keeps track of blocks that have extremely high explosion resistances. 13 | * Any Block with an explosion Resistance above 3.400 explosion resistance will be automatically trimmed down to 1.6 resistance if not whitelisted. 14 | * This is to ensure nukes do actual damage. 15 | * 16 | * Vanilla Blocks are also nerfed by IC2Classic to be TNT safe but not block entire nukes single-handedly. 17 | */ 18 | public class ExplosionWhitelist 19 | { 20 | static final Set WHITELIST = new ObjectOpenHashSet<>(); 21 | 22 | public static void addWhitelist(Block... blocks) 23 | { 24 | WHITELIST.addAll(ObjectArrayList.wrap(blocks)); 25 | } 26 | 27 | public static void removeWhitelist(Block...blocks) 28 | { 29 | WHITELIST.removeAll(ObjectArrayList.wrap(blocks)); 30 | } 31 | 32 | public static boolean isWhitelisted(Block block) 33 | { 34 | return WHITELIST.contains(block); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/IAdvancedComparable.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.world.level.Level; 6 | import net.minecraft.world.level.block.Block; 7 | import net.minecraft.world.level.block.state.BlockState; 8 | 9 | /** 10 | * 11 | * @author Speiger 12 | * 13 | * This interface is the Support for IC2Classics Advanced Comparator. 14 | * It does support the Vanilla function, and also includes Directional Output which was removed from the Vanilla functionality a few years ago. 15 | * 16 | * This interface exists to reintroduce this feature. 17 | */ 18 | public interface IAdvancedComparable 19 | { 20 | /** 21 | * This function works exactly the same as {@linkplain Block#getAnalogOutputSignal(BlockState, Level, BlockPos)} just adding directional support 22 | * @param state your state 23 | * @param world the block is in 24 | * @param pos the block is at 25 | * @param side the side the comparator comes from 26 | * @return the comparator output. Which is between 0-15 27 | */ 28 | int getComparatorInputOverride(BlockState state, Level world, BlockPos pos, Direction side); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/BaseWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import java.util.List; 4 | 5 | import ic2.api.blocks.IWrenchable; 6 | import it.unimi.dsi.fastutil.objects.ObjectLists; 7 | import net.minecraft.core.BlockPos; 8 | import net.minecraft.core.Direction; 9 | import net.minecraft.server.level.ServerLevel; 10 | import net.minecraft.world.entity.player.Player; 11 | import net.minecraft.world.item.ItemStack; 12 | import net.minecraft.world.level.Level; 13 | import net.minecraft.world.level.block.Block; 14 | import net.minecraft.world.level.block.state.BlockState; 15 | import net.minecraft.world.phys.AABB; 16 | import net.minecraft.world.phys.Vec3; 17 | 18 | public abstract class BaseWrenchHandler implements IWrenchable 19 | { 20 | 21 | @Override 22 | public boolean doSpecialAction(BlockState state, Level world, BlockPos pos, Direction dir, Player player, Vec3 hit) { return false; } 23 | @Override 24 | public AABB hasSpecialAction(BlockState state, Level world, BlockPos pos, Direction dir, Player player, Vec3 hit) { return null; } 25 | @Override 26 | public boolean canRemoveBlock(BlockState state, Level world, BlockPos pos, Player player) { return false; } 27 | @Override 28 | public double getDropRate(BlockState state, Level world, BlockPos pos, Player player) { return 0; } 29 | @Override 30 | public List getDrops(BlockState state, Level world, BlockPos pos, Player player) { 31 | if(!(world instanceof ServerLevel)) return ObjectLists.emptyList(); 32 | return Block.getDrops(state, (ServerLevel)world, pos, null); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/ChestWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.ChestBlock; 9 | import net.minecraft.world.level.block.HorizontalDirectionalBlock; 10 | import net.minecraft.world.level.block.state.BlockState; 11 | import net.minecraft.world.level.block.state.properties.ChestType; 12 | 13 | public class ChestWrenchHandler extends HorizontalWrenchHandler 14 | { 15 | public static final IWrenchable INSTANCE = new ChestWrenchHandler(); 16 | 17 | @Override 18 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 19 | if(state.hasProperty(ChestBlock.TYPE) && state.getValue(ChestBlock.TYPE) != ChestType.SINGLE) return false; 20 | return side.getAxis().isHorizontal() && state.getValue(HorizontalDirectionalBlock.FACING) != side; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/DispenserWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.DispenserBlock; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | 11 | public class DispenserWrenchHandler extends BaseWrenchHandler 12 | { 13 | public static final IWrenchable INSTANCE = new DispenserWrenchHandler(); 14 | 15 | @Override 16 | public Direction getFacing(BlockState state, Level world, BlockPos pos) 17 | { 18 | return state.getValue(DispenserBlock.FACING); 19 | } 20 | 21 | @Override 22 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) 23 | { 24 | return state.getValue(DispenserBlock.FACING) != side; 25 | } 26 | 27 | @Override 28 | public boolean setFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) 29 | { 30 | return world.setBlockAndUpdate(pos, state.setValue(DispenserBlock.FACING, side)); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/HopperWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.HopperBlock; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | 11 | public class HopperWrenchHandler extends BaseWrenchHandler 12 | { 13 | public static final IWrenchable INSTANCE = new HopperWrenchHandler(); 14 | 15 | @Override 16 | public Direction getFacing(BlockState state, Level world, BlockPos pos) 17 | { 18 | return state.getValue(HopperBlock.FACING); 19 | } 20 | 21 | @Override 22 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) 23 | { 24 | return side != Direction.UP && getFacing(state, world, pos) != side; 25 | } 26 | 27 | @Override 28 | public boolean setFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) 29 | { 30 | return side != Direction.UP && world.setBlockAndUpdate(pos, state.setValue(HopperBlock.FACING, side)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/HorizontalWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.HorizontalDirectionalBlock; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | 11 | public class HorizontalWrenchHandler extends BaseWrenchHandler 12 | { 13 | public static final IWrenchable INSTANCE = new HorizontalWrenchHandler(); 14 | 15 | @Override 16 | public Direction getFacing(BlockState state, Level world, BlockPos pos) { 17 | return state.getValue(HorizontalDirectionalBlock.FACING); 18 | } 19 | 20 | @Override 21 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 22 | return side.getAxis().isHorizontal() && state.getValue(HorizontalDirectionalBlock.FACING) != side; 23 | } 24 | 25 | @Override 26 | public boolean setFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 27 | return side.getAxis().isHorizontal() && world.setBlockAndUpdate(pos, state.setValue(HorizontalDirectionalBlock.FACING, side)); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/InvertedHorizontalWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.HorizontalDirectionalBlock; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | 11 | public class InvertedHorizontalWrenchHandler extends HorizontalWrenchHandler 12 | { 13 | public static final IWrenchable INSTANCE = new InvertedHorizontalWrenchHandler(); 14 | 15 | @Override 16 | public Direction getFacing(BlockState state, Level world, BlockPos pos) { 17 | return state.getValue(HorizontalDirectionalBlock.FACING).getOpposite(); 18 | } 19 | 20 | @Override 21 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 22 | return side.getAxis().isHorizontal() && state.getValue(HorizontalDirectionalBlock.FACING).getOpposite() != side; 23 | } 24 | 25 | @Override 26 | public boolean setFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 27 | return side.getAxis().isHorizontal() && world.setBlockAndUpdate(pos, state.setValue(HorizontalDirectionalBlock.FACING, side.getOpposite())); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/ObserverBlockWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.ObserverBlock; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | 11 | public class ObserverBlockWrenchHandler extends BaseWrenchHandler 12 | { 13 | public static final IWrenchable INSTANCE = new ObserverBlockWrenchHandler(); 14 | 15 | @Override 16 | public Direction getFacing(BlockState state, Level world, BlockPos pos) { 17 | return state.getValue(ObserverBlock.FACING); 18 | } 19 | 20 | @Override 21 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 22 | return state.getValue(ObserverBlock.FACING) != side; 23 | } 24 | 25 | @Override 26 | public boolean setFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 27 | return world.setBlockAndUpdate(pos, state.setValue(ObserverBlock.FACING, side)); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/PillarWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.RotatedPillarBlock; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | 11 | public class PillarWrenchHandler extends BaseWrenchHandler 12 | { 13 | public static final IWrenchable INSTANCE = new PillarWrenchHandler(); 14 | 15 | @Override 16 | public Direction getFacing(BlockState state, Level world, BlockPos pos) { 17 | switch(state.getValue(RotatedPillarBlock.AXIS)) 18 | { 19 | case X: return Direction.EAST; 20 | case Y: return Direction.UP; 21 | case Z: return Direction.SOUTH; 22 | default: return null; 23 | } 24 | } 25 | 26 | @Override 27 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 28 | return state.getValue(RotatedPillarBlock.AXIS) != side.getAxis(); 29 | } 30 | 31 | @Override 32 | public boolean setFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 33 | return world.setBlockAndUpdate(pos, state.setValue(RotatedPillarBlock.AXIS, side.getAxis())); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/PistonWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.piston.PistonBaseBlock; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | 11 | public class PistonWrenchHandler extends BaseWrenchHandler 12 | { 13 | public static final IWrenchable INSTANCE = new PistonWrenchHandler(); 14 | 15 | @Override 16 | public Direction getFacing(BlockState state, Level world, BlockPos pos) { 17 | return state.getValue(PistonBaseBlock.FACING); 18 | } 19 | 20 | @Override 21 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 22 | return state.getValue(PistonBaseBlock.FACING) != side && !state.getValue(PistonBaseBlock.EXTENDED); 23 | } 24 | 25 | @Override 26 | public boolean setFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 27 | if(state.getValue(PistonBaseBlock.EXTENDED)) return false; 28 | return world.setBlockAndUpdate(pos, state.setValue(PistonBaseBlock.FACING, side)); 29 | } 30 | @Override 31 | public boolean canRemoveBlock(BlockState state, Level world, BlockPos pos, Player player) { return true; } 32 | @Override 33 | public double getDropRate(BlockState state, Level world, BlockPos pos, Player player) { return 1; } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/blocks/wrench/StairWrenchHandler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.blocks.wrench; 2 | 3 | import ic2.api.blocks.IWrenchable; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.core.Direction; 6 | import net.minecraft.world.entity.player.Player; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.StairBlock; 9 | import net.minecraft.world.level.block.state.BlockState; 10 | import net.minecraft.world.level.block.state.properties.Half; 11 | 12 | public class StairWrenchHandler extends BaseWrenchHandler 13 | { 14 | public static final IWrenchable INSTANCE = new StairWrenchHandler(); 15 | 16 | @Override 17 | public Direction getFacing(BlockState state, Level world, BlockPos pos) { 18 | return state.getValue(StairBlock.FACING).getOpposite(); 19 | } 20 | 21 | @Override 22 | public boolean canSetFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 23 | if(side.getAxis().isVertical()) { 24 | return side == Direction.DOWN ? state.getValue(StairBlock.HALF) == Half.TOP : state.getValue(StairBlock.HALF) == Half.BOTTOM; 25 | } 26 | return state.getValue(StairBlock.FACING).getOpposite() != side; 27 | } 28 | 29 | @Override 30 | public boolean setFacing(BlockState state, Level world, BlockPos pos, Player player, Direction side) { 31 | if(side.getAxis().isVertical()) { 32 | return world.setBlockAndUpdate(pos, state.setValue(StairBlock.HALF, (side == Direction.UP ? Half.TOP : Half.BOTTOM))); 33 | } 34 | return world.setBlockAndUpdate(pos, state.setValue(StairBlock.FACING, side.getOpposite())); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/core/APIHelper.java: -------------------------------------------------------------------------------- 1 | package ic2.api.core; 2 | 3 | import java.util.List; 4 | 5 | import ic2.api.network.INetworkManager; 6 | import ic2.api.ticks.ITickScheduler; 7 | import net.minecraft.world.item.ItemStack; 8 | import net.minecraft.world.level.material.Fluid; 9 | import net.minecraftforge.api.distmarker.Dist; 10 | import net.minecraftforge.fluids.FluidStack; 11 | 12 | public interface APIHelper 13 | { 14 | List getFluidContainers(Fluid fluid); 15 | FluidStack createSteam(int amount); 16 | ITickScheduler getTickHelper(); 17 | INetworkManager getNetworkManager(); 18 | INetworkManager getNetworkManager(Dist side); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/core/IC2Classic.java: -------------------------------------------------------------------------------- 1 | package ic2.api.core; 2 | 3 | import ic2.api.items.armor.IArmorModule.IArmorCapability; 4 | import ic2.api.tiles.INotifiableMachine; 5 | import ic2.api.tiles.tubes.ITube; 6 | import net.minecraftforge.common.capabilities.Capability; 7 | import net.minecraftforge.common.capabilities.CapabilityManager; 8 | import net.minecraftforge.common.capabilities.CapabilityToken; 9 | import net.minecraftforge.fml.ModLoadingContext; 10 | 11 | public class IC2Classic 12 | { 13 | public static final Capability TUBE_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); 14 | public static final Capability NOTIFY_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); 15 | public static final Capability ARMOR_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); 16 | 17 | private static APIHelper HELPER; 18 | 19 | public static APIHelper getHelper() 20 | { 21 | return HELPER; 22 | } 23 | 24 | public static void setHelper(APIHelper helper) 25 | { 26 | if(!ModLoadingContext.get().getActiveNamespace().equalsIgnoreCase("ic2") || HELPER != null) 27 | { 28 | throw new IllegalStateException("IC2 is the only mod that can set these variables"); 29 | } 30 | HELPER = helper; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/crops/BaseSeed.java: -------------------------------------------------------------------------------- 1 | package ic2.api.crops; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | /** 6 | * 7 | * @author Speiger 8 | * 9 | * A Helper class that allows to define a crop with its Stats and required stacksize 10 | * 11 | */ 12 | public class BaseSeed 13 | { 14 | public final ICrop crop; 15 | public int stage; 16 | public int growth; 17 | public int gain; 18 | public int resistance; 19 | public int stack_size; 20 | 21 | public BaseSeed(ICrop crop, int stage, int growth, int gain, int resistance, int stack_size) 22 | { 23 | this.crop = crop; 24 | this.stage = stage; 25 | this.growth = growth; 26 | this.gain = gain; 27 | this.resistance = resistance; 28 | this.stack_size = stack_size; 29 | } 30 | 31 | public BaseSeed(ItemStack stack) 32 | { 33 | ICropSeed seed = (ICropSeed)stack.getItem(); 34 | crop = seed.getCrop(stack); 35 | stage = 1; 36 | growth = seed.getGrowth(stack); 37 | gain = seed.getGain(stack); 38 | resistance = seed.getResistance(stack); 39 | stack_size = 1; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/crops/CropDifficulty.java: -------------------------------------------------------------------------------- 1 | package ic2.api.crops; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.util.Mth; 6 | import net.minecraft.util.RandomSource; 7 | 8 | 9 | /** 10 | * 11 | * @author Speiger 12 | * 13 | * A Helper class that allows to configure calculations based on a difficulty level. 14 | * By default level 2 is the default implementation. 15 | * 16 | */ 17 | public class CropDifficulty 18 | { 19 | int level; 20 | 21 | public CropDifficulty(int level) 22 | { 23 | this.level = level; 24 | } 25 | 26 | public int getWeedChance() 27 | { 28 | switch(level) 29 | { 30 | case 0: return 25; 31 | case 1: return 50; 32 | case 3: return 200; 33 | default: return 100; 34 | } 35 | } 36 | 37 | public int getCropGrowth(int value) 38 | { 39 | switch(level) 40 | { 41 | case 0: return value * 2; 42 | case 1: return (int)(value * 1.3); 43 | case 3: 44 | { 45 | if(value == 0) return 0; 46 | return (int)Math.max(1, value * 0.75); 47 | } 48 | default: return value; 49 | } 50 | } 51 | 52 | public int getBreedingDifficulty() 53 | { 54 | switch(level) 55 | { 56 | case 0: return 10; 57 | case 1: return 6; 58 | case 3: return 2; 59 | default: return 4; 60 | } 61 | } 62 | 63 | public int[] getCropStats(List crops, RandomSource rand) 64 | { 65 | int[] result = new int[3]; 66 | int size = crops.size(); 67 | for(int k = 0;k < size;++k) 68 | { 69 | ICropTile tile = crops.get(k); 70 | result[0] += tile.getGrowthStat(); 71 | result[1] += tile.getResistanceStat(); 72 | result[2] += tile.getGainStat(); 73 | } 74 | 75 | for(int i = 0;i createQuadsForStage(int stage, boolean fancy, FaceBakery baker); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/crops/ICropSeed.java: -------------------------------------------------------------------------------- 1 | package ic2.api.crops; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | /** 6 | * 7 | * @author Speiger 8 | * 9 | * API to the CropSeedItem implementation 10 | */ 11 | public interface ICropSeed 12 | { 13 | /** Cost Values how much each scan tier would cost */ 14 | int[] SCAN_COST = new int[]{10, 90, 900, 9000}; 15 | /** Tier values for each crop tier */ 16 | String[] TIERS = new String[]{"0", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI"}; 17 | 18 | /** 19 | * Get's the Crop in the seed. 20 | * @param stack of the seed 21 | * @return the Crop that is in said item 22 | */ 23 | ICrop getCrop(ItemStack stack); 24 | 25 | /** 26 | * Get's the Scan Level of the seed 27 | * @param stack the seed 28 | * @return the scan level of said seed. 29 | */ 30 | int getScanLevel(ItemStack stack); 31 | 32 | /** 33 | * Set's the Scan Level of the seed 34 | * @param stack the seed 35 | * @param level that it should be set to. 36 | */ 37 | void setScanLevel(ItemStack stack, int level); 38 | 39 | /** 40 | * Increments the Scan Level of the seed 41 | * @param stack the seed itself 42 | */ 43 | default void increaseScanLevel(ItemStack stack) 44 | { 45 | setScanLevel(stack, getScanLevel(stack) + 1); 46 | } 47 | 48 | /** 49 | * Get's the Growth Stat of the Seed 50 | * @param stack the seed 51 | * @return the Growth stat of the Seed. Between 0-31 (inclusive) 52 | */ 53 | int getGrowth(ItemStack stack); 54 | 55 | /** 56 | * Set's the Growth Stat of the Seed 57 | * @param stack the seed 58 | * @param growth what the stat should be. Clamped between 0-31 (inclusive) 59 | */ 60 | void setGrowth(ItemStack stack, int growth); 61 | 62 | /** 63 | * Get's the Gain Stat of the Seed 64 | * @param stack the seed 65 | * @return the Gain stat of the Seed. Between 0-31 (inclusive) 66 | */ 67 | int getGain(ItemStack stack); 68 | 69 | /** 70 | * Set's the Gain Stat of the Seed 71 | * @param stack the seed 72 | * @param gain what the stat should be. Clamped between 0-31 (inclusive) 73 | */ 74 | void setGain(ItemStack stack, int gain); 75 | 76 | /** 77 | * Get's the Resistance Stat of the Seed 78 | * @param stack the seed 79 | * @return the Resistance stat of the Seed. Between 0-31 (inclusive) 80 | */ 81 | int getResistance(ItemStack stack); 82 | 83 | /** 84 | * Set's the Resistance Stat of the Seed 85 | * @param stack the seed 86 | * @param resistance what the stat should be. Clamped between 0-31 (inclusive) 87 | */ 88 | void setResistance(ItemStack stack, int resistance); 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/crops/IFarmland.java: -------------------------------------------------------------------------------- 1 | package ic2.api.crops; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.level.Level; 5 | import net.minecraft.world.level.block.Block; 6 | import net.minecraft.world.level.block.state.BlockState; 7 | 8 | /** 9 | * 10 | * @author Speiger 11 | * 12 | * Farmlands are the Blocks directly underneath the Crop Itself. 13 | * These Provide a rather large boni to the crop they are standing on. 14 | * 15 | * The internal rule of thumb is. 16 | * A Farmland under normal conditions is only allowed to give a +3 to a stat. 17 | * If you want to give more then you have to have down side that ensures a re-balance of a +3 18 | * For example: Soulsand gives a +5 in Nutriens, but a -2 in Humidity. 19 | * 20 | * There is exception to the rule where the block has special conditions that makes the building of said Blocks 21 | * much much harder. Where the area around the Block itself has to maintain also special conditions. 22 | * Normal Vanilla Farmland fulfills said condition. 23 | * 24 | * For that the rule of thumb is that there is a +4 or a +5 total boost if there is a significant building limitation. 25 | */ 26 | public interface IFarmland 27 | { 28 | /** 29 | * Function to give a boni towards the humidity stat. 30 | * This will be capped between 0-20 31 | * @param world the Farmland is in. 32 | * @param pos the Farmland is at. 33 | * @return the humidity Boni. 34 | */ 35 | default int getHumidity(Level world, BlockPos pos) 36 | { 37 | return getHumidity(world.getBlockState(pos)); 38 | } 39 | 40 | /** 41 | * @see IFarmland#getHumidity(Level, BlockPos) 42 | */ 43 | int getHumidity(BlockState state); 44 | 45 | /** 46 | * Function to give a boni towards the nutrient stat. 47 | * This will be capped between 0-20 48 | * @param world the Farmland is in. 49 | * @param pos the Farmland is at. 50 | * @return the nutrient Boni. 51 | */ 52 | default int getNutrients(Level world, BlockPos pos) 53 | { 54 | return getNutrients(world.getBlockState(pos)); 55 | } 56 | 57 | /** 58 | * @see IFarmland#getNutrients(Level, BlockPos) 59 | */ 60 | int getNutrients(BlockState state); 61 | 62 | /** 63 | * If a Farmland has a Special BlockState required to actually apply its effect then return this true. 64 | * The Farmland Block for example uses this. 65 | * @return true if you need a Special BlockState to require its effect to take place 66 | */ 67 | default boolean isSpecial() { return false; } 68 | 69 | /** 70 | * The special State required to make its effect happen. 71 | * This is only used for Tooltips 72 | * @param block that has a Farmland Block. 73 | * @return the BlockState that does the best effect. 74 | */ 75 | default BlockState getSpecialState(Block block) { return block.defaultBlockState(); } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/crops/ISeedCrop.java: -------------------------------------------------------------------------------- 1 | package ic2.api.crops; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | /** 6 | * 7 | * @author Speiger 8 | * 9 | * Helper interface for Crops if they have altering Drops. 10 | * This is in combination to {@link ICropModifier#canChangeSeedMode(ItemStack)} is used for. 11 | * When enabled this interface is usually in play. 12 | * 13 | * This interface is used by ICrop implementation 14 | * 15 | */ 16 | public interface ISeedCrop 17 | { 18 | /** 19 | * Function that defines if this alternative drop function should be called. 20 | * @param tile the crop holder 21 | * @return true if it should use this alternative drop function 22 | */ 23 | boolean isDroppingSeeds(ICropTile tile); 24 | 25 | /** 26 | * Returns a freshly created ItemStack array with all the drops that can come out of the Crop in the seed Mode enabled. 27 | * @param tile the crop holder 28 | * @return a ItemStack array of all the drops. If empty just return a new ItemStack[0]; 29 | */ 30 | ItemStack[] getSeedDrops(ICropTile tile); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/crops/ISubSoil.java: -------------------------------------------------------------------------------- 1 | package ic2.api.crops; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.level.Level; 5 | import net.minecraft.world.level.block.Block; 6 | import net.minecraft.world.level.block.state.BlockState; 7 | 8 | /** 9 | * SubSoils are the 3 Blocks underneath a {@link IFarmland} 10 | * These can give small Boni to the Crop they are underneath. 11 | * 12 | * The internal rule of thumb is. 13 | * A SubSoil under normal conditions is only allowed to give a +2 to a stat. 14 | * If you want to give more then you have to have down side that ensures a re-balance of a +2 15 | * For example: Soulsand gives a +3 in Nutriens, but a -1 in Humidity. 16 | * 17 | * There is exception to the rule where the block has special conditions that makes the building of said Blocks 18 | * much much harder. Where the area around the Block itself has to maintain also special conditions. 19 | * Normal Vanilla Farmland fulfills said condition. 20 | * 21 | * For that the rule of thumb is that there is a +3 or a +4 total boost if there is a significant building limitation. 22 | */ 23 | public interface ISubSoil 24 | { 25 | /** 26 | * Function to give a boni towards the humidity stat. 27 | * This will be capped between 0-20 28 | * @param world the SubSoil is in. 29 | * @param pos the SubSoil is at. 30 | * @return the humidity Boni. 31 | */ 32 | default int getHumidity(Level world, BlockPos pos) 33 | { 34 | return getHumidity(world.getBlockState(pos)); 35 | } 36 | 37 | /** 38 | * @see ISubSoil#getHumidity(Level, BlockPos) 39 | */ 40 | int getHumidity(BlockState state); 41 | 42 | /** 43 | * Function to give a boni towards the nutrient stat. 44 | * This will be capped between 0-20 45 | * @param world the SubSoil is in. 46 | * @param pos the SubSoil is at. 47 | * @return the nutrient Boni. 48 | */ 49 | default int getNutrients(Level world, BlockPos pos) 50 | { 51 | return getNutrients(world.getBlockState(pos)); 52 | } 53 | 54 | /** 55 | * @see ISubSoil#getNutrients(Level, BlockPos) 56 | */ 57 | int getNutrients(BlockState state); 58 | 59 | /** 60 | * If a SubSoil has a Special BlockState required to actually apply its effect then return this true. 61 | * The Farmland Block for example uses this. 62 | * @return true if you need a Special BlockState to require its effect to take place 63 | */ 64 | default boolean isSpecial() { return false; } 65 | 66 | /** 67 | * The special State required to make its effect happen. 68 | * This is only used for Tooltips 69 | * @param block that has a SubSoil Block. 70 | * @return the BlockState that does the best effect. 71 | */ 72 | default BlockState getSpecialState(Block block) { return block.defaultBlockState(); } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/energy/EnergyNet.java: -------------------------------------------------------------------------------- 1 | package ic2.api.energy; 2 | 3 | public class EnergyNet 4 | { 5 | /** 6 | * Right now used but will be moved to a core Class where all registries will be found. 7 | */ 8 | public static IEnergyNet INSTANCE; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/energy/IEnergyNet.java: -------------------------------------------------------------------------------- 1 | package ic2.api.energy; 2 | 3 | import java.util.List; 4 | 5 | import ic2.api.energy.tile.IEnergyTile; 6 | import net.minecraft.core.BlockPos; 7 | import net.minecraft.world.level.Level; 8 | 9 | public interface IEnergyNet 10 | { 11 | IEnergyTile getTile(Level world, BlockPos pos); 12 | 13 | IEnergyTile getSubTile(Level world, BlockPos pos); 14 | GridTile getTiles(Level world, BlockPos pos); 15 | 16 | void addTile(IEnergyTile tile); 17 | void removeTile(IEnergyTile tile); 18 | void updateTile(IEnergyTile tile); 19 | 20 | int getPowerFromTier(int tier); 21 | int getTierFromPower(int power); 22 | String getDisplayTier(int tier); 23 | 24 | TransferStats getStats(IEnergyTile tile); 25 | 26 | List getPacketStats(IEnergyTile tile); 27 | 28 | class GridTile 29 | { 30 | IEnergyTile mainTile; 31 | IEnergyTile subTile; 32 | 33 | public GridTile(IEnergyTile mainTile, IEnergyTile subTile) 34 | { 35 | this.mainTile = mainTile; 36 | this.subTile = subTile; 37 | } 38 | 39 | public IEnergyTile getMainTile() 40 | { 41 | return mainTile; 42 | } 43 | 44 | public IEnergyTile getSubTile() 45 | { 46 | return subTile; 47 | } 48 | 49 | public BlockPos getPos() 50 | { 51 | return subTile.getPosition(); 52 | } 53 | 54 | public Level getWorld() 55 | { 56 | return subTile.getWorldObj(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/energy/PacketStats.java: -------------------------------------------------------------------------------- 1 | package ic2.api.energy; 2 | 3 | import ic2.api.energy.tile.IEnergyTile; 4 | 5 | public class PacketStats 6 | { 7 | final IEnergyTile tile; 8 | final long packets; 9 | final long power; 10 | final boolean accepting; 11 | 12 | public PacketStats(IEnergyTile tile, long packets, long power, boolean accepting) 13 | { 14 | this.tile = tile; 15 | this.packets = packets; 16 | this.power = power; 17 | this.accepting = accepting; 18 | } 19 | 20 | public IEnergyTile getTile() 21 | { 22 | return tile; 23 | } 24 | 25 | public long getPackets() 26 | { 27 | return packets; 28 | } 29 | 30 | public long getPower() 31 | { 32 | return power; 33 | } 34 | 35 | public boolean isAccepting() 36 | { 37 | return accepting; 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/energy/TransferStats.java: -------------------------------------------------------------------------------- 1 | package ic2.api.energy; 2 | 3 | public class TransferStats 4 | { 5 | final long energyIn; 6 | final long energyOut; 7 | final long energyLossIn; 8 | final long energyLossOut; 9 | 10 | public TransferStats(long energyIn, long energyOut, long energyLossIn, long energyLossOut) 11 | { 12 | this.energyIn = energyIn; 13 | this.energyOut = energyOut; 14 | this.energyLossIn = energyLossIn; 15 | this.energyLossOut = energyLossOut; 16 | } 17 | 18 | public long getEnergyIn() 19 | { 20 | return energyIn; 21 | } 22 | 23 | public long getEnergyOut() 24 | { 25 | return energyOut; 26 | } 27 | 28 | public long getEnergyLossIn() 29 | { 30 | return energyLossIn; 31 | } 32 | 33 | public long getEnergyLossOut() 34 | { 35 | return energyLossOut; 36 | } 37 | 38 | @Override 39 | public String toString() 40 | { 41 | return "TransferStats[In="+energyIn+", Out="+energyOut+", LossIn="+energyLossIn+", LossOut="+energyLossOut+"]"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/energy/impl/LinkedSink.java: -------------------------------------------------------------------------------- 1 | package ic2.api.energy.impl; 2 | 3 | import ic2.api.energy.tile.IEnergyAcceptor; 4 | import ic2.api.energy.tile.IEnergyEmitter; 5 | import net.minecraft.core.BlockPos; 6 | import net.minecraft.core.Direction; 7 | import net.minecraft.world.level.Level; 8 | import net.minecraft.world.level.block.entity.BlockEntity; 9 | 10 | public class LinkedSink implements IEnergyAcceptor 11 | { 12 | Level world; 13 | BlockPos pos; 14 | int directions; 15 | 16 | public LinkedSink(Level world, BlockPos pos, Iterable directions) 17 | { 18 | this.world = world; 19 | this.pos = pos; 20 | for(Direction dir : directions) 21 | { 22 | this.directions |= 1 << dir.get3DDataValue(); 23 | } 24 | } 25 | 26 | public LinkedSink(Level world, BlockPos pos, Direction...directions) 27 | { 28 | this.world = world; 29 | this.pos = pos; 30 | for(int i = 0;i directions) 17 | { 18 | this.world = world; 19 | this.pos = pos; 20 | for(Direction dir : directions) 21 | { 22 | this.directions |= 1 << dir.get3DDataValue(); 23 | } 24 | } 25 | 26 | public LinkedSource(Level world, BlockPos pos, Direction...directions) 27 | { 28 | this.world = world; 29 | this.pos = pos; 30 | for(int i = 0;i getTiles(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/events/ArmorSlotEvent.java: -------------------------------------------------------------------------------- 1 | package ic2.api.events; 2 | 3 | import ic2.api.items.armor.IArmorModule.ModuleType; 4 | import it.unimi.dsi.fastutil.objects.Object2IntMap; 5 | import net.minecraft.world.entity.EquipmentSlot; 6 | import net.minecraft.world.item.Item; 7 | import net.minecraftforge.eventbus.api.Event; 8 | 9 | public class ArmorSlotEvent extends Event 10 | { 11 | Item item; 12 | String id; 13 | EquipmentSlot slot; 14 | Object2IntMap slots; 15 | 16 | public ArmorSlotEvent(Item item, String id, EquipmentSlot slot, Object2IntMap slots) 17 | { 18 | this.item = item; 19 | this.id = id; 20 | this.slot = slot; 21 | this.slots = slots; 22 | } 23 | 24 | public Item getItem() 25 | { 26 | return item; 27 | } 28 | 29 | public String getId() 30 | { 31 | return id; 32 | } 33 | 34 | public EquipmentSlot getEquipmentSlot() 35 | { 36 | return slot; 37 | } 38 | 39 | public Object2IntMap getSlots() 40 | { 41 | return slots; 42 | } 43 | 44 | public void addSlots(ModuleType type, int amount) 45 | { 46 | slots.computeInt(type, (T, V) -> Math.min(9, (V == null ? 0 : V) + amount)); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/events/FoamEvent.java: -------------------------------------------------------------------------------- 1 | package ic2.api.events; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.level.LevelAccessor; 5 | import net.minecraft.world.level.block.entity.BlockEntity; 6 | import net.minecraft.world.level.block.state.BlockState; 7 | import net.minecraftforge.event.level.LevelEvent; 8 | import net.minecraftforge.eventbus.api.Cancelable; 9 | 10 | public abstract class FoamEvent extends LevelEvent 11 | { 12 | final BlockPos pos; 13 | public FoamEvent(LevelAccessor world, BlockPos pos) 14 | { 15 | super(world); 16 | this.pos = pos; 17 | } 18 | 19 | public BlockPos getPos() 20 | { 21 | return pos; 22 | } 23 | 24 | public BlockState getState() 25 | { 26 | return getLevel().getBlockState(getPos()); 27 | } 28 | 29 | public BlockEntity getBlockEntity() 30 | { 31 | return getLevel().getBlockEntity(getPos()); 32 | } 33 | 34 | @Cancelable 35 | public static class Check extends FoamEvent 36 | { 37 | TargetType type = TargetType.ANY; 38 | boolean isCustom = false; 39 | 40 | public Check(LevelAccessor world, BlockPos pos) 41 | { 42 | super(world, pos); 43 | } 44 | 45 | public void setCustomTarget(TargetType type) 46 | { 47 | this.type = type; 48 | isCustom = true; 49 | } 50 | 51 | public boolean isCustomPlacement() 52 | { 53 | return isCustom; 54 | } 55 | 56 | public TargetType getType() 57 | { 58 | return type; 59 | } 60 | } 61 | 62 | @Cancelable 63 | public static class Place extends FoamEvent 64 | { 65 | boolean placeFoam = false; 66 | 67 | public Place(LevelAccessor world, BlockPos pos) 68 | { 69 | super(world, pos); 70 | } 71 | 72 | public void requestFoamPlacement() 73 | { 74 | placeFoam = true; 75 | } 76 | 77 | public boolean shouldPlaceFoam() 78 | { 79 | return placeFoam; 80 | } 81 | 82 | } 83 | 84 | public enum TargetType 85 | { 86 | ANY, 87 | SCAFFOLD, 88 | CABLE, 89 | TUBE, 90 | PIPE, 91 | CUSTOM 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/events/ScrapBoxEvent.java: -------------------------------------------------------------------------------- 1 | package ic2.api.events; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.core.BlockSource; 6 | import net.minecraft.world.InteractionHand; 7 | import net.minecraft.world.entity.player.Player; 8 | import net.minecraft.world.item.ItemStack; 9 | import net.minecraftforge.eventbus.api.Event; 10 | 11 | public class ScrapBoxEvent extends Event 12 | { 13 | List drops; 14 | ItemStack scrapBox; 15 | 16 | public ScrapBoxEvent(List drops, ItemStack scrapBox) 17 | { 18 | this.drops = drops; 19 | this.scrapBox = scrapBox; 20 | } 21 | 22 | public List getDrops() 23 | { 24 | return drops; 25 | } 26 | 27 | public ItemStack getScrapBox() 28 | { 29 | return scrapBox; 30 | } 31 | 32 | public static class ScrapBoxPlayerUseEvent extends ScrapBoxEvent 33 | { 34 | Player player; 35 | InteractionHand hand; 36 | 37 | public ScrapBoxPlayerUseEvent(List drops, ItemStack scrapBox, Player player, InteractionHand hand) 38 | { 39 | super(drops, scrapBox); 40 | this.player = player; 41 | this.hand = hand; 42 | } 43 | 44 | public Player getPlayer() 45 | { 46 | return player; 47 | } 48 | 49 | public InteractionHand getHand() 50 | { 51 | return hand; 52 | } 53 | } 54 | 55 | public static class ScrapBoxDispenseEvent extends ScrapBoxEvent 56 | { 57 | BlockSource source; 58 | 59 | public ScrapBoxDispenseEvent(List drops, ItemStack scrapBox, BlockSource source) 60 | { 61 | super(drops, scrapBox); 62 | this.source = source; 63 | } 64 | 65 | public BlockSource getSource() 66 | { 67 | return source; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IAutoEatable.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.world.entity.player.Player; 4 | import net.minecraft.world.item.ItemStack; 5 | import net.minecraft.world.level.Level; 6 | 7 | public interface IAutoEatable 8 | { 9 | public boolean canAutoEat(ItemStack stack); 10 | public int getFoodValue(ItemStack stack); 11 | public ItemStack onEaten(ItemStack stack, Level level, Player player); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IBoxableItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IBoxableItem 6 | { 7 | boolean canStoreIntoBox(ItemStack stack); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/ICoinItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface ICoinItem 6 | { 7 | int getMoneyValue(ItemStack stack); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/ICutterItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.entity.player.Player; 5 | import net.minecraft.world.item.ItemStack; 6 | import net.minecraft.world.level.Level; 7 | 8 | public interface ICutterItem 9 | { 10 | void cutInsulation(Player player, ItemStack stack, Level world, BlockPos pos); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IDisplayProvider.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import ic2.api.tiles.display.IDisplayInfo; 6 | import net.minecraft.world.item.ItemStack; 7 | 8 | public interface IDisplayProvider 9 | { 10 | void provideInfo(ItemStack stack, Consumer infos); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IDrinkContainer.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IDrinkContainer { 6 | public static class BrewType { 7 | public static final int EMPTY = 0; 8 | public static final int BEER = 1; 9 | public static final int RUM = 2; 10 | public static final int WHISKY = 5; 11 | public static final int POTION = 10; 12 | } 13 | 14 | public static class BeerQuality { 15 | public static final int BREW = 0; 16 | public static final int YOUNGSTER = 1; 17 | public static final int BEER = 2; 18 | public static final int ALE = 3; 19 | public static final int DRAGONBLOOD = 4; 20 | public static final int BAD = 5; 21 | } 22 | 23 | public static class BeerAlcoholLevel { 24 | public static final int SOUP = 0; 25 | public static final int ALCFREE = 1; 26 | public static final int WHITE = 2; 27 | public static final int NORMAL = 3; 28 | public static final int DARK = 4; 29 | public static final int FULL = 5; 30 | public static final int BLACK = 6; 31 | } 32 | 33 | public static class BeerSolidRatio { 34 | public static final int WATERY = 0; 35 | public static final int CLEAR = 1; 36 | public static final int LITE = 2; 37 | public static final int NORMAL = 3; 38 | public static final int STRONG = 4; 39 | public static final int THICK = 5; 40 | public static final int STODGE = 6; 41 | } 42 | 43 | public static class WhiskyQuality { 44 | public static final int RAW = 0; 45 | public static final int TEN_YEARS = 1; 46 | public static final int TWELVE_YEARS = 2; 47 | public static final int FIFTEEN_YEARS = 3; 48 | public static final int TWENTY_FIVE_YEARS = 4; 49 | public static final int FIFTY_YEARS = 5; 50 | } 51 | 52 | public static class PotionQuality { 53 | //Submitted by Aziel 54 | public static final int RAW = 0; 55 | public static final int UNREFINED = 1; 56 | public static final int IMPURE = 2; 57 | public static final int REDUCED = 3; 58 | public static final int PURE = 4; 59 | public static final int CONCENTRATED = 5; 60 | public static final int BAD = 6; 61 | } 62 | 63 | int getCapacity(); 64 | 65 | IDrinkableFluid getContent(ItemStack stack); 66 | 67 | boolean hasContent(ItemStack stack); 68 | 69 | ItemStack fillWith(IDrinkableFluid fluid, int amount); 70 | 71 | ItemStack getEmptyContainer(); 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IDrinkableFluid.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; 8 | import net.minecraft.network.chat.Component; 9 | import net.minecraft.resources.ResourceLocation; 10 | import net.minecraft.world.entity.player.Player; 11 | import net.minecraft.world.item.ItemStack; 12 | import net.minecraft.world.level.Level; 13 | 14 | public abstract class IDrinkableFluid 15 | { 16 | public static final Map REGISTRY = new Object2ObjectOpenHashMap<>(); 17 | 18 | final ResourceLocation id; 19 | 20 | public IDrinkableFluid(ResourceLocation id) 21 | { 22 | this.id = id; 23 | if(REGISTRY.put(id, this) != null) 24 | { 25 | throw new IllegalStateException("Duplicated Drinkable Fluids are not allowed"); 26 | } 27 | } 28 | 29 | public abstract boolean drink(ItemStack stack, Level world, Player player); 30 | 31 | public boolean hasSpecialName() 32 | { 33 | return false; 34 | } 35 | 36 | public Component getSpecialName(ItemStack stack) 37 | { 38 | return null; 39 | } 40 | 41 | public List generateSubStates(ItemStack base, boolean textures) 42 | { 43 | return Collections.singletonList(base); 44 | } 45 | 46 | public abstract ResourceLocation getTexture(ItemStack stack, String baseFolder); 47 | 48 | public int getTextureIndex(ItemStack stack) 49 | { 50 | return 0; 51 | } 52 | 53 | public final ResourceLocation getID() 54 | { 55 | return id; 56 | } 57 | 58 | @Override 59 | public final int hashCode() 60 | { 61 | return id.hashCode(); 62 | } 63 | 64 | @Override 65 | public final boolean equals(Object obj) 66 | { 67 | if(obj instanceof IDrinkableFluid) 68 | { 69 | return ((IDrinkableFluid)obj).getID().equals(getID()); 70 | } 71 | return false; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IFoamOverrider.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | public interface IFoamOverrider 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IFuelableItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IFuelableItem 6 | { 7 | ItemStack fill(ItemStack stack, int amount); 8 | 9 | boolean canFuel(ItemStack stack); 10 | 11 | boolean hasFuel(ItemStack stack); 12 | 13 | int getFuel(ItemStack stack, int requested, boolean doDrain); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IRepairable.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | import net.minecraft.world.level.ItemLike; 5 | 6 | public interface IRepairable extends ItemLike 7 | { 8 | boolean repairDamage(ItemStack stack, int amount); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/ITagBlock.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.world.item.ItemStack; 6 | import net.minecraft.world.level.block.Block; 7 | 8 | public interface ITagBlock 9 | { 10 | boolean matches(ItemStack self, Block block); 11 | List getBlocks(ItemStack self); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/ITagItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface ITagItem 6 | { 7 | boolean matches(ItemStack self, ItemStack toCompare); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/ITerraformerBP.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import ic2.api.tiles.ITerraformer; 4 | import net.minecraft.core.BlockPos; 5 | import net.minecraft.world.entity.player.Player; 6 | import net.minecraft.world.item.ItemStack; 7 | import net.minecraft.world.level.Level; 8 | 9 | public interface ITerraformerBP 10 | { 11 | boolean canInsert(ItemStack stack, Player player, Level world, BlockPos pos); 12 | 13 | void onInsert(ItemStack stack, Player player, Level world, BlockPos pos); 14 | 15 | boolean isRandomized(ItemStack stack); 16 | 17 | int getEnergyUsage(ItemStack stack); 18 | 19 | int getRadius(ItemStack stack); 20 | 21 | boolean terraform(ItemStack stack, Level world, BlockPos position, ITerraformer terraformer); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IUpgradeItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import java.util.EnumSet; 4 | import java.util.List; 5 | 6 | import javax.annotation.Nullable; 7 | 8 | import ic2.api.recipes.ingridients.queue.IStackOutput; 9 | import ic2.api.recipes.ingridients.recipes.IRecipeOutput; 10 | import ic2.api.recipes.registries.IMachineRecipeList.RecipeEntry; 11 | import ic2.api.tiles.IMachine; 12 | import net.minecraft.nbt.CompoundTag; 13 | import net.minecraft.world.item.ItemStack; 14 | 15 | public interface IUpgradeItem 16 | { 17 | UpgradeType getType(ItemStack stack); 18 | 19 | EnumSet getFunctions(ItemStack stack); 20 | 21 | void onInstall(ItemStack stack, IMachine machine); 22 | 23 | double getProcessingSpeedMultiplier(ItemStack stack, IMachine machine); 24 | int getExtraProcessingSpeed(ItemStack stack, IMachine machine); 25 | 26 | double getProcessingTimeMultiplier(ItemStack stack, IMachine machine); 27 | int getExtraProcessingTime(ItemStack stack, IMachine machine); 28 | 29 | double getEnergyDemandMultiplier(ItemStack stack, IMachine machine); 30 | int getExtraEnergyDemand(ItemStack stack, IMachine machine); 31 | 32 | double getEnergyStorageMultiplier(ItemStack stack, IMachine machine); 33 | int getExtraEnergyStorage(ItemStack stack, IMachine machine); 34 | 35 | int getExtraTier(ItemStack stack, IMachine machine); 36 | 37 | float getSoundMultiplier(ItemStack stack, IMachine machine); 38 | 39 | boolean useRedstoneInvertion(ItemStack stack, IMachine machine); 40 | 41 | void onTick(ItemStack stack, IMachine machine); 42 | 43 | void onMachineFinishedRecipePre(ItemStack stack, IMachine machine, IRecipeOutput output, CompoundTag recipeFlags); 44 | void onMachineFinishedRecipePost(ItemStack stack, IMachine machine, @Nullable RecipeEntry entry, List drops); 45 | 46 | void onMachineProcessed(ItemStack stack, IMachine machine); 47 | 48 | enum UpgradeType 49 | { 50 | RECIPE_MOD("ProcessingTime", "EnergyDemand", "ProcessingSpeed"), 51 | MACHINE_MOD("EnergyStorage", "ExtraTier"), 52 | REDSTONE_MOD("RedstoneInvertion"), 53 | PROCESSING_MOD, 54 | TRANSPORT_MOD, 55 | AUDIO_MOD, 56 | CUSTOM_MOD; 57 | 58 | String[] names; 59 | UpgradeType(String... names) 60 | { 61 | this.names = names; 62 | } 63 | } 64 | 65 | enum Functions 66 | { 67 | TICK, 68 | RECIPE 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/IWindmillBlade.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | public interface IWindmillBlade 7 | { 8 | int getRadius(ItemStack stack); 9 | float getEffectiveness(ItemStack stack); 10 | ResourceLocation getTexture(ItemStack stack); 11 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/armor/IArmorHud.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.armor; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IArmorHud 6 | { 7 | boolean isHudEnabled(ItemStack stack); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/armor/ICustomArmor.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.armor; 2 | 3 | import net.minecraft.world.damagesource.DamageSource; 4 | import net.minecraft.world.entity.EquipmentSlot; 5 | import net.minecraft.world.entity.LivingEntity; 6 | import net.minecraft.world.item.ItemStack; 7 | 8 | public interface ICustomArmor 9 | { 10 | AbsorptionProperties getProperties(LivingEntity entity, ItemStack armor, DamageSource source, double damage, EquipmentSlot slot); 11 | 12 | void damageArmor(LivingEntity player, ItemStack stack, DamageSource source, int damage, EquipmentSlot slot, DamageType type); 13 | 14 | default boolean canBlockDamageSource(LivingEntity player, ItemStack stack, DamageSource source, EquipmentSlot slot) { 15 | return !source.isBypassArmor(); 16 | } 17 | 18 | enum DamageType 19 | { 20 | MODDED, 21 | VANILLA, 22 | THORNS_SELF 23 | } 24 | 25 | class AbsorptionProperties implements Comparable 26 | { 27 | public int priority; 28 | public int absorbMax; 29 | public double absorbRatio; 30 | public EquipmentSlot slot = null; 31 | 32 | public AbsorptionProperties(int priority, double ratio, int max) 33 | { 34 | this.priority = priority; 35 | absorbMax = max; 36 | absorbRatio = ratio; 37 | } 38 | 39 | private AbsorptionProperties(AbsorptionProperties orig) 40 | { 41 | priority = orig.priority; 42 | absorbMax = orig.absorbMax; 43 | absorbRatio = orig.absorbRatio; 44 | slot = orig.slot; 45 | } 46 | 47 | private int calcMaxAbsorption() 48 | { 49 | return (int)(absorbRatio == 0 ? 0 : absorbMax * 100.0 / absorbRatio); 50 | } 51 | 52 | @Override 53 | public int compareTo(AbsorptionProperties o) 54 | { 55 | if(o.priority != priority) 56 | return o.priority - priority; 57 | return calcMaxAbsorption() - o.calcMaxAbsorption(); 58 | } 59 | 60 | @Override 61 | public String toString() 62 | { 63 | return String.format("%d, %d, %f, %d", priority, absorbMax, absorbRatio, calcMaxAbsorption()); 64 | } 65 | 66 | public AbsorptionProperties copy() 67 | { 68 | return new AbsorptionProperties(this); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/armor/IEnergyShieldArmor.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.armor; 2 | 3 | import net.minecraft.world.entity.EquipmentSlot; 4 | import net.minecraft.world.entity.EquipmentSlot.Type; 5 | import net.minecraft.world.entity.LivingEntity; 6 | import net.minecraft.world.item.ItemStack; 7 | 8 | public interface IEnergyShieldArmor 9 | { 10 | boolean addsShieldEffect(EquipmentSlot type, LivingEntity entity, ItemStack stack); 11 | 12 | boolean isEffectAlwaysOn(EquipmentSlot type, LivingEntity entity, ItemStack stack); 13 | 14 | static boolean addsEnergyShieldEffect(LivingEntity living) 15 | { 16 | if(living == null) return false; 17 | for(EquipmentSlot slot : EquipmentSlot.values()) 18 | { 19 | if(slot.getType() == Type.ARMOR) 20 | { 21 | ItemStack stack = living.getItemBySlot(slot); 22 | if(stack.getItem() instanceof IEnergyShieldArmor && ((IEnergyShieldArmor)stack.getItem()).addsShieldEffect(slot, living, stack)) 23 | { 24 | return true; 25 | } 26 | } 27 | } 28 | return false; 29 | } 30 | 31 | static boolean shouldAlwaysShowEffect(LivingEntity living) 32 | { 33 | if(living == null) return false; 34 | for(EquipmentSlot slot : EquipmentSlot.values()) 35 | { 36 | if(slot.getType() == Type.ARMOR) 37 | { 38 | ItemStack stack = living.getItemBySlot(slot); 39 | if(stack.getItem() instanceof IEnergyShieldArmor && ((IEnergyShieldArmor)stack.getItem()).addsShieldEffect(slot, living, stack)) 40 | { 41 | IEnergyShieldArmor shield = (IEnergyShieldArmor)stack.getItem(); 42 | if(shield.addsShieldEffect(slot, living, stack) && shield.isEffectAlwaysOn(slot, living, stack)) 43 | { 44 | return true; 45 | } 46 | } 47 | } 48 | } 49 | return false; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/armor/IFoamSupplier.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.armor; 2 | 3 | import net.minecraft.world.entity.player.Player; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | public interface IFoamSupplier 7 | { 8 | boolean canProvideFoam(Player player, ItemStack stack, InventoryType inv, int amount); 9 | 10 | void useFoam(Player player, ItemStack stack, int amount); 11 | 12 | int getFreeFoamSpace(ItemStack stack); 13 | 14 | void fillFoam(ItemStack stack, int amount); 15 | 16 | enum InventoryType 17 | { 18 | HOTBAR, 19 | OFFHAND, 20 | ARMOR, 21 | CURIO 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/armor/IMetalArmor.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.armor; 2 | 3 | import net.minecraft.world.entity.EquipmentSlot; 4 | import net.minecraft.world.entity.player.Player; 5 | import net.minecraft.world.item.ItemStack; 6 | 7 | public interface IMetalArmor 8 | { 9 | boolean isMetalArmor(ItemStack stack, Player player, EquipmentSlot targetSlot); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/electric/ICustomElectricItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.electric; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface ICustomElectricItem 6 | { 7 | IElectricItemManager getManager(ItemStack stack); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/electric/IDamagelessElectricItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.electric; 2 | 3 | public interface IDamagelessElectricItem extends IElectricItem 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/electric/IElectricEnchantable.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.electric; 2 | 3 | import net.minecraft.world.InteractionResult; 4 | import net.minecraft.world.item.ItemStack; 5 | import net.minecraft.world.item.enchantment.Enchantment; 6 | import net.minecraft.world.item.enchantment.EnchantmentCategory; 7 | import net.minecraftforge.common.extensions.IForgeItem; 8 | 9 | public interface IElectricEnchantable extends IForgeItem 10 | { 11 | InteractionResult getEnchantmentCompatibility(ItemStack stack, Enchantment ench); 12 | EnchantmentCategory getEnchantmentType(ItemStack stack); 13 | @Override 14 | default boolean isBookEnchantable(ItemStack stack, ItemStack book){return false;} 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/electric/IElectricItem.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.electric; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IElectricItem 6 | { 7 | boolean canProvideEnergy(ItemStack stack); 8 | 9 | int getCapacity(ItemStack stack); 10 | 11 | int getTier(ItemStack stack); 12 | 13 | int getTransferLimit(ItemStack stack); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/electric/IElectricItemManager.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.electric; 2 | 3 | import net.minecraft.network.chat.Component; 4 | import net.minecraft.world.entity.LivingEntity; 5 | import net.minecraft.world.item.ItemStack; 6 | 7 | public interface IElectricItemManager 8 | { 9 | int charge(ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate); 10 | 11 | int discharge(ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); 12 | 13 | int getCharge(ItemStack stack); 14 | 15 | int getCapacity(ItemStack stack); 16 | 17 | boolean canUse(ItemStack stack, int amount); 18 | 19 | boolean use(ItemStack stack, int amount, LivingEntity entity); 20 | 21 | void chargeFromArmor(ItemStack stack, LivingEntity entity); 22 | 23 | int getTier(ItemStack stack); 24 | 25 | int getTransferLimit(ItemStack stack); 26 | 27 | Component getToolTip(ItemStack stack); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/electric/IFluidScanner.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.electric; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.item.ItemStack; 5 | import net.minecraft.world.level.LevelReader; 6 | import net.minecraft.world.level.material.FluidState; 7 | 8 | public interface IFluidScanner 9 | { 10 | int getScanRadius(ItemStack stack, boolean useEnergy); 11 | 12 | default boolean isValuableFluid(ItemStack stack, FluidState state, LevelReader world, BlockPos pos) 13 | { 14 | return isValuableFluid(stack, state); 15 | } 16 | 17 | boolean isValuableFluid(ItemStack stack, FluidState state); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/electric/IMiningDrill.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.electric; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.item.ItemStack; 5 | import net.minecraft.world.level.LevelReader; 6 | import net.minecraft.world.level.block.state.BlockState; 7 | 8 | public interface IMiningDrill 9 | { 10 | boolean canMineBlock(ItemStack drill, BlockState state, LevelReader access, BlockPos pos); 11 | 12 | default int getMiningBoost(ItemStack stack, BlockState state) 13 | { 14 | return 0; 15 | } 16 | 17 | default int getExtraEnergyCost(ItemStack stack) 18 | { 19 | return 0; 20 | } 21 | 22 | boolean canDrillBeUsed(ItemStack stack); 23 | 24 | void onDrillUsed(ItemStack stack); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/electric/IScanner.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.electric; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.item.ItemStack; 5 | import net.minecraft.world.level.LevelReader; 6 | import net.minecraft.world.level.block.state.BlockState; 7 | 8 | public interface IScanner 9 | { 10 | int getScanRadius(ItemStack stack, boolean useEnergy); 11 | 12 | boolean hasScanEffect(ItemStack stack); 13 | 14 | default boolean isOreValuable(ItemStack stack, BlockState state, LevelReader world, BlockPos pos) 15 | { 16 | return getOreValue(stack, state) > 0; 17 | } 18 | 19 | default boolean isOreValuable(ItemStack stack, BlockState state) 20 | { 21 | return getOreValue(stack, state) > 0; 22 | } 23 | 24 | default int getOreValue(ItemStack stack, BlockState state, LevelReader world, BlockPos pos) 25 | { 26 | return getOreValue(stack, state); 27 | } 28 | 29 | int getOreValue(ItemStack stack, BlockState state); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/readers/ICropReader.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.readers; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface ICropReader 6 | { 7 | boolean isCropReader(ItemStack stack); 8 | 9 | static boolean isCropReaderImpl(ItemStack stack) 10 | { 11 | return stack.getItem() instanceof ICropReader && ((ICropReader)stack.getItem()).isCropReader(stack); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/readers/IEUReader.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.readers; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IEUReader 6 | { 7 | boolean isEUReader(ItemStack stack); 8 | 9 | static boolean isEUReaderImpl(ItemStack stack) 10 | { 11 | return stack.getItem() instanceof IEUReader && ((IEUReader)stack.getItem()).isEUReader(stack); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/readers/IThermometer.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.readers; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IThermometer 6 | { 7 | boolean isThermometer(ItemStack stack); 8 | 9 | static boolean isThermometerImpl(ItemStack stack) 10 | { 11 | return stack.getItem() instanceof IThermometer && ((IThermometer)stack.getItem()).isThermometer(stack); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/items/readers/IWrenchTool.java: -------------------------------------------------------------------------------- 1 | package ic2.api.items.readers; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IWrenchTool 6 | { 7 | double getActualLoss(ItemStack stack, double originalLoss); 8 | default boolean shouldRenderOverlay(ItemStack stack) { return true; } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/INetworkManager.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network; 2 | 3 | import java.util.function.Supplier; 4 | 5 | import ic2.api.network.buffer.INetworkDataBuffer; 6 | import ic2.api.network.tile.INetworkFieldProvider; 7 | import ic2.api.network.tile.PacketRange; 8 | import net.minecraft.nbt.CompoundTag; 9 | import net.minecraft.resources.ResourceLocation; 10 | import net.minecraft.world.entity.player.Player; 11 | import net.minecraft.world.item.ItemStack; 12 | import net.minecraft.world.level.block.entity.BlockEntity; 13 | 14 | public interface INetworkManager 15 | { 16 | void registerDataBuffer(ResourceLocation location, Class clz, Supplier creator); 17 | 18 | 19 | // Auto Sync 20 | 21 | void startGuiTracking(BlockEntity tile, Player player); 22 | 23 | void sendInitialGuiData(INetworkFieldProvider tile, Player player); 24 | 25 | void updateGuiData(BlockEntity tile, Player player); 26 | 27 | void updateTileField(BlockEntity tile, String field); 28 | 29 | void updateTileFields(BlockEntity tile, String...fields); 30 | 31 | void updateGuiField(BlockEntity tile, String field); 32 | 33 | void updateGuiFields(BlockEntity tile, String...fields); 34 | 35 | void sendInitialData(INetworkFieldProvider prov, CompoundTag nbt); 36 | 37 | void handleInitialChange(BlockEntity prov, CompoundTag nbt); 38 | 39 | void requestInitialData(INetworkFieldProvider prov); 40 | 41 | // TileEvent 42 | void sendTileEvent(BlockEntity tile, int key, int value, PacketRange target); 43 | 44 | void sendTileDataBufferEvent(BlockEntity tile, String id, INetworkDataBuffer buffer, PacketRange target); 45 | 46 | void sendClientTileEvent(BlockEntity tile, int key, int value); 47 | 48 | void sendClientTileDataBufferEvent(BlockEntity tile, String id, INetworkDataBuffer buffer); 49 | 50 | //ItemEvent 51 | void sendItemEvent(Player player, ItemStack stack, int key, int value); 52 | 53 | void sendItemBuffer(Player player, ItemStack stack, String id, INetworkDataBuffer buffer); 54 | 55 | void sendClientItemEvent(ItemStack stack, int key, int value); 56 | 57 | void sendClientItemBuffer(ItemStack stack, String id, INetworkDataBuffer buffer); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/IPlayerPacket.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network; 2 | 3 | import java.util.Optional; 4 | import java.util.function.Consumer; 5 | 6 | import net.minecraft.world.entity.EquipmentSlot; 7 | import net.minecraft.world.entity.player.Player; 8 | import net.minecraft.world.inventory.AbstractContainerMenu; 9 | import net.minecraft.world.item.ItemStack; 10 | 11 | @SuppressWarnings("unchecked") 12 | public interface IPlayerPacket 13 | { 14 | default T getContainer(Player player, Class clz) 15 | { 16 | return clz.isInstance(player.containerMenu) ? (T)player.containerMenu : null; 17 | } 18 | 19 | default void getContainer(Player player, Class clz, Consumer listener) 20 | { 21 | if(clz.isInstance(player.containerMenu)) 22 | { 23 | listener.accept((T)player.containerMenu); 24 | } 25 | } 26 | 27 | default Optional getOptionalContainer(Player player, Class clz) 28 | { 29 | return clz.isInstance(player.containerMenu) ? Optional.of((T)player.containerMenu) : Optional.empty(); 30 | } 31 | 32 | default ItemStack findPlayerStack(Player player, ItemStack send) 33 | { 34 | for(EquipmentSlot slot : EquipmentSlot.values()) if(ItemStack.matches(send, player.getItemBySlot(slot))) return player.getItemBySlot(slot); 35 | return ItemStack.EMPTY; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/buffer/EmptyDataBuffer.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.buffer; 2 | 3 | public class EmptyDataBuffer implements INetworkDataBuffer 4 | { 5 | public static final EmptyDataBuffer INSTANCE = new EmptyDataBuffer(); 6 | @Override 7 | public void write(IOutputBuffer buffer) {} 8 | @Override 9 | public void read(IInputBuffer buffer) {} 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/buffer/IBitLevelOverride.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.buffer; 2 | 3 | import ic2.api.network.buffer.NetworkInfo.BitLevel; 4 | 5 | public interface IBitLevelOverride 6 | { 7 | BitLevel getOverride(int fieldID, String fieldName); 8 | 9 | boolean hasOverride(int fieldID, String fieldName); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/buffer/IInputBuffer.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.buffer; 2 | 3 | import java.util.UUID; 4 | 5 | import ic2.api.network.buffer.NetworkInfo.BitLevel; 6 | import net.minecraft.core.Registry; 7 | import net.minecraft.nbt.CompoundTag; 8 | import net.minecraft.resources.ResourceKey; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.minecraftforge.fluids.FluidStack; 11 | import net.minecraftforge.registries.IForgeRegistry; 12 | 13 | public interface IInputBuffer 14 | { 15 | boolean readBoolean(); 16 | byte readByte(); 17 | short readShort(); 18 | int readMedium(); 19 | int readInt(); 20 | int readVarInt(); 21 | float readFloat(); 22 | double readDouble(); 23 | long readLong(); 24 | long readData(BitLevel length); 25 | char readChar(); 26 | > T readEnum(Class clz); 27 | 28 | byte[] readBytes(); 29 | String readString(); 30 | 31 | CompoundTag readNBTData(); 32 | 33 | T readForgeRegistryEntry(IForgeRegistry registry); 34 | ItemStack readItemStack(); 35 | FluidStack readFluidStack(); 36 | UUID readUUID(); 37 | ResourceKey readRegistryKey(ResourceKey> key); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/buffer/INetworkDataBuffer.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.buffer; 2 | 3 | public interface INetworkDataBuffer 4 | { 5 | void write(IOutputBuffer buffer); 6 | 7 | void read(IInputBuffer buffer); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/buffer/IOutputBuffer.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.buffer; 2 | 3 | import java.util.UUID; 4 | 5 | import ic2.api.network.buffer.NetworkInfo.BitLevel; 6 | import net.minecraft.nbt.CompoundTag; 7 | import net.minecraft.resources.ResourceKey; 8 | import net.minecraft.world.item.ItemStack; 9 | import net.minecraftforge.fluids.FluidStack; 10 | import net.minecraftforge.registries.IForgeRegistry; 11 | 12 | public interface IOutputBuffer 13 | { 14 | void writeBoolean(boolean value); 15 | void writeByte(byte value); 16 | void writeShort(short value); 17 | void writeMedium(int value); 18 | void writeInt(int value); 19 | void writeVarInt(int value); 20 | void writeFloat(float value); 21 | void writeDouble(double value); 22 | void writeLong(long value); 23 | void writeData(long value, BitLevel type); 24 | void writeChar(char value); 25 | void writeEnum(Enum value); 26 | 27 | void writeString(String value); 28 | void writeBytes(byte[] value); 29 | 30 | void writeNBTData(CompoundTag value); 31 | 32 | void writeForgeEntry(T value, IForgeRegistry registry); 33 | void writeItemStack(ItemStack stack); 34 | void writeFluidStack(FluidStack stack); 35 | void writeUUID(UUID value); 36 | void writeRegistryKey(ResourceKey key); 37 | static void writeItemStack(ItemStack stack, IOutputBuffer buffer) { 38 | buffer.writeItemStack(stack); 39 | } 40 | static void writeEnum(Enum value, IOutputBuffer buffer) { 41 | buffer.writeEnum(value); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/buffer/NetworkInfo.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.buffer; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 5 | 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.Target; 8 | 9 | @Retention(RUNTIME) 10 | @Target(FIELD) 11 | public @interface NetworkInfo 12 | { 13 | BitLevel value() default BitLevel.BIT_0; 14 | 15 | enum BitLevel 16 | { 17 | BIT_0(0), // IgnoreCase 18 | BIT_8(1), // Byte 19 | BIT_16(2), // Short 20 | BIT_24(3), // Medium 21 | BIT_32(4), // Integer 22 | BIT_40(5), // Integer + Byte 23 | BIT_48(6), // Integer + Short 24 | BIT_56(7), // Integer + Medium 25 | BIT_64(8); // long 26 | 27 | final int index; 28 | final long maxNumber; 29 | public static final BitLevel[] LEVELS; 30 | 31 | BitLevel(int lvl) 32 | { 33 | index = lvl; 34 | maxNumber = (1L << (lvl * 8)); 35 | } 36 | 37 | public int getIndex() 38 | { 39 | return index; 40 | } 41 | 42 | public boolean isSkip() 43 | { 44 | return index == 0; 45 | } 46 | 47 | public boolean isValid(BitLevel limit) 48 | { 49 | if(index == 0) 50 | return false; 51 | else 52 | return index < limit.index; 53 | } 54 | 55 | public long limitNumber(long input) 56 | { 57 | if(index == 0) 58 | return 0; 59 | if(input >= maxNumber) 60 | return maxNumber - 1; 61 | return input; 62 | } 63 | 64 | public static BitLevel getLevel(int index) 65 | { 66 | if(index < 0 || index > 8) 67 | { 68 | return BitLevel.BIT_32; 69 | } 70 | return LEVELS[index]; 71 | } 72 | 73 | static 74 | { 75 | LEVELS = new BitLevel[values().length]; 76 | for(BitLevel level : values()) 77 | { 78 | LEVELS[level.getIndex()] = level; 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/container/IContainerDataEvent.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.container; 2 | 3 | public interface IContainerDataEvent 4 | { 5 | public void onDataReceived(int key, int value); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/item/INetworkItemBufferEvent.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.item; 2 | 3 | import ic2.api.network.IPlayerPacket; 4 | import ic2.api.network.buffer.INetworkDataBuffer; 5 | import net.minecraft.world.entity.player.Player; 6 | import net.minecraft.world.item.ItemStack; 7 | import net.minecraftforge.api.distmarker.Dist; 8 | 9 | public interface INetworkItemBufferEvent extends IPlayerPacket 10 | { 11 | void onDataBufferReceived(ItemStack stack, Player player, String id, T buffer, Dist targetSide); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/item/INetworkItemEvent.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.item; 2 | 3 | import ic2.api.network.IPlayerPacket; 4 | import net.minecraft.world.entity.player.Player; 5 | import net.minecraft.world.item.ItemStack; 6 | import net.minecraftforge.api.distmarker.Dist; 7 | 8 | public interface INetworkItemEvent extends IPlayerPacket 9 | { 10 | void onEventReceived(ItemStack stack, Player player, int key, int value, Dist target); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/tile/INetworkClientEventListener.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.tile; 2 | 3 | import ic2.api.network.IPlayerPacket; 4 | import net.minecraft.world.entity.player.Player; 5 | 6 | public interface INetworkClientEventListener extends IPlayerPacket 7 | { 8 | void onClientDataReceived(Player entity, int key, int value); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/tile/INetworkDataEventListener.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.tile; 2 | 3 | import ic2.api.network.IPlayerPacket; 4 | import ic2.api.network.buffer.INetworkDataBuffer; 5 | import net.minecraft.world.entity.player.Player; 6 | import net.minecraftforge.api.distmarker.Dist; 7 | 8 | public interface INetworkDataEventListener extends IPlayerPacket 9 | { 10 | void onDataBufferReceived(Player player, String id, INetworkDataBuffer data, Dist target); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/tile/INetworkEventListener.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.tile; 2 | 3 | public interface INetworkEventListener 4 | { 5 | void onServerDataReceived(int key, int value); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/tile/INetworkFieldNotifier.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.tile; 2 | 3 | import java.util.Set; 4 | 5 | import ic2.api.network.IPlayerPacket; 6 | import net.minecraft.world.entity.player.Player; 7 | 8 | public interface INetworkFieldNotifier extends IPlayerPacket 9 | { 10 | void onNetworkFieldChanged(Set fields, Player player); 11 | 12 | void onGuiFieldChanged(Set fields, Player player); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/tile/INetworkFieldProvider.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.tile; 2 | 3 | import java.util.List; 4 | 5 | public interface INetworkFieldProvider 6 | { 7 | List getNetworkFields(); 8 | List getGuiFields(); 9 | default boolean isDefaultData(String fieldName) { return false; } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/network/tile/PacketRange.java: -------------------------------------------------------------------------------- 1 | package ic2.api.network.tile; 2 | 3 | public enum PacketRange 4 | { 5 | SHORT_RANGE, 6 | LONG_RANGE, 7 | CHUNK_TRACKED, 8 | ALL_DIM, 9 | ALL_SERVER; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/IChamberReactor.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor; 2 | 3 | public interface IChamberReactor extends IReactor 4 | { 5 | void refreshChambers(); 6 | 7 | int getWidth(); 8 | 9 | int getHeight(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/IReactor.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor; 2 | 3 | import ic2.api.util.ILocation; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | public interface IReactor extends ILocation 7 | { 8 | int getHeat(); 9 | 10 | void setHeat(int newHeat); 11 | 12 | void addHeat(int heat); 13 | 14 | int getMaxHeat(); 15 | 16 | void setMaxHeat(int heat); 17 | 18 | float getHeatEffectModifier(); 19 | 20 | void setHeatEffectModifier(float hem); 21 | 22 | double getEnergyOutput(); 23 | 24 | void addOutput(float output); 25 | 26 | ItemStack getStackInReactor(int x, int y); 27 | 28 | void setStackInReactor(int x, int y, ItemStack stack); 29 | 30 | void explode(); 31 | 32 | int getTickRate(); 33 | 34 | boolean isProducingEnergy(); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/IReactorChamber.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor; 2 | 3 | public interface IReactorChamber 4 | { 5 | IReactor getReactor(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/IReactorComponent.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IReactorComponent extends IReactorProduct 6 | { 7 | @Override 8 | default boolean isValidForReactor(ItemStack stack, IReactor reactor) 9 | { 10 | return true; 11 | } 12 | 13 | void processChamber(ItemStack stack, IReactor reactor, int x, int y, boolean heatCalculation, boolean damageTick); 14 | 15 | boolean acceptUraniumPulse(ItemStack stack, IReactor reactor, ItemStack source, int myX, int myY, int sourceX, int sourceY, boolean heatRun, boolean damageTick); 16 | 17 | boolean canStoreHeat(ItemStack stack, IReactor reactor, int x, int y); 18 | 19 | int getStoredHeat(ItemStack stack, IReactor reactor, int x, int y); 20 | 21 | int getMaxStoredHeat(ItemStack stack, IReactor reactor, int x, int y); 22 | 23 | int storeHeat(ItemStack stack, IReactor reactor, int x, int y, int heatChange); 24 | 25 | float getExplosionInfluence(ItemStack stack, IReactor reactor); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/IReactorProduct.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IReactorProduct 6 | { 7 | boolean isValidForReactor(ItemStack stack, IReactor reactor); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/ISteamReactor.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor; 2 | 3 | import net.minecraftforge.fluids.capability.templates.FluidTank; 4 | 5 | public interface ISteamReactor extends IReactor 6 | { 7 | FluidTank getWaterTank(); 8 | 9 | FluidTank getSteamTank(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/ISteamReactorChamber.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor; 2 | 3 | public interface ISteamReactorChamber extends IReactorChamber 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/IUsableUranium.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IUsableUranium 6 | { 7 | ItemStack createDepletedUraniumRod(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/planner/BaseDurabilitySimulatedStack.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor.planner; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public abstract class BaseDurabilitySimulatedStack implements SimulatedStack 6 | { 7 | protected int maxDamage; 8 | protected int damage; 9 | protected short id; 10 | 11 | public BaseDurabilitySimulatedStack(short id, int maxDamage) 12 | { 13 | this.id = id; 14 | this.maxDamage = maxDamage; 15 | } 16 | 17 | @Override 18 | public CompoundTag save() { 19 | CompoundTag data = new CompoundTag(); 20 | data.putInt("damage", damage); 21 | return data; 22 | } 23 | 24 | @Override 25 | public void load(CompoundTag data) { 26 | damage = data.getInt("damage"); 27 | } 28 | 29 | @Override 30 | public void commitState() { 31 | } 32 | 33 | @Override 34 | public void reset() { 35 | damage = 0; 36 | } 37 | 38 | @Override 39 | public boolean acceptUraniumPulse(ISimulatedReactor reactor, int x, int y, SimulatedStack source, int sourceX, int sourceY, boolean heatRun, boolean damageTick) { return false; } 40 | @Override 41 | public boolean canStoreHeat(ISimulatedReactor reactor, int x, int y) { return false; } 42 | @Override 43 | public int getStoredHeat(ISimulatedReactor reactor, int x, int y) { return 0; } 44 | @Override 45 | public int getMaxStoredHeat(ISimulatedReactor reactor, int x, int y) { return 0; } 46 | @Override 47 | public int storeHeat(ISimulatedReactor reactor, int x, int y, int heatChange) { return heatChange; } 48 | 49 | @Override 50 | public boolean canViewHeat(ISimulatedReactor reactor, int x, int y) { return true; } 51 | @Override 52 | public float getExplosionInfluence(ISimulatedReactor reactor) { return 0F; } 53 | @Override 54 | public short getId() { return id; } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/planner/BaseHeatSimulatedStack.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor.planner; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public abstract class BaseHeatSimulatedStack implements SimulatedStack 6 | { 7 | protected int maxHeat; 8 | protected int heat; 9 | protected short id; 10 | protected Tracker heatChanges = new Tracker(); 11 | 12 | public BaseHeatSimulatedStack(short id, int maxHeat) 13 | { 14 | this.id = id; 15 | this.maxHeat = maxHeat; 16 | } 17 | 18 | @Override 19 | public CompoundTag save() { 20 | CompoundTag data = new CompoundTag(); 21 | data.putInt("heat", heat); 22 | heatChanges.save(data); 23 | return data; 24 | } 25 | 26 | @Override 27 | public void load(CompoundTag data) { 28 | heat = data.getInt("heat"); 29 | heatChanges.load(data); 30 | } 31 | 32 | @Override 33 | public void commitState() { 34 | heatChanges.commit(); 35 | } 36 | 37 | @Override 38 | public void reset() { 39 | heatChanges.reset(); 40 | heat = 0; 41 | } 42 | 43 | @Override 44 | public boolean acceptUraniumPulse(ISimulatedReactor reactor, int x, int y, SimulatedStack source, int sourceX, int sourceY, boolean heatRun, boolean damageTick) { return false; } 45 | @Override 46 | public boolean canStoreHeat(ISimulatedReactor reactor, int x, int y) { return true; } 47 | @Override 48 | public int getStoredHeat(ISimulatedReactor reactor, int x, int y) { return heat; } 49 | @Override 50 | public int getMaxStoredHeat(ISimulatedReactor reactor, int x, int y) { return maxHeat; } 51 | @Override 52 | public int storeHeat(ISimulatedReactor reactor, int x, int y, int heatChange) { 53 | heatChanges.addChange(heatChange); 54 | heat += heatChange; 55 | if (heat > maxHeat) { 56 | reactor.markBroken(x, y); 57 | heatChange = maxHeat - heat + 1; 58 | } 59 | else { 60 | if(heat < 0) { 61 | heatChange = heat; 62 | heat = 0; 63 | } 64 | else heatChange = 0; 65 | } 66 | return heatChange; 67 | } 68 | 69 | @Override 70 | public boolean canViewHeat(ISimulatedReactor reactor, int x, int y) { return true; } 71 | @Override 72 | public float getExplosionInfluence(ISimulatedReactor reactor) { return 0F; } 73 | @Override 74 | public short getId() { return id; } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/planner/FloatTracker.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor.planner; 2 | 3 | public class FloatTracker 4 | { 5 | private float total = 0; 6 | private int count = 0; 7 | private float change = 0; 8 | 9 | public void addChange(float value) { 10 | this.change += value; 11 | } 12 | 13 | public void commit() { 14 | total += change; 15 | change = 0; 16 | count++; 17 | } 18 | 19 | public void reset() { 20 | total = 0F; 21 | count = 0; 22 | change = 0F; 23 | } 24 | 25 | public float getAverage() { 26 | return count == 0 ? 0F : total / count; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/planner/ISimulatedReactor.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor.planner; 2 | 3 | public interface ISimulatedReactor 4 | { 5 | public SimulatedStack getItem(int x, int y); 6 | public void markBroken(int x, int y); 7 | public void addBreedingPulse(); 8 | public void addFuelPulse(); 9 | 10 | public int getHeat(); 11 | public void setHeat(int newHeat); 12 | public void addHeat(int heat); 13 | 14 | public int getMaxHeat(); 15 | public void setMaxHeat(int heat); 16 | 17 | public float getHeatEffectModifier(); 18 | public void setHeatEffectModifier(float hem); 19 | 20 | public void addOutput(float output); 21 | public float getEnergyOutput(); 22 | public void addSteam(int amount); 23 | public int consumeWater(int amount); 24 | 25 | public boolean isProducingEnergy(); 26 | public boolean isSteamReactor(); 27 | public boolean isSimulatingPulses(); 28 | 29 | public long getGameTime(); 30 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/planner/SimulatedStack.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor.planner; 2 | 3 | import java.util.List; 4 | 5 | import ic2.api.reactor.IReactorPlannerComponent.ComponentType; 6 | import ic2.api.reactor.IReactorPlannerComponent.ReactorStat; 7 | import ic2.api.reactor.IReactorPlannerComponent.ReactorType; 8 | import net.minecraft.nbt.CompoundTag; 9 | import net.minecraft.nbt.IntTag; 10 | import net.minecraft.nbt.NumericTag; 11 | import net.minecraft.world.item.ItemStack; 12 | 13 | public interface SimulatedStack 14 | { 15 | NumericTag NULL_VALUE = IntTag.valueOf(0); 16 | 17 | public ItemStack syncStack(ItemStack original); 18 | public CompoundTag save(); 19 | public void load(CompoundTag data); 20 | public void commitState(); 21 | public void reset(); 22 | 23 | public void simulate(ISimulatedReactor reactor, int x, int y, boolean heatTick, boolean damageTick); 24 | public boolean acceptUraniumPulse(ISimulatedReactor reactor, int x, int y, SimulatedStack source, int sourceX, int sourceY, boolean heatRun, boolean damageTick); 25 | public boolean canStoreHeat(ISimulatedReactor reactor, int x, int y); 26 | public int getStoredHeat(ISimulatedReactor reactor, int x, int y); 27 | public int getMaxStoredHeat(ISimulatedReactor reactor, int x, int y); 28 | public int storeHeat(ISimulatedReactor reactor, int x, int y, int heatChange); 29 | public boolean canViewHeat(ISimulatedReactor reactor, int x, int y); 30 | public float getExplosionInfluence(ISimulatedReactor reactor); 31 | 32 | public short getId(); 33 | public List getStats(); 34 | public ReactorType getValidType(); 35 | public ComponentType getComponentType(); 36 | public NumericTag getStat(ReactorStat stat); 37 | public default NumericTag getStat(ReactorStat stat, ISimulatedReactor reactor, int x, int y) { return getStat(stat); } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/reactor/planner/Tracker.java: -------------------------------------------------------------------------------- 1 | package ic2.api.reactor.planner; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public class Tracker 6 | { 7 | private int total = 0; 8 | private int count = 0; 9 | private int change = 0; 10 | 11 | public CompoundTag save(CompoundTag tag) 12 | { 13 | tag.putInt("total", total); 14 | tag.putInt("count", count); 15 | tag.putInt("change", change); 16 | return tag; 17 | } 18 | 19 | public void load(CompoundTag tag) 20 | { 21 | total = tag.getInt("total"); 22 | count = tag.getInt("count"); 23 | change = tag.getInt("change"); 24 | } 25 | 26 | public void addChange(int value) { 27 | this.change += value; 28 | } 29 | 30 | public void commit() { 31 | total += change; 32 | change = 0; 33 | count++; 34 | } 35 | 36 | public void reset() { 37 | total = 0; 38 | count = 0; 39 | change = 0; 40 | } 41 | 42 | public float getAverage() { 43 | return count == 0 ? 0F : (float)total / (float)count; 44 | } 45 | 46 | public int getCount() { 47 | return count; 48 | } 49 | 50 | public int getTotal() { 51 | return total; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/RecipeRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes; 2 | 3 | import ic2.api.recipes.registries.IAdvancedCraftingManager; 4 | import ic2.api.recipes.registries.ICannerRecipeRegistry; 5 | import ic2.api.recipes.registries.IElectrolyzerRecipeList; 6 | import ic2.api.recipes.registries.IFluidFuelRegistry; 7 | import ic2.api.recipes.registries.IFoodCanRegistry; 8 | import ic2.api.recipes.registries.IFusionRecipeList; 9 | import ic2.api.recipes.registries.IIngredientRegistry; 10 | import ic2.api.recipes.registries.IMachineRecipeList; 11 | import ic2.api.recipes.registries.IPotionBrewRegistry; 12 | import ic2.api.recipes.registries.IRareEarthRegistry; 13 | import ic2.api.recipes.registries.IRecyclerRecipeList; 14 | import ic2.api.recipes.registries.IScrapBoxRegistry; 15 | import ic2.api.recipes.registries.IUUMatterRegistry; 16 | import ic2.api.util.SidedObject; 17 | 18 | public final class RecipeRegistry 19 | { 20 | public static IIngredientRegistry INGREDIENTS; 21 | public static IAdvancedCraftingManager CRAFTING; 22 | public static final SidedObject UU_SHAPES = new SidedObject<>(); 23 | 24 | public static final SidedObject FURNACE = new SidedObject<>(); //Read Only 25 | public static final SidedObject BLAST_FURNACE = new SidedObject<>(); //Read Only 26 | public static final SidedObject SMOKER = new SidedObject<>(); //Read Only 27 | public static final SidedObject MACERATOR = new SidedObject<>(); 28 | public static final SidedObject EXTRACTOR = new SidedObject<>(); 29 | public static final SidedObject COMPRESSOR = new SidedObject<>(); 30 | public static final SidedObject RECYCLER = new SidedObject<>(); 31 | public static final SidedObject SAWMILL = new SidedObject<>(); 32 | public static final SidedObject RARE_EARTH = new SidedObject<>(); 33 | public static final SidedObject CANNER = new SidedObject<>(); 34 | public static final SidedObject ELECTROLYZER = new SidedObject<>(); 35 | public static final SidedObject MIXING_FURNACE = new SidedObject<>(); 36 | public static final SidedObject SCRAP_BOX = new SidedObject<>(); 37 | public static final SidedObject MASS_FABRICATOR = new SidedObject<>(); 38 | 39 | public static IFoodCanRegistry CAN_EFFECTS; 40 | public static final SidedObject POTION_BREWING = new SidedObject<>(); 41 | public static final SidedObject FLUID_FUELS = new SidedObject<>(); 42 | public static final SidedObject FUSION_REACTOR = new SidedObject<>(); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/generators/EmptyGenerator.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.generators; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import net.minecraft.world.item.ItemStack; 8 | 9 | public class EmptyGenerator implements IOutputGenerator { 10 | public static final IOutputGenerator EMPTY = new EmptyGenerator(); 11 | 12 | 13 | public EmptyGenerator() {} 14 | public EmptyGenerator(JsonObject obj) {} 15 | 16 | @Override 17 | public void addItems(Consumer output) { 18 | output.accept(ItemStack.EMPTY); 19 | } 20 | 21 | @Override 22 | public JsonObject serialize() { 23 | return new JsonObject(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/generators/IOutputGenerator.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.generators; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import net.minecraft.world.item.ItemStack; 8 | 9 | public interface IOutputGenerator { 10 | public void addItems(Consumer output); 11 | 12 | public JsonObject serialize(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/generators/ItemGenerator.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.generators; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import net.minecraft.resources.ResourceLocation; 8 | import net.minecraft.world.item.Item; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.minecraft.world.level.ItemLike; 11 | import net.minecraftforge.registries.ForgeRegistries; 12 | 13 | public class ItemGenerator implements IOutputGenerator { 14 | 15 | Item item; 16 | int count; 17 | 18 | public ItemGenerator(JsonObject obj) { 19 | this(ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(obj.get("item").getAsString())), obj.get("size").getAsInt()); 20 | } 21 | 22 | public ItemGenerator(ItemLike item) { 23 | this(item, 1); 24 | } 25 | 26 | public ItemGenerator(ItemLike item, int count) { 27 | this.item = item.asItem(); 28 | this.count = count; 29 | } 30 | 31 | @Override 32 | public void addItems(Consumer output) { 33 | output.accept(new ItemStack(item, count)); 34 | } 35 | 36 | @Override 37 | public JsonObject serialize() { 38 | JsonObject obj = new JsonObject(); 39 | obj.addProperty("item", ForgeRegistries.ITEMS.getKey(item).toString()); 40 | obj.addProperty("size", count); 41 | return obj; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/generators/ItemWithNBTGenerator.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.generators; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import ic2.api.recipes.ingridients.inputs.IInput; 8 | import net.minecraft.world.item.ItemStack; 9 | import net.minecraftforge.common.crafting.CraftingHelper; 10 | 11 | public class ItemWithNBTGenerator implements IOutputGenerator { 12 | ItemStack stack; 13 | int count; 14 | 15 | public ItemWithNBTGenerator(JsonObject obj) { 16 | this(CraftingHelper.getItemStack(obj, true), obj.get("size").getAsInt()); 17 | } 18 | 19 | public ItemWithNBTGenerator(ItemStack stack) { 20 | this(stack, stack.getCount()); 21 | } 22 | 23 | public ItemWithNBTGenerator(ItemStack stack, int count) { 24 | this.stack = stack; 25 | this.count = count; 26 | } 27 | 28 | @Override 29 | public void addItems(Consumer output) { 30 | output.accept(IInput.copyWithSize(stack, count)); 31 | } 32 | 33 | @Override 34 | public JsonObject serialize() { 35 | JsonObject obj = IInput.writeItemStack(stack, false); 36 | obj.addProperty("size", count); 37 | return obj; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/inputs/EmptyInput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.inputs; 2 | 3 | import java.util.List; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import it.unimi.dsi.fastutil.objects.ObjectLists; 8 | import net.minecraft.network.FriendlyByteBuf; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.minecraft.world.item.crafting.Ingredient; 11 | 12 | public class EmptyInput implements IInput 13 | { 14 | public static final IInput INSTANCE = new EmptyInput(); 15 | 16 | private EmptyInput() {} 17 | @Override 18 | public List getComponents() { return ObjectLists.singleton(ItemStack.EMPTY); } 19 | @Override 20 | public Ingredient asIngredient() { return Ingredient.EMPTY; } 21 | @Override 22 | public int getInputSize() { return 0; } 23 | @Override 24 | public boolean matches(ItemStack stack) { return stack.isEmpty(); } 25 | @Override 26 | public void serialize(FriendlyByteBuf buffer) {} 27 | @Override 28 | public JsonObject serialize() { return new JsonObject(); } 29 | 30 | public static class InternalInput extends EmptyInput 31 | { 32 | public static final IInput INSTANCE = new InternalInput(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/inputs/INullableInput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.inputs; 2 | 3 | import com.google.gson.JsonObject; 4 | 5 | public interface INullableInput extends IInput 6 | { 7 | @Override 8 | default JsonObject serialize() { return new JsonObject(); } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/inputs/IngredientInput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.inputs; 2 | 3 | import java.util.List; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 8 | import net.minecraft.network.FriendlyByteBuf; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.minecraft.world.item.crafting.Ingredient; 11 | 12 | public class IngredientInput implements IInput 13 | { 14 | Ingredient entry; 15 | int size; 16 | 17 | public IngredientInput(JsonObject obj) 18 | { 19 | this(Ingredient.fromJson(obj.get("ingredient")), obj.get("size").getAsInt()); 20 | } 21 | 22 | public IngredientInput(FriendlyByteBuf buffer) 23 | { 24 | entry = Ingredient.fromNetwork(buffer); 25 | size = buffer.readByte(); 26 | } 27 | 28 | public IngredientInput(Ingredient entry, int size) 29 | { 30 | this.entry = entry; 31 | this.size = size; 32 | } 33 | 34 | @Override 35 | public List getComponents() 36 | { 37 | return ObjectArrayList.wrap(entry.getItems()); 38 | } 39 | 40 | @Override 41 | public Ingredient asIngredient() 42 | { 43 | return entry; 44 | } 45 | 46 | @Override 47 | public int getInputSize() 48 | { 49 | return size; 50 | } 51 | 52 | @Override 53 | public boolean matches(ItemStack stack) 54 | { 55 | return entry.test(stack); 56 | } 57 | 58 | @Override 59 | public void serialize(FriendlyByteBuf buffer) 60 | { 61 | entry.toNetwork(buffer); 62 | buffer.writeByte(size); 63 | } 64 | 65 | @Override 66 | public JsonObject serialize() 67 | { 68 | JsonObject obj = new JsonObject(); 69 | obj.add("ingredient", entry.toJson()); 70 | obj.addProperty("size", size); 71 | return obj; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/inputs/ItemInput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.inputs; 2 | 3 | import java.util.List; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import it.unimi.dsi.fastutil.objects.ObjectLists; 8 | import net.minecraft.network.FriendlyByteBuf; 9 | import net.minecraft.resources.ResourceLocation; 10 | import net.minecraft.world.item.Item; 11 | import net.minecraft.world.item.ItemStack; 12 | import net.minecraft.world.item.crafting.Ingredient; 13 | import net.minecraft.world.level.ItemLike; 14 | import net.minecraftforge.registries.ForgeRegistries; 15 | 16 | public class ItemInput implements IInput 17 | { 18 | Item item; 19 | int size; 20 | Ingredient ingredient; 21 | 22 | public ItemInput(JsonObject obj) 23 | { 24 | this(ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(obj.get("item").getAsString())), obj.get("size").getAsInt()); 25 | } 26 | 27 | public ItemInput(FriendlyByteBuf buffer) 28 | { 29 | this(Item.byId(buffer.readVarInt()), buffer.readByte()); 30 | } 31 | 32 | public ItemInput(ItemLike prov, int size) 33 | { 34 | this(prov.asItem(), size); 35 | } 36 | 37 | public ItemInput(Item item, int size) 38 | { 39 | this.item = item; 40 | this.size = size; 41 | ingredient = Ingredient.of(new ItemStack(item, size)); 42 | } 43 | 44 | public ItemInput(ItemLike prov) 45 | { 46 | this(prov.asItem()); 47 | } 48 | 49 | public ItemInput(Item item) 50 | { 51 | this(item, 1); 52 | } 53 | 54 | @Override 55 | public Ingredient asIngredient() 56 | { 57 | return ingredient; 58 | } 59 | 60 | @Override 61 | public List getComponents() 62 | { 63 | return ObjectLists.singleton(new ItemStack(item, size)); 64 | } 65 | 66 | @Override 67 | public int getInputSize() 68 | { 69 | return size; 70 | } 71 | 72 | @Override 73 | public boolean matches(ItemStack stack) 74 | { 75 | return stack.getItem() == item; 76 | } 77 | 78 | @Override 79 | public void serialize(FriendlyByteBuf buffer) 80 | { 81 | buffer.writeVarInt(Item.getId(item)); 82 | buffer.writeByte(size); 83 | } 84 | 85 | @Override 86 | public JsonObject serialize() 87 | { 88 | JsonObject obj = new JsonObject(); 89 | obj.addProperty("item", ForgeRegistries.ITEMS.getKey(item).toString()); 90 | obj.addProperty("size", size); 91 | return obj; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/inputs/ItemStackInput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.inputs; 2 | 3 | import java.util.List; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import it.unimi.dsi.fastutil.objects.ObjectLists; 8 | import net.minecraft.network.FriendlyByteBuf; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.minecraftforge.common.crafting.CraftingHelper; 11 | 12 | public class ItemStackInput implements IInput 13 | { 14 | ItemStack input; 15 | int size; 16 | 17 | public ItemStackInput(JsonObject obj) 18 | { 19 | input = CraftingHelper.getItemStack(obj, true); 20 | size = obj.get("size").getAsInt(); 21 | } 22 | 23 | public ItemStackInput(FriendlyByteBuf buffer) 24 | { 25 | input = buffer.readItem(); 26 | size = buffer.readByte(); 27 | } 28 | 29 | public ItemStackInput(ItemStack input, int size) 30 | { 31 | this.input = input.copy(); 32 | this.size = size; 33 | } 34 | 35 | public ItemStackInput(ItemStack input) 36 | { 37 | this(input, input.getCount()); 38 | } 39 | 40 | @Override 41 | public List getComponents() 42 | { 43 | return ObjectLists.singleton(IInput.copyWithSize(input, size)); 44 | } 45 | 46 | @Override 47 | public int getInputSize() 48 | { 49 | return size; 50 | } 51 | 52 | @Override 53 | public boolean matches(ItemStack stack) 54 | { 55 | return IInput.isStackEqual(input, stack); 56 | } 57 | 58 | @Override 59 | public void serialize(FriendlyByteBuf buffer) 60 | { 61 | buffer.writeItem(input); 62 | buffer.writeByte(size); 63 | } 64 | 65 | @Override 66 | public JsonObject serialize() 67 | { 68 | JsonObject obj = IInput.writeItemStack(input, false); 69 | obj.addProperty("size", size); 70 | return obj; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/inputs/ItemTagInput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.inputs; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import com.google.gson.JsonObject; 8 | 9 | import net.minecraft.network.FriendlyByteBuf; 10 | import net.minecraft.resources.ResourceLocation; 11 | import net.minecraft.tags.ItemTags; 12 | import net.minecraft.tags.TagKey; 13 | import net.minecraft.world.item.Item; 14 | import net.minecraft.world.item.ItemStack; 15 | import net.minecraft.world.item.crafting.Ingredient; 16 | import net.minecraftforge.registries.ForgeRegistries; 17 | 18 | public class ItemTagInput implements IInput 19 | { 20 | TagKey tag; 21 | int size; 22 | 23 | public ItemTagInput(JsonObject obj) 24 | { 25 | tag = ItemTags.create(ResourceLocation.tryParse(obj.get("tag").getAsString())); 26 | size = obj.get("size").getAsInt(); 27 | } 28 | 29 | public ItemTagInput(FriendlyByteBuf buffer) 30 | { 31 | tag = ItemTags.create(buffer.readResourceLocation()); 32 | size = buffer.readByte(); 33 | } 34 | 35 | public ItemTagInput(TagKey tag, int size) 36 | { 37 | this.tag = tag; 38 | this.size = size; 39 | } 40 | 41 | public ItemTagInput(TagKey tag) 42 | { 43 | this(tag, 1); 44 | } 45 | 46 | @Override 47 | public List getComponents() 48 | { 49 | List list = new ArrayList<>(); 50 | for(Item item : ForgeRegistries.ITEMS.tags().getTag(tag)) 51 | { 52 | list.add(new ItemStack(item, size)); 53 | } 54 | return Collections.unmodifiableList(list); 55 | } 56 | 57 | @Override 58 | public Ingredient asIngredient() 59 | { 60 | if (size == 1) { 61 | return Ingredient.of(tag); 62 | } else { 63 | return IInput.super.asIngredient(); 64 | } 65 | } 66 | 67 | @Override 68 | public int getInputSize() 69 | { 70 | return size; 71 | } 72 | 73 | @Override 74 | public boolean matches(ItemStack stack) 75 | { 76 | return stack.is(tag); 77 | } 78 | 79 | @Override 80 | public void serialize(FriendlyByteBuf buffer) 81 | { 82 | buffer.writeResourceLocation(tag.location()); 83 | buffer.writeByte(size); 84 | } 85 | 86 | @Override 87 | public JsonObject serialize() 88 | { 89 | JsonObject obj = new JsonObject(); 90 | obj.addProperty("tag", tag.location().toString()); 91 | obj.addProperty("size", size); 92 | return obj; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/inputs/SubItemInput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.inputs; 2 | 3 | import java.util.List; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import net.minecraft.core.NonNullList; 8 | import net.minecraft.network.FriendlyByteBuf; 9 | import net.minecraft.resources.ResourceLocation; 10 | import net.minecraft.world.item.CreativeModeTab; 11 | import net.minecraft.world.item.Item; 12 | import net.minecraft.world.item.ItemStack; 13 | import net.minecraft.world.item.crafting.Ingredient; 14 | import net.minecraft.world.level.ItemLike; 15 | import net.minecraftforge.registries.ForgeRegistries; 16 | 17 | public class SubItemInput implements IInput 18 | { 19 | Item item; 20 | int size; 21 | Ingredient ingredient; 22 | 23 | public SubItemInput(JsonObject obj) 24 | { 25 | this(ForgeRegistries.ITEMS.getValue(ResourceLocation.tryParse(obj.get("item").getAsString())), obj.get("size").getAsInt()); 26 | } 27 | 28 | public SubItemInput(FriendlyByteBuf buffer) 29 | { 30 | this(Item.byId(buffer.readVarInt()), buffer.readByte()); 31 | } 32 | 33 | public SubItemInput(ItemLike prov, int size) 34 | { 35 | this(prov.asItem(), size); 36 | } 37 | 38 | public SubItemInput(Item item, int size) 39 | { 40 | this.item = item; 41 | this.size = size; 42 | NonNullList items = NonNullList.create(); 43 | item.fillItemCategory(CreativeModeTab.TAB_SEARCH, items); 44 | ingredient = Ingredient.of(items.toArray(new ItemStack[items.size()])); 45 | } 46 | 47 | public SubItemInput(ItemLike prov) 48 | { 49 | this(prov.asItem()); 50 | } 51 | 52 | public SubItemInput(Item item) 53 | { 54 | this(item, 1); 55 | } 56 | 57 | @Override 58 | public Ingredient asIngredient() 59 | { 60 | return ingredient; 61 | } 62 | 63 | @Override 64 | public List getComponents() 65 | { 66 | NonNullList items = NonNullList.create(); 67 | item.fillItemCategory(CreativeModeTab.TAB_SEARCH, items); 68 | return items; 69 | } 70 | 71 | @Override 72 | public int getInputSize() 73 | { 74 | return size; 75 | } 76 | 77 | @Override 78 | public boolean matches(ItemStack stack) 79 | { 80 | return stack.getItem() == item; 81 | } 82 | 83 | @Override 84 | public void serialize(FriendlyByteBuf buffer) 85 | { 86 | buffer.writeVarInt(Item.getId(item)); 87 | buffer.writeByte(size); 88 | } 89 | 90 | @Override 91 | public JsonObject serialize() 92 | { 93 | JsonObject obj = new JsonObject(); 94 | obj.addProperty("item", ForgeRegistries.ITEMS.getKey(item).toString()); 95 | obj.addProperty("size", size); 96 | return obj; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/queue/IInputter.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.queue; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IInputter 6 | { 7 | void addItemIntoSlot(int slot, ItemStack stack); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/queue/IStackOutput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.queue; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | public interface IStackOutput 7 | { 8 | boolean addToInventory(IInputter inventory); 9 | 10 | ItemStack getStack(); 11 | 12 | void save(CompoundTag save); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/queue/MultiStackOutput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.queue; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | public class MultiStackOutput implements IStackOutput 7 | { 8 | ItemStack output; 9 | int[] slots; 10 | 11 | public MultiStackOutput(CompoundTag nbt) 12 | { 13 | output = ItemStack.of(nbt.getCompound("stack")); 14 | slots = nbt.getIntArray("slots"); 15 | } 16 | 17 | public MultiStackOutput(ItemStack output, int... slots) 18 | { 19 | this.output = output; 20 | this.slots = slots; 21 | } 22 | 23 | @Override 24 | public boolean addToInventory(IInputter inventory) 25 | { 26 | for(int slot : slots) 27 | { 28 | inventory.addItemIntoSlot(slot, output); 29 | if(output.isEmpty()) 30 | { 31 | return true; 32 | } 33 | } 34 | return false; 35 | } 36 | 37 | @Override 38 | public ItemStack getStack() 39 | { 40 | return output; 41 | } 42 | 43 | @Override 44 | public void save(CompoundTag save) 45 | { 46 | save.putIntArray("slots", slots); 47 | save.put("stack", output.save(new CompoundTag())); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/queue/SimpleStackOutput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.queue; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | public class SimpleStackOutput implements IStackOutput 7 | { 8 | ItemStack output; 9 | int slot; 10 | 11 | public SimpleStackOutput(CompoundTag nbt) 12 | { 13 | output = ItemStack.of(nbt.getCompound("stack")); 14 | slot = nbt.getInt("slot"); 15 | } 16 | 17 | public SimpleStackOutput(ItemStack output, int slot) 18 | { 19 | this.output = output; 20 | this.slot = slot; 21 | } 22 | 23 | @Override 24 | public boolean addToInventory(IInputter inventory) 25 | { 26 | inventory.addItemIntoSlot(slot, output); 27 | return output.isEmpty(); 28 | } 29 | 30 | @Override 31 | public ItemStack getStack() 32 | { 33 | return output; 34 | } 35 | 36 | @Override 37 | public void save(CompoundTag save) 38 | { 39 | save.putByte("slot", (byte)slot); 40 | save.put("stack", output.save(new CompoundTag())); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/recipes/BaseRecipeOutput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.recipes; 2 | 3 | import java.util.List; 4 | 5 | import ic2.api.recipes.ingridients.generators.IOutputGenerator; 6 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 7 | import net.minecraft.world.item.ItemStack; 8 | 9 | public abstract class BaseRecipeOutput implements IRecipeOutput { 10 | protected List generators = new ObjectArrayList<>(); 11 | 12 | protected void handleGenerators(List generators, List outputs) { 13 | this.generators.addAll(generators); 14 | for(IOutputGenerator generator : generators) { 15 | generator.addItems(outputs::add); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/recipes/IFluidRecipeOutput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.recipes; 2 | 3 | import java.util.List; 4 | 5 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 6 | import net.minecraft.nbt.CompoundTag; 7 | import net.minecraft.util.RandomSource; 8 | import net.minecraft.world.item.ItemStack; 9 | import net.minecraftforge.fluids.FluidStack; 10 | 11 | public interface IFluidRecipeOutput extends IRecipeOutput 12 | { 13 | List onFluidRecipeProcessed(RandomSource rand, CompoundTag persistentData, CompoundTag recipeFlags, ItemStack input); 14 | default List onFluidRecipeProcessed(RandomSource rand, CompoundTag persistentData, CompoundTag recipeFlags, ItemStack input, IRecipeOverride overrides) 15 | { 16 | return onFluidRecipeProcessed(rand, persistentData, recipeFlags, input); 17 | } 18 | 19 | List getAllFluidOutputs(); 20 | 21 | static List copyFluids(List copy) 22 | { 23 | List list = new ObjectArrayList<>(); 24 | for(FluidStack stack : copy) 25 | { 26 | list.add(stack.copy()); 27 | } 28 | return list; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/recipes/IRecipeOutput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.recipes; 2 | 3 | import java.util.List; 4 | 5 | import javax.annotation.Nonnull; 6 | 7 | import com.google.gson.JsonObject; 8 | 9 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 10 | import net.minecraft.nbt.CompoundTag; 11 | import net.minecraft.network.FriendlyByteBuf; 12 | import net.minecraft.util.RandomSource; 13 | import net.minecraft.world.item.ItemStack; 14 | 15 | public interface IRecipeOutput 16 | { 17 | CompoundTag EMPTY_COMPOUND = new CompoundTag(); 18 | 19 | List onRecipeProcessed(RandomSource rand, CompoundTag persistentData, CompoundTag recipeFlags); 20 | 21 | default List onRecipeProcessed(RandomSource rand, CompoundTag persistentData, CompoundTag recipeFlags, IRecipeOverride overrides) 22 | { 23 | return onRecipeProcessed(rand, persistentData, recipeFlags); 24 | } 25 | 26 | List getAllOutputs(); 27 | 28 | @Nonnull 29 | CompoundTag getMetadata(); 30 | 31 | float getExperience(); 32 | 33 | void serialize(FriendlyByteBuf buffer); 34 | JsonObject serialize(); 35 | 36 | static List copyItems(List copy) 37 | { 38 | List list = new ObjectArrayList<>(); 39 | for(ItemStack stack : copy) 40 | { 41 | list.add(stack.copy()); 42 | } 43 | return list; 44 | } 45 | 46 | public static interface IRecipeOverride 47 | { 48 | float getChance(float original); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/recipes/IRecipeOutputChance.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.recipes; 2 | 3 | public interface IRecipeOutputChance extends IRecipeOutput { 4 | public float getChance(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/ingridients/recipes/SawMillOutput.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.ingridients.recipes; 2 | 3 | import java.util.List; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import ic2.api.recipes.ingridients.generators.IOutputGenerator; 8 | import net.minecraft.nbt.CompoundTag; 9 | import net.minecraft.network.FriendlyByteBuf; 10 | import net.minecraft.util.RandomSource; 11 | import net.minecraft.world.item.ItemStack; 12 | 13 | public class SawMillOutput extends SimpleRecipeOutput 14 | { 15 | public static final String RECIPE_FLAG = "saw_upgrade"; 16 | 17 | public SawMillOutput(JsonObject obj) 18 | { 19 | super(obj); 20 | } 21 | 22 | public SawMillOutput(FriendlyByteBuf buffer) 23 | { 24 | super(buffer); 25 | } 26 | 27 | public SawMillOutput(List outputs) 28 | { 29 | super(outputs); 30 | } 31 | 32 | public SawMillOutput(List outputs, float xp) 33 | { 34 | super(outputs, xp); 35 | } 36 | 37 | public SawMillOutput(List outputs, CompoundTag nbt, float xp) 38 | { 39 | super(outputs, nbt, xp); 40 | } 41 | 42 | @Override 43 | public List onRecipeProcessed(RandomSource rand, CompoundTag persistentData, CompoundTag recipeFlags) 44 | { 45 | List list = IRecipeOutput.copyItems(outputs); 46 | int effect = recipeFlags.getInt(RECIPE_FLAG); 47 | if(effect != 0) 48 | { 49 | for(int i = 0,m=list.size();i Integer.MAX_VALUE ? Integer.MAX_VALUE : ret)); 24 | } 25 | 26 | public CompoundTag create(CompoundTag compound, double mod, int add) 27 | { 28 | compound.putInt(add_tag, add); 29 | compound.putDouble(mod_tag, mod); 30 | return compound; 31 | } 32 | 33 | public CompoundTag create(double mod, int add) 34 | { 35 | return create(new CompoundTag(), mod, add); 36 | } 37 | 38 | public CompoundTag create(CompoundTag compound, double mod) 39 | { 40 | compound.putDouble(mod_tag, mod); 41 | return compound; 42 | } 43 | 44 | public CompoundTag create(double mod) 45 | { 46 | return create(new CompoundTag(), mod); 47 | } 48 | 49 | public CompoundTag create(CompoundTag compound, int add) 50 | { 51 | compound.putInt(add_tag, add); 52 | return compound; 53 | } 54 | 55 | public CompoundTag create(int add) 56 | { 57 | return create(new CompoundTag(), add); 58 | } 59 | 60 | public static int apply(int min, int base, int extra, double multiplier) 61 | { 62 | long ret = Math.round((base + extra) * multiplier); 63 | return Math.max(min, (int)(ret > Integer.MAX_VALUE ? Integer.MAX_VALUE : ret)); 64 | } 65 | 66 | public static int apply(int base, int extra, double multiplier) 67 | { 68 | long ret = Math.round((base + extra) * multiplier); 69 | return Math.max(1, (int)(ret > Integer.MAX_VALUE ? Integer.MAX_VALUE : ret)); 70 | } 71 | 72 | public static float apply(float min, float base, float extra, double multiplier) 73 | { 74 | double ret = (base + extra) * multiplier; 75 | return Math.max(min, (float)(ret > Integer.MAX_VALUE ? Integer.MAX_VALUE : ret)); 76 | } 77 | 78 | public static float apply(float base, float extra, double multiplier) 79 | { 80 | double ret = (base + extra) * multiplier; 81 | return Math.max(1F, (float)(ret > Integer.MAX_VALUE ? Integer.MAX_VALUE : ret)); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/misc/SimpleCanEffect.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.misc; 2 | 3 | import java.util.Collection; 4 | 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 7 | import net.minecraft.network.chat.Component; 8 | import net.minecraft.resources.ResourceLocation; 9 | import net.minecraft.world.effect.MobEffectInstance; 10 | import net.minecraft.world.entity.player.Player; 11 | import net.minecraft.world.inventory.InventoryMenu; 12 | import net.minecraft.world.item.ItemStack; 13 | import net.minecraftforge.api.distmarker.Dist; 14 | import net.minecraftforge.api.distmarker.OnlyIn; 15 | 16 | public class SimpleCanEffect implements ICanEffect 17 | { 18 | final ResourceLocation id; 19 | final MobEffectInstance[] effects; 20 | Component component = null; 21 | 22 | ResourceLocation texture; 23 | 24 | boolean isRandom = false; 25 | float chance; 26 | 27 | public SimpleCanEffect(ResourceLocation id, Collection effects) 28 | { 29 | this(id, effects.toArray(new MobEffectInstance[effects.size()])); 30 | } 31 | 32 | public SimpleCanEffect(ResourceLocation id, MobEffectInstance... effects) 33 | { 34 | this.id = id; 35 | this.effects = effects; 36 | } 37 | 38 | public SimpleCanEffect setRandom(float chance) 39 | { 40 | this.chance = chance; 41 | isRandom = true; 42 | return this; 43 | } 44 | 45 | /** 46 | * @return the path to the exact texture. 47 | */ 48 | public SimpleCanEffect setTexture(ResourceLocation texture) 49 | { 50 | this.texture = texture; 51 | return this; 52 | } 53 | 54 | public SimpleCanEffect setTooltip(Component component) 55 | { 56 | this.component = component; 57 | return this; 58 | } 59 | 60 | @Override 61 | public void onFoodEaten(ItemStack stack, Player player) 62 | { 63 | if(player.level.isClientSide) 64 | { 65 | return; 66 | } 67 | if((isRandom && player.level.random.nextFloat() >= chance) || effects == null || effects.length == 0) 68 | { 69 | return; 70 | } 71 | for(int i = 0;i < effects.length;i++) 72 | { 73 | if(effects[i] == null) 74 | { 75 | continue; 76 | } 77 | player.addEffect(new MobEffectInstance(effects[i])); 78 | } 79 | } 80 | 81 | @Override 82 | public Component getTooltip() 83 | { 84 | return component; 85 | } 86 | 87 | @Override 88 | @OnlyIn(Dist.CLIENT) 89 | public TextureAtlasSprite getOverrideIcon() 90 | { 91 | return texture == null ? null : Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS).apply(texture); 92 | } 93 | 94 | @Override 95 | public ResourceLocation getID() 96 | { 97 | return id; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IFluidFuelRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.network.FriendlyByteBuf; 6 | import net.minecraft.world.level.material.Fluid; 7 | import net.minecraftforge.registries.ForgeRegistries; 8 | 9 | public interface IFluidFuelRegistry extends IListenableRegistry 10 | { 11 | void addFuel(Fluid fluid, int ticksPerBucket, int euPerTick); 12 | void removeFuel(Fluid fluid); 13 | List getFuels(); 14 | FuelEntry getFuel(Fluid fluid); 15 | 16 | public static class FuelEntry 17 | { 18 | final Fluid fluid; 19 | final int ticksPerBucket; 20 | final int euPerTick; 21 | 22 | public FuelEntry(FriendlyByteBuf buffer) 23 | { 24 | fluid = buffer.readRegistryIdUnsafe(ForgeRegistries.FLUIDS); 25 | ticksPerBucket = buffer.readVarInt(); 26 | euPerTick = buffer.readVarInt(); 27 | } 28 | 29 | public FuelEntry(Fluid fluid, int ticksPerBucket, int euPerTick) 30 | { 31 | this.fluid = fluid; 32 | this.ticksPerBucket = ticksPerBucket; 33 | this.euPerTick = euPerTick; 34 | } 35 | 36 | public Fluid getFluid() 37 | { 38 | return fluid; 39 | } 40 | 41 | public int getTicksPerBucket() 42 | { 43 | return ticksPerBucket; 44 | } 45 | 46 | public int getEuPerTick() 47 | { 48 | return euPerTick; 49 | } 50 | 51 | public void write(FriendlyByteBuf buffer) 52 | { 53 | buffer.writeRegistryIdUnsafe(ForgeRegistries.FLUIDS, fluid); 54 | buffer.writeVarInt(ticksPerBucket); 55 | buffer.writeVarInt(euPerTick); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IFoodCanRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.List; 4 | 5 | import ic2.api.recipes.misc.ICanEffect; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.minecraft.world.item.Item; 8 | import net.minecraft.world.item.ItemStack; 9 | 10 | public interface IFoodCanRegistry 11 | { 12 | Item registerEffect(ICanEffect effect); 13 | 14 | ICanEffect getEffect(ResourceLocation location); 15 | 16 | List getAllEffects(); 17 | 18 | Item getEffectItem(ResourceLocation item); 19 | 20 | void registerItemForEffect(ItemStack stack, ResourceLocation location); 21 | 22 | ResourceLocation getEffectForFood(ItemStack stack); 23 | 24 | default Item getItemForFood(ItemStack food) 25 | { 26 | ResourceLocation location = getEffectForFood(food); 27 | return location == null ? null : getEffectItem(location); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IFusionRecipeList.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.world.item.Item; 6 | 7 | public interface IFusionRecipeList extends IListenableRegistry 8 | { 9 | public void addFuel(Item fuel, int fuelValue, float productionRate, boolean consumed); 10 | 11 | public FusionFuel getFuel(Item item); 12 | public void removeFuel(Item item); 13 | public List getFuels(); 14 | 15 | public static record FusionFuel(Item fuel, int fuelValue, float productionRate, boolean consumed) {} 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IIngredientRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.function.Function; 4 | 5 | import javax.annotation.Nullable; 6 | 7 | import com.google.gson.JsonObject; 8 | 9 | import ic2.api.recipes.ingridients.generators.IOutputGenerator; 10 | import ic2.api.recipes.ingridients.inputs.IInput; 11 | import ic2.api.recipes.ingridients.queue.IStackOutput; 12 | import ic2.api.recipes.ingridients.recipes.IFluidRecipeOutput; 13 | import ic2.api.recipes.ingridients.recipes.IRecipeOutput; 14 | import net.minecraft.nbt.CompoundTag; 15 | import net.minecraft.network.FriendlyByteBuf; 16 | import net.minecraft.resources.ResourceLocation; 17 | 18 | public interface IIngredientRegistry 19 | { 20 | void registerInput(ResourceLocation location, Class clz, Function creator, Function serializer, @Nullable Function maker); 21 | 22 | void registerRecipeOutput(ResourceLocation location, Class clz, Function creator, Function serializer); 23 | void registerFluidOutput(ResourceLocation location, Class clz, Function creator, Function serializer); 24 | 25 | void registerQueue(ResourceLocation location, Class clz, Function creator); 26 | 27 | void registerOutputGenerators(ResourceLocation location, Class clz, Function creator); 28 | 29 | void writeInput(IInput input, FriendlyByteBuf buffer); 30 | void writeRecipeOutput(IRecipeOutput output, FriendlyByteBuf buffer); 31 | void writeFluidOutput(IFluidRecipeOutput output, FriendlyByteBuf buffer); 32 | CompoundTag writeQueue(IStackOutput queue); 33 | 34 | IInput readInput(FriendlyByteBuf buffer); 35 | IRecipeOutput createOutput(FriendlyByteBuf buffer); 36 | IFluidRecipeOutput createFluidOutput(FriendlyByteBuf buffer); 37 | IStackOutput readQueue(CompoundTag nbt); 38 | 39 | IInput readInput(JsonObject obj); 40 | IRecipeOutput readOutput(JsonObject obj); 41 | IFluidRecipeOutput readFluidOutput(JsonObject obj); 42 | IOutputGenerator readOutputGenerator(JsonObject obj); 43 | 44 | IInput createInputFrom(Object obj); 45 | JsonObject serializeInput(IInput input); 46 | JsonObject serializeOutput(IRecipeOutput output); 47 | JsonObject serializeFluidOutput(IFluidRecipeOutput output); 48 | JsonObject serializeOutputGenerator(IOutputGenerator generator); 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IListenableRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.function.Consumer; 4 | 5 | public interface IListenableRegistry> 6 | { 7 | void registerListener(Consumer listener); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IPotionBrewRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import net.minecraft.world.effect.MobEffect; 7 | import net.minecraft.world.item.Item; 8 | import net.minecraft.world.item.Items; 9 | 10 | public interface IPotionBrewRegistry extends IListenableRegistry 11 | { 12 | default void registerBrew(Item item, MobEffect potion){registerBrew(item, null, potion);} 13 | void registerBrew(Item item, MobEffect fromEffect, MobEffect toEffect); 14 | void removeBrew(Item item); 15 | MobEffect getEffect(Item item, MobEffect original); 16 | Map> getEffects(); 17 | List getRequiredItems(MobEffect desiredEffect); 18 | 19 | void registerName(MobEffect effect, String name); 20 | String getName(MobEffect effect); 21 | 22 | void registerPotionContainer(Item input, PotionContainer output); 23 | PotionContainer getPotionContainer(Item input); 24 | Map getContainers(); 25 | 26 | final class PotionContainer 27 | { 28 | final Item output; 29 | final int fluidUsage; 30 | final float durationEffectiveness; 31 | 32 | public PotionContainer(Item output, int fluidUsage, float durationEffectiveness) 33 | { 34 | if(output == Items.AIR || output == null || fluidUsage <= 0 || durationEffectiveness <= 0F) 35 | { 36 | throw new IllegalStateException("Potion Brew Result is invalid"); 37 | } 38 | this.output = output; 39 | this.fluidUsage = fluidUsage; 40 | this.durationEffectiveness = durationEffectiveness; 41 | } 42 | 43 | public float getDurationEffectiveness() 44 | { 45 | return durationEffectiveness; 46 | } 47 | 48 | public int getFluidUsage() 49 | { 50 | return fluidUsage; 51 | } 52 | 53 | public Item getOutput() 54 | { 55 | return output; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IRareEarthRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.resources.ResourceLocation; 6 | import net.minecraft.world.item.ItemStack; 7 | 8 | public interface IRareEarthRegistry extends IListenableRegistry 9 | { 10 | void registerOutput(ResourceLocation id, ItemStack output); 11 | void registerInput(ResourceLocation id, float value, ItemStack... input); 12 | 13 | RareEntry getOutputFor(ItemStack input); 14 | ItemStack getOutputFor(ResourceLocation id); 15 | 16 | RareEntry removeInput(ItemStack input); 17 | void removeOutput(ItemStack output); 18 | void remove(ResourceLocation id); 19 | List getAllRecipes(); 20 | 21 | public static class RareEntry 22 | { 23 | ResourceLocation id; 24 | ItemStack input; 25 | float value; 26 | ItemStack output; 27 | 28 | public RareEntry(ResourceLocation id, ItemStack input, float value, ItemStack output) 29 | { 30 | this.id = id; 31 | this.input = input; 32 | this.value = value; 33 | this.output = output; 34 | } 35 | 36 | public ResourceLocation getID() 37 | { 38 | return id; 39 | } 40 | 41 | public ItemStack getInput() 42 | { 43 | return input; 44 | } 45 | 46 | public ItemStack getOutput() 47 | { 48 | return output; 49 | } 50 | 51 | public float getValue() 52 | { 53 | return value; 54 | } 55 | 56 | public boolean matches(ResourceLocation location) 57 | { 58 | return id.equals(location); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IRecipeFilter.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.List; 4 | 5 | import com.google.gson.JsonObject; 6 | 7 | import ic2.api.recipes.ingridients.inputs.IInput; 8 | import net.minecraft.world.item.ItemStack; 9 | import net.minecraft.world.level.ItemLike; 10 | 11 | public interface IRecipeFilter 12 | { 13 | int SIMPLE = 1; 14 | int FILTER = 2; 15 | int BOTH = SIMPLE | FILTER; 16 | 17 | void add(ItemLike... items); 18 | 19 | void add(IInput... inputs); 20 | 21 | void remove(ItemStack stack, int flags); 22 | 23 | boolean contains(ItemStack stack); 24 | 25 | List getFilteredItems(); 26 | 27 | void clear(); 28 | 29 | JsonObject serialize(); 30 | void read(JsonObject obj); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IRecyclerRecipeList.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | public interface IRecyclerRecipeList extends IMachineRecipeList 4 | { 5 | IRecipeFilter getBlackList(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/recipes/registries/IScrapBoxRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.recipes.registries; 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.world.item.ItemStack; 6 | import net.minecraft.world.level.ItemLike; 7 | 8 | public interface IScrapBoxRegistry extends IListenableRegistry 9 | { 10 | default void addDrop(ItemLike prov, float chance) 11 | { 12 | if(prov == null) 13 | { 14 | return; 15 | } 16 | addDrop(new ItemStack(prov), chance); 17 | } 18 | 19 | void addDrop(ItemStack stack, float chance); 20 | 21 | IDrop getRandomDrop(ItemStack source, boolean consumeItem); 22 | 23 | void removeDrops(ItemStack stack); 24 | 25 | void removeDrop(IDrop drop); 26 | 27 | List getAllDrops(); 28 | 29 | interface IDrop 30 | { 31 | ItemStack getDrop(); 32 | 33 | float getChance(); 34 | 35 | float getPoolChance(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/ticks/ITickScheduler.java: -------------------------------------------------------------------------------- 1 | package ic2.api.ticks; 2 | 3 | import java.util.function.IntSupplier; 4 | import java.util.function.ToIntFunction; 5 | 6 | import net.minecraft.server.MinecraftServer; 7 | import net.minecraft.world.level.Level; 8 | 9 | public interface ITickScheduler 10 | { 11 | void addWorldCallback(Level world, ToIntFunction ticket); 12 | void addWorldCallback(Level world, ToIntFunction ticket, int delay); 13 | void addServerCallback(ToIntFunction ticket); 14 | void addServerCallback(ToIntFunction ticket, int delay); 15 | void addClientCallback(IntSupplier ticket); 16 | void addClientCallback(IntSupplier ticket, int delay); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/ArrayTube.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | import java.util.List; 4 | 5 | import ic2.api.tiles.tubes.ITube; 6 | import ic2.api.tiles.tubes.TransportedItem; 7 | import net.minecraft.core.Direction; 8 | import net.minecraft.world.item.DyeColor; 9 | import net.minecraft.world.item.ItemStack; 10 | 11 | public class ArrayTube implements ITube 12 | { 13 | ITube[] array; 14 | int index; 15 | boolean loop; 16 | 17 | public ArrayTube(List tubes) 18 | { 19 | this(tubes.toArray(new ITube[tubes.size()])); 20 | } 21 | 22 | public ArrayTube(ITube[] array) 23 | { 24 | this(array, true); 25 | } 26 | 27 | public ArrayTube(ITube[] array, boolean loop) 28 | { 29 | this.array = array; 30 | this.loop = loop; 31 | } 32 | 33 | @Override 34 | public TubeType getTubeType() 35 | { 36 | return TubeType.SIMPLE; 37 | } 38 | 39 | @Override 40 | public void addItem(ItemStack item, Direction side, DyeColor color) 41 | { 42 | index = loop ? ++index % array.length : 0; 43 | array[index].addItem(item, side, color); 44 | } 45 | 46 | @Override 47 | public void addItem(TransportedItem item, Direction side) 48 | { 49 | throw new UnsupportedOperationException(); 50 | } 51 | 52 | @Override 53 | public boolean canAddItem(TransportedItem item, Direction side) 54 | { 55 | throw new UnsupportedOperationException(); 56 | } 57 | 58 | @Override 59 | public boolean canConnect(ITube other, Direction dir) 60 | { 61 | throw new UnsupportedOperationException(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/IAnchorTile.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | import net.minecraft.core.Direction; 4 | 5 | public interface IAnchorTile 6 | { 7 | boolean hasAnchor(Direction side); 8 | boolean addAnchor(Direction side); 9 | boolean removeAnchor(Direction side); 10 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/ICopyableSettings.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | import net.minecraft.nbt.CompoundTag; 4 | 5 | public interface ICopyableSettings 6 | { 7 | public void saveSettings(CompoundTag compound); 8 | public void loadSettings(CompoundTag compound); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/IElectrolyzerProvider.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | public interface IElectrolyzerProvider extends IEnergyStorage 4 | { 5 | int getProcessRate(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/IEnergyStorage.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | import ic2.api.tiles.readers.IEUStorage; 4 | 5 | public interface IEnergyStorage extends IEUStorage 6 | { 7 | int addEnergy(int power); 8 | 9 | int drawEnergy(int power); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/IFluidMachine.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | import net.minecraft.core.Direction; 4 | import net.minecraftforge.fluids.capability.IFluidHandler; 5 | 6 | public interface IFluidMachine 7 | { 8 | IFluidHandler getConnectedTank(Direction dir); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/IInputMachine.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | import net.minecraft.world.item.ItemStack; 4 | 5 | public interface IInputMachine 6 | { 7 | int getValidRoom(ItemStack stack); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/IMachine.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | import java.util.EnumSet; 4 | 5 | import ic2.api.items.IUpgradeItem.UpgradeType; 6 | import ic2.api.tiles.tubes.ITube; 7 | import ic2.api.util.ILocation; 8 | import net.minecraft.core.Direction; 9 | import net.minecraftforge.items.IItemHandler; 10 | 11 | public interface IMachine extends ILocation, IInputMachine 12 | { 13 | EnumSet getSupportedUpgradeTypes(); 14 | void onUpgradesChanged(); 15 | 16 | int getAvailableEnergy(); 17 | boolean useEnergy(int toUse, boolean doUse); 18 | 19 | boolean isMachineWorking(); 20 | 21 | void setRedstoneSensitive(boolean flag); 22 | boolean isRedstoneSensitive(); 23 | 24 | IItemHandler getConnectedInventory(Direction dir); 25 | ITube getConnectedTube(Direction dir); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/INotifiableMachine.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | @FunctionalInterface 4 | public interface INotifiableMachine 5 | { 6 | void onNotify(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/IRecipeMachine.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles; 2 | 3 | import ic2.api.recipes.registries.IMachineRecipeList; 4 | 5 | public interface IRecipeMachine extends IInputMachine 6 | { 7 | IMachineRecipeList getRecipeList(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/display/IDisplayInfo.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.display; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | 5 | import ic2.api.tiles.display.IDisplayRegistry.DelegateRegistry; 6 | import net.minecraft.nbt.Tag; 7 | import net.minecraft.network.FriendlyByteBuf; 8 | import net.minecraftforge.api.distmarker.Dist; 9 | import net.minecraftforge.api.distmarker.OnlyIn; 10 | 11 | public interface IDisplayInfo 12 | { 13 | IDisplayRegistry REGISTRY = new DelegateRegistry(); 14 | 15 | @OnlyIn(Dist.CLIENT) 16 | void render(PoseStack stack, int x, int y, int width, int height, Alignment align, IMonitorRenderer helper); 17 | @OnlyIn(Dist.CLIENT) 18 | int getHeight(int width, Alignment align); 19 | 20 | boolean isValid(); 21 | void serialize(FriendlyByteBuf buffer); 22 | 23 | Tag getServerData(); 24 | 25 | public static enum Alignment 26 | { 27 | LEFT, 28 | CENTER, 29 | RIGHT; 30 | 31 | public int getXOffset(int width) 32 | { 33 | return this == Alignment.CENTER ? width >> 1 : (this == Alignment.RIGHT ? width : 0); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/display/IDisplayRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.display; 2 | 3 | import java.util.function.Function; 4 | 5 | import net.minecraft.network.FriendlyByteBuf; 6 | import net.minecraft.resources.ResourceLocation; 7 | 8 | public interface IDisplayRegistry 9 | { 10 | void register(ResourceLocation id, Class info, Function creator); 11 | void serialize(IDisplayInfo info, FriendlyByteBuf buffer); 12 | IDisplayInfo deserialize(FriendlyByteBuf buffer); 13 | 14 | public static class DelegateRegistry implements IDisplayRegistry 15 | { 16 | IDisplayRegistry registry; 17 | 18 | public void setRegistry(IDisplayRegistry registry) 19 | { 20 | this.registry = registry; 21 | } 22 | 23 | @Override 24 | public void register(ResourceLocation id, Class info, Function creator) 25 | { 26 | if(registry == null) throw new UnsupportedOperationException(); 27 | registry.register(id, info, creator); 28 | } 29 | 30 | @Override 31 | public void serialize(IDisplayInfo info, FriendlyByteBuf buffer) 32 | { 33 | if(registry == null) throw new UnsupportedOperationException(); 34 | registry.serialize(info, buffer); 35 | } 36 | 37 | @Override 38 | public IDisplayInfo deserialize(FriendlyByteBuf buffer) 39 | { 40 | if(registry == null) throw new UnsupportedOperationException(); 41 | return registry.deserialize(buffer); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/display/IMonitorRenderer.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.display; 2 | 3 | import com.mojang.blaze3d.vertex.PoseStack; 4 | 5 | import net.minecraft.client.gui.Font; 6 | import net.minecraft.client.renderer.MultiBufferSource; 7 | import net.minecraft.client.renderer.entity.ItemRenderer; 8 | import net.minecraft.world.item.ItemStack; 9 | import net.minecraftforge.api.distmarker.Dist; 10 | import net.minecraftforge.api.distmarker.OnlyIn; 11 | 12 | @OnlyIn(Dist.CLIENT) 13 | public interface IMonitorRenderer 14 | { 15 | public MultiBufferSource.BufferSource getBatcher(); 16 | public Font getFont(); 17 | public ItemRenderer getItemRenderer(); 18 | public void renderGuiItems(PoseStack matrix, ItemStack stack, float x, float y); 19 | public default void renderGuiItemText(PoseStack matrixstack, ItemStack stack, float x, float y, String text) { 20 | renderGuiItemText(matrixstack, getFont(), stack, x, y, text); 21 | } 22 | public void renderGuiItemText(PoseStack matrixstack, Font font, ItemStack stack, float x, float y, String text); 23 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/display/impl/ItemDisplayInfo.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.display.impl; 2 | 3 | import java.util.function.BooleanSupplier; 4 | import java.util.function.Supplier; 5 | 6 | import com.mojang.blaze3d.vertex.PoseStack; 7 | import com.mojang.math.Matrix3f; 8 | 9 | import ic2.api.tiles.display.IDisplayInfo; 10 | import ic2.api.tiles.display.IMonitorRenderer; 11 | import net.minecraft.nbt.CompoundTag; 12 | import net.minecraft.nbt.Tag; 13 | import net.minecraft.network.FriendlyByteBuf; 14 | import net.minecraft.world.item.ItemStack; 15 | import net.minecraftforge.api.distmarker.Dist; 16 | import net.minecraftforge.api.distmarker.OnlyIn; 17 | 18 | public class ItemDisplayInfo implements IDisplayInfo 19 | { 20 | ItemStack item; 21 | boolean showCount; 22 | Supplier itemProvider; 23 | BooleanSupplier aliveProvider; 24 | 25 | public ItemDisplayInfo(FriendlyByteBuf buffer) 26 | { 27 | showCount = buffer.readBoolean(); 28 | item = buffer.readItem(); 29 | if(showCount) item.setCount(buffer.readVarInt()); 30 | } 31 | 32 | public ItemDisplayInfo(boolean showCount, Supplier itemProvider, BooleanSupplier aliveProvider) 33 | { 34 | this.showCount = showCount; 35 | this.itemProvider = itemProvider; 36 | this.aliveProvider = aliveProvider; 37 | } 38 | 39 | @Override 40 | @OnlyIn(Dist.CLIENT) 41 | public void render(PoseStack stack, int x, int y, int width, int height, Alignment align, IMonitorRenderer helper) 42 | { 43 | stack.pushPose(); 44 | stack.last().normal().load(Matrix3f.createScaleMatrix(1.0F, -1.0F, 1.0F)); 45 | helper.renderGuiItems(stack, item, x, y); 46 | if(showCount) 47 | { 48 | helper.renderGuiItemText(stack, item, x, y, null); 49 | } 50 | stack.popPose(); 51 | } 52 | 53 | @Override 54 | @OnlyIn(Dist.CLIENT) 55 | public int getHeight(int width, Alignment align) 56 | { 57 | return 18; 58 | } 59 | 60 | @Override 61 | public boolean isValid() 62 | { 63 | return aliveProvider.getAsBoolean(); 64 | } 65 | 66 | @Override 67 | public void serialize(FriendlyByteBuf buffer) 68 | { 69 | ItemStack stack = itemProvider.get(); 70 | buffer.writeBoolean(showCount); 71 | buffer.writeItem(stack); 72 | if(showCount) buffer.writeVarInt(stack.getCount()); 73 | } 74 | 75 | @Override 76 | public Tag getServerData() 77 | { 78 | ItemStack stack = itemProvider.get(); 79 | CompoundTag data = stack.save(new CompoundTag()); 80 | if(showCount) data.putInt("Count", stack.getCount()); 81 | else data.remove("Count"); 82 | return data; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/display/impl/StringDisplayInfo.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.display.impl; 2 | 3 | import java.util.function.BooleanSupplier; 4 | import java.util.function.Supplier; 5 | 6 | import com.mojang.blaze3d.vertex.PoseStack; 7 | 8 | import ic2.api.tiles.display.IDisplayInfo; 9 | import ic2.api.tiles.display.IMonitorRenderer; 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.client.gui.Font; 12 | import net.minecraft.nbt.StringTag; 13 | import net.minecraft.nbt.Tag; 14 | import net.minecraft.network.FriendlyByteBuf; 15 | import net.minecraft.network.chat.Component; 16 | import net.minecraft.network.chat.Style; 17 | import net.minecraft.util.FormattedCharSequence; 18 | import net.minecraftforge.api.distmarker.Dist; 19 | import net.minecraftforge.api.distmarker.OnlyIn; 20 | 21 | public class StringDisplayInfo implements IDisplayInfo 22 | { 23 | Component comp; 24 | Supplier textProvider; 25 | BooleanSupplier aliveProvider; 26 | 27 | public StringDisplayInfo(Supplier textProvider, BooleanSupplier aliveProvider) 28 | { 29 | this.textProvider = textProvider; 30 | this.aliveProvider = aliveProvider; 31 | } 32 | 33 | public StringDisplayInfo(FriendlyByteBuf buffer) 34 | { 35 | comp = buffer.readComponent(); 36 | } 37 | 38 | @Override 39 | @OnlyIn(Dist.CLIENT) 40 | public void render(PoseStack stack, int x, int y, int width, int height, Alignment align, IMonitorRenderer helper) 41 | { 42 | Font font = helper.getFont(); 43 | int heightConsumed = 0; 44 | for(FormattedCharSequence sub : font.split(comp, width)) 45 | { 46 | if(height - heightConsumed < font.lineHeight) return; 47 | font.drawInBatch(sub, x-align.getXOffset(font.width(sub)), y+heightConsumed, -1, false, stack.last().pose(), helper.getBatcher(), false, 0, 15728880); 48 | heightConsumed += font.lineHeight; 49 | } 50 | } 51 | 52 | @Override 53 | @OnlyIn(Dist.CLIENT) 54 | public int getHeight(int width, Alignment align) 55 | { 56 | Font font = Minecraft.getInstance().font; 57 | return font.getSplitter().splitLines(comp, width, Style.EMPTY).size() * font.lineHeight; 58 | } 59 | 60 | @Override 61 | public boolean isValid() 62 | { 63 | return aliveProvider.getAsBoolean(); 64 | } 65 | 66 | @Override 67 | public Tag getServerData() 68 | { 69 | return StringTag.valueOf(textProvider.get().getString()); 70 | } 71 | 72 | @Override 73 | public void serialize(FriendlyByteBuf buffer) 74 | { 75 | buffer.writeComponent(textProvider.get()); 76 | } 77 | } -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/IActivityProvider.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface IActivityProvider 4 | { 5 | boolean isActivated(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/IAirSpeed.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface IAirSpeed 4 | { 5 | public float getCurrentSpeed(); 6 | 7 | public float getMaxSpeed(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/IEUProducer.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface IEUProducer 4 | { 5 | float getEUProduction(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/IEUStorage.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface IEUStorage 4 | { 5 | int getStoredEU(); 6 | 7 | int getMaxEU(); 8 | 9 | int getTier(); 10 | 11 | default double getChargeLevel() 12 | { 13 | return (double)getStoredEU() / (double)getMaxEU(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/IFuelStorage.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface IFuelStorage 4 | { 5 | int getFuel(); 6 | int getMaxFuel(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/IProgressMachine.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface IProgressMachine 4 | { 5 | float getProgress(); 6 | 7 | float getMaxProgress(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/IPumpTile.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface IPumpTile 4 | { 5 | int getPumpProgress(); 6 | 7 | int getPumpMaxProgress(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/ISpeedMachine.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface ISpeedMachine 4 | { 5 | int getSpeed(); 6 | 7 | int getMaxSpeed(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/ISubProgressMachine.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface ISubProgressMachine 4 | { 5 | float getSubProgress(); 6 | 7 | float getMaxSubProgress(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/IWorkProvider.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | public interface IWorkProvider 4 | { 5 | boolean isWorking(); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/readers/ReaderProvider.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.readers; 2 | 3 | import java.util.Map; 4 | 5 | import com.google.common.base.Function; 6 | 7 | import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; 8 | import net.minecraft.world.level.block.entity.BlockEntity; 9 | 10 | public class ReaderProvider 11 | { 12 | static final Map, Function> FUEL_PROVIDER = new Object2ObjectOpenHashMap<>(); 13 | static final Map, Function> ACTIVE_PROVIDER = new Object2ObjectOpenHashMap<>(); 14 | static final Map, Function> PROGRESS_PROVIDER = new Object2ObjectOpenHashMap<>(); 15 | 16 | public static void registerActiveProvider(Class clz, Function provider) 17 | { 18 | ACTIVE_PROVIDER.put(clz, provider); 19 | } 20 | 21 | public static void registerFuelProvider(Class clz, Function provider) 22 | { 23 | FUEL_PROVIDER.put(clz, provider); 24 | } 25 | 26 | public static void registerProgressProvider(Class clz, Function provider) 27 | { 28 | PROGRESS_PROVIDER.put(clz, provider); 29 | } 30 | 31 | public static IFuelStorage getFuelProvider(BlockEntity tile) 32 | { 33 | if(tile == null) return null; 34 | if(tile instanceof IFuelStorage) return (IFuelStorage)tile; 35 | Class clz = tile.getClass(); 36 | while(clz != BlockEntity.class) 37 | { 38 | Function storage = FUEL_PROVIDER.get(clz); 39 | if(storage != null) { 40 | if(clz != tile.getClass()) FUEL_PROVIDER.put(tile.getClass(), storage); 41 | return storage.apply(tile); 42 | } 43 | clz = clz.getSuperclass(); 44 | } 45 | return null; 46 | } 47 | 48 | public static IProgressMachine getProgressProvider(BlockEntity tile) 49 | { 50 | if(tile == null) return null; 51 | if(tile instanceof IProgressMachine) return (IProgressMachine)tile; 52 | Class clz = tile.getClass(); 53 | while(clz != BlockEntity.class) 54 | { 55 | Function storage = PROGRESS_PROVIDER.get(clz); 56 | if(storage != null) { 57 | if(clz != tile.getClass()) PROGRESS_PROVIDER.put(tile.getClass(), storage); 58 | return storage.apply(tile); 59 | } 60 | clz = clz.getSuperclass(); 61 | } 62 | return null; 63 | } 64 | 65 | public static IActivityProvider getActivityProvider(BlockEntity tile) 66 | { 67 | if(tile == null) return null; 68 | if(tile instanceof IActivityProvider) return (IActivityProvider)tile; 69 | Class clz = tile.getClass(); 70 | while(clz != BlockEntity.class) 71 | { 72 | Function storage = ACTIVE_PROVIDER.get(clz); 73 | if(storage != null) { 74 | if(clz != tile.getClass()) ACTIVE_PROVIDER.put(tile.getClass(), storage); 75 | return storage.apply(tile); 76 | } 77 | clz = clz.getSuperclass(); 78 | } 79 | return null; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/teleporter/ITeleporterTarget.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.teleporter; 2 | 3 | import ic2.api.util.ILocation; 4 | import net.minecraft.core.Direction; 5 | 6 | public interface ITeleporterTarget extends ILocation 7 | { 8 | Direction getFacing(); 9 | TeleportType getSendType(); 10 | boolean canReceive(TeleportType type); 11 | 12 | boolean setTarget(TeleporterTarget target); 13 | boolean hasTarget(TeleporterTarget target); 14 | 15 | enum TeleportType 16 | { 17 | ENTITY, 18 | SPAWNER, 19 | ITEM, 20 | FLUID, 21 | ENERGY, 22 | NOTHING; 23 | 24 | public boolean matches(TeleportType other) 25 | { 26 | if(other == SPAWNER) return this == ENTITY; 27 | if(this == SPAWNER) return other == ENTITY; 28 | return this == other; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/teleporter/TargetRegistry.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.teleporter; 2 | 3 | import java.util.Map; 4 | 5 | import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; 6 | 7 | public class TargetRegistry 8 | { 9 | public static final TargetRegistry INSTANCE = new TargetRegistry(); 10 | Map names = new Object2ObjectLinkedOpenHashMap<>(); 11 | 12 | public void addTarget(TeleporterTarget target, String name) 13 | { 14 | names.put(target, name); 15 | } 16 | 17 | public void removeTarget(TeleporterTarget target) 18 | { 19 | names.remove(target); 20 | } 21 | 22 | public String getTargetName(TeleporterTarget target) 23 | { 24 | return names.get(target); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/tubes/IItemCache.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.tubes; 2 | 3 | import java.util.function.Supplier; 4 | 5 | import ic2.api.util.SidedObject; 6 | import net.minecraft.world.item.ItemStack; 7 | 8 | /** 9 | * 10 | * @author Speiger 11 | * A Network Manager that syncs and keeps tracks of Item instances. 12 | * Simply Register server sided the Stack and a ID is allocated/provided to you that you can send to the client. 13 | * The client just gets the Item with the Provided Id, it is a supplier because it might take a while for it to arrive, so it can return a ItemStack.EMPTY or the actual instance. 14 | * This is to reduce network traffic. 15 | */ 16 | public interface IItemCache 17 | { 18 | SidedObject CACHE = new SidedObject<>(); 19 | 20 | static IItemCache getCache() 21 | { 22 | return CACHE.get(); 23 | } 24 | 25 | /** 26 | * Returns the requested Stack from the given ID. 27 | * @param id that was provided from the registering 28 | * @return ItemStack.EMPTY or the stack registered. This is due to network delay. 29 | * @throws IllegalStateException if this is called on the server 30 | */ 31 | Supplier getItem(int id); 32 | 33 | /** 34 | * Registers a item + NBT Data and get a id that the client will have. 35 | * @param stack that should be synced to the client 36 | * @return the id for that specific stack 37 | * @throws IllegalStateException when called on the client. 38 | */ 39 | int registerItem(ItemStack stack); 40 | 41 | /** 42 | * Internally called automatically, this is just here for easier access. 43 | * Sends a sync request to the server from all the new ids that asked for on the client. 44 | * @throws IllegalStateException when called server sided. 45 | */ 46 | void updateCache(); 47 | 48 | /** 49 | * Clears the cache. Internal called automatically. Here for easier access. 50 | * Can be called both sides 51 | */ 52 | void clearCache(); 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/tubes/ILimiterTube.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.tubes; 2 | 3 | import java.util.EnumSet; 4 | 5 | import net.minecraft.world.item.DyeColor; 6 | 7 | public interface ILimiterTube extends ITube 8 | { 9 | public EnumSet getValidColors(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/tubes/IProviderTube.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.tubes; 2 | 3 | import java.util.UUID; 4 | import java.util.function.ObjIntConsumer; 5 | 6 | import net.minecraft.world.item.DyeColor; 7 | import net.minecraft.world.item.ItemStack; 8 | 9 | public interface IProviderTube extends ITube 10 | { 11 | int provideItems(ItemStack stack, int amount, DyeColor color, UUID requestId); 12 | void getItemsProvided(ObjIntConsumer listener); 13 | long getProviderSource(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/tubes/IRequestTube.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.tubes; 2 | 3 | import java.util.UUID; 4 | 5 | import net.minecraft.world.item.DyeColor; 6 | import net.minecraft.world.item.ItemStack; 7 | 8 | public interface IRequestTube extends ITube 9 | { 10 | void provideRequests(ITubeRequester requested); 11 | void onRequestsReset(); 12 | void onRequestFulfilled(ItemStack stack, int amount); 13 | UUID getRequestId(); 14 | void onRequestLost(ItemStack stack, int amount); 15 | long getRequestSource(); 16 | 17 | interface ITubeRequester 18 | { 19 | void requestItems(ItemStack stack, int amount, DyeColor color, UUID requestId); 20 | int validateRequest(ItemStack stack, int originalRequest, DyeColor color); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/tiles/tubes/ITube.java: -------------------------------------------------------------------------------- 1 | package ic2.api.tiles.tubes; 2 | 3 | import ic2.api.util.ILocation; 4 | import net.minecraft.core.Direction; 5 | import net.minecraft.world.item.DyeColor; 6 | import net.minecraft.world.item.ItemStack; 7 | 8 | public interface ITube extends ILocation 9 | { 10 | default void addItem(ItemStack item, Direction side) { addItem(item, side, null); } 11 | void addItem(ItemStack item, Direction side, DyeColor color); 12 | void addItem(TransportedItem item, Direction side); 13 | boolean canAddItem(TransportedItem item, Direction side); 14 | 15 | boolean canConnect(ITube other, Direction dir); 16 | TubeType getTubeType(); 17 | 18 | enum TubeType 19 | { 20 | SIMPLE, 21 | EXTRACTION 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/util/IC2DamageSource.java: -------------------------------------------------------------------------------- 1 | package ic2.api.util; 2 | 3 | import net.minecraft.world.damagesource.DamageSource; 4 | import net.minecraft.world.entity.Entity; 5 | 6 | public final class IC2DamageSource extends DamageSource 7 | { 8 | public static final IC2DamageSource ELECTRICITY = new IC2DamageSource("electricity"); 9 | public static final IC2DamageSource NUKE = new IC2DamageSource("nuke"); 10 | public static final IC2DamageSource RADIATION = new IC2DamageSource("radiation"); 11 | 12 | Entity source; 13 | 14 | private IC2DamageSource(String damageTypeIn) 15 | { 16 | super(damageTypeIn); 17 | } 18 | 19 | public static IC2DamageSource newShockDamage(Entity entity) 20 | { 21 | IC2DamageSource source = new IC2DamageSource(ELECTRICITY.getMsgId()); 22 | source.source = entity; 23 | return source; 24 | } 25 | 26 | @Override 27 | public Entity getEntity() 28 | { 29 | return source; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/util/ILocation.java: -------------------------------------------------------------------------------- 1 | package ic2.api.util; 2 | 3 | import net.minecraft.core.BlockPos; 4 | import net.minecraft.world.level.Level; 5 | import net.minecraft.world.level.block.entity.BlockEntity; 6 | 7 | /** 8 | * 9 | * @author Speiger 10 | * 11 | * Wrapper interface for TileEntities to allow easy access to their Level and BlockPos 12 | */ 13 | public interface ILocation 14 | { 15 | default Level getWorldObj() 16 | { 17 | if(this instanceof BlockEntity) 18 | { 19 | return ((BlockEntity)this).getLevel(); 20 | } 21 | throw new RuntimeException("ILocation needs to be implemented explicitly"); 22 | } 23 | 24 | default BlockPos getPosition() 25 | { 26 | if(this instanceof BlockEntity) 27 | { 28 | return ((BlockEntity)this).getBlockPos(); 29 | } 30 | throw new RuntimeException("ILocation needs to be implemented explicitly"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/ic2/api/util/SidedObject.java: -------------------------------------------------------------------------------- 1 | package ic2.api.util; 2 | 3 | import net.minecraftforge.fml.util.thread.EffectiveSide; 4 | 5 | /** 6 | * 7 | * @author Speiger 8 | * 9 | * Similar to what forges {@link net.minecraftforge.fml.DistExecutor} does, but this allows to access both implementations if present and needed. 10 | * 11 | * @param 12 | */ 13 | public class SidedObject 14 | { 15 | T client; 16 | T server; 17 | 18 | /** 19 | * 20 | * @param value an implementation of a sided component 21 | * @param serverSide true for server thread implementations, false for client thread implementations 22 | */ 23 | public void set(T value, boolean serverSide) 24 | { 25 | if(serverSide) 26 | { 27 | server = value; 28 | return; 29 | } 30 | client = value; 31 | } 32 | 33 | /** 34 | * 35 | * @return the implementation for the current thread 36 | */ 37 | public T get() 38 | { 39 | return get(isSimulating()); 40 | } 41 | 42 | /** 43 | * 44 | * @param serverSide true for server thread implementations, false for client thread implementations 45 | * @return the implementation for the requested thread 46 | */ 47 | public T get(boolean serverSide) 48 | { 49 | return serverSide ? server : client; 50 | } 51 | 52 | protected boolean isSimulating() 53 | { 54 | return EffectiveSide.get().isServer(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/crops_en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "crop.ic2.adamantum": "Adamantum", 3 | "crop.ic2.allium": "Allium", 4 | "crop.ic2.alumen": "Alumen", 5 | "crop.ic2.argentum": "Argentum", 6 | "crop.ic2.aurelia": "Aurelia", 7 | "crop.ic2.azure_bluet": "Azure Bluet", 8 | "crop.ic2.bamboo": "Bamboo", 9 | "crop.ic2.beetroot": "Beetroot", 10 | "crop.ic2.blackthorn": "Blackthorn", 11 | "crop.ic2.blue_orchid": "Blue Orchid", 12 | "crop.ic2.blue_wheat": "Blue Wheat", 13 | "crop.ic2.bone_flower": "Bone Flower", 14 | "crop.ic2.brain_coral": "Brain Coral", 15 | "crop.ic2.brown_mushroom": "Brown Mushroom", 16 | "crop.ic2.bubble_coral": "Bubble Coral", 17 | "crop.ic2.cactus": "Cactus", 18 | "crop.ic2.carrot": "Carrot", 19 | "crop.ic2.cocoa": "Cocoa", 20 | "crop.ic2.coffee": "Coffee", 21 | "crop.ic2.cornflower": "Cornflower", 22 | "crop.ic2.crimson_fungus": "Crimson Fungus", 23 | "crop.ic2.dandelion": "Dandelion", 24 | "crop.ic2.ferru": "Ferru", 25 | "crop.ic2.fire_coral": "Fire Coral", 26 | "crop.ic2.forget_me_not": "Forget-Me-Not", 27 | "crop.ic2.glowshroom": "Glowshroom", 28 | "crop.ic2.glow_berry": "Glow Berry", 29 | "crop.ic2.hemp": "Hemp", 30 | "crop.ic2.hops": "Hops", 31 | "crop.ic2.horn_coral": "Horn Coral", 32 | "crop.ic2.inkbergine": "Inkbergine", 33 | "crop.ic2.kelp": "Kelp", 34 | "crop.ic2.lily_of_the_valley": "Lily of the Valley", 35 | "crop.ic2.lumilia": "Lumilia", 36 | "crop.ic2.malachite": "Malachite", 37 | "crop.ic2.melon": "Melon", 38 | "crop.ic2.netherwart": "Netherwart", 39 | "crop.ic2.orange_tulip": "Orange Tulip", 40 | "crop.ic2.oxeye_daisy": "Oxeye Daisy", 41 | "crop.ic2.pink_tulip": "Pink Tulip", 42 | "crop.ic2.poppy": "Poppy", 43 | "crop.ic2.potato": "Potato", 44 | "crop.ic2.pumpkin": "Pumpkin", 45 | "crop.ic2.purple_tulip": "Purple Tulip", 46 | "crop.ic2.rainbow_flower": "Rainbow Flower", 47 | "crop.ic2.red_mushroom": "Red Mushroom", 48 | "crop.ic2.red_tulip": "Red Tulip", 49 | "crop.ic2.red_wheat": "RedWheat", 50 | "crop.ic2.sapling_acacia": "Acacia Sapling", 51 | "crop.ic2.sapling_birch": "Birch Sapling", 52 | "crop.ic2.sapling_dark_oak": "Dark Oak Sapling", 53 | "crop.ic2.sapling_jungle": "Jungle Sapling", 54 | "crop.ic2.sapling_oak": "Oak Sapling", 55 | "crop.ic2.sapling_spruce": "Spruce Sapling", 56 | "crop.ic2.sea_grass": "Sea Grass", 57 | "crop.ic2.sea_pickle": "Sea Pickle", 58 | "crop.ic2.stannum": "Stannum", 59 | "crop.ic2.stickreed": "Stickreed", 60 | "crop.ic2.sugarcane": "Sugarcane", 61 | "crop.ic2.sweet_berry_bush": "Sweet Berry Bush", 62 | "crop.ic2.tea": "Tea", 63 | "crop.ic2.terrawart": "Terrawart", 64 | "crop.ic2.tube_coral": "Tube Coral", 65 | "crop.ic2.unknown": "Unknown", 66 | "crop.ic2.venomilia": "Venomilia", 67 | "crop.ic2.warped_fungus": "Warped Fungus", 68 | "crop.ic2.weed": "Weed", 69 | "crop.ic2.wheat": "Wheat", 70 | "crop.ic2.white_tulip": "White Tulip" 71 | } -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/crops_ko_kr.json: -------------------------------------------------------------------------------- 1 | { 2 | "crop.ic2.adamantum": "아다만툼", 3 | "crop.ic2.allium": "파꽃", 4 | "crop.ic2.alumen": "백반", 5 | "crop.ic2.argentum": "백은", 6 | "crop.ic2.aurelia": "아우렐리아", 7 | "crop.ic2.azure_bluet": "선애기별꽃", 8 | "crop.ic2.bamboo": "대나무", 9 | "crop.ic2.beetroot": "사탕무", 10 | "crop.ic2.blackthorn": "자두", 11 | "crop.ic2.blue_orchid": "파란색 난초", 12 | "crop.ic2.blue_wheat": "파란밀", 13 | "crop.ic2.bone_flower": "뼈 꽃", 14 | "crop.ic2.brain_coral": "뇌 산호", 15 | "crop.ic2.brown_mushroom": "갈색 버섯", 16 | "crop.ic2.bubble_coral": "거품 산호", 17 | "crop.ic2.cactus": "선인장", 18 | "crop.ic2.carrot": "당근", 19 | "crop.ic2.cocoa": "코코아", 20 | "crop.ic2.coffee": "커피", 21 | "crop.ic2.cornflower": "수레국화", 22 | "crop.ic2.crimson_fungus": "진홍빛 균", 23 | "crop.ic2.dandelion": "민들레", 24 | "crop.ic2.ferru": "페루", 25 | "crop.ic2.fire_coral": "불 산호", 26 | "crop.ic2.forget_me_not": "물망초", 27 | "crop.ic2.glowshroom": "발광 버섯", 28 | "crop.ic2.glow_berry": "발광 열매", 29 | "crop.ic2.hemp": "대마", 30 | "crop.ic2.hops": "홉", 31 | "crop.ic2.horn_coral": "사방산호", 32 | "crop.ic2.inkbergine": "잉크버건", 33 | "crop.ic2.kelp": "켈프", 34 | "crop.ic2.lily_of_the_valley": "은방울꽃", 35 | "crop.ic2.lumilia": "루밀리어", 36 | "crop.ic2.malachite": "맬러카이트", 37 | "crop.ic2.melon": "수박", 38 | "crop.ic2.netherwart": "네더와트", 39 | "crop.ic2.orange_tulip": "주황색 튤립", 40 | "crop.ic2.oxeye_daisy": "데이지", 41 | "crop.ic2.pink_tulip": "분홍색 튤립", 42 | "crop.ic2.poppy": "양귀비", 43 | "crop.ic2.potato": "감자", 44 | "crop.ic2.pumpkin": "호박", 45 | "crop.ic2.purple_tulip": "보라색 튤립", 46 | "crop.ic2.rainbow_flower": "무지개 꽃", 47 | "crop.ic2.red_mushroom": "빨간색 버섯", 48 | "crop.ic2.red_tulip": "빨간색 튤립", 49 | "crop.ic2.red_wheat": "붉은 밀", 50 | "crop.ic2.sapling_acacia": "아카시아 나무 묘목", 51 | "crop.ic2.sapling_birch": "자작나무 묘목", 52 | "crop.ic2.sapling_dark_oak": "짙은 참나무 묘목", 53 | "crop.ic2.sapling_jungle": "정글나무 묘목", 54 | "crop.ic2.sapling_oak": "참나무 묘목", 55 | "crop.ic2.sapling_spruce": "가문비나무 묘목", 56 | "crop.ic2.sea_grass": "해초", 57 | "crop.ic2.sea_pickle": "불우렁쉥이", 58 | "crop.ic2.stannum": "스탄눔", 59 | "crop.ic2.stickreed": "스틱 리드", 60 | "crop.ic2.sugarcane": "사탕수수", 61 | "crop.ic2.sweet_berry_bush": "달콤한 열매 덤불", 62 | "crop.ic2.tea": "차", 63 | "crop.ic2.terrawart": "테라와트", 64 | "crop.ic2.tube_coral": "관 산호", 65 | "crop.ic2.unknown": "알 수 없음.", 66 | "crop.ic2.venomilia": "베노밀리아", 67 | "crop.ic2.warped_fungus": "뒤틀린 균", 68 | "crop.ic2.weed": "잡초", 69 | "crop.ic2.wheat": "밀", 70 | "crop.ic2.white_tulip": "하얀색 튤립" 71 | } -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/crops_ru_ru.json: -------------------------------------------------------------------------------- 1 | { 2 | "crop.ic2.adamantum": "Алмазные культуры", 3 | "crop.ic2.allium": "Лук-батун", 4 | "crop.ic2.alumen": "Алюминиевые культуры", 5 | "crop.ic2.argentum": "Аргентум", 6 | "crop.ic2.aurelia": "Аурелия", 7 | "crop.ic2.azure_bluet": "Хаустония серая", 8 | "crop.ic2.bamboo": "Бамбук", 9 | "crop.ic2.beetroot": "Свекла", 10 | "crop.ic2.blackthorn": "Терновник", 11 | "crop.ic2.blue_orchid": "Синяя орхидея", 12 | "crop.ic2.blue_wheat": "Синяя пшеница", 13 | "crop.ic2.bone_flower": "Костяной цветок", 14 | "crop.ic2.brain_coral": "Мозговой коралл", 15 | "crop.ic2.brown_mushroom": "Коричневый гриб", 16 | "crop.ic2.bubble_coral": "Пузырчатый коралл", 17 | "crop.ic2.cactus": "Кактус", 18 | "crop.ic2.carrot": "Морковь", 19 | "crop.ic2.cocoa": "Какао", 20 | "crop.ic2.coffee": "Кофе", 21 | "crop.ic2.cornflower": "Синий василек", 22 | "crop.ic2.crimson_fungus": "Багровый гриб", 23 | "crop.ic2.dandelion": "Одуванчик", 24 | "crop.ic2.ferru": "Ферум", 25 | "crop.ic2.fire_coral": "Огненный коралл", 26 | "crop.ic2.forget_me_not": "Незабудка", 27 | "crop.ic2.glowshroom": "Светящийся гриб", 28 | "crop.ic2.glow_berry": "Светящиеся ягоды", 29 | "crop.ic2.hemp": "Конопля", 30 | "crop.ic2.hops": "Хмель", 31 | "crop.ic2.horn_coral": "Роговый коралл", 32 | "crop.ic2.inkbergine": "Спрутоцвет", 33 | "crop.ic2.kelp": "Ламинария", 34 | "crop.ic2.lily_of_the_valley": "Ландыш", 35 | "crop.ic2.lumilia": "Луноцвет", 36 | "crop.ic2.malachite": "Малахит", 37 | "crop.ic2.melon": "Арбуз", 38 | "crop.ic2.netherwart": "Адский нарост", 39 | "crop.ic2.orange_tulip": "Оранжевый тюльпан", 40 | "crop.ic2.oxeye_daisy": "Ромашка", 41 | "crop.ic2.pink_tulip": "Розовый тюльпан", 42 | "crop.ic2.poppy": "Мак", 43 | "crop.ic2.potato": "Картофель", 44 | "crop.ic2.pumpkin": "Тыква", 45 | "crop.ic2.purple_tulip": "Фиолетовый тюльпан", 46 | "crop.ic2.rainbow_flower": "Радужный цветок", 47 | "crop.ic2.red_mushroom": "Красный гриб", 48 | "crop.ic2.red_tulip": "Красный тюльпан", 49 | "crop.ic2.red_wheat": "Красная пшеница", 50 | "crop.ic2.sapling_acacia": "Саженец акации", 51 | "crop.ic2.sapling_birch": "Саженец березы", 52 | "crop.ic2.sapling_dark_oak": "Саженец темного дуба", 53 | "crop.ic2.sapling_jungle": "Саженец джунглей", 54 | "crop.ic2.sapling_oak": "Саженец дуба", 55 | "crop.ic2.sapling_spruce": "Саженец ели", 56 | "crop.ic2.sea_grass": "Морская трава", 57 | "crop.ic2.sea_pickle": "Морской огурец", 58 | "crop.ic2.stannum": "Оловянные культуры", 59 | "crop.ic2.stickreed": "Резиновый тростник", 60 | "crop.ic2.sugarcane": "Сахарный тростник", 61 | "crop.ic2.sweet_berry_bush": "Куст сладких ягод", 62 | "crop.ic2.tea": "Чай", 63 | "crop.ic2.terrawart": "Земляной нарост", 64 | "crop.ic2.tube_coral": "Трубчатый коралл", 65 | "crop.ic2.unknown": "Неизвестно", 66 | "crop.ic2.venomilia": "Веномилия", 67 | "crop.ic2.warped_fungus": "Искаженный гриб", 68 | "crop.ic2.weed": "Сорняк", 69 | "crop.ic2.wheat": "Пшеница", 70 | "crop.ic2.white_tulip": "Белый тюльпан" 71 | } 72 | -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/crops_uk_ua.json: -------------------------------------------------------------------------------- 1 | { 2 | "crop.ic2.adamantum": "Адамантум", 3 | "crop.ic2.allium": "Алліум", 4 | "crop.ic2.alumen": "Алюмен", 5 | "crop.ic2.argentum": "Аргентум", 6 | "crop.ic2.aurelia": "Аурелія", 7 | "crop.ic2.azure_bluet": "Блют", 8 | "crop.ic2.bamboo": "Бамбук", 9 | "crop.ic2.beetroot": "Буряк", 10 | "crop.ic2.blackthorn": "Терен", 11 | "crop.ic2.blue_orchid": "Синя орхідея", 12 | "crop.ic2.blue_wheat": "Синя пшениця", 13 | "crop.ic2.bone_flower": "Кістяна квітка", 14 | "crop.ic2.brain_coral": "Мозковий корал", 15 | "crop.ic2.brown_mushroom": "Коричневий гриб", 16 | "crop.ic2.bubble_coral": "Бульбашковий корал", 17 | "crop.ic2.cactus": "Кактус", 18 | "crop.ic2.carrot": "Морква", 19 | "crop.ic2.cocoa": "Какао", 20 | "crop.ic2.coffee": "Кава", 21 | "crop.ic2.cornflower": "Волошка", 22 | "crop.ic2.crimson_fungus": "Малиновий гриб", 23 | "crop.ic2.dandelion": "Кульбаба", 24 | "crop.ic2.ferru": "Папороть", 25 | "crop.ic2.fire_coral": "Вогняний корал", 26 | "crop.ic2.forget_me_not": "Незабудка", 27 | "crop.ic2.glowshroom": "Світлячок", 28 | "crop.ic2.glow_berry": "Сяюча ягода", 29 | "crop.ic2.hemp": "Конопля", 30 | "crop.ic2.hops": "Хміль", 31 | "crop.ic2.horn_coral": "Роговий корал", 32 | "crop.ic2.inkbergine": "Чернильниця", 33 | "crop.ic2.kelp": "Ламінарія", 34 | "crop.ic2.lily_of_the_valley": "Конвалія", 35 | "crop.ic2.lumilia": "Люмілія", 36 | "crop.ic2.malachite": "Малахіт", 37 | "crop.ic2.melon": "Кавун", 38 | "crop.ic2.netherwart": "Наріст Незеру", 39 | "crop.ic2.oxeye_daisy": "Ромашка", 40 | "crop.ic2.poppy": "Мак", 41 | "crop.ic2.potato": "Картопля", 42 | "crop.ic2.pumpkin": "Ґарбуз", 43 | "crop.ic2.orange_tulip": "Помаранчевий тюльпан", 44 | "crop.ic2.pink_tulip": "Рожевий тюльпан", 45 | "crop.ic2.purple_tulip": "Фіолетовий тюльпан", 46 | "crop.ic2.white_tulip": "Білий тюльпан", 47 | "crop.ic2.red_tulip": "Червоний тюльпан", 48 | "crop.ic2.rainbow_flower": "Веселкова квітка", 49 | "crop.ic2.red_mushroom": "Червоний гриб", 50 | "crop.ic2.red_wheat": "Галичанка", 51 | "crop.ic2.sapling_acacia": "Паросток акації", 52 | "crop.ic2.sapling_birch": "Паросток берези", 53 | "crop.ic2.sapling_dark_oak": "Паросток темного дуба", 54 | "crop.ic2.sapling_jungle": "Паросток тропічного дерева", 55 | "crop.ic2.sapling_oak": "Паросток дуба", 56 | "crop.ic2.sapling_spruce": "Паросток смереки", 57 | "crop.ic2.sea_grass": "Морська трава", 58 | "crop.ic2.sea_pickle": "Морський огірок", 59 | "crop.ic2.stannum": "Станнум", 60 | "crop.ic2.stickreed": "Резинова тростина", 61 | "crop.ic2.sugarcane": "Цукрова тростина", 62 | "crop.ic2.sweet_berry_bush": "Солодкі ягоди", 63 | "crop.ic2.tea": "Чай", 64 | "crop.ic2.terrawart": "Земний наріст", 65 | "crop.ic2.tube_coral": "Трубчастий корал", 66 | "crop.ic2.unknown": "Невідомо", 67 | "crop.ic2.venomilia": "Веномілія", 68 | "crop.ic2.warped_fungus": "Химерний гриб", 69 | "crop.ic2.weed": "Бур'ян", 70 | "crop.ic2.wheat": "Пшениця" 71 | } 72 | -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/crops_zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "crop.ic2.adamantum":"钻叶草", 3 | "crop.ic2.allium":"绒球葱", 4 | "crop.ic2.alumen":"铝叶草", 5 | "crop.ic2.argentum":"银叶草", 6 | "crop.ic2.aurelia":"金叶草", 7 | "crop.ic2.azure_bluet":"茜草花", 8 | "crop.ic2.bamboo":"竹子", 9 | "crop.ic2.beetroot":"甜菜根", 10 | "crop.ic2.blackthorn":"黑刺李", 11 | "crop.ic2.blue_orchid":"蓝色兰花", 12 | "crop.ic2.blue_wheat":"蓝麦", 13 | "crop.ic2.bone_flower":"骨花", 14 | "crop.ic2.brain_coral":"脑纹珊瑚", 15 | "crop.ic2.brown_mushroom":"棕色蘑菇", 16 | "crop.ic2.bubble_coral":"气泡珊瑚", 17 | "crop.ic2.cactus":"仙人掌", 18 | "crop.ic2.carrot":"胡萝卜", 19 | "crop.ic2.cocoa":"可可豆", 20 | "crop.ic2.coffee":"咖啡豆", 21 | "crop.ic2.cornflower":"矢车菊", 22 | "crop.ic2.crimson_fungus":"绯红菌", 23 | "crop.ic2.dandelion":"蒲公英", 24 | "crop.ic2.ferru":"铁叶草", 25 | "crop.ic2.fire_coral":"火珊瑚", 26 | "crop.ic2.forget_me_not":"勿忘我", 27 | "crop.ic2.glowshroom":"荧光蘑菇", 28 | "crop.ic2.glow_berry":"发光浆果", 29 | "crop.ic2.hemp":"大麻", 30 | "crop.ic2.hops":"啤酒花", 31 | "crop.ic2.horn_coral":"角珊瑚", 32 | "crop.ic2.inkbergine":"墨佛手", 33 | "crop.ic2.kelp":"海带", 34 | "crop.ic2.lily_of_the_valley":"铃兰", 35 | "crop.ic2.lumilia":"卢米利亚", 36 | "crop.ic2.malachite":"孔雀石", 37 | "crop.ic2.melon":"西瓜", 38 | "crop.ic2.netherwart":"下界疣", 39 | "crop.ic2.orange_tulip":"橙色郁金香", 40 | "crop.ic2.oxeye_daisy":"滨菊", 41 | "crop.ic2.pink_tulip":"粉红色郁金香", 42 | "crop.ic2.poppy":"虞美人", 43 | "crop.ic2.potato":"马铃薯", 44 | "crop.ic2.pumpkin":"南瓜", 45 | "crop.ic2.purple_tulip":"紫色郁金香", 46 | "crop.ic2.rainbow_flower":"彩虹花", 47 | "crop.ic2.red_mushroom":"红色蘑菇", 48 | "crop.ic2.red_tulip":"红色郁金香", 49 | "crop.ic2.red_wheat":"红麦", 50 | "crop.ic2.sapling_acacia":"金合欢树苗", 51 | "crop.ic2.sapling_birch":"白桦树苗", 52 | "crop.ic2.sapling_dark_oak":"深色橡树树苗", 53 | "crop.ic2.sapling_jungle":"丛林树苗", 54 | "crop.ic2.sapling_oak":"橡树树苗", 55 | "crop.ic2.sapling_spruce":"云杉树苗", 56 | "crop.ic2.sea_grass":"海草", 57 | "crop.ic2.sea_pickle":"海泡菜", 58 | "crop.ic2.stannum":"锡叶草", 59 | "crop.ic2.stickreed":"粘性甘蔗", 60 | "crop.ic2.sugarcane":"甘蔗", 61 | "crop.ic2.sweet_berry_bush":"甜浆果灌木", 62 | "crop.ic2.tea":"茶叶", 63 | "crop.ic2.terrawart":"大地疣", 64 | "crop.ic2.tube_coral":"管珊瑚", 65 | "crop.ic2.unknown":"未知作物", 66 | "crop.ic2.venomilia":"毒液花", 67 | "crop.ic2.warped_fungus":"诡异菌", 68 | "crop.ic2.weed":"杂草", 69 | "crop.ic2.wheat":"小麦", 70 | "crop.ic2.white_tulip":"白色郁金香" 71 | } -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/stats_en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "stat.ic2.air_cells_used": "Air Cells Used", 3 | "stat.ic2.blocks_drilled": "Blocks Drilled", 4 | "stat.ic2.blocks_sawed": "Blocks Chainsawed", 5 | "stat.ic2.cable_shock_damage": "Cable Shock Damage Taken", 6 | "stat.ic2.chainsaws_kills": "Entities Chainsawed", 7 | "stat.ic2.crops_breed": "Textures Copied", 8 | "stat.ic2.crops_discovered": "Crops Discovered", 9 | "stat.ic2.distance_teleported": "Teleported Distance", 10 | "stat.ic2.dragons_lasered": "Dragons Lasered", 11 | "stat.ic2.drown_with_q_helmet": "Drowned with Quantum Helmet", 12 | "stat.ic2.electric_enchanted": "Electric Items Enchanted", 13 | "stat.ic2.foam_sprayed": "Construction-Foam Sprayed", 14 | "stat.ic2.food_cans_eaten": "Food Cans Eaten", 15 | "stat.ic2.highest_crop_gain": "Highest Crop Gain Breed", 16 | "stat.ic2.highest_crop_growth": "Highest Crop Growth Breed", 17 | "stat.ic2.highest_crop_resistance": "Highest Crop Resistance Breed", 18 | "stat.ic2.highest_crop_tier": "Highest Crop Tier Breed", 19 | "stat.ic2.jetpack_fly_time": "Jetpack Fly Time", 20 | "stat.ic2.laser_kills": "Entities Lasered", 21 | "stat.ic2.lucky_person": "Being very Lucky", 22 | "stat.ic2.nukes_ignited": "Nukes Ignited", 23 | "stat.ic2.nukes_survived": "Nukes Survived", 24 | "stat.ic2.overgrowth_used": "Overgrowth Fertilizers Used", 25 | "stat.ic2.revived_used": "Restoring Fertilizers Used", 26 | "stat.ic2.rocket_mode_used": "Jetpack Rockets Launched", 27 | "stat.ic2.textures_stolen": "Textures Copied", 28 | "stat.ic2.withers_nuked": "Withers Nuked" 29 | } -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/stats_ko_kr.json: -------------------------------------------------------------------------------- 1 | { 2 | "stat.ic2.air_cells_used": "사용된 공기셀", 3 | "stat.ic2.blocks_drilled": "드릴로 캔 블록 수", 4 | "stat.ic2.blocks_sawed": "전기톱으로 캔 블록 수", 5 | "stat.ic2.cable_shock_damage": "전선 충격 데미지", 6 | "stat.ic2.chainsaws_kills": "전기톱으로 처리한 엔티티", 7 | "stat.ic2.crops_breed": "작물 번식", 8 | "stat.ic2.distance_teleported": "텔레포트된 거리", 9 | "stat.ic2.dragons_lasered": "레이저로 드래곤 처리", 10 | "stat.ic2.drown_with_q_helmet": "퀀텀 헬멧에 익사", 11 | "stat.ic2.electric_enchanted": "마법 부여된 전기 아이템", 12 | "stat.ic2.foam_sprayed": "CF 스프레이", 13 | "stat.ic2.food_cans_eaten": "먹은 음식 캔", 14 | "stat.ic2.jetpack_fly_time": "제트팩 비행 시간", 15 | "stat.ic2.laser_kills": "레이저로 처리된 엔티티", 16 | "stat.ic2.lucky_person": "매우 운이 좋다", 17 | "stat.ic2.nukes_ignited": "핵폭탄 점화", 18 | "stat.ic2.nukes_survived": "핵폭발에서 생존", 19 | "stat.ic2.overgrowth_used": "과성장 비료 사용", 20 | "stat.ic2.revived_used": "사용한 비료의 복원", 21 | "stat.ic2.rocket_mode_used": "제트팩 로켓 발사", 22 | "stat.ic2.textures_stolen": "복사된 텍스처", 23 | "stat.ic2.withers_nuked": "핵으로 위더 처리" 24 | } -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/stats_ru_ru.json: -------------------------------------------------------------------------------- 1 | { 2 | "stat.ic2.air_cells_used": "Использовано воздушных камер", 3 | "stat.ic2.blocks_drilled": "Блоков выкопано", 4 | "stat.ic2.blocks_sawed": "Блоков распилено бензопилой", 5 | "stat.ic2.cable_shock_damage": "Получено урона от удара током", 6 | "stat.ic2.chainsaws_kills": "Существ распилено бензопилой", 7 | "stat.ic2.crops_breed": "Культур выведено", 8 | "stat.ic2.distance_teleported": "Дистанция телепортации", 9 | "stat.ic2.dragons_lasered": "Убито драконов лазером", 10 | "stat.ic2.drown_with_q_helmet": "Утонул в квантовом шлеме", 11 | "stat.ic2.electric_enchanted": "Зачаровано электрических предметов", 12 | "stat.ic2.foam_sprayed": "Распылено монтажной пены", 13 | "stat.ic2.food_cans_eaten": "Съедено консерв с едой", 14 | "stat.ic2.jetpack_fly_time": "Время полета на реактивном ранце", 15 | "stat.ic2.laser_kills": "Сущностей поражено лазером", 16 | "stat.ic2.lucky_person": "Был очень удачливым", 17 | "stat.ic2.nukes_ignited": "Подожжено ядерных бомб", 18 | "stat.ic2.nukes_survived": "Пережито ядерных взрывов", 19 | "stat.ic2.overgrowth_used": "Использовано удобрений для перероста", 20 | "stat.ic2.revived_used": "Использованно восстанавливающих удобрений", 21 | "stat.ic2.rocket_mode_used": "Использован режим парения", 22 | "stat.ic2.textures_stolen": "Текстур скопировано", 23 | "stat.ic2.withers_nuked": "Взорвано иссушителей ядерным взрывом" 24 | } 25 | -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/stats_uk_ua.json: -------------------------------------------------------------------------------- 1 | { 2 | "stat.ic2.air_cells_used": "Використанно Повітряних капсул", 3 | "stat.ic2.blocks_drilled": "Блоків пробурено", 4 | "stat.ic2.blocks_sawed": "Блоків спилених Ланцюговою пилою", 5 | "stat.ic2.cable_shock_damage": "Урон від кабелів під струмом", 6 | "stat.ic2.chainsaws_kills": "Порізано сутностей Ланцюговою пилою", 7 | "stat.ic2.crops_breed": "Скопійованих текстур", 8 | "stat.ic2.crops_discovered": "Виявлено культур", 9 | "stat.ic2.distance_teleported": "Дистанція телепортацій", 10 | "stat.ic2.dragons_lasered": "Драконів піджарених лазером", 11 | "stat.ic2.drown_with_q_helmet": "Кількість втоплень у Квантовому шоломі", 12 | "stat.ic2.electric_enchanted": "Зачарованих електричних приборів", 13 | "stat.ic2.foam_sprayed": "Вибризкано будівельної піни", 14 | "stat.ic2.food_cans_eaten": "З'їдено консервів", 15 | "stat.ic2.highest_crop_gain": "Найвищий рівень врожайності серед порід", 16 | "stat.ic2.highest_crop_growth": "Найвищий рівень росту серед порід", 17 | "stat.ic2.highest_crop_resistance": "Найвища стійкість урожаю серед порід", 18 | "stat.ic2.highest_crop_tier": "Найвищий рівень урожаю серед порід", 19 | "stat.ic2.jetpack_fly_time": "Час польоту на Реактивному ранці", 20 | "stat.ic2.laser_kills": "Сутностей піджарених лазером", 21 | "stat.ic2.lucky_person": "Бути дуже везучим", 22 | "stat.ic2.nukes_ignited": "Активовано Ядерних бомю", 23 | "stat.ic2.nukes_survived": "Пережито ядерних вибухів", 24 | "stat.ic2.overgrowth_used": "Використано добирв для переросту", 25 | "stat.ic2.revived_used": "Використано добрив для відновлення", 26 | "stat.ic2.rocket_mode_used": "Використано режим Ракети", 27 | "stat.ic2.textures_stolen": "Скопійовано текстур", 28 | "stat.ic2.withers_nuked": "Підірвано Візерів" 29 | } -------------------------------------------------------------------------------- /src/main/resources/assets/ic2/lang/stats_zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "stat.ic2.air_cells_used":"空气单元使用次数", 3 | "stat.ic2.blocks_drilled":"电钻钻数", 4 | "stat.ic2.blocks_sawed":"链锯锯数", 5 | "stat.ic2.cable_shock_damage":"电缆损坏数", 6 | "stat.ic2.chainsaws_kills":"实体被链锯杀死数", 7 | "stat.ic2.crops_breed":"复制的纹理数", 8 | "stat.ic2.crops_discovered": "作物发现数量", 9 | "stat.ic2.distance_teleported":"传送距离", 10 | "stat.ic2.dragons_lasered":"用激光杀死龙次数", 11 | "stat.ic2.drown_with_q_helmet":"戴着量子头盔溺水次数", 12 | "stat.ic2.electric_enchanted":"充电物品附魔次数", 13 | "stat.ic2.foam_sprayed":"喷射施工泡沫次数", 14 | "stat.ic2.food_cans_eaten":"食用的食品罐头个数", 15 | "stat.ic2.highest_crop_gain": "最高作物收获数量", 16 | "stat.ic2.highest_crop_growth": "最高的作物生长程度", 17 | "stat.ic2.highest_crop_resistance": "最高作物抗性品种", 18 | "stat.ic2.highest_crop_tier": "最高作物等级品种", 19 | "stat.ic2.jetpack_fly_time":"喷气背包飞行时间", 20 | "stat.ic2.laser_kills":"激光杀死实体数", 21 | "stat.ic2.lucky_person":"非常幸运次数", 22 | "stat.ic2.nukes_ignited":"起爆核弹次数", 23 | "stat.ic2.nukes_survived":"核爆存活次数", 24 | "stat.ic2.overgrowth_used":"使用过度生长肥料次数", 25 | "stat.ic2.revived_used":"恢复材料使用次数", 26 | "stat.ic2.rocket_mode_used":"喷气背包火箭发射", 27 | "stat.ic2.textures_stolen":"材质复制次数", 28 | "stat.ic2.withers_nuked":"凋零核爆次数" 29 | } --------------------------------------------------------------------------------