mirror of
https://github.com/peter-tanner/old-beacon.git
synced 2024-11-30 11:10:18 +08:00
update descriptions and more comments
This commit is contained in:
parent
179f906242
commit
4f745d0b70
|
@ -8,9 +8,9 @@ org.gradle.jvmargs=-Xmx1G
|
|||
loader_version=0.10.6+build.214
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.0
|
||||
mod_version = 0.1.0
|
||||
maven_group = io.github.npc_strider.oldbeacon
|
||||
archives_base_name = fabric-test
|
||||
archives_base_name = old-beacon
|
||||
|
||||
# Dependencies
|
||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||
|
|
|
@ -22,10 +22,6 @@ public class OldBeacon implements ModInitializer {
|
|||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
// However, some things (like resources) may still be uninitialized.
|
||||
// Proceed with mild caution.
|
||||
// System.out.println("Load"+MOD_ID);
|
||||
|
||||
//Config file stuff.
|
||||
Properties p = new Properties();
|
||||
|
@ -41,7 +37,7 @@ public class OldBeacon implements ModInitializer {
|
|||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
List<String> lines = Arrays.asList(
|
||||
"# default: true. Beacon has a blue star when it is not emitting a beam.",
|
||||
"# default: true. Beacon has a blue star when it is not emitting a beam. Setting this to false results in the star being yellow regardless of whether it's active",
|
||||
"idle_anim=true"
|
||||
);
|
||||
try {
|
||||
|
@ -52,6 +48,8 @@ public class OldBeacon implements ModInitializer {
|
|||
}
|
||||
}
|
||||
IDLE_ANIM = p.getProperty("idle_anim").toLowerCase().trim().equals("true") ? true : false;
|
||||
//
|
||||
|
||||
};
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
// package io.github.npc_strider.oldbeacon;
|
||||
|
||||
// import net.fabricmc.api.ClientModInitializer;
|
||||
// import net.fabricmc.api.EnvType;
|
||||
// import net.fabricmc.api.Environment;
|
||||
|
||||
// @Environment(EnvType.CLIENT)
|
||||
// public class OldBeaconClient implements ClientModInitializer {
|
||||
// @Override
|
||||
// public void onInitializeClient() {
|
||||
// }
|
||||
// }
|
|
@ -29,8 +29,7 @@ import io.github.npc_strider.oldbeacon.OldBeacon;
|
|||
|
||||
@Mixin(BeaconBlockEntityRenderer.class)
|
||||
public class BeaconMixin {
|
||||
@Shadow static final Identifier BEAM_TEXTURE = new Identifier("textures/entity/beacon_beam.png");
|
||||
// @Shadow static final Identifier BEAM_TEXTURE = new Identifier("textures/misc/beam.png"); //Not going to bother trying to reimplement the old beacon beam
|
||||
@Shadow static final Identifier BEAM_TEXTURE = new Identifier("textures/entity/beacon_beam.png"); //"textures/misc/beam.png" //Not going to bother trying to reimplement the old beacon beam - have to modify code for it to accept alpha channel?
|
||||
@Shadow private static void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, float f, long l, int i, int j, float[] fs) {};
|
||||
|
||||
private static final boolean IDLE_ANIM = OldBeacon.IDLE_ANIM;
|
||||
|
@ -41,33 +40,16 @@ public class BeaconMixin {
|
|||
private ModelPart core = new ModelPart(64, 32, 32, 0).addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
private ModelPart frame = new ModelPart(64, 32, 0, 0).addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
private ModelPart bottom = new ModelPart(64, 32, 0, 16).addCuboid(-6.0F, 0.0F, -6.0F, 12.0F, 4.0F, 12.0F);
|
||||
|
||||
// @Inject(
|
||||
// at = @At("HEAD"),
|
||||
// method = "BeaconBlockEntityRenderer()V"
|
||||
// )
|
||||
// public BeaconBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
|
||||
// this.frame = new ModelPart(64, 32, 0, 0);
|
||||
// this.frame.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
// this.core = new ModelPart(64, 32, 32, 0);
|
||||
// this.core.addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
// this.bottom = new ModelPart(64, 32, 0, 16);
|
||||
// this.bottom.addCuboid(-6.0F, 0.0F, -6.0F, 12.0F, 4.0F, 12.0F);
|
||||
// }
|
||||
|
||||
// Yeah for some reason this is a thing; have to ignore the error when debugging.
|
||||
@Inject(
|
||||
at = @At("HEAD"),
|
||||
method = "BeaconBlockEntityRenderer()V"
|
||||
)
|
||||
public BeaconBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
|
||||
public BeaconBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) { // For some reason you have to ignore the error during debugging? Everything seems to work.
|
||||
super(blockEntityRenderDispatcher);
|
||||
this.frame = new ModelPart(64, 32, 0, 0).addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
this.core = new ModelPart(64, 32, 32, 0).addCuboid(-4.0F, -4.0F, -4.0F, 8.0F, 8.0F, 8.0F);
|
||||
this.bottom = new ModelPart(64, 32, 0, 16).addCuboid(-6.0F, 0.0F, -6.0F, 12.0F, 4.0F, 12.0F);
|
||||
// this.frame = new ModelPart(64, 32, 0, 0).addCuboid(0.0F, 0.0F, 0.0F, 8.0F, 8.0F, 8.0F);
|
||||
// this.core = new ModelPart(64, 32, 32, 0).addCuboid(0.0F, 0.0F, 0.0F, 8.0F, 8.0F, 8.0F);
|
||||
// this.bottom = new ModelPart(64, 32, 0, 16).addCuboid(-2.0F, 4.0F, -2.0F, 12.0F, 4.0F, 12.0F);
|
||||
};
|
||||
|
||||
//Why am I not using injects ?
|
||||
|
@ -77,23 +59,14 @@ public class BeaconMixin {
|
|||
// 2. This modification seems so complex that using injection isn't worth it anymore.
|
||||
// I was considering using it but once I started making changes to the beacon beam renderer pretty much everything within render is changed, so might as well override it.
|
||||
public void render(BeaconBlockEntity beaconBlockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
|
||||
// long l = beaconBlockEntity.getWorld().getTime();
|
||||
// List<BeaconBlockEntity.BeamSegment> list = beaconBlockEntity.getBeamSegments();
|
||||
// int k = 0;
|
||||
|
||||
// for(int m = 0; m < list.size(); ++m) {
|
||||
// BeaconBlockEntity.BeamSegment beamSegment = (BeaconBlockEntity.BeamSegment)list.get(m);
|
||||
// render(matrixStack, vertexConsumerProvider, f, l, k, m == list.size() - 1 ? 1024 : beamSegment.getHeight(), new float[]{1.0F, 1.0F, 0.0F} /*beamSegment.getColor()*/);
|
||||
// k += beamSegment.getHeight();
|
||||
// }
|
||||
|
||||
//Code here is for the nether star
|
||||
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(NETHER_STAR);
|
||||
|
||||
float scale = 1.0F; // Original in EndCrystalEntityRenderer: 2.0F
|
||||
float[] ccolor = new float[]{1.0F, 1.0F, 1.0F, 1.0F};
|
||||
float[] fcolor = new float[]{1.0F, 1.0F, 1.0F, 1.0F};
|
||||
float scale = 1.0F; // Original in EndCrystalEntityRenderer: 2.0F => matrixStack.scale(2.0F, 2.0F, 2.0F);
|
||||
float[] ccolor = new float[]{1.0F, 1.0F, 1.0F, 1.0F}; //=> Core color (the star)
|
||||
float[] fcolor = new float[]{1.0F, 1.0F, 1.0F, 1.0F}; //=> Frame color (the white box that rotates around the star)
|
||||
if (beaconBlockEntity.getBeamSegments().size() == 0 & IDLE_ANIM == true) { //This is if the beacon is INACTIVE.
|
||||
scale = 0.7F;
|
||||
scale = 0.7F; //Make the star smaller when inactive. Also tint the star core and frame so it's cyan.
|
||||
fcolor = new float[]{0.65F, 1.0F, 1.0F, 0.05F}; //Alpha doesn't work??
|
||||
ccolor = new float[]{0.1F, 0.5F, 1.0F, 0.05F}; //Alpha doesn't work??
|
||||
};
|
||||
|
@ -101,46 +74,33 @@ public class BeaconMixin {
|
|||
matrixStack.push();
|
||||
long tick = beaconBlockEntity.getWorld().getTime(); // Unfortunately the block has no time (endcrystals have endCrystalAge), so all block have the same animations
|
||||
float h = OldBeacon_getYOffset(tick, tickDelta) - (1.75F - d - 0.075F);//(h)eight offset of crystal //tickDelta ensures smooth animation (Not capped to 20fps/ 1 frame per tick.)
|
||||
float phase = (/*(float)BeaconBlockEntity.endCrystalAge +*/ tick + tickDelta) * 3.0F; //phase or angle - results in rotational motion
|
||||
// float phase = ((float)BeaconBlockEntity.endCrystalAge + g) * 3.0F;
|
||||
float phase = (tick + tickDelta) * 3.0F; //phase or angle - results in rotational motion
|
||||
matrixStack.push();
|
||||
// matrixStack.scale(2.0F, 2.0F, 2.0F);
|
||||
matrixStack.scale(scale, scale, scale);
|
||||
matrixStack.translate(0.5D/scale, /*-0.5D*/ -0.2D/scale, 0.5D/scale);
|
||||
matrixStack.translate(0.5D/scale, -0.2D/scale, 0.5D/scale); //Translate it to the center of the block. Original Y was -0.5D
|
||||
int k = OverlayTexture.DEFAULT_UV;
|
||||
// if (BeaconBlockEntity.getShowBottom()) { //Originally code for the bedrock 'base' of end crystals.
|
||||
// this.bottom.render(matrixStack, vertexConsumer, i, k);
|
||||
// }
|
||||
// if (BeaconBlockEntity.getShowBottom()) { [...] }; //Originally code here for the bedrock 'base' of end crystals. Note that on the original beacon, this bedrock base did render, but I'm not including it because it looks bad.
|
||||
|
||||
// Below here is graphical stuff. Don't mess with it - idk how tf quaternions rotations even work!
|
||||
// Below here is graphical stuff, presumably results in the arcane motion of the end crystal. Don't mess with it - idk how tf quaternions rotations even work!
|
||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(phase));
|
||||
matrixStack.translate(0.0D, (double)(1.5F + h / 2.0F)/scale, 0.0D);
|
||||
matrixStack.translate(0.0D, (double)(1.5F + h / 2.0F)/scale, 0.0D); //Translate up/down according to h - the oscillating height.
|
||||
matrixStack.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
this.frame.render(matrixStack, vertexConsumer, i, k, fcolor[0], fcolor[1], fcolor[2], fcolor[3]);
|
||||
this.frame.render(matrixStack, vertexConsumer, i, k, fcolor[0], fcolor[1], fcolor[2], fcolor[3]); //Render the frame, with the tint
|
||||
float l = 0.875F; //Not sure why this number - don't want to hear about it.
|
||||
matrixStack.scale(l, l, l);
|
||||
matrixStack.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(phase));
|
||||
this.frame.render(matrixStack, vertexConsumer, i, k, fcolor[0], fcolor[1], fcolor[2], fcolor[3]);
|
||||
this.frame.render(matrixStack, vertexConsumer, i, k, fcolor[0], fcolor[1], fcolor[2], fcolor[3]); //Render the frame, with the tint
|
||||
matrixStack.scale(l, l, l);
|
||||
matrixStack.multiply(new Quaternion(new Vector3f(SINE_45_DEGREES, 0.0F, SINE_45_DEGREES), 60.0F, true));
|
||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(phase));
|
||||
this.core.render(matrixStack, vertexConsumer, i, k, ccolor[0], ccolor[1], ccolor[2], ccolor[3]);
|
||||
this.core.render(matrixStack, vertexConsumer, i, k, ccolor[0], ccolor[1], ccolor[2], ccolor[3]); //Render the frame, with the tint
|
||||
matrixStack.pop();
|
||||
matrixStack.pop();
|
||||
// BlockPos blockPos = BeaconBlockEntity.getBeamTarget(); //Originally code for the ender dragon beam which goes from crystal to dragon.
|
||||
// if (blockPos != null) {
|
||||
// float m = (float)blockPos.getX() + 0.5F;
|
||||
// float n = (float)blockPos.getY() + 0.5F;
|
||||
// float o = (float)blockPos.getZ() + 0.5F;
|
||||
// float p = (float)((double)m - BeaconBlockEntity.getX());
|
||||
// float q = (float)((double)n - BeaconBlockEntity.getY());
|
||||
// float r = (float)((double)o - BeaconBlockEntity.getZ());
|
||||
// matrixStack.translate((double)p, (double)q, (double)r);
|
||||
// EnderDragonEntityRenderer.renderCrystalBeam(-p, -q + h, -r, g, BeaconBlockEntity.endCrystalAge, matrixStack, vertexConsumerProvider, i);
|
||||
// }
|
||||
|
||||
// Originally code here for the ender dragon beam which goes from crystal to dragon.
|
||||
// BlockPos blockPos = BeaconBlockEntity.getBeamTarget(); [...]
|
||||
|
||||
//Code below here is for the beacon beam.
|
||||
float tr = 0.5F + 0.075F; //Translate beam so it's inside of the star.
|
||||
matrixStack.translate(0.0D, tr, 0.0D); // Make sure beam starts inside of star, not below it.
|
||||
matrixStack.scale(1.0F, (1.0F-tr), 1.0F);
|
||||
|
@ -155,25 +115,23 @@ public class BeaconMixin {
|
|||
for(int m = 0; m < list.size(); ++m) {
|
||||
BeaconBlockEntity.BeamSegment beamSegment = (BeaconBlockEntity.BeamSegment)list.get(m);
|
||||
int j_ = beamSegment.getHeight();
|
||||
if (m == 1){ //hacky stuff to ensure glass blocks tint the beam at the start, not in the middle of the glass (if we only transformed it up by 0.5F)
|
||||
if (m == 1){ //lots of hacky stuff to ensure glass blocks tint the beam at the start, not in the middle of the glass (if we only transformed it up by 0.5F)
|
||||
matrixStack.scale(1.0F, 1.0F/(1.0F-tr), 1.0F); //Scale up the next beam segment so it's 1 block tall again
|
||||
matrixStack.translate(0.0D, -tr, 0.0D); //Re-translate the beam so it's aligned to the grid.
|
||||
j_--; // This covers the case where the tint block is immediately above the beacon (=> height of 0)
|
||||
} else if (m == 2){
|
||||
matrixStack.translate(0.0D, -1.0F, 0.0D); // Need to cover the truncated height of the previous beam segment (j_--)
|
||||
matrixStack.translate(0.0D, -1.0F, 0.0D); // Need to cover the truncated height of the previous beam segment (j_--), otherwise we get a 1 block gap between the starting segment and the first tinted segment.
|
||||
}
|
||||
render(matrixStack, vertexConsumerProvider, tickDelta, tick, x, m == list.size() - 1 ? 1024 : j_, beamSegment.getColor());
|
||||
x += beamSegment.getHeight();
|
||||
}
|
||||
|
||||
// super.render(beaconBlockEntity, f, g, matrixStack, vertexConsumerProvider, i);
|
||||
}
|
||||
|
||||
private static float OldBeacon_getYOffset(/*BeaconBlockEntity crystal,*/long tick, float tickDelta) {
|
||||
float f = /*(float)crystal.endCrystalAge +*/tick + tickDelta;
|
||||
private static float OldBeacon_getYOffset(long tick, float tickDelta) {
|
||||
float f = tick + tickDelta;
|
||||
float g = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F;
|
||||
g = (g * g + g) * d;
|
||||
return g /*- 1.4F*/; // Center of the beacon. Again, not sure of the official constant used. (1.75F is the real center, but it clips due to its oscillation). Moved the constant to the result.
|
||||
return g; // Center of the beacon. Again, not sure of the official constant (-1.4F) used so I'm using my own. (1.75F is the real center, but it clips due to its oscillation). Moved the constant to the result.
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package io.github.npc_strider.oldbeacon.mixin;
|
||||
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public class TestMixin {
|
||||
private String splashText;
|
||||
@Inject(
|
||||
at = @At("HEAD"),
|
||||
method = "init()V"
|
||||
)
|
||||
private void init(CallbackInfo info) {
|
||||
System.out.println("This line is printed by an example mod mixin!");
|
||||
this.splashText = "Hello world! This text has been injected via a MIXIN.";
|
||||
}
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "modid",
|
||||
"id": "oldbeacon",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "Example Mod",
|
||||
"description": "This is an example description! Tell everyone what your mod is about!",
|
||||
"name": "Old Beacon",
|
||||
"description": "This mod adds in the old beacon graphics from the 12w36a snapshot. It has a small nether star in the middle which has the same motion as an end crystal. Check config/oldbeacon.cfg for options.",
|
||||
"authors": [
|
||||
"Me!"
|
||||
"npc_strider"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://fabricmc.net/",
|
||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||
"homepage": "https://npc-strider.github.io/",
|
||||
"sources": "https://github.com/npc-strider/old-beacon"
|
||||
},
|
||||
|
||||
"license": "CC0-1.0",
|
||||
"icon": "assets/modid/icon.png",
|
||||
"license": "MIT",
|
||||
"icon": "assets/oldbeacon/icon.png",
|
||||
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
|
@ -23,7 +23,7 @@
|
|||
]
|
||||
},
|
||||
"mixins": [
|
||||
"modid.mixins.json"
|
||||
"oldbeacon.mixins.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"TestMixin",
|
||||
"BeaconMixin"
|
||||
],
|
||||
"injectors": {
|
Loading…
Reference in New Issue
Block a user