Config and minor improvements
This commit is contained in:
parent
ca2c5aa93e
commit
a166e94656
6 changed files with 114 additions and 3 deletions
|
@ -2,21 +2,65 @@ package su.a71.new_soviet;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.SignBlock;
|
||||||
|
import net.minecraft.block.entity.SignText;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
|
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
|
||||||
|
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.text.OrderedText;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.RotationAxis;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import org.joml.Matrix4f;
|
||||||
import su.a71.new_soviet.entity.TVBlockEntity;
|
import su.a71.new_soviet.entity.TVBlockEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class TVBlockEntityRenderer implements BlockEntityRenderer<TVBlockEntity> {
|
public class TVBlockEntityRenderer implements BlockEntityRenderer<TVBlockEntity> {
|
||||||
public TVBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {}
|
private static TextRenderer textRenderer;
|
||||||
|
private static final Vec3d TEXT_OFFSET = new Vec3d(0.0, 0.3333333432674408, 0.046666666865348816);
|
||||||
|
|
||||||
|
|
||||||
|
public TVBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {
|
||||||
|
textRenderer = ctx.getTextRenderer();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(TVBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
public void render(TVBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||||
matrices.push();
|
matrices.push();
|
||||||
// Rendering stuff here
|
// Rendering stuff here
|
||||||
|
// this.setTextAngles(matrices, true, TEXT_OFFSET);
|
||||||
|
// textRenderer.draw("Test amogus", 0, 0, 999999, false, matrices.peek().getPositionMatrix(), vertexConsumers, TextRenderer.TextLayerType.POLYGON_OFFSET, 19999, light);
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getScale() {
|
||||||
|
return 0.6666667F;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setAngles(MatrixStack matrices, float rotationDegrees, BlockState state) {
|
||||||
|
matrices.translate(0.5F, 0.75F * this.getScale(), 0.5F);
|
||||||
|
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(rotationDegrees));
|
||||||
|
if (!(state.getBlock() instanceof SignBlock)) {
|
||||||
|
matrices.translate(0.0F, -0.3125F, -0.4375F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTextAngles(MatrixStack matrices, boolean front, Vec3d translation) {
|
||||||
|
if (!front) {
|
||||||
|
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
float f = 0.015625F * this.getScale();
|
||||||
|
matrices.translate(translation.x, translation.y, translation.z);
|
||||||
|
matrices.scale(f, -f, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
55
src/main/java/su/a71/new_soviet/Config.java
Normal file
55
src/main/java/su/a71/new_soviet/Config.java
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package su.a71.new_soviet;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
private boolean invert_lamps = false;
|
||||||
|
|
||||||
|
public static Config INSTANCE;
|
||||||
|
|
||||||
|
public Config() {
|
||||||
|
INSTANCE = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldInvertLamps() {
|
||||||
|
return invert_lamps;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void generateDefault() {
|
||||||
|
File file = new File("config/new_soviet.json");
|
||||||
|
if(!file.getParentFile().exists()) {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
INSTANCE = new Config();
|
||||||
|
try {
|
||||||
|
FileWriter writer = new FileWriter(file);
|
||||||
|
writer.write(NewSoviet.GSON.toJson(INSTANCE));
|
||||||
|
writer.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
INSTANCE = new Config();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void load() {
|
||||||
|
// Generate config if it doesn't exist
|
||||||
|
File file = new File("config/new_soviet.json");
|
||||||
|
if(!file.exists()) {
|
||||||
|
generateDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String s;
|
||||||
|
while((s = reader.readLine()) != null)
|
||||||
|
sb.append(s);
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
INSTANCE = NewSoviet.GSON.fromJson(sb.toString(), Config.class);
|
||||||
|
} catch(Exception e) {
|
||||||
|
INSTANCE = new Config();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,8 @@ public class NewSoviet implements ModInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
|
Config.load();
|
||||||
|
|
||||||
NSE_Blocks.init();
|
NSE_Blocks.init();
|
||||||
NSE_Items.init();
|
NSE_Items.init();
|
||||||
NSE_Custom.init();
|
NSE_Custom.init();
|
||||||
|
|
BIN
src/main/resources/assets/new_soviet/icon.png
Normal file
BIN
src/main/resources/assets/new_soviet/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 177 KiB |
|
@ -204,5 +204,6 @@
|
||||||
"block.new_soviet.brown_wallpaper": "Brown Wallpaper Block",
|
"block.new_soviet.brown_wallpaper": "Brown Wallpaper Block",
|
||||||
"block.new_soviet.beige_wallpaper": "Beige Wallpaper Block",
|
"block.new_soviet.beige_wallpaper": "Beige Wallpaper Block",
|
||||||
"block.new_soviet.purple_goo": "Purple Goo",
|
"block.new_soviet.purple_goo": "Purple Goo",
|
||||||
"subtitles.new_soviet.switch_press": "Switch clicks"
|
"subtitles.new_soviet.switch_press": "Switch clicks",
|
||||||
|
"subtitles.new_soviet.electric_hit": "Electric sparks"
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@
|
||||||
"homepage": "https://nse.a71.su/",
|
"homepage": "https://nse.a71.su/",
|
||||||
"sources": "https://git.a71.su/Ethyl/New-Soviet-Era"
|
"sources": "https://git.a71.su/Ethyl/New-Soviet-Era"
|
||||||
},
|
},
|
||||||
"license": "All rights reserved",
|
"license": "Mixed: All rights reserved assets & MIT code",
|
||||||
"icon": "assets/new_soviet/icon.png",
|
"icon": "assets/new_soviet/icon.png",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
|
@ -31,5 +31,14 @@
|
||||||
"minecraft": "~1.20.1",
|
"minecraft": "~1.20.1",
|
||||||
"java": ">=17",
|
"java": ">=17",
|
||||||
"fabric-api": "*"
|
"fabric-api": "*"
|
||||||
|
},
|
||||||
|
|
||||||
|
"custom": {
|
||||||
|
"modmenu": {
|
||||||
|
"links": {
|
||||||
|
"modmenu.discord": "https://discord.gg/D46vGJeCfj"
|
||||||
|
},
|
||||||
|
"update_checker": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue