Colorful lasers

This commit is contained in:
Flanks255 2022-07-27 13:06:26 -05:00
parent 70b0131f88
commit 011834c732
4 changed files with 16 additions and 2 deletions

View file

@ -26,5 +26,6 @@ public interface IAtomicReconstructor extends IEnergyTile {
Direction getOrientation(); Direction getOrientation();
void resetBeam(int maxAge); void resetBeam(int maxAge);
void resetBeam(int maxAge, int color);
int getTTL(); int getTTL();
} }

View file

@ -40,6 +40,7 @@ public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicRe
public void render(TileEntityAtomicReconstructor tile, float partialTicks, @Nonnull MatrixStack matrices, @Nonnull IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) { public void render(TileEntityAtomicReconstructor tile, float partialTicks, @Nonnull MatrixStack matrices, @Nonnull IRenderTypeBuffer buffer, int combinedLight, int combinedOverlay) {
ItemStack stack = tile.inv.getStackInSlot(0); ItemStack stack = tile.inv.getStackInSlot(0);
//default color 0x1b6dff //default color 0x1b6dff
int color = tile.getBeamColor();
Direction direction = tile.getOrientation(); Direction direction = tile.getOrientation();
float rot = 360.0f - direction.getOpposite().toYRot(); //Sigh... float rot = 360.0f - direction.getOpposite().toYRot(); //Sigh...
float pitch = 0; float pitch = 0;
@ -49,7 +50,7 @@ public class ReconstructorRenderer extends TileEntityRenderer<TileEntityAtomicRe
pitch = -90; pitch = -90;
} }
if (tile.getProgress() > 0) { if (tile.getProgress() > 0) {
AssetUtil.renderLaser(matrices, buffer, 0, 0, 0, rot, pitch, 5, 0, 0x1b6dff, 0.8f * tile.getProgress(), 0.2f); AssetUtil.renderLaser(matrices, buffer, 0, 0, 0, rot, pitch, 5, 0, color, 0.8f * tile.getProgress(), 0.2f);
tile.decTTL(); tile.decTTL();
} }
if (stack.isEmpty() || !(stack.getItem() instanceof ILensItem)) { if (stack.isEmpty() || !(stack.getItem() instanceof ILensItem)) {

View file

@ -41,6 +41,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
private int oldEnergy; private int oldEnergy;
private int ttl = 0; private int ttl = 0;
private int maxAge = 0; private int maxAge = 0;
private int beamColor = 0x1b6dff;
public TileEntityAtomicReconstructor() { public TileEntityAtomicReconstructor() {
super(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getTileEntityType(), 1); super(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getTileEntityType(), 1);
@ -62,8 +63,18 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
@Override @Override
public void resetBeam(int maxAge) { public void resetBeam(int maxAge) {
this.resetBeam(maxAge, 0x1b6dff);
}
@Override
public void resetBeam(int maxAge, int color) {
this.ttl = maxAge; this.ttl = maxAge;
this.maxAge = maxAge; this.maxAge = maxAge;
this.beamColor = color;
}
public int getBeamColor() {
return this.beamColor;
} }
public float getProgress(){ public float getProgress(){

View file

@ -230,7 +230,7 @@ public final class AssetUtil {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
TileEntity tile = mc.level.getBlockEntity(new BlockPos(startX, startY, startZ)); TileEntity tile = mc.level.getBlockEntity(new BlockPos(startX, startY, startZ));
if(tile instanceof TileEntityAtomicReconstructor) if(tile instanceof TileEntityAtomicReconstructor)
((TileEntityAtomicReconstructor) tile).resetBeam(maxAge); ((TileEntityAtomicReconstructor) tile).resetBeam(maxAge, color);
/* if (mc.player.distanceToSqr(startX, startY, startZ) <= 64 || mc.player.distanceToSqr(endX, endY, endZ) <= 64) { /* if (mc.player.distanceToSqr(startX, startY, startZ) <= 64 || mc.player.distanceToSqr(endX, endY, endZ) <= 64) {
@ -251,6 +251,7 @@ public final class AssetUtil {
int g = (color >> 8) & 0xFF; int g = (color >> 8) & 0xFF;
int b = color & 0xFF; int b = color & 0xFF;
int a = (int) (alpha * 255); int a = (int) (alpha * 255);
ActuallyAdditions.LOGGER.info("Laser: " + a);
int lightmap = LightTexture.pack(MAX_LIGHT_X, MAX_LIGHT_Y); int lightmap = LightTexture.pack(MAX_LIGHT_X, MAX_LIGHT_Y);