Make first working version (Time not work in Bad Air)
This commit is contained in:
		| @ -0,0 +1,35 @@ | ||||
| package ru.bitheaven.createairfabric; | ||||
|  | ||||
| import com.simibubi.create.Create; | ||||
| import fuzs.thinair.helper.AirHelper; | ||||
| import fuzs.thinair.helper.AirQualityLevel; | ||||
| import io.github.fabricators_of_create.porting_lib.util.EnvExecutor; | ||||
| import net.fabricmc.api.ModInitializer; | ||||
| import net.minecraft.resources.ResourceLocation; | ||||
| import net.minecraft.world.entity.LivingEntity; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| public class CreateAirFabric implements ModInitializer { | ||||
|     public static final String ID = "createairfabric"; | ||||
|     public static final String NAME = "Create Air Fabric"; | ||||
|     public static final Logger LOGGER = LoggerFactory.getLogger(NAME); | ||||
|  | ||||
|     @Override | ||||
|     public void onInitialize() { | ||||
|         LOGGER.info("Create addon mod [{}] is loading alongside Create [{}]!", NAME, Create.VERSION); | ||||
|         LOGGER.info(EnvExecutor.unsafeRunForDist( | ||||
|                 () -> () -> "{} is accessing Porting Lib from the client!", | ||||
|                 () -> () -> "{} is accessing Porting Lib from the server!" | ||||
|         ), NAME); | ||||
|     } | ||||
|  | ||||
|     public static boolean airQualityActivatesHelmet(LivingEntity entity) { | ||||
|         final var air = AirHelper.getO2LevelFromLocation(entity.getEyePosition(), entity.level()).getFirst(); | ||||
|         return air == AirQualityLevel.RED || air == AirQualityLevel.YELLOW; | ||||
|     } | ||||
|  | ||||
|     public static ResourceLocation id(String path) { | ||||
|         return new ResourceLocation(ID, path); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,26 @@ | ||||
| package ru.bitheaven.createairfabric.mixin; | ||||
|  | ||||
| import fuzs.thinair.helper.AirHelper; | ||||
| import fuzs.thinair.helper.AirQualityLevel; | ||||
| import net.minecraft.tags.TagKey; | ||||
| import net.minecraft.world.level.material.Fluid; | ||||
| import org.spongepowered.asm.mixin.Mixin; | ||||
| import org.spongepowered.asm.mixin.injection.At; | ||||
| import org.spongepowered.asm.mixin.injection.Redirect; | ||||
|  | ||||
| import ru.bitheaven.createairfabric.CreateAirFabric; | ||||
| import com.simibubi.create.content.equipment.armor.DivingHelmetItem; | ||||
|  | ||||
| import net.minecraft.world.entity.LivingEntity; | ||||
|  | ||||
| @Mixin(DivingHelmetItem.class) | ||||
| public abstract class DivingHelmetItemMixin { | ||||
|     /** | ||||
|      * Activate helmet "if in water or lava" -> "if in water or bad air or lava" | ||||
|      */ | ||||
|     @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isEyeInFluid(Lnet/minecraft/tags/TagKey;)Z"), | ||||
|             method = "breatheUnderwater(Lnet/minecraft/world/entity/LivingEntity;)V") | ||||
|     private static boolean redirectBreatheUnderwater(LivingEntity entity, TagKey<Fluid> fluidTagKey) { | ||||
|         return entity.isEyeInFluid(fluidTagKey) || CreateAirFabric.airQualityActivatesHelmet(entity); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,20 @@ | ||||
| package ru.bitheaven.createairfabric.mixin; | ||||
|  | ||||
| import ru.bitheaven.createairfabric.CreateAirFabric; | ||||
|  | ||||
| import net.minecraft.client.Minecraft; | ||||
|  | ||||
| import net.minecraft.client.main.GameConfig; | ||||
|  | ||||
| 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(Minecraft.class) | ||||
| public class MinecraftMixin { | ||||
|     @Inject(method = "<init>", at = @At("TAIL")) | ||||
|     private void example$init(GameConfig gameConfig, CallbackInfo ci) { | ||||
|         CreateAirFabric.LOGGER.info("Hello from {}", CreateAirFabric.NAME); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								src/main/resources/assets/createairfabric/icon.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/main/resources/assets/createairfabric/icon.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 52 KiB | 
							
								
								
									
										15
									
								
								src/main/resources/createairfabric.mixins.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/main/resources/createairfabric.mixins.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| { | ||||
|   "required": true, | ||||
|   "minVersion": "0.8", | ||||
|   "package": "ru.bitheaven.createairfabric.mixin", | ||||
|   "compatibilityLevel": "JAVA_17", | ||||
|   "mixins": [ | ||||
|     "DivingHelmetItemMixin" | ||||
|   ], | ||||
|   "client": [ | ||||
|     "MinecraftMixin" | ||||
|   ], | ||||
|   "injectors": { | ||||
|     "defaultRequire": 1 | ||||
|   } | ||||
| } | ||||
| @ -4,15 +4,28 @@ | ||||
|   "version": "${version}", | ||||
|   "name": "Create Air Fabric", | ||||
|   "description": "Addon for compatibility Create and Thin Air", | ||||
|   "authors": [], | ||||
|   "contact": {}, | ||||
|   "authors": [ | ||||
|     "BitHeaven" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "website": "https://bitheaven.ru", | ||||
|     "repo": "https://git.bitheaven.ru/bitheaven/create-air-fabric" | ||||
|   }, | ||||
|   "license": "GPL-3.0", | ||||
|   "icon": "assets/createairfabric/icon.png", | ||||
|   "environment": "*", | ||||
|   "entrypoints": {}, | ||||
|   "entrypoints": { | ||||
|     "main": [ | ||||
|       "ru.bitheaven.createairfabric.CreateAirFabric" | ||||
|     ] | ||||
|   }, | ||||
|   "mixins": [ | ||||
|     "createairfabric.mixins.json" | ||||
|   ], | ||||
|   "depends": { | ||||
|     "fabricloader": ">=${loader_version}", | ||||
|     "fabricloader": ">=${fabric_loader_version}", | ||||
|     "fabric": "*", | ||||
|     "minecraft": "${minecraft_version}" | ||||
|     "minecraft": "${minecraft_version}", | ||||
|     "create": "${create_version}" | ||||
|   } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user