Skip to content

Commit

Permalink
Merge pull request #6 from Keriils/TimeVial-for-1710
Browse files Browse the repository at this point in the history
a test to porting time vial
  • Loading branch information
Keriils authored Aug 23, 2024
2 parents 4da8930 + c5241be commit 79dd864
Show file tree
Hide file tree
Showing 67 changed files with 1,662 additions and 87 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin
/.github/** @Keriils

18 changes: 15 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,22 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
// api("com.github.GTNewHorizons:GT5-Unofficial:5.09.48.66:dev")
compileOnly ('org.jetbrains:annotations:24.1.0')
api("com.github.GTNewHorizons:Draconic-Evolution:1.3.5-GTNH:dev")
api("com.github.GTNewHorizons:GT5-Unofficial:5.09.48.66:dev")
implementation("com.github.GTNewHorizons:Draconic-Evolution:1.3.5-GTNH:dev")
implementation("com.github.GTNewHorizons:Botania:1.11.3-GTNH:dev")
implementation('com.github.GTNewHorizons:Avaritia:1.49:dev')
implementation('com.github.GTNewHorizons:Avaritiaddons:1.7.1-GTNH:dev')
implementation('com.github.GTNewHorizons:Eternal-Singularity:1.2.1:dev')
implementation('com.github.GTNewHorizons:Universal-Singularities:8.7.0:dev')
implementation("com.github.GTNewHorizons:Baubles:1.0.4:dev")
implementation("com.github.GTNewHorizons:ae2stuff:0.8.2-GTNH:dev")
implementation("com.github.GTNewHorizons:ServerUtilities:2.0.66:dev") // debug info & nbtEdit

// compileOnly ('org.jetbrains:annotations:24.1.0')

// libs files
// implementation files("libs/rawinput-1.4.2.jar")
implementation files("libs/ProjectE-1.7.10-PE1.10.1.jar") // DEBUG TEST
implementation files("libs/Torcherino-1.7.10-2.2s.jar") // DEBUG TEST
implementation files("libs/ForgeNBTEdit.jar")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ usesMixinDebug = true
mixinPlugin = mixinPlugin.MixinPlugin

# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage = Mixins
mixinsPackage = mixins

# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
Expand Down
Binary file added libs/ForgeNBTEdit.jar
Binary file not shown.
Binary file added libs/ProjectE-1.7.10-PE1.10.1.jar
Binary file not shown.
Binary file added libs/Torcherino-1.7.10-2.2s.jar
Binary file not shown.
Binary file added libs/Torcherino-OP-fort.jar
Binary file not shown.
Binary file added libs/Torcherino-OP.jar
Binary file not shown.
Binary file added libs/rawinput-1.4.2.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xir.NHUtilities.client;
package com.xir.NHUtilities.client.key;

import net.minecraft.client.settings.KeyBinding;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xir.NHUtilities.client;
package com.xir.NHUtilities.client.key;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package com.xir.NHUtilities.client.render;

import static com.xir.NHUtilities.config.Config.enableNumberMultiplierTexture;
import static com.xir.NHUtilities.config.Config.enableTimeAcceleratorBoost;
import static com.xir.NHUtilities.main.NHUtilities.MODID;

import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

import org.jetbrains.annotations.NotNull;
import org.lwjgl.opengl.GL11;

import com.xir.NHUtilities.common.entity.EntityTimeAccelerator;

public class RenderTimeAccelerator extends Render {

private static final ResourceLocation[] TEXTURE_ARRAY = new ResourceLocation[6];
private static final boolean ENABLE_NUMBER_TEXTURE = enableNumberMultiplierTexture;
private static final double ROTATE_SPEED = 7.12d;
private static final double RADIUS = 0.34d;
private static final double OFFSET = 0.51d;

static {
final String pathURL = MODID + ':' + "textures/entity/";
if (!ENABLE_NUMBER_TEXTURE) {
for (int i = 0; i < TEXTURE_ARRAY.length; i++) {
TEXTURE_ARRAY[i] = new ResourceLocation(String.format(pathURL + "Circle/time_%d.png", i));
}
} else {
for (int i = 0; i < TEXTURE_ARRAY.length; i++) {
TEXTURE_ARRAY[i] = new ResourceLocation(
String.format(pathURL + "Number/number_%d.png", enableTimeAcceleratorBoost ? i + 1 : i));
}
}
}

private void doRender(@NotNull EntityTimeAccelerator entityTimeAccelerator, double x, double y, double z) {

double angle = ENABLE_NUMBER_TEXTURE ? 0.0d
: (ROTATE_SPEED * entityTimeAccelerator.worldObj.getTotalWorldTime()) % 360;
int i = (int) (Math.log(entityTimeAccelerator.getTimeRateForRender()) / Math.log(2))
- (enableTimeAcceleratorBoost ? 3 : 2);

// security considerations
if (i >= TEXTURE_ARRAY.length || i < 0) i = 0;

this.bindTexture(TEXTURE_ARRAY[i]);

GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
Tessellator tessellator = Tessellator.instance;

drawAllSide(tessellator, x, y, z, angle);

GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
}

/**
* <li>Make sure every side is correctly drawn.</li>
*/
private static void drawAllSide(@NotNull Tessellator tessellator, double x, double y, double z, double angle) {

GL11.glPushMatrix();
tessellator.startDrawingQuads();
GL11.glTranslated(x, y + OFFSET, z);
GL11.glRotated(angle, 0.0d, -1.0d, 0.0d);
tessellator.addVertexWithUV(RADIUS, 0, RADIUS, 0.0d, 0.0d);
tessellator.addVertexWithUV(-RADIUS, 0, RADIUS, 1.0d, 0.0d);
tessellator.addVertexWithUV(-RADIUS, 0, -RADIUS, 1.0d, 1.0d);
tessellator.addVertexWithUV(RADIUS, 0, -RADIUS, 0.0d, 1.0d);
tessellator.draw();
GL11.glPopMatrix();

GL11.glPushMatrix();
tessellator.startDrawingQuads();
GL11.glTranslated(x, y - OFFSET, z);
GL11.glRotated(angle, 0.0d, 1.0d, 0.0d);
tessellator.addVertexWithUV(RADIUS, 0, -RADIUS, 0.0d, 0.0d);
tessellator.addVertexWithUV(-RADIUS, 0, -RADIUS, 1.0d, 0.0d);
tessellator.addVertexWithUV(-RADIUS, 0, RADIUS, 1.0d, 1.0d);
tessellator.addVertexWithUV(RADIUS, 0, RADIUS, 0.0d, 1.0d);
tessellator.draw();
GL11.glPopMatrix();

GL11.glPushMatrix();
tessellator.startDrawingQuads();
GL11.glTranslated(x + OFFSET, y, z);
GL11.glRotated(angle, -1.0d, 0.0d, 0.0d);
tessellator.addVertexWithUV(0, RADIUS, RADIUS, 0.0d, 0.0d);
tessellator.addVertexWithUV(0, RADIUS, -RADIUS, 1.0d, 0.0d);
tessellator.addVertexWithUV(0, -RADIUS, -RADIUS, 1.0d, 1.0d);
tessellator.addVertexWithUV(0, -RADIUS, RADIUS, 0.0d, 1.0d);
tessellator.draw();
GL11.glPopMatrix();

GL11.glPushMatrix();
tessellator.startDrawingQuads();
GL11.glTranslated(x - OFFSET, y, z);
GL11.glRotated(angle, 1.0d, 0.0d, 0.0d);
tessellator.addVertexWithUV(0, RADIUS, -RADIUS, 0.0d, 0.0d);
tessellator.addVertexWithUV(0, RADIUS, RADIUS, 1.0d, 0.0d);
tessellator.addVertexWithUV(0, -RADIUS, RADIUS, 1.0d, 1.0d);
tessellator.addVertexWithUV(0, -RADIUS, -RADIUS, 0.0d, 1.0d);
tessellator.draw();
GL11.glPopMatrix();

GL11.glPushMatrix();
tessellator.startDrawingQuads();
GL11.glTranslated(x, y, z + OFFSET);
GL11.glRotated(angle, 0.0d, 0.0d, -1.0d);
tessellator.addVertexWithUV(-RADIUS, RADIUS, 0, 0.0d, 0.0d);
tessellator.addVertexWithUV(RADIUS, RADIUS, 0, 1.0d, 0.0d);
tessellator.addVertexWithUV(RADIUS, -RADIUS, 0, 1.0d, 1.0d);
tessellator.addVertexWithUV(-RADIUS, -RADIUS, 0, 0.0d, 1.0d);
tessellator.draw();
GL11.glPopMatrix();

GL11.glPushMatrix();
tessellator.startDrawingQuads();
GL11.glTranslated(x, y, z - OFFSET);
GL11.glRotated(angle, 0.0d, 0.0d, 1.0d);
tessellator.addVertexWithUV(RADIUS, RADIUS, 0, 0.0d, 0.0d);
tessellator.addVertexWithUV(-RADIUS, RADIUS, 0, 1.0d, 0.0d);
tessellator.addVertexWithUV(-RADIUS, -RADIUS, 0, 1.0d, 1.0d);
tessellator.addVertexWithUV(RADIUS, -RADIUS, 0, 0.0d, 1.0d);
tessellator.draw();
GL11.glPopMatrix();
}

@Override
public void doRender(Entity entity, double x, double y, double z, float entityYaw, float partialTicks) {
doRender((EntityTimeAccelerator) entity, x, y, z);
}

@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.xir.NHUtilities.common.api;

import com.xir.NHUtilities.common.entity.EntityTimeAccelerator;

/**
* only used for EntityTimeAccelerator {@link EntityTimeAccelerator#onEntityUpdate()}
*/
public interface ITileEntityTickAcceleration {

/**
* <li>true if the tickAcceleration logic should be executed.</li>
* <li>false if the default TileEntity update method should proceed.</li>
*/
boolean tickAcceleration(int tickAcceleratedRate);

}
Loading

0 comments on commit 79dd864

Please sign in to comment.