Skip to content

Commit

Permalink
Merge pull request #1 from LimonBlaze/master
Browse files Browse the repository at this point in the history
Resolve wrong local branch pushes
  • Loading branch information
RaymondBlaze authored Aug 27, 2022
2 parents dacb2b3 + 5ead73f commit e2d5efa
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ build
# other
eclipse
run
*.lnk

# Files from Forge MDK
forge*changelog.txt
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -69,7 +77,7 @@ public int getBarColor(ItemStack pStack) {

@Override
public boolean canBeDepleted() {
return true;
return false;
}

@Override
Expand Down Expand Up @@ -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);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class OriacsMobEffects {
() -> new SimpleMobEffect(MobEffectCategory.BENEFICIAL, 0xAACCFF));

public static final RegistryObject<SimpleMobEffect> SUNLIGHT_RESISTANCE = REGISTRY.register("sunlight_resistance",
() -> new SimpleMobEffect(MobEffectCategory.BENEFICIAL, 0xAAFFCC));
() -> new SimpleMobEffect(MobEffectCategory.BENEFICIAL, 0xFFCCAA));

public static final RegistryObject<SimpleMobEffect> FRESH_AIR = REGISTRY.register("fresh_air",
() -> new SimpleMobEffect(MobEffectCategory.BENEFICIAL, 0xFFFFFF));
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}

}
30 changes: 30 additions & 0 deletions src/main/java/dev/limonblaze/oriacs/core/mixin/MobMixin.java
Original file line number Diff line number Diff line change
@@ -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<? extends LivingEntity> entityType, Level level) {
super(entityType, level);
}

@Inject(method = "isSunBurnTick", at = @At("HEAD"), cancellable = true)
private void oriacs$checkSunResistanceAndUmbrella(CallbackInfoReturnable<Boolean> cir) {
if(this.hasEffect(OriacsMobEffects.SUNLIGHT_RESISTANCE.get()) ||
UmbrellaItem.canKeepOutSunlight(this)
) {
cir.setReturnValue(false);
}
}

}
Original file line number Diff line number Diff line change
@@ -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());
}

}
5 changes: 3 additions & 2 deletions src/main/resources/assets/oriacs/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
5 changes: 3 additions & 2 deletions src/main/resources/assets/oriacs/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "喷溅型防晒药水",
Expand All @@ -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": "僵尸带着伞生成的概率(困难难度下)"
}
5 changes: 4 additions & 1 deletion src/main/resources/oriacs.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"mixins": [
"AirCurrentMixin",
"EntityMixin",
"LivingEntityMixin",
"MobMixin",
"PotionBrewingAccessor",
"SimpleEntityConditionMixin"
"SimpleEntityConditionMixin",
"TrownPotionMixin"
],
"client": [
"HumanoidArmorLayerMixin"
Expand Down
Binary file modified src/main/resources/pack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e2d5efa

Please sign in to comment.