Repository: GabrielOlvH/Industrial-Revolution
Branch: master
Commit: 012a1b83f39a
Files: 1883
Total size: 1.9 MB
Directory structure:
gitextract_2rmcmr4g/
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── bugs.md
│ └── requests.md
├── .gitignore
├── LICENSE.txt
├── README.md
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src/
└── main/
├── java/
│ └── me/
│ └── steven/
│ └── indrev/
│ ├── AprilFools.java
│ ├── FabricRecipeRemainder.java
│ ├── IREnergyStorage.java
│ ├── WCustomTabPanel.java
│ └── mixin/
│ ├── aprilfools/
│ │ ├── AprilFoolsMixinConfigPlugin.java
│ │ └── MixinTranslatableText.java
│ ├── client/
│ │ ├── MixinBuiltChunk.java
│ │ ├── MixinClientPlayerInteractionManager.java
│ │ ├── MixinGameRenderer.java
│ │ ├── MixinItemRenderer.java
│ │ ├── MixinLivingEntityClient.java
│ │ ├── MixinMinecraftClient.java
│ │ └── MixinWItemSlot.java
│ └── common/
│ ├── MixinAbstractCookingRecipe.java
│ ├── MixinEnchantmentHelper.java
│ ├── MixinEntity.java
│ ├── MixinItemPredicate.java
│ ├── MixinItemStack.java
│ ├── MixinLivingEntity.java
│ ├── MixinPiglinBrain.java
│ ├── MixinPlayerEntity.java
│ ├── MixinPlayerInventory.java
│ ├── MixinServerPlayerEntity.java
│ └── MixinServerWorld.java
├── kotlin/
│ └── me/
│ └── steven/
│ └── indrev/
│ ├── IndustrialRevolution.kt
│ ├── IndustrialRevolutionClient.kt
│ ├── api/
│ │ ├── AttributeModifierProvider.kt
│ │ ├── CustomEnchantmentProvider.kt
│ │ ├── IREntityExtension.kt
│ │ ├── IRPlayerEntityExtension.kt
│ │ ├── IRServerPlayerEntityExtension.kt
│ │ ├── OreDataCards.kt
│ │ ├── ServerWorldExtension.kt
│ │ ├── machines/
│ │ │ ├── Tier.kt
│ │ │ └── TransferMode.kt
│ │ └── sideconfigs/
│ │ ├── Configurable.kt
│ │ ├── ConfigurationType.kt
│ │ └── SideConfiguration.kt
│ ├── armor/
│ │ ├── IRArmorMaterial.kt
│ │ ├── ModuleFeatureRenderer.kt
│ │ └── ReinforcedElytraFeatureRenderer.kt
│ ├── blockentities/
│ │ ├── BaseBlockEntity.kt
│ │ ├── BaseMachineBlockEntity.kt
│ │ ├── GlobalStateController.kt
│ │ ├── MachineBlockEntity.kt
│ │ ├── Syncable.kt
│ │ ├── cables/
│ │ │ └── BasePipeBlockEntity.kt
│ │ ├── crafters/
│ │ │ ├── CompressorBlockEntity.kt
│ │ │ ├── CompressorFactoryBlockEntity.kt
│ │ │ ├── CondenserBlockEntity.kt
│ │ │ ├── CondenserBlockEntityRenderer.kt
│ │ │ ├── CraftingMachineBlockEntity.kt
│ │ │ ├── ElectricFurnaceBlockEntity.kt
│ │ │ ├── ElectricFurnaceFactoryBlockEntity.kt
│ │ │ ├── ElectrolyticSeparatorBlockEntity.kt
│ │ │ ├── FluidInfuserBlockEntity.kt
│ │ │ ├── FluidInfuserBlockEntityRenderer.kt
│ │ │ ├── PulverizerBlockEntity.kt
│ │ │ ├── PulverizerFactoryBlockEntity.kt
│ │ │ ├── RecyclerBlockEntity.kt
│ │ │ ├── SawmillBlockEntity.kt
│ │ │ ├── SmelterBlockEntity.kt
│ │ │ ├── SolidInfuserBlockEntity.kt
│ │ │ └── SolidInfuserFactoryBlockEntity.kt
│ │ ├── farms/
│ │ │ ├── AOEMachineBlockEntity.kt
│ │ │ ├── AOEMachineBlockEntityRenderer.kt
│ │ │ ├── BiomassComposterBlockEntity.kt
│ │ │ ├── BiomassComposterBlockEntityRenderer.kt
│ │ │ ├── ChopperBlockEntity.kt
│ │ │ ├── ChopperBlockEntityRenderer.kt
│ │ │ ├── DirtOxygenatorBlockEntity.kt
│ │ │ ├── DrainBlockEntity.kt
│ │ │ ├── FarmerBlockEntity.kt
│ │ │ ├── FisherBlockEntity.kt
│ │ │ ├── PumpBlockEntity.kt
│ │ │ ├── PumpBlockEntityRenderer.kt
│ │ │ ├── RancherBlockEntity.kt
│ │ │ └── SlaughterBlockEntity.kt
│ │ ├── generators/
│ │ │ ├── BiomassGeneratorBlockEntity.kt
│ │ │ ├── CoalGeneratorBlockEntity.kt
│ │ │ ├── GasBurningGeneratorBlockEntity.kt
│ │ │ ├── GeneratorBlockEntity.kt
│ │ │ ├── HeatGeneratorBlockEntity.kt
│ │ │ ├── HeatGeneratorBlockEntityRenderer.kt
│ │ │ ├── SolarGeneratorBlockEntity.kt
│ │ │ ├── SolidFuelGeneratorBlockEntity.kt
│ │ │ ├── SteamTurbineBlockEntity.kt
│ │ │ └── SteamTurbineSteamInputValveBlockEntity.kt
│ │ ├── laser/
│ │ │ ├── CapsuleBlockEntity.kt
│ │ │ ├── CapsuleBlockEntityRenderer.kt
│ │ │ ├── LaserBlockEntity.kt
│ │ │ └── LaserBlockEntityRenderer.kt
│ │ ├── miningrig/
│ │ │ ├── DataCardWriterBlockEntity.kt
│ │ │ ├── DrillBlockEntity.kt
│ │ │ ├── DrillBlockEntityRenderer.kt
│ │ │ ├── MiningRigBlockEntity.kt
│ │ │ └── MiningRigBlockEntityRenderer.kt
│ │ ├── modularworkbench/
│ │ │ ├── ModularWorkbenchBlockEntity.kt
│ │ │ └── ModularWorkbenchBlockEntityRenderer.kt
│ │ ├── solarpowerplant/
│ │ │ ├── HeliostatBlockEntity.kt
│ │ │ ├── HeliostatBlockEntityRenderer.kt
│ │ │ ├── SolarPowerPlantTowerBlockEntity.kt
│ │ │ └── SolarReceiverBlockEntity.kt
│ │ └── storage/
│ │ ├── CabinetBlockEntity.kt
│ │ ├── ChargePadBlockEntity.kt
│ │ ├── ChargePadBlockEntityRenderer.kt
│ │ ├── LazuliFluxContainerBlockEntity.kt
│ │ ├── LazuliFluxContainerBlockEntityRenderer.kt
│ │ ├── TankBlockEntity.kt
│ │ └── TankBlockEntityRenderer.kt
│ ├── blocks/
│ │ ├── HeliostatBlock.kt
│ │ ├── machine/
│ │ │ ├── CapsuleBlock.kt
│ │ │ ├── ChargePadBlock.kt
│ │ │ ├── DirtOxygenatorBlock.kt
│ │ │ ├── DrillBlock.kt
│ │ │ ├── DrillHeadModel.kt
│ │ │ ├── ElectrolyticSeparatorBlock.kt
│ │ │ ├── FacingMachineBlock.kt
│ │ │ ├── HorizontalFacingMachineBlock.kt
│ │ │ ├── LaserBlock.kt
│ │ │ ├── LazuliFluxContainerBlock.kt
│ │ │ ├── MachineBlock.kt
│ │ │ ├── MiningRigBlock.kt
│ │ │ ├── PumpBlock.kt
│ │ │ ├── pipes/
│ │ │ │ ├── BasePipeBlock.kt
│ │ │ │ ├── CableBlock.kt
│ │ │ │ ├── FluidPipeBlock.kt
│ │ │ │ └── ItemPipeBlock.kt
│ │ │ └── solarpowerplant/
│ │ │ ├── FluidValveBlock.kt
│ │ │ ├── SolarPowerPlantFluidOutputBlock.kt
│ │ │ ├── SolarPowerPlantTowerBlock.kt
│ │ │ ├── SolarReceiverBlock.kt
│ │ │ ├── SteamTurbineBlock.kt
│ │ │ └── SteamTurbineSteamInputValveBlock.kt
│ │ ├── misc/
│ │ │ ├── AcidFluidBlock.kt
│ │ │ ├── BiomassComposterBlock.kt
│ │ │ ├── CabinetBlock.kt
│ │ │ ├── DuctBlock.kt
│ │ │ ├── HorizontalFacingBlock.kt
│ │ │ ├── NikoliteOreBlock.kt
│ │ │ ├── PlankBlock.kt
│ │ │ ├── SulfurCrystalBlock.kt
│ │ │ ├── TankBlock.kt
│ │ │ ├── VerticalFacingBlock.kt
│ │ │ └── WarningStrobeBlock.kt
│ │ └── models/
│ │ ├── LazuliFluxContainerBakedModel.kt
│ │ ├── MachineBakedModel.kt
│ │ ├── MinerBakedModel.kt
│ │ ├── PumpPipeBakedModel.kt
│ │ └── pipes/
│ │ ├── BasePipeModel.kt
│ │ ├── CableModel.kt
│ │ ├── FluidPipeModel.kt
│ │ └── ItemPipeModel.kt
│ ├── compat/
│ │ ├── dashloader/
│ │ │ └── models/
│ │ │ ├── DashCableModel.kt
│ │ │ ├── DashFluidPipeModel.kt
│ │ │ ├── DashItemPipeModel.kt
│ │ │ ├── DashLazuliFluxContainerModel.kt
│ │ │ ├── DashMachineModel.kt
│ │ │ ├── DashMinerModel.kt
│ │ │ └── DashTankModel.kt
│ │ └── rei/
│ │ ├── REIPlugin.kt
│ │ ├── categories/
│ │ │ ├── IRMachineRecipeCategory.kt
│ │ │ ├── IRModuleCraftingRecipeCategory.kt
│ │ │ └── IRSawmillRecipeCategory.kt
│ │ └── plugins/
│ │ └── IRMachinePlugin.kt
│ ├── components/
│ │ ├── CraftingComponent.kt
│ │ ├── EnhancerComponent.kt
│ │ ├── FluidComponent.kt
│ │ ├── GuiSyncableComponent.kt
│ │ ├── InventoryComponent.kt
│ │ ├── TemperatureComponent.kt
│ │ └── multiblock/
│ │ ├── BlockStateFilter.kt
│ │ ├── MultiBlockComponent.kt
│ │ ├── MultiblockBlockEntityRenderer.kt
│ │ ├── MultiblockMatcher.kt
│ │ ├── StructureDefinition.kt
│ │ ├── StructureHolder.kt
│ │ ├── StructureIdentifier.kt
│ │ └── definitions/
│ │ ├── FactoryStructureDefinition.kt
│ │ ├── SolarPowerPlantTowerStructureDefinition.kt
│ │ └── SteamTurbineStructureDefinition.kt
│ ├── config/
│ │ └── IRConfig.kt
│ ├── datagen/
│ │ ├── DataFactory.kt
│ │ ├── DataGenerator.kt
│ │ ├── DataGeneratorManager.kt
│ │ ├── ImageFactory.kt
│ │ ├── IndustrialRevolutionDatagen.kt
│ │ ├── JsonFactory.kt
│ │ ├── generators/
│ │ │ ├── BlockModelGenerator.kt
│ │ │ ├── ItemModelGenerator.kt
│ │ │ ├── LootTableGenerator.kt
│ │ │ ├── MaterialRecipeGenerator.kt
│ │ │ ├── MaterialTagGenerator.kt
│ │ │ └── MetalSpriteGenerator.kt
│ │ └── utils/
│ │ ├── MaterialColors.kt
│ │ ├── MetalModel.kt
│ │ ├── MetalSpriteRegistry.kt
│ │ └── SpriteColorHolder.kt
│ ├── events/
│ │ ├── client/
│ │ │ ├── IRClientTickEvents.kt
│ │ │ ├── IRHudRenderCallback.kt
│ │ │ ├── IRLivingEntityFeatureRendererCallback.kt
│ │ │ ├── IRTooltipComponentsCallback.kt
│ │ │ ├── IRWorldRenderer.kt
│ │ │ ├── MatterProjectorPreviewRenderer.kt
│ │ │ └── MiningRigInfoTooltipCallback.kt
│ │ └── common/
│ │ └── IRLootTableCallback.kt
│ ├── fluids/
│ │ ├── BaseFluid.kt
│ │ └── FluidType.kt
│ ├── gui/
│ │ ├── IRInventoryScreen.kt
│ │ ├── IRModularControllerScreen.kt
│ │ ├── IRScreenHandlerFactory.kt
│ │ ├── ScrewdriverScreenHandlerFactory.kt
│ │ ├── guiutils.kt
│ │ ├── properties/
│ │ │ └── SyncableProperty.kt
│ │ ├── screenhandlers/
│ │ │ ├── IRGuiScreenHandler.kt
│ │ │ ├── blockblacklister/
│ │ │ │ └── BlockBlacklisterScreenHandler.kt
│ │ │ ├── machines/
│ │ │ │ ├── BiomassGeneratorScreenHandler.kt
│ │ │ │ ├── ChopperScreenHandler.kt
│ │ │ │ ├── CoalGeneratorScreenHandler.kt
│ │ │ │ ├── CompressorFactoryScreenHandler.kt
│ │ │ │ ├── CompressorScreenHandler.kt
│ │ │ │ ├── CondenserScreenHandler.kt
│ │ │ │ ├── DataCardWriterScreenHandler.kt
│ │ │ │ ├── ElectricFurnaceFactoryScreenHandler.kt
│ │ │ │ ├── ElectricFurnaceScreenHandler.kt
│ │ │ │ ├── ElectrolyticSeparatorScreenHandler.kt
│ │ │ │ ├── FarmerScreenHandler.kt
│ │ │ │ ├── FisherScreenHandler.kt
│ │ │ │ ├── FluidInfuserScreenHandler.kt
│ │ │ │ ├── GasBurningGeneratorScreenHandler.kt
│ │ │ │ ├── HeatGeneratorScreenHandler.kt
│ │ │ │ ├── LaserEmitterScreenHandler.kt
│ │ │ │ ├── LazuliFluxContainerScreenHandler.kt
│ │ │ │ ├── MiningRigComputerScreenHandler.kt
│ │ │ │ ├── MiningRigDrillScreenHandler.kt
│ │ │ │ ├── ModularWorkbenchScreenHandler.kt
│ │ │ │ ├── PulverizerFactoryScreenHandler.kt
│ │ │ │ ├── PulverizerScreenHandler.kt
│ │ │ │ ├── PumpScreenHandler.kt
│ │ │ │ ├── RancherScreenHandler.kt
│ │ │ │ ├── RecyclerScreenHandler.kt
│ │ │ │ ├── SawmillScreenHandler.kt
│ │ │ │ ├── SlaughterScreenHandler.kt
│ │ │ │ ├── SmelterScreenHandler.kt
│ │ │ │ ├── SolarGeneratorScreenHandler.kt
│ │ │ │ ├── SolarPowerPlantTowerScreenHandler.kt
│ │ │ │ ├── SolidInfuserFactoryScreenHandler.kt
│ │ │ │ ├── SolidInfuserScreenHandler.kt
│ │ │ │ └── SteamTurbineScreenHandler.kt
│ │ │ ├── modular/
│ │ │ │ └── ModularItemConfigurationScreenHandler.kt
│ │ │ ├── pipes/
│ │ │ │ ├── PipeFilterScreen.kt
│ │ │ │ ├── PipeFilterScreenFactory.kt
│ │ │ │ └── PipeFilterScreenHandler.kt
│ │ │ ├── screenhandlers.kt
│ │ │ ├── storage/
│ │ │ │ └── CabinetScreenHandler.kt
│ │ │ └── wrench/
│ │ │ └── ScrewdriverScreenHandler.kt
│ │ ├── tooltip/
│ │ │ ├── energy/
│ │ │ │ ├── EnergyTooltipComponent.kt
│ │ │ │ └── EnergyTooltipData.kt
│ │ │ ├── modular/
│ │ │ │ ├── ModularTooltipComponent.kt
│ │ │ │ └── ModularTooltipData.kt
│ │ │ └── oredatacards/
│ │ │ ├── OreDataCardTooltipComponent.kt
│ │ │ └── OreDataCardTooltipData.kt
│ │ └── widgets/
│ │ ├── machines/
│ │ │ ├── WCustomBar.kt
│ │ │ └── WMachineSideDisplay.kt
│ │ └── misc/
│ │ ├── WBookEntryShortcut.kt
│ │ ├── WCircleProgressBar.kt
│ │ ├── WDynamicSprite.kt
│ │ ├── WKnob.kt
│ │ ├── WPlayerRender.kt
│ │ ├── WStaticTooltip.kt
│ │ ├── WText.kt
│ │ └── WTooltipedItemSlot.kt
│ ├── inventories/
│ │ ├── IRInventory.kt
│ │ └── IRInventoryDSL.kt
│ ├── items/
│ │ ├── armor/
│ │ │ ├── IRColorModuleItem.kt
│ │ │ ├── IRModularArmorItem.kt
│ │ │ ├── IRModuleItem.kt
│ │ │ ├── JetpackHandler.kt
│ │ │ ├── JetpackItem.kt
│ │ │ └── ReinforcedElytraItem.kt
│ │ ├── energy/
│ │ │ ├── IRBatteryItem.kt
│ │ │ ├── IREnergyItem.kt
│ │ │ ├── IRGamerAxeItem.kt
│ │ │ ├── IRMiningDrillItem.kt
│ │ │ ├── IRModularDrillItem.kt
│ │ │ ├── IRPortableChargerItem.kt
│ │ │ └── MachineBlockItem.kt
│ │ ├── misc/
│ │ │ ├── IRCraftingToolItem.kt
│ │ │ ├── IREnergyReaderItem.kt
│ │ │ ├── IRGuideBookItem.kt
│ │ │ ├── IRMachineUpgradeItem.kt
│ │ │ ├── IRServoItem.kt
│ │ │ ├── OreDataCardItem.kt
│ │ │ └── Tools.kt
│ │ ├── models/
│ │ │ └── TankItemBakedModel.kt
│ │ └── upgrade/
│ │ ├── Enhancer.kt
│ │ └── IREnhancerItem.kt
│ ├── networks/
│ │ ├── EndpointData.kt
│ │ ├── Network.kt
│ │ ├── NetworkEvents.kt
│ │ ├── NetworkState.kt
│ │ ├── Node.kt
│ │ ├── ServoNetworkState.kt
│ │ ├── client/
│ │ │ ├── ClientNetworkInfo.kt
│ │ │ ├── ClientNetworkState.kt
│ │ │ ├── ClientServoNetworkInfo.kt
│ │ │ └── node/
│ │ │ ├── ClientNodeInfo.kt
│ │ │ └── ClientServoNodeInfo.kt
│ │ ├── energy/
│ │ │ ├── CableEnergyIo.kt
│ │ │ ├── EnergyNetwork.kt
│ │ │ └── EnergyNetworkState.kt
│ │ ├── factory/
│ │ │ ├── NetworkFactory.kt
│ │ │ └── factories.kt
│ │ ├── fluid/
│ │ │ ├── FluidNetwork.kt
│ │ │ └── FluidNetworkState.kt
│ │ └── item/
│ │ ├── ItemFilterData.kt
│ │ ├── ItemNetwork.kt
│ │ └── ItemNetworkState.kt
│ ├── packets/
│ │ ├── PacketRegistry.kt
│ │ ├── client/
│ │ │ ├── ClientItemPipePackets.kt
│ │ │ ├── GuiPropertySyncPacket.kt
│ │ │ ├── MachineStateUpdatePacket.kt
│ │ │ ├── MiningRigSpawnBlockParticlesPacket.kt
│ │ │ ├── SyncAppliedModulesPacket.kt
│ │ │ ├── SyncConfigPacket.kt
│ │ │ └── SyncNetworkServosPacket.kt
│ │ └── common/
│ │ ├── ConfigureIOPackets.kt
│ │ ├── DataCardWriteStartPacket.kt
│ │ ├── FluidGuiHandInteractionPacket.kt
│ │ ├── ItemPipePackets.kt
│ │ ├── SelectModuleOnWorkbenchPacket.kt
│ │ ├── ToggleFactoryStackSplittingPacket.kt
│ │ ├── ToggleGamerAxePacket.kt
│ │ ├── UpdateAOEMachineRangePacket.kt
│ │ ├── UpdateKnobValue.kt
│ │ ├── UpdateMiningDrillBlockBlacklistPacket.kt
│ │ ├── UpdateModularToolLevelPacket.kt
│ │ └── UpdateRancherConfigPacket.kt
│ ├── recipes/
│ │ ├── IRecipeGetter.kt
│ │ ├── SelfRemainderRecipe.kt
│ │ └── machines/
│ │ ├── CompressorRecipe.kt
│ │ ├── CondenserRecipe.kt
│ │ ├── DistillerRecipe.kt
│ │ ├── ElectrolysisRecipe.kt
│ │ ├── FluidInfuserRecipe.kt
│ │ ├── IRFluidRecipe.kt
│ │ ├── IRRecipe.kt
│ │ ├── IRRecipeType.kt
│ │ ├── InfuserRecipe.kt
│ │ ├── LaserRecipe.kt
│ │ ├── ModuleRecipe.kt
│ │ ├── PulverizerRecipe.kt
│ │ ├── RecyclerRecipe.kt
│ │ ├── SawmillRecipe.kt
│ │ ├── SmelterRecipe.kt
│ │ ├── VanillaCookingRecipeCachedGetter.kt
│ │ └── entries/
│ │ ├── InputEntry.kt
│ │ └── OutputEntry.kt
│ ├── registry/
│ │ ├── IRBlockRegistry.kt
│ │ ├── IRFluidFuelRegistry.kt
│ │ ├── IRFluidRegistry.kt
│ │ ├── IRItemRegistry.kt
│ │ ├── IRModelManagers.kt
│ │ ├── MachineRegistry.kt
│ │ ├── MaterialHelper.kt
│ │ └── WorldGeneration.kt
│ ├── tools/
│ │ ├── IRToolMaterial.kt
│ │ └── modular/
│ │ ├── ArmorModule.kt
│ │ ├── DrillModule.kt
│ │ ├── GamerAxeModule.kt
│ │ ├── IRModularItem.kt
│ │ ├── MiningToolModule.kt
│ │ └── Module.kt
│ ├── utils/
│ │ ├── EmptyModel.kt
│ │ ├── EnergyDamageHandler.kt
│ │ ├── IRFluidTank.kt
│ │ ├── ReusableArrayDeque.kt
│ │ ├── accessorextensions.kt
│ │ ├── clientutils.kt
│ │ ├── energyutils.kt
│ │ ├── fluidutils.kt
│ │ ├── helperextensions.kt
│ │ ├── hiddenitems.kt
│ │ ├── interactions.kt
│ │ ├── itemutils.kt
│ │ ├── machineinteractions.kt
│ │ └── utils.kt
│ └── world/
│ └── features/
│ ├── IRConfiguredFeature.kt
│ └── SulfurCrystalFeature.kt
└── resources/
├── assets/
│ └── indrev/
│ ├── blockstates/
│ │ ├── biomass_composter.json
│ │ ├── block_base.json
│ │ ├── block_highlight.json
│ │ ├── block_shadow.json
│ │ ├── bronze_block.json
│ │ ├── cabinet.json
│ │ ├── capsule.json
│ │ ├── charge_pad_mk4.json
│ │ ├── composting.json
│ │ ├── controller.json
│ │ ├── coolant.json
│ │ ├── deepslate_lead_ore.json
│ │ ├── deepslate_nikolite_ore.json
│ │ ├── deepslate_silver_ore.json
│ │ ├── deepslate_tin_ore.json
│ │ ├── deepslate_tungsten_ore.json
│ │ ├── drain_mk1.json
│ │ ├── drill_bottom.json
│ │ ├── drill_middle.json
│ │ ├── drill_top.json
│ │ ├── duct.json
│ │ ├── electrum_block.json
│ │ ├── fisher_mk2.json
│ │ ├── fisher_mk3.json
│ │ ├── fisher_mk4.json
│ │ ├── frame.json
│ │ ├── heat_generator_mk4.json
│ │ ├── hydrogen.json
│ │ ├── intake.json
│ │ ├── laser_emitter_mk4.json
│ │ ├── lead_block.json
│ │ ├── lead_ore.json
│ │ ├── machine_block.json
│ │ ├── methane.json
│ │ ├── modular_workbench_mk4.json
│ │ ├── molten_copper.json
│ │ ├── molten_gold.json
│ │ ├── molten_iron.json
│ │ ├── molten_lead.json
│ │ ├── molten_netherite.json
│ │ ├── molten_silver.json
│ │ ├── molten_tin.json
│ │ ├── nikolite_ore.json
│ │ ├── ore_base.json
│ │ ├── ore_highlight.json
│ │ ├── oxygen.json
│ │ ├── plank_block.json
│ │ ├── planks.json
│ │ ├── pump_mk1.json
│ │ ├── raw_lead_block.json
│ │ ├── raw_silver_block.json
│ │ ├── raw_tin_block.json
│ │ ├── raw_tungsten_block.json
│ │ ├── silo.json
│ │ ├── silver_block.json
│ │ ├── silver_ore.json
│ │ ├── steel_block.json
│ │ ├── sulfur_crystal.json
│ │ ├── sulfuric_acid.json
│ │ ├── tank.json
│ │ ├── tin_block.json
│ │ ├── tin_ore.json
│ │ ├── toxic_mud.json
│ │ ├── tungsten_block.json
│ │ ├── tungsten_ore.json
│ │ ├── warning_strobe.json
│ │ └── wither_proof_obsidian.json
│ ├── lang/
│ │ ├── en_us.json
│ │ ├── pt_br.json
│ │ ├── ru_ru.json
│ │ ├── tr_tr.json
│ │ └── zh_cn.json
│ ├── models/
│ │ ├── block/
│ │ │ ├── block_base.json
│ │ │ ├── block_highlight.json
│ │ │ ├── block_shadow.json
│ │ │ ├── bronze_block.json
│ │ │ ├── cabinet.json
│ │ │ ├── cable_center_mk1.json
│ │ │ ├── cable_center_mk2.json
│ │ │ ├── cable_center_mk3.json
│ │ │ ├── cable_center_mk4.json
│ │ │ ├── cable_side_mk1.json
│ │ │ ├── cable_side_mk2.json
│ │ │ ├── cable_side_mk3.json
│ │ │ ├── cable_side_mk4.json
│ │ │ ├── capsule.json
│ │ │ ├── charge_pad_mk4.json
│ │ │ ├── controller.json
│ │ │ ├── deepslate_lead_ore.json
│ │ │ ├── deepslate_nikolite_ore.json
│ │ │ ├── deepslate_silver_ore.json
│ │ │ ├── deepslate_tin_ore.json
│ │ │ ├── deepslate_tungsten_ore.json
│ │ │ ├── diamond_drill_head.json
│ │ │ ├── drain_mk1.json
│ │ │ ├── drill.json
│ │ │ ├── drill_bottom.json
│ │ │ ├── drill_middle.json
│ │ │ ├── drill_top.json
│ │ │ ├── drill_top_on.json
│ │ │ ├── duct.json
│ │ │ ├── electrum_block.json
│ │ │ ├── fishing_farm_mk2.json
│ │ │ ├── fishing_farm_mk3.json
│ │ │ ├── fishing_farm_mk4.json
│ │ │ ├── fluid_pipe_center_mk1.json
│ │ │ ├── fluid_pipe_center_mk2.json
│ │ │ ├── fluid_pipe_center_mk3.json
│ │ │ ├── fluid_pipe_center_mk4.json
│ │ │ ├── fluid_pipe_side_mk1.json
│ │ │ ├── fluid_pipe_side_mk2.json
│ │ │ ├── fluid_pipe_side_mk3.json
│ │ │ ├── fluid_pipe_side_mk4.json
│ │ │ ├── frame.json
│ │ │ ├── gray_lava.json
│ │ │ ├── heat_generator_mk4.json
│ │ │ ├── intake.json
│ │ │ ├── iron_drill_head.json
│ │ │ ├── item_pipe_center_mk1.json
│ │ │ ├── item_pipe_center_mk2.json
│ │ │ ├── item_pipe_center_mk3.json
│ │ │ ├── item_pipe_center_mk4.json
│ │ │ ├── item_pipe_side_mk1.json
│ │ │ ├── item_pipe_side_mk2.json
│ │ │ ├── item_pipe_side_mk3.json
│ │ │ ├── item_pipe_side_mk4.json
│ │ │ ├── laser.json
│ │ │ ├── laser_on.json
│ │ │ ├── lazuli_flux_container.json
│ │ │ ├── lazuli_flux_container_input.json
│ │ │ ├── lazuli_flux_container_item_lf_level.json
│ │ │ ├── lazuli_flux_container_mk1_overlay.json
│ │ │ ├── lazuli_flux_container_mk2_overlay.json
│ │ │ ├── lazuli_flux_container_mk3_overlay.json
│ │ │ ├── lazuli_flux_container_mk4_overlay.json
│ │ │ ├── lazuli_flux_container_output.json
│ │ │ ├── lead_block.json
│ │ │ ├── lead_ore.json
│ │ │ ├── machine.json
│ │ │ ├── machine_block.json
│ │ │ ├── modular_workbench_mk4.json
│ │ │ ├── netherite_drill_head.json
│ │ │ ├── nikolite_ore.json
│ │ │ ├── ore_base.json
│ │ │ ├── ore_highlight.json
│ │ │ ├── plank_block.json
│ │ │ ├── planks_height10.json
│ │ │ ├── planks_height12.json
│ │ │ ├── planks_height14.json
│ │ │ ├── planks_height2.json
│ │ │ ├── planks_height4.json
│ │ │ ├── planks_height6.json
│ │ │ ├── planks_height8.json
│ │ │ ├── pump_mk1.json
│ │ │ ├── pump_pipe.json
│ │ │ ├── raw_lead_block.json
│ │ │ ├── raw_silver_block.json
│ │ │ ├── raw_tin_block.json
│ │ │ ├── raw_tungsten_block.json
│ │ │ ├── servo_output.json
│ │ │ ├── servo_output_item.json
│ │ │ ├── servo_retriever.json
│ │ │ ├── servo_retriever_item.json
│ │ │ ├── silo.json
│ │ │ ├── silver_block.json
│ │ │ ├── silver_ore.json
│ │ │ ├── smelter_mk4.json
│ │ │ ├── solar_generator_mk1.json
│ │ │ ├── solar_generator_mk1_on.json
│ │ │ ├── solar_generator_mk3.json
│ │ │ ├── solar_generator_mk3_on.json
│ │ │ ├── steel_block.json
│ │ │ ├── stone_drill_head.json
│ │ │ ├── sulfur_crystal.json
│ │ │ ├── tank.json
│ │ │ ├── tank_both.json
│ │ │ ├── tank_down.json
│ │ │ ├── tank_up.json
│ │ │ ├── tin_block.json
│ │ │ ├── tin_ore.json
│ │ │ ├── tungsten_block.json
│ │ │ ├── tungsten_ore.json
│ │ │ ├── warning_strobe.json
│ │ │ └── wither_proof_obsidian.json
│ │ └── item/
│ │ ├── axe_base.json
│ │ ├── axe_highlight.json
│ │ ├── axe_outline.json
│ │ ├── battery.json
│ │ ├── biomass.json
│ │ ├── blast_furnace_enhancer.json
│ │ ├── block_base.json
│ │ ├── block_highlight.json
│ │ ├── boots_base.json
│ │ ├── boots_highlight.json
│ │ ├── boots_outline.json
│ │ ├── broken_reinforced_elytra.json
│ │ ├── bronze_axe.json
│ │ ├── bronze_block.json
│ │ ├── bronze_boots.json
│ │ ├── bronze_chestplate.json
│ │ ├── bronze_dust.json
│ │ ├── bronze_helmet.json
│ │ ├── bronze_hoe.json
│ │ ├── bronze_ingot.json
│ │ ├── bronze_leggings.json
│ │ ├── bronze_nugget.json
│ │ ├── bronze_pickaxe.json
│ │ ├── bronze_plate.json
│ │ ├── bronze_shovel.json
│ │ ├── bronze_sword.json
│ │ ├── buffer_enhancer.json
│ │ ├── cabinet.json
│ │ ├── cable_mk1.json
│ │ ├── cable_mk2.json
│ │ ├── cable_mk3.json
│ │ ├── cable_mk4.json
│ │ ├── capsule.json
│ │ ├── charge_pad_mk4.json
│ │ ├── chestplate_base.json
│ │ ├── chestplate_highlight.json
│ │ ├── chestplate_outline.json
│ │ ├── chunk_base.json
│ │ ├── chunk_highlight.json
│ │ ├── chunk_outline.json
│ │ ├── chunk_scanner.json
│ │ ├── circuit_mk1.json
│ │ ├── circuit_mk2.json
│ │ ├── circuit_mk3.json
│ │ ├── circuit_mk4.json
│ │ ├── coal_dust.json
│ │ ├── controller.json
│ │ ├── coolant_bucket.json
│ │ ├── cooler_cell.json
│ │ ├── copper_axe.json
│ │ ├── copper_block.json
│ │ ├── copper_boots.json
│ │ ├── copper_chestplate.json
│ │ ├── copper_chunk.json
│ │ ├── copper_dust.json
│ │ ├── copper_gear.json
│ │ ├── copper_helmet.json
│ │ ├── copper_hoe.json
│ │ ├── copper_leggings.json
│ │ ├── copper_nether_ore.json
│ │ ├── copper_nugget.json
│ │ ├── copper_ore.json
│ │ ├── copper_pickaxe.json
│ │ ├── copper_plate.json
│ │ ├── copper_purified_ore.json
│ │ ├── copper_shovel.json
│ │ ├── copper_sword.json
│ │ ├── damage_enhancer.json
│ │ ├── deepslate_lead_ore.json
│ │ ├── deepslate_nikolite_ore.json
│ │ ├── deepslate_silver_ore.json
│ │ ├── deepslate_tin_ore.json
│ │ ├── deepslate_tungsten_ore.json
│ │ ├── diamond_drill_head.json
│ │ ├── diamond_dust.json
│ │ ├── drain_mk1.json
│ │ ├── drill_bottom.json
│ │ ├── duct.json
│ │ ├── dust_base.json
│ │ ├── dust_highlight.json
│ │ ├── dust_outline.json
│ │ ├── electrum_block.json
│ │ ├── electrum_dust.json
│ │ ├── electrum_ingot.json
│ │ ├── electrum_nugget.json
│ │ ├── electrum_plate.json
│ │ ├── empty_enhancer.json
│ │ ├── energy_enhancer.json
│ │ ├── energy_reader.json
│ │ ├── enriched_nikolite_dust.json
│ │ ├── enriched_nikolite_ingot.json
│ │ ├── fan.json
│ │ ├── fisher_mk2.json
│ │ ├── fisher_mk3.json
│ │ ├── fisher_mk4.json
│ │ ├── fluid_pipe_mk1.json
│ │ ├── fluid_pipe_mk2.json
│ │ ├── fluid_pipe_mk3.json
│ │ ├── fluid_pipe_mk4.json
│ │ ├── frame.json
│ │ ├── gamer_axe.json
│ │ ├── gamer_axe1.json
│ │ ├── gamer_axe10.json
│ │ ├── gamer_axe2.json
│ │ ├── gamer_axe3.json
│ │ ├── gamer_axe4.json
│ │ ├── gamer_axe5.json
│ │ ├── gamer_axe6.json
│ │ ├── gamer_axe7.json
│ │ ├── gamer_axe8.json
│ │ ├── gamer_axe9.json
│ │ ├── gold_chunk.json
│ │ ├── gold_dust.json
│ │ ├── gold_plate.json
│ │ ├── gold_purified_ore.json
│ │ ├── guide_book.json
│ │ ├── hammer.json
│ │ ├── heat_coil.json
│ │ ├── heat_generator_mk4.json
│ │ ├── heatsink.json
│ │ ├── helmet_base.json
│ │ ├── helmet_highlight.json
│ │ ├── helmet_outline.json
│ │ ├── hoe_base.json
│ │ ├── hoe_highlight.json
│ │ ├── hoe_outline.json
│ │ ├── ingot_base.json
│ │ ├── ingot_highlight.json
│ │ ├── ingot_outline.json
│ │ ├── intake.json
│ │ ├── iron_chunk.json
│ │ ├── iron_drill_head.json
│ │ ├── iron_dust.json
│ │ ├── iron_gear.json
│ │ ├── iron_plate.json
│ │ ├── iron_purified_ore.json
│ │ ├── jetpack_mk1.json
│ │ ├── jetpack_mk2.json
│ │ ├── jetpack_mk3.json
│ │ ├── jetpack_mk4.json
│ │ ├── laser_emitter_mk4.json
│ │ ├── lazuli_flux_container_creative.json
│ │ ├── lazuli_flux_container_mk1.json
│ │ ├── lazuli_flux_container_mk2.json
│ │ ├── lazuli_flux_container_mk3.json
│ │ ├── lazuli_flux_container_mk4.json
│ │ ├── lead_axe.json
│ │ ├── lead_block.json
│ │ ├── lead_boots.json
│ │ ├── lead_chestplate.json
│ │ ├── lead_chunk.json
│ │ ├── lead_dust.json
│ │ ├── lead_helmet.json
│ │ ├── lead_hoe.json
│ │ ├── lead_ingot.json
│ │ ├── lead_leggings.json
│ │ ├── lead_nugget.json
│ │ ├── lead_ore.json
│ │ ├── lead_pickaxe.json
│ │ ├── lead_plate.json
│ │ ├── lead_purified_ore.json
│ │ ├── lead_shovel.json
│ │ ├── lead_sword.json
│ │ ├── leggings_base.json
│ │ ├── leggings_highlight.json
│ │ ├── leggings_outline.json
│ │ ├── machine_block.json
│ │ ├── miner_mk4.json
│ │ ├── mining_drill_mk1.json
│ │ ├── mining_drill_mk2.json
│ │ ├── mining_drill_mk3.json
│ │ ├── mining_drill_mk4.json
│ │ ├── modular_armor_boots.json
│ │ ├── modular_armor_chest.json
│ │ ├── modular_armor_helmet.json
│ │ ├── modular_armor_legs.json
│ │ ├── modular_core.json
│ │ ├── modular_core_activated.json
│ │ ├── modular_workbench_mk4.json
│ │ ├── module_auto_feeder.json
│ │ ├── module_breathing.json
│ │ ├── module_charger.json
│ │ ├── module_color_black.json
│ │ ├── module_color_blue.json
│ │ ├── module_color_brown.json
│ │ ├── module_color_cyan.json
│ │ ├── module_color_green.json
│ │ ├── module_color_orange.json
│ │ ├── module_color_pink.json
│ │ ├── module_color_purple.json
│ │ ├── module_color_red.json
│ │ ├── module_color_yellow.json
│ │ ├── module_efficiency.json
│ │ ├── module_elytra.json
│ │ ├── module_feather_falling.json
│ │ ├── module_fire_aspect.json
│ │ ├── module_fire_resistance.json
│ │ ├── module_fortune.json
│ │ ├── module_jetpack.json
│ │ ├── module_jump_boost.json
│ │ ├── module_looting.json
│ │ ├── module_magnet.json
│ │ ├── module_night_vision.json
│ │ ├── module_piglin_tricker.json
│ │ ├── module_protection.json
│ │ ├── module_range.json
│ │ ├── module_reach.json
│ │ ├── module_sharpness.json
│ │ ├── module_silk_touch.json
│ │ ├── module_solar_panel.json
│ │ ├── module_speed.json
│ │ ├── module_water_affinity.json
│ │ ├── molten_bucket_base.json
│ │ ├── molten_bucket_highlight.json
│ │ ├── molten_bucket_outline.json
│ │ ├── molten_copper_bucket.json
│ │ ├── molten_gold_bucket.json
│ │ ├── molten_iron_bucket.json
│ │ ├── molten_lead_bucket.json
│ │ ├── molten_netherite_bucket.json
│ │ ├── molten_silver_bucket.json
│ │ ├── molten_tin_bucket.json
│ │ ├── netherite_drill_head.json
│ │ ├── netherite_scrap_chunk.json
│ │ ├── netherite_scrap_dust.json
│ │ ├── netherite_scrap_purified_ore.json
│ │ ├── nikolite_dust.json
│ │ ├── nikolite_ingot.json
│ │ ├── nikolite_nether_ore.json
│ │ ├── nikolite_ore.json
│ │ ├── nugget_base.json
│ │ ├── nugget_highlight.json
│ │ ├── nugget_outline.json
│ │ ├── ore_base.json
│ │ ├── ore_data_card.json
│ │ ├── ore_data_card_not_empty.json
│ │ ├── ore_highlight.json
│ │ ├── pickaxe_base.json
│ │ ├── pickaxe_highlight.json
│ │ ├── pickaxe_outline.json
│ │ ├── plank_block.json
│ │ ├── planks.json
│ │ ├── plate_base.json
│ │ ├── plate_highlight.json
│ │ ├── plate_outline.json
│ │ ├── portable_charger.json
│ │ ├── pump_mk1.json
│ │ ├── purified_ore_base.json
│ │ ├── purified_ore_highlight.json
│ │ ├── purified_ore_outline.json
│ │ ├── raw_lead.json
│ │ ├── raw_lead_block.json
│ │ ├── raw_silver.json
│ │ ├── raw_silver_block.json
│ │ ├── raw_tin.json
│ │ ├── raw_tin_block.json
│ │ ├── raw_tungsten.json
│ │ ├── raw_tungsten_block.json
│ │ ├── reinforced_elytra.json
│ │ ├── sawdust.json
│ │ ├── scan_output.json
│ │ ├── screwdriver.json
│ │ ├── servo_output.json
│ │ ├── servo_retriever.json
│ │ ├── shovel_base.json
│ │ ├── shovel_highlight.json
│ │ ├── shovel_outline.json
│ │ ├── silo.json
│ │ ├── silver_axe.json
│ │ ├── silver_block.json
│ │ ├── silver_boots.json
│ │ ├── silver_chestplate.json
│ │ ├── silver_chunk.json
│ │ ├── silver_dust.json
│ │ ├── silver_helmet.json
│ │ ├── silver_hoe.json
│ │ ├── silver_ingot.json
│ │ ├── silver_leggings.json
│ │ ├── silver_nugget.json
│ │ ├── silver_ore.json
│ │ ├── silver_pickaxe.json
│ │ ├── silver_plate.json
│ │ ├── silver_purified_ore.json
│ │ ├── silver_shovel.json
│ │ ├── silver_sword.json
│ │ ├── smelter_mk4.json
│ │ ├── smoker_enhancer.json
│ │ ├── soot.json
│ │ ├── speed_enhancer.json
│ │ ├── steel_axe.json
│ │ ├── steel_block.json
│ │ ├── steel_boots.json
│ │ ├── steel_chestplate.json
│ │ ├── steel_dust.json
│ │ ├── steel_gear.json
│ │ ├── steel_helmet.json
│ │ ├── steel_hoe.json
│ │ ├── steel_ingot.json
│ │ ├── steel_leggings.json
│ │ ├── steel_nugget.json
│ │ ├── steel_pickaxe.json
│ │ ├── steel_plate.json
│ │ ├── steel_shovel.json
│ │ ├── steel_sword.json
│ │ ├── stone_drill_head.json
│ │ ├── sulfur_crystal.json
│ │ ├── sulfur_dust.json
│ │ ├── sulfuric_acid_bucket.json
│ │ ├── sword_base.json
│ │ ├── sword_highlight.json
│ │ ├── sword_outline.json
│ │ ├── tank.json
│ │ ├── tech_soup.json
│ │ ├── tier_upgrade_mk2.json
│ │ ├── tier_upgrade_mk3.json
│ │ ├── tier_upgrade_mk4.json
│ │ ├── tin_axe.json
│ │ ├── tin_block.json
│ │ ├── tin_boots.json
│ │ ├── tin_chestplate.json
│ │ ├── tin_chunk.json
│ │ ├── tin_dust.json
│ │ ├── tin_gear.json
│ │ ├── tin_helmet.json
│ │ ├── tin_hoe.json
│ │ ├── tin_ingot.json
│ │ ├── tin_leggings.json
│ │ ├── tin_nugget.json
│ │ ├── tin_ore.json
│ │ ├── tin_pickaxe.json
│ │ ├── tin_plate.json
│ │ ├── tin_purified_ore.json
│ │ ├── tin_shovel.json
│ │ ├── tin_sword.json
│ │ ├── tool_stick.json
│ │ ├── toxic_mud_bucket.json
│ │ ├── tungsten_block.json
│ │ ├── tungsten_chunk.json
│ │ ├── tungsten_dust.json
│ │ ├── tungsten_ingot.json
│ │ ├── tungsten_nugget.json
│ │ ├── tungsten_ore.json
│ │ ├── tungsten_plate.json
│ │ ├── tungsten_purified_ore.json
│ │ ├── untanned_leather.json
│ │ ├── warning_strobe.json
│ │ ├── wither_proof_obsidian.json
│ │ └── wrench.json
│ ├── particles/
│ │ └── laser_particle.json
│ ├── sounds/
│ │ └── laser.ogg
│ ├── sounds.json
│ └── textures/
│ ├── block/
│ │ ├── biomass_generator_on.png.mcmeta
│ │ ├── cable_center_emissive_mk1.png.mcmeta
│ │ ├── cable_center_emissive_mk2.png.mcmeta
│ │ ├── cable_center_emissive_mk3.png.mcmeta
│ │ ├── cable_center_emissive_mk4.png.mcmeta
│ │ ├── cable_wire_emissive_mk1.png.mcmeta
│ │ ├── cable_wire_emissive_mk2.png.mcmeta
│ │ ├── cable_wire_emissive_mk3.png.mcmeta
│ │ ├── cable_wire_emissive_mk4.png.mcmeta
│ │ ├── chopper_on.png.mcmeta
│ │ ├── coal_generator_on.png.mcmeta
│ │ ├── compressor_on.png.mcmeta
│ │ ├── condenser_on.png.mcmeta
│ │ ├── data_card_writer_on.png.mcmeta
│ │ ├── drill_top_emissive_on.png.mcmeta
│ │ ├── drill_top_tracer_emissive_on.png.mcmeta
│ │ ├── electric_furnace_emissive_on.png.mcmeta
│ │ ├── fluid_infuser_on.png.mcmeta
│ │ ├── gray_lava_flow.png.mcmeta
│ │ ├── gray_lava_still.png.mcmeta
│ │ ├── mining_rig_screen_emissive.png.mcmeta
│ │ ├── pulverizer_on.png.mcmeta
│ │ ├── rancher_on.png.mcmeta
│ │ ├── recycler_on.png.mcmeta
│ │ ├── sawmill_on.png.mcmeta
│ │ └── solid_infuser_emissive_on.png.mcmeta
│ ├── entity/
│ │ └── laser.png.mcmeta
│ ├── gui/
│ │ ├── hud_damaged.png.mcmeta
│ │ ├── hud_regenerating.png.mcmeta
│ │ └── hud_warning.png.mcmeta
│ └── item/
│ ├── enriched_nikolite_dust.png.mcmeta
│ ├── enriched_nikolite_ingot.png.mcmeta
│ └── gamer_axe.png.mcmeta
├── data/
│ ├── c/
│ │ └── tags/
│ │ ├── blocks/
│ │ │ ├── bronze_blocks.json
│ │ │ ├── copper_blocks.json
│ │ │ ├── electrum_blocks.json
│ │ │ ├── lead_blocks.json
│ │ │ ├── lead_ores.json
│ │ │ ├── silver_blocks.json
│ │ │ ├── silver_ores.json
│ │ │ ├── tin_blocks.json
│ │ │ ├── tin_ores.json
│ │ │ ├── tungsten_blocks.json
│ │ │ └── tungsten_ores.json
│ │ └── items/
│ │ ├── ancient_debris_ores.json
│ │ ├── bronze_blocks.json
│ │ ├── bronze_dusts.json
│ │ ├── bronze_ingots.json
│ │ ├── bronze_nuggets.json
│ │ ├── bronze_plates.json
│ │ ├── coal_dusts.json
│ │ ├── coal_ores.json
│ │ ├── copper_blocks.json
│ │ ├── copper_dusts.json
│ │ ├── copper_ingots.json
│ │ ├── copper_nuggets.json
│ │ ├── copper_ores.json
│ │ ├── copper_plates.json
│ │ ├── diamond_dusts.json
│ │ ├── diamond_ores.json
│ │ ├── electrum_blocks.json
│ │ ├── electrum_dusts.json
│ │ ├── electrum_ingots.json
│ │ ├── electrum_nuggets.json
│ │ ├── electrum_plates.json
│ │ ├── emerald_ores.json
│ │ ├── gold_dusts.json
│ │ ├── gold_ingots.json
│ │ ├── gold_ores.json
│ │ ├── gold_plates.json
│ │ ├── iron_dusts.json
│ │ ├── iron_ingots.json
│ │ ├── iron_ores.json
│ │ ├── iron_plates.json
│ │ ├── lead_blocks.json
│ │ ├── lead_dusts.json
│ │ ├── lead_ingots.json
│ │ ├── lead_nuggets.json
│ │ ├── lead_ores.json
│ │ ├── lead_plates.json
│ │ ├── netherite_scrap_dusts.json
│ │ ├── nikolite_ores.json
│ │ ├── raw_copper_ores.json
│ │ ├── raw_gold_ores.json
│ │ ├── raw_iron_ores.json
│ │ ├── raw_lead_ores.json
│ │ ├── raw_silver_ores.json
│ │ ├── raw_tin_ores.json
│ │ ├── raw_tungsten_ores.json
│ │ ├── redstone_ores.json
│ │ ├── screwdrivers.json
│ │ ├── silver_blocks.json
│ │ ├── silver_dusts.json
│ │ ├── silver_ingots.json
│ │ ├── silver_nuggets.json
│ │ ├── silver_ores.json
│ │ ├── silver_plates.json
│ │ ├── steel_blocks.json
│ │ ├── steel_boots.json
│ │ ├── steel_chestplates.json
│ │ ├── steel_dusts.json
│ │ ├── steel_helmets.json
│ │ ├── steel_ingots.json
│ │ ├── steel_leggings.json
│ │ ├── steel_nuggets.json
│ │ ├── steel_plates.json
│ │ ├── sulfur_dusts.json
│ │ ├── sulfurs.json
│ │ ├── tin_blocks.json
│ │ ├── tin_dusts.json
│ │ ├── tin_ingots.json
│ │ ├── tin_nuggets.json
│ │ ├── tin_ores.json
│ │ ├── tin_plates.json
│ │ ├── tungsten_blocks.json
│ │ ├── tungsten_dusts.json
│ │ ├── tungsten_ingots.json
│ │ ├── tungsten_nuggets.json
│ │ ├── tungsten_ores.json
│ │ ├── tungsten_plates.json
│ │ └── wrenches.json
│ ├── fabric/
│ │ └── tags/
│ │ └── items/
│ │ ├── axes.json
│ │ ├── hoes.json
│ │ ├── pickaxes.json
│ │ ├── shovels.json
│ │ └── swords.json
│ ├── indrev/
│ │ ├── advancements/
│ │ │ ├── advanced_solar_generator.json
│ │ │ ├── basic_solar_generator.json
│ │ │ ├── biomass.json
│ │ │ ├── biomass_generator.json
│ │ │ ├── blast_furnace_enhancer.json
│ │ │ ├── buffer_enhancer.json
│ │ │ ├── cable_mk1.json
│ │ │ ├── cable_mk2.json
│ │ │ ├── cable_mk3.json
│ │ │ ├── cable_mk4.json
│ │ │ ├── chopper_mk4.json
│ │ │ ├── circuit_mk1.json
│ │ │ ├── circuit_mk2.json
│ │ │ ├── circuit_mk3.json
│ │ │ ├── circuit_mk4.json
│ │ │ ├── coal_generator.json
│ │ │ ├── compressor.json
│ │ │ ├── condenser.json
│ │ │ ├── electric_furnace.json
│ │ │ ├── empty_enhancer.json
│ │ │ ├── enriched_nikolite_dust.json
│ │ │ ├── enriched_nikolite_ingot.json
│ │ │ ├── farmer_mk1.json
│ │ │ ├── gamer_axe.json
│ │ │ ├── heat_generator.json
│ │ │ ├── industrial_smelter.json
│ │ │ ├── lazuli_flux_container_mk1.json
│ │ │ ├── lazuli_flux_container_mk2.json
│ │ │ ├── lazuli_flux_container_mk3.json
│ │ │ ├── lazuli_flux_container_mk4.json
│ │ │ ├── machine_block.json
│ │ │ ├── mk2_upgrade.json
│ │ │ ├── mk3_upgrade.json
│ │ │ ├── mk4_upgrade.json
│ │ │ ├── modular_armor.json
│ │ │ ├── modular_workbench.json
│ │ │ ├── nikolite.json
│ │ │ ├── nikolite_ingot.json
│ │ │ ├── pulverizer.json
│ │ │ ├── rancher_mk4.json
│ │ │ ├── recycler.json
│ │ │ ├── slaughter_mk1.json
│ │ │ ├── smoker_enhancer.json
│ │ │ ├── solid_infuser.json
│ │ │ └── speed_enhancer.json
│ │ ├── loot_tables/
│ │ │ └── blocks/
│ │ │ ├── biomass_generator_mk3.json
│ │ │ ├── bronze_block.json
│ │ │ ├── cabinet.json
│ │ │ ├── cable_mk1.json
│ │ │ ├── cable_mk2.json
│ │ │ ├── cable_mk3.json
│ │ │ ├── cable_mk4.json
│ │ │ ├── capsule.json
│ │ │ ├── charge_pad_mk4.json
│ │ │ ├── chopper_creative.json
│ │ │ ├── chopper_mk1.json
│ │ │ ├── chopper_mk2.json
│ │ │ ├── chopper_mk3.json
│ │ │ ├── chopper_mk4.json
│ │ │ ├── coal_generator_mk1.json
│ │ │ ├── compressor_creative.json
│ │ │ ├── compressor_factory_mk4.json
│ │ │ ├── compressor_mk1.json
│ │ │ ├── compressor_mk2.json
│ │ │ ├── compressor_mk3.json
│ │ │ ├── compressor_mk4.json
│ │ │ ├── condenser_mk4.json
│ │ │ ├── controller.json
│ │ │ ├── deepslate_lead_ore.json
│ │ │ ├── deepslate_nikolite_ore.json
│ │ │ ├── deepslate_silver_ore.json
│ │ │ ├── deepslate_tin_ore.json
│ │ │ ├── deepslate_tungsten_ore.json
│ │ │ ├── drain_mk1.json
│ │ │ ├── drill_bottom.json
│ │ │ ├── duct.json
│ │ │ ├── electric_furnace_creative.json
│ │ │ ├── electric_furnace_factory_mk4.json
│ │ │ ├── electric_furnace_mk1.json
│ │ │ ├── electric_furnace_mk2.json
│ │ │ ├── electric_furnace_mk3.json
│ │ │ ├── electric_furnace_mk4.json
│ │ │ ├── electrum_block.json
│ │ │ ├── farmer_creative.json
│ │ │ ├── farmer_mk1.json
│ │ │ ├── farmer_mk2.json
│ │ │ ├── farmer_mk3.json
│ │ │ ├── farmer_mk4.json
│ │ │ ├── fisher_mk2.json
│ │ │ ├── fisher_mk3.json
│ │ │ ├── fisher_mk4.json
│ │ │ ├── fluid_infuser_creative.json
│ │ │ ├── fluid_infuser_mk1.json
│ │ │ ├── fluid_infuser_mk2.json
│ │ │ ├── fluid_infuser_mk3.json
│ │ │ ├── fluid_infuser_mk4.json
│ │ │ ├── fluid_pipe_mk1.json
│ │ │ ├── fluid_pipe_mk2.json
│ │ │ ├── fluid_pipe_mk3.json
│ │ │ ├── fluid_pipe_mk4.json
│ │ │ ├── frame.json
│ │ │ ├── heat_generator_mk4.json
│ │ │ ├── intake.json
│ │ │ ├── item_pipe_mk1.json
│ │ │ ├── item_pipe_mk2.json
│ │ │ ├── item_pipe_mk3.json
│ │ │ ├── item_pipe_mk4.json
│ │ │ ├── laser_emitter_mk4.json
│ │ │ ├── lazuli_flux_container_creative.json
│ │ │ ├── lazuli_flux_container_mk1.json
│ │ │ ├── lazuli_flux_container_mk2.json
│ │ │ ├── lazuli_flux_container_mk3.json
│ │ │ ├── lazuli_flux_container_mk4.json
│ │ │ ├── lead_block.json
│ │ │ ├── lead_ore.json
│ │ │ ├── machine_block.json
│ │ │ ├── mining_rig_mk4.json
│ │ │ ├── modular_workbench_mk4.json
│ │ │ ├── nikolite_ore.json
│ │ │ ├── plank_block.json
│ │ │ ├── planks.json
│ │ │ ├── pulverizer_creative.json
│ │ │ ├── pulverizer_factory_mk4.json
│ │ │ ├── pulverizer_mk1.json
│ │ │ ├── pulverizer_mk2.json
│ │ │ ├── pulverizer_mk3.json
│ │ │ ├── pulverizer_mk4.json
│ │ │ ├── pump_mk1.json
│ │ │ ├── rancher_creative.json
│ │ │ ├── rancher_mk1.json
│ │ │ ├── rancher_mk2.json
│ │ │ ├── rancher_mk3.json
│ │ │ ├── rancher_mk4.json
│ │ │ ├── raw_lead_block.json
│ │ │ ├── raw_silver_block.json
│ │ │ ├── raw_tin_block.json
│ │ │ ├── raw_tungsten_block.json
│ │ │ ├── recycler_mk2.json
│ │ │ ├── sawmill_creative.json
│ │ │ ├── sawmill_mk1.json
│ │ │ ├── sawmill_mk2.json
│ │ │ ├── sawmill_mk3.json
│ │ │ ├── sawmill_mk4.json
│ │ │ ├── silo.json
│ │ │ ├── silver_block.json
│ │ │ ├── silver_ore.json
│ │ │ ├── slaughter_creative.json
│ │ │ ├── slaughter_mk1.json
│ │ │ ├── slaughter_mk2.json
│ │ │ ├── slaughter_mk3.json
│ │ │ ├── slaughter_mk4.json
│ │ │ ├── smelter_mk4.json
│ │ │ ├── solar_generator_mk1.json
│ │ │ ├── solar_generator_mk3.json
│ │ │ ├── solid_infuser_creative.json
│ │ │ ├── solid_infuser_factory_mk4.json
│ │ │ ├── solid_infuser_mk1.json
│ │ │ ├── solid_infuser_mk2.json
│ │ │ ├── solid_infuser_mk3.json
│ │ │ ├── solid_infuser_mk4.json
│ │ │ ├── steel_block.json
│ │ │ ├── sulfur_crystal.json
│ │ │ ├── tank.json
│ │ │ ├── tin_block.json
│ │ │ ├── tin_ore.json
│ │ │ ├── tungsten_block.json
│ │ │ ├── tungsten_ore.json
│ │ │ ├── warning_strobe.json
│ │ │ └── wither_proof_obsidian.json
│ │ ├── patchouli_books/
│ │ │ └── indrev/
│ │ │ ├── book.json
│ │ │ ├── en_us/
│ │ │ │ ├── categories/
│ │ │ │ │ ├── enhanced_ore_processing.json
│ │ │ │ │ ├── machines.json
│ │ │ │ │ ├── natural_resources.json
│ │ │ │ │ ├── temperature.json
│ │ │ │ │ ├── tools.json
│ │ │ │ │ ├── transportation.json
│ │ │ │ │ └── upgrades.json
│ │ │ │ └── entries/
│ │ │ │ ├── enhanced_ore_processing/
│ │ │ │ │ ├── doubling.json
│ │ │ │ │ ├── quadrupling.json
│ │ │ │ │ └── tripling.json
│ │ │ │ ├── machines/
│ │ │ │ │ ├── basic_machines.json
│ │ │ │ │ ├── batteries.json
│ │ │ │ │ ├── cables.json
│ │ │ │ │ ├── chopper.json
│ │ │ │ │ ├── factories.json
│ │ │ │ │ ├── farmer.json
│ │ │ │ │ ├── fisher.json
│ │ │ │ │ ├── generators.json
│ │ │ │ │ ├── miner.json
│ │ │ │ │ ├── pump.json
│ │ │ │ │ └── rancher.json
│ │ │ │ ├── natural_resources/
│ │ │ │ │ ├── lead_ore.json
│ │ │ │ │ ├── nikolite_ore.json
│ │ │ │ │ ├── silver_ore.json
│ │ │ │ │ ├── sulfur_crystals.json
│ │ │ │ │ ├── tin_ore.json
│ │ │ │ │ └── tungsten_ore.json
│ │ │ │ ├── temperature/
│ │ │ │ │ ├── coolers_and_fans.json
│ │ │ │ │ └── info.json
│ │ │ │ ├── tools/
│ │ │ │ │ ├── energy_reader.json
│ │ │ │ │ ├── gamer_axe.json
│ │ │ │ │ ├── hammer.json
│ │ │ │ │ ├── mining_drills.json
│ │ │ │ │ ├── modular_armor.json
│ │ │ │ │ ├── modular_core.json
│ │ │ │ │ ├── screwdriver.json
│ │ │ │ │ └── wrench.json
│ │ │ │ ├── transportation/
│ │ │ │ │ ├── energy.json
│ │ │ │ │ ├── fluid_pipes.json
│ │ │ │ │ ├── item_pipes.json
│ │ │ │ │ └── servos.json
│ │ │ │ └── upgrades/
│ │ │ │ ├── enhancement_upgrades.json
│ │ │ │ └── tier_upgrades.json
│ │ │ ├── ru_ru/
│ │ │ │ ├── book.json
│ │ │ │ ├── categories/
│ │ │ │ │ ├── enhanced_ore_processing.json
│ │ │ │ │ ├── machines.json
│ │ │ │ │ ├── natural_resources.json
│ │ │ │ │ ├── temperature.json
│ │ │ │ │ ├── tools.json
│ │ │ │ │ ├── transportation.json
│ │ │ │ │ └── upgrades.json
│ │ │ │ └── entries/
│ │ │ │ ├── enhanced_ore_processing/
│ │ │ │ │ ├── doubling.json
│ │ │ │ │ ├── quadrupling.json
│ │ │ │ │ └── tripling.json
│ │ │ │ ├── machines/
│ │ │ │ │ ├── basic_machines.json
│ │ │ │ │ ├── batteries.json
│ │ │ │ │ ├── cables.json
│ │ │ │ │ ├── chopper.json
│ │ │ │ │ ├── factories.json
│ │ │ │ │ ├── farmer.json
│ │ │ │ │ ├── fisher.json
│ │ │ │ │ ├── generators.json
│ │ │ │ │ ├── miner.json
│ │ │ │ │ ├── pump.json
│ │ │ │ │ └── rancher.json
│ │ │ │ ├── natural_resources/
│ │ │ │ │ ├── lead_ore.json
│ │ │ │ │ ├── nikolite_ore.json
│ │ │ │ │ ├── silver_ore.json
│ │ │ │ │ ├── sulfur_crystals.json
│ │ │ │ │ ├── tin_ore.json
│ │ │ │ │ └── tungsten_ore.json
│ │ │ │ ├── temperature/
│ │ │ │ │ ├── coolers_and_fans.json
│ │ │ │ │ └── info.json
│ │ │ │ ├── tools/
│ │ │ │ │ ├── energy_reader.json
│ │ │ │ │ ├── gamer_axe.json
│ │ │ │ │ ├── hammer.json
│ │ │ │ │ ├── mining_drills.json
│ │ │ │ │ ├── modular_armor.json
│ │ │ │ │ ├── modular_core.json
│ │ │ │ │ ├── screwdriver.json
│ │ │ │ │ └── wrench.json
│ │ │ │ ├── transportation/
│ │ │ │ │ ├── energy.json
│ │ │ │ │ ├── fluid_pipes.json
│ │ │ │ │ ├── item_pipes.json
│ │ │ │ │ └── servos.json
│ │ │ │ └── upgrades/
│ │ │ │ ├── enhancement_upgrades.json
│ │ │ │ └── tier_upgrades.json
│ │ │ └── zh_cn/
│ │ │ ├── categories/
│ │ │ │ ├── enhanced_ore_processing.json
│ │ │ │ ├── machines.json
│ │ │ │ ├── natural_resources.json
│ │ │ │ ├── temperature.json
│ │ │ │ ├── tools.json
│ │ │ │ ├── transportation.json
│ │ │ │ └── upgrades.json
│ │ │ └── entries/
│ │ │ ├── enhanced_ore_processing/
│ │ │ │ ├── doubling.json
│ │ │ │ ├── quadrupling.json
│ │ │ │ └── tripling.json
│ │ │ ├── machines/
│ │ │ │ ├── basic_machines.json
│ │ │ │ ├── batteries.json
│ │ │ │ ├── cables.json
│ │ │ │ ├── chopper.json
│ │ │ │ ├── factories.json
│ │ │ │ ├── farmer.json
│ │ │ │ ├── fisher.json
│ │ │ │ ├── generators.json
│ │ │ │ ├── miner.json
│ │ │ │ ├── pump.json
│ │ │ │ └── rancher.json
│ │ │ ├── natural_resources/
│ │ │ │ ├── lead_ore.json
│ │ │ │ ├── nikolite_ore.json
│ │ │ │ ├── silver_ore.json
│ │ │ │ ├── sulfur_crystals.json
│ │ │ │ ├── tin_ore.json
│ │ │ │ └── tungsten_ore.json
│ │ │ ├── temperature/
│ │ │ │ ├── coolers_and_fans.json
│ │ │ │ └── info.json
│ │ │ ├── tools/
│ │ │ │ ├── energy_reader.json
│ │ │ │ ├── gamer_axe.json
│ │ │ │ ├── hammer.json
│ │ │ │ ├── mining_drills.json
│ │ │ │ ├── modular_armor.json
│ │ │ │ ├── modular_core.json
│ │ │ │ ├── screwdriver.json
│ │ │ │ └── wrench.json
│ │ │ ├── transportation/
│ │ │ │ ├── energy.json
│ │ │ │ ├── fluid_pipes.json
│ │ │ │ ├── item_pipes.json
│ │ │ │ └── servos.json
│ │ │ └── upgrades/
│ │ │ ├── enhancement_upgrades.json
│ │ │ └── tier_upgrades.json
│ │ ├── recipes/
│ │ │ ├── blasting/
│ │ │ │ ├── bronze_ingot_from_smelting.json
│ │ │ │ ├── copper_ingot_from_ore.json
│ │ │ │ ├── copper_ingot_from_smelting.json
│ │ │ │ ├── electrum_ingot_from_smelting.json
│ │ │ │ ├── gold_ingot.json
│ │ │ │ ├── iron_ingot_from_dust.json
│ │ │ │ ├── lead_ingot_from_ore.json
│ │ │ │ ├── lead_ingot_from_raw_ore.json
│ │ │ │ ├── lead_ingot_from_smelting.json
│ │ │ │ ├── netherite_scrap.json
│ │ │ │ ├── silver_ingot_from_ore.json
│ │ │ │ ├── silver_ingot_from_raw_ores.json
│ │ │ │ ├── silver_ingot_from_smelting.json
│ │ │ │ ├── steel_ingot.json
│ │ │ │ ├── tin_ingot_from_ore.json
│ │ │ │ ├── tin_ingot_from_raw_ores.json
│ │ │ │ ├── tin_ingot_from_smelting.json
│ │ │ │ ├── tungsten_ingot_from_ore.json
│ │ │ │ ├── tungsten_ingot_from_raw_ores.json
│ │ │ │ └── tungsten_ingot_from_smelting.json
│ │ │ ├── compressing/
│ │ │ │ ├── bronze_plate_from_compressor.json
│ │ │ │ ├── carbon_fiber_plate.json
│ │ │ │ ├── copper_plate_from_compressor.json
│ │ │ │ ├── electrum_plate_from_compressor.json
│ │ │ │ ├── empty_upgrade.json
│ │ │ │ ├── gold_plate_from_compressor.json
│ │ │ │ ├── iron_plate_from_compressor.json
│ │ │ │ ├── lead_plate_from_compressor.json
│ │ │ │ ├── plank_block.json
│ │ │ │ ├── planks.json
│ │ │ │ ├── silver_plate_from_compressor.json
│ │ │ │ ├── steel_plate.json
│ │ │ │ ├── tin_plate_from_compressor.json
│ │ │ │ └── tungsten_plate_from_compressor.json
│ │ │ ├── condensing/
│ │ │ │ ├── copper_chunk_from_molten_copper.json
│ │ │ │ ├── gold_chunk_from_molten_gold.json
│ │ │ │ ├── iron_chunk_from_molten_iron.json
│ │ │ │ ├── lead_chunk_from_molten_lead.json
│ │ │ │ ├── netherite_chunk_from_molten_netherite.json
│ │ │ │ ├── silver_chunk_from_molten_silver.json
│ │ │ │ └── tin_chunk_from_molten_tin.json
│ │ │ ├── distiller/
│ │ │ │ └── salt_from_water.json
│ │ │ ├── electrolysis/
│ │ │ │ └── electrolyze_water.json
│ │ │ ├── fluid_infusing/
│ │ │ │ ├── clay.json
│ │ │ │ ├── coolant_fluid.json
│ │ │ │ ├── copper_purified_ore.json
│ │ │ │ ├── gold_purified_ore.json
│ │ │ │ ├── harden_black_concrete_powder.json
│ │ │ │ ├── harden_blue_concrete_powder.json
│ │ │ │ ├── harden_brown_concrete_powder.json
│ │ │ │ ├── harden_cyan_concrete_powder.json
│ │ │ │ ├── harden_gray_concrete_powder.json
│ │ │ │ ├── harden_green_concrete_powder.json
│ │ │ │ ├── harden_light_blue_concrete_powder.json
│ │ │ │ ├── harden_light_gray_concrete_powder.json
│ │ │ │ ├── harden_lime_concrete_powder.json
│ │ │ │ ├── harden_magenta_concrete_powder.json
│ │ │ │ ├── harden_orange_concrete_powder.json
│ │ │ │ ├── harden_pink_concrete_powder.json
│ │ │ │ ├── harden_purple_concrete_powder.json
│ │ │ │ ├── harden_red_concrete_powder.json
│ │ │ │ ├── harden_white_concrete_powder.json
│ │ │ │ ├── harden_yellow_concrete_powder.json
│ │ │ │ ├── iron_purified_ore.json
│ │ │ │ ├── lead_purified_ore.json
│ │ │ │ ├── netherite_purified_ore.json
│ │ │ │ ├── paper.json
│ │ │ │ ├── silver_purified_ore.json
│ │ │ │ ├── sulfuric_acid.json
│ │ │ │ ├── tin_purified_ore.json
│ │ │ │ ├── tungsten_purified_ore.json
│ │ │ │ └── wither_proof_obsidian.json
│ │ │ ├── infusing/
│ │ │ │ ├── allium.json
│ │ │ │ ├── azure_bluet.json
│ │ │ │ ├── big_dripleaf.json
│ │ │ │ ├── blue_orchid.json
│ │ │ │ ├── bronze_dust.json
│ │ │ │ ├── brown_mushroom.json
│ │ │ │ ├── cornflower.json
│ │ │ │ ├── crimson_fungus.json
│ │ │ │ ├── crimson_roots.json
│ │ │ │ ├── dandelion.json
│ │ │ │ ├── dead_bush.json
│ │ │ │ ├── electrum_dust.json
│ │ │ │ ├── enriched_nikolite.json
│ │ │ │ ├── enriched_nikolite_ingot.json
│ │ │ │ ├── fern.json
│ │ │ │ ├── glow_lichen.json
│ │ │ │ ├── grass.json
│ │ │ │ ├── kelp.json
│ │ │ │ ├── large_fern.json
│ │ │ │ ├── lilac.json
│ │ │ │ ├── lily_of_the_valley.json
│ │ │ │ ├── lily_pad.json
│ │ │ │ ├── nether_sprouts.json
│ │ │ │ ├── nikolite_ingot.json
│ │ │ │ ├── orange_tulip.json
│ │ │ │ ├── oxeye_daisy.json
│ │ │ │ ├── pink_tulip.json
│ │ │ │ ├── poppy.json
│ │ │ │ ├── red_mushroom.json
│ │ │ │ ├── red_tulip.json
│ │ │ │ ├── sea_pickle.json
│ │ │ │ ├── seagrass.json
│ │ │ │ ├── small_dripleaf.json
│ │ │ │ ├── spore_blossom.json
│ │ │ │ ├── steel_dust.json
│ │ │ │ ├── tall_grass.json
│ │ │ │ ├── twisting_vines.json
│ │ │ │ ├── untanned_leather.json
│ │ │ │ ├── vine.json
│ │ │ │ ├── warped_fungus.json
│ │ │ │ ├── warped_roots.json
│ │ │ │ ├── weeping_vines.json
│ │ │ │ └── white_tulip.json
│ │ │ ├── laser.json
│ │ │ ├── modules/
│ │ │ │ ├── module_auto_feeder.json
│ │ │ │ ├── module_breathing.json
│ │ │ │ ├── module_charger.json
│ │ │ │ ├── module_efficiency.json
│ │ │ │ ├── module_elytra.json
│ │ │ │ ├── module_feather_falling.json
│ │ │ │ ├── module_fire_aspect.json
│ │ │ │ ├── module_fire_resistance.json
│ │ │ │ ├── module_fortune.json
│ │ │ │ ├── module_jump_boost.json
│ │ │ │ ├── module_looting.json
│ │ │ │ ├── module_night_vision.json
│ │ │ │ ├── module_piglin_tricker.json
│ │ │ │ ├── module_protection.json
│ │ │ │ ├── module_range.json
│ │ │ │ ├── module_sharpness.json
│ │ │ │ ├── module_silk_touch.json
│ │ │ │ ├── module_solar_panel.json
│ │ │ │ └── module_speed.json
│ │ │ ├── pulverizer/
│ │ │ │ ├── blaze_power.json
│ │ │ │ ├── bone_meal.json
│ │ │ │ ├── bronze_dust_from_ingot.json
│ │ │ │ ├── coal_dust.json
│ │ │ │ ├── coal_dust_from_ore.json
│ │ │ │ ├── cobblestone_pulverizer.json
│ │ │ │ ├── copper_dust_from_chunk.json
│ │ │ │ ├── copper_dust_from_ingot.json
│ │ │ │ ├── copper_dust_from_ore.json
│ │ │ │ ├── copper_dust_from_purified_ore.json
│ │ │ │ ├── copper_dust_from_raw.json
│ │ │ │ ├── diamond_dust.json
│ │ │ │ ├── diamond_dust_from_ore.json
│ │ │ │ ├── electrum_dust_from_ingot.json
│ │ │ │ ├── gold_dust_from_chunk.json
│ │ │ │ ├── gold_dust_from_ingot.json
│ │ │ │ ├── gold_dust_from_ore.json
│ │ │ │ ├── gold_dust_from_raw.json
│ │ │ │ ├── gravel_pulverizer.json
│ │ │ │ ├── iron_dust_from_chunk.json
│ │ │ │ ├── iron_dust_from_ingot.json
│ │ │ │ ├── iron_dust_from_ore.json
│ │ │ │ ├── iron_dust_from_purified_ore.json
│ │ │ │ ├── iron_dust_from_raw.json
│ │ │ │ ├── lead_dust_from_chunk.json
│ │ │ │ ├── lead_dust_from_ingot.json
│ │ │ │ ├── lead_dust_from_ore.json
│ │ │ │ ├── lead_dust_from_purified_ore.json
│ │ │ │ ├── lead_dust_from_raw.json
│ │ │ │ ├── netherite_dust.json
│ │ │ │ ├── netherite_dust_from_chunk.json
│ │ │ │ ├── nikolite.json
│ │ │ │ ├── sand_pulverizer.json
│ │ │ │ ├── silver_dust_from_chunk.json
│ │ │ │ ├── silver_dust_from_ingot.json
│ │ │ │ ├── silver_dust_from_ore.json
│ │ │ │ ├── silver_dust_from_purified_ore.json
│ │ │ │ ├── silver_dust_from_raw.json
│ │ │ │ ├── sulfur_dust.json
│ │ │ │ ├── sulfur_dust_from_gunpowder.json
│ │ │ │ ├── tin_dust_from_chunk.json
│ │ │ │ ├── tin_dust_from_ingot.json
│ │ │ │ ├── tin_dust_from_ore.json
│ │ │ │ ├── tin_dust_from_purified_ore.json
│ │ │ │ ├── tin_dust_from_raw.json
│ │ │ │ ├── tungsten_dust_from_ingot.json
│ │ │ │ ├── tungsten_dust_from_ore.json
│ │ │ │ └── tungsten_dust_from_purified_ore.json
│ │ │ ├── recycling/
│ │ │ │ ├── recycle_baked_potato.json
│ │ │ │ ├── recycle_bamboo.json
│ │ │ │ ├── recycle_beetroot.json
│ │ │ │ ├── recycle_beetrot_seeds.json
│ │ │ │ ├── recycle_bread.json
│ │ │ │ ├── recycle_brown_mushroom.json
│ │ │ │ ├── recycle_cactus.json
│ │ │ │ ├── recycle_carrot.json
│ │ │ │ ├── recycle_cookie.json
│ │ │ │ ├── recycle_dirt.json
│ │ │ │ ├── recycle_flowers.json
│ │ │ │ ├── recycle_grass.json
│ │ │ │ ├── recycle_grass_block.json
│ │ │ │ ├── recycle_hay_block.json
│ │ │ │ ├── recycle_logs.json
│ │ │ │ ├── recycle_melon.json
│ │ │ │ ├── recycle_melon_seeds.json
│ │ │ │ ├── recycle_melon_slice.json
│ │ │ │ ├── recycle_nether_wart.json
│ │ │ │ ├── recycle_planks.json
│ │ │ │ ├── recycle_potato.json
│ │ │ │ ├── recycle_red_mushroom.json
│ │ │ │ ├── recycle_saplings.json
│ │ │ │ ├── recycle_wheat.json
│ │ │ │ └── recycle_wheat_seeds.json
│ │ │ ├── sawmill/
│ │ │ │ ├── acacia_planks.json
│ │ │ │ ├── birch_planks.json
│ │ │ │ ├── crimson_planks.json
│ │ │ │ ├── dark_oak_planks.json
│ │ │ │ ├── jungle_planks.json
│ │ │ │ ├── oak_planks.json
│ │ │ │ ├── spruce_planks.json
│ │ │ │ └── warped_planks.json
│ │ │ ├── shaped/
│ │ │ │ ├── battery.json
│ │ │ │ ├── biomass_generator_mk3.json
│ │ │ │ ├── blast_furnace_enhancer.json
│ │ │ │ ├── bronze_axe.json
│ │ │ │ ├── bronze_block.json
│ │ │ │ ├── bronze_boots.json
│ │ │ │ ├── bronze_chestplate.json
│ │ │ │ ├── bronze_helmet.json
│ │ │ │ ├── bronze_hoe.json
│ │ │ │ ├── bronze_ingot_from_nugget.json
│ │ │ │ ├── bronze_leggings.json
│ │ │ │ ├── bronze_pickaxe.json
│ │ │ │ ├── bronze_shovel.json
│ │ │ │ ├── bronze_sword.json
│ │ │ │ ├── buffer_enhancer.json
│ │ │ │ ├── cabinet.json
│ │ │ │ ├── cable_mk1.json
│ │ │ │ ├── cable_mk2.json
│ │ │ │ ├── cable_mk3.json
│ │ │ │ ├── cable_mk4.json
│ │ │ │ ├── capsule.json
│ │ │ │ ├── carbon_fiber_boots_frame.json
│ │ │ │ ├── carbon_fiber_chest_frame.json
│ │ │ │ ├── carbon_fiber_helmet_frame.json
│ │ │ │ ├── carbon_fiber_legs_frame.json
│ │ │ │ ├── carbon_fiber_rod.json
│ │ │ │ ├── charge_pad_mk4.json
│ │ │ │ ├── chopper_mk1.json
│ │ │ │ ├── circuit_mk1.json
│ │ │ │ ├── circuit_mk2.json
│ │ │ │ ├── circuit_mk3.json
│ │ │ │ ├── circuit_mk4.json
│ │ │ │ ├── coal_generator_mk1.json
│ │ │ │ ├── compressor_factory_mk4.json
│ │ │ │ ├── compressor_mk1.json
│ │ │ │ ├── condenser_mk4.json
│ │ │ │ ├── controller.json
│ │ │ │ ├── cooler_cell.json
│ │ │ │ ├── copper_axe.json
│ │ │ │ ├── copper_boots.json
│ │ │ │ ├── copper_chestplate.json
│ │ │ │ ├── copper_helmet.json
│ │ │ │ ├── copper_hoe.json
│ │ │ │ ├── copper_ingot_from_nuggets.json
│ │ │ │ ├── copper_leggings.json
│ │ │ │ ├── copper_pickaxe.json
│ │ │ │ ├── copper_shovel.json
│ │ │ │ ├── copper_sword.json
│ │ │ │ ├── damage_upgrade.json
│ │ │ │ ├── data_card_writer_mk4.json
│ │ │ │ ├── diamond_drill_head.json
│ │ │ │ ├── drain_mk1.json
│ │ │ │ ├── drill_bottom.json
│ │ │ │ ├── duct.json
│ │ │ │ ├── electric_furnace_factory_mk4.json
│ │ │ │ ├── electric_furnace_mk1.json
│ │ │ │ ├── electrum_block.json
│ │ │ │ ├── electrum_block_from_nugget.json
│ │ │ │ ├── energy_reader.json
│ │ │ │ ├── fan.json
│ │ │ │ ├── farmer_mk1.json
│ │ │ │ ├── fisher_mk2.json
│ │ │ │ ├── fisher_mk3.json
│ │ │ │ ├── fisher_mk4.json
│ │ │ │ ├── fluid_infuser_mk1.json
│ │ │ │ ├── fluid_pipe_mk1.json
│ │ │ │ ├── fluid_pipe_mk2.json
│ │ │ │ ├── fluid_pipe_mk3.json
│ │ │ │ ├── fluid_pipe_mk4.json
│ │ │ │ ├── frame.json
│ │ │ │ ├── gamer_axe.json
│ │ │ │ ├── hammer.json
│ │ │ │ ├── heat_coil.json
│ │ │ │ ├── heat_generator.json
│ │ │ │ ├── heatsink.json
│ │ │ │ ├── intake.json
│ │ │ │ ├── iron_drill_head.json
│ │ │ │ ├── item_pipe_mk1.json
│ │ │ │ ├── item_pipe_mk2.json
│ │ │ │ ├── item_pipe_mk3.json
│ │ │ │ ├── item_pipe_mk4.json
│ │ │ │ ├── laser_emitter_mk4.json
│ │ │ │ ├── lazuli_flux_container_mk1.json
│ │ │ │ ├── lazuli_flux_container_mk2.json
│ │ │ │ ├── lazuli_flux_container_mk3.json
│ │ │ │ ├── lazuli_flux_container_mk4.json
│ │ │ │ ├── lead_axe.json
│ │ │ │ ├── lead_block.json
│ │ │ │ ├── lead_boots.json
│ │ │ │ ├── lead_chestplate.json
│ │ │ │ ├── lead_helmet.json
│ │ │ │ ├── lead_hoe.json
│ │ │ │ ├── lead_ingot_from_nuggets.json
│ │ │ │ ├── lead_leggings.json
│ │ │ │ ├── lead_pickaxe.json
│ │ │ │ ├── lead_shovel.json
│ │ │ │ ├── lead_sword.json
│ │ │ │ ├── machine_block.json
│ │ │ │ ├── mining_drill_mk1.json
│ │ │ │ ├── mining_drill_mk2.json
│ │ │ │ ├── mining_drill_mk3.json
│ │ │ │ ├── mining_drill_mk4.json
│ │ │ │ ├── mining_rig_mk4.json
│ │ │ │ ├── modular_armor_boots.json
│ │ │ │ ├── modular_armor_chest.json
│ │ │ │ ├── modular_armor_helmet.json
│ │ │ │ ├── modular_armor_legs.json
│ │ │ │ ├── modular_core.json
│ │ │ │ ├── modular_workbench.json
│ │ │ │ ├── netherite_drill_head.json
│ │ │ │ ├── ore_data_card.json
│ │ │ │ ├── paper.json
│ │ │ │ ├── portable_charger.json
│ │ │ │ ├── pulverizer_factory_mk4.json
│ │ │ │ ├── pulverizer_mk1.json
│ │ │ │ ├── pump_mk1.json
│ │ │ │ ├── rancher_mk1.json
│ │ │ │ ├── raw_lead_block.json
│ │ │ │ ├── raw_silver_block.json
│ │ │ │ ├── raw_tin_block.json
│ │ │ │ ├── raw_tungsten_block.json
│ │ │ │ ├── recycler_mk2.json
│ │ │ │ ├── reinforced_elytra.json
│ │ │ │ ├── sawmill_mk1.json
│ │ │ │ ├── screwdriver.json
│ │ │ │ ├── servo_output.json
│ │ │ │ ├── servo_retriever.json
│ │ │ │ ├── silo.json
│ │ │ │ ├── silver_axe.json
│ │ │ │ ├── silver_block.json
│ │ │ │ ├── silver_boots.json
│ │ │ │ ├── silver_chestplate.json
│ │ │ │ ├── silver_helmet.json
│ │ │ │ ├── silver_hoe.json
│ │ │ │ ├── silver_ingot_from_nuggets.json
│ │ │ │ ├── silver_leggings.json
│ │ │ │ ├── silver_pickaxe.json
│ │ │ │ ├── silver_shovel.json
│ │ │ │ ├── silver_sword.json
│ │ │ │ ├── slaughter_mk1.json
│ │ │ │ ├── smelter_mk4.json
│ │ │ │ ├── smoker_enhancer.json
│ │ │ │ ├── solar_generator_mk1.json
│ │ │ │ ├── solar_generator_mk3.json
│ │ │ │ ├── solid_infuser_factory_mk4.json
│ │ │ │ ├── solid_infuser_mk1.json
│ │ │ │ ├── speed_enhancer.json
│ │ │ │ ├── steel_axe.json
│ │ │ │ ├── steel_block.json
│ │ │ │ ├── steel_boots.json
│ │ │ │ ├── steel_chestplate.json
│ │ │ │ ├── steel_helmet.json
│ │ │ │ ├── steel_hoe.json
│ │ │ │ ├── steel_ingot_from_nuggets.json
│ │ │ │ ├── steel_leggings.json
│ │ │ │ ├── steel_pickaxe.json
│ │ │ │ ├── steel_shovel.json
│ │ │ │ ├── steel_sword.json
│ │ │ │ ├── stone_drill_head.json
│ │ │ │ ├── tank.json
│ │ │ │ ├── tier_upgrade_mk2.json
│ │ │ │ ├── tier_upgrade_mk3.json
│ │ │ │ ├── tier_upgrade_mk4.json
│ │ │ │ ├── tin_axe.json
│ │ │ │ ├── tin_block.json
│ │ │ │ ├── tin_boots.json
│ │ │ │ ├── tin_chestplate.json
│ │ │ │ ├── tin_helmet.json
│ │ │ │ ├── tin_hoe.json
│ │ │ │ ├── tin_ingot_from_nuggets.json
│ │ │ │ ├── tin_leggings.json
│ │ │ │ ├── tin_pickaxe.json
│ │ │ │ ├── tin_shovel.json
│ │ │ │ ├── tin_sword.json
│ │ │ │ ├── tungsten_block.json
│ │ │ │ ├── tungsten_ingot_from_nuggets.json
│ │ │ │ ├── warning_strobe.json
│ │ │ │ └── wrench.json
│ │ │ ├── shapeless/
│ │ │ │ ├── bronze_ingot_from_block.json
│ │ │ │ ├── bronze_nugget.json
│ │ │ │ ├── copper_ingot_from_block.json
│ │ │ │ ├── copper_nugget.json
│ │ │ │ ├── copper_plate_from_hammer.json
│ │ │ │ ├── electrum_ingot_from_block.json
│ │ │ │ ├── electrum_nugget.json
│ │ │ │ ├── gold_plate_from_hammer.json
│ │ │ │ ├── guide_book.json
│ │ │ │ ├── iron_plate_from_hammer.json
│ │ │ │ ├── lead_ingot_from_block.json
│ │ │ │ ├── lead_nugget.json
│ │ │ │ ├── planks.json
│ │ │ │ ├── raw_lead.json
│ │ │ │ ├── raw_silver.json
│ │ │ │ ├── raw_tin.json
│ │ │ │ ├── raw_tungsten.json
│ │ │ │ ├── silver_ingot_from_block.json
│ │ │ │ ├── silver_nugget.json
│ │ │ │ ├── steel_ingot_from_block.json
│ │ │ │ ├── steel_nugget.json
│ │ │ │ ├── tin_ingot_from_block.json
│ │ │ │ ├── tin_nugget.json
│ │ │ │ ├── tin_plate_from_hammer.json
│ │ │ │ ├── tungsten_ingot_from_block.json
│ │ │ │ └── tungsten_nugget.json
│ │ │ ├── smelter/
│ │ │ │ ├── molten_copper_from_block.json
│ │ │ │ ├── molten_copper_from_dust.json
│ │ │ │ ├── molten_copper_from_ingot.json
│ │ │ │ ├── molten_copper_from_nugget.json
│ │ │ │ ├── molten_copper_from_ore.json
│ │ │ │ ├── molten_copper_from_purified_ore.json
│ │ │ │ ├── molten_gold_from_block.json
│ │ │ │ ├── molten_gold_from_dust.json
│ │ │ │ ├── molten_gold_from_ingot.json
│ │ │ │ ├── molten_gold_from_nugget.json
│ │ │ │ ├── molten_gold_from_ore.json
│ │ │ │ ├── molten_gold_from_purified_ore.json
│ │ │ │ ├── molten_iron_from_block.json
│ │ │ │ ├── molten_iron_from_dust.json
│ │ │ │ ├── molten_iron_from_ingot.json
│ │ │ │ ├── molten_iron_from_nugget.json
│ │ │ │ ├── molten_iron_from_ore.json
│ │ │ │ ├── molten_iron_from_purified_ore.json
│ │ │ │ ├── molten_lead_from_block.json
│ │ │ │ ├── molten_lead_from_dust.json
│ │ │ │ ├── molten_lead_from_ingot.json
│ │ │ │ ├── molten_lead_from_nugget.json
│ │ │ │ ├── molten_lead_from_ore.json
│ │ │ │ ├── molten_lead_from_purified_ore.json
│ │ │ │ ├── molten_netherite_from_dust.json
│ │ │ │ ├── molten_netherite_from_ore.json
│ │ │ │ ├── molten_netherite_from_purified_ore.json
│ │ │ │ ├── molten_silver_from_block.json
│ │ │ │ ├── molten_silver_from_dust.json
│ │ │ │ ├── molten_silver_from_ingot.json
│ │ │ │ ├── molten_silver_from_nugget.json
│ │ │ │ ├── molten_silver_from_ore.json
│ │ │ │ ├── molten_silver_from_purified_ore.json
│ │ │ │ ├── molten_tin_from_block.json
│ │ │ │ ├── molten_tin_from_dust.json
│ │ │ │ ├── molten_tin_from_ingot.json
│ │ │ │ ├── molten_tin_from_nugget.json
│ │ │ │ ├── molten_tin_from_ore.json
│ │ │ │ └── molten_tin_from_purified_ore.json
│ │ │ ├── smelting/
│ │ │ │ ├── bronze_ingot_from_smelting.json
│ │ │ │ ├── copper_ingot_from_smelting.json
│ │ │ │ ├── electrum_ingot_from_smelting.json
│ │ │ │ ├── gold_ingot.json
│ │ │ │ ├── iron_ingot_from_dust.json
│ │ │ │ ├── lead_ingot_from_ore.json
│ │ │ │ ├── lead_ingot_from_raw_ore.json
│ │ │ │ ├── lead_ingot_from_smelting.json
│ │ │ │ ├── leather.json
│ │ │ │ ├── netherite_scrap.json
│ │ │ │ ├── silver_ingot_from_ore.json
│ │ │ │ ├── silver_ingot_from_raw_ores.json
│ │ │ │ ├── silver_ingot_from_smelting.json
│ │ │ │ ├── steel_ingot.json
│ │ │ │ ├── tin_ingot_from_ore.json
│ │ │ │ ├── tin_ingot_from_raw_ores.json
│ │ │ │ ├── tin_ingot_from_smelting.json
│ │ │ │ ├── tungsten_ingot_from_ore.json
│ │ │ │ ├── tungsten_ingot_from_raw_ores.json
│ │ │ │ └── tungsten_ingot_from_smelting.json
│ │ │ └── upgrade/
│ │ │ ├── chopper_mk1_to_mk2.json
│ │ │ ├── chopper_mk2_to_mk3.json
│ │ │ ├── chopper_mk3_to_mk4.json
│ │ │ ├── compressor_mk1_to_mk2.json
│ │ │ ├── compressor_mk2_to_mk3.json
│ │ │ ├── compressor_mk3_to_mk4.json
│ │ │ ├── electric_furnace_mk1_to_mk2.json
│ │ │ ├── electric_furnace_mk2_to_mk3.json
│ │ │ ├── electric_furnace_mk3_to_mk4.json
│ │ │ ├── electrolytic_separator_mk1_to_mk2.json
│ │ │ ├── electrolytic_separator_mk2_to_mk3.json
│ │ │ ├── electrolytic_separator_mk3_to_mk4.json
│ │ │ ├── farmer_mk1_to_mk2.json
│ │ │ ├── farmer_mk2_to_mk3.json
│ │ │ ├── farmer_mk3_to_mk4.json
│ │ │ ├── fluid_infuser_mk1_to_mk2.json
│ │ │ ├── fluid_infuser_mk2_to_mk3.json
│ │ │ ├── fluid_infuser_mk3_to_mk4.json
│ │ │ ├── pulverizer_mk1_to_mk2.json
│ │ │ ├── pulverizer_mk2_to_mk3.json
│ │ │ ├── pulverizer_mk3_to_mk4.json
│ │ │ ├── rancher_mk1_to_mk2.json
│ │ │ ├── rancher_mk2_to_mk3.json
│ │ │ ├── rancher_mk3_to_mk4.json
│ │ │ ├── sawmill_mk1_to_mk2.json
│ │ │ ├── sawmill_mk2_to_mk3.json
│ │ │ ├── sawmill_mk3_to_mk4.json
│ │ │ ├── slaughter_mk1_to_mk2.json
│ │ │ ├── slaughter_mk2_to_mk3.json
│ │ │ ├── slaughter_mk3_to_mk4.json
│ │ │ ├── solid_infuser_mk1_to_mk2.json
│ │ │ ├── solid_infuser_mk2_to_mk3.json
│ │ │ └── solid_infuser_mk3_to_mk4.json
│ │ └── tags/
│ │ └── items/
│ │ └── coolers.json
│ └── minecraft/
│ └── tags/
│ ├── blocks/
│ │ ├── mineable/
│ │ │ ├── axe.json
│ │ │ └── pickaxe.json
│ │ └── wither_immune.json
│ └── fluids/
│ ├── lava.json
│ └── water.json
├── fabric.mod.json
├── indrev.accesswidener
└── indrev.mixins.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE/bugs.md
================================================
---
name: Bug report
about: Something isn't working right
title: '[BUG] '
labels: bug
assignees: ''
---
**Description:**
- Give a detailed explanation of the issue
**Steps to Reproduce:**
- Steps to reproduce this behaviour
**Technical Information:**
- Minecraft:
- Fabric API:
- Industrial Revolution:
- Modpack:
**Logs:**
- Use a paste service, do not paste the logs directly here.
**Details:**
Extra information that might be helpful like screenshots or technical information about your computer.
================================================
FILE: .github/ISSUE_TEMPLATE/requests.md
================================================
---
name: Request
about: I have a really cool idea!
title: '[REQUEST] '
labels: enhancement
assignees: ''
---
**Description:**
- Describe your suggestion with as many details as possible.
**Reason:**
- Why do you think your suggestion should be added?
================================================
FILE: .gitignore
================================================
# gradle
.gradle/
build/
out/
# idea
.idea/
*.iml
*.ipr
*.iws
# fabric
run/
================================================
FILE: LICENSE.txt
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================

Industrial Revolution
An Industrial mod made for Fabric.
## Features
For a complete list of features please check the mods [official page](https://www.curseforge.com/minecraft/mc-mods/industrial-revolution)
## License
Distributed under the Apache License, Version 2.0. See `LICENSE` for more information.
## Build
If you want to build this yourself, please clone the repository and execute `gradlew build` in the projects folder.
Artifacts will be generated at `/build/libs`
================================================
FILE: build.gradle
================================================
plugins {
id "fabric-loom"
id "maven-publish"
id "org.jetbrains.kotlin.jvm"
}
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
maven {
name = "Modmuss50"
url = "https://maven.modmuss50.me/"
content {
includeGroup "RebornCore"
includeGroup "TechReborn"
includeGroup "teamreborn"
}
}
maven {
url "https://maven.shedaniel.me/"
content {
includeGroup "dev.architectury"
includeGroup "me.shedaniel"
includeGroup "me.shedaniel.cloth"
includeGroup "me.shedaniel.cloth.api"
}
}
maven {
url = "https://maven.fabricmc.net/"
content {
includeGroup "net.fabricmc"
}
}
maven {
name = "BuildCraft"
url = "https://mod-buildcraft.com/maven"
content {
includeGroup "alexiil.mc.lib"
}
}
maven {
name = "CottonMC"
url = "https://server.bbkr.space/artifactory/libs-release"
content {
includeGroup "io.github.cottonmc"
}
}
maven {
url = "https://maven.terraformersmc.com/releases/"
content {
includeGroup "com.terraformersmc"
}
}
maven {
name = "Patchouli"
url = "https://maven.blamejared.com"
content {
includeGroup "vazkii.patchouli"
}
}
maven {
url = "https://jitpack.io"
content {
includeGroup "com.github.Technici4n"
includeGroup "com.github.Draylar"
includeGroup "com.github.Draylar.omega-config"
includeGroup "com.github.emilyploszaj"
}
}
maven {
url "https://oskarstrom.net/maven"
content {
includeGroup "net.oskarstrom"
}
}
maven {
name = "Cafeteria Development"
url = 'https://maven.cafeteria.dev'
content {
includeGroup 'dev.cafeteria'
includeGroup 'me.luligabi'
includeGroup 'net.adriantodt.fabricmc'
}
}
maven {
name = 'Ladysnake Mods'
url = 'https://ladysnake.jfrog.io/artifactory/mods'
content {
includeGroup 'io.github.ladysnake'
includeGroupByRegex 'io\\.github\\.onyxstudios.*'
}
}
}
dependencies {
dependencies.ext.lib = { dep, optional = false ->
modImplementation(dep) {
exclude group: "net.fabricmc.fabric-api"
exclude group: "com.jamieswhiteshirt"
exclude group: "io.github.prospector"
}
if (!optional) {
include(dep) {
exclude group: "net.fabricmc.fabric-api"
exclude group: "com.jamieswhiteshirt"
exclude group: "io.github.prospector"
}
}
}
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
dependencies.ext.lib("teamreborn:energy:${project.tr_energy_version}")
dependencies.ext.lib("io.github.cottonmc:LibGui:${project.libgui_version}")
dependencies.ext.lib("vazkii.patchouli:Patchouli:${project.patchouli_version}")
dependencies.ext.lib("alexiil.mc.lib:libblockattributes-core:${project.lba_version}")
dependencies.ext.lib("alexiil.mc.lib:libblockattributes-fluids:${project.lba_version}")
dependencies.ext.lib("alexiil.mc.lib:libblockattributes-items:${project.lba_version}")
dependencies.ext.lib("com.github.Draylar:magna:${project.magna_version}")
dependencies.ext.lib("com.github.emilyploszaj:step-height-entity-attribute:v1.0.1")
dependencies.ext.lib("dev.cafeteria:fake-player-api:${project.fakeplayerapi_version}")
dependencies.ext.lib("me.luligabi:NoIndium:1.0")
dependencies.ext.lib("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}", true)
modRuntimeOnly("com.terraformersmc:modmenu:${project.modmenu_version}") {
exclude group: "net.fabricmc.fabric-api", module: "fabric-api"
}
// DashLoader Stuff
modCompileOnly("net.oskarstrom:DashLoader:2.0-dev12")
dependencies.ext.lib("io.activej:activej-serializer:${project.activej_version}", true)
modRuntimeOnly("org.yaml:snakeyaml:1.27")
}
loom {
accessWidenerPath = file("src/main/resources/indrev.accesswidener")
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
it.options.encoding = "UTF-8"
it.options.release = 16
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
exclude("me/steven/indrev/datagen")
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
// select the repositories you want to publish to
repositories {
maven {
url "https://maven.cafeteria.dev/releases"
credentials {
username = project.property("mcdUsername")
password = project.property("mcdPassword")
}
authentication {
basic(BasicAuthentication)
}
}
}
}
compileKotlin.kotlinOptions.jvmTarget = "16"
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
================================================
FILE: gradle.properties
================================================
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.13.3
#Fabric api
fabric_version=0.51.1+1.18.2
loom_version=0.11-SNAPSHOT
# Mod Properties
mod_version=1.14.0-BETA
maven_group=me.steven
archives_base_name=indrev
# Kotlin
kotlin_version=1.6.20
fabric_kotlin_version=1.7.2+kotlin.1.6.20
# LibGui
libgui_version=5.3.2+1.18.2
# Mod Menu
modmenu_version=3.1.0
# Roughly Enough Items
rei_version=8.0.442
# Patchouli
patchouli_version=1.18.2-66-FABRIC
# LBA
lba_version=0.10.0
# Magna
magna_version=1.7.0-1.18
# TR Energy
tr_energy_version=2.0.0-beta1
# Fake Player API
fakeplayerapi_version=0.3.0
# ActiveJ
activej_version=4.3
================================================
FILE: gradlew
================================================
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
================================================
FILE: gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: settings.gradle
================================================
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
plugins {
id 'fabric-loom' version loom_version
id "org.jetbrains.kotlin.jvm" version kotlin_version
}
}
================================================
FILE: src/main/java/me/steven/indrev/AprilFools.java
================================================
package me.steven.indrev;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.minecraft.util.registry.Registry;
import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
@Environment(EnvType.CLIENT)
public final class AprilFools {
private static final File CHECK =
new File(FabricLoader.getInstance().getGameDir().toString(), ".indrev_" + LocalDate.now().getYear());
public static void init() {
if (isToday()) {
ItemTooltipCallback.EVENT.register((itemStack, tooltipContext, list) -> {
String itemNamespace = Registry.ITEM.getId(itemStack.getItem()).getNamespace();
if (itemNamespace.equals(IndustrialRevolution.MOD_ID) && list.size() > 1) {
list.add(new LiteralText("")); // break line
list.add(new LiteralText("every good modpack uses forge...").formatted(Formatting.ITALIC));
}
});
try { CHECK.createNewFile(); }
catch (IOException ex) { ex.printStackTrace(); }
}
}
public static boolean isToday() {
return false;
/*LocalDate now = LocalDate.now();
return now.getDayOfMonth() == 1 && now.getMonthValue() == 4 && !CHECK.exists();*/
}
}
================================================
FILE: src/main/java/me/steven/indrev/FabricRecipeRemainder.java
================================================
package me.steven.indrev;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
public interface FabricRecipeRemainder {
ItemStack getRemainder(ItemStack stack, CraftingInventory craftingInventory, PlayerEntity playerEntity);
}
================================================
FILE: src/main/java/me/steven/indrev/IREnergyStorage.java
================================================
package me.steven.indrev;
import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
import net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant;
import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.Nullable;
import team.reborn.energy.api.EnergyStorage;
/**
* Copied from SimpleSidedEnergyContainer and modified to fit IR's needs
*/
public abstract class IREnergyStorage extends SnapshotParticipant {
private final SideStorage[] sideStorages = new SideStorage[7];
public IREnergyStorage() {
for (int i = 0; i < 7; ++i) {
sideStorages[i] = new SideStorage(i == 6 ? null : Direction.byId(i));
}
}
/**
* @return The current capacity of this storage.
*/
public abstract long getCapacity();
/**
* @return The maximum amount of energy that can be inserted in a single operation from the passed side.
*/
public abstract long getMaxInsert(@Nullable Direction side);
/**
* @return The maximum amount of energy that can be extracted in a single operation from the passed side.
*/
public abstract long getMaxExtract(@Nullable Direction side);
/**
* @return An {@link EnergyStorage} implementation for the passed side.
*/
public EnergyStorage getSideStorage(@Nullable Direction side) {
return sideStorages[side == null ? 6 : side.getId()];
}
public long getAmount() {
return 0;
}
public void setAmount(long v) {
}
@Override
protected Long createSnapshot() {
return getAmount();
}
@Override
protected void readSnapshot(Long snapshot) {
setAmount(snapshot);
}
private class SideStorage implements EnergyStorage {
private final Direction side;
private SideStorage(Direction side) {
this.side = side;
}
@Override
public boolean supportsInsertion() {
return getMaxInsert(side) > 0;
}
@Override
public long insert(long maxAmount, TransactionContext transaction) {
StoragePreconditions.notNegative(maxAmount);
long inserted = Math.min(getMaxInsert(side), Math.min(maxAmount, getCapacity() - getAmount()));
if (inserted > 0) {
updateSnapshots(transaction);
setAmount(getAmount() + inserted);
return inserted;
}
return 0;
}
@Override
public boolean supportsExtraction() {
return getMaxExtract(side) > 0;
}
@Override
public long extract(long maxAmount, TransactionContext transaction) {
StoragePreconditions.notNegative(maxAmount);
long extracted = Math.min(getMaxExtract(side), Math.min(maxAmount, getAmount()));
if (extracted > 0) {
updateSnapshots(transaction);
setAmount(getAmount() - extracted);
return extracted;
}
return 0;
}
@Override
public long getAmount() {
return IREnergyStorage.this.getAmount();
}
@Override
public long getCapacity() {
return IREnergyStorage.this.getCapacity();
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/WCustomTabPanel.java
================================================
/*
Original code by Juuxel, part of https://github.com/CottonMC/LibGui
MIT License
Copyright (c) 2018 The Cotton Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package me.steven.indrev;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
import io.github.cottonmc.cotton.gui.client.LibGui;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
import io.github.cottonmc.cotton.gui.widget.*;
import io.github.cottonmc.cotton.gui.widget.data.Axis;
import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
import io.github.cottonmc.cotton.gui.widget.data.InputResult;
import io.github.cottonmc.cotton.gui.widget.icon.Icon;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.function.Consumer;
public class WCustomTabPanel extends WPanel {
private static final int TAB_PADDING = 4;
private static final int TAB_WIDTH = 28;
private static final int TAB_HEIGHT = 25;
private static final int PANEL_PADDING = 8; // The padding of BackgroundPainter.VANILLA
private static final int ICON_SIZE = 16;
private final WBox tabRibbon = new WBox(Axis.HORIZONTAL).setSpacing(1);
private final List tabWidgets = new ArrayList<>();
private final WCardPanel mainPanel = new WCardPanel();
/**
* Constructs a new tab panel.
*/
public WCustomTabPanel() {
add(tabRibbon, 0, 0);
add(mainPanel, PANEL_PADDING, TAB_HEIGHT + PANEL_PADDING);
}
public void add(WWidget widget, int x, int y) {
children.add(widget);
widget.setParent(this);
widget.setLocation(x, y);
expandToFit(widget);
}
@Override
public WPanel setBackgroundPainter(BackgroundPainter painter) {
return super.setBackgroundPainter(
BackgroundPainter.createLightDarkVariants(
BackgroundPainter.createNinePatch(new Identifier("libgui", "textures/widget/panel_light.png")).setPadding(0).setTopPadding(-25),
BackgroundPainter.createNinePatch(new Identifier("libgui", "textures/widget/panel_dark.png")).setPadding(8).setTopPadding(-25)
));
}
// dont bother it's just bad code ik
public WPanel setForceBackgroundPainter(BackgroundPainter painter) {
return super.setBackgroundPainter(painter);
}
/**
* Adds a tab to this panel.
*
* @param tab the added tab
*/
public void add(WCustomTabPanel.Tab tab) {
WTab tabWidget = new WTab(tab);
if (tabWidgets.isEmpty()) {
tabWidget.selected = true;
}
tabWidgets.add(tabWidget);
tabRibbon.add(tabWidget, TAB_WIDTH, TAB_HEIGHT + TAB_PADDING);
mainPanel.add(tab.getWidget());
}
/**
* Configures and adds a tab to this panel.
*
* @param widget the contained widget
* @param configurator the tab configurator
*/
public void add(WWidget widget, Consumer configurator) {
WCustomTabPanel.Tab.Builder builder = new WCustomTabPanel.Tab.Builder(widget);
configurator.accept(builder);
add(builder.build());
}
@Override
public void setSize(int x, int y) {
super.setSize(x, y);
tabRibbon.setSize(x, TAB_HEIGHT);
}
@Environment(EnvType.CLIENT)
@Override
public void addPainters() {
super.addPainters();
}
/**
* The data of a tab.
*/
public static class Tab {
private final Text title;
private final Icon icon;
private final WWidget widget;
private final Consumer tooltip;
/**
* Constructs a tab.
*
* @param title the tab title
* @param icon the tab icon
* @param widget the widget contained in the tab
* @param tooltip the tab tooltip
* @throws IllegalArgumentException if both the title and the icon are null
* @throws NullPointerException if either the widget or the tooltip is null
*/
public Tab(Text title, Icon icon, WWidget widget, Consumer tooltip) {
if (title == null && icon == null) {
throw new IllegalArgumentException("A tab must have a title or an icon");
}
this.title = title;
this.icon = icon;
this.widget = Objects.requireNonNull(widget, "widget");
this.tooltip = tooltip;
}
/**
* Gets the title of this tab.
*
* @return the title, or null if there's no title
*/
public Text getTitle() {
return title;
}
/**
* Gets the icon of this tab.
*
* @return the icon, or null if there's no title
*/
public Icon getIcon() {
return icon;
}
/**
* Gets the contained widget of this tab.
*
* @return the contained widget
*/
public WWidget getWidget() {
return widget;
}
/**
* Adds this widget's tooltip to the {@code tooltip} builder.
*
* @param tooltip the tooltip builder
*/
public void addTooltip(TooltipBuilder tooltip) {
if (this.tooltip != null)
this.tooltip.accept(tooltip);
}
/**
* A builder for tab data.
*/
public static final class Builder {
@Nullable
private Text title;
@Nullable
private Icon icon;
private final WWidget widget;
private final List tooltip = new ArrayList<>();
/**
* Constructs a new tab data builder.
*
* @param widget the contained widget
* @throws NullPointerException if the widget is null
*/
public Builder(WWidget widget) {
this.widget = Objects.requireNonNull(widget, "widget");
}
/**
* Sets the tab title.
*
* @param title the new title
* @return this builder
* @throws NullPointerException if the title is null
*/
public Builder title(Text title) {
this.title = Objects.requireNonNull(title, "title");
return this;
}
/**
* Sets the tab icon.
*
* @param icon the new icon
* @return this builder
* @throws NullPointerException if the icon is null
*/
public Builder icon(Icon icon) {
this.icon = Objects.requireNonNull(icon, "icon");
return this;
}
/**
* Adds lines to the tab's tooltip.
*
* @param lines the added lines
* @return this builder
* @throws NullPointerException if the line array is null
*/
public Builder tooltip(Text... lines) {
Objects.requireNonNull(lines, "lines");
Collections.addAll(tooltip, lines);
return this;
}
/**
* Adds lines to the tab's tooltip.
*
* @param lines the added lines
* @return this builder
* @throws NullPointerException if the line collection is null
*/
public Builder tooltip(Collection extends Text> lines) {
Objects.requireNonNull(lines, "lines");
tooltip.addAll(lines);
return this;
}
/**
* Builds a tab from this builder.
*
* @return the built tab
*/
public Tab build() {
Consumer tooltip = null;
if (!this.tooltip.isEmpty()) {
//noinspection Convert2Lambda
tooltip = new Consumer() {
@Environment(EnvType.CLIENT)
@Override
public void accept(TooltipBuilder builder) {
builder.add(WCustomTabPanel.Tab.Builder.this.tooltip.toArray(new Text[0]));
}
};
}
return new Tab(title, icon, widget, tooltip);
}
}
}
private final class WTab extends WWidget {
private final WCustomTabPanel.Tab data;
boolean selected = false;
WTab(WCustomTabPanel.Tab data) {
this.data = data;
}
@Override
public boolean canFocus() {
return true;
}
@Environment(EnvType.CLIENT)
@Override
public InputResult onClick(int x, int y, int button) {
super.onClick(x, y, button);
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
for (WTab tab : tabWidgets) {
tab.selected = (tab == this);
}
mainPanel.setSelectedCard(data.getWidget());
WCustomTabPanel.this.layout();
return InputResult.PROCESSED;
}
@Environment(EnvType.CLIENT)
@Override
public void onKeyPressed(int ch, int key, int modifiers) {
if (isActivationKey(ch)) {
onClick(0, 0, 0);
}
}
@Environment(EnvType.CLIENT)
@Override
public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
TextRenderer renderer = MinecraftClient.getInstance().textRenderer;
Text title = data.getTitle();
Icon icon = data.getIcon();
if (title != null) {
int width = TAB_WIDTH + renderer.getWidth(title);
if (icon == null) width = Math.max(TAB_WIDTH, width - ICON_SIZE);
if (this.width != width) {
setSize(width, this.height);
getParent().layout();
}
}
(selected ? WCustomTabPanel.Painters.SELECTED_TAB : WCustomTabPanel.Painters.UNSELECTED_TAB).paintBackground(matrices, x, y, this);
if (isFocused()) {
(selected ? WCustomTabPanel.Painters.SELECTED_TAB_FOCUS_BORDER : Painters.UNSELECTED_TAB_FOCUS_BORDER).paintBackground(matrices, x, y, this);
}
int iconX = 6;
if (title != null) {
int titleX = (icon != null) ? iconX + ICON_SIZE + 1 : 0;
int titleY = (height - TAB_PADDING - renderer.fontHeight) / 2 + 1;
int width = (icon != null) ? this.width - iconX - ICON_SIZE : this.width;
HorizontalAlignment align = (icon != null) ? HorizontalAlignment.LEFT : HorizontalAlignment.CENTER;
int color;
if (LibGui.isDarkMode()) {
color = WLabel.DEFAULT_DARKMODE_TEXT_COLOR;
} else {
color = selected ? WLabel.DEFAULT_TEXT_COLOR : 0xEEEEEE;
}
ScreenDrawing.drawString(matrices, title.asOrderedText(), align, x + titleX, y + titleY, width, color);
}
if (icon != null) {
icon.paint(matrices, x + iconX, (y + (height - TAB_PADDING - ICON_SIZE) / 2) + 1, ICON_SIZE);
}
}
@Override
public void addTooltip(TooltipBuilder tooltip) {
data.addTooltip(tooltip);
}
}
/**
* Internal background painter instances for tabs.
*/
@Environment(EnvType.CLIENT)
final static class Painters {
static final BackgroundPainter SELECTED_TAB = BackgroundPainter.createLightDarkVariants(
BackgroundPainter.createNinePatch(new Identifier("indrev", "textures/gui/selected_light.png")).setTopPadding(2),
BackgroundPainter.createNinePatch(new Identifier("libgui", "textures/widget/tab/selected_dark.png")).setTopPadding(2)
);
static final BackgroundPainter UNSELECTED_TAB = BackgroundPainter.createLightDarkVariants(
BackgroundPainter.createNinePatch(new Identifier("indrev", "textures/gui/unselected_light.png")),
BackgroundPainter.createNinePatch(new Identifier("libgui", "textures/widget/tab/unselected_dark.png"))
);
static final BackgroundPainter SELECTED_TAB_FOCUS_BORDER = BackgroundPainter.createNinePatch(new Identifier("libgui", "textures/widget/tab/focus.png")).setTopPadding(2);
static final BackgroundPainter UNSELECTED_TAB_FOCUS_BORDER = BackgroundPainter.createNinePatch(new Identifier("libgui", "textures/widget/tab/focus.png"));
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/aprilfools/AprilFoolsMixinConfigPlugin.java
================================================
package me.steven.indrev.mixin.aprilfools;
import me.steven.indrev.AprilFools;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class AprilFoolsMixinConfigPlugin implements IMixinConfigPlugin {
private static final ArrayList mixins = new ArrayList<>();
static {
mixins.add("aprilfools.MixinTranslatableText");
}
@Override
public void onLoad(String mixinPackage) { }
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}
@Override
public void acceptTargets(Set myTargets, Set otherTargets) { }
@Override
public List getMixins() {
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT && AprilFools.isToday() ? mixins : null;
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { }
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { }
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/aprilfools/MixinTranslatableText.java
================================================
package me.steven.indrev.mixin.aprilfools;
import me.steven.indrev.IndustrialRevolution;
import net.minecraft.text.TranslatableText;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(TranslatableText.class)
public class MixinTranslatableText {
@Shadow @Final private String key;
@ModifyVariable(name = "string", at = @At("STORE"), method = "updateTranslations")
private String owo(String original) {
if (this.key.contains(IndustrialRevolution.MOD_ID)) {
if (!original.contains(".")) {
String[] words = original.split(" ");
for (int i = 0; i < words.length; i++) {
if (words[i].endsWith("ger") || words[i].endsWith("der"))
words[i] = words[i].substring(0, words[i].length() - 2) + "ah";
else if (words[i].endsWith("er") || words[i].endsWith("re"))
words[i] = words[i].substring(0, words[i].length() - 2) + 'y';
else if (words[i].endsWith("xe"))
words[i] = words[i].substring(0, words[i].length() - 2) + "xie";
else if (words[i].endsWith("et"))
words[i] = words[i].substring(0, words[i].length() - 2) + "ie";
words[i] = words[i].replaceFirst("est", "ess"); // Chest -> Chess
words[i] = words[i].replaceFirst("O", "Ow").replaceFirst("o", "ow");
}
return String.join(" ", words);
}
}
return original;
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/client/MixinBuiltChunk.java
================================================
package me.steven.indrev.mixin.client;
import me.steven.indrev.blockentities.GlobalStateController;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.chunk.ChunkBuilder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ChunkBuilder.BuiltChunk.class)
public abstract class MixinBuiltChunk {
@Shadow public abstract BlockPos getOrigin();
@Inject(method = "rebuild", at = @At("INVOKE"))
private void indrev_removeBuiltChunk(CallbackInfo ci) {
long chunkPos = ChunkPos.toLong(getOrigin().getX() >> 4, getOrigin().getZ() >> 4);
MinecraftClient.getInstance().execute(() -> GlobalStateController.INSTANCE.getChunksToUpdate().remove(chunkPos));
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/client/MixinClientPlayerInteractionManager.java
================================================
package me.steven.indrev.mixin.client;
import me.steven.indrev.registry.IRItemRegistry;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ClientPlayerInteractionManager.class)
public class MixinClientPlayerInteractionManager {
@Redirect(method = "isCurrentlyBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;areNbtEqual(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z"))
private boolean indrev_fixGamerAxe(ItemStack left, ItemStack right) {
if (left.getItem() == IRItemRegistry.INSTANCE.getGAMER_AXE_ITEM() && left.getItem() == right.getItem())
return true;
return ItemStack.areNbtEqual(left, right);
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/client/MixinGameRenderer.java
================================================
package me.steven.indrev.mixin.client;
import me.steven.indrev.api.IRPlayerEntityExtension;
import me.steven.indrev.tools.modular.ArmorModule;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(value = GameRenderer.class, priority = 999)
public class MixinGameRenderer {
@Inject(method = "getNightVisionStrength", at = @At("INVOKE"), cancellable = true)
private static void indrev_nightVisionStrength(LivingEntity livingEntity, float f, CallbackInfoReturnable cir) {
if (livingEntity instanceof IRPlayerEntityExtension && ((IRPlayerEntityExtension) livingEntity).isApplied(ArmorModule.NIGHT_VISION)) {
cir.setReturnValue(1f);
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/client/MixinItemRenderer.java
================================================
package me.steven.indrev.mixin.client;
import com.mojang.blaze3d.systems.RenderSystem;
import me.steven.indrev.items.armor.IRModularArmorItem;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ItemRenderer.class)
public abstract class MixinItemRenderer {
@Shadow protected abstract void renderGuiQuad(BufferBuilder buffer, int x, int y, int width, int height, int red, int green, int blue, int alpha);
@Inject(
method = "renderGuiItemOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/item/ItemStack;isItemBarVisible()Z",
shift = At.Shift.BEFORE
)
)
private void indrev_renderModularArmorFluidTank(TextRenderer renderer, ItemStack stack, int x, int y, String countLabel, CallbackInfo ci) {
if (stack.getItem() instanceof IRModularArmorItem armor && armor.isFluidItemBarVisible(stack)) {
RenderSystem.disableDepthTest();
RenderSystem.disableTexture();
RenderSystem.disableBlend();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
int i = armor.getFluidItemBarStep(stack);
int j = armor.getFluidItemBarColor(stack);
this.renderGuiQuad(bufferBuilder, x + 2, y + 11, 13, 2, 0, 0, 0, 255);
this.renderGuiQuad(bufferBuilder, x + 2, y + 11, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255, 255);
RenderSystem.enableBlend();
RenderSystem.enableTexture();
RenderSystem.enableDepthTest();
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/client/MixinLivingEntityClient.java
================================================
package me.steven.indrev.mixin.client;
import me.steven.indrev.api.IRPlayerEntityExtension;
import me.steven.indrev.tools.modular.ArmorModule;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffects;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(LivingEntity.class)
public abstract class MixinLivingEntityClient {
@Inject(method = "hasStatusEffect", at = @At("INVOKE"), cancellable = true)
private void indrev_nightVision(StatusEffect effect, CallbackInfoReturnable cir) {
if (
effect.equals(StatusEffects.NIGHT_VISION)
&& this instanceof IRPlayerEntityExtension
&& ((IRPlayerEntityExtension) this).isApplied(ArmorModule.NIGHT_VISION)
) {
cir.setReturnValue(true);
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/client/MixinMinecraftClient.java
================================================
package me.steven.indrev.mixin.client;
import me.steven.indrev.gui.screenhandlers.IRGuiScreenHandler;
import me.steven.indrev.packets.client.GuiPropertySyncPacket;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.ScreenHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftClient.class)
public class MixinMinecraftClient {
@Inject(method = "setScreen", at = @At("RETURN"))
private void indrev_requestProperties(Screen screen, CallbackInfo ci) {
if (screen instanceof ScreenHandlerProvider> provider) {
ScreenHandler handler = provider.getScreenHandler();
if (handler instanceof IRGuiScreenHandler) {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeInt(handler.syncId);
ClientPlayNetworking.send(GuiPropertySyncPacket.INSTANCE.getC2S_REQUEST_PROPERTIES(), buf);
}
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/client/MixinWItemSlot.java
================================================
package me.steven.indrev.mixin.client;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
import io.github.cottonmc.cotton.gui.widget.WItemSlot;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = WItemSlot.class, remap = false)
public class MixinWItemSlot {
@Shadow @Nullable
private BackgroundPainter backgroundPainter;
@Inject(method = "addPainters", at = @At("HEAD"), cancellable = true, remap = false)
private void indrev_dontOverridePainters(CallbackInfo ci) {
if (backgroundPainter != null) ci.cancel();
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinAbstractCookingRecipe.java
================================================
package me.steven.indrev.mixin.common;
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
import me.steven.indrev.components.CraftingComponent;
import me.steven.indrev.recipes.machines.IRRecipe;
import me.steven.indrev.recipes.machines.entries.InputEntry;
import me.steven.indrev.recipes.machines.entries.OutputEntry;
import me.steven.indrev.utils.IRFluidTank;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.AbstractCookingRecipe;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeType;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@Mixin(AbstractCookingRecipe.class)
public abstract class MixinAbstractCookingRecipe implements IRRecipe {
@Shadow @Final protected Identifier id;
@Shadow @Final protected int cookTime;
@Shadow @Final protected ItemStack output;
@Shadow @Final protected Ingredient input;
private InputEntry[] indrev_inputEntries;
private OutputEntry[] indrev_outputEntries;
@Inject(method = "", at = @At("TAIL"))
private void a(RecipeType> type, Identifier id, String group, Ingredient input, ItemStack output, float experience, int cookTime, CallbackInfo ci) {
this.indrev_inputEntries = new InputEntry[] { new InputEntry(input, 1) };
this.indrev_outputEntries = new OutputEntry[] { new OutputEntry(output, 1d) };
}
@NotNull
@Override
public Identifier getIdentifier() {
return id;
}
@NotNull
@Override
public InputEntry @NotNull [] getInput() {
return indrev_inputEntries;
}
@NotNull
@Override
public OutputEntry @NotNull [] getOutputs() {
return indrev_outputEntries;
}
@Override
public int getTicks() {
return cookTime;
}
@Override
public boolean matches(@NotNull List inv, @NotNull List fluidVolume) {
return this.input.test(inv.get(0));
}
@NotNull
@Override
public List craft(Random random) {
return Collections.singletonList(output.copy());
}
@NotNull
@Override
public Identifier getId() {
return id;
}
@Override
public boolean isIgnoredInRecipeBook() {
return false;
}
@NotNull
@Override
public DefaultedList getIngredients() {
DefaultedList defaultedList = DefaultedList.of();
defaultedList.add(this.input);
return defaultedList;
}
@Override
public boolean isEmpty() {
DefaultedList defaultedList = this.getIngredients();
return defaultedList.isEmpty() || defaultedList.stream().anyMatch((ingredient) -> ingredient.getMatchingStacks().length == 0);
}
@Override
public boolean canStart(@NotNull CraftingComponent> component) {
return component.fits(output);
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinEnchantmentHelper.java
================================================
package me.steven.indrev.mixin.common;
import me.steven.indrev.api.CustomEnchantmentProvider;
import me.steven.indrev.api.IRPlayerEntityExtension;
import me.steven.indrev.tools.modular.ArmorModule;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(EnchantmentHelper.class)
public class MixinEnchantmentHelper {
@Inject(method = "getLevel", at = @At("HEAD"), cancellable = true)
private static void indrev_customEnchantProvider(Enchantment enchantment, ItemStack stack, CallbackInfoReturnable cir) {
if (stack.getItem() instanceof CustomEnchantmentProvider) {
int level = ((CustomEnchantmentProvider) stack.getItem()).getLevel(enchantment, stack);
if (level > -1)
cir.setReturnValue(level);
}
}
@Inject(method = "hasAquaAffinity", at = @At("HEAD"), cancellable = true)
private static void indrev_waterAffinityChest(LivingEntity entity, CallbackInfoReturnable cir) {
//specifically checks for water affinity on chestplate
if (entity instanceof PlayerEntity player
&& ArmorModule.WATER_AFFINITY.getLevel(player.getInventory().getArmorStack(EquipmentSlot.CHEST.getEntitySlotId())) > 0
&& entity instanceof IRPlayerEntityExtension ext
&& ext.isApplied(ArmorModule.WATER_AFFINITY)
)
cir.setReturnValue(true);
}
@Inject(method = "getDepthStrider", at = @At("HEAD"), cancellable = true)
private static void indrev_waterAffinityLegs(LivingEntity entity, CallbackInfoReturnable cir) {
//specifically checks for water affinity on leggings
if (entity instanceof PlayerEntity player
&& ArmorModule.WATER_AFFINITY.getLevel(player.getInventory().getArmorStack(EquipmentSlot.LEGS.getEntitySlotId())) > 0
&& entity instanceof IRPlayerEntityExtension ext
&& ext.isApplied(ArmorModule.WATER_AFFINITY)
)
cir.setReturnValue(3);
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinEntity.java
================================================
package me.steven.indrev.mixin.common;
import me.steven.indrev.api.IREntityExtension;
import me.steven.indrev.api.IRPlayerEntityExtension;
import me.steven.indrev.inventories.IRInventory;
import me.steven.indrev.tools.modular.ArmorModule;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Entity.class)
public abstract class MixinEntity implements IREntityExtension {
@Shadow public World world;
@Shadow public abstract double getX();
@Shadow public abstract double getY();
@Shadow public abstract double getZ();
private IRInventory machineInv = null;
@Inject(method = "setAir", at = @At("INVOKE"), cancellable = true)
private void indrev_breathingModule(CallbackInfo ci) {
if (this instanceof IRPlayerEntityExtension && ((IRPlayerEntityExtension) this).isApplied(ArmorModule.BREATHING)) {
ci.cancel();
}
}
@Inject(method = "getJumpVelocityMultiplier", at = @At(value = "RETURN"), cancellable = true)
private void indrev_jumpBoostModule(CallbackInfoReturnable cir) {
if (this instanceof IRPlayerEntityExtension && ((IRPlayerEntityExtension) this).isApplied(ArmorModule.JUMP_BOOST)) {
cir.setReturnValue((float) ((IRPlayerEntityExtension) this).getAppliedLevel(ArmorModule.JUMP_BOOST));
}
}
@Inject(method = "dropStack(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/ItemEntity;", at = @At("HEAD"), cancellable = true)
private void indrev_onDropItem(ItemStack stack, float yOffset, CallbackInfoReturnable cir) {
if (!world.isClient && machineInv != null) {
if (!machineInv.output(stack)) {
ItemEntity itemEntity = new ItemEntity(world, getX(), getY() + yOffset, getZ(), stack);
itemEntity.setToDefaultPickupDelay();
this.world.spawnEntity(itemEntity);
}
cir.cancel();
}
}
@Nullable
@Override
public IRInventory getMachineInv() {
return machineInv;
}
@Override
public void setMachineInv(IRInventory machineInv) {
this.machineInv = machineInv;
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinItemPredicate.java
================================================
package me.steven.indrev.mixin.common;
import me.steven.indrev.api.CustomEnchantmentProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.predicate.item.EnchantmentPredicate;
import net.minecraft.predicate.item.ItemPredicate;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ItemPredicate.class)
public class MixinItemPredicate {
@Shadow @Final private EnchantmentPredicate[] enchantments;
@Inject(
method = "test",
slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/predicate/item/EnchantmentPredicate;test(Ljava/util/Map;)Z")
),
at = @At(value = "RETURN"),
cancellable = true)
private void indrev_customEnchantProvider(ItemStack stack, CallbackInfoReturnable cir) {
if (stack.getItem() instanceof CustomEnchantmentProvider && enchantments.length > 0) {
for (EnchantmentPredicate predicate : enchantments) {
if (predicate.levels != null && predicate.enchantment != null) {
int level = ((CustomEnchantmentProvider) stack.getItem()).getLevel(predicate.enchantment, stack);
if (level > -1 && predicate.levels.test(level)) cir.setReturnValue(true);
}
}
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinItemStack.java
================================================
package me.steven.indrev.mixin.common;
import com.google.common.collect.Multimap;
import me.steven.indrev.api.AttributeModifierProvider;
import me.steven.indrev.items.energy.IREnergyItem;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Random;
@Mixin(ItemStack.class)
public abstract class MixinItemStack {
@Shadow public abstract Item getItem();
@Inject(method = "getAttributeModifiers", at = @At("TAIL"), cancellable = true)
private void indrev_modifiableAttributeModifiers(EquipmentSlot equipmentSlot, CallbackInfoReturnable> cir) {
ItemStack stack = (ItemStack) (Object) this;
if (stack.getItem() instanceof AttributeModifierProvider) {
cir.setReturnValue(((AttributeModifierProvider) stack.getItem()).getAttributeModifiers(stack, equipmentSlot));
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinLivingEntity.java
================================================
package me.steven.indrev.mixin.common;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LivingEntity.class)
public abstract class MixinLivingEntity extends Entity {
public MixinLivingEntity(EntityType> type, World world) {
super(type, world);
}
/*
@Inject(method = "knockDownwards", at = @At("HEAD"), cancellable = true)
private void indrev_waterAffinityDownwards(CallbackInfo ci) {
this.setVelocity(this.getVelocity().add(0.0D, -0.03999999910593033D * 2, 0.0D));
ci.cancel();
}
@Inject(method = "swimUpward", at = @At("HEAD"), cancellable = true)
private void indrev_waterAffinityUpwards(CallbackInfo ci) {
this.setVelocity(this.getVelocity().add(0.0D, 0.03999999910593033D * 2, 0.0D));
ci.cancel();
}*/
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinPiglinBrain.java
================================================
package me.steven.indrev.mixin.common;
import me.steven.indrev.api.IRPlayerEntityExtension;
import me.steven.indrev.tools.modular.ArmorModule;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.PiglinBrain;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PiglinBrain.class)
public class MixinPiglinBrain {
@Inject(method = "wearsGoldArmor", at = @At("RETURN"), cancellable = true)
private static void indrev_hasPiglinTrickerModule(LivingEntity entity, CallbackInfoReturnable cir) {
if (entity instanceof IRPlayerEntityExtension && ((IRPlayerEntityExtension) entity).isApplied(ArmorModule.PIGLIN_TRICKER)) {
cir.setReturnValue(true);
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinPlayerEntity.java
================================================
package me.steven.indrev.mixin.common;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import me.steven.indrev.api.IRPlayerEntityExtension;
import me.steven.indrev.items.energy.IREnergyItem;
import me.steven.indrev.items.energy.IRGamerAxeItem;
import me.steven.indrev.tools.modular.ArmorModule;
import me.steven.indrev.utils.EnergyutilsKt;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import team.reborn.energy.api.EnergyStorage;
import java.util.Iterator;
import java.util.Map;
@Mixin(PlayerEntity.class)
public abstract class MixinPlayerEntity extends LivingEntity implements IRPlayerEntityExtension {
private boolean indrev_regenerating = false;
private double indrev_shield = 0.0;
private final Object2IntMap appliedEffects = new Object2IntOpenHashMap<>();
protected MixinPlayerEntity(EntityType extends LivingEntity> entityType, World world) {
super(entityType, world);
}
@Inject(method = "getBlockBreakingSpeed", at = @At("HEAD"), cancellable = true)
private void indrev_checkEnergyTool(BlockState block, CallbackInfoReturnable cir) {
PlayerEntity player = (PlayerEntity) (Object) this;
PlayerInventory inventory = player.getInventory();
ItemStack itemStack = inventory.main.get(inventory.selectedSlot);
Item item = itemStack.getItem();
EnergyStorage itemIo = EnergyutilsKt.energyOf(itemStack);
if (itemIo != null && item instanceof IREnergyItem) {
long amount = itemIo.getAmount();
if (item instanceof IRGamerAxeItem) {
NbtCompound tag = itemStack.getOrCreateNbt();
if (tag.contains("Active") && !tag.getBoolean("Active")) {
cir.setReturnValue(0.2F);
return;
}
}
if (amount < 1) cir.setReturnValue(0.2F);
}
}
@Inject(method = "writeCustomDataToNbt", at = @At("RETURN"))
private void indrev_writeShieldToPlayerTag(NbtCompound tag, CallbackInfo ci) {
tag.putDouble("indrev:shield", indrev_shield);
}
@Inject(method = "readCustomDataFromNbt", at = @At("RETURN"))
private void indrev_readShieldToPlayerTag(NbtCompound tag, CallbackInfo ci) {
indrev_shield = tag.getDouble("indrev:shield");
}
@Override
public double getShieldDurability() {
return indrev_shield;
}
@Override
public void setShieldDurability(double shieldDurability) {
this.indrev_shield = shieldDurability;
}
@Override
public double getMaxShieldDurability() {
Iterator iterator = getArmorItems().iterator();
double shield = 0.0;
while (iterator.hasNext()) {
ItemStack next = iterator.next();
shield += ArmorModule.PROTECTION.getLevel(next) * 25;
}
return shield;
}
@Override
public @NotNull Map getAppliedModules() {
return appliedEffects;
}
@Override
public boolean isApplied(@NotNull ArmorModule module) {
return appliedEffects.containsKey(module);
}
@Override
public void applyModule(@NotNull ArmorModule module, int level) {
appliedEffects.put(module, level);
}
@Override
public int getAppliedLevel(@NotNull ArmorModule module) {
return appliedEffects.getOrDefault(module, 0);
}
@Override
public void setRegenerating(boolean isRegenerating) {
this.indrev_regenerating = isRegenerating;
}
@Override
public boolean isRegenerating() {
return indrev_regenerating;
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinPlayerInventory.java
================================================
package me.steven.indrev.mixin.common;
import me.steven.indrev.items.armor.JetpackHandler;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerInventory.class)
public abstract class MixinPlayerInventory {
@Shadow public abstract ItemStack getArmorStack(int slot);
@Shadow @Final public PlayerEntity player;
@Inject(method = "updateItems", at = @At("TAIL"))
private void indrev_tickJetpack(CallbackInfo ci) {
ItemStack armorStack = getArmorStack(EquipmentSlot.CHEST.getEntitySlotId());
if (armorStack.getItem() instanceof JetpackHandler handler && handler.isUsable(armorStack)) {
handler.tickJetpack(armorStack, player);
}
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinServerPlayerEntity.java
================================================
package me.steven.indrev.mixin.common;
import com.mojang.authlib.GameProfile;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import me.steven.indrev.api.IRServerPlayerEntityExtension;
import me.steven.indrev.items.armor.IRModularArmorItem;
import me.steven.indrev.items.energy.IRPortableChargerItem;
import me.steven.indrev.packets.client.SyncAppliedModulesPacket;
import me.steven.indrev.tools.modular.ArmorModule;
import me.steven.indrev.utils.AccessorextensionsKt;
import me.steven.indrev.utils.EnergyutilsKt;
import me.steven.indrev.utils.HelperextensionsKt;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.entity.ExperienceOrbEntity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.HungerManager;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import team.reborn.energy.api.EnergyStorage;
import java.util.List;
import java.util.Map;
@Mixin(ServerPlayerEntity.class)
public abstract class MixinServerPlayerEntity extends PlayerEntity implements IRServerPlayerEntityExtension {
@Shadow public abstract boolean isInvulnerableTo(DamageSource damageSource);
@Shadow public abstract void playSound(SoundEvent event, SoundCategory category, float volume, float pitch);
private int ticks = 0;
private int lastDamageTick = 0;
private float lastDmg = 0f;
private double lastShield = 0.0;
private final Object2IntMap oldAppliedModules = new Object2IntOpenHashMap<>();
public MixinServerPlayerEntity(World world, BlockPos pos, float yaw, GameProfile profile) {
super(world, pos, yaw, profile);
}
@Inject(method = "tick", at = @At("TAIL"))
private void indrev_applyEffects(CallbackInfo ci) {
ticks++;
if (ticks % 15 == 0) {
applyArmorEffects();
}
indrev_tickMagnet();
setShieldDurability(Math.min(getShieldDurability(), getMaxShieldDurability()));
}
@ModifyVariable(method = "damage(Lnet/minecraft/entity/damage/DamageSource;F)Z", at = @At("HEAD"), argsOnly = true)
private float indrev_absorbDamage(float amount, DamageSource source) {
final float initial = amount;
if (isInvulnerableTo(source)) return amount;
if (lastDamageTick + 10 > ticks) {
if (amount <= lastDmg)
return 0f;
amount = amount - lastDmg;
}
lastDamageTick = ticks;
lastDmg = initial;
if (shouldApplyToShield(source)) {
float leftover = (float) applyDamageToShield(amount);
if (amount > leftover)
world.playSoundFromEntity(null, this, SoundEvents.BLOCK_CHAIN_BREAK, SoundCategory.PLAYERS, 1f, 0.0001f);
return leftover;
} else
return amount;
}
@Inject(method = "worldChanged", at = @At("TAIL"))
private void indrev_syncOnDimChange(ServerWorld origin, CallbackInfo ci) {
sync();
AccessorextensionsKt.getFluidNetworkState(origin).onDimChange(this);
AccessorextensionsKt.getItemNetworkState(origin).onDimChange(this);
}
private boolean shouldApplyToShield(DamageSource source) {
if (source.equals(DamageSource.FALL)) return isApplied(ArmorModule.FEATHER_FALLING);
else if (source.isFire()) return isApplied(ArmorModule.FIRE_RESISTANCE);
else return !source.equals(DamageSource.STARVE) && !source.equals(DamageSource.DROWN);
}
private void applyArmorEffects() {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
PlayerInventory inventory = player.getInventory();
getAppliedModules().clear();
for (int i = 0; i < inventory.armor.size(); i++) {
int cSlot = 36+i;
ItemStack itemStack = inventory.getStack(cSlot);
if (itemStack.getItem() instanceof IRModularArmorItem) {
List modules = ((IRModularArmorItem) itemStack.getItem()).getInstalled(itemStack);
for (ArmorModule module : modules) {
int level = module.getLevel(itemStack);
if (level <= 0) continue;
switch (module) {
case SPEED:
case BREATHING:
case JUMP_BOOST:
case NIGHT_VISION:
case FIRE_RESISTANCE:
case PIGLIN_TRICKER:
case FEATHER_FALLING:
case WATER_AFFINITY:
if (EnergyutilsKt.extract(inventory, cSlot, 20))
applyModule(module, level);
break;
case AUTO_FEEDER:
HungerManager hunger = player.getHungerManager();
if (hunger.isNotFull()) {
for (int slot = 0; slot <= inventory.size(); slot++) {
ItemStack stack = inventory.getStack(slot);
FoodComponent food = stack.getItem().getFoodComponent();
if (food != null && !food.isAlwaysEdible() && !HelperextensionsKt.hasNegativeEffects(food) && food.getHunger() <= 20 - hunger.getFoodLevel() && EnergyutilsKt.extract(inventory, cSlot, 30)) {
stack.finishUsing(world, player);
player.eatFood(world, stack);
}
if (!hungerManager.isNotFull()) break;
}
}
break;
case CHARGER:
IRPortableChargerItem.Companion.chargeItemsInInv(cSlot, player.getInventory());
break;
case SOLAR_PANEL:
if (world.isDay() && world.isSkyVisible(player.getBlockPos().up(2))) {
for (int x = 0; x < 4; x++) {
EnergyutilsKt.insert(inventory, cSlot - x, 75L * level);
}
}
break;
case PROTECTION:
if (ticks - 120 > lastDamageTick && getShieldDurability() < getMaxShieldDurability() && EnergyutilsKt.extract(inventory, cSlot, 30)) {
regenerateShield();
}
break;
default:
break;
}
}
}
}
}
private void indrev_tickMagnet() {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
PlayerInventory inventory = player.getInventory();
for (ItemStack itemStack : inventory.armor) {
if (itemStack.getItem() instanceof IRModularArmorItem) {
int level = ArmorModule.MAGNET.getLevel(itemStack);
if (level > 0) {
Vec3i offset = new Vec3i(8, 8, 8);
Box area = new Box(getBlockPos().subtract(offset), getBlockPos().add(offset));
Vec3d blockCenter = HelperextensionsKt.toVec3d(getBlockPos()).add(0.5, 0.5, 0.5);
world.getOtherEntities(this, area, (entity) -> entity instanceof ItemEntity || entity instanceof ExperienceOrbEntity).forEach(entity -> {
if ((entity instanceof ItemEntity itemEntity && !itemEntity.cannotPickup())
|| (entity instanceof ExperienceOrbEntity xpEntity && xpEntity.age > 40)) {
Vec3d v = entity.getPos().relativize(blockCenter).normalize().multiply(0.2);
entity.addVelocity(v.x, v.y, v.z);
//applyModule(ArmorModule.MAGNET, 1);
}
});
return;
}
}
}
//getAppliedModules().remove(ArmorModule.MAGNET);
}
private void regenerateShield() {
setShieldDurability(Math.min(getShieldDurability() + 0.5, getMaxShieldDurability()));
}
private double applyDamageToShield(double damage) {
double absorbed = Math.min(damage, getShieldDurability());
setShieldDurability(getShieldDurability() - absorbed);
return damage - absorbed;
}
@Override
public boolean shouldSync() {
return !oldAppliedModules.equals(getAppliedModules()) || lastShield != getShieldDurability();
}
@Override
public void sync() {
lastShield = getShieldDurability();
oldAppliedModules.clear();
oldAppliedModules.putAll(getAppliedModules());
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
Map appliedModules = getAppliedModules();
buf.writeInt(appliedModules.size());
appliedModules.forEach((module, level) -> {
buf.writeInt(module.ordinal());
buf.writeInt(level);
});
buf.writeDouble(getShieldDurability());
buf.writeBoolean(ticks - 120 > lastDamageTick);
ServerPlayNetworking.send((ServerPlayerEntity) (Object) this, SyncAppliedModulesPacket.INSTANCE.getSYNC_MODULE_PACKET(), buf);
}
@Override
public boolean isRegenerating() {
return ticks - 120 > lastDamageTick;
}
}
================================================
FILE: src/main/java/me/steven/indrev/mixin/common/MixinServerWorld.java
================================================
package me.steven.indrev.mixin.common;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import me.steven.indrev.api.ServerWorldExtension;
import me.steven.indrev.networks.Network;
import me.steven.indrev.networks.NetworkState;
import me.steven.indrev.networks.ServoNetworkState;
import me.steven.indrev.networks.energy.EnergyNetwork;
import me.steven.indrev.networks.energy.EnergyNetworkState;
import me.steven.indrev.networks.fluid.FluidNetworkState;
import me.steven.indrev.networks.item.ItemNetworkState;
import net.fabricmc.fabric.api.lookup.v1.block.BlockApiCache;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Direction;
import net.minecraft.world.PersistentStateManager;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import team.reborn.energy.api.EnergyStorage;
@Mixin(ServerWorld.class)
public abstract class MixinServerWorld implements ServerWorldExtension {
private final Long2ObjectOpenHashMap> indrev_energyIoCache = new Long2ObjectOpenHashMap<>();
private ItemNetworkState indrev_itemNetworkState = null;
private FluidNetworkState indrev_fluidNetworkState = null;
private EnergyNetworkState indrev_energyNetworkState = null;
@Shadow
public abstract PersistentStateManager getPersistentStateManager();
@NotNull
@Override
public Long2ObjectOpenHashMap> indrev_getEnergyCache() {
return indrev_energyIoCache;
}
@NotNull
@Override
public EnergyNetworkState indrev_getEnergyNetworkState() {
ServerWorld world = (ServerWorld) (Object) this;
if (indrev_energyNetworkState == null) {
indrev_energyNetworkState = getPersistentStateManager()
.getOrCreate(
nbt -> EnergyNetworkState.Companion.readNbt(nbt, () -> new EnergyNetworkState(world)),
() -> new EnergyNetworkState(world),
Network.Type.Companion.getENERGY().getKey());
}
return indrev_energyNetworkState;
}
@NotNull
@Override
public FluidNetworkState indrev_getFluidNetworkState() {
ServerWorld world = (ServerWorld) (Object) this;
if (indrev_fluidNetworkState == null) {
indrev_fluidNetworkState = getPersistentStateManager()
.getOrCreate(
nbt -> ServoNetworkState.Companion.readNbt(nbt, () -> new FluidNetworkState(world)),
() -> new FluidNetworkState(world),
Network.Type.Companion.getFLUID().getKey());
}
return indrev_fluidNetworkState;
}
@NotNull
@Override
public ItemNetworkState indrev_getItemNetworkState() {
ServerWorld world = (ServerWorld) (Object) this;
if (indrev_itemNetworkState == null) {
indrev_itemNetworkState = getPersistentStateManager()
.getOrCreate(
nbt -> ItemNetworkState.Companion.readNbt(nbt, () -> new ItemNetworkState(world)),
() -> new ItemNetworkState(world),
Network.Type.Companion.getITEM().getKey());
}
return indrev_itemNetworkState;
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/IndustrialRevolution.kt
================================================
package me.steven.indrev
import dev.cafeteria.fakeplayerapi.server.FakePlayerBuilder
import dev.cafeteria.fakeplayerapi.server.FakeServerPlayer
import me.steven.indrev.api.IRServerPlayerEntityExtension
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.config.IRConfig
import me.steven.indrev.datagen.DataGeneratorManager
import me.steven.indrev.events.common.IRLootTableCallback
import me.steven.indrev.gui.screenhandlers.COAL_GENERATOR_HANDLER
import me.steven.indrev.gui.screenhandlers.IRGuiScreenHandler
import me.steven.indrev.networks.NetworkEvents
import me.steven.indrev.packets.PacketRegistry
import me.steven.indrev.packets.client.SyncConfigPacket
import me.steven.indrev.recipes.SelfRemainderRecipe
import me.steven.indrev.recipes.machines.*
import me.steven.indrev.registry.*
import me.steven.indrev.utils.identifier
import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerBlockEntityEvents
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes
import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.item.Item
import net.minecraft.item.ItemGroup
import net.minecraft.item.ItemStack
import net.minecraft.sound.SoundCategory
import net.minecraft.sound.SoundEvent
import net.minecraft.tag.TagKey
import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
object IndustrialRevolution : ModInitializer {
override fun onInitialize() {
//load the screenhandlers.kt class
COAL_GENERATOR_HANDLER
IRConfig
IRItemRegistry.registerAll()
IRBlockRegistry.registerAll()
IRFluidRegistry.registerAll()
Registry.register(Registry.SOUND_EVENT, LASER_SOUND_ID, LASER_SOUND_EVENT)
Registry.register(Registry.PARTICLE_TYPE, identifier("laser_particle"), LASER_PARTICLE)
WorldGeneration.init()
WorldGeneration.addFeatures()
LootTableLoadingCallback.EVENT.register(IRLootTableCallback)
MachineRegistry
Registry.register(Registry.RECIPE_SERIALIZER, PulverizerRecipe.IDENTIFIER, PulverizerRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, PulverizerRecipe.IDENTIFIER, PulverizerRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, CompressorRecipe.IDENTIFIER, CompressorRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, CompressorRecipe.IDENTIFIER, CompressorRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, InfuserRecipe.IDENTIFIER, InfuserRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, InfuserRecipe.IDENTIFIER, InfuserRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, FluidInfuserRecipe.IDENTIFIER, FluidInfuserRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, FluidInfuserRecipe.IDENTIFIER, FluidInfuserRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, RecyclerRecipe.IDENTIFIER, RecyclerRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, RecyclerRecipe.IDENTIFIER, RecyclerRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, SmelterRecipe.IDENTIFIER, SmelterRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, SmelterRecipe.IDENTIFIER, SmelterRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, CondenserRecipe.IDENTIFIER, CondenserRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, CondenserRecipe.IDENTIFIER, CondenserRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, DistillerRecipe.IDENTIFIER, DistillerRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, DistillerRecipe.IDENTIFIER, DistillerRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, SawmillRecipe.IDENTIFIER, SawmillRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, SawmillRecipe.IDENTIFIER, SawmillRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, ModuleRecipe.IDENTIFIER, ModuleRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, ModuleRecipe.IDENTIFIER, ModuleRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, LaserRecipe.IDENTIFIER, LaserRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, LaserRecipe.IDENTIFIER, LaserRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, ElectrolysisRecipe.IDENTIFIER, ElectrolysisRecipe.SERIALIZER)
Registry.register(Registry.RECIPE_TYPE, ElectrolysisRecipe.IDENTIFIER, ElectrolysisRecipe.TYPE)
Registry.register(Registry.RECIPE_SERIALIZER, SelfRemainderRecipe.IDENTIFIER, SelfRemainderRecipe.SERIALIZER)
PacketRegistry.registerServer()
ServerTickEvents.END_WORLD_TICK.register(NetworkEvents)
ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.register(NetworkEvents)
ServerLifecycleEvents.SERVER_STOPPING.register(NetworkEvents)
ServerPlayConnectionEvents.JOIN.register { handler, _, _ ->
val player = handler.player
SyncConfigPacket.sendConfig(player)
if (player is IRServerPlayerEntityExtension) {
(player as IRServerPlayerEntityExtension).sync()
}
}
ServerTickEvents.START_SERVER_TICK.register { server ->
server.playerManager.playerList.forEach { player ->
if (player is IRServerPlayerEntityExtension && player.shouldSync()) {
player.sync()
}
}
}
ServerTickEvents.END_SERVER_TICK.register { server ->
server.playerManager.playerList.forEach { player ->
val currentScreenHandler = player.currentScreenHandler as? IRGuiScreenHandler ?: return@forEach
currentScreenHandler.syncProperties()
}
}
ServerLifecycleEvents.END_DATA_PACK_RELOAD.register { s, _, _ ->
s.recipeManager.recipes.keys.filterIsInstance>().forEach { it.clearCache() }
}
if (FabricLoader.getInstance().getLaunchArguments(true).contains("-dataGen")) {
FabricDataGenHelper.run()
ClientLifecycleEvents.CLIENT_STARTED.register(ClientLifecycleEvents.ClientStarted {
DataGeneratorManager("indrev").generate()
})
}
LOGGER.info("Industrial Revolution has initialized.")
}
val LOGGER: Logger = LogManager.getLogger("Industrial Revolution")
const val MOD_ID = "indrev"
val MOD_GROUP: ItemGroup =
FabricItemGroupBuilder.build(identifier("indrev_group")) { ItemStack { MachineRegistry.PULVERIZER_REGISTRY.block(Tier.MK4).asItem() } }
val COOLERS_TAG: TagKey- = TagKey.of(Registry.ITEM_KEY, identifier("coolers"))
val WRENCH_TAG: TagKey
- = TagKey.of(Registry.ITEM_KEY, Identifier("c:wrenches"))
val SCREWDRIVER_TAG: TagKey
- = TagKey.of(Registry.ITEM_KEY, Identifier("c:screwdrivers"))
val NIKOLITE_ORES: TagKey
- = TagKey.of(Registry.ITEM_KEY, Identifier("c:nikolite_ores"))
val TIN_ORES: TagKey
- = TagKey.of(Registry.ITEM_KEY, Identifier("c:tin_ores"))
val LEAD_ORES: TagKey
- = TagKey.of(Registry.ITEM_KEY, Identifier("c:lead_ores"))
val SILVER_ORES: TagKey
- = TagKey.of(Registry.ITEM_KEY, Identifier("c:silver_ores"))
val TUNGSTEN_ORES: TagKey
- = TagKey.of(Registry.ITEM_KEY, Identifier("c:tungsten_ores"))
val ANCIENT_DEBRIS_ORES: TagKey
- = TagKey.of(Registry.ITEM_KEY, Identifier("c:ancient_debris_ores"))
val LASER_SOUND_ID = identifier("laser")
val LASER_SOUND_EVENT = SoundEvent(LASER_SOUND_ID)
val LASER_PARTICLE = FabricParticleTypes.simple()
val FAKE_PLAYER_BUILDER = FakePlayerBuilder(identifier("default_fake_player")) { builder, server, world, profile ->
object : FakeServerPlayer(builder, server, world, profile) {
override fun isCreative(): Boolean = false
override fun isSpectator(): Boolean = false
override fun playSound(sound: SoundEvent?, volume: Float, pitch: Float) {}
override fun playSound(event: SoundEvent?, category: SoundCategory?, volume: Float, pitch: Float) {}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/IndustrialRevolutionClient.kt
================================================
package me.steven.indrev
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import me.steven.indrev.api.OreDataCards
import me.steven.indrev.blockentities.GlobalStateController
import me.steven.indrev.blockentities.crafters.*
import me.steven.indrev.blockentities.miningrig.DrillBlockEntityRenderer
import me.steven.indrev.blockentities.farms.*
import me.steven.indrev.blockentities.generators.HeatGeneratorBlockEntityRenderer
import me.steven.indrev.blockentities.generators.SteamTurbineBlockEntity
import me.steven.indrev.blockentities.laser.CapsuleBlockEntityRenderer
import me.steven.indrev.blockentities.laser.LaserBlockEntityRenderer
import me.steven.indrev.blockentities.miningrig.MiningRigBlockEntityRenderer
import me.steven.indrev.blockentities.modularworkbench.ModularWorkbenchBlockEntityRenderer
import me.steven.indrev.blockentities.solarpowerplant.HeliostatBlockEntityRenderer
import me.steven.indrev.blockentities.storage.ChargePadBlockEntityRenderer
import me.steven.indrev.blockentities.storage.LazuliFluxContainerBlockEntityRenderer
import me.steven.indrev.blockentities.storage.TankBlockEntityRenderer
import me.steven.indrev.components.multiblock.MultiblockBlockEntityRenderer
import me.steven.indrev.config.IRConfig
import me.steven.indrev.events.client.*
import me.steven.indrev.fluids.FluidType
import me.steven.indrev.gui.IRInventoryScreen
import me.steven.indrev.gui.screenhandlers.*
import me.steven.indrev.gui.screenhandlers.pipes.PipeFilterScreen
import me.steven.indrev.networks.Network
import me.steven.indrev.networks.client.ClientNetworkState
import me.steven.indrev.packets.PacketRegistry
import me.steven.indrev.registry.*
import me.steven.indrev.events.client.IRWorldRenderer
import me.steven.indrev.utils.identifier
import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.`object`.builder.v1.client.model.FabricModelPredicateProviderRegistry
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry
import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback
import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.particle.FlameParticle
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.util.InputUtil
import net.minecraft.item.ElytraItem
import net.minecraft.screen.PlayerScreenHandler
import org.lwjgl.glfw.GLFW
@Suppress("UNCHECKED_CAST")
object IndustrialRevolutionClient : ClientModInitializer {
override fun onInitializeClient() {
FluidType.WATER.registerReloadListener()
FluidType.LAVA.registerReloadListener()
FluidType.GAS.registerReloadListener()
arrayOf(
IRFluidRegistry.COOLANT_STILL,
IRFluidRegistry.SULFURIC_ACID_STILL,
IRFluidRegistry.TOXIC_MUD_STILL,
IRFluidRegistry.STEAM_STILL
).forEach { it.registerRender(FluidType.WATER) }
arrayOf(
IRFluidRegistry.MOLTEN_NETHERITE_STILL,
IRFluidRegistry.MOLTEN_IRON_STILL,
IRFluidRegistry.MOLTEN_GOLD_STILL,
IRFluidRegistry.MOLTEN_COPPER_STILL,
IRFluidRegistry.MOLTEN_TIN_STILL,
IRFluidRegistry.MOLTEN_LEAD_STILL,
IRFluidRegistry.MOLTEN_SILVER_STILL
).forEach { it.registerRender(FluidType.LAVA) }
arrayOf(
IRFluidRegistry.HYDROGEN_STILL,
IRFluidRegistry.OXYGEN_STILL,
IRFluidRegistry.METHANE_STILL,
).forEach { it.registerRender(FluidType.GAS) }
arrayOf(
COAL_GENERATOR_HANDLER,
SOLAR_GENERATOR_HANDLER,
BIOMASS_GENERATOR_HANDLER,
HEAT_GENERATOR_HANDLER,
GAS_BURNING_GENERATOR_HANDLER,
BATTERY_HANDLER,
ELECTRIC_FURNACE_HANDLER,
PULVERIZER_HANDLER,
COMPRESSOR_HANDLER,
SOLID_INFUSER_HANDLER,
RECYCLER_HANDLER,
CHOPPER_HANDLER,
RANCHER_HANDLER,
MINING_RIG_HANDLER,
MODULAR_WORKBENCH_HANDLER,
FISHER_HANDLER,
SCREWDRIVER_HANDLER,
SMELTER_HANDLER,
CONDENSER_HANDLER,
FLUID_INFUSER_HANDLER,
FARMER_HANDLER,
SLAUGHTER_HANDLER,
SAWMILL_HANDLER,
ELECTRIC_FURNACE_FACTORY_HANDLER,
PULVERIZER_FACTORY_HANDLER,
COMPRESSOR_FACTORY_HANDLER,
SOLID_INFUSER_FACTORY_HANDLER,
CABINET_HANDLER,
DRILL_HANDLER,
LASER_HANDLER,
ELECTROLYTIC_SEPARATOR_HANDLER,
STEAM_TURBINE_HANDLER,
SOLAR_POWER_PLANT_TOWER_HANDLER,
DATA_CARD_WRITER_HANDLER,
PUMP_HANDLER
).forEach { handler ->
ScreenRegistry.register(handler) { controller, inv, _ -> IRInventoryScreen(controller, inv.player) }
}
ScreenRegistry.register(PIPE_FILTER_HANDLER) { controller, inv, _ -> PipeFilterScreen(controller, inv.player) }
MachineRegistry.CHOPPER_REGISTRY.registerBlockEntityRenderer(::ChopperBlockEntityRenderer)
MachineRegistry.RANCHER_REGISTRY.registerBlockEntityRenderer(::AOEMachineBlockEntityRenderer)
MachineRegistry.FARMER_REGISTRY.registerBlockEntityRenderer(::AOEMachineBlockEntityRenderer)
MachineRegistry.SLAUGHTER_REGISTRY.registerBlockEntityRenderer(::AOEMachineBlockEntityRenderer)
MachineRegistry.MODULAR_WORKBENCH_REGISTRY.registerBlockEntityRenderer(::ModularWorkbenchBlockEntityRenderer)
MachineRegistry.CHARGE_PAD_REGISTRY.registerBlockEntityRenderer(::ChargePadBlockEntityRenderer)
MachineRegistry.CONDENSER_REGISTRY.registerBlockEntityRenderer(::CondenserBlockEntityRenderer)
MachineRegistry.FLUID_INFUSER_REGISTRY.registerBlockEntityRenderer(::FluidInfuserBlockEntityRenderer)
MachineRegistry.SOLID_INFUSER_FACTORY_REGISTRY.registerBlockEntityRenderer { MultiblockBlockEntityRenderer { be -> be.multiblockComponent!! } }
MachineRegistry.COMPRESSOR_FACTORY_REGISTRY.registerBlockEntityRenderer { MultiblockBlockEntityRenderer { be -> be.multiblockComponent!! } }
MachineRegistry.PULVERIZER_FACTORY_REGISTRY.registerBlockEntityRenderer { MultiblockBlockEntityRenderer { be -> be.multiblockComponent!! } }
MachineRegistry.ELECTRIC_FURNACE_FACTORY_REGISTRY.registerBlockEntityRenderer { MultiblockBlockEntityRenderer { be -> be.multiblockComponent!! } }
MachineRegistry.MINING_RIG_REGISTRY.registerBlockEntityRenderer(::MiningRigBlockEntityRenderer)
MachineRegistry.PUMP_REGISTRY.registerBlockEntityRenderer(::PumpBlockEntityRenderer)
MachineRegistry.LAZULI_FLUX_CONTAINER_REGISTRY.registerBlockEntityRenderer(::LazuliFluxContainerBlockEntityRenderer)
MachineRegistry.HEAT_GENERATOR_REGISTRY.registerBlockEntityRenderer(::HeatGeneratorBlockEntityRenderer)
MachineRegistry.LASER_EMITTER_REGISTRY.registerBlockEntityRenderer(::LaserBlockEntityRenderer)
MachineRegistry.STEAM_TURBINE_REGISTRY.registerBlockEntityRenderer { MultiblockBlockEntityRenderer { be -> be.multiblockComponent!! } }
BlockEntityRendererRegistry.register(IRBlockRegistry.TANK_BLOCK_ENTITY) { TankBlockEntityRenderer() }
BlockEntityRendererRegistry.register(IRBlockRegistry.DRILL_BLOCK_ENTITY_TYPE) { DrillBlockEntityRenderer() }
BlockEntityRendererRegistry.register(IRBlockRegistry.CAPSULE_BLOCK_ENTITY) { CapsuleBlockEntityRenderer() }
BlockEntityRendererRegistry.register(IRBlockRegistry.BIOMASS_COMPOSTER_BLOCK_ENTITY) { BiomassComposterBlockEntityRenderer() }
BlockEntityRendererRegistry.register(IRBlockRegistry.SOLAR_POWER_PLANT_TOWER_BLOCK_ENTITY) { MultiblockBlockEntityRenderer { be -> be.multiblockComponent } }
BlockEntityRendererRegistry.register(IRBlockRegistry.HELIOSTAT_BLOCK_ENTITY) { HeliostatBlockEntityRenderer() }
MachineRegistry.MODULAR_WORKBENCH_REGISTRY.setRenderLayer(RenderLayer.getTranslucent())
MachineRegistry.PUMP_REGISTRY.setRenderLayer(RenderLayer.getTranslucent())
MachineRegistry.HEAT_GENERATOR_REGISTRY.setRenderLayer(RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.TANK_BLOCK, RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.SULFUR_CRYSTAL_CLUSTER, RenderLayer.getTranslucent())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.DRILL_TOP, RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.DRILL_MIDDLE, RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.DRILL_BOTTOM, RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.CAPSULE_BLOCK, RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.CABLE_MK1, RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.CABLE_MK2, RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.CABLE_MK3, RenderLayer.getCutout())
BlockRenderLayerMap.INSTANCE.putBlock(IRBlockRegistry.CABLE_MK4, RenderLayer.getCutout())
ModelLoadingRegistry.INSTANCE.registerModelProvider(IRModelManagers)
ModelLoadingRegistry.INSTANCE.registerVariantProvider { IRModelManagers }
FabricModelPredicateProviderRegistry.register(
IRItemRegistry.GAMER_AXE_ITEM,
identifier("activate")
) { stack, _, _, _ -> stack?.orCreateNbt?.getFloat("Progress") ?: 0f }
FabricModelPredicateProviderRegistry.register(IRItemRegistry.REINFORCED_ELYTRA, identifier("broken")) { stack, _, _, _ ->
if (ElytraItem.isUsable(stack)) 0.0f else 1.0f
}
FabricModelPredicateProviderRegistry.register(IRItemRegistry.ORE_DATA_CARD, identifier("empty")) { stack, _, _, _ ->
if (OreDataCards.readNbt(stack) == null) 0.0f else 1.0f
}
PacketRegistry.registerClient()
GlobalStateController.initClient()
HudRenderCallback.EVENT.register(IRHudRenderCallback)
WorldRenderEvents.BEFORE_BLOCK_OUTLINE.register(IRWorldRenderer)
WorldRenderEvents.BEFORE_ENTITIES.register(MatterProjectorPreviewRenderer)
ClientTickEvents.END_CLIENT_TICK.register(IRClientTickEvents)
ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register(
ClientSpriteRegistryCallback { _, registry ->
registry.register(identifier("block/lazuli_flux_container_lf_level"))
registry.register(identifier("gui/hud_damaged"))
registry.register(identifier("gui/hud_regenerating"))
registry.register(identifier("gui/hud_warning"))
registry.register(identifier("gui/hud_default"))
registry.register(identifier("particle/laser_particle_1"))
registry.register(identifier("particle/laser_particle_2"))
registry.register(identifier("particle/laser_particle_3"))
})
ParticleFactoryRegistry.getInstance().register(IndustrialRevolution.LASER_PARTICLE) { spriteProvider ->
FlameParticle.Factory(spriteProvider)
}
ClientPlayConnectionEvents.DISCONNECT.register { _, _ ->
IRConfig.readConfigs()
}
LivingEntityFeatureRendererRegistrationCallback.EVENT.register(IRLivingEntityFeatureRendererCallback)
TooltipComponentCallback.EVENT.register(IRTooltipComponentsCallback)
ItemTooltipCallback.EVENT.register(MiningRigInfoTooltipCallback)
AprilFools.init()
}
val MODULAR_CONTROLLER_KEYBINDING: KeyBinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.indrev.modular",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_K,
"category.indrev"
)
)
val GAMER_AXE_TOGGLE_KEYBINDING: KeyBinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.indrev.gamer_axe_toggle",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_G,
"category.indrev"
)
)
val CLIENT_NETWORK_STATE = Object2ObjectOpenHashMap, ClientNetworkState<*>>()
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/AttributeModifierProvider.kt
================================================
package me.steven.indrev.api
import com.google.common.collect.Multimap
import net.minecraft.entity.EquipmentSlot
import net.minecraft.entity.attribute.EntityAttribute
import net.minecraft.entity.attribute.EntityAttributeModifier
import net.minecraft.item.ItemStack
interface AttributeModifierProvider {
fun getAttributeModifiers(itemStack: ItemStack, equipmentSlot: EquipmentSlot): Multimap
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/CustomEnchantmentProvider.kt
================================================
package me.steven.indrev.api
import net.minecraft.enchantment.Enchantment
import net.minecraft.item.ItemStack
interface CustomEnchantmentProvider {
fun getLevel(enchantment: Enchantment, itemStack: ItemStack): Int
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/IREntityExtension.kt
================================================
package me.steven.indrev.api
import me.steven.indrev.inventories.IRInventory
interface IREntityExtension {
var machineInv: IRInventory?
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/IRPlayerEntityExtension.kt
================================================
package me.steven.indrev.api
import me.steven.indrev.tools.modular.ArmorModule
interface IRPlayerEntityExtension {
var shieldDurability: Double
var isRegenerating: Boolean
fun getMaxShieldDurability(): Double
fun getAppliedModules(): Map
fun applyModule(module: ArmorModule, level: Int)
fun isApplied(module: ArmorModule): Boolean
fun getAppliedLevel(module: ArmorModule): Int
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/IRServerPlayerEntityExtension.kt
================================================
package me.steven.indrev.api
interface IRServerPlayerEntityExtension : IRPlayerEntityExtension {
fun shouldSync(): Boolean
fun sync()
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/OreDataCards.kt
================================================
package me.steven.indrev.api
import me.steven.indrev.config.IRConfig
import me.steven.indrev.registry.IRItemRegistry
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.nbt.NbtCompound
import net.minecraft.nbt.NbtList
import net.minecraft.tag.TagKey
import net.minecraft.util.Identifier
import net.minecraft.util.registry.Registry
import java.util.*
import kotlin.math.pow
object OreDataCards {
const val MAX_SIZE = 2048
const val MAX_RICNHESS = 1.0
const val MAX_PER_CYCLE = 8
val INVALID_DATA = Data(emptyList(), mutableMapOf(), -1.0, -1, -1, -1, -1, -1)
fun isAllowed(stack: ItemStack): Boolean {
return IRConfig.miningRigConfig.allowedTags.any { stack.isIn(TagKey.of(Registry.ITEM_KEY, Identifier(it.key))) }
}
fun getCost(stack: ItemStack): Int {
return IRConfig.miningRigConfig.allowedTags.firstNotNullOfOrNull { if (stack.isIn(TagKey.of(Registry.ITEM_KEY, Identifier(it.key)))) it.value else null } ?: 0
}
fun readNbt(stack: ItemStack): Data? {
if (!stack.isOf(IRItemRegistry.ORE_DATA_CARD)) return null
val nbt = stack.getSubNbt("CardData") ?: return null
val entriesNbt = nbt.getList("Entries", 10)
val entries = mutableListOf()
entriesNbt.forEach { element ->
val itemId = (element as NbtCompound).getString("ItemId")
val optional = Registry.ITEM.getOrEmpty(Identifier(itemId))
if (!optional.isPresent) {
return INVALID_DATA
}
val count = element.getInt("Count")
entries.add(OreEntry(optional.get(), count))
}
val modifiersNbt = nbt.getList("ModifiersUsed", 10)
val modifiers = mutableMapOf()
modifiersNbt.forEach { element ->
val modifierId = (element as NbtCompound).getInt("Modifier")
val level = element.getInt("Level")
modifiers[Modifier.values()[modifierId]] = level
}
val richness = nbt.getDouble("Richness")
val size = nbt.getInt("Size")
val used = nbt.getInt("Used")
val speed = nbt.getInt("Speed")
val rng = nbt.getInt("Rng")
val energy = nbt.getInt("Energy")
return Data(entries.toList(), modifiers, richness, speed, rng, energy, size, used)
}
fun writeNbt(stack: ItemStack, data: Data) {
if (!stack.isOf(IRItemRegistry.ORE_DATA_CARD)) return
val nbt = stack.getOrCreateSubNbt("CardData")
val entriesNbt = NbtList()
data.entries.forEach { entry ->
val entryNbt = NbtCompound()
entryNbt.putString("ItemId", Registry.ITEM.getId(entry.item).toString())
entryNbt.putInt("Count", entry.count)
entriesNbt.add(entryNbt)
}
nbt.put("Entries", entriesNbt)
val modifiersNbt = NbtList()
data.modifiersUsed.forEach { (modifier, level) ->
val modifierNbt = NbtCompound()
modifierNbt.putInt("Modifier", modifier.ordinal)
modifierNbt.putInt("Level", level)
modifiersNbt.add(modifierNbt)
}
nbt.put("ModifiersUsed", modifiersNbt)
nbt.putDouble("Richness", data.richness)
nbt.putInt("Size", data.maxCycles)
nbt.putInt("Used", data.used)
nbt.putInt("Speed", data.speed)
nbt.putInt("Rng", data.rng)
nbt.putInt("Energy", data.energyRequired)
}
data class Data(val entries: List, val modifiersUsed: MutableMap, val richness: Double, val speed: Int, val rng: Int, val energyRequired: Int, val maxCycles: Int, var used: Int) {
fun isValid(): Boolean {
return this != INVALID_DATA && entries.isNotEmpty() && richness > 0 && maxCycles > 0 && maxCycles < MAX_SIZE
}
fun isEmpty(): Boolean {
return used >= maxCycles
}
fun pickRandom(random: Random): Item {
entries.forEach { entry ->
entry.order = -random.nextFloat().pow(1.0f / entry.count.toFloat())
}
return entries.minByOrNull { a -> a.order }!!.item
}
}
data class OreEntry(val item: Item, val count: Int, var order: Float = 0.0f)
enum class Modifier(val item: Item) {
RICHNESS(IRItemRegistry.ENRICHED_NIKOLITE_DUST()),
SPEED(Items.REDSTONE),
SIZE(Items.STONE),
RNG(Items.EMERALD);
val translationKey = "item.indrev.ore_data_card.modifier.${name.lowercase()}"
companion object {
fun isModifierItem(item: Item): Boolean = values().any { it.item == item }
fun byItem(item: Item): Modifier? = values().firstOrNull { it.item == item }
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/ServerWorldExtension.kt
================================================
package me.steven.indrev.api
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
import me.steven.indrev.networks.energy.EnergyNetworkState
import me.steven.indrev.networks.fluid.FluidNetworkState
import me.steven.indrev.networks.item.ItemNetworkState
import net.fabricmc.fabric.api.lookup.v1.block.BlockApiCache
import net.minecraft.util.math.Direction
import team.reborn.energy.api.EnergyStorage
interface ServerWorldExtension {
fun indrev_getEnergyCache(): Long2ObjectOpenHashMap>
fun indrev_getEnergyNetworkState(): EnergyNetworkState
fun indrev_getFluidNetworkState(): FluidNetworkState
fun indrev_getItemNetworkState(): ItemNetworkState
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/machines/Tier.kt
================================================
package me.steven.indrev.api.machines
enum class Tier(val io: Long, val id: String) {
MK1(64, "mk1"),
MK2(128, "mk2"),
MK3(512, "mk3"),
MK4(4096, "mk4"),
CREATIVE(4096, "creative");
fun next(): Tier {
return when (this) {
MK1 -> MK2
MK2 -> MK3
MK3 -> MK4
else -> error("no tier after $this")
}
}
companion object {
val VALUES = arrayOf(MK1, MK2, MK3, MK4)
val ALL_VALUES = values()
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/machines/TransferMode.kt
================================================
package me.steven.indrev.api.machines
enum class TransferMode(val rgb: Long, val input: Boolean, val output: Boolean) {
INPUT(0x997e75ff, true, false),
INPUT_FIRST(0x9975ff8e, true, false),
INPUT_SECOND(0x9975ff8e, true, false),
OUTPUT_FIRST(0x9975ff8e, false, true),
OUTPUT_SECOND(0x9975ff8e, false, true),
OUTPUT(0x99ffb175, false, true),
INPUT_OUTPUT(0x99d875ff, true, true),
NONE(-1, false, false);
fun next(): TransferMode = when (this) {
INPUT -> INPUT_FIRST
INPUT_FIRST -> INPUT_SECOND
INPUT_SECOND -> OUTPUT_FIRST
OUTPUT_FIRST -> OUTPUT_SECOND
OUTPUT_SECOND -> OUTPUT
OUTPUT -> INPUT_OUTPUT
INPUT_OUTPUT -> NONE
NONE -> INPUT
}
fun next(available: Array): TransferMode {
var current = this
for (i in values().indices) {
val possible = current.next()
if (available.contains(possible)) {
return possible
}
current = possible
}
return this
}
companion object {
val DEFAULT = arrayOf(INPUT, OUTPUT, INPUT_OUTPUT, NONE)
val SOLID_INFUSER = arrayOf(INPUT, OUTPUT, INPUT_OUTPUT, INPUT_FIRST, INPUT_SECOND, NONE)
val ELECTROLYTIC_SEPARATOR = arrayOf(TransferMode.INPUT, TransferMode.OUTPUT_FIRST, TransferMode.OUTPUT_SECOND, TransferMode.NONE)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/sideconfigs/Configurable.kt
================================================
package me.steven.indrev.api.sideconfigs
import me.steven.indrev.api.machines.TransferMode
import net.minecraft.block.BlockState
import net.minecraft.util.math.Direction
interface Configurable {
fun isConfigurable(type: ConfigurationType): Boolean
fun isFixed(type: ConfigurationType): Boolean
fun getValidConfigurations(type: ConfigurationType): Array
fun getCurrentConfiguration(type: ConfigurationType): SideConfiguration
fun applyDefault(state: BlockState, type: ConfigurationType, configuration: MutableMap)
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/sideconfigs/ConfigurationType.kt
================================================
package me.steven.indrev.api.sideconfigs
import me.steven.indrev.api.machines.TransferMode
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
enum class ConfigurationType(val title: Text, vararg val validModes: TransferMode) {
ITEM(TranslatableText("item.indrev.wrench.item"), TransferMode.INPUT, TransferMode.OUTPUT, TransferMode.INPUT_OUTPUT, TransferMode.INPUT_FIRST, TransferMode.INPUT_SECOND, TransferMode.NONE),
FLUID(TranslatableText("item.indrev.wrench.fluid"), TransferMode.INPUT, TransferMode.OUTPUT, TransferMode.INPUT_OUTPUT, TransferMode.NONE),
ENERGY(TranslatableText("item.indrev.wrench.energy"), TransferMode.INPUT, TransferMode.OUTPUT, TransferMode.NONE);
fun next(): ConfigurationType {
return when (this) {
ITEM -> FLUID
FLUID -> ENERGY
ENERGY -> ITEM
}
}
fun next(available: Array): ConfigurationType {
var current = this
for (i in values().indices) {
val possible = current.next()
if (available.contains(possible)) {
return possible
}
current = possible
}
return this
}
companion object {
fun getTypes(blockEntity: Configurable) = values().filter { type -> blockEntity.isConfigurable(type) && !blockEntity.isFixed(type) }.toTypedArray()
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/api/sideconfigs/SideConfiguration.kt
================================================
package me.steven.indrev.api.sideconfigs
import io.github.cottonmc.cotton.gui.widget.WGridPanel
import io.github.cottonmc.cotton.gui.widget.WToggleButton
import io.github.cottonmc.cotton.gui.widget.WWidget
import io.netty.buffer.Unpooled
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.blocks.machine.FacingMachineBlock
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import me.steven.indrev.gui.widgets.machines.WMachineSideDisplay
import me.steven.indrev.packets.common.ConfigureIOPackets
import me.steven.indrev.utils.add
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.nbt.NbtCompound
import net.minecraft.network.PacketByteBuf
import net.minecraft.text.TranslatableText
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.World
import java.util.*
import java.util.function.Consumer
data class SideConfiguration(val type: ConfigurationType, private val transferConfig: EnumMap = EnumMap(Direction::class.java))
: MutableMap by transferConfig {
var autoPush = true
var autoPull = true
init {
Direction.values().forEach { dir -> this[dir] = TransferMode.NONE }
}
fun canInput(direction: Direction): Boolean {
return this[direction]?.input == true
}
fun canOutput(direction: Direction): Boolean {
return this[direction]?.output == true
}
fun writeNbt(tag: NbtCompound?) {
var transferConfigTag = tag?.getCompound("TransferConfig")
if (tag?.contains("TransferConfig") == false) {
transferConfigTag = NbtCompound()
tag.put("TransferConfig", transferConfigTag)
}
val configTag = NbtCompound()
forEach { (dir, mode) ->
configTag.putString(dir.toString(), mode.toString())
}
transferConfigTag?.put(type.toString().lowercase(Locale.getDefault()), configTag)
configTag.putBoolean("AutoPush", autoPush)
configTag.putBoolean("AutoPull", autoPull)
}
fun readNbt(tag: NbtCompound?) {
if (tag?.contains("TransferConfig") == true) {
val transferConfigTag = tag.getCompound("TransferConfig")
val configTag = transferConfigTag.getCompound(type.toString().lowercase(Locale.getDefault()))
Direction.values().forEach { dir ->
val value = configTag.getString(dir.toString()).uppercase(Locale.getDefault())
if (value.isNotEmpty()) {
val mode = TransferMode.valueOf(value)
this[dir] = mode
}
}
if (configTag.contains("AutoPush"))
autoPush = configTag.getBoolean("AutoPush")
if (configTag.contains("AutoPull"))
autoPull = configTag.getBoolean("AutoPull")
}
}
fun writeBuf(buf: PacketByteBuf) {
buf.writeBoolean(autoPush)
buf.writeBoolean(autoPull)
forEach { dir, mode ->
buf.writeByte(dir.ordinal)
buf.writeByte(mode.ordinal)
}
}
fun readBuf(buf: PacketByteBuf) {
autoPush = buf.readBoolean()
autoPull = buf.readBoolean()
repeat(6) {
val direction = Direction.values()[buf.readByte().toInt()]
val mode = TransferMode.values()[buf.readByte().toInt()]
this[direction] = mode
}
}
fun getConfigurationPanel(world: World, pos: BlockPos, configurable: Configurable, playerInventory: PlayerInventory, type: ConfigurationType): WWidget {
val root = WGridPanel()
root.setSize(100, 128)
val configuration = this
if (configuration.type == ConfigurationType.ITEM) {
val autoPushBtn = WToggleButton(TranslatableText("item.indrev.wrench.autopush"))
autoPushBtn.toggle = configuration.autoPush
autoPushBtn.onToggle = Consumer { v ->
configuration.autoPush = v
val buf = PacketByteBuf(Unpooled.buffer())
buf.writeEnumConstant(type)
buf.writeByte(0)
buf.writeBlockPos(pos)
buf.writeBoolean(v)
ClientPlayNetworking.send(ConfigureIOPackets.UPDATE_AUTO_OPERATION_PACKET_ID, buf)
}
root.add(autoPushBtn, 0, 4)
val autoPullBtn = WToggleButton(TranslatableText("item.indrev.wrench.autopull"))
autoPullBtn.toggle = configuration.autoPull
autoPullBtn.onToggle = Consumer { v ->
configuration.autoPull = v
val buf = PacketByteBuf(Unpooled.buffer())
buf.writeEnumConstant(type)
buf.writeByte(1)
buf.writeBlockPos(pos)
buf.writeBoolean(v)
ClientPlayNetworking.send(ConfigureIOPackets.UPDATE_AUTO_OPERATION_PACKET_ID, buf)
}
root.add(autoPullBtn, 0.0, 4.8)
}
val blockState = world.getBlockState(pos)
val machineVisualizerPanel = WGridPanel()
MachineSide.values().forEach { side ->
var facing =
when {
blockState.contains(HorizontalFacingMachineBlock.HORIZONTAL_FACING) ->
blockState[HorizontalFacingMachineBlock.HORIZONTAL_FACING]
blockState.contains(FacingMachineBlock.FACING) ->
blockState[FacingMachineBlock.FACING]
else ->
Direction.UP
}
if (facing.axis.isVertical) {
facing = playerInventory.player.horizontalFacing.opposite
}
val direction = offset(facing, side.direction)
val mode = configuration[direction]!!
val widget = WMachineSideDisplay(side, direction, mode, world, pos)
widget.setOnClick {
widget.mode = widget.mode.next(configurable.getValidConfigurations(type))
configuration[direction] = widget.mode
val buf = PacketByteBuf(Unpooled.buffer())
buf.writeEnumConstant(type)
buf.writeBlockPos(pos)
buf.writeInt(direction.id)
buf.writeInt(widget.mode.ordinal)
ClientPlayNetworking.send(ConfigureIOPackets.UPDATE_MACHINE_SIDE_PACKET_ID, buf)
}
machineVisualizerPanel.add(widget, (side.x) * 1.2, (side.y) * 1.2)
}
root.add(machineVisualizerPanel, 0.5, 0.0)
return root
}
private fun offset(facing: Direction, side: Direction): Direction {
return if (side.axis.isVertical) side
else when (facing) {
Direction.NORTH -> side
Direction.SOUTH -> side.opposite
Direction.WEST -> side.rotateYCounterclockwise()
Direction.EAST -> side.rotateYClockwise()
else -> side
}
}
enum class MachineSide(val x: Int, val y: Int, val direction: Direction, val u1: Float, val v1: Float, val u2: Float, val v2: Float) {
FRONT(1, 1, Direction.NORTH, 5.333f, 5.333f, 10.666f, 10.666f),
LEFT(0, 1, Direction.EAST, 0.0f, 5.333f, 5.332f, 10.666f),
BACK(2, 2, Direction.SOUTH, 10.667f, 10.667f, 16.0f, 16f),
RIGHT(2, 1, Direction.WEST, 10.667f, 5.333f, 16.0f, 10.665f),
TOP(1, 0, Direction.UP, 5.333f, 0.0f, 10.666f, 5.333f),
BOTTOM(1, 2, Direction.DOWN, 5.333f, 10.667f, 10.666f, 15.998f)
}
companion object {
val EMPTY_ITEM = SideConfiguration(ConfigurationType.ITEM)
val EMPTY_FLUID = SideConfiguration(ConfigurationType.FLUID)
val EMPTY_ENERGY = SideConfiguration(ConfigurationType.ENERGY)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/armor/IRArmorMaterial.kt
================================================
package me.steven.indrev.armor
import me.steven.indrev.registry.IRItemRegistry
import net.minecraft.entity.EquipmentSlot
import net.minecraft.item.ArmorMaterial
import net.minecraft.recipe.Ingredient
import net.minecraft.sound.SoundEvent
import net.minecraft.sound.SoundEvents
enum class IRArmorMaterial(
private val armorName: String,
private val durabilityMultiplier: Int,
private val armorValues: IntArray,
private val enchantability: Int,
private val equipSound: SoundEvent,
private val toughness: Float,
private val knockbackResistance: Float,
private val repairIngredient: () -> Ingredient?) : ArmorMaterial {
MODULAR(
"modular", 0, intArrayOf(1, 3, 2, 1), 15,
SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.0F, 1.0F, { null }
),
STEEL_ELYTRA(
"reinforced_elytra", 30, intArrayOf(1, 1, 1, 1), 15,
SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.0F, 0F, { Ingredient.ofItems(IRItemRegistry.STEEL_PLATE()) }
),
JETPACK(
"jetpack", 30, intArrayOf(1, 1, 1, 1), 15,
SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.0F, 0F, { null }
),
STEEL(
"steel", 30, intArrayOf(2, 6, 7, 2), 15,
SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.0F, 0F, { Ingredient.ofItems(IRItemRegistry.STEEL_INGOT()) }
),
COPPER(
"copper", 14, intArrayOf(2, 4, 5, 2), 15,
SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, { Ingredient.ofItems(IRItemRegistry.COPPER_INGOT()) }
),
TIN(
"tin", 10, intArrayOf(1, 4, 5, 2), 15,
SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, { Ingredient.ofItems(IRItemRegistry.TIN_INGOT()) }
),
BRONZE(
"bronze", 15, intArrayOf(2, 5, 6, 2), 15,
SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, { Ingredient.ofItems(IRItemRegistry.BRONZE_INGOT()) }
),
LEAD(
"lead", 20, intArrayOf(2, 4, 4, 1), 15,
SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, { Ingredient.ofItems(IRItemRegistry.LEAD_INGOT()) }
),
SILVER(
"silver", 30, intArrayOf(1, 4, 4, 1), 15,
SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, { Ingredient.ofItems(IRItemRegistry.SILVER_INGOT()) }
);
override fun getName(): String = armorName
override fun getEquipSound(): SoundEvent = equipSound
override fun getRepairIngredient(): Ingredient? = repairIngredient()
override fun getEnchantability(): Int = enchantability
override fun getProtectionAmount(slot: EquipmentSlot): Int = this.armorValues[slot.entitySlotId]
override fun getDurability(slot: EquipmentSlot): Int = BASE_DURABILITY[slot.entitySlotId] * durabilityMultiplier
override fun getKnockbackResistance(): Float = knockbackResistance
override fun getToughness(): Float = toughness
companion object {
private val BASE_DURABILITY = intArrayOf(13, 15, 16, 11)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/armor/ModuleFeatureRenderer.kt
================================================
package me.steven.indrev.armor
import me.steven.indrev.items.armor.IRModularArmorItem
import me.steven.indrev.utils.identifier
import net.minecraft.client.render.OverlayTexture
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer
import net.minecraft.client.render.entity.feature.FeatureRendererContext
import net.minecraft.client.render.entity.model.BipedEntityModel
import net.minecraft.client.render.item.ItemRenderer
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.entity.EquipmentSlot
import net.minecraft.entity.LivingEntity
import net.minecraft.item.ArmorItem
import net.minecraft.util.Identifier
class ModuleFeatureRenderer, A : BipedEntityModel>(
context: FeatureRendererContext,
private val leggingsModel: A,
private val bodyModel: A
) : ArmorFeatureRenderer(context, leggingsModel, bodyModel) {
override fun render(matrixStack: MatrixStack, vertexConsumerProvider: VertexConsumerProvider, i: Int, livingEntity: T, f: Float, g: Float, h: Float, j: Float, k: Float, l: Float) {
renderArmor(matrixStack, vertexConsumerProvider, livingEntity, EquipmentSlot.CHEST, i, getArmor(EquipmentSlot.CHEST))
renderArmor(matrixStack, vertexConsumerProvider, livingEntity, EquipmentSlot.LEGS, i, getArmor(EquipmentSlot.LEGS))
renderArmor(matrixStack, vertexConsumerProvider, livingEntity, EquipmentSlot.FEET, i, getArmor(EquipmentSlot.FEET))
renderArmor(matrixStack, vertexConsumerProvider, livingEntity, EquipmentSlot.HEAD, i, getArmor(EquipmentSlot.HEAD))
}
private fun renderArmor(matrices: MatrixStack, vertexConsumers: VertexConsumerProvider, livingEntity: T, equipmentSlot: EquipmentSlot, light: Int, bipedEntityModel: A) {
val itemStack = livingEntity.getEquippedStack(equipmentSlot)
val item = itemStack.item as? IRModularArmorItem ?: return
if (item.slotType == equipmentSlot) {
(this.contextModel as? BipedEntityModel)?.setAttributes(bipedEntityModel) ?: return
setVisible(bipedEntityModel, equipmentSlot)
val rgb = item.getColor(itemStack)
val r = (rgb and 0xFF0000 shr 16) / 255f
val g = (rgb and 0xFF00 shr 8) / 255f
val b = (rgb and 0xFF) / 255f
item.getInstalled(itemStack).filter { it.slots.contains(equipmentSlot) }.forEach { module ->
if (module.hasTexture) {
renderArmorParts(
matrices, vertexConsumers, light, item, itemStack.hasGlint(), bipedEntityModel, usesSecondLayer(equipmentSlot), r, g, b, module.key
)
if (module.hasOverlay) {
renderArmorParts(
matrices, vertexConsumers, 15728880, item, itemStack.hasGlint(), bipedEntityModel, usesSecondLayer(equipmentSlot), r, g, b, "${module.key}_overlay"
)
}
}
}
}
}
private fun renderArmorParts(
matrixStack: MatrixStack,
vertexConsumerProvider: VertexConsumerProvider,
light: Int,
armorItem: ArmorItem,
hasGlint: Boolean,
bipedEntityModel: A,
secondLayer: Boolean,
r: Float, g: Float, b: Float,
overlay: String?) {
val vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(getArmorTexture(armorItem, secondLayer, overlay)), false, hasGlint)
bipedEntityModel.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, r, g, b, 1.0f)
}
private fun getArmor(slot: EquipmentSlot): A {
return if (usesSecondLayer(slot)) leggingsModel else bodyModel
}
private fun usesSecondLayer(slot: EquipmentSlot): Boolean {
return slot == EquipmentSlot.LEGS
}
private fun getArmorTexture(armorItem: ArmorItem, secondLayer: Boolean, overlay: String?): Identifier {
val path = "textures/models/armor/" + armorItem.material.name + "_layer_" + (if (secondLayer) 2 else 1) + (if (overlay == null) "" else "_$overlay") + ".png"
return MODULAR_ARMOR_TEXTURE_CACHE.computeIfAbsent(path) { id -> identifier(id) }
}
companion object {
val MODULAR_ARMOR_TEXTURE_CACHE = mutableMapOf()
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/armor/ReinforcedElytraFeatureRenderer.kt
================================================
package me.steven.indrev.armor
import me.steven.indrev.items.armor.ReinforcedElytraItem
import me.steven.indrev.utils.identifier
import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.minecraft.client.network.AbstractClientPlayerEntity
import net.minecraft.client.render.OverlayTexture
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.entity.PlayerModelPart
import net.minecraft.client.render.entity.feature.FeatureRenderer
import net.minecraft.client.render.entity.feature.FeatureRendererContext
import net.minecraft.client.render.entity.model.ElytraEntityModel
import net.minecraft.client.render.entity.model.EntityModel
import net.minecraft.client.render.entity.model.EntityModelLayers
import net.minecraft.client.render.entity.model.EntityModelLoader
import net.minecraft.client.render.item.ItemRenderer
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.entity.EquipmentSlot
import net.minecraft.entity.LivingEntity
@Environment(EnvType.CLIENT)
class ReinforcedElytraFeatureRenderer>(
context: FeatureRendererContext,
loader: EntityModelLoader
) : FeatureRenderer(context) {
private val elytraModel: ElytraEntityModel = ElytraEntityModel(loader.getModelPart(EntityModelLayers.ELYTRA))
override fun render(
matrices: MatrixStack,
vertexConsumers: VertexConsumerProvider,
light: Int,
entity: T,
limbAngle: Float,
limbDistance: Float,
tickDelta: Float,
animationProgress: Float,
headYaw: Float,
headPitch: Float
) {
val itemStack = entity.getEquippedStack(EquipmentSlot.CHEST)
if (ReinforcedElytraItem.hasValidElytra(itemStack)) {
val textureId = when {
entity !is AbstractClientPlayerEntity -> REINFORCED_ELYTRA_SKIN
entity.canRenderElytraTexture() && entity.elytraTexture != null -> entity.elytraTexture!!
entity.canRenderCapeTexture() && entity.capeTexture != null && entity.isPartVisible(PlayerModelPart.CAPE) -> entity.capeTexture!!
else -> REINFORCED_ELYTRA_SKIN
}
matrices.push()
matrices.translate(0.0, 0.0, 0.125)
this.contextModel.copyStateTo(elytraModel)
elytraModel.setAngles(entity, limbAngle, limbDistance, animationProgress, headYaw, headPitch)
val vertexConsumer = ItemRenderer.getArmorGlintConsumer(
vertexConsumers,
RenderLayer.getArmorCutoutNoCull(textureId),
false,
itemStack.hasGlint()
)
elytraModel.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, 1.0f)
matrices.pop()
}
}
companion object {
private val REINFORCED_ELYTRA_SKIN = identifier("textures/entity/reinforced_elytra.png")
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/BaseBlockEntity.kt
================================================
package me.steven.indrev.blockentities
import com.google.common.base.Preconditions
import me.steven.indrev.components.GuiSyncableComponent
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.nbt.NbtCompound
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.math.BlockPos
abstract class BaseBlockEntity(type: BlockEntityType<*>, pos: BlockPos, state: BlockState) : BlockEntity(type, pos, state) {
open val guiSyncableComponent: GuiSyncableComponent? = null
fun sync() {
Preconditions.checkNotNull(world) // Maintain distinct failure case from below
check(world is ServerWorld) { "Cannot call sync() on the logical client! Did you check world.isClient first?" }
(world as ServerWorld).chunkManager.markForUpdate(getPos())
}
abstract fun toTag(tag: NbtCompound)
abstract fun fromTag(tag: NbtCompound)
open fun toClientTag(tag: NbtCompound) {
toTag(tag)
}
open fun fromClientTag(tag: NbtCompound) {
fromTag(tag)
}
override fun toUpdatePacket(): BlockEntityUpdateS2CPacket {
return BlockEntityUpdateS2CPacket.create(this)
}
override fun toInitialChunkDataNbt(): NbtCompound {
val nbt = super.toInitialChunkDataNbt()
toClientTag(nbt)
nbt.putBoolean("#c", true)
return nbt
}
override fun writeNbt(nbt: NbtCompound) {
super.writeNbt(nbt)
toTag(nbt)
}
override fun readNbt(nbt: NbtCompound) {
super.readNbt(nbt)
if (nbt.contains("#c")) {
fromClientTag(nbt)
} else {
fromTag(nbt)
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/BaseMachineBlockEntity.kt
================================================
package me.steven.indrev.blockentities
import me.steven.indrev.api.sideconfigs.Configurable
import net.minecraft.block.BlockState
import net.minecraft.block.InventoryProvider
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.util.math.BlockPos
abstract class BaseMachineBlockEntity(type: BlockEntityType<*>, pos: BlockPos, state: BlockState)
: BaseBlockEntity(type, pos, state), InventoryProvider, Configurable, Syncable {
/**
* Whether the machine should call #sync or not
*/
open val syncToWorld = false
var isMarkedForUpdate: Boolean = true
override fun markForUpdate(condition: () -> Boolean) {
isMarkedForUpdate = isMarkedForUpdate || condition()
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/GlobalStateController.kt
================================================
package me.steven.indrev.blockentities
import it.unimi.dsi.fastutil.longs.Long2BooleanOpenHashMap
import it.unimi.dsi.fastutil.longs.Long2ObjectMap
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
import me.steven.indrev.packets.client.MachineStateUpdatePacket
import me.steven.indrev.utils.component1
import me.steven.indrev.utils.component2
import me.steven.indrev.utils.component3
import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
import net.minecraft.client.MinecraftClient
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.ChunkPos
import net.minecraft.world.World
import java.util.function.LongFunction
object GlobalStateController {
@Environment(EnvType.CLIENT)
val chunksToUpdate: Long2ObjectMap> = Long2ObjectOpenHashMap()
@Environment(EnvType.CLIENT)
val workingStateTracker = Long2BooleanOpenHashMap()
@Environment(EnvType.CLIENT)
fun queueUpdate(pos: BlockPos) {
val chunkPos = ChunkPos.toLong(pos.x shr 4, pos.z shr 4)
if (MinecraftClient.getInstance().isOnThread)
chunksToUpdate.computeIfAbsent(chunkPos, LongFunction { hashSetOf() }).add(pos)
else
MinecraftClient.getInstance().execute { chunksToUpdate.computeIfAbsent(chunkPos, LongFunction { hashSetOf() }).add(pos) }
}
fun update(world: World, pos: BlockPos, workingState: Boolean) {
val (x, y, z) = pos
val players = world.server!!.playerManager.playerList
for (i in players.indices) {
val player = players[i]
if (player.world.registryKey === world.registryKey) {
val xOffset = x - player.x
val yOffset = y - player.y
val zOffset = z - player.z
if (xOffset * xOffset + yOffset * yOffset + zOffset * zOffset < 64 * 64) {
val buf = PacketByteBufs.create()
buf.writeLong(pos.asLong())
buf.writeBoolean(workingState)
ServerPlayNetworking.send(player, MachineStateUpdatePacket.UPDATE_PACKET_ID, buf)
}
}
}
}
@Environment(EnvType.CLIENT)
fun initClient() {
var ticks = 0
ClientTickEvents.END_CLIENT_TICK.register { client ->
ticks++
val world = client.world
if (world != null && ticks % 15 == 0) {
chunksToUpdate.values.removeIf { positions ->
positions.forEach { (x, y, z) ->
client.worldRenderer.scheduleBlockRenders(x , y, z, x, y,z)
}
true
}
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/MachineBlockEntity.kt
================================================
package me.steven.indrev.blockentities
import me.steven.indrev.IREnergyStorage
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.api.sideconfigs.SideConfiguration
import me.steven.indrev.blocks.machine.MachineBlock
import me.steven.indrev.components.*
import me.steven.indrev.components.multiblock.MultiBlockComponent
import me.steven.indrev.config.IConfig
import me.steven.indrev.config.IRConfig
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import me.steven.indrev.utils.transferEnergy
import me.steven.indrev.utils.transferFluids
import me.steven.indrev.utils.transferItems
import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.minecraft.block.BlockState
import net.minecraft.client.MinecraftClient
import net.minecraft.inventory.SidedInventory
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.WorldAccess
import kotlin.collections.set
abstract class MachineBlockEntity(val tier: Tier, val registry: MachineRegistry, pos: BlockPos, state: BlockState)
: BaseMachineBlockEntity(registry.blockEntityType(tier), pos, state) {
val validConnections = Direction.values().toMutableList()
override var guiSyncableComponent: GuiSyncableComponent? = GuiSyncableComponent()
var energy: Long by autosync(ENERGY_ID, 0L) { value ->
when (tier) {
Tier.CREATIVE -> energyCapacity
else -> value.coerceIn(0, energyCapacity)
}
}
var inventoryComponent: InventoryComponent? = null
var temperatureComponent: TemperatureComponent? = null
var fluidComponent: FluidComponent? = null
var multiblockComponent: MultiBlockComponent? = null
var enhancerComponent: EnhancerComponent? = null
var itemTransferCooldown = 0
var workingState: Boolean = false
set(value) {
val update = value != field
field = value
if (update && world?.isClient == false)
GlobalStateController.update(world!!, pos, value)
}
get() {
if (world?.isClient == true && GlobalStateController.workingStateTracker.contains(pos.asLong())) {
MinecraftClient.getInstance().execute { field = GlobalStateController.workingStateTracker.remove(pos.asLong()) }
}
return field
}
var ticks = 0
@Suppress("UNCHECKED_CAST")
val config: T by lazy { registry.config(tier) as T }
open val maxInput: Long = tier.io
open val maxOutput: Long = tier.io
open val energyCapacity: Long get() = config.maxEnergyStored + (IRConfig.upgrades.bufferUpgradeModifier * (enhancerComponent?.getCount(Enhancer.BUFFER) ?: 0))
init {
trackLong(MAX_ENERGY_ID) { energyCapacity }
}
open val storage = MachineEnergyStorage()
protected open fun machineTick() {}
@Environment(EnvType.CLIENT)
open fun machineClientTick() {}
fun tick() {
inventoryComponent?.run { enhancerComponent?.updateEnhancers(inventory) }
ticks++
multiblockComponent?.tick(world!!, pos, cachedState)
if (multiblockComponent?.isBuilt(world!!, pos, cachedState) == false) return
transferEnergy()
transferItems()
transferFluids()
machineTick()
if (isMarkedForUpdate) {
markDirty()
if (syncToWorld) sync()
isMarkedForUpdate = false
}
}
open fun getProcessingSpeed(): Double {
return 1.0 + (IRConfig.upgrades.speedUpgradeModifier * (enhancerComponent?.getCount(Enhancer.SPEED) ?: 0))
}
open fun getEnergyCost(): Long = 0
// internal consumption
fun use(amount: Long): Boolean {
val extracted = amount.coerceAtMost(energy)
if (extracted == amount) {
this.energy -= extracted
return true
}
return false
}
fun canUse(amount: Long): Boolean {
val extracted = amount.coerceAtMost(energy)
return extracted == amount
}
override fun getInventory(state: BlockState?, world: WorldAccess?, pos: BlockPos?): SidedInventory? = inventoryComponent?.inventory
override fun isConfigurable(type: ConfigurationType): Boolean {
return when (type) {
ConfigurationType.ITEM -> inventoryComponent != null
&& (inventoryComponent?.inventory?.inputSlots?.isNotEmpty() == true
|| inventoryComponent?.inventory?.outputSlots?.isNotEmpty() == true)
ConfigurationType.FLUID -> fluidComponent != null
ConfigurationType.ENERGY -> false
}
}
override fun applyDefault(state: BlockState, type: ConfigurationType, configuration: MutableMap) {
val direction = (state.block as MachineBlock).getFacing(state)
when (type) {
ConfigurationType.ITEM -> {
configuration[direction.rotateYClockwise()] = TransferMode.INPUT
configuration[direction.rotateYCounterclockwise()] = TransferMode.OUTPUT
}
ConfigurationType.ENERGY -> throw IllegalArgumentException("cannot apply energy configuration to $this")
else -> return
}
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.ITEM -> TransferMode.DEFAULT
ConfigurationType.FLUID, ConfigurationType.ENERGY -> arrayOf(TransferMode.INPUT, TransferMode.OUTPUT, TransferMode.NONE)
}
}
override fun getCurrentConfiguration(type: ConfigurationType): SideConfiguration {
return when (type) {
ConfigurationType.ITEM -> inventoryComponent!!.itemConfig
ConfigurationType.FLUID -> fluidComponent!!.transferConfig
ConfigurationType.ENERGY -> error("nope")
}
}
override fun isFixed(type: ConfigurationType): Boolean = false
open fun getFluidTransferRate(): Long = when (tier) {
Tier.MK1 -> bucket / 3
Tier.MK2 -> bucket * 2 / 3
else -> bucket
}
override fun fromTag(tag: NbtCompound) {
inventoryComponent?.readNbt(tag)
inventoryComponent?.run { enhancerComponent?.updateEnhancers(inventory) }
temperatureComponent?.readNbt(tag)
fluidComponent?.fromTag(tag)
multiblockComponent?.readNbt(tag)
energy = tag.getLong("Energy")
}
override fun toTag(tag: NbtCompound) {
tag.putLong("Energy", energy)
inventoryComponent?.writeNbt(tag)
temperatureComponent?.writeNbt(tag)
fluidComponent?.toTag(tag)
multiblockComponent?.writeNbt(tag)
}
override fun fromClientTag(tag: NbtCompound) {
}
override fun toClientTag(tag: NbtCompound) {
}
open inner class MachineEnergyStorage : IREnergyStorage() {
override fun getAmount(): Long = energy
override fun setAmount(v: Long) {
energy = v
}
override fun getCapacity(): Long = energyCapacity
override fun getMaxExtract(side: Direction?): Long = maxOutput
override fun getMaxInsert(side: Direction?): Long = maxInput
override fun onFinalCommit() {
super.onFinalCommit()
markForUpdate()
}
}
companion object {
const val ENERGY_ID = 0
const val MAX_ENERGY_ID = 1
const val TEMPERATURE_ID = 2
const val MAX_TEMPERATURE_ID = 3
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/Syncable.kt
================================================
package me.steven.indrev.blockentities
interface Syncable {
fun markForUpdate(condition: () -> Boolean = { true })
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/cables/BasePipeBlockEntity.kt
================================================
package me.steven.indrev.blockentities.cables
import com.google.common.base.Preconditions
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blocks.machine.pipes.BasePipeBlock
import me.steven.indrev.networks.Network
import me.steven.indrev.registry.IRBlockRegistry
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.client.MinecraftClient
import net.minecraft.nbt.NbtCompound
import net.minecraft.nbt.NbtList
import net.minecraft.nbt.NbtOps
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
class BasePipeBlockEntity(val pipeType: Network.Type<*>, tier: Tier, pos: BlockPos, state: BlockState) :
BlockEntity(when (tier) {
Tier.MK1 -> IRBlockRegistry.COVERABLE_BLOCK_ENTITY_TYPE_MK1
Tier.MK2 -> IRBlockRegistry.COVERABLE_BLOCK_ENTITY_TYPE_MK2
Tier.MK3 -> IRBlockRegistry.COVERABLE_BLOCK_ENTITY_TYPE_MK3
Tier.MK4 -> IRBlockRegistry.COVERABLE_BLOCK_ENTITY_TYPE_MK4
Tier.CREATIVE -> error("no creative cable")
}, pos, state), RenderAttachmentBlockEntity {
val connections = Object2ObjectOpenHashMap()
init {
connections.defaultReturnValue(BasePipeBlock.ConnectionType.NONE)
}
var coverState: BlockState? = null
override fun getRenderAttachmentData(): Any {
return PipeRenderData(
coverState,
connections.filterValues { type -> type == BasePipeBlock.ConnectionType.CONNECTED }.keys.toTypedArray()
)
}
override fun readNbt(tag: NbtCompound) {
this.coverState = null
if (tag.contains("coverState")) {
BlockState.CODEC.decode(NbtOps.INSTANCE, tag.getCompound("coverState")).result().ifPresent { pair ->
this.coverState = pair.first
}
}
val list = tag.getList("connections", 10)
connections.clear()
list?.forEach { t ->
t as NbtCompound
val dir = Direction.byId(t.getByte("d").toInt())
val type = BasePipeBlock.ConnectionType.byId(t.getByte("c").toInt())
connections[dir] = type
}
super.readNbt(tag)
if (world != null && world!!.isClient) {
MinecraftClient.getInstance().worldRenderer.updateBlock(world!!, pos, null, null, 0)
}
}
override fun writeNbt(tag: NbtCompound) {
if (this.coverState != null) {
BlockState.CODEC.encode(this.coverState, NbtOps.INSTANCE, NbtCompound()).result().ifPresent { t ->
tag.put("coverState", t)
}
}
val list = NbtList()
connections.forEach { (dir, conn) ->
if (conn != BasePipeBlock.ConnectionType.NONE) {
val t = NbtCompound()
t.putByte("d", dir.id.toByte())
t.putByte("c", conn.id.toByte())
list.add(t)
}
}
tag.put("connections", list)
}
fun sync() {
Preconditions.checkNotNull(world) // Maintain distinct failure case from below
check(world is ServerWorld) { "Cannot call sync() on the logical client! Did you check world.isClient first?" }
(world as ServerWorld).chunkManager.markForUpdate(getPos())
}
override fun toUpdatePacket(): BlockEntityUpdateS2CPacket {
return BlockEntityUpdateS2CPacket.create(this)
}
override fun toInitialChunkDataNbt(): NbtCompound {
val nbt = super.toInitialChunkDataNbt()
writeNbt(nbt)
return nbt
}
data class PipeRenderData(val cover: BlockState?, val connections: Array)
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/CompressorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.CompressorRecipe
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
class CompressorBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.COMPRESSOR_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 700..1100, 1500)
this.enhancerComponent = EnhancerComponent(intArrayOf(4, 5, 6, 7), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slot = 2 }
output { slot = 3 }
}
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
}
override val type: IRRecipeType = CompressorRecipe.TYPE
companion object {
const val CRAFTING_COMPONENT_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/CompressorFactoryBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.CraftingComponent
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.multiblock.MultiBlockComponent
import me.steven.indrev.components.multiblock.definitions.FactoryStructureDefinition
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.CompressorRecipe
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
class CompressorFactoryBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.COMPRESSOR_FACTORY_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 700..1100, 1400)
this.enhancerComponent = EnhancerComponent(intArrayOf(2, 3, 4, 5), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slots = intArrayOf(6, 8, 10, 12, 14) }
output { slots = intArrayOf(7, 9, 11, 13, 15) }
}
this.craftingComponents = Array(5) { index ->
val component = CraftingComponent(index, this).apply {
inputSlots = intArrayOf(6 + (index * 2))
outputSlots = intArrayOf(6 + (index * 2) + 1)
}
trackObject(CRAFTING_COMPONENT_START_ID + index, component)
component
}
this.multiblockComponent = MultiBlockComponent(FactoryStructureDefinition.SELECTOR)
}
override val syncToWorld: Boolean = true
override val type: IRRecipeType = CompressorRecipe.TYPE
override fun fromClientTag(tag: NbtCompound) {
multiblockComponent?.readNbt(tag)
}
override fun toClientTag(tag: NbtCompound) {
multiblockComponent?.writeNbt(tag)
}
companion object {
const val CRAFTING_COMPONENT_START_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/CondenserBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.blocks.machine.MachineBlock
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.CondenserRecipe
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
class CondenserBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.CONDENSER_REGISTRY, pos, state) {
init {
this.enhancerComponent = EnhancerComponent(intArrayOf(3, 4, 5, 6), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
output { slot = 2 }
coolerSlot = 1
}
this.fluidComponent = object : FluidComponent({ this }, bucket * 8) {
init {
this.inputTanks = intArrayOf(0)
}
}
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
trackObject(INPUT_TANK_ID, fluidComponent!![0])
}
override val syncToWorld: Boolean = true
override val type: IRRecipeType = CondenserRecipe.TYPE
override fun getMaxCount(enhancer: Enhancer): Int {
return if (enhancer == Enhancer.SPEED) 4 else super.getMaxCount(enhancer)
}
override fun applyDefault(
state: BlockState,
type: ConfigurationType,
configuration: MutableMap
) {
val direction = (state.block as MachineBlock).getFacing(state)
when (type) {
ConfigurationType.ITEM -> {
configuration[direction.rotateYCounterclockwise()] = TransferMode.OUTPUT
}
else -> super.applyDefault(state, type, configuration)
}
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.ITEM -> arrayOf(TransferMode.OUTPUT, TransferMode.NONE)
else -> return super.getValidConfigurations(type)
}
}
override fun fromClientTag(tag: NbtCompound) {
fluidComponent!!.fromTag(tag)
}
override fun toClientTag(tag: NbtCompound) {
fluidComponent!!.toTag(tag)
}
companion object {
const val CRAFTING_COMPONENT_ID = 2
const val INPUT_TANK_ID = 3
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/CondenserBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.crafters
import alexiil.mc.lib.attributes.fluid.render.FluidRenderFace
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Direction
class CondenserBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: CondenserBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
val fluidComponent = entity?.fluidComponent ?: return
val faces = when (entity.cachedState[HorizontalFacingMachineBlock.HORIZONTAL_FACING]) {
Direction.NORTH -> NORTH_FACE
Direction.SOUTH -> SOUTH_FACE
Direction.WEST -> WEST_FACE
Direction.EAST -> EAST_FACE
else -> return
}
val volume = fluidComponent[0]
if (!volume.isEmpty) {
volume.render(faces, vertexConsumers, matrices)
}
}
companion object {
private val NORTH_FACE =
listOf(FluidRenderFace.createFlatFaceZ(0.815, 0.625, -0.005, 0.19, 0.815, -0.005, 1.0, true, false))
private val SOUTH_FACE =
listOf(FluidRenderFace.createFlatFaceZ(0.185, 0.625, 1.005, 0.81, 0.815, 1.005, 1.0, true, false))
private val WEST_FACE =
listOf(FluidRenderFace.createFlatFaceX(-0.005, 0.625, 0.185, -0.005, 0.815, 0.81, 1.0, false, false))
private val EAST_FACE =
listOf(FluidRenderFace.createFlatFaceX(1.005, 0.625, 0.815, 1.005, 0.815, 0.19, 1.0, false, false))
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/CraftingMachineBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.components.CraftingComponent
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.config.HeatMachineConfig
import me.steven.indrev.config.IRConfig
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.IRecipeGetter
import me.steven.indrev.recipes.machines.IRRecipe
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.entity.ExperienceOrbEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.nbt.NbtList
import net.minecraft.recipe.SmeltingRecipe
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.Identifier
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Vec3d
import net.minecraft.world.World
import java.util.function.IntBinaryOperator
import kotlin.math.floor
abstract class CraftingMachineBlockEntity(tier: Tier, registry: MachineRegistry, pos: BlockPos, state: BlockState) :
MachineBlockEntity(tier, registry, pos, state) {
override val maxOutput: Long = 0
private var currentRecipe: T? = null
val usedRecipes = Object2IntOpenHashMap()
abstract val type: IRecipeGetter
var craftingComponents = Array(1) { CraftingComponent(0, this) }
var isSplitOn = false
override fun machineTick() {
ticks++
craftingComponents.forEach { it.tick() }
workingState = craftingComponents.any { it.isCrafting }
if (ticks % 20 == 0 && isSplitOn) { splitStacks() }
}
override fun getProcessingSpeed(): Double {
val isFullEfficiency = temperatureComponent?.isFullEfficiency() == true
val baseSpeed = if (isFullEfficiency)
((config as? HeatMachineConfig)?.processTemperatureBoost ?: 1.0) * config.processSpeed
else
config.processSpeed
return baseSpeed + (IRConfig.upgrades.speedUpgradeModifier * (enhancerComponent?.getCount(Enhancer.SPEED) ?: 0))
}
override fun getEnergyCost(): Long {
val speedEnhancers = (enhancerComponent!!.getCount(Enhancer.SPEED) * 2).coerceAtLeast(1)
return (if (temperatureComponent?.isFullEfficiency() == true) config.energyCost * 1.5
else config.energyCost).toLong() * speedEnhancers
}
open fun getMaxCount(enhancer: Enhancer): Int {
return when (enhancer) {
Enhancer.SPEED -> return 1
Enhancer.BUFFER -> 4
else -> 1
}
}
open fun splitStacks() {
if (craftingComponents.size <= 1) return
val inventory = inventoryComponent!!.inventory
splitStacks(inventory.inputSlots)
}
fun splitStacks(inputSlots: IntArray) {
if (craftingComponents.size <= 1) return
val inventory = inventoryComponent!!.inventory
val (item, sum) = inputSlots.associateStacks { inventory.getStack(it) }.maxByOrNull { it.value } ?: return
if (sum <= 0) return
val freeSlots = inputSlots.filter { inventory.fits(item, it) }
var remaining = sum
val slotsUsed = freeSlots.size.coerceAtMost(sum)
val rem = sum % slotsUsed
val isBelowLimit = slotsUsed > freeSlots.size
val baseAmount = Math.floorDiv(sum, slotsUsed)
freeSlots.forEachIndexed { index, slot ->
if (isBelowLimit && index + 1 > slotsUsed) {
inventory.setStack(slot, ItemStack.EMPTY)
return@forEachIndexed
}
var set = baseAmount
if (rem != 0 && rem > index && remaining > 0)
set++
if (index == slotsUsed - 1)
set += remaining
remaining -= set
if (remaining < 0) set += remaining
inventory.setStack(slot, ItemStack(item, set))
}
}
private inline fun IntArray.associateStacks(transform: (Int) -> ItemStack): Map
- {
return associateToStacks(Object2IntArrayMap(5), transform)
}
private inline fun > IntArray.associateToStacks(destination: M, transform: (Int) -> ItemStack): M {
for (element in this) {
val stack = transform(element)
if (!stack.isEmpty && stack.nbt?.isEmpty != false)
destination.mergeInt(stack.item, stack.count, IntBinaryOperator { old, new -> old + new })
}
return destination
}
override fun fromTag(tag: NbtCompound) {
val craftTags = tag.getList("craftingComponents", 10)
craftTags?.forEach { craftTag ->
val index = (craftTag as NbtCompound).getInt("index")
craftingComponents[index].readNbt(craftTag)
}
isSplitOn = tag.getBoolean("split")
super.fromTag(tag)
}
override fun toTag(tag: NbtCompound) {
val craftTags = NbtList()
craftingComponents.forEachIndexed { index, crafting ->
val craftTag = NbtCompound()
craftTags.add(crafting.writeNbt(craftTag))
craftTag.putInt("index", index)
}
tag.put("craftingComponents", craftTags)
tag.putBoolean("split", isSplitOn)
return super.toTag(tag)
}
@Suppress("UNCHECKED_CAST")
fun dropExperience(player: PlayerEntity) {
val list = mutableListOf()
usedRecipes.forEach { (id, amount) ->
for (recipes in world!!.recipeManager.recipes.values) {
val recipe = recipes[id] ?: continue
list.add(recipe as? T ?: continue)
if (recipe is SmeltingRecipe)
spawnOrbs(world!!, player.pos, amount, recipe.experience)
break
}
}
player.unlockRecipes(list.toList())
usedRecipes.clear()
}
private fun spawnOrbs(world: World, pos: Vec3d, amount: Int, experience: Float) {
val xp = amount.toFloat() * experience
var n = floor(xp).toInt()
val decimal = xp % 1
if (decimal != 0.0f && Math.random() < decimal.toDouble()) {
++n
}
ExperienceOrbEntity.spawn(world as ServerWorld, pos, n)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/ElectricFurnaceBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.mixin.common.MixinAbstractCookingRecipe
import me.steven.indrev.recipes.IRecipeGetter
import me.steven.indrev.recipes.machines.VanillaCookingRecipeCachedGetter
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
class ElectricFurnaceBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.ELECTRIC_FURNACE_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.1, 1300..1700, 2000)
this.enhancerComponent = EnhancerComponent(intArrayOf(4, 5, 6, 7), Enhancer.FURNACE, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slot = 2 }
output { slot = 3 }
}
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
}
@Suppress("UNCHECKED_CAST")
override val type: IRecipeGetter
get() {
val upgrades = enhancerComponent!!.enhancers
return when (upgrades.keys.firstOrNull { it == Enhancer.BLAST_FURNACE || it == Enhancer.SMOKER }) {
Enhancer.BLAST_FURNACE -> VanillaCookingRecipeCachedGetter.BLASTING
Enhancer.SMOKER -> VanillaCookingRecipeCachedGetter.SMOKING
else -> VanillaCookingRecipeCachedGetter.SMELTING
} as IRecipeGetter
}
companion object {
const val CRAFTING_COMPONENT_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/ElectricFurnaceFactoryBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.CraftingComponent
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.multiblock.MultiBlockComponent
import me.steven.indrev.components.multiblock.definitions.FactoryStructureDefinition
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.mixin.common.MixinAbstractCookingRecipe
import me.steven.indrev.recipes.IRecipeGetter
import me.steven.indrev.recipes.machines.VanillaCookingRecipeCachedGetter
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
class ElectricFurnaceFactoryBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.ELECTRIC_FURNACE_FACTORY_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.1, 1300..1700, 2000)
this.enhancerComponent = EnhancerComponent(intArrayOf(2, 3, 4, 5), Enhancer.FURNACE, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slots = intArrayOf(6, 8, 10, 12, 14) }
output { slots = intArrayOf(7, 9, 11, 13, 15) }
}
this.craftingComponents = Array(5) { index ->
val component = CraftingComponent(index, this).apply {
inputSlots = intArrayOf(6 + (index * 2))
outputSlots = intArrayOf(6 + (index * 2) + 1)
}
trackObject(CRAFTING_COMPONENT_START_ID + index, component)
component
}
this.multiblockComponent = MultiBlockComponent(FactoryStructureDefinition.SELECTOR)
}
override val syncToWorld: Boolean = true
@Suppress("UNCHECKED_CAST")
override val type: IRecipeGetter
get() {
val upgrades = enhancerComponent!!.enhancers
return when (upgrades.keys.firstOrNull { it == Enhancer.BLAST_FURNACE || it == Enhancer.SMOKER }) {
Enhancer.BLAST_FURNACE -> VanillaCookingRecipeCachedGetter.BLASTING
Enhancer.SMOKER -> VanillaCookingRecipeCachedGetter.SMOKING
else -> VanillaCookingRecipeCachedGetter.SMELTING
} as IRecipeGetter
}
override fun fromClientTag(tag: NbtCompound) {
multiblockComponent?.readNbt(tag)
}
override fun toClientTag(tag: NbtCompound) {
multiblockComponent?.writeNbt(tag)
}
companion object {
const val CRAFTING_COMPONENT_START_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/ElectrolyticSeparatorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.ElectrolysisRecipe
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
class ElectrolyticSeparatorBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: CraftingMachineBlockEntity(tier, MachineRegistry.ELECTROLYTIC_SEPARATOR_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 500..700, 900)
this.enhancerComponent = EnhancerComponent(intArrayOf(1, 2, 3, 4), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
coolerSlot = 0
}
this.fluidComponent = ElectrolyticSeparatorFluidComponent()
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
trackObject(INPUT_TANK_ID, fluidComponent!![0])
trackObject(FIRST_OUTPUT_TANK_ID, fluidComponent!![1])
trackObject(SECOND_OUTPUT_TANK_ID, fluidComponent!![2])
}
override val type: IRRecipeType = ElectrolysisRecipe.TYPE
override fun applyDefault(
state: BlockState,
type: ConfigurationType,
configuration: MutableMap
) {
if (type != ConfigurationType.ITEM)
super.applyDefault(state, type, configuration)
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.FLUID -> TransferMode.ELECTROLYTIC_SEPARATOR
else -> return super.getValidConfigurations(type)
}
}
inner class ElectrolyticSeparatorFluidComponent : FluidComponent({ this }, bucket * 4, 3) {
init {
this.inputTanks = intArrayOf(0)
this.outputTanks = intArrayOf(1, 2)
}
override fun getValidTanks(dir: Direction): IntArray {
return when (transferConfig[dir]!!) {
TransferMode.OUTPUT_FIRST -> intArrayOf(1)
TransferMode.OUTPUT_SECOND -> intArrayOf(2)
else -> super.getValidTanks(dir)
}
}
}
companion object {
const val CRAFTING_COMPONENT_ID = 4
const val INPUT_TANK_ID = 5
const val FIRST_OUTPUT_TANK_ID = 6
const val SECOND_OUTPUT_TANK_ID = 7
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/FluidInfuserBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.FluidInfuserRecipe
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
class FluidInfuserBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: CraftingMachineBlockEntity(tier, MachineRegistry.FLUID_INFUSER_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 700..1100, 1400)
this.enhancerComponent = EnhancerComponent(intArrayOf(4, 5, 6, 7), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slot = 2 }
output { slot = 3 }
}
this.fluidComponent = FluidInfuserFluidComponent()
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
trackObject(INPUT_TANK_ID, fluidComponent!![0])
trackObject(OUTPUT_TANK_ID, fluidComponent!![1])
}
override val syncToWorld: Boolean = true
override val type: IRRecipeType = FluidInfuserRecipe.TYPE
override fun fromClientTag(tag: NbtCompound) {
fluidComponent!!.fromTag(tag)
}
override fun toClientTag(tag: NbtCompound) {
fluidComponent!!.toTag(tag)
}
inner class FluidInfuserFluidComponent : FluidComponent({ this }, bucket * 8 , 2) {
init {
this.inputTanks = intArrayOf(0)
this.outputTanks = intArrayOf(1)
}
}
companion object {
const val CRAFTING_COMPONENT_ID = 4
const val INPUT_TANK_ID = 5
const val OUTPUT_TANK_ID = 6
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/FluidInfuserBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.crafters
import alexiil.mc.lib.attributes.fluid.render.FluidRenderFace
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Direction
class FluidInfuserBlockEntityRenderer : BlockEntityRenderer{
override fun render(
entity: FluidInfuserBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
val fluidComponent = entity?.fluidComponent ?: return
val inputFace = when (entity.cachedState[HorizontalFacingMachineBlock.HORIZONTAL_FACING]) {
Direction.NORTH -> INPUT_NORTH_FACE
Direction.SOUTH -> INPUT_SOUTH_FACE
Direction.WEST -> INPUT_WEST_FACE
Direction.EAST -> INPUT_EAST_FACE
else -> return
}
val inputVolume = fluidComponent[0]
if (!inputVolume.isEmpty) {
inputVolume.render(inputFace, vertexConsumers, matrices)
}
val outputFace = when (entity.cachedState[HorizontalFacingMachineBlock.HORIZONTAL_FACING]) {
Direction.NORTH -> OUTPUT_NORTH_FACE
Direction.SOUTH -> OUTPUT_SOUTH_FACE
Direction.WEST -> OUTPUT_WEST_FACE
Direction.EAST -> OUTPUT_EAST_FACE
else -> return
}
val outputVolume = fluidComponent[1]
if (!outputVolume.isEmpty) {
outputVolume.render(outputFace, vertexConsumers, matrices)
}
}
companion object {
private val INPUT_NORTH_FACE =
listOf(FluidRenderFace.createFlatFaceZ(0.815, 0.690, -0.005, 0.19, 0.815, -0.005, 1.0, true, false))
private val INPUT_SOUTH_FACE =
listOf(FluidRenderFace.createFlatFaceZ(0.185, 0.690, 1.005, 0.81, 0.815, 1.005, 1.0, true, false))
private val INPUT_WEST_FACE =
listOf(FluidRenderFace.createFlatFaceX(-0.005, 0.690, 0.185, -0.005, 0.815, 0.81, 1.0, false, false))
private val INPUT_EAST_FACE =
listOf(FluidRenderFace.createFlatFaceX(1.005, 0.690, 0.815, 1.005, 0.815, 0.19, 1.0, false, false))
private val OUTPUT_NORTH_FACE =
listOf(FluidRenderFace.createFlatFaceZ(0.815, 0.190, -0.005, 0.19, 0.32, -0.005, 1.0, true, false))
private val OUTPUT_SOUTH_FACE =
listOf(FluidRenderFace.createFlatFaceZ(0.185, 0.190, 1.005, 0.81, 0.32, 1.005, 1.0, true, false))
private val OUTPUT_WEST_FACE =
listOf(FluidRenderFace.createFlatFaceX(-0.005, 0.190, 0.185, -0.005, 0.32, 0.81, 1.0, false, false))
private val OUTPUT_EAST_FACE =
listOf(FluidRenderFace.createFlatFaceX(1.005, 0.190, 0.815, 1.005, 0.32, 0.19, 1.0, false, false))
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/PulverizerBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.recipes.machines.PulverizerRecipe
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
class PulverizerBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.PULVERIZER_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 700..1100, 1400)
this.enhancerComponent = EnhancerComponent(intArrayOf(5, 6, 7, 8), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slot = 2 }
output { slots = intArrayOf(3, 4) }
}
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
}
override val type: IRRecipeType = PulverizerRecipe.TYPE
companion object {
const val CRAFTING_COMPONENT_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/PulverizerFactoryBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.CraftingComponent
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.multiblock.MultiBlockComponent
import me.steven.indrev.components.multiblock.definitions.FactoryStructureDefinition
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.recipes.machines.PulverizerRecipe
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
class PulverizerFactoryBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.PULVERIZER_FACTORY_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 700..1100, 1400)
this.enhancerComponent = EnhancerComponent(intArrayOf(2, 3, 4, 5), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slots = intArrayOf(6, 8, 10, 12, 14) }
output { slots = intArrayOf(7, 9, 11, 13, 15) }
}
this.craftingComponents = Array(5) { index ->
val component = CraftingComponent(index, this).apply {
inputSlots = intArrayOf(6 + (index * 2))
outputSlots = intArrayOf(6 + (index * 2) + 1)
}
trackObject(CRAFTING_COMPONENT_START_ID + index, component)
component
}
this.multiblockComponent = MultiBlockComponent(FactoryStructureDefinition.SELECTOR)
}
override val syncToWorld: Boolean = true
override val type: IRRecipeType = PulverizerRecipe.TYPE
override fun fromClientTag(tag: NbtCompound) {
multiblockComponent?.readNbt(tag)
}
override fun toClientTag(tag: NbtCompound) {
multiblockComponent?.writeNbt(tag)
}
companion object {
const val CRAFTING_COMPONENT_START_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/RecyclerBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.recipes.machines.RecyclerRecipe
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
class RecyclerBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: CraftingMachineBlockEntity(tier, MachineRegistry.RECYCLER_REGISTRY, pos, state) {
init {
this.enhancerComponent = object : EnhancerComponent(intArrayOf(4, 5, 6, 7), Enhancer.DEFAULT, this::getMaxCount) {
override fun isLocked(slot: Int, tier: Tier): Boolean = false
}
this.inventoryComponent = inventory(this) {
input { slot = 2 }
output { slot = 3 }
coolerSlot = 1
}
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
}
override val type: IRRecipeType = RecyclerRecipe.TYPE
companion object {
const val CRAFTING_COMPONENT_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/SawmillBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.recipes.machines.SawmillRecipe
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
class SawmillBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: CraftingMachineBlockEntity(tier, MachineRegistry.SAWMILL_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 700..1100, 1400)
this.enhancerComponent = EnhancerComponent(intArrayOf(7, 8, 9, 10), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slot = 2 }
output { slots = intArrayOf(3, 4, 5, 6) }
}
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
}
override val type: IRRecipeType = SawmillRecipe.TYPE
companion object {
const val CRAFTING_COMPONENT_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/SmelterBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.blocks.machine.MachineBlock
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.recipes.machines.SmelterRecipe
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
class SmelterBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.SMELTER_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.2, 1700..2500, 2700)
this.enhancerComponent = EnhancerComponent(intArrayOf(3, 4, 5, 6), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slot = 2 }
}
this.fluidComponent = object : FluidComponent({ this }, bucket * 8) {
init {
this.outputTanks = intArrayOf(0)
}
}
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
trackObject(TANK_ID, fluidComponent!![0])
}
override val type: IRRecipeType = SmelterRecipe.TYPE
override fun getMaxCount(enhancer: Enhancer): Int {
return if (enhancer == Enhancer.SPEED) 4 else super.getMaxCount(enhancer)
}
override fun applyDefault(
state: BlockState,
type: ConfigurationType,
configuration: MutableMap
) {
val direction = (state.block as MachineBlock).getFacing(state)
when (type) {
ConfigurationType.ITEM -> {
configuration[direction.rotateYClockwise()] = TransferMode.INPUT
}
else -> super.applyDefault(state, type, configuration)
}
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.ITEM -> arrayOf(TransferMode.INPUT, TransferMode.NONE)
else -> return super.getValidConfigurations(type)
}
}
companion object {
const val CRAFTING_COMPONENT_ID = 4
const val TANK_ID = 5
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/SolidInfuserBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.recipes.machines.InfuserRecipe
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
class SolidInfuserBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.SOLID_INFUSER_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 700..1100, 1400)
this.enhancerComponent = EnhancerComponent(intArrayOf(5, 6, 7, 8), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input {
slots = intArrayOf(2, 3)
filter { _, dir, slot -> canInput(dir, slot) }
}
output { slot = 4 }
}
trackObject(CRAFTING_COMPONENT_ID, craftingComponents[0])
}
private fun canInput(side: Direction?, slot: Int): Boolean {
if (side == null) return true
return when (inventoryComponent!!.itemConfig[side]) {
TransferMode.INPUT_FIRST -> slot == 2
TransferMode.INPUT_SECOND -> slot == 3
else -> true
}
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.ITEM -> TransferMode.SOLID_INFUSER
else -> super.getValidConfigurations(type)
}
}
override val type: IRRecipeType = InfuserRecipe.TYPE
companion object {
const val CRAFTING_COMPONENT_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/crafters/SolidInfuserFactoryBlockEntity.kt
================================================
package me.steven.indrev.blockentities.crafters
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.components.CraftingComponent
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.multiblock.MultiBlockComponent
import me.steven.indrev.components.multiblock.definitions.FactoryStructureDefinition
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.recipes.machines.IRRecipeType
import me.steven.indrev.recipes.machines.InfuserRecipe
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
class SolidInfuserFactoryBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
CraftingMachineBlockEntity(tier, MachineRegistry.SOLID_INFUSER_FACTORY_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.06, 700..1100, 1400)
this.enhancerComponent = EnhancerComponent(intArrayOf(2, 3, 4, 5), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input {
slots = intArrayOf(6, 7, 9, 10, 12, 13, 15, 16, 18, 19)
filter { _, dir, slot -> canInput(dir, slot) }
}
output { slots = intArrayOf(8, 11, 14, 17, 20) }
}
this.craftingComponents = Array(5) { index ->
val component = CraftingComponent(index, this).apply {
inputSlots = intArrayOf(6 + (index * 3), 6 + (index * 3) + 1)
outputSlots = intArrayOf(6 + (index * 3) + 2)
}
trackObject(CRAFTING_COMPONENT_START_ID + index, component)
component
}
this.multiblockComponent = MultiBlockComponent(FactoryStructureDefinition.SELECTOR)
}
override val syncToWorld: Boolean = true
override fun splitStacks() {
splitStacks(TOP_SLOTS)
splitStacks(BOTTOM_SLOTS)
}
private fun canInput(side: Direction?, slot: Int): Boolean {
if (side == null) return true
return when (inventoryComponent!!.itemConfig[side]) {
TransferMode.INPUT_FIRST -> TOP_SLOTS.contains(slot)
TransferMode.INPUT_SECOND -> BOTTOM_SLOTS.contains(slot)
else -> true
}
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.ITEM -> TransferMode.SOLID_INFUSER
else -> super.getValidConfigurations(type)
}
}
override val type: IRRecipeType = InfuserRecipe.TYPE
override fun fromClientTag(tag: NbtCompound) {
multiblockComponent?.readNbt(tag)
}
override fun toClientTag(tag: NbtCompound) {
multiblockComponent?.writeNbt(tag)
}
companion object {
val TOP_SLOTS = intArrayOf(6, 9, 12, 15, 18)
val BOTTOM_SLOTS = intArrayOf(7, 10, 13, 16, 19)
const val CRAFTING_COMPONENT_START_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/AOEMachineBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import io.netty.buffer.Unpooled
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.config.IConfig
import me.steven.indrev.packets.common.UpdateAOEMachineRangePacket
import me.steven.indrev.registry.MachineRegistry
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.network.PacketByteBuf
import net.minecraft.screen.ScreenHandlerContext
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Box
abstract class AOEMachineBlockEntity(tier: Tier, registry: MachineRegistry, pos: BlockPos, state: BlockState) : MachineBlockEntity(tier, registry, pos, state) {
override val syncToWorld: Boolean = true
var renderWorkingArea = false
abstract var range: Int
open fun getWorkingArea(): Box {
val box = Box(pos)
return box.expand(range.toDouble(), 0.0, range.toDouble()).stretch(0.0, range.toDouble() * 2, 0.0)
}
override fun toTag(tag: NbtCompound) {
tag.putInt("range", range)
super.toTag(tag)
}
override fun toClientTag(tag: NbtCompound) {
tag.putInt("range", range)
}
override fun fromTag(tag: NbtCompound) {
super.fromTag(tag)
range = tag.getInt("range")
}
override fun fromClientTag(tag: NbtCompound) {
range = tag.getInt("range")
}
companion object {
fun sendValueUpdatePacket(value: Int, ctx: ScreenHandlerContext) {
if (value > 0) {
val packet = PacketByteBuf(Unpooled.buffer())
packet.writeInt(value)
ctx.run { _, pos -> packet.writeBlockPos(pos) }
ClientPlayNetworking.send(UpdateAOEMachineRangePacket.UPDATE_VALUE_PACKET_ID, packet)
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/AOEMachineBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.farms
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.WorldRenderer
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.math.MatrixStack
open class AOEMachineBlockEntityRenderer : BlockEntityRenderer> {
override fun render(
blockEntity: AOEMachineBlockEntity<*>,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider,
light: Int,
overlay: Int
) {
if (blockEntity.renderWorkingArea) {
val pos = blockEntity.pos
val area = blockEntity.getWorkingArea().offset(-pos.x.toDouble(), -pos.y.toDouble(), -pos.z.toDouble())
val vc = vertexConsumers.getBuffer(RenderLayer.getLines())
WorldRenderer.drawBox(matrices, vc, area, 1f, 0f, 1f, 1f)
}
}
override fun rendersOutsideBoundingBox(blockEntity: AOEMachineBlockEntity<*>?): Boolean = true
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/BiomassComposterBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import alexiil.mc.lib.attributes.fluid.amount.FluidAmount
import alexiil.mc.lib.attributes.fluid.render.FluidRenderFace
import alexiil.mc.lib.attributes.fluid.volume.FluidKeys
import me.steven.indrev.blockentities.BaseBlockEntity
import me.steven.indrev.blocks.misc.BiomassComposterBlock
import me.steven.indrev.registry.IRBlockRegistry
import me.steven.indrev.registry.IRFluidRegistry
import me.steven.indrev.registry.IRItemRegistry
import me.steven.indrev.utils.bucket
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant
import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext
import net.minecraft.block.BlockState
import net.minecraft.block.ComposterBlock
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.fluid.Fluids
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
class BiomassComposterBlockEntity(pos: BlockPos, state: BlockState) : BaseBlockEntity(IRBlockRegistry.BIOMASS_COMPOSTER_BLOCK_ENTITY, pos, state) {
var ticks = 0
var level = 0
val fluidInv = BiomassComposterFluidInv()
val itemInv = BiomassComposterItemInv()
companion object {
fun tick(state: BlockState, blockEntity: BiomassComposterBlockEntity) {
val vol = blockEntity.fluidInv
if (blockEntity.isInProgress()) {
blockEntity.ticks++
}
if (blockEntity.isReady() && state[BiomassComposterBlock.CLOSED] && vol.amount > 0 && vol.resource.isOf(Fluids.WATER)) {
blockEntity.fluidInv.variant = FluidVariant.of(IRFluidRegistry.METHANE_STILL)
blockEntity.reset()
} else if (blockEntity.isReady() && !blockEntity.hasFluids()) {
blockEntity.itemInv.amount = 1
blockEntity.itemInv.variant = ItemVariant.of(IRItemRegistry.BIOMASS)
blockEntity.reset()
}
blockEntity.doneInsertionThisTick = false
}
}
private var doneInsertionThisTick = false
private fun hasFluids() = !fluidInv.isResourceBlank && fluidInv.amount > 0
fun isReady() = level >= 7 && ticks >= getProgressTime()
fun reset() {
level = 0
ticks = 0
markDirty()
if (!world!!.isClient)
sync()
}
fun isInProgress(): Boolean {
return when {
level < 7 -> false
cachedState[BiomassComposterBlock.CLOSED] -> fluidInv.variant.isOf(Fluids.WATER)
else -> !hasFluids()
} && ticks < getProgressTime()
}
fun getProgressTime() = if (!cachedState[BiomassComposterBlock.CLOSED]) 120 else 440
inner class BiomassComposterFluidInv : SingleVariantStorage() {
override fun canInsert(variant: FluidVariant): Boolean = variant.isOf(Fluids.WATER)
override fun canExtract(variant: FluidVariant): Boolean = variant.isOf(IRFluidRegistry.METHANE_STILL)
override fun getCapacity(variant: FluidVariant?): Long = bucket
override fun getBlankVariant(): FluidVariant = FluidVariant.blank()
fun render(faces: List?, vcp: VertexConsumerProvider?, matrices: MatrixStack?) {
if (!variant.isBlank)
FluidKeys.get(variant.fluid).withAmount(FluidAmount.BUCKET).render(faces, vcp, matrices)
}
}
inner class BiomassComposterItemInv : SingleVariantStorage() {
override fun canInsert(variant: ItemVariant): Boolean = ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.contains(variant.item) && level < 7 && !doneInsertionThisTick
override fun insert(insertedVariant: ItemVariant, maxAmount: Long, transaction: TransactionContext?): Long {
StoragePreconditions.notBlankNotNegative(insertedVariant, maxAmount)
if ((insertedVariant == variant || variant.isBlank) && canInsert(insertedVariant)) {
val chance = ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.getValue(variant.item)
val insertedAmount = maxAmount.coerceAtMost(getCapacity(insertedVariant) - amount)
var actuallyInserted = 0L
for (x in 0 until insertedAmount) {
if (world!!.random.nextDouble() < chance) {
actuallyInserted++
}
}
if (insertedAmount > 0) {
updateSnapshots(transaction)
if (variant.isBlank) {
variant = insertedVariant
amount = actuallyInserted
} else {
amount += actuallyInserted
}
doneInsertionThisTick = true
}
return insertedAmount
}
return 0
}
override fun getCapacity(variant: ItemVariant): Long = 7 - level.toLong()
override fun canExtract(variant: ItemVariant): Boolean = variant.isOf(IRItemRegistry.BIOMASS)
override fun getBlankVariant(): ItemVariant = ItemVariant.blank()
}
override fun toTag(tag: NbtCompound) {
tag.putInt("ticks", ticks)
tag.putInt("level", level)
tag.put("fluidVariant", fluidInv.variant.toNbt())
tag.putLong("fluidAmt", fluidInv.amount)
tag.put("itemVariant", itemInv.variant.toNbt())
tag.putLong("itemAmt", itemInv.amount)
}
override fun fromTag(tag: NbtCompound) {
ticks = tag.getInt("ticks")
level = tag.getInt("level")
fluidInv.variant = FluidVariant.fromNbt(tag.getCompound("fluidVariant"))
fluidInv.amount = tag.getLong("fluidAmt")
itemInv.variant = ItemVariant.fromNbt(tag.getCompound("itemVariant"))
itemInv.amount = tag.getLong("itemAmt")
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/BiomassComposterBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.farms
import alexiil.mc.lib.attributes.fluid.render.FluidRenderFace
import me.steven.indrev.blocks.misc.BiomassComposterBlock
import me.steven.indrev.utils.bucket
import me.steven.indrev.utils.identifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.render.OverlayTexture
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.WorldRenderer
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.ModelIdentifier
import net.minecraft.client.util.math.MatrixStack
class BiomassComposterBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: BiomassComposterBlockEntity,
tickDelta: Float,
matrices: MatrixStack,
vertexConsumers: VertexConsumerProvider,
light: Int,
overlay: Int
) {
if (entity.cachedState[BiomassComposterBlock.CLOSED]) return
matrices.run {
if (entity.level > 0) {
push()
translate(0.0, ((((entity.level - 1) * 2)) / 16.0), 0.0)
val model = MinecraftClient.getInstance().bakedModelManager.getModel(ModelIdentifier(identifier("composting"), ""))
MinecraftClient.getInstance().blockRenderManager.modelRenderer.render(
matrices.peek(),
vertexConsumers.getBuffer(RenderLayer.getTranslucent()),
null,
model,
-1f,
-1f,
-1f,
WorldRenderer.getLightmapCoordinates(entity.world, entity.pos.up()),
OverlayTexture.DEFAULT_UV
)
pop()
}
push()
val vol = entity.fluidInv.amount / bucket.toDouble()
translate(0.0, vol, 0.0)
entity.fluidInv.render(FACE, vertexConsumers, matrices)
pop()
}
}
companion object {
private val FACE = listOf(FluidRenderFace.createFlatFaceY(0.125, 0.0, 0.125, 0.875, 0.0, 0.875, 1.0, true, false))
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/ChopperBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.*
import net.minecraft.block.*
import net.minecraft.item.AxeItem
import net.minecraft.item.BlockItem
import net.minecraft.item.BoneMealItem
import net.minecraft.item.ItemStack
import net.minecraft.item.SwordItem
import net.minecraft.loot.context.LootContext
import net.minecraft.loot.context.LootContextParameters
import net.minecraft.server.world.ServerWorld
import net.minecraft.tag.BlockTags
import net.minecraft.tag.ItemTags
import net.minecraft.util.ItemScatterer
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Box
import net.minecraft.world.chunk.Chunk
class ChopperBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) : AOEMachineBlockEntity(tier, MachineRegistry.CHOPPER_REGISTRY, pos, state) {
init {
this.enhancerComponent = EnhancerComponent(intArrayOf(15, 16, 17, 18), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input {
slots = intArrayOf(2, 3, 4, 5)
//todo tool tags?
2 filter { stack -> stack.item is AxeItem || stack.item is SwordItem }
3 filter { (_, item) -> item is BoneMealItem }
4..5 filter { (stack, item), _ -> stack.isIn(ItemTags.SAPLINGS)
|| (item is BlockItem && (item.block is MushroomPlantBlock || item.block is BambooBlock)) }
}
output { slots = intArrayOf(6, 7, 8, 9, 10, 11, 12, 13, 14) }
coolerSlot = 1
}
}
override val maxInput: Long = config.maxInput
override val maxOutput: Long = 0
private var scheduledBlocks = mutableListOf().iterator()
private val scannedBlocks = mutableSetOf()
override var range = 5
var cooldown = 0.0
override fun machineTick() {
if (world?.isClient == true) return
val inventory = inventoryComponent?.inventory ?: return
cooldown += getProcessingSpeed()
if (cooldown < config.processSpeed || ticks % 15 != 0 || !canUse(getEnergyCost()))
return
val area = getWorkingArea()
if (!scheduledBlocks.hasNext()) {
// includes tree branches that goes outside the actual area
val fullArea = area.expand(4.0).shrink(0.0, -4.0, 0.0)
scheduledBlocks = fullArea.map(::BlockPos).iterator()
scannedBlocks.clear()
} else {
var currentChunk: Chunk? = null
var performedActions = 0
val axeStack = inventory.getStack(2)
val brokenBlocks = hashMapOf()
while (scheduledBlocks.hasNext() && cooldown >= config.processSpeed) {
val pos = scheduledBlocks.next()
if (!scannedBlocks.add(pos)) continue
if (pos.x shr 4 != currentChunk?.pos?.x || pos.z shr 4 != currentChunk.pos.z) {
currentChunk = world?.getChunk(pos)
}
val blockState = currentChunk?.getBlockState(pos) ?: continue
if (axeStack != null
&& !axeStack.isEmpty
&& tryChop(axeStack, pos, blockState, currentChunk)
) {
cooldown -= config.processSpeed
if (!use(getEnergyCost())) break
brokenBlocks[pos] = blockState
performedActions++
}
if (pos.y == this.pos.y && pos in area) {
for (slot in 3..5) {
val stack = inventory.getStack(slot)
if (stack.isEmpty || !tryUse(blockState, stack, pos)) continue
cooldown -= config.processSpeed
if (!use(getEnergyCost())) break
brokenBlocks[pos] = blockState
performedActions++
}
}
}
brokenBlocks.forEach { (blockPos, blockState) ->
val droppedStacks = blockState.getDroppedStacks(
LootContext.Builder(world as ServerWorld).random(world?.random)
.parameter(LootContextParameters.ORIGIN, blockPos.toVec3d())
.parameter(LootContextParameters.TOOL, axeStack)
)
droppedStacks.forEach {
if (!inventory.output(it))
ItemScatterer.spawn(world, blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble(), it)
}
}
temperatureComponent?.tick(performedActions > 0)
workingState = performedActions > 0
}
cooldown = 0.0
}
private fun tryChop(
toolStack: ItemStack,
blockPos: BlockPos,
blockState: BlockState,
chunk: Chunk
): Boolean {
fun damageTool(amount: Int): Boolean {
return when {
energyOf(toolStack) != null -> energyOf(toolStack)!!.use(amount.toLong())
toolStack.isEmpty -> false
toolStack.isDamageable -> {
toolStack.damage(amount, world?.random, null)
if (toolStack.damage >= toolStack.maxDamage)
toolStack.decrement(1)
true
}
else -> true
}
}
val block = blockState.block
when {
toolStack.item is AxeItem
&& (blockState.isIn(BlockTags.LOGS) || block is MushroomBlock || block == Blocks.MUSHROOM_STEM) -> {
if (!damageTool(1)) return false
world?.setBlockState(blockPos, Blocks.AIR.defaultState, 3)
}
block is LeavesBlock -> {
world?.setBlockState(blockPos, Blocks.AIR.defaultState, 3)
}
toolStack.item is SwordItem && block is BambooBlock && blockPos.y > pos.y -> {
val upPos = blockPos.up()
val up = chunk.getBlockState(upPos)
scannedBlocks.add(upPos)
if (up.isOf(block))
tryChop(toolStack, upPos, blockState, chunk)
if (!damageTool(2)) return false
world?.setBlockState(blockPos, Blocks.AIR.defaultState, 3)
}
else -> return false
}
return true
}
private fun tryUse(blockState: BlockState, itemStack: ItemStack, pos: BlockPos): Boolean {
val item = itemStack.item
val block = blockState.block
when {
item is BoneMealItem && itemStack.count > 1
&& (blockState.isIn(BlockTags.SAPLINGS) || block is MushroomPlantBlock || block is BambooBlock || block is BambooSaplingBlock)
&& block is Fertilizable
&& block.isFertilizable(world, pos, blockState, false)
&& block.canGrow(world, world?.random, pos, blockState) -> {
block.grow(world as ServerWorld, world?.random, pos, blockState)
world?.syncWorldEvent(2005, pos, 0)
itemStack.decrement(1)
}
block is AirBlock
&& item is BlockItem
&& (itemStack.isIn(ItemTags.SAPLINGS) || item.block is MushroomPlantBlock || item.block is BambooBlock)
&& item.block.defaultState.canPlaceAt(world, pos)
&& itemStack.count > 1 -> {
if (item.block is BambooBlock)
world?.setBlockState(pos, Blocks.BAMBOO_SAPLING.defaultState, 3)
else
world?.setBlockState(pos, item.block.defaultState, 3)
itemStack.decrement(1)
}
else -> return false
}
return true
}
override fun getEnergyCost(): Long {
val speedEnhancers = (enhancerComponent!!.getCount(Enhancer.SPEED) * 2).coerceAtLeast(1)
return config.energyCost * speedEnhancers
}
override fun getWorkingArea(): Box {
val box = Box(pos)
return box.expand(range.toDouble(), 0.0, range.toDouble()).stretch(0.0, 40.0, 0.0)
}
fun getMaxCount(enhancer: Enhancer): Int {
return when (enhancer) {
Enhancer.SPEED -> return 12
Enhancer.BUFFER -> 4
else -> 1
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/ChopperBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.farms
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.WorldRenderer
import net.minecraft.client.util.math.MatrixStack
class ChopperBlockEntityRenderer : AOEMachineBlockEntityRenderer() {
override fun render(
blockEntity: AOEMachineBlockEntity<*>,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider,
light: Int,
overlay: Int
) {
super.render(blockEntity, tickDelta, matrices, vertexConsumers, light, overlay)
if (blockEntity.renderWorkingArea) {
val pos = blockEntity.pos
val area = blockEntity.getWorkingArea().offset(-pos.x.toDouble(), -pos.y.toDouble(), -pos.z.toDouble()).expand(4.0, 0.0, 4.0)
val vc = vertexConsumers.getBuffer(RenderLayer.getLines())
WorldRenderer.drawBox(matrices, vc, area, 1f, 0.2f, 0.2f, 1f)
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/DirtOxygenatorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.blocks.machine.FacingMachineBlock
import me.steven.indrev.config.MachineConfig
import me.steven.indrev.registry.IRFluidRegistry
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage
import net.minecraft.block.BlockState
import net.minecraft.block.Fertilizable
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.math.BlockPos
class DirtOxygenatorBlockEntity(pos: BlockPos, state: BlockState) : MachineBlockEntity(Tier.MK1, MachineRegistry.DIRT_OXYGENATOR_REGISTRY, pos, state) {
private var streak = 0
private var ticksUntilReset = 40
val fluidInv = FluidStorage()
override fun machineTick() {
val target = pos.offset(cachedState[FacingMachineBlock.FACING]).up()
val targetState = world!!.getBlockState(target)
val block = targetState.block
if (block !is Fertilizable || !targetState.canPlaceAt(world, target)) return
if (fluidInv.amount <= 0) {
ticksUntilReset--
if (ticksUntilReset <= 0)
streak = 0
return
} else {
streak++
ticksUntilReset = 40
}
val chance = (streak / 300.0).coerceIn(0.0, 1.0) * 0.6
if (world!!.random.nextDouble() < chance) {
if (
block.isFertilizable(world, pos, targetState, false)
&& block.canGrow(world, world!!.random, target, targetState)
) {
block.grow(world as ServerWorld, world!!.random, target, targetState)
}
}
fluidInv.variant = FluidVariant.blank()
fluidInv.amount = 0
}
inner class FluidStorage : SingleVariantStorage() {
override fun canExtract(variant: FluidVariant): Boolean = false
override fun canInsert(variant: FluidVariant): Boolean = variant.isOf(IRFluidRegistry.OXYGEN_STILL)
override fun getCapacity(variant: FluidVariant): Long = bucket
override fun getBlankVariant(): FluidVariant = FluidVariant.blank()
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/DrainBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import me.steven.indrev.utils.contains
import me.steven.indrev.utils.drainFluid
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.minecraft.block.BlockState
import net.minecraft.block.FluidBlock
import net.minecraft.block.FluidDrainable
import net.minecraft.fluid.FlowableFluid
import net.minecraft.fluid.Fluid
import net.minecraft.fluid.Fluids
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Box
import net.minecraft.util.math.Direction
class DrainBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) : MachineBlockEntity(tier, MachineRegistry.DRAIN_REGISTRY, pos, state) {
init {
this.fluidComponent = object : FluidComponent({ this }, bucket) {
init {
this.outputTanks = intArrayOf(0)
}
}
}
override val maxInput: Long = config.maxInput
override fun machineTick() {
val world = world ?: return
val fluidComponent = fluidComponent ?: return
if (ticks % 20 == 0 || !fluidComponent[0].isEmpty) return
val fluidState = world.getFluidState(pos.up())
if (fluidState?.isEmpty == false) {
val range = getWorkingArea()
// DOWN is intentionally excluded
val directions = arrayOf(Direction.UP, Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST)
val mutablePos = pos.mutableCopy()
val fluid = getStill(fluidState.fluid)
val bfs = mutableListOf(pos.up())
var i = 0
while (i < bfs.size) {
val current = bfs[i++]
for (dir in directions) {
mutablePos.set(current, dir)
if (mutablePos !in bfs && mutablePos in range && getStill(world.getFluidState(mutablePos).fluid) === fluid) {
bfs.add(mutablePos.toImmutable())
}
}
}
bfs.sortByDescending { it.y }
for (pos in bfs) {
val blockState = world.getBlockState(pos)
val block = blockState?.block
if (block is FluidDrainable && block is FluidBlock) {
val drained = block.drainFluid(world, pos, blockState)
if (drained != Fluids.EMPTY) {
fluidComponent[0].insert(FluidVariant.of(drained), bucket, true)
return
}
}
}
}
}
private fun getStill(fluid: Fluid): Fluid = if (fluid is FlowableFluid) fluid.still else fluid
fun getWorkingArea(): Box = Box(pos.up()).expand(8.0, 0.0, 8.0).stretch(0.0, 4.0, 0.0)
override fun applyDefault(
state: BlockState,
type: ConfigurationType,
configuration: MutableMap
) {
Direction.values().forEach { dir -> configuration[dir] = TransferMode.OUTPUT }
}
override fun isFixed(type: ConfigurationType): Boolean = true
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/FarmerBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.map
import me.steven.indrev.utils.toVec3d
import net.minecraft.block.*
import net.minecraft.item.BlockItem
import net.minecraft.item.BoneMealItem
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.loot.context.LootContext
import net.minecraft.loot.context.LootContextParameters
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Box
import net.minecraft.util.math.Direction
class FarmerBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: AOEMachineBlockEntity(tier, MachineRegistry.FARMER_REGISTRY, pos, state) {
init {
this.enhancerComponent = EnhancerComponent(intArrayOf(14, 15, 16, 17), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slots = intArrayOf(1, 2, 3, 4) }
output { slots = intArrayOf(5, 6, 7, 8, 9, 10, 11, 12, 13) }
}
}
override val maxInput: Long = config.maxInput
override val maxOutput: Long = 0
override var range: Int = 5
var cooldown = 0.0
private var nextBlocks = emptyList().iterator()
override fun machineTick() {
cooldown += getProcessingSpeed()
if (cooldown < config.processSpeed) return
val world = world as ServerWorld
val energyCost = config.energyCost
if (!canUse(energyCost)) return
if (nextBlocks.hasNext()) {
while (nextBlocks.hasNext()) {
val pos = nextBlocks.next()
val state = world.getBlockState(pos)
if (state.block != Blocks.SUGAR_CANE)
tryHarvest(state, pos, world)
else {
for (i in 5 downTo 1) {
val posToHarvest = pos.up(i)
val toHarvest = world.getBlockState(posToHarvest)
if (toHarvest.block == Blocks.SUGAR_CANE) {
tryHarvest(state, posToHarvest, world)
}
}
}
}
} else {
nextBlocks = getWorkingArea().map(::BlockPos).iterator()
}
cooldown = 0.0
}
private fun tryHarvest(state: BlockState, pos: BlockPos, world: ServerWorld): Boolean {
val block = state.block
val inventory = inventoryComponent?.inventory
val performedAction = inventory?.inputSlots?.any { slot ->
val stack = inventory.getStack(slot)
val item = stack.item
val isCropBlock = block is CropBlock || block is StemBlock || block is SweetBerryBushBlock || block is CocoaBlock || block is NetherWartBlock
when {
item is BoneMealItem && isCropBlock && (block as? Fertilizable)?.isFertilizable(world, pos, state, false) == true && block.canGrow(world, world.random, pos, state) -> {
stack.decrement(1)
block.grow(world, world.random, pos, state)
world.syncWorldEvent(2005, pos, 0)
true
}
canHarvest(slot, state, block, item) -> {
if ((block is CropBlock || block is SweetBerryBushBlock) && stack.count > 1) {
world.setBlockState(pos, block.defaultState)
stack.decrement(1)
} else {
world.setBlockState(pos, Blocks.AIR.defaultState)
}
val droppedStacks = state.getDroppedStacks(LootContext.Builder(world)
.random(world.random)
.parameter(LootContextParameters.ORIGIN, pos.toVec3d())
.parameter(LootContextParameters.BLOCK_STATE, state)
.parameter(LootContextParameters.TOOL, ItemStack.EMPTY))
droppedStacks.forEach { inventory.output(it) }
true
}
block is AirBlock && canPlant(item) && stack.count > 1 -> {
var cropState = (item as BlockItem).block.defaultState
if (item.block is CocoaBlock) {
arrayOf(Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST).firstOrNull {
cropState = cropState.with(CocoaBlock.FACING, it)
cropState.canPlaceAt(world, pos)
} ?: return@any false
}
if (cropState.canPlaceAt(world, pos) && world.isAir(pos)) {
world.setBlockState(pos, cropState)
stack.count--
true
} else false
}
else -> false
}
} ?: false
if (performedAction)
use(getEnergyCost())
return performedAction
}
override fun getEnergyCost(): Long {
val speedEnhancers = (enhancerComponent!!.getCount(Enhancer.SPEED) * 2).coerceAtLeast(1)
return config.energyCost * speedEnhancers
}
private fun canPlant(item: Item) =
item is BlockItem && (
item.block is CropBlock
|| item.block is StemBlock
|| item.block == Blocks.SUGAR_CANE
|| item.block is SweetBerryBushBlock
|| item.block is CocoaBlock
|| item.block is NetherWartBlock
)
private fun canHarvest(slot: Int, state: BlockState, block: Block, item: Item): Boolean =
(((block is CropBlock && block.isMature(state))
|| (block is SweetBerryBushBlock && state[SweetBerryBushBlock.AGE] == 2))
&& (item is BlockItem && item.block == block || slot == 4))
|| block is GourdBlock
|| block == Blocks.SUGAR_CANE
|| (block is CocoaBlock && state[CocoaBlock.AGE] == 2)
|| (block is NetherWartBlock && state[NetherWartBlock.AGE] == 3)
override fun getWorkingArea(): Box = Box(pos).expand(range.toDouble(), 0.0, range.toDouble())
fun getMaxCount(enhancer: Enhancer): Int {
return when (enhancer) {
Enhancer.SPEED -> return 1
Enhancer.BUFFER -> 4
else -> 1
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/FisherBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.component1
import me.steven.indrev.utils.component2
import me.steven.indrev.utils.toVec3d
import net.minecraft.block.BlockState
import net.minecraft.item.FishingRodItem
import net.minecraft.loot.context.LootContext
import net.minecraft.loot.context.LootContextParameters
import net.minecraft.loot.context.LootContextTypes
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.Identifier
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
class FisherBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: MachineBlockEntity(tier, MachineRegistry.FISHER_REGISTRY, pos, state) {
init {
this.enhancerComponent = EnhancerComponent(intArrayOf(6, 7, 8, 9), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input {
slot = 1
filter { (_, item), _ -> item is FishingRodItem }
}
output { slots = intArrayOf(2, 3, 4, 5) }
}
}
private var cooldown = config.processSpeed
override val maxInput: Long = config.maxInput
override val maxOutput: Long = 0
override fun machineTick() {
if (!canUse(getEnergyCost())) return
val rodStack = inventoryComponent!!.inventory.getStack(1)
if (rodStack.isEmpty || rodStack.item !is FishingRodItem || !use(getEnergyCost())) return
cooldown += getProcessingSpeed()
if (cooldown < config.processSpeed) return
cooldown = 0.0
Direction.values().forEach { direction ->
val pos = pos.offset(direction)
if (world?.isWater(pos) == true) {
val identifiers = getIdentifiers(tier)
val id = identifiers[world!!.random!!.nextInt(identifiers.size)]
val lootTable = (world as ServerWorld).server.lootManager.getTable(id)
val ctx = LootContext.Builder(world as ServerWorld).random(world!!.random)
.parameter(LootContextParameters.ORIGIN, pos.toVec3d())
.parameter(LootContextParameters.TOOL, rodStack)
.build(LootContextTypes.FISHING)
val loot = lootTable.generateLoot(ctx)
loot.forEach { stack -> inventoryComponent?.inventory?.output(stack) }
rodStack?.apply {
damage++
if (damage >= maxDamage) decrement(1)
}
}
}
}
override fun getEnergyCost(): Long {
val speedEnhancers = (enhancerComponent!!.getCount(Enhancer.SPEED) * 2).coerceAtLeast(1)
return config.energyCost * speedEnhancers
}
private fun getIdentifiers(tier: Tier) = when (tier) {
Tier.MK2 -> arrayOf(FISH_IDENTIFIER)
Tier.MK3 -> arrayOf(FISH_IDENTIFIER, FISH_IDENTIFIER, JUNK_IDENTIFIER, JUNK_IDENTIFIER, TREASURE_IDENTIFIER)
else -> arrayOf(FISH_IDENTIFIER, FISH_IDENTIFIER, FISH_IDENTIFIER, TREASURE_IDENTIFIER)
}
fun getMaxCount(enhancer: Enhancer): Int {
return when (enhancer) {
Enhancer.SPEED, Enhancer.BUFFER -> 4
else -> 1
}
}
companion object {
private val FISH_IDENTIFIER = Identifier("gameplay/fishing/fish")
private val JUNK_IDENTIFIER = Identifier("gameplay/fishing/junk")
private val TREASURE_IDENTIFIER = Identifier("gameplay/fishing/treasure")
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/PumpBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue
import it.unimi.dsi.fastutil.longs.LongOpenHashSet
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import me.steven.indrev.components.*
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.config.IRConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import me.steven.indrev.utils.drainFluid
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.minecraft.block.BlockState
import net.minecraft.block.FluidBlock
import net.minecraft.block.FluidDrainable
import net.minecraft.fluid.FlowableFluid
import net.minecraft.fluid.Fluid
import net.minecraft.fluid.FluidState
import net.minecraft.fluid.Fluids
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import kotlin.math.floor
import kotlin.math.roundToInt
class PumpBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: MachineBlockEntity(tier, MachineRegistry.PUMP_REGISTRY, pos, state) {
init {
this.fluidComponent = FluidComponent({ this }, bucket)
this.enhancerComponent = object : EnhancerComponent(intArrayOf(0, 1, 2, 3), Enhancer.DEFAULT, this::getMaxCount) {
override fun isLocked(slot: Int, tier: Tier): Boolean = false
}
this.inventoryComponent = inventory(this) {
}
trackObject(TANK_ID, fluidComponent!![0])
trackDouble(SPEED_ID) { config.processSpeed - enhancerComponent!!.getCount(Enhancer.SPEED) * 10 }
}
override val syncToWorld: Boolean = true
override val maxInput: Long = config.maxInput
override val maxOutput: Long = 0
var pipePosition = 0.0
private var isSearchingDown = false
private var currentTarget: BlockPos = pos
private val scanned = LongOpenHashSet()
private var queue = LongArrayFIFOQueue()
private var cooldown = 20.0
override fun machineTick() {
if (pipePosition == 0.0) {
isSearchingDown = true
}
if (!isSearchingDown && currentTarget == pos) {
searchFluid()
}
if (queue.isEmpty) {
isSearchingDown = true
}
if (currentTarget != pos) {
cooldown--
if (cooldown <= 0) {
drainTargetFluid()
}
}
if (isSearchingDown) {
searchDown()
}
}
private fun searchFluid() {
val currentLevel = floor(pipePosition).toInt()
val lookLevel = pos.offset(Direction.DOWN, currentLevel)
val currentFluid = world!!.getFluidState(lookLevel)
val targetFluid = world!!.getFluidState(currentTarget)
if (currentFluid.isEmpty) {
isSearchingDown = true
return
}
if ((targetFluid.isEmpty || !targetFluid.isStill) && !currentFluid.isEmpty) {
scanned.clear()
val searching = BlockPos.Mutable()
val neighbor = BlockPos.Mutable()
while (!queue.isEmpty) {
val packedPos = queue.dequeue()
searching.set(BlockPos.unpackLongX(packedPos), BlockPos.unpackLongY(packedPos), BlockPos.unpackLongZ(packedPos))
SEARCH_DIRECTIONS.forEach { dir ->
neighbor.set(searching.x + dir.offsetX, searching.y + dir.offsetY, searching.z + dir.offsetZ)
if (neighbor.getSquaredDistance(lookLevel) < IRConfig.machines.pumpMaxRange * IRConfig.machines.pumpMaxRange
&& scanned.add(neighbor.asLong())
&& getStill(world!!.getFluidState(neighbor).fluid) == getStill(currentFluid.fluid)) {
queue.enqueue(neighbor.asLong())
}
}
val fluidState = world!!.getFluidState(searching)
if (fluidState.isStill && !fluidState.isEmpty && fluidState.fluid == getStill(currentFluid.fluid)) {
currentTarget = searching
break
}
}
}
}
private fun getFluidTouchingPipe(): FluidState {
val currentLevel = floor(pipePosition).toInt()
val lookLevel = pos.offset(Direction.DOWN, currentLevel)
return world!!.getFluidState(lookLevel)
}
private fun drainTargetFluid() {
val fluidToPump = world!!.getFluidState(currentTarget)
if (!fluidToPump.isEmpty && canUse(config.energyCost) && fluidComponent!![0].isEmpty) {
val blockState = world!!.getBlockState(currentTarget)
val block = blockState?.block
if (block is FluidDrainable && block is FluidBlock) {
val drained = block.drainFluid(world!!, currentTarget, blockState)
if (drained != Fluids.EMPTY) {
fluidComponent!![0].insert(FluidVariant.of(drained), bucket, true)
use(getEnergyCost())
cooldown = config.processSpeed - enhancerComponent!!.getCount(Enhancer.SPEED) * 10
}
currentTarget = pos
}
}
}
override fun getEnergyCost(): Long {
return config.energyCost * (enhancerComponent!!.getCount(Enhancer.SPEED) + 1)
}
private fun searchDown() {
if (use(2)) {
pipePosition += 0.01
sync()
val fluid = getFluidTouchingPipe()
if (!fluid.isEmpty) {
isSearchingDown = false
pipePosition = pipePosition.roundToInt().toDouble()
queue = LongArrayFIFOQueue()
val currentLevel = floor(pipePosition).toInt()
queue.enqueue(pos.offset(Direction.DOWN, currentLevel).asLong())
}
}
}
private fun getStill(fluid: Fluid): Fluid = if (fluid is FlowableFluid) fluid.still else fluid
override fun applyDefault(
state: BlockState,
type: ConfigurationType,
configuration: MutableMap
) {
assert(type == ConfigurationType.FLUID)
val facing = state[HorizontalFacingMachineBlock.HORIZONTAL_FACING]
configuration[facing] = TransferMode.OUTPUT
}
override fun isFixed(type: ConfigurationType): Boolean = true
fun getMaxCount(enhancer: Enhancer): Int {
return when (enhancer) {
Enhancer.SPEED -> return 1
Enhancer.BUFFER -> 4
else -> 1
}
}
override fun toTag(tag: NbtCompound) {
tag.putDouble("MovingTicks", pipePosition)
super.toTag(tag)
}
override fun fromTag(tag: NbtCompound) {
pipePosition = tag.getDouble("MovingTicks")
super.fromTag(tag)
}
override fun fromClientTag(tag: NbtCompound) {
pipePosition = tag.getDouble("MovingTicks")
}
override fun toClientTag(tag: NbtCompound) {
tag.putDouble("MovingTicks", pipePosition)
}
companion object {
const val TANK_ID = 2
const val SPEED_ID = 3
val SEARCH_DIRECTIONS = mutableListOf(Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/PumpBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.farms
import alexiil.mc.lib.attributes.fluid.render.FluidRenderFace
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import me.steven.indrev.utils.IRFluidTank
import me.steven.indrev.utils.identifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.render.OverlayTexture
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.WorldRenderer
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.ModelIdentifier
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3f
import kotlin.math.floor
class PumpBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: PumpBlockEntity,
tickDelta: Float,
matrices: MatrixStack,
vertexConsumers: VertexConsumerProvider,
light: Int,
overlay: Int
) {
matrices.run {
push()
val inputVolume = entity.fluidComponent!![0]
if (!inputVolume.isEmpty) {
translate(0.5, 0.5, 0.5)
var direction = entity.cachedState[HorizontalFacingMachineBlock.HORIZONTAL_FACING]
if (direction.axis == Direction.Axis.X) direction = direction.opposite
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(direction.asRotation()))
translate(-0.5, -0.5, -0.5)
push()
multiply(Vec3f.NEGATIVE_X.getDegreesQuaternion(22.5f))
renderFluid(inputVolume, vertexConsumers)
pop()
push()
multiply(Vec3f.NEGATIVE_Z.getDegreesQuaternion(22.5f))
translate(0.5, 0.5, 0.5)
multiply(Vec3f.NEGATIVE_Y.getDegreesQuaternion(90f))
translate(-0.5, -0.5, -0.5)
matrices.translate(0.0, 0.38, 0.0765)
renderFluid(inputVolume, vertexConsumers)
pop()
push()
multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(22.5f))
translate(0.5, 0.5, 0.5)
multiply(Vec3f.NEGATIVE_Y.getDegreesQuaternion(180f))
translate(-0.5, -0.5, -0.5)
matrices.translate(0.1284, 0.0, 0.1285)
renderFluid(inputVolume, vertexConsumers)
pop()
}
pop()
val currentY = floor(entity.pipePosition).toInt()
for (y in 1..currentY) {
push()
translate(0.0, -y.toDouble(), 0.0)
renderModel(vertexConsumers, entity)
pop()
}
if (currentY.toDouble() != entity.pipePosition) {
push()
scale(1.01f, 1f, 1.01f)
translate(-0.005, -entity.pipePosition, -0.005)
renderModel(vertexConsumers, entity)
pop()
}
}
}
private fun MatrixStack.renderModel(vertexConsumers: VertexConsumerProvider, entity: PumpBlockEntity) {
val model = MinecraftClient.getInstance().bakedModelManager.getModel(ModelIdentifier(identifier("pump_pipe"), ""))
val buffer = vertexConsumers.getBuffer(RenderLayer.getSolid())
val light = WorldRenderer.getLightmapCoordinates(entity.world, entity.pos)
MinecraftClient.getInstance().blockRenderManager.modelRenderer.render(
peek(), buffer, null, model, -1f, -1f, -1f, light, OverlayTexture.DEFAULT_UV
)
}
private fun MatrixStack.renderFluid(inputVolume: IRFluidTank, vcp: VertexConsumerProvider) {
inputVolume.render(FACES, vcp, this)
}
override fun rendersOutsideBoundingBox(blockEntity: PumpBlockEntity?): Boolean = true
companion object {
val FACES = listOf(
FluidRenderFace.createFlatFaceZ(0.443, 0.15, 0.32, 0.556, 0.31, 0.32, 2.0, false, false),
FluidRenderFace.createFlatFaceZ(0.443, 0.15, 0.32+ (0.55-0.443), 0.556, 0.31, 0.32+ (0.55-0.443), 2.0, true, false),
FluidRenderFace.createFlatFaceX(0.443, 0.15, 0.323, 0.443, 0.31, 0.426, 2.0, false, false),
FluidRenderFace.createFlatFaceX(0.443+ (0.55-0.443), 0.15, 0.323, 0.443+ (0.55-0.443), 0.31, 0.426, 2.0, true, false)
)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/RancherBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import me.steven.indrev.IndustrialRevolution
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.components.autosync
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.redirectDrops
import net.minecraft.block.BlockState
import net.minecraft.entity.damage.DamageSource
import net.minecraft.entity.passive.AnimalEntity
import net.minecraft.item.ItemStack
import net.minecraft.item.SwordItem
import net.minecraft.nbt.NbtCompound
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.math.BlockPos
class RancherBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: AOEMachineBlockEntity(tier, MachineRegistry.RANCHER_REGISTRY, pos, state) {
init {
this.enhancerComponent = EnhancerComponent(intArrayOf(15, 16, 17, 18), Enhancer.DEFAULT, this::getMaxCount)
this.inventoryComponent = inventory(this) {
input { slots = intArrayOf(2, 3, 4, 5) }
output { slots = intArrayOf(6, 7, 8, 9, 10, 11, 12, 13, 14) }
coolerSlot = 1
}
}
override val maxInput: Long = config.maxInput
override val maxOutput: Long = 0
var cooldown = 0.0
override var range = 5
private val fakePlayer by lazy { IndustrialRevolution.FAKE_PLAYER_BUILDER.create(world!!.server, world as ServerWorld, "rancher") }
var feedBabies: Boolean by autosync(FEED_BABIES_ID, true)
var mateAdults: Boolean by autosync(MATE_ADULTS, true)
var matingLimit: Int by autosync(MATING_LIMIT, 16)
var killAfter: Int by autosync(KILL_AFTER, 8)
override fun machineTick() {
if (world?.isClient == true) return
val inventory = inventoryComponent?.inventory ?: return
cooldown += getProcessingSpeed()
if (cooldown < config.processSpeed) return
val animals = world?.getEntitiesByClass(AnimalEntity::class.java, getWorkingArea()) { true } ?: emptyList()
if (animals.isEmpty() || !canUse(getEnergyCost())) {
workingState = false
return
} else workingState = true
val swordStack = inventory.inputSlots.map { inventory.getStack(it) }.firstOrNull { it.item is SwordItem }
fakePlayer.inventory.selectedSlot = 0
if (swordStack != null && !swordStack.isEmpty && swordStack.damage < swordStack.maxDamage) {
val swordItem = swordStack.item as SwordItem
val kill = filterAnimalsToKill(animals)
if (kill.isNotEmpty()) use(getEnergyCost())
kill.forEach { animal ->
animal.redirectDrops(inventory) {
if (!animal.isAlive || !animal.damage(DamageSource.player(fakePlayer), swordItem.attackDamage)) return@forEach
swordStack.damage(1, world?.random, null)
if (swordStack.damage >= swordStack.maxDamage) swordStack.decrement(1)
}
}
}
for (animal in animals) {
inventory.inputSlots.forEach { slot ->
val stack = inventory.getStack(slot).copy()
animal.redirectDrops(inventory) {
if (tryFeed(animals.size, animal, inventory.getStack(slot)).isAccepted) return@forEach
fakePlayer.inventory.selectedSlot = 8
fakePlayer.setStackInHand(Hand.MAIN_HAND, stack)
if (animal.interactMob(fakePlayer, Hand.MAIN_HAND).isAccepted)
use(getEnergyCost())
val inserted = inventory.output(fakePlayer.inventory.getStack(0))
val handStack = fakePlayer.getStackInHand(Hand.MAIN_HAND)
if (!handStack.isEmpty && handStack.item != stack.item) {
inventory.output(handStack)
fakePlayer.setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY)
}
if (inserted)
inventory.setStack(slot, stack)
fakePlayer.inventory.clear()
}
}
}
fakePlayer.inventory.clear()
cooldown = 0.0
}
private fun tryFeed(size: Int, animalEntity: AnimalEntity, stack: ItemStack): ActionResult {
if (animalEntity.isBreedingItem(stack)) {
val breedingAge: Int = animalEntity.breedingAge
if (!world!!.isClient && breedingAge == 0 && animalEntity.canEat() && size <= matingLimit && mateAdults) {
animalEntity.eat(fakePlayer, Hand.MAIN_HAND, stack)
animalEntity.lovePlayer(fakePlayer)
}
if (animalEntity.isBaby && feedBabies) {
animalEntity.eat(fakePlayer, Hand.MAIN_HAND, stack)
animalEntity.growUp(((-breedingAge / 20f) * 0.1f).toInt(), true)
}
return ActionResult.SUCCESS
}
return ActionResult.PASS
}
private fun filterAnimalsToKill(entities: List): List {
val adults = entities.filter { !it.isBaby }
val types = adults.map { it.type }.associateWith { mutableListOf() }
adults.forEach { types[it.type]?.add(it) }
return types.values.let { values ->
values.map { animals -> animals.dropLast((animals.size - killAfter).coerceAtLeast(killAfter)) }
}.flatten()
}
override fun getEnergyCost(): Long {
val speedEnhancers = (enhancerComponent!!.getCount(Enhancer.SPEED) * 2).coerceAtLeast(1)
return config.energyCost * speedEnhancers
}
fun getMaxCount(enhancer: Enhancer): Int {
return when (enhancer) {
Enhancer.SPEED -> return 1
Enhancer.BUFFER -> 4
else -> 1
}
}
override fun toTag(tag: NbtCompound) {
super.toTag(tag)
tag.putBoolean("feedBabies", feedBabies)
tag.putBoolean("mateAdults", mateAdults)
tag.putInt("matingLimit", matingLimit)
tag.putInt("killAfter", killAfter)
}
override fun fromTag(tag: NbtCompound) {
super.fromTag(tag)
feedBabies = tag.getBoolean("feedBabies")
mateAdults = tag.getBoolean("mateAdults")
matingLimit = tag.getInt("matingLimit")
killAfter = tag.getInt("killAfter")
}
companion object {
const val FEED_BABIES_ID = 2
const val MATE_ADULTS = 3
const val MATING_LIMIT = 4
const val KILL_AFTER = 5
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/farms/SlaughterBlockEntity.kt
================================================
package me.steven.indrev.blockentities.farms
import me.steven.indrev.IndustrialRevolution
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.EnhancerComponent
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.upgrade.Enhancer
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.redirectDrops
import net.minecraft.block.BlockState
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.boss.WitherEntity
import net.minecraft.entity.damage.DamageSource
import net.minecraft.entity.decoration.ArmorStandEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.SwordItem
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.math.BlockPos
class SlaughterBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) : AOEMachineBlockEntity(tier, MachineRegistry.SLAUGHTER_REGISTRY, pos, state) {
init {
this.enhancerComponent = EnhancerComponent(
intArrayOf(11, 12, 13, 14),
arrayOf(Enhancer.SPEED, Enhancer.BUFFER, Enhancer.DAMAGE),
this::getMaxCount
)
this.inventoryComponent = inventory(this) {
input { slot = 1 }
output { slots = intArrayOf(2, 3, 4, 5, 6, 7, 8, 9, 10) }
}
}
override val maxInput: Long = config.maxInput
override val maxOutput: Long = 0
var cooldown = 0.0
override var range = 5
private val fakePlayer by lazy { IndustrialRevolution.FAKE_PLAYER_BUILDER.create(world!!.server, world as ServerWorld, "slaughter") }
override fun machineTick() {
if (world?.isClient == true) return
val inventory = inventoryComponent?.inventory ?: return
val enhancers = enhancerComponent!!.enhancers
cooldown += getProcessingSpeed()
if (cooldown < config.processSpeed) return
val source = DamageSource.player(fakePlayer)
val mobs = world?.getEntitiesByClass(LivingEntity::class.java, getWorkingArea()) { e -> e !is PlayerEntity && e !is ArmorStandEntity && !e.isDead && !e.isInvulnerableTo(source) && (e !is WitherEntity || e.invulnerableTimer <= 0) } ?: emptyList()
if (mobs.isEmpty() || !canUse(getEnergyCost())) {
workingState = false
return
} else workingState = true
val swordStack = inventory.inputSlots.map { inventory.getStack(it) }.firstOrNull { it.item is SwordItem }
fakePlayer.inventory.selectedSlot = 0
if (swordStack != null && !swordStack.isEmpty && swordStack.damage < swordStack.maxDamage) {
val swordItem = swordStack.item as SwordItem
use(getEnergyCost())
mobs.forEach { mob ->
swordStack.damage(1, world?.random, null)
if (swordStack.damage >= swordStack.maxDamage) swordStack.decrement(1)
if (mob.isAlive) {
mob.redirectDrops(inventory) {
mob.damage(source, (swordItem.attackDamage * Enhancer.getDamageMultiplier(enhancers)).toFloat())
}
}
}
}
fakePlayer.inventory.clear()
cooldown = 0.0
}
override fun getEnergyCost(): Long {
val speedEnhancers = (enhancerComponent!!.getCount(Enhancer.SPEED) * 2).coerceAtLeast(1)
val dmgEnhancers = (enhancerComponent!!.getCount(Enhancer.DAMAGE) * 8).coerceAtLeast(1)
return config.energyCost * speedEnhancers * dmgEnhancers
}
fun getMaxCount(enhancer: Enhancer): Int {
return when (enhancer) {
Enhancer.SPEED, Enhancer.DAMAGE -> return 1
Enhancer.BUFFER -> 4
else -> 1
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/BiomassGeneratorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.inventories.inventory
import me.steven.indrev.registry.IRItemRegistry
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.item.Item
import net.minecraft.util.math.BlockPos
class BiomassGeneratorBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: SolidFuelGeneratorBlockEntity(tier, MachineRegistry.BIOMASS_GENERATOR_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.08, 900..2000, 2500)
this.inventoryComponent = inventory(this) {
input { slot = 2 }
}
}
override fun getFuelMap(): Map
- = BURN_TIME_MAP
companion object {
private val BURN_TIME_MAP = hashMapOf
- ()
init {
BURN_TIME_MAP[IRItemRegistry.BIOMASS] = 150
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/CoalGeneratorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.inventories.inventory
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.block.entity.AbstractFurnaceBlockEntity
import net.minecraft.item.Item
import net.minecraft.util.math.BlockPos
class CoalGeneratorBlockEntity(pos: BlockPos, state: BlockState) :
SolidFuelGeneratorBlockEntity(Tier.MK1, MachineRegistry.COAL_GENERATOR_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.08, 900..2000, 2500)
this.inventoryComponent = inventory(this) {
input {
slot = 2
2 filter { stack -> BURN_TIME_MAP.containsKey(stack.item) }
}
}
}
override fun getFuelMap(): Map
- = BURN_TIME_MAP
companion object {
private val BURN_TIME_MAP = AbstractFurnaceBlockEntity.createFuelTimeMap()
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/GasBurningGeneratorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.components.autosync
import me.steven.indrev.components.trackObject
import me.steven.indrev.inventories.inventory
import me.steven.indrev.registry.IRFluidFuelRegistry
import me.steven.indrev.registry.IRItemRegistry
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.minecraft.block.BlockState
import net.minecraft.item.ItemStack
import net.minecraft.util.math.BlockPos
class GasBurningGeneratorBlockEntity(pos: BlockPos, state: BlockState) : GeneratorBlockEntity(Tier.MK4, MachineRegistry.GAS_BURNING_GENERATOR_REGISTRY, pos, state) {
private var burnTime by autosync(BURN_TIME_ID, 0)
private var maxBurnTime by autosync(TOTAL_BURN_TIME_ID, 0)
init {
this.temperatureComponent = TemperatureComponent(this, 0.3, 2200..2400, 2500)
this.inventoryComponent = inventory(this) {
coolerSlot = 0
output {
slot = 1
}
}
this.fluidComponent = GasBurningGeneratorFluidComponent()
}
var generatingTicks = 0
override fun machineTick() {
super.machineTick()
if (workingState) {
generatingTicks++
if (generatingTicks % 100 == 0 && world!!.random.nextDouble() < 0.6) {
inventoryComponent!!.inventory.output(ItemStack(IRItemRegistry.SOOT))
}
}
}
override fun shouldGenerate(): Boolean {
if (burnTime > 0) burnTime--
else if (energyCapacity > energy) {
val invFluid = fluidComponent!![0]
val fluid = invFluid.resource.fluid
if (invFluid.isEmpty || !IRFluidFuelRegistry.isFuel(fluid)) return false
val fuel = IRFluidFuelRegistry.get(fluid)!!
if (fluidComponent!![0].extract(fuel.consumptionRatio) == fuel.consumptionRatio) {
burnTime = fuel.burnTime
maxBurnTime = burnTime
}
}
return burnTime > 0 && energy < energyCapacity
}
override fun getGenerationRatio(): Long {
val invFluid = fluidComponent!![0]
val fluid = invFluid.resource.fluid
val modifier = if (temperatureComponent!!.isFullEfficiency()) config.temperatureBoost else 1.0
return ((IRFluidFuelRegistry.get(fluid)?.generationRatio ?: 0) * modifier).toLong()
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.ITEM -> arrayOf(TransferMode.OUTPUT, TransferMode.NONE)
ConfigurationType.FLUID -> arrayOf(TransferMode.INPUT, TransferMode.NONE)
else -> super.getValidConfigurations(type)
}
}
inner class GasBurningGeneratorFluidComponent : FluidComponent({ this }, bucket * 2, 1) {
init {
trackObject(TANK_ID, this[0])
}
override fun isFluidValidForTank(index: Int, variant: FluidVariant): Boolean {
return IRFluidFuelRegistry.isFuel(variant.fluid)
}
}
companion object {
const val BURN_TIME_ID = 4
const val TOTAL_BURN_TIME_ID = 5
const val TANK_ID = 6
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/GeneratorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.config.GeneratorConfig
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
abstract class GeneratorBlockEntity(tier: Tier, registry: MachineRegistry, pos: BlockPos, state: BlockState) :
MachineBlockEntity(tier, registry, pos, state) {
override fun machineTick() {
if (world?.isClient == false) {
val ratio = getGenerationRatio()
if (shouldGenerate() && energyCapacity > energy + ratio) {
this.energy += ratio
this.temperatureComponent?.tick(true)
workingState = true
} else {
workingState = false
this.temperatureComponent?.tick(false)
}
}
}
override val maxInput: Long = 0
override val maxOutput: Long = config.maxOutput
abstract fun shouldGenerate(): Boolean
open fun getGenerationRatio(): Long = (config.ratio * if (this.temperatureComponent?.isFullEfficiency() == true) config.temperatureBoost else 1.0).toLong()
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/HeatGeneratorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.*
import me.steven.indrev.inventories.inventory
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import net.minecraft.block.BlockState
import net.minecraft.fluid.Fluids
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
class HeatGeneratorBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: GeneratorBlockEntity(tier, MachineRegistry.HEAT_GENERATOR_REGISTRY, pos, state) {
private var burnTime by autosync(GasBurningGeneratorBlockEntity.BURN_TIME_ID, 0)
private var maxBurnTime by autosync(GasBurningGeneratorBlockEntity.TOTAL_BURN_TIME_ID, 0)
init {
this.temperatureComponent = TemperatureComponent(this, 0.8, 7000..9000, 10000)
this.inventoryComponent = inventory(this) {
input { slot = 2 }
}
this.fluidComponent = FluidComponent({ this }, bucket * 4)
fluidComponent!!.inputTanks = intArrayOf(0)
trackObject(TANK_ID, fluidComponent!![0])
trackLong(GENERATION_RATIO_ID) { getGenerationRatio() }
trackLong(CONSUMPTION_RATIO_ID) { getConsumptionRate() }
}
override val syncToWorld: Boolean = true
override fun shouldGenerate(): Boolean {
if (burnTime > 0) burnTime--
else if (energyCapacity > energy) {
val tank = fluidComponent!![0]
val consume = getConsumptionRate()
if (tank.variant.isOf(Fluids.LAVA)
&& tank.tryExtract(consume)) {
burnTime = 10
maxBurnTime = burnTime
tank.extract(consume, true)
}
markDirty()
}
return burnTime > 0 && energy < energyCapacity
}
override fun getGenerationRatio(): Long {
return (config.ratio * (temperatureComponent!!.temperature / temperatureComponent!!.optimalRange.first).coerceAtMost(1.0)).toLong()
}
fun getConsumptionRate(temperature: Double = temperatureComponent!!.temperature): Long {
return ((temperature / temperatureComponent!!.optimalRange.first).coerceIn(0.001, 1.0) * 810).toLong()
}
override fun fromTag(tag: NbtCompound) {
super.fromTag(tag)
burnTime = tag.getInt("BurnTime")
maxBurnTime = tag.getInt("MaxBurnTime")
}
override fun toTag(tag: NbtCompound) {
tag.putInt("BurnTime", burnTime)
tag.putInt("MaxBurnTime", maxBurnTime)
super.toTag(tag)
}
override fun toClientTag(tag: NbtCompound) {
fluidComponent!!.toTag(tag)
}
override fun fromClientTag(tag: NbtCompound) {
fluidComponent!!.fromTag(tag)
}
companion object {
const val TANK_ID = 4
const val GENERATION_RATIO_ID = 5
const val CONSUMPTION_RATIO_ID = 6
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/HeatGeneratorBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.generators
import alexiil.mc.lib.attributes.fluid.render.FluidRenderFace
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import me.steven.indrev.utils.IRFluidTank
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3f
class HeatGeneratorBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: HeatGeneratorBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider,
light: Int,
overlay: Int
) {
val volume = entity?.fluidComponent?.get(0) ?: return
if (!volume.isEmpty) {
matrices?.run {
push()
val direction = entity.cachedState[HorizontalFacingMachineBlock.HORIZONTAL_FACING]
.let { if (it.axis == Direction.Axis.X) it.opposite else it }
translate(0.5, 0.5, 0.5)
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(direction.asRotation()))
translate(-0.5, -0.5, -0.5)
matrices.renderFluid(volume, vertexConsumers)
pop()
}
}
}
private fun MatrixStack.renderFluid(inputVolume: IRFluidTank, vcp: VertexConsumerProvider) {
val yMax = (((inputVolume.amount / (4f*81000)) * 10.0) / 16.0).coerceAtLeast(0.1)
val face =
listOf(
FluidRenderFace.createFlatFaceZ(0.01, 0.1, 0.99, 0.99, yMax, 0.99, 2.0, true, false),
FluidRenderFace.createFlatFaceY(0.01, yMax, 0.8, 0.99, yMax, 0.99, 2.0, true, false),
FluidRenderFace.createFlatFaceX(0.01, 0.1, 0.8, 0.01, yMax, 0.99, 2.0, false, false),
FluidRenderFace.createFlatFaceX(0.99, 0.1, 0.8, 0.99, yMax, 0.99, 2.0, true, false)
)
inputVolume.render(face, vcp, this)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/SolarGeneratorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.TemperatureComponent
import me.steven.indrev.inventories.inventory
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.util.math.BlockPos
class SolarGeneratorBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
GeneratorBlockEntity(tier, MachineRegistry.SOLAR_GENERATOR_REGISTRY, pos, state) {
init {
this.temperatureComponent = TemperatureComponent(this, 0.1, 500..700, 1000)
this.inventoryComponent = inventory(this) {}
}
override fun shouldGenerate(): Boolean = this.world?.isSkyVisible(pos.up()) == true && this.world?.isDay == true && energy < energyCapacity
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/SolidFuelGeneratorBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.blocks.machine.MachineBlock
import me.steven.indrev.components.autosync
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
abstract class SolidFuelGeneratorBlockEntity(tier: Tier, registry: MachineRegistry, pos: BlockPos, state: BlockState)
: GeneratorBlockEntity(tier, registry, pos, state) {
private var burnTime by autosync(BURN_TIME_ID, 0)
private var maxBurnTime by autosync(TOTAL_BURN_TIME_ID, 0)
override fun shouldGenerate(): Boolean {
if (burnTime > 0) burnTime--
else if (energyCapacity > energy) {
val inventory = inventoryComponent?.inventory ?: return false
val invStack = inventory.getStack(2)
val item = invStack.item
if (!invStack.isEmpty && getFuelMap().containsKey(invStack.item)) {
burnTime = getFuelMap()[invStack.item] ?: return false
maxBurnTime = burnTime
invStack.decrement(1)
if (item.hasRecipeRemainder())
inventory.setStack(2, ItemStack(item.recipeRemainder))
}
markDirty()
}
return burnTime > 0 && energy < energyCapacity
}
override fun applyDefault(
state: BlockState,
type: ConfigurationType,
configuration: MutableMap
) {
val direction = (state.block as MachineBlock).getFacing(state)
when (type) {
ConfigurationType.ITEM -> {
configuration[direction.rotateYClockwise()] = TransferMode.INPUT
}
else -> super.applyDefault(state, type, configuration)
}
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.ITEM -> arrayOf(TransferMode.INPUT, TransferMode.NONE)
else -> return super.getValidConfigurations(type)
}
}
override fun fromTag(tag: NbtCompound) {
super.fromTag(tag)
burnTime = tag?.getInt("BurnTime") ?: 0
maxBurnTime = tag?.getInt("MaxBurnTime") ?: 0
}
override fun toTag(tag: NbtCompound) {
tag?.putInt("BurnTime", burnTime)
tag?.putInt("MaxBurnTime", maxBurnTime)
super.toTag(tag)
}
abstract fun getFuelMap(): Map
-
companion object {
const val BURN_TIME_ID = 4
const val TOTAL_BURN_TIME_ID = 5
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/SteamTurbineBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import alexiil.mc.lib.attributes.fluid.amount.FluidAmount
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.components.autosync
import me.steven.indrev.components.multiblock.MultiBlockComponent
import me.steven.indrev.components.multiblock.definitions.SteamTurbineStructureDefinition
import me.steven.indrev.components.trackLong
import me.steven.indrev.registry.IRFluidRegistry
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.bucket
import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class SteamTurbineBlockEntity(pos: BlockPos, state: BlockState) : GeneratorBlockEntity(Tier.MK4, MachineRegistry.STEAM_TURBINE_REGISTRY, pos, state) {
init {
this.multiblockComponent = SteamTurbineMultiblockComponent()
this.fluidComponent = SteamTurbineFluidComponent()
}
override val maxInput: Long = 0
var efficiency by autosync(EFFICIENCY, 1.0)
var generatingTicks = 0
var totalInserted: FluidAmount = FluidAmount.ZERO
init {
trackLong(GENERATING) { getGenerationRatio() * 100 }
}
// used for the screen handler
@Environment(EnvType.CLIENT)
var consuming: FluidAmount = FluidAmount.ZERO
override fun getGenerationRatio(): Long {
val radius = getRadius()
val eff = totalInserted.div(20).asInexactDouble()
return (((eff * 2) / (radius.toDouble() / 7)) * 2048).toLong()
}
override fun shouldGenerate(): Boolean {
if (generatingTicks <= 0) {
if (!totalInserted.isZero) {
generatingTicks = 20
fluidComponent!![0].extract(Long.MAX_VALUE, true)
} else
return false
}
generatingTicks--
if (generatingTicks <= 0) totalInserted = FluidAmount.ZERO
return true
}
private fun getConsumptionRatio(): FluidAmount {
return totalInserted.div(20)
}
private fun getRadius(): Int {
//return 7
val matcher = multiblockComponent!!.getSelectedMatcher(world ?: return 0, pos, cachedState)
return SteamTurbineStructureDefinition.getRadius(matcher.builtId ?: return 0)
}
private inner class SteamTurbineFluidComponent : FluidComponent({ this }, bucket, 1) {
override fun getTankCapacity(index: Int): Long {
return (((getRadius() * getRadius().toLong()) * efficiency) * 81L).toLong()
}
override fun isFluidValidForTank(index: Int, variant: FluidVariant): Boolean {
return variant.isOf(IRFluidRegistry.STEAM_STILL)
}
}
private inner class SteamTurbineMultiblockComponent : MultiBlockComponent({ _, _, _ -> SteamTurbineStructureDefinition }) {
override fun tick(world: World, pos: BlockPos, blockState: BlockState) {
super.tick(world, pos, blockState)
SteamTurbineStructureDefinition
.getInputValvePositions(pos, blockState, getSelectedMatcher(world, pos, blockState))
.forEach { valvePos ->
val valveBlockEntity = world.getBlockEntity(valvePos)
if (valveBlockEntity is SteamTurbineSteamInputValveBlockEntity)
valveBlockEntity.steamTurbinePos = pos
}
if (!isBuilt(world, pos, blockState)) {
fluidComponent!![0].amount = 0
}
}
}
override fun toTag(tag: NbtCompound) {
tag.putDouble("Efficiency", efficiency)
super.toTag(tag)
}
override fun fromTag(tag: NbtCompound) {
efficiency = tag.getDouble("Efficiency")
super.fromTag(tag)
}
override fun toClientTag(tag: NbtCompound) {
tag.put("Consuming", getConsumptionRatio().toNbt())
multiblockComponent?.writeNbt(tag)
}
override fun fromClientTag(tag: NbtCompound) {
consuming = FluidAmount.fromNbt(tag.getCompound("Consuming")) ?: consuming
multiblockComponent?.readNbt(tag)
}
companion object {
const val EFFICIENCY = 2
const val GENERATING = 3
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/generators/SteamTurbineSteamInputValveBlockEntity.kt
================================================
package me.steven.indrev.blockentities.generators
import me.steven.indrev.registry.IRBlockRegistry
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.util.math.BlockPos
class SteamTurbineSteamInputValveBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(IRBlockRegistry.STEAM_TURBINE_STEAM_INPUT_VALVE_BLOCK_ENTITY, pos, state) {
var steamTurbinePos: BlockPos = BlockPos(-1, -1, -1)
var inserted = false
fun getSteamTurbine(): SteamTurbineBlockEntity? {
val blockEntity = world!!.getBlockEntity(steamTurbinePos) as? SteamTurbineBlockEntity ?: return null
return if (blockEntity.multiblockComponent?.isBuilt(world!!, pos, blockEntity.cachedState) == true)
blockEntity
else null
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/laser/CapsuleBlockEntity.kt
================================================
package me.steven.indrev.blockentities.laser
import com.google.common.base.Preconditions
import me.steven.indrev.blocks.machine.LaserBlock
import me.steven.indrev.registry.IRBlockRegistry
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.inventory.Inventories
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.collection.DefaultedList
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.World
class CapsuleBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(IRBlockRegistry.CAPSULE_BLOCK_ENTITY, pos, state) {
var inventory: DefaultedList = DefaultedList.ofSize(1, ItemStack.EMPTY)
var lastProgress = 0
fun getActiveLasersCount(): Int {
return Direction.values().count {
val laser = world?.getBlockEntity(pos.offset(it, 4)) as? LaserBlockEntity ?: return@count false
laser.cachedState[LaserBlock.POWERED]
}
}
override fun readNbt(tag: NbtCompound?) {
super.readNbt(tag)
inventory = DefaultedList.ofSize(1, ItemStack.EMPTY)
Inventories.readNbt(tag, inventory)
}
override fun writeNbt(tag: NbtCompound) {
super.writeNbt(tag)
Inventories.writeNbt(tag, inventory)
}
open fun sync() {
Preconditions.checkNotNull(world) // Maintain distinct failure case from below
check(world is ServerWorld) { "Cannot call sync() on the logical client! Did you check world.isClient first?" }
(world as ServerWorld).chunkManager.markForUpdate(getPos())
}
companion object {
fun tick(world: World, pos: BlockPos, state: BlockState, blockEntity: CapsuleBlockEntity) {
if (world.isClient) return
val tag = blockEntity.inventory[0].orCreateNbt
val progress = tag.getInt("Progress")
if (tag.contains("Progress") && progress == blockEntity.lastProgress) {
tag.remove("Progress")
}
blockEntity.lastProgress = progress
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/laser/CapsuleBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.laser
import net.minecraft.client.MinecraftClient
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.WorldRenderer
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.render.model.json.ModelTransformation
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Vec3f
class CapsuleBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: CapsuleBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
entity ?: return
val itemStack = entity.inventory[0]
if (itemStack.isEmpty) return
val lightCoord = WorldRenderer.getLightmapCoordinates(entity.world, entity.pos)
matrices?.run {
push()
val time = entity.world?.time ?: 1
translate(0.5, 0.35, 0.5)
scale(1.2f, 1.2f, 1.2f)
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((time + tickDelta) * 16 * entity.getActiveLasersCount()))
MinecraftClient.getInstance().itemRenderer.renderItem(itemStack, ModelTransformation.Mode.GROUND, lightCoord, overlay, matrices, vertexConsumers, 0)
pop()
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/laser/LaserBlockEntity.kt
================================================
package me.steven.indrev.blockentities.laser
import me.steven.indrev.IndustrialRevolution
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.blocks.machine.FacingMachineBlock
import me.steven.indrev.blocks.machine.LaserBlock
import me.steven.indrev.config.MachineConfig
import me.steven.indrev.recipes.machines.LaserRecipe
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.component1
import me.steven.indrev.utils.component2
import me.steven.indrev.utils.component3
import me.steven.indrev.utils.toVec3d
import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.minecraft.block.BlockState
import net.minecraft.entity.Entity
import net.minecraft.item.ItemStack
import net.minecraft.particle.ParticleTypes
import net.minecraft.server.world.ServerWorld
import net.minecraft.sound.SoundCategory
import net.minecraft.sound.SoundEvents
import net.minecraft.util.math.*
import net.minecraft.world.World
import net.minecraft.world.explosion.Explosion
import java.util.*
class LaserBlockEntity(pos: BlockPos, state: BlockState) : MachineBlockEntity(Tier.MK4, MachineRegistry.LASER_EMITTER_REGISTRY, pos, state) {
override val maxInput: Long = config.maxInput
override val maxOutput: Long = 0
private var ticksUntilExplode = 100
private var recipe: LaserRecipe? = null
override fun machineTick() {
if (!cachedState[LaserBlock.POWERED]) {
ticksUntilExplode = 100
return
}
val facing = cachedState[FacingMachineBlock.FACING]
val containerPos = pos.offset(facing, 4)
val container = world?.getBlockEntity(containerPos) as? CapsuleBlockEntity
if (container == null) {
ticksUntilExplode--
if (ticksUntilExplode < 0) explode()
return
} else {
ticksUntilExplode = 100
BlockPos.iterate(pos.offset(facing), pos.offset(facing, 3)).forEach {
world?.breakBlock(it, true)
}
}
val stack = container.inventory[0]
if (recipe == null) {
recipe = LaserRecipe.TYPE.getMatchingRecipe(world as ServerWorld, stack)
.firstOrNull { it.matches(stack, emptyList()) }
} else if (ItemStack.areItemsEqual(recipe!!.outputs.first().stack, stack)) {
return
}
if (recipe?.matches(stack, emptyList()) != true) {
world?.breakBlock(containerPos, false)
recipe = null
return
}
if (!use(config.energyCost)) {
world?.setBlockState(pos, cachedState.with(LaserBlock.POWERED, false))
return
}
val (x, y, z) = scale(facing.vec3f(), 3.0f)
val damageArea = Box(pos).stretch(x.toDouble(), y.toDouble(), z.toDouble()).let {
when {
facing.axis.isVertical ->
it.shrink(0.3, 0.0, 0.3)
facing.axis == Direction.Axis.X ->
it.shrink(0.0, 0.3, 0.3)
else ->
it.shrink(0.3, 0.3, 0.0)
}
}
world?.getEntitiesByClass(Entity::class.java, damageArea) { true }?.forEach {
it.setOnFireFor(1000)
it.damage(LaserBlock.LASER_DAMAGE_SOURCE, 2f)
}
val tag = stack.orCreateNbt
val progress = tag.getDouble("Progress")
if (progress >= recipe!!.ticks) {
container.inventory[0] = recipe!!.craft(null as Random?).first()
container.markDirty()
container.sync()
world?.updateNeighbors(containerPos, container.cachedState.block)
} else
tag.putDouble("Progress", progress + config.energyCost)
}
@Environment(EnvType.CLIENT)
override fun machineClientTick() {
if (cachedState[LaserBlock.POWERED]) {
if (!isEmittingLaser()) {
if (world!!.random.nextDouble() > 0.7) {
spawnParticles(world!!, pos, isFire = true)
world!!.playSound(
pos.x.toDouble() + 0.5,
pos.y.toDouble() + 0.5,
pos.z.toDouble() + 0.5,
SoundEvents.BLOCK_FIRE_EXTINGUISH,
SoundCategory.BLOCKS,
0.6f,
0.8f,
false
)
}
return
}
spawnParticles(world!!, pos, 0.4)
}
}
private fun spawnParticles(world: World, pos: BlockPos, width: Double = 0.5625, isFire: Boolean = false) {
val random = world.random
val facing = cachedState[FacingMachineBlock.FACING]
repeat(6) {
val axis = facing.axis
val x = if (axis != Direction.Axis.X) 0.7 - random.nextDouble() * width else 0.0
val y = if (axis != Direction.Axis.Y) 0.7 - random.nextDouble() * width else 0.0
val z = if (axis != Direction.Axis.Z) 0.7 - random.nextDouble() * width else 0.0
val source = Vec3d(pos.x + x, pos.y + y, pos.z + z).let {
val (x, y, z) = facing.unitVector
if (x > 0 || y > 0 || z > 0)
it.add(Vec3d(facing.unitVector))
else it
}
val velocity = pos.offset(facing, 4).toVec3d().add(x, y, z).subtract(source).normalize().multiply(0.18)
world.addParticle(
if (isFire) ParticleTypes.SMOKE else IndustrialRevolution.LASER_PARTICLE,
true,
source.x,
source.y,
source.z,
if (isFire) 0.0 else velocity.x,
if (isFire) 0.05 else velocity.y,
if (isFire) 0.0 else velocity.z
)
}
}
fun isEmittingLaser(): Boolean {
val facing = cachedState[FacingMachineBlock.FACING]
val containerPos = pos.offset(facing, 4)
return cachedState[LaserBlock.POWERED] && world?.getBlockEntity(containerPos) as? CapsuleBlockEntity != null
}
private fun explode() {
world?.createExplosion(
null,
pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble(),
3f,
true,
Explosion.DestructionType.DESTROY
)
}
companion object {
private fun Direction.vec3f() = Vec3f(offsetX.toFloat(), offsetY.toFloat(), offsetZ.toFloat())
private fun scale(v: Vec3f, scale: Float): Vec3f {
return Vec3f(v.x * scale, v.y * scale, v.z * scale)
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/laser/LaserBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.laser
import me.steven.indrev.blocks.machine.FacingMachineBlock
import me.steven.indrev.utils.identifier
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.Identifier
import net.minecraft.util.math.Direction
class LaserBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: LaserBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
entity ?: return
if (!entity.isEmittingLaser()) return
val direction = entity.cachedState[FacingMachineBlock.FACING]
matrices?.run {
push()
translate(direction.unitVector.x.toDouble(), direction.unitVector.y.toDouble(), direction.unitVector.z.toDouble())
translate(0.5, 0.5, 0.5)
val rotation = direction.let {
when {
it.axis.isHorizontal -> it.rotateYCounterclockwise().unitVector.getDegreesQuaternion(90f)
it == Direction.DOWN -> Direction.EAST.unitVector.getDegreesQuaternion(180f)
else -> it.unitVector.getDegreesQuaternion(90f)
}
}
multiply(rotation)
translate(-0.5, -0.5, -0.5)
BeaconBlockEntityRenderer.renderBeam(
matrices,
vertexConsumers,
TEXTURE,
tickDelta,
1.0f,
entity.world!!.time,
0,
3,
floatArrayOf(1f, 1f, 1f),
0.085f,
0.1f
)
pop()
}
}
override fun rendersOutsideBoundingBox(blockEntity: LaserBlockEntity?): Boolean = true
companion object {
val TEXTURE: Identifier = identifier("textures/entity/laser.png")
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/miningrig/DataCardWriterBlockEntity.kt
================================================
package me.steven.indrev.blockentities.miningrig
import me.steven.indrev.api.OreDataCards
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.components.autosync
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.config.IRConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.registry.IRItemRegistry
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.util.math.BlockPos
class DataCardWriterBlockEntity (tier: Tier, pos: BlockPos, state: BlockState)
: MachineBlockEntity(tier, MachineRegistry.DATA_CARD_WRITER_REGISTRY, pos, state) {
init {
this.inventoryComponent = inventory(this) {
input {
0 filter { itemStack, _ -> itemStack.item == IRItemRegistry.ORE_DATA_CARD }
1 until 13 filter { stack, _ -> OreDataCards.isAllowed(stack) }
13 until 16 filter { stack, _ -> OreDataCards.Modifier.isModifierItem(stack.item) }
}
}
}
var processTime by autosync(PROCESS_ID, 0)
var totalProcessTime by autosync(TOTAL_PROCESS_ID, 0)
private val modifiersToAdd = mutableMapOf()
private val toWrite = mutableListOf()
override fun machineTick() {
if (totalProcessTime > 0 && use(getEnergyCost())) {
if (processTime >= totalProcessTime)
finish()
else {
processTime++
workingState = true
}
} else {
workingState = false
}
}
fun start() {
val inventory = inventoryComponent!!.inventory
val cardStack = inventory.getStack(0)
val oldData = OreDataCards.readNbt(cardStack)
ORES_SLOTS.forEach { slot ->
val stack = inventory.getStack(slot)
if (!stack.isEmpty && stack.count == 64) {
toWrite.add(stack)
inventory.setStack(slot, ItemStack.EMPTY)
}
}
if (toWrite.isEmpty() && oldData == null) {
return
}
MODIFIERS_SLOTS.forEach { slot ->
val stack = inventory.getStack(slot)
val modifier = OreDataCards.Modifier.byItem(stack.item)
var level = (modifiersToAdd[modifier] ?: 0) + (oldData?.modifiersUsed?.get(modifier) ?: 0)
when (modifier) {
OreDataCards.Modifier.RICHNESS -> {
while (stack.count >= 16 && level < 40) {
stack.decrement(16)
level++
}
}
OreDataCards.Modifier.SPEED, OreDataCards.Modifier.SIZE -> {
while (stack.count >= 64) {
stack.decrement(64)
level++
}
}
OreDataCards.Modifier.RNG -> {
if (level == 0) {
stack.decrement(1)
val r = world!!.random.nextDouble()
if (r > 0.95 && r <= 0.98) {
level = -1
} else if (r > 0.98) {
level = 1
}
}
}
else -> return@forEach
}
modifiersToAdd[modifier] = level - (oldData?.modifiersUsed?.get(modifier) ?: 0)
}
processTime = 0
totalProcessTime = 20*10 + (toWrite.size * (5*modifiersToAdd.map { it.value }.sum()))
}
private fun finish() {
val inventory = inventoryComponent!!.inventory
val cardStack = inventory.getStack(0)
val oldData = OreDataCards.readNbt(cardStack)
val oreTypes = toWrite.map { it.item }.distinct().count()
val richnessDecrease = if (oreTypes == 1) 0.02 else 0.04
val richnessModifier = ((modifiersToAdd[OreDataCards.Modifier.RICHNESS] ?: 0) * 0.01).coerceAtMost(0.2)
val richness = ((oldData?.richness ?: 1.0) - (richnessDecrease * toWrite.size) + richnessModifier).coerceIn(richnessDecrease, 1.0)
val speedModifier = ((oldData?.modifiersUsed?.get(OreDataCards.Modifier.SPEED) ?: 0) + (modifiersToAdd[OreDataCards.Modifier.SPEED] ?: 0)) * 20
val speed = 100 + (richness * 1100) - speedModifier + (modifiersToAdd[OreDataCards.Modifier.SIZE] ?: 0) * 2
val rng = oldData?.rng ?: modifiersToAdd[OreDataCards.Modifier.RNG] ?: 0
val oreEnergyRequired = toWrite.sumOf { OreDataCards.getCost(it) * 16 }
val energyRequired = (oldData?.energyRequired ?: 32) + 8 * (modifiersToAdd[OreDataCards.Modifier.SPEED] ?: 0) + oreEnergyRequired
val cyclesModifiers = (modifiersToAdd[OreDataCards.Modifier.SIZE] ?: 0) * 128
val maxCycles = (oldData?.maxCycles ?: 0) + (toWrite.size * 64) + cyclesModifiers
val items = mutableMapOf
- ()
oldData?.entries?.forEach { entry ->
items[entry.item] = entry.count
}
toWrite.forEach { stack ->
items[stack.item] = items.getOrDefault(stack.item, 0) + stack.count
}
val entries = items.keys.map { OreDataCards.OreEntry(it, items[it]!!) }
val modifiersMap = mutableMapOf()
modifiersToAdd.forEach { (modifier, level) ->
modifiersMap[modifier] = (oldData?.modifiersUsed?.get(modifier)?: 0) + level
}
val data = OreDataCards.Data(entries, modifiersMap, richness, speed.toInt(), rng, energyRequired, maxCycles, oldData?.used ?: 0)
OreDataCards.writeNbt(cardStack, data)
modifiersToAdd.clear()
toWrite.clear()
processTime = 0
totalProcessTime = 0
}
override fun getEnergyCost(): Long {
return IRConfig.machines.dataCardWriter.energyCost
}
companion object {
const val PROCESS_ID = 2
const val TOTAL_PROCESS_ID = 3
val MODIFIERS_SLOTS = 13 until 16
val ORES_SLOTS = 1 until 13
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/miningrig/DrillBlockEntity.kt
================================================
package me.steven.indrev.blockentities.miningrig
import com.google.common.base.Preconditions
import io.netty.buffer.Unpooled
import me.steven.indrev.api.OreDataCards
import me.steven.indrev.blocks.machine.DrillBlock
import me.steven.indrev.gui.screenhandlers.machines.MiningRigDrillScreenHandler
import me.steven.indrev.packets.client.MiningRigSpawnBlockParticlesPacket
import me.steven.indrev.registry.IRBlockRegistry
import me.steven.indrev.registry.IRItemRegistry
import me.steven.indrev.utils.component1
import me.steven.indrev.utils.component2
import me.steven.indrev.utils.component3
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.block.entity.LootableContainerBlockEntity
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.inventory.Inventories
import net.minecraft.item.BlockItem
import net.minecraft.item.Item
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.network.PacketByteBuf
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket
import net.minecraft.screen.ScreenHandler
import net.minecraft.screen.ScreenHandlerContext
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.server.world.ServerWorld
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.util.collection.DefaultedList
import net.minecraft.util.math.BlockPos
import net.minecraft.util.registry.Registry
import net.minecraft.world.World
class DrillBlockEntity(pos: BlockPos, state: BlockState) : LootableContainerBlockEntity(IRBlockRegistry.DRILL_BLOCK_ENTITY_TYPE, pos, state), ExtendedScreenHandlerFactory {
var inventory: DefaultedList = DefaultedList.ofSize(1, ItemStack.EMPTY)
var position: Double = 1.0
var miningProgress: Double = 0.0
fun setWorkingState(working: Boolean) {
if (cachedState[DrillBlock.WORKING] != working)
world?.setBlockState(pos, cachedState.with(DrillBlock.WORKING, working))
}
fun tickMining(miningRig: MiningRigBlockEntity, data: OreDataCards.Data) {
setWorkingState(true)
miningProgress += getSpeedMultiplier()
if (miningProgress >= data.speed) {
miningProgress = 0.0
val item = data.pickRandom(world!!.random)
val rng = if (data.rng == 1 && world!!.random.nextDouble() < 0.1) 2 else 1
val count = ((5 * data.richness) + world!!.random.nextInt((OreDataCards.MAX_PER_CYCLE * data.richness).toInt().coerceAtLeast(1))).toInt() * rng
var stack = ItemStack(item, count)
if (data.rng == 1 && world!!.random.nextDouble() > 0.9) {
stack.count *= 2
} else if (data.rng == -1 && world!!.random.nextDouble() > 0.9) {
stack = ItemStack.EMPTY
}
miningRig.output(stack)
data.used++
miningRig.lastMinedItem = ItemStack(item)
miningRig.sync()
val drillStack = inventory[0]
drillStack.damage(1, world!!.random, null)
if (drillStack.damage >= drillStack.maxDamage) {
inventory[0] = ItemStack.EMPTY
}
if (item is BlockItem)
sendBlockBreakPacket(item.block)
}
}
private fun sendBlockBreakPacket(block: Block) {
val (x, y, z) = pos
val players = (world as ServerWorld).server.playerManager.playerList
for (i in players.indices) {
val serverPlayerEntity = players[i]
if (serverPlayerEntity.world.registryKey === world!!.registryKey) {
val xOffset = x - serverPlayerEntity.x
val yOffset = y - serverPlayerEntity.y
val zOffset = z - serverPlayerEntity.z
if (xOffset * xOffset + yOffset * yOffset + zOffset * zOffset < 64 * 64) {
val buf = PacketByteBuf(Unpooled.buffer())
buf.writeBlockPos(pos)
buf.writeInt(Registry.BLOCK.getRawId(block))
ServerPlayNetworking.send(serverPlayerEntity, MiningRigSpawnBlockParticlesPacket.BLOCK_BREAK_PACKET, buf)
}
}
}
}
override fun size(): Int = 1
override fun getContainerName(): Text = TranslatableText("block.indrev.drill")
override fun createScreenHandler(syncId: Int, playerInventory: PlayerInventory): ScreenHandler {
return MiningRigDrillScreenHandler(syncId, playerInventory, ScreenHandlerContext.create(world, pos))
}
override fun getInvStackList(): DefaultedList = inventory
override fun setInvStackList(list: DefaultedList) {
inventory = list
}
override fun readNbt(tag: NbtCompound) {
super.readNbt(tag)
inventory = DefaultedList.ofSize(size(), ItemStack.EMPTY)
if (!deserializeLootTable(tag)) {
Inventories.readNbt(tag, inventory)
}
position = tag.getDouble("Position")
miningProgress = tag.getDouble("Mining")
}
override fun writeNbt(tag: NbtCompound) {
super.writeNbt(tag)
if (!serializeLootTable(tag)) {
Inventories.writeNbt(tag, inventory)
}
tag.putDouble("Position", position)
tag.putDouble("Mining", miningProgress)
}
override fun toUpdatePacket(): BlockEntityUpdateS2CPacket {
return BlockEntityUpdateS2CPacket.create(this)
}
override fun toInitialChunkDataNbt(): NbtCompound {
val nbt = super.toInitialChunkDataNbt()
writeNbt(nbt)
return nbt
}
fun sync() {
Preconditions.checkNotNull(world) // Maintain distinct failure case from below
check(world is ServerWorld) { "Cannot call sync() on the logical client! Did you check world.isClient first?" }
(world as ServerWorld).chunkManager.markForUpdate(getPos())
}
override fun writeScreenOpeningData(player: ServerPlayerEntity, buf: PacketByteBuf) {
buf.writeBlockPos(pos)
}
fun getSpeedMultiplier(): Double {
val item = inventory[0].item
return if (position > 0) 0.0 else when (item) {
IRItemRegistry.STONE_DRILL_HEAD -> 1.0
IRItemRegistry.IRON_DRILL_HEAD -> 2.0
IRItemRegistry.DIAMOND_DRILL_HEAD -> 4.0
IRItemRegistry.NETHERITE_DRILL_HEAD -> 8.0
else -> 0.0
}
}
companion object {
fun isValidDrill(item: Item) =
item == IRItemRegistry.STONE_DRILL_HEAD
|| item == IRItemRegistry.IRON_DRILL_HEAD
|| item == IRItemRegistry.DIAMOND_DRILL_HEAD
|| item == IRItemRegistry.NETHERITE_DRILL_HEAD
fun tick(world: World, pos: BlockPos, state: BlockState, blockEntity: DrillBlockEntity) {
if (blockEntity.inventory[0].isEmpty) {
blockEntity.position = 1.0
blockEntity.markDirty()
blockEntity.sync()
} else if (state[DrillBlock.WORKING]) {
if (blockEntity.position > 0) blockEntity.position -= 0.01
else return
blockEntity.markDirty()
blockEntity.sync()
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/miningrig/DrillBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.miningrig
import me.steven.indrev.blocks.machine.DrillBlock
import me.steven.indrev.registry.IRItemRegistry
import me.steven.indrev.utils.identifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.render.OverlayTexture
import net.minecraft.client.render.RenderLayers
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.WorldRenderer
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.ModelIdentifier
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Vec3f
class DrillBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: DrillBlockEntity,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider,
light: Int,
overlay: Int
) {
val variant = when (entity.inventory[0].item) {
IRItemRegistry.STONE_DRILL_HEAD -> "stone"
IRItemRegistry.IRON_DRILL_HEAD -> "iron"
IRItemRegistry.DIAMOND_DRILL_HEAD -> "diamond"
IRItemRegistry.NETHERITE_DRILL_HEAD -> "netherite"
else -> return
}
val model =
MinecraftClient.getInstance().bakedModelManager.getModel(ModelIdentifier(identifier("drill_head"), variant))
matrices?.run {
push()
val entry = peek()
translate(0.5, 0.0, 0.5)
if (entity.position <= 0.0 && entity.cachedState[DrillBlock.WORKING]) {
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion( (entity.world!!.time + tickDelta) * 12))
}
translate(-0.5, entity.position, -0.5)
MinecraftClient.getInstance().blockRenderManager.modelRenderer.render(
entry,
vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.cachedState)),
null,
model,
-1f,
-1f,
-1f,
WorldRenderer.getLightmapCoordinates(entity.world, entity.pos),
OverlayTexture.DEFAULT_UV
)
pop()
}
}
override fun rendersOutsideBoundingBox(blockEntity: DrillBlockEntity?): Boolean = true
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/miningrig/MiningRigBlockEntity.kt
================================================
package me.steven.indrev.blockentities.miningrig
import me.steven.indrev.api.OreDataCards
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.blocks.machine.DrillBlock
import me.steven.indrev.blocks.machine.MachineBlock
import me.steven.indrev.components.*
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.config.IRConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.misc.OreDataCardItem
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.*
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction
import net.minecraft.block.BlockState
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import java.util.EnumSet
class MiningRigBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: MachineBlockEntity(tier, MachineRegistry.MINING_RIG_REGISTRY, pos, state) {
init {
this.inventoryComponent = inventory(this) {
input {
0 filter { itemStack, _ -> itemStack.item is OreDataCardItem }
}
}
trackLong(ENERGY_REQUIRED_ID) { getEnergyCost() }
trackInt(MAX_SPEED_ID) {
OreDataCards.readNbt(inventoryComponent!!.inventory.getStack(0))?.speed ?: 0
}
VALID_DRILL_POSITIONS.forEachIndexed { index, offset ->
val id = START_DRILL_ID + index
val drillPos = pos.add(offset)
trackDouble(id) {
val block = world?.getBlockState(drillPos)?.block as? DrillBlock ?: return@trackDouble 0.0
val drillBlockEntity = world?.getBlockEntity(block.part.getBlockEntityPos(drillPos)) as? DrillBlockEntity ?: return@trackDouble 0.0
drillBlockEntity.miningProgress
}
}
}
override val syncToWorld: Boolean = true
override val maxInput: Long = config.maxInput
override val maxOutput: Long = 0
var lastMinedItem: ItemStack = ItemStack.EMPTY
val storageDirections = Direction.values().toMutableList()
private val remainingStacks = mutableListOf()
override fun machineTick() {
val inventory = inventoryComponent?.inventory ?: return
if (remainingStacks.isNotEmpty()) {
val copy = ArrayList(remainingStacks)
remainingStacks.clear()
copy.forEach { output(it) }
getActiveDrills().forEach { drill -> drill.setWorkingState(false) }
workingState = false
return
}
val cardStack = inventory.getStack(0)
val data = OreDataCards.readNbt(cardStack)
if (data != null && data.isValid() && !data.isEmpty() && use(getEnergyCost())) {
workingState = true
val before = data.used
getActiveDrills().forEach { drill -> drill.tickMining(this, data) }
if (before != data.used)
OreDataCards.writeNbt(cardStack, data)
} else {
workingState = false
getActiveDrills().forEach { drill ->
drill.setWorkingState(false)
drill.miningProgress = 0.0
}
}
}
fun output(stack: ItemStack) {
val variant = ItemVariant.of(stack)
var count = stack.count.toLong()
storageDirections.removeIf { dir ->
val itemStorage = itemStorageOf(world!!, pos.offset(dir), dir.opposite) ?: return@removeIf true
if (count > 0) {
transaction { tx ->
val inserted = itemStorage.insert(variant, count, tx)
tx.commit()
count -= inserted
}
}
false
}
if (count > 0) {
stack.count = count.toInt()
remainingStacks.add(stack)
}
}
fun getActiveDrills(): List {
return VALID_DRILL_POSITIONS.map { pos.add(it) }.mapNotNull { pos ->
val blockState = world?.getBlockState(pos)
val block = blockState?.block
if (block is DrillBlock) {
val blockEntity = world?.getBlockEntity(block.part.getBlockEntityPos(pos)) as? DrillBlockEntity ?: return@mapNotNull null
val itemStack = blockEntity.inventory[0]
if (!itemStack.isEmpty && DrillBlockEntity.isValidDrill(itemStack.item)) {
blockEntity
} else {
blockEntity.setWorkingState(false)
null
}
} else null
}
}
override fun getEnergyCost(): Long {
return config.energyCost + (IRConfig.machines.drill * getActiveDrills().size) + (OreDataCards.readNbt(inventoryComponent!!.inventory.getStack(0))?.energyRequired ?: 0)
}
override fun applyDefault(
state: BlockState,
type: ConfigurationType,
configuration: MutableMap
) {
val direction = (state.block as MachineBlock).getFacing(state)
when (type) {
ConfigurationType.ITEM -> {
configuration[direction.rotateYCounterclockwise()] = TransferMode.OUTPUT
}
else -> super.applyDefault(state, type, configuration)
}
}
override fun getValidConfigurations(type: ConfigurationType): Array {
return when (type) {
ConfigurationType.ITEM -> arrayOf(TransferMode.OUTPUT, TransferMode.NONE)
else -> return super.getValidConfigurations(type)
}
}
override fun toClientTag(tag: NbtCompound) {
tag.put("LastMinedBlock", lastMinedItem.writeNbt(NbtCompound()))
}
override fun fromClientTag(tag: NbtCompound) {
lastMinedItem = ItemStack.fromNbt(tag.getCompound("LastMinedBlock"))
}
companion object {
val VALID_DRILL_POSITIONS = arrayOf(
BlockPos(-1, 0, 0),
BlockPos(1, 0, 0),
BlockPos(0, 0, -1),
BlockPos(0, 0, 1),
BlockPos(-1, 0, -1),
BlockPos(-1, 0, 1),
BlockPos(1, 0, 1),
BlockPos(1, 0, -1)
)
const val ENERGY_REQUIRED_ID = 2
const val MAX_SPEED_ID = 3
const val START_DRILL_ID = 4
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/miningrig/MiningRigBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.miningrig
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import net.minecraft.client.MinecraftClient
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.render.model.json.ModelTransformation
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3f
class MiningRigBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: MiningRigBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
if (entity == null || !entity.workingState) return
matrices?.run {
push()
val direction = entity.cachedState[HorizontalFacingMachineBlock.HORIZONTAL_FACING]
when (direction) {
Direction.NORTH -> translate(0.34, 0.6, -0.01)
Direction.SOUTH -> translate(0.66, 0.6, 1.01)
Direction.WEST -> translate(-0.01, 0.6, 0.66)
Direction.EAST -> translate(1.01, 0.6, 0.34)
else -> {
pop()
return
}
}
multiply(Vec3f.NEGATIVE_Y.getDegreesQuaternion(direction.asRotation()))
scale(0.3f, 0.3f, 0.01f)
MinecraftClient.getInstance().itemRenderer.renderItem(entity.lastMinedItem, ModelTransformation.Mode.GUI, 15728880, overlay, this, vertexConsumers, 0)
pop()
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/modularworkbench/ModularWorkbenchBlockEntity.kt
================================================
package me.steven.indrev.blockentities.modularworkbench
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.components.autosync
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.items.armor.IRColorModuleItem
import me.steven.indrev.items.armor.IRModularArmorItem
import me.steven.indrev.items.armor.IRModuleItem
import me.steven.indrev.recipes.machines.ModuleRecipe
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.tools.modular.ArmorModule
import me.steven.indrev.tools.modular.IRModularItem
import me.steven.indrev.utils.component1
import me.steven.indrev.utils.component2
import me.steven.indrev.utils.getRecipes
import net.minecraft.block.BlockState
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.Identifier
import net.minecraft.util.math.BlockPos
class ModularWorkbenchBlockEntity(tier: Tier, pos: BlockPos, state: BlockState)
: MachineBlockEntity(tier, MachineRegistry.MODULAR_WORKBENCH_REGISTRY, pos, state) {
init {
this.inventoryComponent = inventory(this) {
maxStackCount = 1
0 filter { (_, item) -> item !is IRModularItem<*> }
1 filter { stack -> stack.item is IRModuleItem }
2 filter { stack -> stack.item is IRModularItem<*> }
3 until 15 filter { stack, index -> recipe != null && recipe!!.input.size > index - 3 && recipe!!.input[index - 3].ingredient.test(stack) }
input {
slots = (1 until 15).map { it }.toIntArray()
}
output { slot = 15 }
}
}
override val syncToWorld: Boolean = true
override val maxOutput: Long = 0
var moduleProcessTime by autosync(PROCESS_TIME_ID, 0)
var moduleMaxProcessTime by autosync(MAX_PROCESS_TIME_ID, 0)
private var processTime by autosync(INSTALL_TIME_ID, 0)
private var maxProcessTime by autosync(MAX_INSTALL_TIME_ID, 0)
private var state: State by autosync(STATE_ID, State.IDLE, State.values())
var selectedRecipe: Identifier? = null
var recipe: ModuleRecipe? = null
get() {
if (selectedRecipe != null)
field = world!!.recipeManager.getRecipes(ModuleRecipe.TYPE)[selectedRecipe]!!
return field
}
override fun machineTick() {
tickModuleInstall()
tickModuleCraft()
}
private fun tickModuleCraft() {
val inventory = inventoryComponent?.inventory ?: return
if (!inventory.getStack(15).isEmpty) return
val inputStacks = inventory.inputSlots.map { inventory.getStack(it) }
when {
recipe?.matches(inputStacks, emptyList()) != true -> {
moduleMaxProcessTime = 0
moduleProcessTime = 0
}
moduleMaxProcessTime in 1..moduleProcessTime -> {
(3 until 15).forEach { slot -> inventory.setStack(slot, ItemStack.EMPTY) }
inventory.setStack(15, recipe!!.outputs[0].stack.copy())
moduleMaxProcessTime = 0
moduleProcessTime = 0
}
else -> {
moduleMaxProcessTime = recipe!!.ticks
moduleProcessTime++
}
}
}
private fun tickModuleInstall() {
val inventory = inventoryComponent?.inventory ?: return
val targetStack = inventory.getStack(2)
val moduleStack = inventory.getStack(1)
if (moduleStack.item !is IRModuleItem || targetStack.item !is IRModularItem<*>) {
processTime = 0
state = State.IDLE
return
}
val targetItem = targetStack.item as IRModularItem<*>
val moduleItem = moduleStack.item as IRModuleItem
val module = moduleItem.module
val compatible = targetItem.getCompatibleModules(targetStack)
if (inventory.isEmpty) {
processTime = 0
workingState = false
state = State.IDLE
} else {
if (isProcessing()
&& compatible.contains(module)
&& use(config.energyCost)) {
workingState = true
processTime += config.processSpeed.toInt()
if (processTime >= maxProcessTime) {
inventory.setStack(1, ItemStack.EMPTY)
val tag = targetStack.orCreateNbt
when {
module == ArmorModule.COLOR -> {
if (targetItem !is IRModularArmorItem) return
val colorModuleItem = moduleItem as IRColorModuleItem
targetItem.setColor(targetStack, colorModuleItem.color)
}
tag.contains(module.key) -> {
val level = tag.getInt(module.key) + 1
tag.putInt(module.key, level.coerceAtMost(module.maxLevel))
}
else -> tag.putInt(module.key, 1)
}
processTime = 0
state = State.IDLE
}
} else if (energy > 0 && !targetStack.isEmpty && !moduleStack.isEmpty && compatible.contains(module)) {
val tag = targetStack.orCreateNbt
if (tag.contains(module.key)) {
val level = module.getMaxInstalledLevel(targetStack)
if (module != ArmorModule.COLOR && level >= module.maxLevel) {
state = State.MAX_LEVEL
return
}
}
processTime = 1
maxProcessTime = 1200
workingState = true
state = State.INSTALLING
} else {
state = State.INCOMPATIBLE
}
}
}
private fun isProcessing(): Boolean = processTime > 0 && energy > 0
override fun fromTag(tag: NbtCompound) {
processTime = tag.getInt("ProcessTime")
if (tag.contains("SelectedRecipe"))
selectedRecipe = Identifier(tag.getString("SelectedRecipe"))
super.fromTag(tag)
}
override fun toTag(tag: NbtCompound) {
tag.putInt("ProcessTime", processTime)
if (selectedRecipe != null)
tag.putString("SelectedRecipe", selectedRecipe!!.toString())
super.toTag(tag)
}
override fun fromClientTag(tag: NbtCompound) {
if (tag.contains("SelectedRecipe"))
selectedRecipe = Identifier(tag.getString("SelectedRecipe"))
inventoryComponent!!.readNbt(tag)
}
override fun toClientTag(tag: NbtCompound) {
if (selectedRecipe != null)
tag.putString("SelectedRecipe", selectedRecipe!!.toString())
inventoryComponent!!.writeNbt(tag)
}
enum class State {
IDLE,
INSTALLING,
INCOMPATIBLE,
MAX_LEVEL;
}
companion object {
const val PROCESS_TIME_ID = 2
const val MAX_PROCESS_TIME_ID = 3
const val INSTALL_TIME_ID = 4
const val MAX_INSTALL_TIME_ID = 5
const val STATE_ID = 6
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/modularworkbench/ModularWorkbenchBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.modularworkbench
import me.steven.indrev.armor.ModuleFeatureRenderer
import me.steven.indrev.components.multiblock.MultiblockBlockEntityRenderer
import me.steven.indrev.items.armor.IRModularArmorItem
import me.steven.indrev.tools.modular.IRModularItem
import me.steven.indrev.utils.identifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.model.Dilation
import net.minecraft.client.model.TexturedModelData
import net.minecraft.client.network.AbstractClientPlayerEntity
import net.minecraft.client.render.OverlayTexture
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.WorldRenderer
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.render.entity.model.BipedEntityModel
import net.minecraft.client.render.entity.model.ElytraEntityModel
import net.minecraft.client.render.entity.model.PlayerEntityModel
import net.minecraft.client.render.item.ItemRenderer
import net.minecraft.client.render.model.json.ModelTransformation
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.entity.EquipmentSlot
import net.minecraft.item.ArmorItem
import net.minecraft.item.ItemStack
import net.minecraft.util.Identifier
import net.minecraft.util.math.Vec3f
class ModularWorkbenchBlockEntityRenderer : BlockEntityRenderer {
private val bodyModel = BipedEntityModel(TexturedModelData.of(PlayerEntityModel.getTexturedModelData(Dilation.NONE, false), 64, 64).createModel())
private val leggingsModel = BipedEntityModel(TexturedModelData.of(PlayerEntityModel.getTexturedModelData(Dilation.NONE, false), 64, 64).createModel())
init {
bodyModel.setVisible(false)
leggingsModel.setVisible(false)
}
override fun render(
entity: ModularWorkbenchBlockEntity,
tickDelta: Float,
matrices: MatrixStack,
vertexConsumers: VertexConsumerProvider,
light: Int,
overlay: Int
) {
ElytraEntityModel.getTexturedModelData().createModel()
val itemStack = entity.inventoryComponent?.inventory?.getStack(2)
if (itemStack?.item is IRModularArmorItem) {
matrices.run {
push()
val yOffset = if (itemStack.item is IRModularArmorItem) {
when ((itemStack.item as IRModularArmorItem).slotType) {
EquipmentSlot.HEAD -> 1.0
EquipmentSlot.CHEST -> 1.5
EquipmentSlot.LEGS -> 1.7
EquipmentSlot.FEET -> 2.0
else -> -1.0
}
} else 0.0
val time = entity.world?.time ?: 1
translate(0.5, yOffset, 0.5)
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((time + tickDelta) * 4))
multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(180f))
val lightMapCoords = WorldRenderer.getLightmapCoordinates(entity.world, entity.pos)
renderArmor(this, vertexConsumers, itemStack, lightMapCoords)
pop()
}
} else if (itemStack?.item is IRModularItem<*>) {
val lightCoord = WorldRenderer.getLightmapCoordinates(entity.world, entity.pos)
matrices.run {
push()
val time = entity.world?.time ?: 1
translate(0.5, 0.35, 0.5)
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((time + tickDelta) * 4))
MinecraftClient.getInstance().itemRenderer.renderItem(itemStack, ModelTransformation.Mode.GROUND, lightCoord, overlay, matrices, vertexConsumers, 0)
pop()
}
}
}
private fun renderArmor(
matrices: MatrixStack,
vertexConsumers: VertexConsumerProvider,
itemStack: ItemStack,
light: Int
) {
val item = itemStack.item as? IRModularArmorItem ?: return
val slotType = item.slotType
val bipedEntityModel = getArmor(slotType)
setVisible(slotType)
val rgb = item.getColor(itemStack)
val r = (rgb and 0xFF0000 shr 16) / 255f
val g = (rgb and 0xFF00 shr 8) / 255f
val b = (rgb and 0xFF) / 255f
renderArmorParts(
matrices, vertexConsumers, light, item, itemStack.hasGlint(), bipedEntityModel, usesSecondLayer(slotType), r, g, b, null
)
item.getInstalled(itemStack).filter { it.slots.contains(slotType) }.forEach { module ->
if (module.hasTexture) {
renderArmorParts(
matrices, vertexConsumers, light, item, itemStack.hasGlint(), bipedEntityModel, usesSecondLayer(slotType), r, g, b, module.key
)
if (module.hasOverlay) {
renderArmorParts(
matrices, vertexConsumers, 15728880, item, itemStack.hasGlint(), bipedEntityModel, usesSecondLayer(slotType), r, g, b, "${module.key}_overlay"
)
}
}
}
}
private fun renderArmorParts(
matrixStack: MatrixStack,
vertexConsumerProvider: VertexConsumerProvider,
light: Int,
armorItem: ArmorItem,
hasGlint: Boolean,
bipedEntityModel: BipedEntityModel,
secondLayer: Boolean,
r: Float, g: Float, b: Float,
overlay: String?
) {
val vertexConsumer = ItemRenderer.getArmorGlintConsumer(
vertexConsumerProvider,
RenderLayer.getArmorCutoutNoCull(getArmorTexture(armorItem, secondLayer, overlay)),
false,
hasGlint
)
bipedEntityModel.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, r, g, b, 1.0f)
}
private fun getArmor(slot: EquipmentSlot): BipedEntityModel {
return if (usesSecondLayer(slot)) leggingsModel else bodyModel
}
private fun usesSecondLayer(slot: EquipmentSlot): Boolean {
return slot == EquipmentSlot.LEGS
}
private fun setVisible(slot: EquipmentSlot) {
bodyModel.head.visible = slot == EquipmentSlot.HEAD
bodyModel.hat.visible = slot == EquipmentSlot.HEAD
bodyModel.body.visible = slot == EquipmentSlot.CHEST
bodyModel.rightArm.visible = slot == EquipmentSlot.CHEST
bodyModel.leftArm.visible = slot == EquipmentSlot.CHEST
leggingsModel.body.visible = slot == EquipmentSlot.LEGS
leggingsModel.rightLeg.visible = slot == EquipmentSlot.LEGS
leggingsModel.leftLeg.visible = slot == EquipmentSlot.LEGS
bodyModel.rightLeg.visible = slot == EquipmentSlot.FEET
bodyModel.leftLeg.visible = slot == EquipmentSlot.FEET
}
private fun getArmorTexture(armorItem: ArmorItem, bl: Boolean, string: String?): Identifier {
val path = "textures/models/armor/" + armorItem.material.name + "_layer_" + (if (bl) 2 else 1) + (if (string == null) "" else "_$string") + ".png"
return ModuleFeatureRenderer.MODULAR_ARMOR_TEXTURE_CACHE.computeIfAbsent(path) { id ->
if (string == null) Identifier(id) else identifier(id)
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/solarpowerplant/HeliostatBlockEntity.kt
================================================
package me.steven.indrev.blockentities.solarpowerplant
import me.steven.indrev.blockentities.BaseBlockEntity
import me.steven.indrev.blocks.HeliostatBlock
import me.steven.indrev.registry.IRBlockRegistry
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class HeliostatBlockEntity(pos: BlockPos, state: BlockState) : BaseBlockEntity(IRBlockRegistry.HELIOSTAT_BLOCK_ENTITY, pos, state) {
var targetBlock: BlockPos = BlockPos.ORIGIN
var pitch: Float = 0.0f
var yaw: Float = 0.0f
companion object {
fun tick(world: World, pos: BlockPos, state: BlockState, blockEntity: HeliostatBlockEntity) {
//this doesn't work, i need another way to check if there's no obstruction
//val hit = world!!.raycastBlock(pos.toVec3d().add(0.5, 1.5, 0.5), targetBlock.toVec3d().add(0.5, 0.5, 0.5), pos, cachedState.getOutlineShape(world, pos), cachedState)
//if (hit !is BlockHitResult || hit.blockPos != targetBlock) return
if (!world.isSkyVisible(pos.up())) return
val receiver = world.getBlockEntity(blockEntity.targetBlock) as? SolarReceiverBlockEntity ?: return
val controller =
world.getBlockEntity(receiver.controllerPos) as? SolarPowerPlantTowerBlockEntity ?: return
controller.heliostats++
}
}
override fun toTag(tag: NbtCompound) {
tag.putLong("target", targetBlock.asLong())
}
override fun fromTag(tag: NbtCompound) {
targetBlock = BlockPos.fromLong(tag.getLong("target"))
yaw = HeliostatBlock.getYaw(pos, targetBlock)
pitch = HeliostatBlock.getPitch(pos, targetBlock)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/solarpowerplant/HeliostatBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.solarpowerplant
import net.minecraft.block.Blocks
import net.minecraft.block.HorizontalConnectingBlock
import net.minecraft.client.MinecraftClient
import net.minecraft.client.render.RenderLayers
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Vec3f
class HeliostatBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: HeliostatBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
if (entity == null) return
matrices?.run {
push()
val state = Blocks.GLASS_PANE.defaultState.with(HorizontalConnectingBlock.WEST, true).with(HorizontalConnectingBlock.EAST, true)
matrices.translate(0.5, 0.5, 0.5)
matrices.multiply(Vec3f.NEGATIVE_Y.getDegreesQuaternion(entity.yaw))
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(entity.pitch))
matrices.translate(-0.5, -0.5, -0.5)
val buffer = vertexConsumers?.getBuffer(RenderLayers.getBlockLayer(state))
MinecraftClient.getInstance().blockRenderManager.renderBlock(state, entity.pos, entity.world, this, buffer, false, entity.world!!.random)
pop()
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/solarpowerplant/SolarPowerPlantTowerBlockEntity.kt
================================================
package me.steven.indrev.blockentities.solarpowerplant
import me.steven.indrev.blockentities.BaseBlockEntity
import me.steven.indrev.blockentities.Syncable
import me.steven.indrev.components.*
import me.steven.indrev.components.multiblock.MultiBlockComponent
import me.steven.indrev.components.multiblock.definitions.SolarPowerPlantTowerStructureDefinition
import me.steven.indrev.registry.IRBlockRegistry
import me.steven.indrev.utils.bucket
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class SolarPowerPlantTowerBlockEntity(pos: BlockPos, state: BlockState)
: BaseBlockEntity(IRBlockRegistry.SOLAR_POWER_PLANT_TOWER_BLOCK_ENTITY, pos, state), Syncable {
override val guiSyncableComponent = GuiSyncableComponent()
val temperatureComponent = TemperatureComponent(this, 0.09, 1100..1300, 1500)
val multiblockComponent = SolarPowerPlantMultiblockComponent()
val fluidComponent = object : FluidComponent({ this }, bucket * 16, 2) {
init {
this.inputTanks = intArrayOf(0)
this.outputTanks = intArrayOf(1)
this.unsided = true
}
}
var isMarkedForUpdate = false
init {
trackObject(INPUT_TANK_ID, fluidComponent[0])
trackObject(OUTPUT_TANK_ID, fluidComponent[1])
}
var heliostats = 0
companion object {
const val INPUT_TANK_ID = 4
const val OUTPUT_TANK_ID = 5
fun tick(world: World, pos: BlockPos, state: BlockState, blockEntity: SolarPowerPlantTowerBlockEntity) {
blockEntity.multiblockComponent.tick(world, pos, state)
if (blockEntity.multiblockComponent.isBuilt(world, pos, state)) {
val limit = blockEntity.heliostats * 6
blockEntity.temperatureComponent.tick(blockEntity.temperatureComponent.temperature < limit + (world.random.nextFloat() * 2 - 1) * 10)
blockEntity.markForUpdate()
blockEntity.heliostats = 0
}
}
}
override fun fromTag(tag: NbtCompound) {
temperatureComponent.readNbt(tag)
fluidComponent.fromTag(tag)
multiblockComponent.readNbt(tag)
}
override fun toTag(tag: NbtCompound) {
temperatureComponent.writeNbt(tag)
fluidComponent.toTag(tag)
multiblockComponent.writeNbt(tag)
}
override fun fromClientTag(tag: NbtCompound) {
multiblockComponent.readNbt(tag)
}
override fun toClientTag(tag: NbtCompound) {
multiblockComponent.writeNbt(tag)
}
override fun markForUpdate(condition: () -> Boolean) {
isMarkedForUpdate = isMarkedForUpdate || condition()
}
inner class SolarPowerPlantMultiblockComponent : MultiBlockComponent({ _, _, _ -> SolarPowerPlantTowerStructureDefinition }) {
override fun tick(world: World, pos: BlockPos, blockState: BlockState) {
super.tick(world, pos, blockState)
SolarPowerPlantTowerStructureDefinition.getSolarReceiverPositions(pos, blockState).forEach { receiverPos ->
val blockEntity = world.getBlockEntity(receiverPos) as? SolarReceiverBlockEntity ?: return@forEach
blockEntity.controllerPos = pos
}
SolarPowerPlantTowerStructureDefinition.getFluidInputPositions(pos, blockState).forEach { inputPos ->
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/solarpowerplant/SolarReceiverBlockEntity.kt
================================================
package me.steven.indrev.blockentities.solarpowerplant
import me.steven.indrev.registry.IRBlockRegistry
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
class SolarReceiverBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(IRBlockRegistry.SOLAR_RECEIVER_BLOCK_ENTITY, pos, state) {
var controllerPos: BlockPos = BlockPos.ORIGIN
override fun writeNbt(tag: NbtCompound?) {
tag?.putLong("controller", controllerPos.asLong())
return super.writeNbt(tag)
}
override fun readNbt(tag: NbtCompound) {
super.readNbt(tag)
controllerPos = BlockPos.fromLong(tag.getLong("controller"))
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/storage/CabinetBlockEntity.kt
================================================
package me.steven.indrev.blockentities.storage
import me.steven.indrev.gui.screenhandlers.storage.CabinetScreenHandler
import me.steven.indrev.registry.IRBlockRegistry
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory
import net.minecraft.block.BlockState
import net.minecraft.block.entity.LootableContainerBlockEntity
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.inventory.Inventories
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound
import net.minecraft.network.PacketByteBuf
import net.minecraft.screen.ScreenHandler
import net.minecraft.screen.ScreenHandlerContext
import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.util.collection.DefaultedList
import net.minecraft.util.math.BlockPos
class CabinetBlockEntity(pos: BlockPos, state: BlockState) : LootableContainerBlockEntity(IRBlockRegistry.CABINET_BLOCK_ENTITY_TYPE, pos, state), ExtendedScreenHandlerFactory {
private var inventory: DefaultedList = DefaultedList.ofSize(27, ItemStack.EMPTY)
override fun size(): Int = 27
override fun getContainerName(): Text = TranslatableText("block.indrev.cabinet")
override fun createScreenHandler(syncId: Int, playerInventory: PlayerInventory): ScreenHandler {
return CabinetScreenHandler(syncId, playerInventory, ScreenHandlerContext.create(world, pos))
}
override fun getInvStackList(): DefaultedList = inventory
override fun setInvStackList(list: DefaultedList) {
inventory = list
}
override fun writeScreenOpeningData(player: ServerPlayerEntity?, buf: PacketByteBuf) {
buf.writeBlockPos(pos)
}
override fun readNbt(tag: NbtCompound?) {
super.readNbt(tag)
inventory = DefaultedList.ofSize(size(), ItemStack.EMPTY)
if (!deserializeLootTable(tag)) {
Inventories.readNbt(tag, inventory)
}
}
override fun writeNbt(tag: NbtCompound) {
super.writeNbt(tag)
if (!serializeLootTable(tag)) {
Inventories.writeNbt(tag, inventory)
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/storage/ChargePadBlockEntity.kt
================================================
package me.steven.indrev.blockentities.storage
import com.google.common.collect.Iterables
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.config.BasicMachineConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.asMutableList
import me.steven.indrev.utils.energyOf
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext
import net.minecraft.block.BlockState
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Box
import team.reborn.energy.api.EnergyStorage
class ChargePadBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) : MachineBlockEntity(tier, MachineRegistry.CHARGE_PAD_REGISTRY, pos, state) {
init {
this.inventoryComponent = inventory(this) {
input { slot = 0 }
output { slot = 0 }
}
}
override val syncToWorld: Boolean = true
override val maxOutput: Long = 16384
override val maxInput: Long = 16384
override val energyCapacity: Long = 0L
val energyIo = ChargePadEnergyStorage()
var hasCollided = false
private fun getItemEnergyIo() = energyOf(inventoryComponent!!.inventory, 0)
override fun fromClientTag(tag: NbtCompound) {
inventoryComponent!!.readNbt(tag)
}
override fun toClientTag(tag: NbtCompound) {
inventoryComponent!!.writeNbt(tag)
}
inner class ChargePadEnergyStorage : EnergyStorage {
override fun getAmount(): Long = getItemEnergyIo()?.amount ?: 0
override fun getCapacity(): Long = getItemEnergyIo()?.capacity ?: 0
override fun insert(amount: Long, transaction: TransactionContext?): Long {
val handlers = if (hasCollided) {
val collidedEntityItems = collectItemIos()
if (collidedEntityItems.isEmpty()) hasCollided = false
getItemEnergyIo()?.also { collidedEntityItems.add(it) }
collidedEntityItems
} else
getItemEnergyIo().let { if (it == null) emptyList() else listOf(it) }
if (handlers.isEmpty()) return 0
val max = amount.coerceAtMost(maxOutput)
var remainder = max
handlers.forEach { handler ->
if (remainder > 0)
remainder -= handler.insert(remainder, transaction)
else return 0
}
return max - remainder
}
override fun extract(maxAmount: Long, transaction: TransactionContext?): Long = 0
override fun supportsExtraction(): Boolean = false
override fun supportsInsertion(): Boolean = true
private fun collectItemIos(): MutableList {
return world!!.getEntitiesByClass(LivingEntity::class.java, Box(pos)) { true }.flatMap { entity ->
when (entity) {
is PlayerEntity -> Iterables.concat(entity.inventory.armor.mapIndexed { index, _ -> energyOf(entity.inventory, 36 + index) },
listOf(energyOf(entity.inventory, entity.inventory.selectedSlot), energyOf(entity.inventory, 40)))
else -> emptyList()
}
}.filterNotNull().asMutableList()
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/storage/ChargePadBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.storage
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import net.minecraft.client.MinecraftClient
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.WorldRenderer
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.render.model.json.ModelTransformation
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3f
import kotlin.math.abs
import kotlin.math.sin
class ChargePadBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: ChargePadBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
val inventory = entity?.inventoryComponent?.inventory
val stack = inventory?.getStack(0)
if (stack?.isEmpty == false) {
val facing = entity.cachedState[HorizontalFacingMachineBlock.HORIZONTAL_FACING].rotateYClockwise()
var x = abs(facing.offsetX.toFloat()) * 0.5
var z = abs(facing.offsetZ.toFloat()) * 0.5
if (facing.offsetX == -1)
z = x
else if (facing.offsetZ == 1) x = z
when (facing.axis) {
Direction.Axis.X -> z += 0.2
Direction.Axis.Z -> x += 0.2
else -> return
}
matrices?.run {
push()
val time = entity.world?.time ?: 1
val offset = sin((time + tickDelta) / 16.0) / 32.0
translate(x, 1.1 + offset, z)
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((time + tickDelta) * 4))
scale(0.5f, 0.5f, 0.5f)
val lightAbove = WorldRenderer.getLightmapCoordinates(entity.world, entity.pos.up())
MinecraftClient.getInstance().itemRenderer.renderItem(stack, ModelTransformation.Mode.GROUND, lightAbove, overlay, this, vertexConsumers, 0)
pop()
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/storage/LazuliFluxContainerBlockEntity.kt
================================================
package me.steven.indrev.blockentities.storage
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.api.sideconfigs.SideConfiguration
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.blocks.machine.FacingMachineBlock
import me.steven.indrev.config.LFCConfig
import me.steven.indrev.inventories.inventory
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.energyOf
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import team.reborn.energy.api.EnergyStorageUtil
import kotlin.math.floor
class LazuliFluxContainerBlockEntity(tier: Tier, pos: BlockPos, state: BlockState) :
MachineBlockEntity(tier, MachineRegistry.LAZULI_FLUX_CONTAINER_REGISTRY, pos, state) {
init {
this.inventoryComponent = inventory(this) {
input { 0 filter { stack -> energyOf(stack) != null } }
}
}
override val syncToWorld: Boolean = true
override val maxInput: Long = config.maxInput
override val maxOutput: Long = config.maxOutput
val transferConfig: SideConfiguration = SideConfiguration(ConfigurationType.ENERGY)
override val storage = LazuliFluxContainerEnergyStorage()
private var clientLastRenderWidth = 0f
override fun machineTick() {
if (world?.isClient == true) return
val inventory = inventoryComponent?.inventory ?: return
val itemIo = energyOf(inventory, 0)
if (itemIo != null)
EnergyStorageUtil.move(storage.getSideStorage(null), itemIo, maxOutput, null)
}
private fun update() {
val width = floor((((energy.toFloat() / energyCapacity.toFloat()) * 0.5f) + 0.25f) * 16)
if (width != clientLastRenderWidth) {
sync()
clientLastRenderWidth = width
}
}
override fun isConfigurable(type: ConfigurationType): Boolean {
return type == ConfigurationType.ENERGY
}
override fun getCurrentConfiguration(type: ConfigurationType): SideConfiguration {
return transferConfig
}
override fun applyDefault(state: BlockState, type: ConfigurationType, configuration: MutableMap) {
val facing = state[FacingMachineBlock.FACING]
Direction.values().forEach { dir ->
if (dir == facing && tier != Tier.CREATIVE) configuration[dir] = TransferMode.INPUT
else configuration[dir] = TransferMode.OUTPUT
}
}
override fun toTag(tag: NbtCompound) {
transferConfig.writeNbt(tag)
super.toTag(tag)
}
override fun fromTag(tag: NbtCompound) {
super.fromTag(tag)
transferConfig.readNbt(tag)
}
override fun toClientTag(tag: NbtCompound) {
tag.putLong("energy", energy)
transferConfig.writeNbt(tag)
}
override fun fromClientTag(tag: NbtCompound) {
transferConfig.readNbt(tag)
energy = tag.getLong("energy")
}
inner class LazuliFluxContainerEnergyStorage : MachineEnergyStorage() {
override fun getMaxInsert(side: Direction?): Long {
return if (side == null || transferConfig.canInput(side)) maxInput
else 0
}
override fun getMaxExtract(side: Direction?): Long {
return if (side == null || transferConfig.canOutput(side)) maxOutput
else 0
}
override fun onFinalCommit() {
super.onFinalCommit()
update()
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/storage/LazuliFluxContainerBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.storage
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.utils.identifier
import net.minecraft.client.MinecraftClient
import net.minecraft.client.render.OverlayTexture
import net.minecraft.client.render.RenderLayer
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.texture.Sprite
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.screen.PlayerScreenHandler
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3f
import kotlin.math.absoluteValue
import kotlin.math.floor
import kotlin.math.sin
class LazuliFluxContainerBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: LazuliFluxContainerBlockEntity?,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
entity ?: return
val width = ((entity.energy.toFloat() / entity.energyCapacity.toFloat()) * 0.5f) + 0.25f
val sprite = MinecraftClient.getInstance().getSpriteAtlas(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).apply(identifier("block/lazuli_flux_container_lf_level"))
val color: Long = (255 shl 24 or when (entity.tier) {
Tier.MK1 -> 0xffbb19
Tier.MK2 -> 0x5d3dff
Tier.MK3 -> 0xfd47ff
else -> 0xff4070
}).toLong()
val maxX = floor((width * 16)) / 16f
val time = entity.world!!.time
matrices?.run {
val offset = 0.001
push()
translate(-0.0, 0.0, -offset)
drawOverlay(this, 0.25f, 0f, maxX, 1f, color, sprite, vertexConsumers, Direction.NORTH, width, tickDelta, time)
translate(0.0, 0.0, offset)
translate(0.5, 0.5, 0.5)
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90f))
translate(-0.5, -0.5, -0.5)
translate(0.0, 0.0, -offset)
drawOverlay(this, 0.25f, 0f, maxX, 1f, color, sprite, vertexConsumers, Direction.EAST, width, tickDelta, time)
translate(0.0, 0.0, offset)
translate(0.5, 0.5, 0.5)
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90f))
translate(-0.5, -0.5, -0.5)
translate(-0.0, 0.0, -offset)
drawOverlay(this, 0.25f, 0f, maxX, 1f, color, sprite, vertexConsumers, Direction.SOUTH, width, tickDelta, time)
translate(0.0, 0.0, offset)
translate(0.5, 0.5, 0.5)
multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90f))
translate(-0.5, -0.5, -0.5)
translate(0.0, 0.0, -offset)
drawOverlay(this, 0.25f, 0f, maxX, 1f, color, sprite, vertexConsumers, Direction.WEST, width, tickDelta, time)
translate(0.0, 0.0, offset)
pop()
}
}
private fun drawOverlay(matrices: MatrixStack, x1: Float, y1: Float, x2: Float, y2: Float, color: Long, sprite: Sprite, vertexConsumers: VertexConsumerProvider?, direction: Direction, width: Float, tickDelta: Float, time: Long) {
val matrix = matrices.peek().positionMatrix
var xx1 = x1
var xx2 = x2
var yy1 = x1
var yy2 = x2
if (x1 < x2) {
xx1 = x2
xx2 = x1
}
if (y1 < y2) {
yy1 = y2
yy2 = y1
}
val a = (color shr 24 and 255) / 255.0f
val r = (color shr 16 and 255) / 255.0f
val g = (color shr 8 and 255) / 255.0f
val b = (color and 255) / 255.0f
val vec = direction.unitVector
var maxU = sprite.getFrameU(4.0)
var minU = sprite.getFrameU(floor(width.toDouble() * 16))
val normal = matrices.peek().normalMatrix
vertexConsumers?.getBuffer(RenderLayer.getEntityTranslucent(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE))?.run {
fun vertex(x: Float, y: Float, u: Float, v: Float, alpha: Float = a) {
this@run.vertex(matrix, x, y, 0.0f).color(r, g, b, alpha).texture(u, v).overlay(OverlayTexture.DEFAULT_UV).light(EMISSIVE_LIGHT).normal(normal, vec.x, vec.y, vec.z).next()
}
vertex(xx1, yy1, minU, sprite.minV)
vertex(xx1, yy2, minU, sprite.maxV)
vertex(xx2, yy2, maxU, sprite.maxV)
vertex(xx1, yy1, minU, sprite.minV)
vertex(xx1, yy1, minU, sprite.minV)
vertex(xx2, yy2, maxU, sprite.maxV)
vertex(xx2, yy1, maxU, sprite.minV)
vertex(xx1, yy1, minU, sprite.minV)
if (width < 0.75 && width > 0.25) {
xx2 = xx1
xx1 = (floor(width * 16) + 1) / 16f
val opacity = sin((time + tickDelta) / 8).absoluteValue
maxU = minU
minU = sprite.getFrameU(floor(width.toDouble() * 16) + 1)
vertex(xx1, yy1, minU, sprite.minV, opacity)
vertex(xx1, yy2, minU, sprite.maxV, opacity)
vertex(xx2, yy2, maxU, sprite.maxV, opacity)
vertex(xx1, yy1, minU, sprite.minV, opacity)
vertex(xx1, yy1, minU, sprite.minV, opacity)
vertex(xx2, yy2, maxU, sprite.maxV, opacity)
vertex(xx2, yy1, maxU, sprite.minV, opacity)
vertex(xx1, yy1, minU, sprite.minV, opacity)
}
}
}
companion object {
private const val EMISSIVE_LIGHT = 15728880
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/storage/TankBlockEntity.kt
================================================
package me.steven.indrev.blockentities.storage
import me.steven.indrev.IndustrialRevolution
import me.steven.indrev.blockentities.BaseBlockEntity
import me.steven.indrev.blockentities.Syncable
import me.steven.indrev.blocks.misc.TankBlock
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.registry.IRBlockRegistry
import me.steven.indrev.utils.bucket
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant
import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil
import net.fabricmc.fabric.api.transfer.v1.storage.base.CombinedStorage
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext
import net.minecraft.block.BlockState
import net.minecraft.nbt.NbtCompound
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class TankBlockEntity(pos: BlockPos, state: BlockState) : BaseBlockEntity(IRBlockRegistry.TANK_BLOCK_ENTITY, pos, state), Syncable {
val fluidComponent = object : FluidComponent({ this }, bucket * 8) {
init {
this.unsided = true
}
}
var isMarkedForUpdate: Boolean = true
companion object {
fun tick(world: World, pos: BlockPos, state: BlockState, blockEntity: TankBlockEntity) {
if (world.isClient) return
if (blockEntity.isMarkedForUpdate) {
blockEntity.markDirty()
blockEntity.sync()
blockEntity.isMarkedForUpdate = false
}
if (!state[TankBlock.DOWN]) return
val down = world.getBlockEntity(pos.down()) as? TankBlockEntity ?: return
val volume = StorageUtil.move(blockEntity.fluidComponent, down.fluidComponent, { true }, Long.MAX_VALUE, null)
if (volume > 0) {
down.isMarkedForUpdate = true
blockEntity.isMarkedForUpdate = true
}
}
}
override fun toTag(tag: NbtCompound) {
fluidComponent.toTag(tag)
}
override fun fromTag(tag: NbtCompound) {
fluidComponent.fromTag(tag)
}
override fun toClientTag(tag: NbtCompound) {
fluidComponent.toTag(tag)
}
override fun fromClientTag(tag: NbtCompound) {
fluidComponent.fromTag(tag)
}
override fun markDirty() {
if (world != null) {
world!!.markDirty(pos)
}
}
override fun markForUpdate(condition: () -> Boolean) {
isMarkedForUpdate = isMarkedForUpdate || condition()
}
class CombinedTankStorage : CombinedStorage(mutableListOf()) {
var initialFluid = FluidVariant.blank()
fun add(tank: TankBlockEntity): Boolean {
val invFluid = tank.fluidComponent[0]
if (initialFluid.isBlank && !invFluid.isEmpty) {
initialFluid = invFluid.variant
} else if (!invFluid.isEmpty && initialFluid != invFluid.variant) {
IndustrialRevolution.LOGGER.debug("Found connected tanks with mismatching fluids @ ${tank.pos}")
return false
}
parts.add(tank.fluidComponent)
return true
}
override fun insert(resource: FluidVariant?, maxAmount: Long, transaction: TransactionContext?): Long {
if (!initialFluid.isBlank && resource != initialFluid) return 0
return super.insert(resource, maxAmount, transaction)
}
override fun extract(resource: FluidVariant?, maxAmount: Long, transaction: TransactionContext?): Long {
if (!initialFluid.isBlank && resource != initialFluid) return 0
return super.extract(resource, maxAmount, transaction)
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blockentities/storage/TankBlockEntityRenderer.kt
================================================
package me.steven.indrev.blockentities.storage
import alexiil.mc.lib.attributes.fluid.render.FluidRenderFace
import me.steven.indrev.blocks.misc.TankBlock
import net.minecraft.client.render.VertexConsumerProvider
import net.minecraft.client.render.block.entity.BlockEntityRenderer
import net.minecraft.client.util.math.MatrixStack
class TankBlockEntityRenderer : BlockEntityRenderer {
override fun render(
entity: TankBlockEntity,
tickDelta: Float,
matrices: MatrixStack?,
vertexConsumers: VertexConsumerProvider?,
light: Int,
overlay: Int
) {
val fluidComponent = entity.fluidComponent
val volume = fluidComponent[0]
if (volume.isEmpty) return
val fluid = volume.amount
val maxFluid = fluidComponent.limit
var percent = fluid.toFloat() / maxFluid.toFloat()
val maxHeight = if (entity.cachedState[TankBlock.UP]) 16 else 14
percent = (percent * maxHeight).toInt() / 16f
val yHeight = percent.toDouble().coerceAtLeast(0.1)
val faces = mutableListOf(
FluidRenderFace.createFlatFaceZ(0.9, 0.0, 0.1, 0.1, yHeight, 0.1, 1.0, true, false),
FluidRenderFace.createFlatFaceZ(0.1, 0.0, 0.9, 0.9, yHeight, 0.9, 1.0, true, false),
FluidRenderFace.createFlatFaceX(0.1, 0.0, 0.1, 0.1, yHeight, 0.9, 1.0, false, false),
FluidRenderFace.createFlatFaceX(0.9, 0.0, 0.9, 0.9, yHeight, 0.1, 1.0, false, false),
)
var renderFluidTop = true
if (entity.cachedState[TankBlock.UP]) {
val aboveTank = entity.world!!.getBlockEntity(entity.pos.up()) as? TankBlockEntity
renderFluidTop = aboveTank?.fluidComponent?.get(0)?.variant != volume.variant
}
if (renderFluidTop) {
faces.add(FluidRenderFace.createFlatFaceY(0.1, yHeight, 0.1, 0.9, yHeight, 0.9, 1.0, true, false))
}
for (face in faces) {
face.light = light;
}
volume.render(faces, vertexConsumers, matrices);
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/HeliostatBlock.kt
================================================
package me.steven.indrev.blocks
import me.steven.indrev.blockentities.solarpowerplant.HeliostatBlockEntity
import net.minecraft.block.Block
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockRenderType
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityTicker
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.math.MathHelper
import net.minecraft.world.World
class HeliostatBlock(settings: Settings) : Block(settings), BlockEntityProvider {
override fun getRenderType(state: BlockState?): BlockRenderType = BlockRenderType.ENTITYBLOCK_ANIMATED
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = HeliostatBlockEntity(pos, state)
override fun getTicker(
world: World,
state: BlockState?,
type: BlockEntityType?
): BlockEntityTicker? {
return if (world.isClient) null
else return BlockEntityTicker { world, pos, state, blockEntity ->
HeliostatBlockEntity.tick(world, pos, state, blockEntity as? HeliostatBlockEntity ?: return@BlockEntityTicker)
}
}
companion object {
private const val RAD2DEG = 57.2957763671875
fun getYaw(origin: BlockPos, target: BlockPos): Float {
val xOffset = target.x + 0.0 - origin.x.toDouble() + 0.0
val zOffset = target.z + 0.0 - origin.z.toDouble() + 0.0
return MathHelper.wrapDegrees((MathHelper.atan2(zOffset, xOffset) * RAD2DEG).toFloat() - 90.0f)
}
fun getPitch(origin: BlockPos, target: BlockPos): Float {
val xOffset = target.x + 0.0f - origin.x.toFloat() + 0.0f
val yOffset = target.y + 0.0f - origin.y.toFloat() + 0.0f
val zOffset = target.z + 0.0f - origin.z.toFloat() + 0.0f
val g = MathHelper.sqrt(xOffset * xOffset + zOffset * zOffset).toDouble()
return MathHelper.wrapDegrees((-(MathHelper.atan2(yOffset.toDouble(), g) * RAD2DEG)).toFloat())
}
fun findConnectingHeliostats(origin: BlockPos, world: World, scanned: MutableSet, positions: MutableSet) {
Direction.values().forEach { dir ->
val off = origin.offset(dir)
if (scanned.add(off.asLong()) && world.testBlockState(off) { state -> state.block is HeliostatBlock }) {
positions.add(off.asLong())
findConnectingHeliostats(off, world, scanned, positions)
}
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/CapsuleBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.blockentities.laser.CapsuleBlockEntity
import me.steven.indrev.recipes.machines.LaserRecipe
import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings
import net.minecraft.block.Block
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.Material
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityTicker
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemStack
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.ItemScatterer
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.BlockView
import net.minecraft.world.World
class CapsuleBlock : Block(FabricBlockSettings.of(Material.GLASS).requiresTool().nonOpaque().strength(1f, 1f)), BlockEntityProvider {
override fun onUse(
state: BlockState?,
world: World,
pos: BlockPos?,
player: PlayerEntity,
hand: Hand?,
hit: BlockHitResult?
): ActionResult {
if (!world.isClient && hand == Hand.MAIN_HAND) {
val stack = player.getStackInHand(hand)
val recipe = LaserRecipe.TYPE.getMatchingRecipe(world as ServerWorld, stack)
.firstOrNull { it.matches(stack, emptyList()) }
val blockEntity = world.getBlockEntity(pos) as? CapsuleBlockEntity ?: return ActionResult.PASS
if (recipe != null && blockEntity.inventory[0].isEmpty) {
player.setStackInHand(hand, ItemStack.EMPTY)
blockEntity.inventory[0] = stack
} else if (!blockEntity.inventory[0].isEmpty) {
val itemStack = blockEntity.inventory[0]
itemStack.nbt = null
player.inventory?.insertStack(itemStack)
blockEntity.inventory[0] = ItemStack.EMPTY
} else
return ActionResult.PASS
world.updateNeighbors(pos, this)
blockEntity.markDirty()
blockEntity.sync()
return ActionResult.SUCCESS
}
return ActionResult.PASS
}
override fun onStateReplaced(
state: BlockState?,
world: World,
pos: BlockPos,
newState: BlockState?,
moved: Boolean
) {
val blockEntity = world.getBlockEntity(pos) as? CapsuleBlockEntity
if (blockEntity != null)
ItemScatterer.spawn(world, pos, blockEntity.inventory)
super.onStateReplaced(state, world, pos, newState, moved)
}
override fun emitsRedstonePower(state: BlockState?): Boolean = true
override fun getWeakRedstonePower(
state: BlockState?,
world: BlockView,
pos: BlockPos,
direction: Direction?
): Int {
val blockEntity = world.getBlockEntity(pos) as? CapsuleBlockEntity ?: return 0
if (blockEntity.world!!.isClient) return 0
val stack = blockEntity.inventory[0]
val recipe = LaserRecipe.TYPE.getMatchingRecipe(world as ServerWorld, stack)
.firstOrNull { it.matches(stack, emptyList()) }
return if (recipe == null) 15
else 0
}
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = CapsuleBlockEntity(pos, state)
override fun getTicker(
world: World,
state: BlockState?,
type: BlockEntityType?
): BlockEntityTicker? {
return if (world.isClient) null
else BlockEntityTicker { world, pos, state, blockEntity ->
CapsuleBlockEntity.tick(world, pos, state, blockEntity as CapsuleBlockEntity)
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/ChargePadBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.storage.ChargePadBlockEntity
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.energyOf
import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.minecraft.block.BlockState
import net.minecraft.block.ShapeContext
import net.minecraft.client.item.TooltipContext
import net.minecraft.entity.Entity
import net.minecraft.entity.decoration.ArmorStandEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemPlacementContext
import net.minecraft.item.ItemStack
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.util.ActionResult
import net.minecraft.util.Formatting
import net.minecraft.util.Hand
import net.minecraft.util.function.BooleanBiFunction
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView
import net.minecraft.world.World
import java.util.*
import java.util.stream.Stream
class ChargePadBlock(registry: MachineRegistry, settings: Settings, tier: Tier) :
HorizontalFacingMachineBlock(registry, settings, tier, null, null) {
override fun getOutlineShape(
state: BlockState,
world: BlockView?,
pos: BlockPos?,
context: ShapeContext?
): VoxelShape =
when (state[HORIZONTAL_FACING]) {
Direction.NORTH -> FACING_NORTH
Direction.SOUTH -> FACING_SOUTH
Direction.EAST -> FACING_EAST
Direction.WEST -> FACING_WEST
else -> FACING_NORTH
}
override fun onUse(state: BlockState?, world: World, pos: BlockPos?, player: PlayerEntity?, hand: Hand?, hit: BlockHitResult?): ActionResult {
val blockEntity = world.getBlockEntity(pos) as? ChargePadBlockEntity ?: return ActionResult.PASS
val inventory = blockEntity.inventoryComponent?.inventory ?: return ActionResult.PASS
val machineStack = inventory.getStack(0)
if (!machineStack.isEmpty) {
player?.inventory?.insertStack(machineStack)
return ActionResult.SUCCESS
}
val handStack = player?.mainHandStack
if (energyOf(player?.inventory, player?.inventory?.selectedSlot?: return ActionResult.PASS) != null) {
inventory.setStack(0, handStack)
player.setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY)
return ActionResult.SUCCESS
}
return ActionResult.PASS
}
override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? {
super.getPlacementState(ctx)
return this.defaultState.with(HORIZONTAL_FACING, ctx?.playerFacing)
}
override fun onEntityCollision(state: BlockState?, world: World?, pos: BlockPos?, entity: Entity?) {
if (entity is PlayerEntity || entity is ArmorStandEntity) {
val blockEntity = world?.getBlockEntity(pos) as? ChargePadBlockEntity ?: return
blockEntity.hasCollided = true
}
}
override fun appendTooltip(stack: ItemStack?, view: BlockView?, tooltip: MutableList?, options: TooltipContext?) {
super.appendTooltip(stack, view, tooltip, options)
tooltip?.add(TranslatableText("block.indrev.charge_pad_mk4.tooltip").formatted(Formatting.BLUE, Formatting.ITALIC))
}
@Environment(EnvType.CLIENT)
override fun randomDisplayTick(state: BlockState?, world: World, pos: BlockPos, random: Random?) {
}
companion object {
private val FACING_NORTH = Stream.of(
createCuboidShape(1.0, 0.0, 1.0, 15.0, 0.1, 15.0),
createCuboidShape(1.25, 0.0, 1.25, 14.75, 0.3, 14.75),
createCuboidShape(7.0, 0.0, 2.0, 9.0, 15.0, 4.0),
createCuboidShape(8.0, 15.0, 2.0, 9.0, 15.5, 3.0),
createCuboidShape(7.0, 15.0, 2.0, 8.0, 15.5, 3.0),
createCuboidShape(7.0, 15.0, 3.0, 8.0, 15.2, 4.0),
createCuboidShape(8.0, 15.0, 3.0, 9.0, 15.2, 4.0)
).reduce { v1: VoxelShape?, v2: VoxelShape? -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
private val FACING_SOUTH: VoxelShape = Stream.of(
createCuboidShape(1.0, 0.0, 1.0, 15.0, 0.1, 15.0),
createCuboidShape(1.25, 0.0, 1.25, 14.75, 0.3, 14.75),
createCuboidShape(7.0, 0.0, 12.0, 9.0, 15.0, 14.0),
createCuboidShape(7.0, 15.0, 13.0, 8.0, 15.5, 14.0),
createCuboidShape(8.0, 15.0, 13.0, 9.0, 15.5, 14.0),
createCuboidShape(8.0, 15.0, 12.0, 9.0, 15.2, 13.0),
createCuboidShape(7.0, 15.0, 12.0, 8.0, 15.2, 13.0)
).reduce { v1: VoxelShape?, v2: VoxelShape? -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
private val FACING_WEST = Stream.of(
createCuboidShape(1.0, 0.0, 1.0, 15.0, 0.1, 15.0),
createCuboidShape(1.25, 0.0, 1.25, 14.75, 0.3, 14.75),
createCuboidShape(2.0, 0.0, 7.0, 4.0, 15.0, 9.0),
createCuboidShape(2.0, 15.0, 7.0, 3.0, 15.5, 8.0),
createCuboidShape(2.0, 15.0, 8.0, 3.0, 15.5, 9.0),
createCuboidShape(3.0, 15.0, 8.0, 4.0, 15.2, 9.0),
createCuboidShape(3.0, 15.0, 7.0, 4.0, 15.2, 8.0)
).reduce { v1: VoxelShape?, v2: VoxelShape? -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
private val FACING_EAST = Stream.of(
createCuboidShape(1.0, 0.0, 1.0, 15.0, 0.1, 15.0),
createCuboidShape(1.25, 0.0, 1.25, 14.75, 0.3, 14.75),
createCuboidShape(12.0, 0.0, 7.0, 14.0, 15.0, 9.0),
createCuboidShape(13.0, 15.0, 8.0, 14.0, 15.5, 9.0),
createCuboidShape(13.0, 15.0, 7.0, 14.0, 15.5, 8.0),
createCuboidShape(12.0, 15.0, 7.0, 13.0, 15.2, 8.0),
createCuboidShape(12.0, 15.0, 8.0, 13.0, 15.2, 9.0)
).reduce { v1: VoxelShape?, v2: VoxelShape? -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/DirtOxygenatorBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.config.IRConfig
import me.steven.indrev.registry.MachineRegistry
import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings
import net.minecraft.block.BlockState
import net.minecraft.item.ItemPlacementContext
class DirtOxygenatorBlock(registry: MachineRegistry, settings: FabricBlockSettings)
: FacingMachineBlock(registry, settings, Tier.MK1, IRConfig.machines.dirtOxygenator, null) {
override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? {
return this.defaultState.with(FACING, ctx?.playerLookDirection)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/DrillBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.blockentities.miningrig.DrillBlockEntity
import me.steven.indrev.registry.IRBlockRegistry
import net.minecraft.block.Block
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.Blocks
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityTicker
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemPlacementContext
import net.minecraft.item.ItemStack
import net.minecraft.state.StateManager
import net.minecraft.state.property.BooleanProperty
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.ItemScatterer
import net.minecraft.util.StringIdentifiable
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.BlockView
import net.minecraft.world.World
import net.minecraft.world.WorldAccess
import net.minecraft.world.WorldView
open class DrillBlock private constructor(settings: Settings, val part: DrillPart) : Block(settings) {
init {
this.defaultState = stateManager.defaultState.with(WORKING, false)
}
override fun getPlacementState(ctx: ItemPlacementContext): BlockState? {
val middle = ctx.world.getBlockState(ctx.blockPos.up())
val top = ctx.world.getBlockState(ctx.blockPos.up(2))
return if (middle.canReplace(ctx) && top.canReplace(ctx)) defaultState else null
}
override fun onPlaced(
world: World,
pos: BlockPos,
state: BlockState,
placer: LivingEntity?,
itemStack: ItemStack?
) {
world.setBlockState(pos.up(2), DRILL_TOP.defaultState)
world.setBlockState(pos.up(), DRILL_MIDDLE.defaultState)
}
override fun onUse(
state: BlockState,
world: World,
pos: BlockPos,
player: PlayerEntity?,
hand: Hand?,
hit: BlockHitResult?
): ActionResult {
if (!world.isClient) {
val blockEntity = world.getBlockEntity(part.getBlockEntityPos(pos)) as? DrillBlockEntity ?: return ActionResult.PASS
player?.openHandledScreen(blockEntity)
}
return ActionResult.CONSUME
}
override fun getStateForNeighborUpdate(
state: BlockState,
direction: Direction?,
newState: BlockState,
world: WorldAccess,
pos: BlockPos,
posFrom: BlockPos?
): BlockState {
return if (newState.block is DrillBlock) state.with(WORKING, newState[WORKING])
else if (!part.test(world, pos)) Blocks.AIR.defaultState
else state
}
override fun onBreak(world: World, pos: BlockPos, state: BlockState, player: PlayerEntity) {
if (!world.isClient && player.isCreative && part != DrillPart.BOTTOM) {
val bottom = part.getBlockEntityPos(pos)
world.setBlockState(bottom, Blocks.AIR.defaultState)
}
super.onBreak(world, pos, state, player)
}
override fun getPickStack(world: BlockView, pos: BlockPos, state: BlockState): ItemStack = ItemStack(DRILL_BOTTOM)
override fun appendProperties(builder: StateManager.Builder?) {
builder?.add(WORKING)
}
enum class DrillPart(val str: String) : StringIdentifiable {
TOP("top") {
override fun test(world: WorldView, pos: BlockPos): Boolean {
return world.getBlockState(pos.down()).isOf(DRILL_MIDDLE)
&& world.getBlockState(pos.down(2)).isOf(DRILL_BOTTOM)
}
override fun getBlockEntityPos(pos: BlockPos): BlockPos = pos.down(2)
},
MIDDLE("middle") {
override fun test(world: WorldView, pos: BlockPos): Boolean {
return world.getBlockState(pos.up()).isOf(DRILL_TOP)
&& world.getBlockState(pos.down()).isOf(DRILL_BOTTOM)
}
override fun getBlockEntityPos(pos: BlockPos): BlockPos = pos.down()
},
BOTTOM("bottom") {
override fun test(world: WorldView, pos: BlockPos): Boolean {
return world.getBlockState(pos.up()).isOf(DRILL_MIDDLE)
&& world.getBlockState(pos.up(2)).isOf(DRILL_TOP)
}
override fun getBlockEntityPos(pos: BlockPos): BlockPos = pos
};
abstract fun test(world: WorldView, pos: BlockPos): Boolean
abstract fun getBlockEntityPos(pos: BlockPos): BlockPos
override fun asString(): String = str
}
class TopDrillBlock(settings: Settings) : DrillBlock(settings, DrillPart.TOP)
class MiddleDrillBlock(settings: Settings) : DrillBlock(settings, DrillPart.MIDDLE)
class BottomDrillBlock(settings: Settings) : DrillBlock(settings, DrillPart.BOTTOM), BlockEntityProvider {
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = DrillBlockEntity(pos, state)
override fun getTicker(
world: World,
state: BlockState?,
type: BlockEntityType?
): BlockEntityTicker? {
return if (world.isClient) null
else BlockEntityTicker { world, pos, state, blockEntity -> DrillBlockEntity.tick(world, pos, state, blockEntity as DrillBlockEntity) }
}
override fun onStateReplaced(
state: BlockState,
world: World?,
pos: BlockPos?,
newState: BlockState,
moved: Boolean
) {
if (!newState.isOf(this)) {
(world?.getBlockEntity(pos) as? DrillBlockEntity)?.let {
ItemScatterer.spawn(world, pos, it)
}
}
super.onStateReplaced(state, world, pos, newState, moved)
}
}
companion object {
private val DRILL_TOP by lazy { IRBlockRegistry.DRILL_TOP }
private val DRILL_MIDDLE by lazy { IRBlockRegistry.DRILL_MIDDLE }
private val DRILL_BOTTOM by lazy { IRBlockRegistry.DRILL_BOTTOM }
val WORKING: BooleanProperty = BooleanProperty.of("working")
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/DrillHeadModel.kt
================================================
package me.steven.indrev.blocks.machine
import com.mojang.datafixers.util.Pair
import me.steven.indrev.utils.identifier
import net.minecraft.client.render.model.BakedModel
import net.minecraft.client.render.model.ModelBakeSettings
import net.minecraft.client.render.model.ModelLoader
import net.minecraft.client.render.model.UnbakedModel
import net.minecraft.client.texture.Sprite
import net.minecraft.client.util.SpriteIdentifier
import net.minecraft.screen.PlayerScreenHandler
import net.minecraft.util.Identifier
import java.util.function.Function
class DrillHeadModel(val variant: String) : UnbakedModel {
private val spriteIdCollection = mutableListOf(
SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, identifier("item/${variant}_drill_head"))
)
private val modelIdentifier = identifier("block/${variant}_drill_head")
private var bakedModel: BakedModel? = null
override fun bake(
loader: ModelLoader,
textureGetter: Function,
rotationContainer: ModelBakeSettings?,
modelId: Identifier?
): BakedModel? {
bakedModel = loader.getOrLoadModel(modelIdentifier).bake(loader, textureGetter, rotationContainer, modelId)
return bakedModel
}
override fun getModelDependencies(): MutableCollection = mutableListOf()
override fun getTextureDependencies(
unbakedModelGetter: Function?,
unresolvedTextureReferences: MutableSet>?
): MutableCollection {
return spriteIdCollection
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/ElectrolyticSeparatorBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.config.IRConfig
import me.steven.indrev.gui.screenhandlers.machines.ElectrolyticSeparatorScreenHandler
import me.steven.indrev.registry.MachineRegistry
import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings
class ElectrolyticSeparatorBlock(registry: MachineRegistry, settings: FabricBlockSettings, tier: Tier)
: HorizontalFacingMachineBlock(registry, settings, tier,
when (tier) {
Tier.MK1 -> IRConfig.machines.electrolyticSeparatorMk1
Tier.MK2 -> IRConfig.machines.electrolyticSeparatorMk2
Tier.MK3 -> IRConfig.machines.electrolyticSeparatorMk3
else -> IRConfig.machines.electrolyticSeparatorMk4
},
::ElectrolyticSeparatorScreenHandler
) {
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/FacingMachineBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.config.IConfig
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.item.ItemPlacementContext
import net.minecraft.screen.ScreenHandler
import net.minecraft.screen.ScreenHandlerContext
import net.minecraft.state.StateManager
import net.minecraft.state.property.DirectionProperty
import net.minecraft.state.property.Properties
import net.minecraft.util.BlockRotation
import net.minecraft.util.math.Direction
open class FacingMachineBlock(
registry: MachineRegistry,
settings: Settings,
tier: Tier,
config: IConfig?,
screenHandler: ((Int, PlayerInventory, ScreenHandlerContext) -> ScreenHandler)?,
) : MachineBlock(registry, settings, tier, config, screenHandler) {
override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? {
super.getPlacementState(ctx)
return this.defaultState.with(FACING, ctx?.playerLookDirection?.opposite)
}
override fun appendProperties(builder: StateManager.Builder?) {
super.appendProperties(builder)
builder?.add(FACING)
}
override fun rotate(state: BlockState, rotation: BlockRotation): BlockState {
return state.with(FACING, HorizontalFacingMachineBlock.getRotated(state[FACING], rotation))
}
override fun getFacing(state: BlockState): Direction = state[FACING]
companion object {
val FACING: DirectionProperty = Properties.FACING
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/HorizontalFacingMachineBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.config.IConfig
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.item.ItemPlacementContext
import net.minecraft.screen.ScreenHandler
import net.minecraft.screen.ScreenHandlerContext
import net.minecraft.state.StateManager
import net.minecraft.state.property.DirectionProperty
import net.minecraft.state.property.Properties
import net.minecraft.util.BlockRotation
import net.minecraft.util.math.Direction
open class HorizontalFacingMachineBlock(
registry: MachineRegistry,
settings: Settings,
tier: Tier,
config: IConfig?,
screenHandler: ((Int, PlayerInventory, ScreenHandlerContext) -> ScreenHandler)?
) : MachineBlock(registry, settings, tier, config, screenHandler) {
override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? {
super.getPlacementState(ctx)
return this.defaultState.with(HORIZONTAL_FACING, ctx?.playerFacing?.opposite)
}
override fun appendProperties(builder: StateManager.Builder?) {
super.appendProperties(builder)
builder?.add(HORIZONTAL_FACING)
}
override fun rotate(state: BlockState, rotation: BlockRotation): BlockState {
return state.with(HORIZONTAL_FACING, getRotated(state[HORIZONTAL_FACING], rotation))
}
override fun getFacing(state: BlockState): Direction = state[HORIZONTAL_FACING]
companion object {
val HORIZONTAL_FACING: DirectionProperty = Properties.HORIZONTAL_FACING
fun getRotated(direction: Direction, rotation: BlockRotation): Direction =
if (direction.axis.isVertical) direction else when (rotation) {
BlockRotation.NONE -> direction
BlockRotation.CLOCKWISE_90 -> direction.rotateYClockwise()
BlockRotation.CLOCKWISE_180 -> direction.opposite
BlockRotation.COUNTERCLOCKWISE_90 -> direction.rotateYCounterclockwise()
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/LaserBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.IndustrialRevolution
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.config.IRConfig
import me.steven.indrev.gui.screenhandlers.machines.LaserEmitterScreenHandler
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.component1
import me.steven.indrev.utils.component2
import me.steven.indrev.utils.component3
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.entity.damage.DamageSource
import net.minecraft.item.ItemPlacementContext
import net.minecraft.sound.SoundCategory
import net.minecraft.state.StateManager
import net.minecraft.state.property.BooleanProperty
import net.minecraft.state.property.Properties
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
import java.util.*
class LaserBlock(registry: MachineRegistry, settings: Settings) : FacingMachineBlock(
registry, settings, Tier.MK4, IRConfig.machines.laser, ::LaserEmitterScreenHandler
) {
override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? {
return super.getPlacementState(ctx)?.with(POWERED, false)
}
override fun appendProperties(builder: StateManager.Builder?) {
super.appendProperties(builder)
builder?.add(POWERED)
}
@Suppress("DEPRECATION")
override fun neighborUpdate(
state: BlockState?,
world: World?,
pos: BlockPos?,
block: Block?,
fromPos: BlockPos?,
notify: Boolean
) {
super.neighborUpdate(state, world, pos, block, fromPos, notify)
world?.setBlockState(pos, state?.with(POWERED, world.isReceivingRedstonePower(pos)))
}
override fun randomDisplayTick(state: BlockState?, world: World, pos: BlockPos, random: Random?) {
if (state!![POWERED] && random!!.nextDouble() > 0.9) {
val (x, y, z) = pos
world.playSound(x.toDouble() + 0.5, y.toDouble(), z.toDouble() + 0.5,
IndustrialRevolution.LASER_SOUND_EVENT, SoundCategory.BLOCKS, 0.4f, 1f, false
)
}
}
companion object {
val POWERED: BooleanProperty = Properties.POWERED
val LASER_DAMAGE_SOURCE = object : DamageSource("laser") {
init {
setFire()
setBypassesArmor()
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/LazuliFluxContainerBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.blockentities.storage.LazuliFluxContainerBlockEntity
import me.steven.indrev.config.IRConfig
import me.steven.indrev.gui.screenhandlers.machines.LazuliFluxContainerScreenHandler
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.entity.LivingEntity
import net.minecraft.item.ItemStack
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class LazuliFluxContainerBlock(registry: MachineRegistry, settings: Settings, tier: Tier) : FacingMachineBlock(
registry, settings, tier, when (tier) {
Tier.MK1 -> IRConfig.machines.lazuliFluxContainerMk1
Tier.MK2 -> IRConfig.machines.lazuliFluxContainerMk2
Tier.MK3 -> IRConfig.machines.lazuliFluxContainerMk3
else -> IRConfig.machines.lazuliFluxContainerMk4
}, ::LazuliFluxContainerScreenHandler
) {
override fun onPlaced(
world: World?,
pos: BlockPos,
state: BlockState,
placer: LivingEntity?,
itemStack: ItemStack?
) {
super.onPlaced(world, pos, state, placer, itemStack)
if (world?.isClient == true) {
val blockEntity = world.getBlockEntity(pos) as? LazuliFluxContainerBlockEntity ?: return
ConfigurationType.values().forEach { type ->
if (blockEntity.isConfigurable(type))
blockEntity.applyDefault(state, type, blockEntity.getCurrentConfiguration(type))
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/MachineBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.IndustrialRevolution
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.api.machines.TransferMode
import me.steven.indrev.api.sideconfigs.ConfigurationType
import me.steven.indrev.api.sideconfigs.SideConfiguration
import me.steven.indrev.blockentities.MachineBlockEntity
import me.steven.indrev.blockentities.storage.LazuliFluxContainerBlockEntity
import me.steven.indrev.config.IConfig
import me.steven.indrev.gui.IRScreenHandlerFactory
import me.steven.indrev.items.misc.IRMachineUpgradeItem
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.energyOf
import me.steven.indrev.utils.screwdriver
import me.steven.indrev.utils.wrench
import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage
import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil
import net.minecraft.block.Block
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.InventoryProvider
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityTicker
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.entity.player.PlayerInventory
import net.minecraft.inventory.SidedInventory
import net.minecraft.item.BlockItem
import net.minecraft.item.ItemStack
import net.minecraft.particle.ParticleTypes
import net.minecraft.screen.ScreenHandler
import net.minecraft.screen.ScreenHandlerContext
import net.minecraft.server.world.ServerWorld
import net.minecraft.stat.Stats
import net.minecraft.text.TranslatableText
import net.minecraft.util.ActionResult
import net.minecraft.util.BlockRotation
import net.minecraft.util.Hand
import net.minecraft.util.ItemScatterer
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.World
import net.minecraft.world.WorldAccess
import java.util.*
open class MachineBlock(
val registry: MachineRegistry,
settings: Settings,
val tier: Tier,
val config: IConfig?,
private val screenHandler: ((Int, PlayerInventory, ScreenHandlerContext) -> ScreenHandler)?,
) : Block(settings), BlockEntityProvider, InventoryProvider{
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity? = registry.blockEntityType(tier).instantiate(pos, state)
override fun getTicker(
world: World,
state: BlockState?,
type: BlockEntityType?
): BlockEntityTicker? {
return if (world.isClient)
BlockEntityTicker { _, _, _, blockEntity -> (blockEntity as? MachineBlockEntity<*>)?.machineClientTick() }
else
BlockEntityTicker { _, _, _, blockEntity -> (blockEntity as? MachineBlockEntity<*>)?.tick() }
}
override fun onUse(
state: BlockState?,
world: World,
pos: BlockPos?,
player: PlayerEntity?,
hand: Hand?,
hit: BlockHitResult?
): ActionResult? {
if (world.isClient) return ActionResult.CONSUME
val blockEntity = world.getBlockEntity(pos) as? MachineBlockEntity<*> ?: return ActionResult.FAIL
if (blockEntity.fluidComponent != null) {
val result = StorageUtil.move(ContainerItemContext.ofPlayerHand(player, hand).find(FluidStorage.ITEM), blockEntity.fluidComponent, { true }, Long.MAX_VALUE, null)
if (result > 0) return ActionResult.SUCCESS
}
val stack = player?.mainHandStack!!
val item = stack.item
if (item is IRMachineUpgradeItem) {
return ActionResult.PASS
} else if (stack.isIn(IndustrialRevolution.WRENCH_TAG)) {
return wrench(world, pos!!, state!!, blockEntity, player, stack)
} else if (stack.isIn(IndustrialRevolution.SCREWDRIVER_TAG)) {
return screwdriver(world, pos!!, state!!, blockEntity, player, stack)
} else if (blockEntity.multiblockComponent != null
&& !blockEntity.multiblockComponent!!.isBuilt(world, pos!!, blockEntity.cachedState, true)) {
player.sendMessage(TranslatableText("text.multiblock.not_built"), true)
blockEntity.multiblockComponent?.toggleRender(player.isSneaking)
blockEntity.markDirty()
blockEntity.sync()
} else if (screenHandler != null) {
player.openHandledScreen(IRScreenHandlerFactory(screenHandler, pos!!))
} else return ActionResult.PASS
return ActionResult.SUCCESS
}
@Suppress("DEPRECATION")
override fun onStateReplaced(state: BlockState, world: World, pos: BlockPos, newState: BlockState, moved: Boolean) {
val oldBlockEntity = world.getBlockEntity(pos) as? MachineBlockEntity<*>
super.onStateReplaced(state, world, pos, newState, moved)
if (world.isClient) return
if (newState.isOf(this)) {
val oldFacing = getFacing(state)
val newFacing = getFacing(newState)
if (oldFacing == newFacing) return
val blockEntity = world.getBlockEntity(pos) as? MachineBlockEntity<*> ?: return
val rotation = offset(oldFacing, newFacing)
blockEntity.inventoryComponent?.run {
update(EnumMap(itemConfig).clone(), itemConfig, rotation)
}
blockEntity.fluidComponent?.run {
update(EnumMap(transferConfig).clone(), transferConfig, rotation)
}
if (blockEntity is LazuliFluxContainerBlockEntity) {
update(EnumMap(blockEntity.transferConfig).clone(), blockEntity.transferConfig, rotation)
}
blockEntity.markDirty()
} else if (oldBlockEntity?.inventoryComponent != null) {
ItemScatterer.spawn(world, pos, oldBlockEntity.inventoryComponent!!.inventory)
world.updateComparators(pos, this)
}
}
private fun update(original: EnumMap, config: SideConfiguration, rotation: BlockRotation) {
Direction.values().forEach { side ->
config[side] = original[rotation.rotate(side)]!!
}
}
private fun offset(old: Direction, new: Direction): BlockRotation {
return when (old) {
new.rotateYClockwise() -> BlockRotation.CLOCKWISE_90
new.rotateYCounterclockwise() -> BlockRotation.COUNTERCLOCKWISE_90
new.opposite -> BlockRotation.CLOCKWISE_180
else -> BlockRotation.NONE
}
}
override fun afterBreak(world: World?, player: PlayerEntity?, pos: BlockPos?, state: BlockState?, blockEntity: BlockEntity?, toolStack: ItemStack?) {
player?.incrementStat(Stats.MINED.getOrCreateStat(this))
player?.addExhaustion(0.005f)
writeNbtComponents(world, player, pos, state, blockEntity, toolStack)
}
fun writeNbtComponents(world: World?, player: PlayerEntity?, pos: BlockPos?, state: BlockState?, blockEntity: BlockEntity?, toolStack: ItemStack?) {
if (world is ServerWorld) {
getDroppedStacks(state, world, pos, blockEntity, player, toolStack).forEach { stack ->
val item = stack.item
if (blockEntity is MachineBlockEntity<*> && item is BlockItem && item.block is MachineBlock) {
val itemIo = energyOf(stack)
if (itemIo != null) {
stack.orCreateNbt.putLong("energy", blockEntity.energy)
}
val tag = stack.getOrCreateSubNbt("MachineInfo")
val temperatureController = blockEntity.temperatureComponent
if (temperatureController != null)
tag.putDouble("Temperature", temperatureController.temperature)
}
dropStack(world, pos, stack)
}
state!!.onStacksDropped(world, pos, toolStack)
}
}
override fun onPlaced(world: World?, pos: BlockPos, state: BlockState, placer: LivingEntity?, itemStack: ItemStack?) {
super.onPlaced(world, pos, state, placer, itemStack)
if (world?.isClient == true) return
val blockEntity = world?.getBlockEntity(pos)
if (blockEntity is MachineBlockEntity<*>) {
val tag = itemStack?.getSubNbt("MachineInfo")
val temperatureController = blockEntity.temperatureComponent
val itemIo = energyOf(itemStack)
if (itemIo != null) {
blockEntity.energy = itemIo.amount
}
if (temperatureController != null) {
val temperature = tag?.getDouble("Temperature")
if (temperature != null) temperatureController.temperature = temperature
}
ConfigurationType.values().forEach { type ->
if (blockEntity.isConfigurable(type))
blockEntity.applyDefault(state, type, blockEntity.getCurrentConfiguration(type))
}
world.updateNeighbors(pos, this)
blockEntity.markDirty()
}
}
override fun neighborUpdate(
state: BlockState?,
world: World?,
pos: BlockPos?,
block: Block?,
fromPos: BlockPos?,
notify: Boolean
) {
val blockEntity = world?.getBlockEntity(pos) as? MachineBlockEntity<*> ?: return
blockEntity.validConnections.clear()
blockEntity.validConnections.addAll(Direction.values())
}
open fun getFacing(state: BlockState): Direction = Direction.UP
override fun getInventory(state: BlockState?, world: WorldAccess?, pos: BlockPos?): SidedInventory? {
val blockEntity = world?.getBlockEntity(pos) as? InventoryProvider ?: return null
return blockEntity.getInventory(state, world, pos)
}
@Environment(EnvType.CLIENT)
override fun randomDisplayTick(state: BlockState?, world: World, pos: BlockPos, random: Random?) {
val blockEntity = world.getBlockEntity(pos) as? MachineBlockEntity<*> ?: return
if (blockEntity.workingState) {
val d = pos.x.toDouble() + 0.5
val e = pos.y.toDouble() + 1.0
val f = pos.z.toDouble() + 0.5
world.addParticle(ParticleTypes.SMOKE, d, e, f, 0.0, 0.0, 0.0)
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/MiningRigBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.miningrig.MiningRigBlockEntity
import me.steven.indrev.config.IRConfig
import me.steven.indrev.gui.screenhandlers.machines.MiningRigComputerScreenHandler
import me.steven.indrev.registry.MachineRegistry
import me.steven.indrev.utils.itemStorageOf
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.client.item.TooltipContext
import net.minecraft.entity.LivingEntity
import net.minecraft.item.ItemStack
import net.minecraft.server.world.ServerWorld
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.util.Formatting
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.BlockView
import net.minecraft.world.World
class MiningRigBlock(registry: MachineRegistry, settings: Settings, tier: Tier) : HorizontalFacingMachineBlock(
registry,
settings,
tier,
IRConfig.machines.miner,
::MiningRigComputerScreenHandler,
) {
override fun appendTooltip(
stack: ItemStack?,
view: BlockView?,
tooltip: MutableList?,
options: TooltipContext?
) {
super.appendTooltip(stack, view, tooltip, options)
tooltip?.add(
TranslatableText("block.indrev.mining_rig.tooltip").formatted(Formatting.BLUE, Formatting.ITALIC)
)
}
override fun neighborUpdate(
state: BlockState?,
world: World?,
pos: BlockPos?,
block: Block?,
fromPos: BlockPos?,
notify: Boolean
) {
super.neighborUpdate(state, world, pos, block, fromPos, notify)
if (world is ServerWorld) {
val dir = Direction.fromVector(fromPos!!.subtract(pos)) ?: return
if (itemStorageOf(world, fromPos, dir) != null) {
val blockEntity = world.getBlockEntity(pos) as? MiningRigBlockEntity ?: return
blockEntity.storageDirections.addAll(Direction.values())
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/PumpBlock.kt
================================================
package me.steven.indrev.blocks.machine
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.config.IRConfig
import me.steven.indrev.gui.screenhandlers.machines.PumpScreenHandler
import me.steven.indrev.registry.MachineRegistry
import net.minecraft.block.BlockState
import net.minecraft.block.ShapeContext
import net.minecraft.item.ItemPlacementContext
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView
class PumpBlock(registry: MachineRegistry, settings: Settings) : HorizontalFacingMachineBlock(
registry,
settings,
Tier.MK1,
IRConfig.machines.pump,
::PumpScreenHandler) {
override fun getOutlineShape(
state: BlockState?,
world: BlockView?,
pos: BlockPos?,
context: ShapeContext?
): VoxelShape = when (state?.get(HORIZONTAL_FACING)) {
Direction.NORTH -> SHAPE_NORTH
Direction.SOUTH -> SHAPE_SOUTH
Direction.WEST -> SHAPE_WEST
Direction.EAST -> SHAPE_EAST
else -> VoxelShapes.fullCube()
}
override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? {
return this.defaultState.with(HORIZONTAL_FACING, ctx?.playerFacing)
}
companion object {
private val SHAPE_NORTH = createCuboidShape(2.5, 0.0, 0.0, 14.5, 16.0, 14.5)
private val SHAPE_SOUTH = createCuboidShape(2.5, 0.0, 2.5, 14.5, 16.0, 16.0)
private val SHAPE_WEST = createCuboidShape(0.0, 0.0, 2.5, 14.5, 16.0, 14.5)
private val SHAPE_EAST = createCuboidShape(2.5, 0.0, 2.5, 16.0, 16.0, 14.5)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/pipes/BasePipeBlock.kt
================================================
package me.steven.indrev.blocks.machine.pipes
import me.steven.indrev.IndustrialRevolution
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.cables.BasePipeBlockEntity
import me.steven.indrev.items.misc.IRServoItem
import me.steven.indrev.networks.EndpointData
import me.steven.indrev.networks.Network
import me.steven.indrev.networks.ServoNetworkState
import me.steven.indrev.registry.IRItemRegistry
import me.steven.indrev.utils.component1
import me.steven.indrev.utils.component2
import me.steven.indrev.utils.component3
import me.steven.indrev.utils.toVec3d
import net.minecraft.block.Block
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.ShapeContext
import net.minecraft.block.entity.BlockEntity
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.BlockItem
import net.minecraft.item.ItemPlacementContext
import net.minecraft.item.ItemStack
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.ItemScatterer
import net.minecraft.util.collection.DefaultedList
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3d
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView
import net.minecraft.world.World
abstract class BasePipeBlock(settings: Settings, val tier: Tier, val type: Network.Type<*>) : Block(settings), BlockEntityProvider {
init {
this.defaultState = stateManager.defaultState
}
abstract fun getShape(blockEntity: BasePipeBlockEntity): VoxelShape
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity? = BasePipeBlockEntity(type, tier, pos, state)
override fun getOutlineShape(
state: BlockState,
view: BlockView,
pos: BlockPos?,
context: ShapeContext?
): VoxelShape {
val blockEntity = view.getBlockEntity(pos) as? BasePipeBlockEntity ?: return VoxelShapes.empty()
return if (blockEntity.coverState != null) VoxelShapes.fullCube()
else getShape(blockEntity)
}
override fun hasDynamicBounds(): Boolean = true
override fun onBlockBreakStart(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity) {
if (!world.isClient) {
val blockEntity = world.getBlockEntity(pos) as? BasePipeBlockEntity ?: return
if (blockEntity.coverState != null && player.mainHandStack.isOf(IRItemRegistry.WRENCH)) {
val cover = blockEntity.coverState ?: return
ItemScatterer.spawn(world, pos, DefaultedList.ofSize(1, ItemStack(cover.block)))
blockEntity.coverState = null
blockEntity.markDirty()
blockEntity.sync()
}
}
}
override fun onUse(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand, hit: BlockHitResult): ActionResult {
val handStack = player.getStackInHand(hand) ?: return ActionResult.FAIL
val blockEntity = world.getBlockEntity(pos) as? BasePipeBlockEntity ?: return ActionResult.FAIL
val tryWrench = onWrench(state, world, pos, player, hand, hit)
if (tryWrench.isAccepted) return tryWrench
else if (handStack.item is IRServoItem) return ActionResult.PASS
val item = handStack.item
if (
blockEntity.coverState == null
&& !player.isSneaking
&& isValidCover(handStack, world, pos)
) {
val result = (item as BlockItem).block.getPlacementState(ItemPlacementContext(player, hand, handStack, hit))
blockEntity.coverState = result
if (!world.isClient) {
blockEntity.markDirty()
blockEntity.sync()
}
if (!player.abilities.creativeMode)
handStack.decrement(1)
return ActionResult.success(world.isClient)
}
return ActionResult.PASS
}
private fun isValidCover(stack: ItemStack, world: World, pos: BlockPos): Boolean {
val item = stack.item
return !stack.isEmpty
&& item is BlockItem
&& item.block !is BlockEntityProvider
&& item.block.defaultState.isFullCube(world, pos)
}
private fun onWrench(state: BlockState,world: World, pos: BlockPos,player: PlayerEntity, hand: Hand, hit: BlockHitResult): ActionResult {
val handStack = player.getStackInHand(hand) ?: return ActionResult.FAIL
val blockEntity = world.getBlockEntity(pos) as? BasePipeBlockEntity ?: return ActionResult.FAIL
if (handStack.isIn(IndustrialRevolution.WRENCH_TAG) && world is ServerWorld) {
val dir = getSideFromHit(hit.pos, pos)
val (x, y, z) = hit.pos
val networkState = type.getNetworkState(world)
if (networkState is ServoNetworkState<*>) {
if (dir != null) {
val data = networkState.removeEndpointData(pos, dir)
when (data?.type) {
EndpointData.Type.OUTPUT -> {
ItemScatterer.spawn(world, x, y, z, ItemStack(IRItemRegistry.SERVO_OUTPUT))
return ActionResult.SUCCESS
}
EndpointData.Type.RETRIEVER -> {
ItemScatterer.spawn(world, x, y, z, ItemStack(IRItemRegistry.SERVO_RETRIEVER))
return ActionResult.SUCCESS
}
else -> { }
}
}
}
if (blockEntity.connections[dir]!!.isConnected())
blockEntity.connections[dir] = ConnectionType.WRENCHED
else
blockEntity.connections[hit.side] =
if (isConnectable(world, pos, hit.side)) ConnectionType.CONNECTED else ConnectionType.NONE
blockEntity.markDirty()
blockEntity.sync()
world.updateNeighbors(pos, state.block)
Network.handleUpdate(networkState, pos)
return ActionResult.success(world.isClient)
}
return ActionResult.PASS
}
@Suppress("DEPRECATION")
override fun onStateReplaced(
blockState: BlockState,
world: World,
pos: BlockPos,
newState: BlockState,
moved: Boolean
) {
super.onStateReplaced(blockState, world, pos, newState, moved)
if (!world.isClient) {
val networkState = type.getNetworkState(world as ServerWorld)
if (networkState is ServoNetworkState<*>) {
if (blockState.isOf(newState.block)) {
Network.handleUpdate(networkState, pos)
} else {
Direction.values().forEach { dir ->
val data = networkState.removeEndpointData(pos, dir)
val (x, y, z) = pos.toVec3d()
when (data?.type) {
EndpointData.Type.OUTPUT ->
ItemScatterer.spawn(world, x, y, z, ItemStack(IRItemRegistry.SERVO_OUTPUT))
EndpointData.Type.RETRIEVER ->
ItemScatterer.spawn(world, x, y, z, ItemStack(IRItemRegistry.SERVO_RETRIEVER))
else -> {
}
}
}
}
}
Network.handleBreak(networkState, pos)
}
}
abstract fun isConnectable(world: ServerWorld, pos: BlockPos, dir: Direction): Boolean
override fun onPlaced(
world: World,
pos: BlockPos,
state: BlockState,
placer: LivingEntity?,
itemStack: ItemStack?
) {
super.onPlaced(world, pos, state, placer, itemStack)
if (!world.isClient) {
DIRECTIONS.forEach { facing ->
updateConnection(world as ServerWorld, pos, pos.offset(facing), facing)
}
val networkState = type.getNetworkState(world as ServerWorld)
Network.handleUpdate(networkState, pos)
}
}
override fun neighborUpdate(
state: BlockState,
world: World?,
pos: BlockPos,
block: Block?,
fromPos: BlockPos,
notify: Boolean
) {
val (x, y, z) = pos.subtract(fromPos)
val facing = Direction.fromVector(x, y, z)?.opposite ?: return
if (world is ServerWorld) {
updateConnection(world, pos, fromPos, facing)
}
}
private fun updateConnection(world: ServerWorld, pos: BlockPos, neighborPos: BlockPos, facing: Direction) {
val networkState = type.getNetworkState(world)
val blockEntity = world.getBlockEntity(pos) as? BasePipeBlockEntity ?: return
val before = blockEntity.connections[facing]
val new = ConnectionType.getType(isConnectable(world, neighborPos, facing))
val neighborBlockEntity = world.getBlockEntity(neighborPos) as? BasePipeBlockEntity
if (before != new && before?.isConnectable() != false && new.isConnectable()) {
neighborBlockEntity?.connections?.put(facing.opposite, new)
neighborBlockEntity?.markDirty()
neighborBlockEntity?.sync()
blockEntity.connections[facing] = new
blockEntity.markDirty()
blockEntity.sync()
Network.handleUpdate(networkState, pos)
}
}
enum class ConnectionType(val id: Int) {
NONE(-1), CONNECTED(0), WRENCHED(1);
fun isConnected() = this == CONNECTED
fun isConnectable() = this != WRENCHED
companion object {
fun getType(connects: Boolean) = if (connects) CONNECTED else NONE
fun byId(id: Int): ConnectionType {
return when (id) {
0 -> CONNECTED
1 -> WRENCHED
else -> NONE
}
}
}
}
companion object {
fun getSideFromHit(hit: Vec3d, pos: BlockPos): Direction? {
val x = hit.x - pos.x
val y = hit.y - pos.y
val z = hit.z - pos.z
return when {
y > 0.6625 -> Direction.UP
y < 0.3375 -> Direction.DOWN
x > 0.6793 -> Direction.EAST
x < 0.3169 -> Direction.WEST
z < 0.3169 -> Direction.NORTH
z > 0.6625 -> Direction.SOUTH
else -> null
}
}
val DIRECTIONS = Direction.values()
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/pipes/CableBlock.kt
================================================
package me.steven.indrev.blocks.machine.pipes
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.cables.BasePipeBlockEntity
import me.steven.indrev.config.IRConfig
import me.steven.indrev.networks.Network
import me.steven.indrev.networks.energy.CableEnergyIo
import me.steven.indrev.utils.energyOf
import me.steven.indrev.utils.pack
import net.minecraft.client.item.TooltipContext
import net.minecraft.item.ItemStack
import net.minecraft.server.world.ServerWorld
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.util.Formatting
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView
import java.util.function.IntFunction
class CableBlock(settings: Settings, tier: Tier) : BasePipeBlock(settings, tier, Network.Type.ENERGY) {
override fun appendTooltip(
stack: ItemStack?,
world: BlockView?,
tooltip: MutableList?,
options: TooltipContext?
) {
tooltip?.add(
TranslatableText("gui.indrev.tooltip.maxTransferRate").formatted(Formatting.AQUA)
.append(TranslatableText("gui.indrev.tooltip.lftick", getMaxTransferRate()).formatted(Formatting.GRAY))
)
}
override fun isConnectable(world: ServerWorld, pos: BlockPos, dir: Direction): Boolean {
val handler = energyOf(world, pos, dir.opposite)
if (handler != null && handler !is CableEnergyIo) return true
val blockEntity = world.getBlockEntity(pos) as? BasePipeBlockEntity ?: return false
if (!blockEntity.cachedState.isOf(this)) return false
return blockEntity.connections[dir.opposite]!!.isConnectable()
}
private fun getMaxTransferRate() = when(tier) {
Tier.MK1 -> IRConfig.cables.cableMk1
Tier.MK2 -> IRConfig.cables.cableMk2
Tier.MK3 -> IRConfig.cables.cableMk3
else -> IRConfig.cables.cableMk4
}
override fun getShape(blockEntity: BasePipeBlockEntity): VoxelShape {
val directions = DIRECTIONS.filter { dir -> blockEntity.connections[dir] == ConnectionType.CONNECTED }
return SHAPE_CACHE.get().computeIfAbsent(pack(directions).toInt(), IntFunction {
var shape = CENTER_SHAPE
directions.forEach { direction ->
shape = VoxelShapes.union(shape, getShape(direction))
}
shape
})
}
companion object {
val SHAPE_CACHE: ThreadLocal> = ThreadLocal.withInitial {
object : Int2ObjectOpenHashMap(64, 0.25f) {
override fun rehash(newN: Int) {
}
}
}
val DOWN_SHAPE: VoxelShape = createCuboidShape(6.0, 0.0, 6.0, 10.0, 6.0, 10.0)
val UP_SHAPE: VoxelShape = createCuboidShape(6.0, 10.5, 6.0, 10.0, 16.0, 10.0)
val SOUTH_SHAPE: VoxelShape = createCuboidShape(6.0, 6.0, 10.5, 10.0, 10.0, 16.0)
val NORTH_SHAPE: VoxelShape = createCuboidShape(6.0, 6.0, 0.0, 10.0, 10.0, 5.5)
val EAST_SHAPE: VoxelShape = createCuboidShape(10.5, 6.0, 6.0, 16.0, 10.0, 10.0)
val WEST_SHAPE: VoxelShape = createCuboidShape(0.0, 6.0, 6.0, 5.5, 10.0, 10.0)
val CENTER_SHAPE: VoxelShape = createCuboidShape(5.5, 5.5, 5.5, 10.5, 10.5, 10.5)
private fun getShape(direction: Direction): VoxelShape {
var shape = VoxelShapes.empty()
if (direction == Direction.NORTH) shape = NORTH_SHAPE
if (direction == Direction.SOUTH) shape = SOUTH_SHAPE
if (direction == Direction.EAST) shape = EAST_SHAPE
if (direction == Direction.WEST) shape = WEST_SHAPE
if (direction == Direction.UP) shape = UP_SHAPE
if (direction == Direction.DOWN) shape = DOWN_SHAPE
return shape
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/pipes/FluidPipeBlock.kt
================================================
package me.steven.indrev.blocks.machine.pipes
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.cables.BasePipeBlockEntity
import me.steven.indrev.config.IRConfig
import me.steven.indrev.networks.Network
import me.steven.indrev.networks.ServoNetworkState
import me.steven.indrev.utils.fluidStorageOf
import me.steven.indrev.utils.pack
import net.minecraft.client.item.TooltipContext
import net.minecraft.item.ItemStack
import net.minecraft.server.world.ServerWorld
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.util.Formatting
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView
import java.util.function.IntFunction
class FluidPipeBlock(settings: Settings, tier: Tier) : BasePipeBlock(settings, tier, Network.Type.FLUID) {
override fun appendTooltip(
stack: ItemStack?,
world: BlockView?,
tooltip: MutableList?,
options: TooltipContext?
) {
tooltip?.add(
TranslatableText("gui.indrev.tooltip.maxTransferRate").formatted(Formatting.AQUA)
.append(TranslatableText("gui.indrev.tooltip.fluidsec", getMaxTransferRate()).formatted(Formatting.GRAY))
)
}
override fun isConnectable(world: ServerWorld, pos: BlockPos, dir: Direction): Boolean {
if (fluidStorageOf(world, pos, dir.opposite) != null) return true
if ((type.getNetworkState(world) as ServoNetworkState<*>).hasServo(pos.offset(dir.opposite), dir))
return true
val blockEntity = world.getBlockEntity(pos) as? BasePipeBlockEntity ?: return false
if (!blockEntity.cachedState.isOf(this)) return false
return blockEntity.connections[dir.opposite]!!.isConnectable()
}
private fun getMaxTransferRate() = when(tier) {
Tier.MK1 -> IRConfig.cables.fluidPipeMk1
Tier.MK2 -> IRConfig.cables.fluidPipeMk2
Tier.MK3 -> IRConfig.cables.fluidPipeMk3
else -> IRConfig.cables.fluidPipeMk4
}
override fun getShape(blockEntity: BasePipeBlockEntity): VoxelShape {
val directions = DIRECTIONS.filter { dir -> blockEntity.connections[dir] == ConnectionType.CONNECTED }
return SHAPE_CACHE.get().computeIfAbsent(pack(directions).toInt(), IntFunction {
var shape = CENTER_SHAPE
directions.forEach { direction ->
shape = VoxelShapes.union(shape, getShape(direction))
}
shape
})
}
companion object {
val SHAPE_CACHE: ThreadLocal> = ThreadLocal.withInitial {
object : Int2ObjectOpenHashMap(64, 0.25f) {
override fun rehash(newN: Int) {
}
}
}
val DOWN_SHAPE: VoxelShape = createCuboidShape(6.0, 0.0, 6.0, 10.0, 6.0, 10.0)
val UP_SHAPE: VoxelShape = createCuboidShape(6.0, 10.0, 6.0, 10.0, 16.0, 10.0)
val SOUTH_SHAPE: VoxelShape = createCuboidShape(6.0, 6.0, 10.5, 10.0, 10.0, 16.0)
val NORTH_SHAPE: VoxelShape = createCuboidShape(6.0, 6.0, 0.0, 10.0, 10.0, 6.0)
val EAST_SHAPE: VoxelShape = createCuboidShape(10.0, 6.0, 6.0, 16.0, 10.0, 10.0)
val WEST_SHAPE: VoxelShape = createCuboidShape(0.0, 6.0, 6.0, 6.0, 10.0, 10.0)
val CENTER_SHAPE: VoxelShape = createCuboidShape(6.0, 6.0, 6.0, 10.0, 10.0, 10.0)
private fun getShape(direction: Direction): VoxelShape {
var shape = VoxelShapes.empty()
if (direction == Direction.NORTH) shape = NORTH_SHAPE
if (direction == Direction.SOUTH) shape = SOUTH_SHAPE
if (direction == Direction.EAST) shape = EAST_SHAPE
if (direction == Direction.WEST) shape = WEST_SHAPE
if (direction == Direction.UP) shape = UP_SHAPE
if (direction == Direction.DOWN) shape = DOWN_SHAPE
return shape
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/pipes/ItemPipeBlock.kt
================================================
package me.steven.indrev.blocks.machine.pipes
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blockentities.cables.BasePipeBlockEntity
import me.steven.indrev.config.IRConfig
import me.steven.indrev.gui.screenhandlers.pipes.PipeFilterScreenFactory
import me.steven.indrev.gui.screenhandlers.pipes.PipeFilterScreenHandler
import me.steven.indrev.networks.Network
import me.steven.indrev.networks.ServoNetworkState
import me.steven.indrev.utils.itemStorageOf
import me.steven.indrev.utils.pack
import net.minecraft.block.BlockState
import net.minecraft.client.item.TooltipContext
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemStack
import net.minecraft.server.world.ServerWorld
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.util.ActionResult
import net.minecraft.util.Formatting
import net.minecraft.util.Hand
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView
import net.minecraft.world.World
import java.util.function.IntFunction
class ItemPipeBlock(settings: Settings, tier: Tier) : BasePipeBlock(settings, tier, Network.Type.ITEM) {
override fun appendTooltip(
stack: ItemStack?,
world: BlockView?,
tooltip: MutableList?,
options: TooltipContext?
) {
tooltip?.add(
TranslatableText("gui.indrev.tooltip.maxTransferRate").formatted(Formatting.AQUA)
.append(TranslatableText("gui.indrev.tooltip.itemsec", getMaxTransferRate()).formatted(Formatting.GRAY))
)
}
override fun onUse(
state: BlockState,
world: World,
pos: BlockPos,
player: PlayerEntity,
hand: Hand,
hit: BlockHitResult
): ActionResult {
val dir = getSideFromHit(hit.pos, pos)
val blockEntity = world.getBlockEntity(pos) as? BasePipeBlockEntity ?: return ActionResult.PASS
if (hand == Hand.MAIN_HAND && !world.isClient && player.getStackInHand(hand).isEmpty && dir != null && blockEntity.connections[dir]!!.isConnected()) {
val type = Network.Type.ITEM
val networkState = type.getNetworkState(world as ServerWorld)
if (networkState.networksByPos.get(pos.asLong())?.containers?.containsKey(pos.offset(dir)) == true) {
player.openHandledScreen(PipeFilterScreenFactory(::PipeFilterScreenHandler, pos, dir))
return ActionResult.SUCCESS
}
}
return super.onUse(state, world, pos, player, hand, hit)
}
override fun isConnectable(world: ServerWorld, pos: BlockPos, dir: Direction): Boolean {
if (itemStorageOf(world, pos, dir.opposite) != null) return true
if ((type.getNetworkState(world) as ServoNetworkState<*>).hasServo(pos.offset(dir.opposite), dir))
return true
val blockEntity = world.getBlockEntity(pos) as? BasePipeBlockEntity ?: return false
if (!blockEntity.cachedState.isOf(this)) return false
return blockEntity.connections[dir.opposite]!!.isConnectable()
}
private fun getMaxTransferRate() = when(tier) {
Tier.MK1 -> IRConfig.cables.itemPipeMk1
Tier.MK2 -> IRConfig.cables.itemPipeMk2
Tier.MK3 -> IRConfig.cables.itemPipeMk3
else -> IRConfig.cables.itemPipeMk4
}
override fun getShape(blockEntity: BasePipeBlockEntity): VoxelShape {
val directions = DIRECTIONS.filter { dir -> blockEntity.connections[dir] == ConnectionType.CONNECTED }
return SHAPE_CACHE.get().computeIfAbsent(pack(directions).toInt(), IntFunction {
var shape = CENTER_SHAPE
directions.forEach { direction ->
shape = VoxelShapes.union(shape, getShape(direction))
}
shape
})
}
companion object {
val SHAPE_CACHE: ThreadLocal> = ThreadLocal.withInitial {
object : Int2ObjectOpenHashMap(64, 0.25f) {
override fun rehash(newN: Int) {
}
}
}
val DOWN_SHAPE: VoxelShape = createCuboidShape(6.5, 0.0, 6.5, 9.5, 6.5, 9.5)
val UP_SHAPE: VoxelShape = createCuboidShape(6.5, 9.5, 6.5, 9.5, 16.0, 9.5)
val SOUTH_SHAPE: VoxelShape = createCuboidShape(6.5, 6.5, 9.5, 9.5, 9.5, 16.0)
val NORTH_SHAPE: VoxelShape = createCuboidShape(6.5, 6.5, 0.0, 9.5, 9.5, 6.5)
val EAST_SHAPE: VoxelShape = createCuboidShape(9.5, 6.5, 6.5, 16.0, 9.5, 9.5)
val WEST_SHAPE: VoxelShape = createCuboidShape(0.0, 6.5, 6.5, 6.5, 9.5, 9.5)
val CENTER_SHAPE: VoxelShape = createCuboidShape(6.5, 6.5, 6.5, 9.5, 9.5, 9.5)
private fun getShape(direction: Direction): VoxelShape {
var shape = VoxelShapes.empty()
if (direction == Direction.NORTH) shape = NORTH_SHAPE
if (direction == Direction.SOUTH) shape = SOUTH_SHAPE
if (direction == Direction.EAST) shape = EAST_SHAPE
if (direction == Direction.WEST) shape = WEST_SHAPE
if (direction == Direction.UP) shape = UP_SHAPE
if (direction == Direction.DOWN) shape = DOWN_SHAPE
return shape
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/solarpowerplant/FluidValveBlock.kt
================================================
package me.steven.indrev.blocks.machine.solarpowerplant
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.block.FacingBlock
import net.minecraft.item.ItemPlacementContext
import net.minecraft.state.StateManager
import net.minecraft.util.BlockMirror
import net.minecraft.util.BlockRotation
import net.minecraft.util.math.Direction
open class FluidValveBlock(settings: Settings) : FacingBlock(settings) {
init {
this.defaultState = stateManager.defaultState.with(FACING, Direction.NORTH)
}
override fun appendProperties(builder: StateManager.Builder?) {
builder?.add(FACING)
}
override fun rotate(state: BlockState, rotation: BlockRotation): BlockState? {
return state.with(FACING, rotation.rotate(state[FACING]))
}
override fun mirror(state: BlockState, mirror: BlockMirror): BlockState? {
return state.rotate(mirror.getRotation(state[FACING]))
}
override fun getPlacementState(ctx: ItemPlacementContext): BlockState? {
return defaultState.with(FACING, ctx.playerLookDirection.opposite)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/solarpowerplant/SolarPowerPlantFluidOutputBlock.kt
================================================
package me.steven.indrev.blocks.machine.solarpowerplant
import me.steven.indrev.blocks.misc.HorizontalFacingBlock
class SolarPowerPlantFluidOutputBlock(settings: Settings) : HorizontalFacingBlock(settings)
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/solarpowerplant/SolarPowerPlantTowerBlock.kt
================================================
package me.steven.indrev.blocks.machine.solarpowerplant
import me.steven.indrev.IndustrialRevolution
import me.steven.indrev.blockentities.solarpowerplant.HeliostatBlockEntity
import me.steven.indrev.blockentities.solarpowerplant.SolarPowerPlantTowerBlockEntity
import me.steven.indrev.blocks.misc.HorizontalFacingBlock
import me.steven.indrev.components.multiblock.definitions.SolarPowerPlantTowerStructureDefinition
import me.steven.indrev.gui.IRScreenHandlerFactory
import me.steven.indrev.gui.screenhandlers.machines.SolarPowerPlantTowerScreenHandler
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityTicker
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.nbt.NbtLong
import net.minecraft.text.LiteralText
import net.minecraft.text.TranslatableText
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class SolarPowerPlantTowerBlock(settings: Settings) : HorizontalFacingBlock(settings), BlockEntityProvider {
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = SolarPowerPlantTowerBlockEntity(pos, state)
override fun getTicker(
world: World,
state: BlockState?,
type: BlockEntityType?
): BlockEntityTicker? {
return if (world.isClient) null
else return BlockEntityTicker { world, pos, state, blockEntity -> SolarPowerPlantTowerBlockEntity.tick(world, pos, state, blockEntity as? SolarPowerPlantTowerBlockEntity ?: return@BlockEntityTicker) }
}
override fun onUse(
state: BlockState,
world: World,
pos: BlockPos,
player: PlayerEntity,
hand: Hand,
hit: BlockHitResult?
): ActionResult {
if (!world.isClient) {
val stack = player.getStackInHand(hand)
if (stack.isIn(IndustrialRevolution.SCREWDRIVER_TAG) && stack.orCreateNbt.contains("SelectedHeliostats")) {
val positions = stack.nbt!!.getList("SelectedHeliostats", 4)?.map { BlockPos.fromLong((it as NbtLong).longValue()) }
val receivers = SolarPowerPlantTowerStructureDefinition.getSolarReceiverPositions(pos, state)
positions?.forEach { p ->
val heliostat = world.getBlockEntity(p) as HeliostatBlockEntity
val target = receivers.minByOrNull { it.getManhattanDistance(p) } ?: return@forEach
heliostat.targetBlock = target
heliostat.markDirty()
heliostat.sync()
}
player.sendMessage(LiteralText("Linked Heliostats!"), true)
} else {
val blockEntity = world.getBlockEntity(pos) as? SolarPowerPlantTowerBlockEntity ?: return ActionResult.PASS
if (!blockEntity.multiblockComponent.isBuilt(world, pos, state)) {
player.sendMessage(TranslatableText("text.multiblock.not_built"), true)
blockEntity.multiblockComponent.toggleRender(player.isSneaking)
blockEntity.markDirty()
blockEntity.sync()
} else
player.openHandledScreen(IRScreenHandlerFactory(::SolarPowerPlantTowerScreenHandler, pos))
}
}
return ActionResult.success(world.isClient)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/solarpowerplant/SolarReceiverBlock.kt
================================================
package me.steven.indrev.blocks.machine.solarpowerplant
import me.steven.indrev.blockentities.solarpowerplant.SolarReceiverBlockEntity
import net.minecraft.block.Block
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.util.math.BlockPos
class SolarReceiverBlock(settings: Settings) : Block(settings), BlockEntityProvider {
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = SolarReceiverBlockEntity(pos, state)
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/solarpowerplant/SteamTurbineBlock.kt
================================================
package me.steven.indrev.blocks.machine.solarpowerplant
import me.steven.indrev.api.machines.Tier
import me.steven.indrev.blocks.machine.HorizontalFacingMachineBlock
import me.steven.indrev.config.IRConfig
import me.steven.indrev.gui.screenhandlers.machines.SteamTurbineScreenHandler
import me.steven.indrev.registry.MachineRegistry
class SteamTurbineBlock(registry: MachineRegistry, settings: Settings)
: HorizontalFacingMachineBlock(registry, settings, Tier.MK4, IRConfig.generators.steamTurbine, ::SteamTurbineScreenHandler)
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/machine/solarpowerplant/SteamTurbineSteamInputValveBlock.kt
================================================
package me.steven.indrev.blocks.machine.solarpowerplant
import me.steven.indrev.blockentities.generators.SteamTurbineSteamInputValveBlockEntity
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityTicker
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class SteamTurbineSteamInputValveBlock(settings: Settings) : FluidValveBlock(settings), BlockEntityProvider {
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = SteamTurbineSteamInputValveBlockEntity(pos, state)
override fun getTicker(
world: World,
state: BlockState?,
type: BlockEntityType?
): BlockEntityTicker? {
return if (world.isClient) null
else BlockEntityTicker { _, _, _, blockEntity ->
(blockEntity as? SteamTurbineSteamInputValveBlockEntity)?.inserted = false
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/AcidFluidBlock.kt
================================================
package me.steven.indrev.blocks.misc
import net.minecraft.block.BlockState
import net.minecraft.block.Blocks
import net.minecraft.block.FluidBlock
import net.minecraft.entity.Entity
import net.minecraft.entity.damage.DamageSource
import net.minecraft.fluid.FlowableFluid
import net.minecraft.particle.ParticleTypes
import net.minecraft.server.world.ServerWorld
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.world.World
import java.util.*
class AcidFluidBlock(fluid: FlowableFluid, settings: Settings) : FluidBlock(fluid, settings) {
override fun randomTick(state: BlockState?, world: ServerWorld?, pos: BlockPos?, random: Random?) {
Direction.values().forEach { dir ->
val neighbor = pos?.offset(dir)
val blockState = world?.getBlockState(neighbor)
val block = blockState?.block
if (block == Blocks.DIRT || block == Blocks.GRASS_BLOCK || block == Blocks.FARMLAND || block == Blocks.DIRT_PATH)
world?.setBlockState(pos, Blocks.COARSE_DIRT.defaultState)
}
}
override fun randomDisplayTick(state: BlockState?, world: World, pos: BlockPos, random: Random) {
if (!world.isAir(pos.up()) || random.nextInt(10) < 5) return
(0..1).forEach { a ->
(0..1).forEach { b ->
world.addParticle(
ParticleTypes.SNEEZE, pos.x + a / 2.0 + (random.nextFloat() / 5), pos.y + 1.0, pos.z + b / 2.0 + (random.nextFloat() / 5), 0.0, 0.005, 0.0)
}
}
}
override fun onEntityCollision(state: BlockState?, world: World, pos: BlockPos?, entity: Entity?) {
if (world.time % 15 == 0L)
entity?.damage(ACID_DAMAGE_SOURCE, 4f)
}
companion object {
val ACID_DAMAGE_SOURCE = object : DamageSource("acid") {
init {
setBypassesArmor()
setUnblockable()
}
}
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/BiomassComposterBlock.kt
================================================
package me.steven.indrev.blocks.misc
import me.steven.indrev.blockentities.farms.BiomassComposterBlockEntity
import me.steven.indrev.registry.IRBlockRegistry
import me.steven.indrev.registry.IRItemRegistry
import me.steven.indrev.utils.bucket
import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant
import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil
import net.minecraft.block.*
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityTicker
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemStack
import net.minecraft.state.StateManager
import net.minecraft.state.property.BooleanProperty
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class BiomassComposterBlock : Block(FabricBlockSettings.copyOf(Blocks.COMPOSTER)), BlockEntityProvider {
init {
this.defaultState = stateManager.defaultState.with(CLOSED, false)
}
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = BiomassComposterBlockEntity(pos, state)
override fun getTicker(
world: World,
state: BlockState,
type: BlockEntityType
): BlockEntityTicker? {
return if (world.isClient) null
else BlockEntityTicker { _, _, state, blockEntity ->
BiomassComposterBlockEntity.tick(
state, blockEntity as? BiomassComposterBlockEntity ?: return@BlockEntityTicker
)
}
}
override fun appendProperties(builder: StateManager.Builder?) {
builder?.add(CLOSED)
}
override fun onUse(
state: BlockState,
world: World,
pos: BlockPos,
player: PlayerEntity,
hand: Hand,
hit: BlockHitResult?
): ActionResult {
val stack = player.getStackInHand(hand)
val blockEntity = world.getBlockEntity(pos) as? BiomassComposterBlockEntity ?: return ActionResult.PASS
val inHand = ContainerItemContext.ofPlayerHand(player, hand).find(FluidStorage.ITEM)
val result = StorageUtil.move(inHand, blockEntity.fluidInv, { true }, bucket, null)
if (result > 0) {
blockEntity.markDirty()
if (!world.isClient)
blockEntity.sync()
return ActionResult.success(world.isClient)
} else if (ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.contains(stack.item) || stack.isEmpty) {
compost(stack, player, blockEntity, world)
} else if (state[CLOSED]) {
world.setBlockState(pos, state.with(CLOSED, false))
if (!player.isCreative)
player.inventory.offerOrDrop(ItemStack(IRBlockRegistry.PLANKS))
} else if (stack.isOf(IRBlockRegistry.PLANKS.asItem())) {
world.setBlockState(pos, state.with(CLOSED, true))
if (!player.isCreative)
stack.decrement(1)
} else return ActionResult.FAIL
return ActionResult.success(world.isClient)
}
private fun compost(stack: ItemStack, player: PlayerEntity, blockEntity: BiomassComposterBlockEntity, world: World) {
if (world.isClient) return
if (blockEntity.itemInv.variant.isOf(IRItemRegistry.BIOMASS)) {
player.inventory.offerOrDrop(ItemStack(IRItemRegistry.BIOMASS))
blockEntity.itemInv.variant = ItemVariant.blank()
blockEntity.itemInv.amount = 0
blockEntity.markDirty()
blockEntity.sync()
} else if (blockEntity.level < 7 && !stack.isEmpty) {
val chance = ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.getValue(stack.item)
if (!player.isCreative)
stack.decrement(1)
var leveledUp = false
if (world.random.nextInt() < chance) {
blockEntity.level++
blockEntity.markDirty()
blockEntity.sync()
leveledUp = true
}
world.syncWorldEvent(1500, blockEntity.pos, if (leveledUp) 1 else 0)
}
}
companion object {
val CLOSED: BooleanProperty = BooleanProperty.of("closed")
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/CabinetBlock.kt
================================================
package me.steven.indrev.blocks.misc
import me.steven.indrev.blockentities.storage.CabinetBlockEntity
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.entity.BlockEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
class CabinetBlock(settings: Settings) : HorizontalFacingBlock(settings), BlockEntityProvider {
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = CabinetBlockEntity(pos, state)
override fun onUse(
state: BlockState?,
world: World,
pos: BlockPos?,
player: PlayerEntity,
hand: Hand?,
hit: BlockHitResult?
): ActionResult {
if (!world.isClient) {
val blockEntity = world.getBlockEntity(pos) as? CabinetBlockEntity ?: return ActionResult.PASS
player.openHandledScreen(blockEntity)
}
return ActionResult.success(world.isClient)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/DuctBlock.kt
================================================
package me.steven.indrev.blocks.misc
import net.minecraft.block.BlockState
import net.minecraft.block.ShapeContext
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape
import net.minecraft.world.BlockView
class DuctBlock(settings: Settings) : HorizontalFacingBlock(settings) {
override fun getOutlineShape(
state: BlockState,
world: BlockView?,
pos: BlockPos?,
context: ShapeContext?
): VoxelShape = when (state[FACING]) {
Direction.NORTH -> FACING_NORTH
Direction.SOUTH -> FACING_SOUTH
Direction.WEST -> FACING_WEST
Direction.EAST -> FACING_EAST
else -> FACING_NORTH
}
companion object {
private val FACING_SOUTH: VoxelShape = createCuboidShape(2.0, 0.0, 0.0, 14.0, 14.0, 14.0)
private val FACING_NORTH: VoxelShape = createCuboidShape(2.0, 0.0, 2.0, 14.0, 14.0, 16.0)
private val FACING_EAST: VoxelShape = createCuboidShape(0.0, 0.0, 2.0, 14.0, 14.0, 14.0)
private val FACING_WEST: VoxelShape = createCuboidShape(2.0, 0.0, 2.0, 16.0, 14.0, 14.0)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/HorizontalFacingBlock.kt
================================================
package me.steven.indrev.blocks.misc
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.block.HorizontalFacingBlock
import net.minecraft.item.ItemPlacementContext
import net.minecraft.state.StateManager
import net.minecraft.util.math.Direction
open class HorizontalFacingBlock(settings: Settings) : HorizontalFacingBlock(settings) {
init {
this.defaultState = stateManager.defaultState.with(FACING, Direction.NORTH)
}
override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? {
return defaultState.with(FACING, ctx?.playerFacing?.opposite)
}
override fun appendProperties(builder: StateManager.Builder?) {
builder?.add(FACING)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/NikoliteOreBlock.kt
================================================
package me.steven.indrev.blocks.misc
import net.minecraft.block.OreBlock
import net.minecraft.util.math.intprovider.UniformIntProvider
class NikoliteOreBlock(settings: Settings) : OreBlock(settings, UniformIntProvider.create(1, 6))
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/PlankBlock.kt
================================================
package me.steven.indrev.blocks.misc
import net.minecraft.block.BlockState
import net.minecraft.block.ShapeContext
import net.minecraft.block.SnowBlock
import net.minecraft.util.math.BlockPos
import net.minecraft.util.shape.VoxelShape
import net.minecraft.world.BlockView
import net.minecraft.world.WorldView
class PlankBlock(settings: Settings) : SnowBlock(settings) {
override fun canPlaceAt(state: BlockState, world: WorldView?, pos: BlockPos): Boolean = true
override fun getCollisionShape(
state: BlockState,
world: BlockView?,
pos: BlockPos?,
context: ShapeContext?
): VoxelShape = LAYERS_TO_SHAPE[state.get(LAYERS)]
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/SulfurCrystalBlock.kt
================================================
package me.steven.indrev.blocks.misc
import me.steven.indrev.registry.IRItemRegistry
import net.minecraft.block.Block
import net.minecraft.block.BlockState
import net.minecraft.block.ShapeContext
import net.minecraft.item.Item
import net.minecraft.item.ItemPlacementContext
import net.minecraft.state.StateManager
import net.minecraft.state.property.DirectionProperty
import net.minecraft.state.property.Properties
import net.minecraft.util.function.BooleanBiFunction
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView
import net.minecraft.world.World
import net.minecraft.world.WorldView
import java.util.stream.Stream
class SulfurCrystalBlock(settings: Settings) : Block(settings) {
init {
defaultState = stateManager.defaultState.with(FACING, Direction.UP)
}
override fun getOutlineShape(
state: BlockState,
world: BlockView?,
pos: BlockPos?,
context: ShapeContext?
): VoxelShape = when (state[FACING]) {
Direction.DOWN -> DOWN_SHAPE
Direction.NORTH -> NORTH_SHAPE
Direction.SOUTH -> SOUTH_SHAPE
Direction.WEST -> WEST_SHAPE
Direction.EAST -> EAST_SHAPE
else -> UP_SHAPE
}
override fun neighborUpdate(
state: BlockState,
world: World?,
pos: BlockPos,
block: Block?,
fromPos: BlockPos,
notify: Boolean
) {
val vec = pos.subtract(fromPos)
val dir = Direction.fromVector(vec.x, vec.y, vec.z)
if (state[FACING] == dir) {
world?.breakBlock(pos, true)
}
}
override fun canPlaceAt(state: BlockState, world: WorldView, pos: BlockPos): Boolean {
val direction = state.get(FACING)
val blockPos = pos.offset(direction.opposite)
val blockState = world.getBlockState(blockPos)
return blockState.isSideSolidFullSquare(world, blockPos, direction)
}
override fun appendProperties(builder: StateManager.Builder?) {
builder?.add(FACING)
}
override fun getPlacementState(ctx: ItemPlacementContext?): BlockState? {
return defaultState.with(FACING, ctx?.playerLookDirection?.opposite)
}
override fun asItem(): Item {
return IRItemRegistry.SULFUR_CRYSTAL_ITEM
}
companion object {
val FACING: DirectionProperty = Properties.FACING
private val UP_SHAPE = Stream.of(
createCuboidShape(2.0, 5.0, 4.0, 3.0, 6.0, 5.0),
createCuboidShape(2.0, 4.0, 4.0, 4.0, 5.0, 6.0),
createCuboidShape(1.0, 0.0, 3.0, 4.0, 4.0, 6.0),
createCuboidShape(3.0, 0.0, 2.0, 5.0, 1.0, 4.0),
createCuboidShape(0.0, 0.0, 5.0, 2.0, 2.0, 7.0),
createCuboidShape(10.0, 0.0, 1.0, 12.0, 1.0, 3.0),
createCuboidShape(11.0, 0.0, 2.0, 14.0, 4.0, 5.0),
createCuboidShape(11.0, 4.0, 2.0, 13.0, 5.0, 4.0),
createCuboidShape(12.0, 5.0, 3.0, 13.0, 6.0, 4.0),
createCuboidShape(13.0, 0.0, 4.0, 15.0, 2.0, 6.0),
createCuboidShape(6.0, 0.0, 7.0, 8.0, 2.0, 10.0),
createCuboidShape(7.0, 0.0, 8.0, 12.0, 5.0, 13.0),
createCuboidShape(8.0, 5.0, 9.0, 11.0, 8.0, 12.0),
createCuboidShape(9.0, 8.0, 10.0, 10.0, 10.0, 11.0),
createCuboidShape(11.0, 0.0, 12.0, 14.0, 3.0, 15.0)
).reduce { v1, v2 -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
private val DOWN_SHAPE = Stream.of(
createCuboidShape(13.0, 11.0, 4.0, 14.0, 12.0, 5.0),
createCuboidShape(12.0, 12.0, 4.0, 14.0, 13.0, 6.0),
createCuboidShape(12.0, 13.0, 3.0, 15.0, 17.0, 6.0),
createCuboidShape(11.0, 16.0, 2.0, 13.0, 17.0, 4.0),
createCuboidShape(14.0, 15.0, 5.0, 16.0, 17.0, 7.0),
createCuboidShape(4.0, 16.0, 1.0, 6.0, 17.0, 3.0),
createCuboidShape(2.0, 13.0, 2.0, 5.0, 17.0, 5.0),
createCuboidShape(3.0, 12.0, 2.0, 5.0, 13.0, 4.0),
createCuboidShape(3.0, 11.0, 3.0, 4.0, 12.0, 4.0),
createCuboidShape(1.0, 15.0, 4.0, 3.0, 17.0, 6.0),
createCuboidShape(8.0, 15.0, 7.0, 10.0, 17.0, 10.0),
createCuboidShape(4.0, 12.0, 8.0, 9.0, 17.0, 13.0),
createCuboidShape(5.0, 9.0, 9.0, 8.0, 12.0, 12.0),
createCuboidShape(6.0, 7.0, 10.0, 7.0, 9.0, 11.0),
createCuboidShape(2.0, 14.0, 12.0, 5.0, 17.0, 15.0)
).reduce { v1, v2 -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
private val EAST_SHAPE = Stream.of(
createCuboidShape(5.0, 11.0, 13.0, 6.0, 12.0, 14.0),
createCuboidShape(4.0, 10.0, 12.0, 5.0, 12.0, 14.0),
createCuboidShape(0.0, 10.0, 12.0, 4.0, 13.0, 15.0),
createCuboidShape(0.0, 12.0, 11.0, 1.0, 14.0, 13.0),
createCuboidShape(0.0, 9.0, 14.0, 2.0, 11.0, 16.0),
createCuboidShape(0.0, 13.0, 4.0, 1.0, 15.0, 6.0),
createCuboidShape(0.0, 11.0, 2.0, 4.0, 14.0, 5.0),
createCuboidShape(4.0, 12.0, 3.0, 5.0, 14.0, 5.0),
createCuboidShape(5.0, 12.0, 3.0, 6.0, 13.0, 4.0),
createCuboidShape(0.0, 10.0, 1.0, 2.0, 12.0, 3.0),
createCuboidShape(0.0, 6.0, 8.0, 2.0, 9.0, 10.0),
createCuboidShape(0.0, 3.0, 4.0, 5.0, 8.0, 9.0),
createCuboidShape(5.0, 4.0, 5.0, 8.0, 7.0, 8.0),
createCuboidShape(8.0, 5.0, 6.0, 10.0, 6.0, 7.0),
createCuboidShape(0.0, 1.0, 2.0, 3.0, 4.0, 5.0)
).reduce { v1, v2 -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
private val SOUTH_SHAPE = Stream.of(
createCuboidShape(1.0, 4.0, 0.0, 3.0, 6.0, 2.0),
createCuboidShape(3.0, 3.0, 5.0, 4.0, 4.0, 6.0),
createCuboidShape(3.0, 2.0, 4.0, 5.0, 4.0, 5.0),
createCuboidShape(2.0, 2.0, 0.0, 5.0, 5.0, 4.0),
createCuboidShape(4.0, 1.0, 0.0, 6.0, 3.0, 1.0),
createCuboidShape(11.0, 2.0, 0.0, 13.0, 4.0, 1.0),
createCuboidShape(12.0, 3.0, 0.0, 15.0, 6.0, 4.0),
createCuboidShape(12.0, 4.0, 4.0, 14.0, 6.0, 5.0),
createCuboidShape(13.0, 4.0, 5.0, 14.0, 5.0, 6.0),
createCuboidShape(14.0, 5.0, 0.0, 16.0, 7.0, 2.0),
createCuboidShape(8.0, 7.0, 0.0, 10.0, 10.0, 2.0),
createCuboidShape(4.0, 8.0, 0.0, 9.0, 13.0, 5.0),
createCuboidShape(5.0, 9.0, 5.0, 8.0, 12.0, 8.0),
createCuboidShape(6.0, 10.0, 8.0, 7.0, 11.0, 10.0),
createCuboidShape(2.0, 12.0, 0.0, 5.0, 15.0, 3.0)
).reduce { v1, v2 -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
private val NORTH_SHAPE = Stream.of(
createCuboidShape(13.0, 4.0, 14.0, 15.0, 6.0, 16.0),
createCuboidShape(12.0, 3.0, 10.0, 13.0, 4.0, 11.0),
createCuboidShape(11.0, 2.0, 11.0, 13.0, 4.0, 12.0),
createCuboidShape(11.0, 2.0, 12.0, 14.0, 5.0, 16.0),
createCuboidShape(10.0, 1.0, 15.0, 12.0, 3.0, 16.0),
createCuboidShape(3.0, 2.0, 15.0, 5.0, 4.0, 16.0),
createCuboidShape(1.0, 3.0, 12.0, 4.0, 6.0, 16.0),
createCuboidShape(2.0, 4.0, 11.0, 4.0, 6.0, 12.0),
createCuboidShape(2.0, 4.0, 10.0, 3.0, 5.0, 11.0),
createCuboidShape(0.0, 5.0, 14.0, 2.0, 7.0, 16.0),
createCuboidShape(6.0, 7.0, 14.0, 8.0, 10.0, 16.0),
createCuboidShape(7.0, 8.0, 11.0, 12.0, 13.0, 16.0),
createCuboidShape(8.0, 9.0, 8.0, 11.0, 12.0, 11.0),
createCuboidShape(9.0, 10.0, 6.0, 10.0, 11.0, 8.0),
createCuboidShape(11.0, 12.0, 13.0, 14.0, 15.0, 16.0)
).reduce { v1: VoxelShape?, v2: VoxelShape? -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
private val WEST_SHAPE = Stream.of(
createCuboidShape(10.0, 11.0, 2.0, 11.0, 12.0, 3.0),
createCuboidShape(11.0, 10.0, 2.0, 12.0, 12.0, 4.0),
createCuboidShape(12.0, 10.0, 1.0, 16.0, 13.0, 4.0),
createCuboidShape(15.0, 12.0, 3.0, 16.0, 14.0, 5.0),
createCuboidShape(14.0, 9.0, 0.0, 16.0, 11.0, 2.0),
createCuboidShape(15.0, 13.0, 10.0, 16.0, 15.0, 12.0),
createCuboidShape(12.0, 11.0, 11.0, 16.0, 14.0, 14.0),
createCuboidShape(11.0, 12.0, 11.0, 12.0, 14.0, 13.0),
createCuboidShape(10.0, 12.0, 12.0, 11.0, 13.0, 13.0),
createCuboidShape(14.0, 10.0, 13.0, 16.0, 12.0, 15.0),
createCuboidShape(14.0, 6.0, 6.0, 16.0, 9.0, 8.0),
createCuboidShape(11.0, 3.0, 7.0, 16.0, 8.0, 12.0),
createCuboidShape(8.0, 4.0, 8.0, 11.0, 7.0, 11.0),
createCuboidShape(6.0, 5.0, 9.0, 8.0, 6.0, 10.0),
createCuboidShape(13.0, 1.0, 11.0, 16.0, 4.0, 14.0)
).reduce { v1, v2 -> VoxelShapes.combineAndSimplify(v1, v2, BooleanBiFunction.OR) }.orElse(null)
}
}
================================================
FILE: src/main/kotlin/me/steven/indrev/blocks/misc/TankBlock.kt
================================================
package me.steven.indrev.blocks.misc
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume
import me.steven.indrev.blockentities.Syncable
import me.steven.indrev.blockentities.storage.TankBlockEntity
import me.steven.indrev.components.FluidComponent
import me.steven.indrev.registry.IRBlockRegistry
import me.steven.indrev.utils.bucket
import me.steven.indrev.utils.fluidStorageOf
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage
import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil
import net.minecraft.block.Block
import net.minecraft.block.BlockEntityProvider
import net.minecraft.block.BlockState
import net.minecraft.block.ShapeContext
import net.minecraft.block.entity.BlockEntity
import net.minecraft.block.entity.BlockEntityTicker
import net.minecraft.block.entity.BlockEntityType
import net.minecraft.client.item.TooltipContext
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.ItemPlacementContext
import net.minecraft.item.ItemStack
import net.minecraft.server.world.ServerWorld
import net.minecraft.stat.Stats
import net.minecraft.state.StateManager
import net.minecraft.state.property.BooleanProperty
import net.minecraft.text.LiteralText
import net.minecraft.text.Text
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.function.BooleanBiFunction
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.shape.VoxelShape
import net.minecraft.util.shape.VoxelShapes
import net.minecraft.world.BlockView
import net.minecraft.world.World
import net.minecraft.world.WorldAccess
import net.minecraft.world.chunk.Chunk
import java.util.stream.Stream
class TankBlock(settings: Settings) : Block(settings), BlockEntityProvider {
init {
this.defaultState = stateManager.defaultState.with(UP, false).with(DOWN, false)
}
override fun appendProperties(builder: StateManager.Builder?) {
builder?.add(UP, DOWN)
}
override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = TankBlockEntity(pos, state)
override fun getTicker(
world: World,
state: BlockState?,
type: BlockEntityType