-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pull mode for Energy Distributor module
- Loading branch information
Showing
12 changed files
with
191 additions
and
46 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/generated/resources/assets/modularrouters/models/item/energy_distributor_module.json
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
8 changes: 8 additions & 0 deletions
8
...generated/resources/assets/modularrouters/models/item/energy_distributor_module_pull.json
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,8 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "modularrouters:item/module/module_layer0", | ||
"layer1": "modularrouters:item/module/module_layer1", | ||
"layer2": "modularrouters:item/module/energy_distributor_module_pull" | ||
} | ||
} |
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
56 changes: 56 additions & 0 deletions
56
src/main/java/me/desht/modularrouters/client/gui/module/EnergyDistributorModuleScreen.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,56 @@ | ||
package me.desht.modularrouters.client.gui.module; | ||
|
||
import me.desht.modularrouters.container.ModuleMenu; | ||
import me.desht.modularrouters.core.ModBlocks; | ||
import me.desht.modularrouters.core.ModDataComponents; | ||
import me.desht.modularrouters.logic.compiled.CompiledDistributorModule; | ||
import me.desht.modularrouters.logic.compiled.CompiledDistributorModule.DistributionStrategy; | ||
import me.desht.modularrouters.logic.compiled.CompiledEnergyDistributorModule; | ||
import me.desht.modularrouters.logic.settings.TransferDirection; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.Util; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import static me.desht.modularrouters.client.util.ClientUtil.xlate; | ||
|
||
public class EnergyDistributorModuleScreen extends ModuleScreen { | ||
private static final ItemStack ROUTER_STACK = new ItemStack(ModBlocks.MODULAR_ROUTER.get()); | ||
|
||
private DistributorModuleScreen.DirectionButton db; | ||
|
||
public EnergyDistributorModuleScreen(ModuleMenu container, Inventory inv, Component displayText) { | ||
super(container, inv, displayText); | ||
} | ||
|
||
@Override | ||
public void init() { | ||
super.init(); | ||
|
||
CompiledEnergyDistributorModule cdm = new CompiledEnergyDistributorModule(null, moduleItemStack); | ||
|
||
addRenderableWidget(db = new DistributorModuleScreen.DirectionButton(leftPos + 147, topPos + 43, cdm.isPulling(), this)); | ||
|
||
getMouseOverHelp().addHelpRegion(leftPos + 125, topPos + 41, leftPos + 165, topPos + 61, | ||
xlate("modularrouters.guiText.popup.distributor.direction").withStyle(ChatFormatting.YELLOW)); | ||
} | ||
|
||
@Override | ||
protected ItemStack buildModifiedItemStack() { | ||
return Util.make(super.buildModifiedItemStack(), stack -> | ||
stack.set(ModDataComponents.DISTRIBUTOR_SETTINGS, new CompiledDistributorModule.DistributorSettings( | ||
DistributionStrategy.ROUND_ROBIN, | ||
db.isToggled() ? TransferDirection.TO_ROUTER : TransferDirection.FROM_ROUTER | ||
)) | ||
); | ||
} | ||
|
||
@Override | ||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) { | ||
super.renderBg(graphics, partialTicks, mouseX, mouseY); | ||
|
||
graphics.renderItem(ROUTER_STACK, leftPos + 127, topPos + 43); | ||
} | ||
} |
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
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
27 changes: 26 additions & 1 deletion
27
src/main/java/me/desht/modularrouters/item/module/EnergyDistributorModule.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
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.