-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
是时候展示真正的绝活了:@mod(dist = Dist.CLIENT)
No @mod will be loaded on dedicated server!
- Loading branch information
Showing
9 changed files
with
309 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,44 @@ | ||
org.gradle.jvmargs=-Xmx3G | ||
org.gradle.daemon=false | ||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties. | ||
org.gradle.jvmargs=-Xmx1G | ||
org.gradle.daemon=true | ||
org.gradle.parallel=true | ||
org.gradle.caching=true | ||
org.gradle.configuration-cache=true | ||
|
||
#read more on this at https://github.com/neoforged/ModDevGradle?tab=readme-ov-file#better-minecraft-parameter-names--javadoc-parchment | ||
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started | ||
parchment_minecraft_version=1.21 | ||
parchment_mappings_version=2024.07.07 | ||
# Environment Properties | ||
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge | ||
# The Minecraft version must agree with the Neo version to get a valid artifact | ||
minecraft_version=1.21.1 | ||
# The Minecraft version range can use any release version of Minecraft as bounds. | ||
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly | ||
# as they do not follow standard versioning conventions. | ||
minecraft_version_range=[1.21,1.21.1) | ||
# The Neo version must agree with the Minecraft version to get a valid artifact | ||
neo_version=21.1.4 | ||
# The Neo version range can use any version of Neo as bounds | ||
neo_version_range=[21.0.0-beta,) | ||
# The loader version range can only use the major version of FML as bounds | ||
loader_version_range=[4,) | ||
|
||
## Mod Properties | ||
|
||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63} | ||
# Must match the String constant located in the main mod class annotated with @Mod. | ||
mod_id=xibao | ||
# The human-readable display name for the mod. | ||
mod_name=Xibao | ||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. | ||
mod_license=UNLICENSE | ||
# The mod version. See https://semver.org/ | ||
mod_version=4.0.0 | ||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. | ||
# This should match the base package used for the mod sources. | ||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html | ||
mod_group_id=org.teacon | ||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list. | ||
mod_authors=IzzelAliz | ||
mod_description=Xibao????: Good News |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,27 @@ | ||
package org.teacon.xibao; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import com.mojang.blaze3d.vertex.BufferBuilder; | ||
import com.mojang.blaze3d.vertex.DefaultVertexFormat; | ||
import com.mojang.blaze3d.vertex.Tesselator; | ||
import com.mojang.blaze3d.vertex.VertexFormat; | ||
import net.minecraft.client.gui.components.Button; | ||
import net.minecraft.client.gui.screens.DisconnectedScreen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.client.event.ScreenEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.IExtensionPoint; | ||
import net.minecraftforge.fml.ModLoadingContext; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.loading.FMLPaths; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.fml.loading.FMLPaths; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@Mod("xibao") | ||
@Mod(value = "xibao", dist = Dist.CLIENT) | ||
public class Xibao { | ||
|
||
@Mod.EventBusSubscriber(modid = "xibao", value = Dist.CLIENT) | ||
public static final class XibaoImpl { | ||
private static final ResourceLocation LOCATION = new ResourceLocation("xibao", "textures/xibao.png"); | ||
|
||
@SubscribeEvent | ||
public static void on(ScreenEvent.Init.Post event) { | ||
var showXibao = !Files.exists(getXibaoStopFile()); | ||
if (showXibao && event.getScreen() instanceof DisconnectedScreen s) { | ||
var translatable = Component.translatable("xibao.do_not_show_again"); | ||
event.addListener(Button | ||
.builder(translatable, XibaoImpl::onPress) | ||
.pos(s.width / 2 - 75, s.height - 30).size(150, 20).build()); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public static void on(ScreenEvent.BackgroundRendered event) { | ||
var showXibao = !Files.exists(getXibaoStopFile()); | ||
if (showXibao && event.getScreen() instanceof DisconnectedScreen s) { | ||
Tesselator tesselator = Tesselator.getInstance(); | ||
BufferBuilder bufferbuilder = tesselator.getBuilder(); | ||
RenderSystem.setShaderTexture(0, LOCATION); | ||
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); | ||
bufferbuilder.vertex(0.0D, s.height, 0.0D).uv(0F, 1F).color(255, 255, 255, 255).endVertex(); | ||
bufferbuilder.vertex(s.width, s.height, 0.0D).uv(1F, 1F).color(255, 255, 255, 255).endVertex(); | ||
bufferbuilder.vertex(s.width, 0.0D, 0.0D).uv(1F, 0F).color(255, 255, 255, 255).endVertex(); | ||
bufferbuilder.vertex(0.0D, 0.0D, 0.0D).uv(0F, 0F).color(255, 255, 255, 255).endVertex(); | ||
tesselator.end(); | ||
} | ||
} | ||
|
||
private static void onPress(Button btn) { | ||
try (var out = Files.newBufferedWriter(getXibaoStopFile())) { | ||
out.write("Remove this file to show Xibao again\n"); | ||
} catch (IOException e) { | ||
return; | ||
} | ||
btn.active = false; | ||
} | ||
public static Path getXibaoStopFile() { | ||
return FMLPaths.GAMEDIR.get().resolve(".xibao_stop"); | ||
} | ||
|
||
private static Path getXibaoStopFile() { | ||
return FMLPaths.GAMEDIR.get().resolve(".xibao_stop"); | ||
public static void onPress(Button btn) { | ||
try (var out = Files.newBufferedWriter(getXibaoStopFile())) { | ||
out.write("Remove this file to show Xibao again\n"); | ||
} catch (IOException e) { | ||
return; | ||
} | ||
btn.active = false; | ||
} | ||
} |
Oops, something went wrong.