Skip to content

Commit

Permalink
Merge pull request #4 from dfdyz/latest
Browse files Browse the repository at this point in the history
更新的了不少东西
  • Loading branch information
dfdyz authored Nov 12, 2024
2 parents 2b93d31 + f94ee49 commit e870ab2
Show file tree
Hide file tree
Showing 62 changed files with 2,601 additions and 483 deletions.
22 changes: 11 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ repositories {
dir 'libs'
}

maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}

maven { url = 'https://maven.minecraftforge.net' }
maven {
name = 'tterrag maven'
Expand All @@ -146,15 +153,6 @@ repositories {

maven { url 'https://maven.valkyrienskies.org/' }


// Add KFF Maven repository
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}

repositories {
maven { url = "https://maven.bawnorton.com/releases" }
}
Expand Down Expand Up @@ -199,7 +197,7 @@ dependencies {
implementation("org.joml:joml-primitives:1.10.0") { transitive = false }

// cc:t dependencies
implementation fg.deobf("curse.maven:cc-tweaked-282001:5379173")
implementation fg.deobf("curse.maven:cc-tweaked-282001:5714507")

//
implementation fg.deobf("libs:peripheralium-forge:1.20.1-0.6.15")
Expand All @@ -216,7 +214,9 @@ dependencies {
// Toms peripheral
//implementation fg.deobf("curse.maven:toms-peripheral-931210:5265063")


// VS CW
runtimeOnly fg.deobf("curse.maven:architectury-api-419699:5137938")
runtimeOnly fg.deobf("curse.maven:clockwork-807792:5580456")

annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mod_name=VoidPower
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPL3
# The mod version. See https://semver.org/
mod_version=1.1.1
mod_version=1.2.5.alpha4
# 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
Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/void_power/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"block.void_power.void_engine": "Void Engine",
"block.void_power.glass_screen":"GlassScreen",
"block.void_power.hologram":"Hologram",
"item.void_power.vr_glasses": "VR Glasses",
"itemGroup.void_power.main": "Void Power",
"gui.void_power.terminal" : "HOLOGRAM"
}
3 changes: 2 additions & 1 deletion src/generated/resources/assets/void_power/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"block.void_power.void_engine": "虚空引擎",
"block.void_power.glass_screen":"玻璃屏幕(电脑外设)",
"block.void_power.hologram":"全息显示器",
"item.void_power.vr_glasses": "VR眼镜",
"itemGroup.void_power.main": "虚空动力",
"gui.void_power.terminal" : "HOLOGRAM"
"gui.void_power.terminal" : "全息显示器(终端)"
}
33 changes: 31 additions & 2 deletions src/main/java/com/dfdyz/void_power/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,29 @@ public class Config

private static final ForgeConfigSpec.IntValue HOLOGRAM_RES_X_MAX = BUILDER
.comment("Max width can set for a hologram.")
.defineInRange("HOLOGRAM_WIDTH_MAX", 1024, 128, 4096);
.defineInRange("HOLOGRAM_WIDTH_MAX", 1024, 128, 2048);

private static final ForgeConfigSpec.IntValue HOLOGRAM_RES_Y_MAX = BUILDER
.comment("Max height can set for a hologram..")
.defineInRange("HOLOGRAM_HEIGHT_MAX", 1024, 128, 4096);
.defineInRange("HOLOGRAM_HEIGHT_MAX", 1024, 128, 2048);

private static final ForgeConfigSpec.IntValue HOLOGRAM_BUFFER_COUNT = BUILDER
.comment("Max count of frame buffer in a hologram.")
.defineInRange("HOLOGRAM_BUFFER_COUNT", 8, 2, 32);


private static final ForgeConfigSpec.BooleanValue WIRELESS_HUB_UNLIMITED = BUILDER
.comment("Remove wireless peripheral hub distance limited.")
.define("WIRELESS_HUB_UNLIMITED", true);

private static final ForgeConfigSpec.IntValue HOLOGRAM_FONT_COUNT = BUILDER
.comment("Max count of font for a hologram.")
.defineInRange("HOLOGRAM_FONT_COUNT", 2, 0, 8);

private static final ForgeConfigSpec.IntValue HOLOGRAM_FORCE_FULL_UPDATE_TICK = BUILDER
.comment("The max ticks between two sync(a tick after a call of 'hologram.Flush()') of hologram. set zero to disable forced full update.")
.defineInRange("HOLOGRAM_FORCE_FULL_UPDATE_TICK", 20, 0, 40);


static final ForgeConfigSpec SPEC = BUILDER.build();

Expand All @@ -59,10 +77,16 @@ public class Config
public static double DefaultMinPeriodFactor = 1;
public static boolean ForceUseVanillaShader = false;
public static boolean ResetControllerWhileLeft = true;
public static int HologramFontCount = 2;

public static int HologramMaxBufferCount = 8;
public static int ForceFullUpdateTick = 2;

public static int holo_w_mx = 1024;
public static int holo_h_mx = 1024;

public static boolean UnlimitDistance = true;

private static boolean validateItemName(final Object obj)
{
return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(new ResourceLocation(itemName));
Expand All @@ -77,9 +101,14 @@ static void onLoad(final ModConfigEvent event)
ForceUseVanillaShader = SCREEN_FORCED_USE_VANILLA_SHADER.get().booleanValue();
ResetControllerWhileLeft = RESET_CONTROLLER_WHEN_LEFT.get().booleanValue();

UnlimitDistance = WIRELESS_HUB_UNLIMITED.get();

holo_w_mx = HOLOGRAM_RES_X_MAX.get();
holo_h_mx = HOLOGRAM_RES_Y_MAX.get();
HologramMaxBufferCount = HOLOGRAM_BUFFER_COUNT.get();

HologramFontCount = HOLOGRAM_FONT_COUNT.get();
ForceFullUpdateTick = HOLOGRAM_FORCE_FULL_UPDATE_TICK.get();
}

}
9 changes: 8 additions & 1 deletion src/main/java/com/dfdyz/void_power/VoidPowerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.event.server.ServerStartedEvent;
Expand Down Expand Up @@ -71,6 +73,8 @@ private void commonSetup(final FMLCommonSetupEvent event)
//LOGGER.info("HELLO FROM COMMON SETUP");
}



private void clientSetup(FMLClientSetupEvent event)
{
/*
Expand All @@ -91,10 +95,13 @@ private void addCreative(BuildCreativeModeTabContentsEvent event)

@SubscribeEvent
public void onServerStarted(ServerStartedEvent event){
LOGGER.error("ServerStarted.");
//LOGGER.error("ServerStarted.");
CCUtils.context = ServerContext.get(event.getServer());
}

public static ResourceLocation getRL(String sub){
return new ResourceLocation(MODID, sub);
}

// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
//@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
Expand Down
44 changes: 29 additions & 15 deletions src/main/java/com/dfdyz/void_power/client/gui/HologramGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,28 @@ public HologramGUI(HologramMenu menu, Inventory inventory, Component p_97743_) {

float GetScale(){
float w = 0.5f,h = 0.25f;
if (te.high <= 64) h = 2;
else if (te.high <= 128) h = 1;
else if (te.high <= 256) h = 0.5f;

if (te.width <= 64) w = 4;
else if (te.width <= 128) w = 2;
else if (te.width <= 256) w = 1;

int wi = te.getWidth();
int hi = te.getHeight();


if (hi <= 64) h = 2;
else if (hi <= 128) h = 1;
else if (hi <= 256) h = 0.5f;

if (wi <= 64) w = 4;
else if (wi <= 128) w = 2;
else if (wi <= 256) w = 1;

return Math.min(w, h);
}

HologramTerminalWidget getTerminal(){
terminal_scale = GetScale();
int w = (int) (te.width * terminal_scale);
int h = (int) (te.high * terminal_scale);
int wi = te.getWidth();
int hi = te.getHeight();
int w = (int) (wi * terminal_scale);
int h = (int) (hi * terminal_scale);
return addRenderableWidget(
new HologramTerminalWidget(te, (width - w) / 2, (height - h) / 2, w, h)
);
Expand All @@ -61,14 +68,14 @@ protected void init() {
htw = addRenderableWidget(getTerminal());

name_editor = addRenderableWidget(
new EditBox(font, width / 2 - 128 - 20, htw.getY() - 30, 254, 16,
new EditBox(font, width / 2 - 128 - 20, 1, 254, 16,
Component.literal("NAME"))
);

name_editor.setValue(te.name);

set_name = addRenderableWidget(Button.builder(Component.literal("Set"), this::ChangeName)
.pos(width / 2 + 128-20, htw.getY() - 31)
.pos(width / 2 + 128-20, 1)
.size(40,18)
.build());

Expand All @@ -89,15 +96,22 @@ public void tick() {
}
if(htw.ShouldResize()){
terminal_scale = GetScale();
int w = (int) (te.width * terminal_scale);
int h = (int) (te.high * terminal_scale);
int w = (int) (te.getWidth() * terminal_scale);
int h = (int) (te.getHeight() * terminal_scale);
htw.setX((width - w) / 2);
htw.setY((height - h) / 2);
htw.setHeight(h);
htw.setWidth(w);

name_editor.setY(htw.getY() - 30);
set_name.setY(htw.getY() - 31);
if(htw.getY() + 29 < set_name.getHeight()){
name_editor.setY(htw.getY() - 30);
set_name.setY(htw.getY() - 31);
}
else {
name_editor.setY(1);
set_name.setY(1);
}

}
//htw.setFocused(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;

import java.util.BitSet;

Expand All @@ -25,13 +26,13 @@ public HologramTerminalWidget(HologramTE te, int x, int y, int w, int h) {
}

public boolean ShouldResize(){
return te.width != this.width || te.high != this.height;
return te.getWidth() != this.width || te.getHeight() != this.height;
}

@Override
protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
if (this.visible) {
if (te.buffer.length == 0)return;
if (te.getBuffer().length == 0)return;
if (te.renderCache == null)te.renderCache = new ScreenCacheImpl(te);
ResourceLocation tex = te.renderCache.getTexture();;
if (tex == null)return;
Expand All @@ -42,7 +43,7 @@ protected void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, flo
}

@Override
protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) {
protected void updateWidgetNarration(@NotNull NarrationElementOutput narrationElementOutput) {

}

Expand Down Expand Up @@ -122,8 +123,8 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (!this.inRegion(mouseX, mouseY)) {
return false;
} else if (button >= 0 && button <= 2) {
int pxX = (int)Math.floor((mouseX - this.getX()) / width * te.width);
int pxY = (int)Math.floor((mouseY - this.getY()) / height * te.high);
int pxX = (int)Math.floor((mouseX - this.getX()) / width * te.getWidth());
int pxY = (int)Math.floor((mouseY - this.getY()) / height * te.getHeight());

te.SendInputPack("vp_mouse_clicked", te.name, button + 1, pxX, pxY);

Expand All @@ -140,8 +141,8 @@ public boolean mouseReleased(double mouseX, double mouseY, int button) {
if (!this.inRegion(mouseX, mouseY)) {
return false;
} else if (button >= 0 && button <= 2) {
int pxX = (int)Math.floor((mouseX - this.getX()) / width * te.width);
int pxY = (int)Math.floor((mouseY - this.getY()) / height * te.high);
int pxX = (int)Math.floor((mouseX - this.getX()) / width * te.getWidth());
int pxY = (int)Math.floor((mouseY - this.getY()) / height * te.getHeight());

if (this.lastMouseButton == button) {
te.SendInputPack("vp_mouse_released", te.name, button + 1, pxX, pxY);
Expand All @@ -164,8 +165,8 @@ public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
if (!this.inRegion(mouseX, mouseY)) {
return false;
} else if (delta != 0.0) {
int pxX = (int)Math.floor((mouseX - this.getX()) / width * te.width);
int pxY = (int)Math.floor((mouseY - this.getY()) / height * te.high);
int pxX = (int)Math.floor((mouseX - this.getX()) / width * te.getWidth());
int pxY = (int)Math.floor((mouseY - this.getY()) / height * te.getHeight());
te.SendInputPack("vp_mouse_scrolled", te.name, delta, pxX, pxY);

this.lastMouseX = pxX;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
public class VPRenderTypes {

public static final ResourceLocation FONT = new ResourceLocation(VoidPowerMod.MODID, "textures/block/term_font.png");
public static final RenderType TERMINAL = getText(FixedWidthFontRenderer.FONT);

public static final ResourceLocation FONT_NEG = new ResourceLocation(VoidPowerMod.MODID, "textures/block/term_font_neg.png");

//public static final ResourceLocation FONT = new ResourceLocation(VoidPowerMod.MODID, "textures/block/term_font.png");
public static final RenderType TERMINAL = getText(VPRenderTypes.FONT);
public static final RenderType TERMINAL_NEG = getText(VPRenderTypes.FONT_NEG);
public static final RenderType HOLOGRAM = getHologram(FixedWidthFontRenderer.FONT);


Expand Down Expand Up @@ -70,5 +75,7 @@ public static ShaderInstance text(){
return Config.ForceUseVanillaShader ? textShader : RenderTypes.getTerminalShader();
}


public static ShaderInstance textNeg(){
return Config.ForceUseVanillaShader ? textShader : RenderTypes.getTerminalShader();
}
}
Loading

0 comments on commit e870ab2

Please sign in to comment.