Skip to content

Commit

Permalink
部分同步修正
Browse files Browse the repository at this point in the history
  • Loading branch information
Azumic committed Nov 3, 2024
1 parent 758589f commit 9aaf51e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
public class DataGenEvent {
@SubscribeEvent
public static void dataGen(GatherDataEvent event) {
event.getGenerator().addProvider(new MaidBlockStateProvider(event.getGenerator(), TouhouLittleMaid.MOD_ID, event.getExistingFileHelper()));
event.getGenerator().addProvider(new AltarRecipeProvider(event.getGenerator()));
event.getGenerator().addProvider(new MaidRecipeProvider(event.getGenerator()));
event.getGenerator().addProvider(new LootModifierProvider(event.getGenerator()));
// event.getGenerator().addProvider(new MaidBlockStateProvider(event.getGenerator(), TouhouLittleMaid.MOD_ID, event.getExistingFileHelper()));
// event.getGenerator().addProvider(new AltarRecipeProvider(event.getGenerator()));
// event.getGenerator().addProvider(new MaidRecipeProvider(event.getGenerator()));
// event.getGenerator().addProvider(new LootModifierProvider(event.getGenerator()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.tartaricacid.touhoulittlemaid.api.entity.fishing.IFishingType;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.entity.projectile.MaidFishingHook;
import net.minecraft.world.item.FishingRodItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
Expand All @@ -15,7 +16,7 @@ public class DefaultFishingType implements IFishingType {
public boolean isFishingRod(ItemStack itemStack) {
// todo check
// Fishing Rod的子类更好?
return itemStack.is(Items.FISHING_ROD);
return itemStack.getItem() instanceof FishingRodItem;
// return itemStack.canPerformAction(ToolActions.FISHING_ROD_CAST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1284,41 +1284,44 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor worldIn, DifficultyInsta
@Override
public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
super.setItemSlot(slot, stack);

// todo check
// 因为182版本没有onEquipItem方法,故放在这里,调查得知这个方法在MaidEquipEvent之前执行
this.onEquipItem(slot, stack);

if (!this.level.isClientSide) {
MinecraftForge.EVENT_BUS.post(new MaidEquipEvent(this, slot, stack));
}
}

// @Override
// public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) {
// super.onEquipItem(slot, oldItem, newItem);
// if (newItem.isEmpty() || this.firstTick || slot.getType() != EquipmentSlot.Type.ARMOR) {
// return;
// }
//
// // 触发成就
// if (this.getOwner() instanceof ServerPlayer serverPlayer) {
// InitTrigger.MAID_EVENT.trigger(serverPlayer, TriggerType.ANY_EQUIPMENT);
// }
//
// // 如果是下界合金
// if (isNetheriteArmor(newItem)) {
// // 检查全身装备
// for (EquipmentSlot slotIn : EquipmentSlot.values()) {
// if (slot.getType() != EquipmentSlot.Type.ARMOR || slotIn == slot) {
// continue;
// }
// ItemStack itemBySlot = getItemBySlot(slotIn);
// if (!isNetheriteArmor(itemBySlot)) {
// return;
// }
// }
// // 触发事件
// if (this.getOwner() instanceof ServerPlayer serverPlayer) {
// InitTrigger.MAID_EVENT.trigger(serverPlayer, TriggerType.ALL_NETHERITE_EQUIPMENT);
// }
// }
// }
public void onEquipItem(EquipmentSlot slot, ItemStack newItem) {
if (newItem.isEmpty() || this.firstTick || slot.getType() != EquipmentSlot.Type.ARMOR) {
return;
}

// 触发成就
if (this.getOwner() instanceof ServerPlayer serverPlayer) {
InitTrigger.MAID_EVENT.trigger(serverPlayer, TriggerType.ANY_EQUIPMENT);
}

// 如果是下界合金
if (isNetheriteArmor(newItem)) {
// 检查全身装备
for (EquipmentSlot slotIn : EquipmentSlot.values()) {
if (slotIn.getType() != EquipmentSlot.Type.ARMOR || slotIn == slot) {
continue;
}
ItemStack itemBySlot = getItemBySlot(slotIn);
if (!isNetheriteArmor(itemBySlot)) {
return;
}
}
// 触发事件
if (this.getOwner() instanceof ServerPlayer serverPlayer) {
InitTrigger.MAID_EVENT.trigger(serverPlayer, TriggerType.ALL_NETHERITE_EQUIPMENT);
}
}
}

private boolean isNetheriteArmor(ItemStack stack) {
if (stack.getItem() instanceof ArmorItem armorItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public AnimatedGeoModel getCurrentModel() {
}

public double getCurrentTick(AnimationEvent<?> animationEvent) {
//todo 访问变压器
//todo check 访问变压器?
//getPartialTick()在Minecraft.runTick里头用到
// Minecraft mc = Minecraft.getInstance();
// this.pause ? this.pausePartialTick : this.timer.partialTick
float partialTick = animationEvent.getPartialTick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class FishingHookPredicateMixin {
@Final
private boolean inOpenWater;

// @Inject(method = "matches(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/phys/Vec3;)Z", at = @At("RETURN"), cancellable = true)
// private void matches(Entity entity, ServerLevel level, Vec3 position, CallbackInfoReturnable<Boolean> cir) {
// FishingHookPredicate predicate = (FishingHookPredicate) (Object) this;
// if (predicate != FishingHookPredicate.ANY && entity instanceof MaidFishingHook fishingHook) {
// cir.setReturnValue(this.inOpenWater == fishingHook.isOpenWaterFishing());
// }
// }
@Inject(method = "matches", at = @At("RETURN"), cancellable = true)
private void matches$tlm(Entity entity, CallbackInfoReturnable<Boolean> cir) {
FishingHookPredicate predicate = (FishingHookPredicate) (Object) this;
if (predicate != FishingHookPredicate.ANY && entity instanceof MaidFishingHook fishingHook) {
cir.setReturnValue(this.inOpenWater == fishingHook.isOpenWaterFishing());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
@SuppressWarnings("all")
@Mixin(ItemProperties.class)
public class ItemPropertiesMixin {
//todo check
//找不着,不知是哪个
// @Inject(method = "lambda$static$18(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/client/multiplayer/ClientLevel;Lnet/minecraft/world/entity/LivingEntity;I)F", at = @At("HEAD"), cancellable = true)
// private static void onItemRender(ItemStack stack, @Nullable ClientLevel pLevel, @Nullable LivingEntity entity, int pSeed, CallbackInfoReturnable<Float> ci) {
// if (entity instanceof EntityMaid maid && maid.getMainHandItem() == stack) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/touhou_little_maid.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
"refmap": "touhou_little_maid.refmap.json",
"mixins": [
"EntityMixin",
"FishingHookPredicateMixin",
"MixinArrowEntity"
],
"client": [
"client.HumanoidModelMixin", "client.ItemPropertiesMixin", "client.LanguageMixin",
"client.HumanoidModelMixin",
"client.ItemPropertiesMixin",
"client.LanguageMixin",
"client.LivingEntityRendererMixin"
],
"injectors": {
Expand Down

0 comments on commit 9aaf51e

Please sign in to comment.