mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 14:02:03 +01:00
Aqua Infinity and Under-lava Visibility
- Diving helmets now always grant aqua affinity - Diving helmets can no longer be enchanted with aqua affinity - Netherite diving helmets now improve under-lava visiblity by 6.25x
This commit is contained in:
parent
9498dacfc9
commit
8e936a0096
5 changed files with 68 additions and 7 deletions
|
@ -2,6 +2,8 @@ package com.simibubi.create.content.curiosities.armor;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.item.MultiLayeredArmorItem;
|
||||
|
||||
|
@ -30,10 +32,19 @@ public class DivingHelmetItem extends BaseArmorItem {
|
|||
}
|
||||
|
||||
public static boolean isWornBy(Entity entity) {
|
||||
if (!(entity instanceof LivingEntity livingEntity)) {
|
||||
ItemStack stack = getWornItem(entity);
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
return livingEntity.getItemBySlot(SLOT).getItem() instanceof DivingHelmetItem;
|
||||
return stack.getItem() instanceof DivingHelmetItem;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemStack getWornItem(Entity entity) {
|
||||
if (!(entity instanceof LivingEntity livingEntity)) {
|
||||
return null;
|
||||
}
|
||||
return livingEntity.getItemBySlot(SLOT);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllFluids;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||
|
@ -334,13 +335,15 @@ public class ClientEvents {
|
|||
return;
|
||||
}
|
||||
|
||||
if (FluidHelper.isWater(fluid) && DivingHelmetItem
|
||||
.isWornBy(Minecraft.getInstance().cameraEntity)) {
|
||||
ItemStack divingHelmet = DivingHelmetItem.getWornItem(Minecraft.getInstance().cameraEntity);
|
||||
if (divingHelmet != null) {
|
||||
if (FluidHelper.isWater(fluid) || FluidHelper.isLava(fluid) && AllItems.NETHERITE_DIVING_HELMET.isIn(divingHelmet)) {
|
||||
event.scaleFarPlaneDistance(6.25f);
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void getFogColor(EntityViewRenderEvent.FogColors event) {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.simibubi.create.foundation.mixin;
|
||||
|
||||
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;
|
||||
|
||||
import com.simibubi.create.content.curiosities.armor.DivingHelmetItem;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
|
||||
@Mixin(EnchantmentHelper.class)
|
||||
public class EnchantmentHelperMixin {
|
||||
@Inject(method = "getItemEnchantmentLevel(Lnet/minecraft/world/item/enchantment/Enchantment;Lnet/minecraft/world/item/ItemStack;)I", at = @At("HEAD"), cancellable = true)
|
||||
private static void onGetItemEnchantmentLevel(Enchantment enchantment, ItemStack stack, CallbackInfoReturnable<Integer> cir) {
|
||||
if (enchantment == Enchantments.AQUA_AFFINITY && stack.getItem() instanceof DivingHelmetItem) {
|
||||
cir.setReturnValue(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.simibubi.create.foundation.mixin;
|
||||
|
||||
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;
|
||||
|
||||
import com.simibubi.create.content.curiosities.armor.DivingHelmetItem;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
|
||||
@Mixin(Enchantment.class)
|
||||
public class EnchantmentMixin {
|
||||
@Inject(method = "canEnchant(Lnet/minecraft/world/item/ItemStack;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private void onCanEnchant(ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
|
||||
if ((Object) this == Enchantments.AQUA_AFFINITY && stack.getItem() instanceof DivingHelmetItem) {
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,8 @@
|
|||
"refmap": "create.refmap.json",
|
||||
"mixins": [
|
||||
"CustomItemUseEffectsMixin",
|
||||
"EnchantmentHelperMixin",
|
||||
"EnchantmentMixin",
|
||||
"EntityMixin",
|
||||
"HumanoidArmorLayerMixin",
|
||||
"MapItemSavedDataMixin",
|
||||
|
|
Loading…
Reference in a new issue