diff --git a/.gitignore b/.gitignore index 12f8644..d52064f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ build # other eclipse run +*.lnk # Files from Forge MDK forge*changelog.txt diff --git a/gradle.properties b/gradle.properties index b9c8641..5c0281f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ create_version = 0.5.0.c-148 # Mod Properties maven_group=dev.dev.limonblaze.oriacs archives_base_name=origins-accessbilities -mod_version=1.0.0 +mod_version=1.0.1 mod_id=oriacs mod_author=LimonBlaze fml_requirements = [40,) diff --git a/src/main/java/dev/limonblaze/oriacs/common/OriacsServerConfig.java b/src/main/java/dev/limonblaze/oriacs/common/OriacsServerConfig.java index 66108d8..57f3ced 100644 --- a/src/main/java/dev/limonblaze/oriacs/common/OriacsServerConfig.java +++ b/src/main/java/dev/limonblaze/oriacs/common/OriacsServerConfig.java @@ -24,6 +24,7 @@ public class OriacsServerConfig { public final ForgeConfigSpec.BooleanValue UMBRELLA_CAN_KEEP_OUT_RAIN; public final ForgeConfigSpec.BooleanValue UMBRELLA_CAN_KEEP_OUT_SUNLIGHT; public final ForgeConfigSpec.IntValue UMBRELLA_MAX_KEEP_OUT_SUNLIGHT_COLOR; + public final ForgeConfigSpec.DoubleValue UMBRELLA_SPAWN_WITH_ZOMBIE_CHANCE; public OriacsServerConfig(ForgeConfigSpec.Builder builder) { builder.push("diet"); @@ -84,6 +85,10 @@ public OriacsServerConfig(ForgeConfigSpec.Builder builder) { "If set to 255, umbrella of all colors can keep out sunlight" ) .defineInRange("maxKeepOutSunlightColor", 127, 0, 255); + UMBRELLA_SPAWN_WITH_ZOMBIE_CHANCE = builder + .translation(translationKey("umbrella.spawn_with_zombie_chance")) + .comment("The chance for a zombie is spawned with an umbrella in hard difficulty") + .defineInRange("spawnWithZombieChance", 0.05, 0, 1); builder.pop(); } diff --git a/src/main/java/dev/limonblaze/oriacs/common/enchantment/FlyingProtectionEnchantment.java b/src/main/java/dev/limonblaze/oriacs/common/enchantment/FlyingProtectionEnchantment.java index 80d1a1d..2154d66 100644 --- a/src/main/java/dev/limonblaze/oriacs/common/enchantment/FlyingProtectionEnchantment.java +++ b/src/main/java/dev/limonblaze/oriacs/common/enchantment/FlyingProtectionEnchantment.java @@ -2,14 +2,24 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.item.enchantment.ProtectionEnchantment; +import javax.annotation.ParametersAreNonnullByDefault; + +@ParametersAreNonnullByDefault public class FlyingProtectionEnchantment extends ProtectionEnchantment { public FlyingProtectionEnchantment() { super(Rarity.RARE, Type.ALL, EquipmentSlot.HEAD); } + @Override + public boolean canApplyAtEnchantingTable(ItemStack stack) { + return Enchantments.RESPIRATION.canEnchant(stack); + } + public boolean isTreasureOnly() { return true; } diff --git a/src/main/java/dev/limonblaze/oriacs/common/item/UmbrellaItem.java b/src/main/java/dev/limonblaze/oriacs/common/item/UmbrellaItem.java index a63bcea..9d30cb6 100644 --- a/src/main/java/dev/limonblaze/oriacs/common/item/UmbrellaItem.java +++ b/src/main/java/dev/limonblaze/oriacs/common/item/UmbrellaItem.java @@ -2,21 +2,28 @@ import dev.limonblaze.oriacs.common.Oriacs; import dev.limonblaze.oriacs.common.OriacsServerConfig; +import dev.limonblaze.oriacs.common.registry.OriacsItems; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.core.BlockPos; +import net.minecraft.core.cauldron.CauldronInteraction; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; +import net.minecraft.world.Difficulty; +import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.monster.Zombie; import net.minecraft.world.item.DyeableLeatherItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Vanishable; import net.minecraft.world.level.Level; import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Random; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault @@ -26,6 +33,7 @@ public class UmbrellaItem extends Item implements DyeableLeatherItem, Vanishable public UmbrellaItem(Properties properties) { super(properties.stacksTo(1).setNoRepair()); + CauldronInteraction.WATER.put(this, CauldronInteraction.DYED_ITEM); } public boolean canKeepOutRain(ItemStack stack) { @@ -69,7 +77,7 @@ public int getBarColor(ItemStack pStack) { @Override public boolean canBeDepleted() { - return true; + return false; } @Override @@ -100,4 +108,20 @@ public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { } } + @SubscribeEvent + public static void onLivingSpawn(LivingSpawnEvent.SpecialSpawn event) { + if(event.getEntityLiving() instanceof Zombie zombie) { + Random random = zombie.getRandom(); + if(zombie.level.getDifficulty() == Difficulty.HARD && + random.nextFloat() < OriacsServerConfig.CONFIG.UMBRELLA_SPAWN_WITH_ZOMBIE_CHANCE.get() && + zombie.getItemInHand(InteractionHand.OFF_HAND).isEmpty() + ) { + UmbrellaItem umbrella = OriacsItems.UMBRELLA.get(); + ItemStack stack = umbrella.getDefaultInstance(); + umbrella.setColor(stack, random.nextInt(0xFFFFFF)); + zombie.setItemInHand(InteractionHand.OFF_HAND, stack); + } + } + } + } diff --git a/src/main/java/dev/limonblaze/oriacs/common/registry/OriacsMobEffects.java b/src/main/java/dev/limonblaze/oriacs/common/registry/OriacsMobEffects.java index 97c2577..4184431 100644 --- a/src/main/java/dev/limonblaze/oriacs/common/registry/OriacsMobEffects.java +++ b/src/main/java/dev/limonblaze/oriacs/common/registry/OriacsMobEffects.java @@ -16,7 +16,7 @@ public class OriacsMobEffects { () -> new SimpleMobEffect(MobEffectCategory.BENEFICIAL, 0xAACCFF)); public static final RegistryObject SUNLIGHT_RESISTANCE = REGISTRY.register("sunlight_resistance", - () -> new SimpleMobEffect(MobEffectCategory.BENEFICIAL, 0xAAFFCC)); + () -> new SimpleMobEffect(MobEffectCategory.BENEFICIAL, 0xFFCCAA)); public static final RegistryObject FRESH_AIR = REGISTRY.register("fresh_air", () -> new SimpleMobEffect(MobEffectCategory.BENEFICIAL, 0xFFFFFF)); diff --git a/src/main/java/dev/limonblaze/oriacs/core/mixin/LivingEntityMixin.java b/src/main/java/dev/limonblaze/oriacs/core/mixin/LivingEntityMixin.java new file mode 100644 index 0000000..e3f3f7e --- /dev/null +++ b/src/main/java/dev/limonblaze/oriacs/core/mixin/LivingEntityMixin.java @@ -0,0 +1,17 @@ +package dev.limonblaze.oriacs.core.mixin; + +import dev.limonblaze.oriacs.common.registry.OriacsMobEffects; +import net.minecraft.world.entity.LivingEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(LivingEntity.class) +public class LivingEntityMixin { + + @Redirect(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isSensitiveToWater()Z")) + private boolean oriacs$checkWaterResistance(LivingEntity entity) { + return entity.isSensitiveToWater() && !entity.hasEffect(OriacsMobEffects.WATER_RESISTANCE.get()); + } + +} diff --git a/src/main/java/dev/limonblaze/oriacs/core/mixin/MobMixin.java b/src/main/java/dev/limonblaze/oriacs/core/mixin/MobMixin.java new file mode 100644 index 0000000..b2f64b2 --- /dev/null +++ b/src/main/java/dev/limonblaze/oriacs/core/mixin/MobMixin.java @@ -0,0 +1,30 @@ +package dev.limonblaze.oriacs.core.mixin; + +import dev.limonblaze.oriacs.common.item.UmbrellaItem; +import dev.limonblaze.oriacs.common.registry.OriacsMobEffects; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.level.Level; +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(Mob.class) +public abstract class MobMixin extends LivingEntity { + + protected MobMixin(EntityType entityType, Level level) { + super(entityType, level); + } + + @Inject(method = "isSunBurnTick", at = @At("HEAD"), cancellable = true) + private void oriacs$checkSunResistanceAndUmbrella(CallbackInfoReturnable cir) { + if(this.hasEffect(OriacsMobEffects.SUNLIGHT_RESISTANCE.get()) || + UmbrellaItem.canKeepOutSunlight(this) + ) { + cir.setReturnValue(false); + } + } + +} diff --git a/src/main/java/dev/limonblaze/oriacs/core/mixin/TrownPotionMixin.java b/src/main/java/dev/limonblaze/oriacs/core/mixin/TrownPotionMixin.java new file mode 100644 index 0000000..8d283e3 --- /dev/null +++ b/src/main/java/dev/limonblaze/oriacs/core/mixin/TrownPotionMixin.java @@ -0,0 +1,18 @@ +package dev.limonblaze.oriacs.core.mixin; + +import dev.limonblaze.oriacs.common.registry.OriacsMobEffects; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.ThrownPotion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(ThrownPotion.class) +public class TrownPotionMixin { + + @Redirect(method = "applyWater", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isSensitiveToWater()Z")) + private boolean oriacs$checkWaterResistance(LivingEntity entity) { + return entity.isSensitiveToWater() && !entity.hasEffect(OriacsMobEffects.WATER_RESISTANCE.get()); + } + +} diff --git a/src/main/resources/assets/oriacs/lang/en_us.json b/src/main/resources/assets/oriacs/lang/en_us.json index 2459a0e..5ecfbe7 100644 --- a/src/main/resources/assets/oriacs/lang/en_us.json +++ b/src/main/resources/assets/oriacs/lang/en_us.json @@ -13,7 +13,7 @@ "item.minecraft.splash_potion.effect.water_resistance": "Splash Potion of Water Resistance", "item.minecraft.lingering_potion.effect.water_resistance": "Lingering Potion of Water Resistance", - "effect.oriacs.sunlight_resistance": "Sunlight Resistance", + "effect.oriacs.sunlight_resistance": "Sunscreen", "item.minecraft.tipped_arrow.effect.sunscreen": "Arrow of Sunscreen", "item.minecraft.potion.effect.sunscreen": "Potion of Sunscreen", "item.minecraft.splash_potion.effect.sunscreen": "Splash Potion of Sunscreen", @@ -31,5 +31,6 @@ "config.oriacs.server.umbrella.max_damage": "Umbrella Max Damage", "config.oriacs.server.umbrella.can_keep_out_rain": "Can Umbrella Keep out Rain", "config.oriacs.server.umbrella.can_keep_out_sunlight": "Can Umbrella Keep out Sunlight", - "config.oriacs.server.umbrella.max_keep_out_sunlight_color": "Max R/G/B for Umbrella to Keep out Sunlight" + "config.oriacs.server.umbrella.max_keep_out_sunlight_color": "Max R/G/B for Umbrella to Keep out Sunlight", + "config.oriacs.server.umbrella.spawn_with_zombie_chance": "Chance for Zombie spawn with umbrella in hard difiiculty" } \ No newline at end of file diff --git a/src/main/resources/assets/oriacs/lang/zh_cn.json b/src/main/resources/assets/oriacs/lang/zh_cn.json index bd9d574..94a2a8c 100644 --- a/src/main/resources/assets/oriacs/lang/zh_cn.json +++ b/src/main/resources/assets/oriacs/lang/zh_cn.json @@ -13,7 +13,7 @@ "item.minecraft.splash_potion.effect.water_resistance": "喷溅型防水药水", "item.minecraft.lingering_potion.effect.water_resistance": "滞留型防水药水", - "effect.oriacs.sunlight_resistance": "阳光抗性", + "effect.oriacs.sunlight_resistance": "防晒", "item.minecraft.tipped_arrow.effect.sunscreen": "防晒之箭", "item.minecraft.potion.effect.sunscreen": "防晒药水", "item.minecraft.splash_potion.effect.sunscreen": "喷溅型防晒药水", @@ -31,5 +31,6 @@ "config.oriacs.server.umbrella.max_damage": "伞最大耐久", "config.oriacs.server.umbrella.can_keep_out_rain": "伞能否遮蔽雨", "config.oriacs.server.umbrella.can_keep_out_sunlight": "伞能否遮蔽阳光", - "config.oriacs.server.umbrella.max_keep_out_sunlight_color": "伞遮蔽阳光所需的R/G/B值上限" + "config.oriacs.server.umbrella.max_keep_out_sunlight_color": "伞遮蔽阳光所需的R/G/B值上限", + "config.oriacs.server.umbrella.spawn_with_zombie_chance": "僵尸带着伞生成的概率(困难难度下)" } \ No newline at end of file diff --git a/src/main/resources/oriacs.mixins.json b/src/main/resources/oriacs.mixins.json index d2e9219..39c06e8 100644 --- a/src/main/resources/oriacs.mixins.json +++ b/src/main/resources/oriacs.mixins.json @@ -6,8 +6,11 @@ "mixins": [ "AirCurrentMixin", "EntityMixin", + "LivingEntityMixin", + "MobMixin", "PotionBrewingAccessor", - "SimpleEntityConditionMixin" + "SimpleEntityConditionMixin", + "TrownPotionMixin" ], "client": [ "HumanoidArmorLayerMixin" diff --git a/src/main/resources/pack.png b/src/main/resources/pack.png index ef44036..2f64e26 100644 Binary files a/src/main/resources/pack.png and b/src/main/resources/pack.png differ