Skip to content

Using GH

devendrn edited this page Jun 30, 2024 · 2 revisions

You can fork this repository and use it as a base for your variant. For this you need a basic understanding of Git and GitHub.

Creating a fork

You can create a fork, by clicking the "Fork" button.

Clone your forked repository to your machine.

git clone <your_fork_link>

Setup git credentials

It would be better for you to commit changes from your local machine using git. For that, you will have to use a token as password for authenticating with GitHub. You can generate a general token here. You will be required to use it later when running git push, so store it somewhere (eg. in a .txt file).

Warning

A token key is a sensitive information. Please store it securely.

Git doesn't know who you are. You need to setup your username and email first. To do that, run:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Use your GitHub username and the email you used to sign up for GitHub

Uploading changes

After making necessary changes and testing shader locally, you can now upload the changes to your GitHub repository.

Check the changes by running:

git status

It will show you a list of all files you have changed. Use git diff <file_name> to see all changes you made inside a file.

Stage all changes by using:

git add .

If you want to stage only some files, use git add <file_name> <some_other_file>.

Run git status again to see all files staged for commit. When you make a commit, only these changes (green ones) will be added.

Now make a commit:

git commit -m "Title about your changes: eg. Increased fog intensity"

You can push the commit to GitHub now:

git push

It will ask for authentication. Use your GitHub username as username, and use the generated token as password.

Note

Don't use your actual GitHub password. You have to copy-paste the token you generated instead.

Using GH Actions to build pack

Note

If you want GitHub to be able to build your shader pack, go to "Repository settings > Actions" and check an "allow actions" option.

To run builder:

  • Go to "Actions > build".
  • Click the button called "Run workflow".
  • Provide a version number of your choice, and press "Run".

It may take a minute or two to finish. You can find the final pack files under artifacts section of that workflow run. If the workflow fails, you can check log to see the error.

Pulling latest changes from my repository

Make sure to commit all your changes first.

Add my repository to your remotes:

git remote add upstream https://github.com/devendrn/newb-x-mcbe

Now pull latest changes:

git pull upstream/main

If pull fails with conflicts, you have to manually merge changes:

git merge upstream/main

This should give an output similar to the following:

deven@dell3515:~/newb-x-future$ git merge upstream/main
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
CONFLICT (modify/delete): assets/COPYRIGHT.txt deleted in upstream/main and modified in HEAD.  Version HEAD of assets/COPYRIGHT.txt left in tree.
Auto-merging src/materials/EndSky/fragment.sc
CONFLICT (content): Merge conflict in src/materials/EndSky/fragment.sc
Auto-merging src/newb/pack_config.toml
CONFLICT (content): Merge conflict in src/newb/pack_config.toml
Automatic merge failed; fix conflicts and then commit the result.

Git will automatically merge both of our changes in the following way when there is a conflict.

<<<<<<< HEAD
Your code block
=======
My code block
>>>>>>> upstream/main

You have to manually add changes from my code block to your code block. You have to do this for all files with conflict.

Example: pack_toml.config

<<<<<<< HEAD
name = "Newb X Future"
version = [0, 16, 0]
url = "https://github.com/1sekon/newb-x-future/"
authors = ["1sekon"]
min_supported_mc_version = [1, 20, 80]
=======
name = "Newb X Legacy"
version = [0, 15, 0]
min_supported_mc_version = [1, 20, 80]
url = "https://devendrn.github.io/newb-shader/"
authors = ["devendrn"]
>>>>>>> upstream/main

After comparing both block, keep the changes you want and remove the ones you don't. For the above example you would update it to:

name = "Newb X Future"
version = [0, 16, 0]
min_supported_mc_version = [1, 20, 80]
url = "https://github.com/1sekon/newb-x-future/"
authors = ["1sekon", "devendrn"]

Make sure to remove ======= and >>>>>>> lines after resolving the issue

Here's another example: src/materials/EndSky/fragment.sc

<<<<<<< HEAD
uniform vec4 ViewPositionAndTime;

SAMPLER2D(s_MatTexture, 0);

void main() {
  vec4 diffuse = texture2D(s_MatTexture, v_texcoord0);
  vec3 bloom1 = nlGlow(s_MatTexture, v_texcoord0, diffuse, nlGlowShimmer(normalize(v_posTime.xyz), ViewPositionAndTime.w), 256.0, 256.0);
  vec3 nPos = normalize(v_posTime.xyz);
=======
SAMPLER2D_AUTOREG(s_SkyTexture);
#endif

void main() {
#ifndef INSTANCING
  vec4 diffuse = texture2D(s_SkyTexture, v_texcoord0);
>>>>>>> upstream/main

You can send this snippet in #customization-help channel of our discord server, if you can't understand the changes. In the above example, you can see that I (upstream/main) updated texture sampler to fix a bug. You have to add the same change to your code.

uniform vec4 ViewPositionAndTime;

SAMPLER2D_AUTOREG(s_SkyTexture);

void main() {
  vec4 diffuse = texture2D(s_SkyTexture, v_texcoord0);
  vec3 bloom1 = nlGlow(s_SkyTexture, v_texcoord0, diffuse, nlGlowShimmer(normalize(v_posTime.xyz), ViewPositionAndTime.w), 256.0, 256.0);
  vec3 nPos = normalize(v_posTime.xyz);

After resolving issues in all files, run git diff to make sure you have have not missed any conflicts.

Now build the shader by running ./build.sh pack and test it to make sure everything works as expected.

If everything is okay, you are ready to complete the merge. Run:

git add .
git commit

It will open a text editor. Save the text file to confirm changes. (If the text editor is nano: To save file, press ctrl + o , then press enter to confirm filename)

The merge should be successful by now. You can check git log to make sure you got my commits:

git log --oneline