Skip to content

Commit

Permalink
完成 1.20 #1b5e2463f97e22c2eae63241c9a3abbb85a658c8 的更新内容
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Oct 30, 2023
1 parent 896550c commit ca8b276
Show file tree
Hide file tree
Showing 144 changed files with 5,077 additions and 677 deletions.
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://maven.parchmentmc.org' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.parchmentmc:librarian:1.+'
classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
}
}

apply plugin: 'eclipse'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'java'

version = mod_version
group = 'com.github.tartaricacid'
Expand All @@ -25,6 +29,7 @@ minecraft {
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
jvmArgs "-XX:+AllowEnhancedClassRedefinition"
workingDirectory project.file('run/client_a')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
Expand All @@ -50,6 +55,7 @@ minecraft {
}

server {
jvmArgs "-XX:+AllowEnhancedClassRedefinition"
workingDirectory project.file('run/server')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
Expand Down Expand Up @@ -80,6 +86,11 @@ minecraft {

sourceSets.main.resources { srcDir 'src/generated/resources' }

mixin {
add sourceSets.main, "touhou_little_maid.refmap.json"
config "touhou_little_maid.mixins.json"
}

repositories {
maven {
// location of the maven that hosts JEI files
Expand Down Expand Up @@ -113,6 +124,9 @@ repositories {
name = "ModMaven"
url = "https://modmaven.dev"
}
maven {
url "https://maven.shedaniel.me/"
}
}

dependencies {
Expand All @@ -128,6 +142,13 @@ dependencies {
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}")

implementation fg.deobf("teamtwilight:twilightforest:${twilight_forest_version}:universal")

implementation fg.deobf("curse.maven:jade-324717:${jade_id}")
implementation fg.deobf("curse.maven:the-one-probe-245211:${top_id}")

implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:${cloth_config_forge}")

annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

jar {
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ jei_version=7.6.1.75
top_version=1.16-3.1.3-21
patchouli_version=1.16.4-50
twilight_forest_version=4.0.870
jade_id=3910873
top_id=3319255
cloth_config_forge=4.17.101
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.tartaricacid.touhoulittlemaid.api.ILittleMaid;
import com.github.tartaricacid.touhoulittlemaid.block.multiblock.MultiBlockManager;
import com.github.tartaricacid.touhoulittlemaid.compat.cloth.MenuIntegration;
import com.github.tartaricacid.touhoulittlemaid.config.GeneralConfig;
import com.github.tartaricacid.touhoulittlemaid.entity.chatbubble.ChatBubbleManger;
import com.github.tartaricacid.touhoulittlemaid.entity.task.TaskManager;
Expand All @@ -10,7 +11,10 @@
import com.github.tartaricacid.touhoulittlemaid.network.NetworkHandler;
import com.github.tartaricacid.touhoulittlemaid.util.AnnotatedInstanceUtil;
import com.google.common.collect.Lists;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
Expand All @@ -23,6 +27,7 @@
@Mod(TouhouLittleMaid.MOD_ID)
public final class TouhouLittleMaid {
public static final String MOD_ID = "touhou_little_maid";
private static final String CLOTH_CONFIG = "cloth-config";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
public static List<ILittleMaid> EXTENSIONS = Lists.newArrayList();

Expand All @@ -42,11 +47,18 @@ public TouhouLittleMaid() {
InitLootModifier.GLOBAL_LOOT_MODIFIER_SERIALIZER.register(FMLJavaModLoadingContext.get().getModEventBus());
InitTrigger.init();
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, GeneralConfig.init());
checkModLoad(CLOTH_CONFIG, () -> DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> MenuIntegration::registerModsPage));
DeferredWorkQueue.runLater(NetworkHandler::init);
EXTENSIONS = AnnotatedInstanceUtil.getModExtensions();
TaskManager.init();
BaubleManager.init();
MultiBlockManager.init();
ChatBubbleManger.initDefaultChat();
}

private static void checkModLoad(String modId, Runnable runnable) {
if (ModList.get().isLoaded(modId)) {
runnable.run();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.github.tartaricacid.touhoulittlemaid.advancements;

import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid;
import com.github.tartaricacid.touhoulittlemaid.config.subconfig.MiscConfig;
import com.google.gson.JsonObject;
import net.minecraft.advancements.criterion.AbstractCriterionTrigger;
import net.minecraft.advancements.criterion.CriterionInstance;
import net.minecraft.advancements.criterion.EntityPredicate;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.loot.ConditionArrayParser;
import net.minecraft.util.ResourceLocation;

public class GivePatchouliBookConfigTrigger extends AbstractCriterionTrigger<GivePatchouliBookConfigTrigger.Instance> {
public static final ResourceLocation ID = new ResourceLocation(TouhouLittleMaid.MOD_ID, "give_patchouli_book_config");

@Override
protected Instance createInstance(JsonObject json, EntityPredicate.AndPredicate entityPredicate, ConditionArrayParser conditionsParser) {
return new Instance(entityPredicate);
}

@Override
public ResourceLocation getId() {
return ID;
}


public void trigger(ServerPlayerEntity serverPlayer) {
super.trigger(serverPlayer, instance -> MiscConfig.GIVE_PATCHOULI_BOOK.get());
}

public static class Instance extends CriterionInstance {
public Instance(EntityPredicate.AndPredicate player) {
super(ID, player);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

@Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public final class ReloadResourceEvent {
public static final ResourceLocation EMPTY_BAUBLE_SLOT = new ResourceLocation(TouhouLittleMaid.MOD_ID, "items/empty_bauble_slot");
public static final ResourceLocation EMPTY_MAINHAND_SLOT = new ResourceLocation(TouhouLittleMaid.MOD_ID, "items/empty_mainhand_slot");
public static final ResourceLocation EMPTY_BACK_SHOW_SLOT = new ResourceLocation(TouhouLittleMaid.MOD_ID, "items/empty_back_show_slot");
public static final ResourceLocation EMPTY_BAUBLE_SLOT = new ResourceLocation(TouhouLittleMaid.MOD_ID, "slot/empty_bauble_slot");
public static final ResourceLocation EMPTY_MAINHAND_SLOT = new ResourceLocation(TouhouLittleMaid.MOD_ID, "slot/empty_mainhand_slot");
public static final ResourceLocation BLOCK_ATLAS_TEXTURE = new ResourceLocation("textures/atlas/blocks.png");
public static final ResourceLocation EMPTY_BACK_SHOW_SLOT = new ResourceLocation(TouhouLittleMaid.MOD_ID, "slot/empty_back_show_slot");

@SubscribeEvent
public static void onTextureStitchEventPost(TextureStitchEvent.Post event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.github.tartaricacid.touhoulittlemaid.api.task.IMaidTask;
import com.github.tartaricacid.touhoulittlemaid.client.download.InfoGetManager;
import com.github.tartaricacid.touhoulittlemaid.client.download.pojo.DownloadInfo;
import com.github.tartaricacid.touhoulittlemaid.client.gui.entity.model.MaidModelGui;
import com.github.tartaricacid.touhoulittlemaid.client.gui.entity.ModelDownloadGui;
import com.github.tartaricacid.touhoulittlemaid.client.gui.entity.model.MaidModelGui;
import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.MaidTabButton;
import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.ScheduleButton;
import com.github.tartaricacid.touhoulittlemaid.client.gui.widget.button.TaskButton;
Expand All @@ -16,6 +16,8 @@
import com.github.tartaricacid.touhoulittlemaid.network.NetworkHandler;
import com.github.tartaricacid.touhoulittlemaid.network.message.MaidConfigMessage;
import com.github.tartaricacid.touhoulittlemaid.network.message.MaidTaskMessage;
import com.github.tartaricacid.touhoulittlemaid.network.message.RequestEffectMessage;
import com.github.tartaricacid.touhoulittlemaid.network.message.SendEffectMessage;
import com.github.tartaricacid.touhoulittlemaid.util.ParseI18n;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
Expand All @@ -26,10 +28,12 @@
import net.minecraft.client.gui.screen.inventory.InventoryScreen;
import net.minecraft.client.gui.widget.ToggleWidget;
import net.minecraft.client.gui.widget.button.ImageButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.IReorderingProcessor;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraft.util.text.*;

import java.util.Collections;
Expand Down Expand Up @@ -60,6 +64,7 @@ public abstract class AbstractMaidContainerGui<T extends AbstractMaidContainer>
private ImageButton soundDownload;
private ScheduleButton<T> scheduleButton;
private boolean taskListOpen;
private int counterTime = 0;

public AbstractMaidContainerGui(T screenContainer, PlayerInventory inv, ITextComponent titleIn) {
super(screenContainer, inv, titleIn);
Expand Down Expand Up @@ -89,6 +94,7 @@ protected void init() {
@SuppressWarnings("all")
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
super.render(matrixStack, mouseX, mouseY, partialTicks);
this.drawEffectInfo(matrixStack);
this.drawCurrentTaskText(matrixStack);
this.renderTooltip(matrixStack, mouseX, mouseY);
}
Expand All @@ -104,6 +110,45 @@ protected void renderBg(MatrixStack matrixStack, float partialTicks, int x, int
this.drawTaskListBg(matrixStack);
}

@SuppressWarnings("all")
private void drawEffectInfo(MatrixStack matrixStack) {
if (taskListOpen) {
return;
}
List<SendEffectMessage.EffectData> effects = maid.getEffects();
if (!effects.isEmpty()) {
int yOffset = 5;
for (SendEffectMessage.EffectData effect : effects) {
IFormattableTextComponent text = new TranslationTextComponent(effect.descriptionId);
if (effect.amplifier >= 1 && effect.amplifier <= 9) {
IFormattableTextComponent levelText = new TranslationTextComponent("enchantment.level." + (effect.amplifier + 1));
text = text.append(" ").append(levelText);
}
String duration;
if (effect.duration == -1) {
duration = I18n.get("effect.duration.infinite");
} else {
duration = StringUtils.formatTickDuration(effect.duration);
}
text = text.append(" ").append(duration);
drawString(matrixStack, font, text, leftPos - font.width(text) - 3, topPos + yOffset + 5, getPotionColor(effect.category));
yOffset += 10;
}
}
}

@SuppressWarnings("all")
private int getPotionColor(int category) {
switch (category) {
case 0:
return TextFormatting.GREEN.getColor();
case 1:
return TextFormatting.RED.getColor();
default:
return TextFormatting.BLUE.getColor();
}
}

@Override
protected void renderTooltip(MatrixStack matrixStack, int x, int y) {
super.renderTooltip(matrixStack, x, y);
Expand Down Expand Up @@ -397,6 +442,14 @@ private void drawBaseInfoGui(MatrixStack matrixStack) {
blit(matrixStack, leftPos + 6, topPos + 168, 0, 47, 67, 25);
}

@Override
public void tick() {
counterTime += 1;
if (counterTime % 20 == 0 && maid != null) {
NetworkHandler.CHANNEL.sendToServer(new RequestEffectMessage(maid.getId()));
}
}

@Override
public int getGuiLeft() {
if (taskListOpen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class TileEntityEntityPlaceholderRenderer extends ItemStackTileEntityRenderer {
private static final EntityPlaceholderModel BASE_MODEL = new EntityPlaceholderModel();
private static final ResourceLocation TEXTURE = new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/items/entity_placeholder.png");
private static final ResourceLocation TEXTURE = new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/item/entity_placeholder.png");

@Override
public void renderByItem(ItemStack stack, ItemCameraTransforms.TransformType transformType, MatrixStack matrixStack, IRenderTypeBuffer bufferIn, int combinedLight, int combinedOverlay) {
Expand All @@ -37,7 +37,7 @@ private ResourceLocation getTexture(ItemStack stack) {
if (recipeId != null) {
Path path = Paths.get(recipeId.getPath().toLowerCase(Locale.US));
String namespace = recipeId.getNamespace().toLowerCase(Locale.US);
ResourceLocation texture = new ResourceLocation(namespace, String.format("textures/items/%s.png", path.getFileName().toString()));
ResourceLocation texture = new ResourceLocation(namespace, String.format("textures/item/%s.png", path.getFileName().toString()));
if (Minecraft.getInstance().getResourceManager().hasResource(texture)) {
return texture;
}
Expand Down
Loading

0 comments on commit ca8b276

Please sign in to comment.