Skip to content

Commit

Permalink
0.4.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FirokOtaku committed Jan 7, 2022
1 parent 812af0f commit 94e6c64
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 51 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

> All Time Stamps: GMT+8
## 0.4.19.0 22-01-07 17:00

* 迁移代码 migrated some code

## 0.4.18.0 22-01-06 23:00

* 迁移代码 migrated some code
Expand Down
6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

一个匠魂的附属模组. An addon of Tinkers' Construct.

* 变更日志 change log:
正在迁移进度至 *1.16.5*. We are migrating code into *1.16.5*.

* 变更日志 change log:
[链接 link](changelog.md)
* 贡献者列表 contributors:
* 贡献者列表 contributors:
[链接 link](doc/contributors.md)
2 changes: 2 additions & 0 deletions src/main/java/firok/tiths/TinkersThings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import firok.tiths.block.TithsBlocks;
import firok.tiths.config.ConfigModifier;
import firok.tiths.item.TithsItems;
import firok.tiths.material.TithsMaterials;
import firok.tiths.modifier.TithsModifiers;
import firok.tiths.tile.TithsTiles;
Expand All @@ -25,6 +26,7 @@ public TinkersThings() {
bus.register(new TithsMaterials());
bus.register(new TithsBlocks());
bus.register(new TithsTiles());
bus.register(new TithsItems());

TithsModule.initRegisters();

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/firok/tiths/config/ConfigModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;

import java.util.ArrayList;

Expand All @@ -30,6 +31,8 @@ public class ConfigModifier

public static DoubleValue range_extreme_freezing;

public static IntValue factor_gluttonic_food;


static {
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
Expand Down Expand Up @@ -71,6 +74,9 @@ public class ConfigModifier
range_extreme_freezing = builder.comment("")
.defineInRange("range_extreme_freezing", 4f, 1, 10);

factor_gluttonic_food = builder.comment("")
.defineInRange("factor_gluttonic_food", 4, 0, 100);

builder.pop();
INSTANCE = builder.build();
}
Expand Down
66 changes: 66 additions & 0 deletions src/main/java/firok/tiths/item/ItemEnderResonanceStone.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package firok.tiths.item;

import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.world.World;

public class ItemEnderResonanceStone extends Item
{
public ItemEnderResonanceStone()
{
super(new Properties().group(ItemGroup.TOOLS).maxStackSize(1).rarity(Rarity.UNCOMMON).setNoRepair().isImmuneToFire());
}

@Override
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{
super.inventoryTick(stack, worldIn, entityIn, itemSlot, isSelected);
}

public static final String KEY_NBT_TYPES = "types";
public static final String KEY_NBT_ITEMS = "items";

/**
* 向一个末影谐振之石填充物品
* @param stackNew 要填充的物品
* @param stackStone 末影谐振之石
* @param countFullType 最大填充种类数
* @return
*/
public static boolean addItem(ItemStack stackNew, ItemStack stackStone, final int countFullType)
{
final int countNew = stackNew.getCount();
final Item itemNew = stackNew.getItem();
CompoundNBT nbtStone = stackStone.getOrCreateTag();

final int currentTypes = nbtStone.contains(KEY_NBT_TYPES,3) ? nbtStone.getInt(KEY_NBT_TYPES) : 0;
final boolean isTypeFull = currentTypes >= countFullType;

ListNBT listItem = nbtStone.getList(KEY_NBT_ITEMS, 10);
final int sizeList = listItem.size();

boolean hasStacked = false; // 是否在储存的物品里找到了一个能叠加的
ItemStack stackExtra = null; // 如果找到了能叠加的stack 是否叠加剩下了一部分

for(int step = sizeList - 1; step >= 0; step--)
{
CompoundNBT nbtItem = listItem.getCompound(step);
ItemStack stackItem = ItemStack.read(nbtItem);
final int maxStackSize = stackItem.getMaxStackSize();
final int currentStackSize = stackItem.getCount();
final int remainStackSize = maxStackSize - currentStackSize; // 这个stack还能叠加多少
if(remainStackSize <= 0 || !ItemStack.areItemsEqual(stackItem, stackNew) || !ItemStack.areItemStackTagsEqual(stackItem, stackNew))
continue; // 满了 或者不能叠加 检查下一个



}

return false;
}
}
16 changes: 16 additions & 0 deletions src/main/java/firok/tiths/item/ItemMaterial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package firok.tiths.item;

import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;

public class ItemMaterial extends Item
{
public ItemMaterial(Properties properties)
{
super(properties);
}
public ItemMaterial()
{
super(new Properties().group(ItemGroup.MATERIALS));
}
}
12 changes: 12 additions & 0 deletions src/main/java/firok/tiths/item/TithsItems.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package firok.tiths.item;

import firok.tiths.TithsModule;
import slimeknights.mantle.registration.object.ItemObject;

public class TithsItems extends TithsModule
{
public static ItemObject<ItemMaterial> materialPhaseCrystal
= ITEMS.register("phase_crystal", ItemMaterial::new);


}
6 changes: 6 additions & 0 deletions src/main/java/firok/tiths/modifier/TithsModifiers.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ public class TithsModifiers extends TithsModule
= MODIFIERS.register("eroding", ModifierEroding::new);
public static final RegistryObject<ModifierExtremeFreezing> MODIFIER_EXTREME_FREEZING
= MODIFIERS.register("extreme_freezing", ModifierExtremeFreezing::new);

public static final RegistryObject<ModifierFarmer> MODIFIER_FARMER
= MODIFIERS.register("farmer", ModifierFarmer::new);

public static final RegistryObject<ModifierGluttonic> MODIFIER_GLUTTONIC
= MODIFIERS.register("gluttonic", ModifierGluttonic::new);
}
49 changes: 0 additions & 49 deletions src/main/java/firok/tiths/modifier/general/ModifierFamer.java

This file was deleted.

72 changes: 72 additions & 0 deletions src/main/java/firok/tiths/modifier/general/ModifierFarmer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package firok.tiths.modifier.general;

import firok.tiths.util.Colors;
import firok.tiths.util.DevUse;
import net.minecraft.block.BlockState;
import net.minecraft.block.CropsBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootParameters;
import net.minecraft.world.World;
import slimeknights.tconstruct.library.modifiers.Modifier;
import slimeknights.tconstruct.library.tools.nbt.IModifierToolStack;

import java.util.ArrayList;
import java.util.List;

import static firok.tiths.util.Predicates.canTrigger;

/**
* 农场主
*
* with a chance to double the loots when harvesting crops.
*
* https://github.com/351768593/MinecraftTinkersThings/blob/indev1122/src/main/java/firok/tiths/traits/TraitFarmer.java
*/
@DevUse
public class ModifierFarmer extends Modifier
{
public ModifierFarmer()
{
super(Colors.ForestGreen);
}

public List<ItemStack> processLoot(IModifierToolStack tool, int level, List<ItemStack> loots, LootContext context)
{
World world = context.getWorld();
BlockState state = context.get(LootParameters.BLOCK_STATE);

if(world.isRemote || state == null || !canTrigger(world, 0.4f) || !(state.getBlock() instanceof CropsBlock)) return loots;
try
{
List<ItemStack> extraLoots = new ArrayList<>(2);

for(ItemStack loot : loots)
{
final int maxSize = loot.getMaxStackSize();
final int nowSize = loot.getCount();
if(nowSize == 0) continue;

if(nowSize + nowSize > maxSize)
{
loot.setCount(maxSize);
ItemStack lootExtra = loot.copy();
lootExtra.setCount(maxSize - nowSize);
extraLoots.add(lootExtra);
}
else
{
loot.setCount(nowSize + nowSize);
}
}

loots.addAll(extraLoots);
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("处理loot发生错误");
}
return loots;
}
}
70 changes: 70 additions & 0 deletions src/main/java/firok/tiths/modifier/general/ModifierGluttonic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package firok.tiths.modifier.general;

import firok.tiths.config.ConfigModifier;
import firok.tiths.util.DevUse;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.FoodStats;
import slimeknights.tconstruct.library.modifiers.Modifier;
import slimeknights.tconstruct.library.tools.context.ToolAttackContext;
import slimeknights.tconstruct.library.tools.nbt.IModifierToolStack;

/**
* 暴食
*
* https://github.com/351768593/MinecraftTinkersThings/blob/indev1122/src/main/java/firok/tiths/traits/TraitGluttonic.java
* */
@DevUse
public class ModifierGluttonic extends Modifier
{
public ModifierGluttonic()
{
super(0x752b40);
}

public float getEntityDamage(IModifierToolStack tool, int level, ToolAttackContext context, float baseDamage, float damage)
{
// 1.12.2 we didn't do this.
return damage + 1.5f;
}

@Override
public int afterEntityHit(IModifierToolStack tool, int level, ToolAttackContext context, float damageDealt)
{
PlayerEntity player = context.getPlayerAttacker();
LivingEntity target = context.getLivingTarget();
if(player != null && player.isServerWorld() && target != null)
{
player.addPotionEffect(new EffectInstance(Effects.HUNGER, 125, 0));

if(target.getHealth() < 0) // dead
{
FoodStats fs = player.getFoodStats();
fs.setFoodLevel(fs.getFoodLevel() + ConfigModifier.factor_gluttonic_food.get());
}
}

return 0;
}
}
/*
在player.dat中,有4个字段是关于饥饿系统的:
食物水平(foodLevel):它表示玩家目前的饥饿值,取值范围是从0到20,显示在饥饿条上。1点等于1(半个“鸡腿”)。初始值为20(即满饥饿值)。
食物饱和度(foodSaturationLevel):它表示玩家目前的饱和度等级,决定了饥饿度下降的速度,吃不同种类的食物补充的饱和度不同。这是一项隐藏的食物变量,这个变量的值是无法超过食物水平的,其初始值为5。当饱和度降至0时,饥饿条会规律地颤抖。
食物计刻表(foodTickTimer):当食物水平为18时,它就会以刻(1/20秒)为单位来增加。当其到达80(4秒)时,就会重设至0,并且对玩家生命值治疗或者伤害1(Half Heart.svg)。如果玩家的饥饿值是满的即20,玩家生命值会恢复1(Half Heart.svg)的1⁄6,最多回复1(Half Heart.svg)生命值,当食物计刻表达到了10(1⁄2秒),就会重置为0。
饥饿等级(foodExhaustionLevel):玩家目前的饥饿等级,它决定了食物饱和度下降的速度,取值范围是从0.0到4.0。玩家的每项行动都会增加它。初始的数值为0,当饥饿等级到达4.0时,它会自动归零,并且从食物饱和度或者食物水平(当食物饱和度等于0时)减去1点。注意的是如果饱和度不足1将减为0,不会从饥饿值中扣除点数。
食用食物同时补充饥饿值和饱和度,先补充的是饥饿值,饥饿值的提高也允许了饱和度的提高(因为饱和度不能超过饥饿值)。例如,玩家吃下一个金胡萝卜(补充6饥饿值,14.4饱和度),吃之前饥饿值为9,饱和度低于1,那么饥饿值会升至15,金胡萝卜提供的饱和度也会被充分利用。然而,如果吃之前饥饿值低于9,一部分的饱和度就浪费掉了。
效果
当饥饿值在20,且仍有富余饱和度时,生命值每半秒回复最多1(Half Heart.svg),每点生命值消耗1.5食物水平(6饥饿等级)。
若玩家生命值已满,则多余的饥饿值会保留到玩家受伤时进行快速恢复。[1]
当饥饿值在18或更高,且没有多余饱和度时,生命值每4秒回复最多1(Half Heart.svg),每点生命值消耗1.5食物水平(6饥饿等级)。
当饥饿值在17或更低,玩家的生命值不会自行回复,除非处于和平模式。
当饥饿值在6或者以下时,玩家将不能进行奔跑。
当饥饿值降低到0时,玩家的生命值将会以每4秒1(Half Heart.svg)的速度减少(此时不能睡觉)。
在简单难度下,玩家的生命值将只会减少到10;
在普通难度下,玩家的生命值只会减少到1),
而在困难难度下,若不立即进食,你的生命值将会不断减少至0(死亡)。[2]
*/

0 comments on commit 94e6c64

Please sign in to comment.