Skip to content

Commit

Permalink
Bug fix:
Browse files Browse the repository at this point in the history
- Fixed the server crash issues
- Added first gift and recipe for the manual
  • Loading branch information
TartaricAcid committed Oct 16, 2021
1 parent 4412545 commit b615495
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public EntityChairRenderer(EntityRendererManager rendererManager) {
@Override
public void render(EntityChair chair, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) {
// 读取默认模型,用于清除不存在模型的缓存残留
// TODO: 2021/10/16 玩家 Shift 时渲染其碰撞箱
CustomPackLoader.CHAIR_MODELS.getModel(DEFAULT_CHAIR_ID).ifPresent(model -> this.model = model);
CustomPackLoader.CHAIR_MODELS.getInfo(DEFAULT_CHAIR_ID).ifPresent(info -> this.mainInfo = info);
this.mainAnimations = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private static int reloadAllPack(CommandContext<CommandSource> context) {
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ReloadResourceEvent::reloadAllPack);
DistExecutor.safeRunWhenOn(Dist.DEDICATED_SERVER, () -> PackCommand::sendPackToClient);
ServerCustomPackLoader.reloadPacks();
// TODO:打印加载的时间到客户端聊天栏
context.getSource().sendSuccess(new TranslationTextComponent("commands.touhou_little_maid.pack.reload.info"), true);
return Command.SINGLE_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import net.minecraft.data.DataGenerator;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.ShapedRecipeBuilder;
import net.minecraft.data.ShapelessRecipeBuilder;
import net.minecraft.item.Items;
import net.minecraft.tags.ItemTags;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.ForgeRecipeProvider;
import vazkii.patchouli.common.item.PatchouliItems;

import java.util.function.Consumer;

Expand Down Expand Up @@ -37,5 +39,9 @@ protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer) {
.pattern("IPI")
.unlockedBy("chair", has(Blocks.WATER))
.save(consumer);
ShapelessRecipeBuilder.shapeless(PatchouliItems.book)
.requires(Tags.Items.DYES_WHITE).requires(Tags.Items.DYES_RED).requires(Items.BOOK)
.unlockedBy("book", has(Items.BOOK))
.save(consumer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.tartaricacid.touhoulittlemaid.api.event.InteractMaidEvent;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.init.InitItems;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
Expand All @@ -12,26 +13,26 @@
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import javax.annotation.Nullable;
import java.util.List;

import static com.github.tartaricacid.touhoulittlemaid.item.MaidGroup.MAIN_TAB;

@Mod.EventBusSubscriber
public class ItemSubstituteJizo extends Item {
public ItemSubstituteJizo() {
super((new Properties()).tab(MAIN_TAB).stacksTo(1));
MinecraftForge.EVENT_BUS.register(this);
}

@SubscribeEvent
public void onEntityInteract(InteractMaidEvent event) {
public static void onEntityInteract(InteractMaidEvent event) {
EntityMaid maid = event.getMaid();
ItemStack stack = event.getStack();
PlayerEntity player = event.getPlayer();
if (maid.isOwnedBy(player) && stack.getItem() == this && !maid.getIsInvulnerable()) {
if (maid.isOwnedBy(player) && stack.getItem() == InitItems.SUBSTITUTE_JIZO.get() && !maid.getIsInvulnerable()) {
maid.setEntityInvulnerable(true);
stack.shrink(1);
event.setCanceled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.util.ItemsUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.DamageSource;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.EventPriority;
Expand All @@ -27,6 +29,7 @@ public void onLivingDamage(MaidDamageEvent event) {
ItemStack stack = maid.getMaidBauble().getStackInSlot(slot);
stack.hurtAndBreak(1, maid, m -> maid.sendItemBreakMessage(stack));
maid.getMaidBauble().setStackInSlot(slot, stack);
maid.addEffect(new EffectInstance(Effects.FIRE_RESISTANCE, 300));
if (!maid.level.isClientSide) {
maid.level.addFreshEntity(new EntityExtinguishingAgent(maid.level, maid.position()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"criteria": {
"tick": {
"trigger": "minecraft:tick"
}
},
"rewards": {
"loot": [
"touhou_little_maid:grant_book_on_first_join"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "advancement_reward",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "item",
"name": "patchouli:guide_book",
"functions": [
{
"function": "set_nbt",
"tag": "{'patchouli:book': 'touhou_little_maid:memorizable_gensokyo'}"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"tag": "forge:dyes/white"
},
{
"tag": "forge:dyes/red"
},
{
"item": "minecraft:book"
}
],
"result": {
"type": "minecraft:item_nbt",
"item": "patchouli:guide_book",
"nbt": {
"patchouli:book": "touhou_little_maid:memorizable_gensokyo"
}
}
}

0 comments on commit b615495

Please sign in to comment.