-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `getPlatformEnergyItem` For retrieving items that stores native energy * Add `ChargerMachine` that implements logic for charger Almost a duplicate from battery buffer, follows same logic as 1.12.2 * Register `ChargerMachine` and its recipe * Change Charger name to Turbo Charger * Add texture for `ChargerMachine` * Add rendering logic to `ChargerMachine` Renders three states: idle, running, finished * fix batterybuffer notification --------- Co-authored-by: KilaBash <yefancy@foxmail.com>
- Loading branch information
Showing
20 changed files
with
463 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
common/src/main/java/com/gregtechceu/gtceu/client/renderer/machine/ChargerRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.gregtechceu.gtceu.client.renderer.machine; | ||
|
||
import com.gregtechceu.gtceu.GTCEu; | ||
import com.gregtechceu.gtceu.api.machine.MachineDefinition; | ||
import com.gregtechceu.gtceu.api.machine.MetaMachine; | ||
import com.gregtechceu.gtceu.common.machine.electric.ChargerMachine; | ||
import com.gregtechceu.gtceu.config.ConfigHolder; | ||
import com.lowdragmc.lowdraglib.client.bakedpipeline.FaceQuad; | ||
import com.lowdragmc.lowdraglib.client.model.ModelFactory; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.renderer.block.model.BakedQuad; | ||
import net.minecraft.client.renderer.texture.TextureAtlas; | ||
import net.minecraft.client.resources.model.ModelState; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.RandomSource; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.*; | ||
import java.util.function.Consumer; | ||
|
||
/** | ||
* @author lucifer_ll | ||
* @date 2023/7/13 | ||
* @implNote ChargerRenderer | ||
*/ | ||
public class ChargerRenderer extends TieredHullMachineRenderer{ | ||
public final static ResourceLocation CHARGER_IDLE = GTCEu.id("block/machines/charger/overlay_charger_idle"); | ||
public final static ResourceLocation CHARGER_RUNNING = GTCEu.id("block/machines/charger/overlay_charger_running"); | ||
public final static ResourceLocation CHARGER_RUNNING_EMISSIVE = GTCEu.id("block/machines/charger/overlay_charger_running_emissive"); | ||
public final static ResourceLocation CHARGER_FINISHED = GTCEu.id("block/machines/charger/overlay_charger_finished"); | ||
public final static ResourceLocation CHARGER_FINISHED_EMISSIVE = GTCEu.id("block/machines/charger/overlay_charger_finished_emissive"); | ||
|
||
public ChargerRenderer(int tier) { | ||
super(tier, GTCEu.id("block/machine/hull_machine")); | ||
} | ||
|
||
@Override | ||
@Environment(EnvType.CLIENT) | ||
public void renderMachine(List<BakedQuad> quads, MachineDefinition definition, @Nullable MetaMachine machine, Direction frontFacing, @Nullable Direction side, RandomSource rand, Direction modelFacing, ModelState modelState) { | ||
super.renderMachine(quads, definition, machine, frontFacing, side, rand, modelFacing, modelState); | ||
var state = ChargerMachine.State.IDLE; | ||
if (machine instanceof ChargerMachine charger) { | ||
state = charger.getState(); | ||
} | ||
|
||
if (side == frontFacing && modelFacing != null) { | ||
var bakedFaces = new ArrayList<BakedQuad>(); | ||
switch (state) { | ||
case IDLE -> bakedFaces.add(FaceQuad.bakeFace(modelFacing, ModelFactory.getBlockSprite(CHARGER_IDLE), modelState, -1, 0, false, true)); | ||
case RUNNING -> { | ||
if (ConfigHolder.INSTANCE.client.machinesEmissiveTextures) { | ||
bakedFaces.add(FaceQuad.bakeFace(modelFacing, ModelFactory.getBlockSprite(CHARGER_RUNNING), modelState, -1, 0, true, true)); | ||
bakedFaces.add(FaceQuad.bakeFace(modelFacing, ModelFactory.getBlockSprite(CHARGER_RUNNING_EMISSIVE), modelState, 0, 15, true, false)); | ||
} else { | ||
bakedFaces.add(FaceQuad.bakeFace(modelFacing, ModelFactory.getBlockSprite(CHARGER_RUNNING), modelState, -1, 0, true, true)); | ||
} | ||
} | ||
case FINISHED -> { | ||
if (ConfigHolder.INSTANCE.client.machinesEmissiveTextures) { | ||
bakedFaces.add(FaceQuad.bakeFace(modelFacing, ModelFactory.getBlockSprite(CHARGER_FINISHED), modelState, -1, 0, true, true)); | ||
bakedFaces.add(FaceQuad.bakeFace(modelFacing, ModelFactory.getBlockSprite(CHARGER_FINISHED_EMISSIVE), modelState, 0, 15, true, false)); | ||
} else { | ||
bakedFaces.add(FaceQuad.bakeFace(modelFacing, ModelFactory.getBlockSprite(CHARGER_FINISHED), modelState, -1, 0, true, true)); | ||
} | ||
} | ||
} | ||
quads.addAll(bakedFaces); | ||
|
||
} | ||
} | ||
|
||
@Override | ||
@Environment(EnvType.CLIENT) | ||
public void onPrepareTextureAtlas(ResourceLocation atlasName, Consumer<ResourceLocation> register) { | ||
super.onPrepareTextureAtlas(atlasName, register); | ||
if (atlasName.equals(TextureAtlas.LOCATION_BLOCKS)) { | ||
register.accept(CHARGER_IDLE); | ||
register.accept(CHARGER_RUNNING); | ||
register.accept(CHARGER_RUNNING_EMISSIVE); | ||
register.accept(CHARGER_FINISHED); | ||
register.accept(CHARGER_FINISHED_EMISSIVE); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.