Solar panel GUI & internal storage plus misc spelling fixes (#1912)
* Solar panel GUI & internal storage plus misc spelling fixes * Pullrequest fixes and recipe changes
This commit is contained in:
parent
73f0ff98e4
commit
b2f4804987
14 changed files with 201 additions and 83 deletions
|
@ -33,6 +33,9 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
|
@ -45,25 +48,26 @@ import techreborn.init.TRContent.SolarPanels;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
|
||||
public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop, IContainerProvider {
|
||||
|
||||
|
||||
// State ZEROGEN: No exposure to sun
|
||||
// State NIGHTGEN: Has direct exposure to sun
|
||||
// State DAYGEN: Has exposure to sun and weather is sunny and not raining/thundering
|
||||
public static final int ZEROGEN = 0;
|
||||
public static final int NIGHTGEN = 1;
|
||||
public static final int DAYGEN = 2;
|
||||
|
||||
private int state = ZEROGEN;
|
||||
private int prevState = ZEROGEN;
|
||||
|
||||
boolean canSeeSky = false;
|
||||
boolean lastState = false;
|
||||
private SolarPanels panel;
|
||||
|
||||
public SolarPanelBlockEntity() {
|
||||
super(TRBlockEntities.SOLAR_PANEL);
|
||||
}
|
||||
|
||||
public SolarPanelBlockEntity(SolarPanels panel) {
|
||||
super(TRBlockEntities.SOLAR_PANEL);
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
public boolean isSunOut() {
|
||||
return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDay();
|
||||
}
|
||||
|
||||
private void updatePanel() {
|
||||
if (world == null) {
|
||||
return;
|
||||
|
@ -75,35 +79,81 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
}
|
||||
}
|
||||
|
||||
// PowerAcceptorBlockEntity
|
||||
|
||||
// Setters and getters for the GUI to sync
|
||||
private void setSunState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int getSunState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
SolarPanels getPanel() {
|
||||
if (panel == null) {
|
||||
updatePanel();
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
if (world.isSkyVisible(pos.up())) {
|
||||
this.setSunState(NIGHTGEN);
|
||||
|
||||
if (!world.isRaining() && !world.isThundering() && world.isDay()) {
|
||||
this.setSunState(DAYGEN);
|
||||
}
|
||||
} else {
|
||||
this.setSunState(ZEROGEN);
|
||||
}
|
||||
|
||||
if (prevState != this.getSunState()) {
|
||||
boolean isGenerating = getSunState() == DAYGEN;
|
||||
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, isGenerating));
|
||||
|
||||
prevState = this.getSunState();
|
||||
}
|
||||
}
|
||||
|
||||
public int getGenerationRate() {
|
||||
int rate = 0;
|
||||
|
||||
switch (getSunState()) {
|
||||
case DAYGEN:
|
||||
rate = getPanel().generationRateD;
|
||||
break;
|
||||
case NIGHTGEN:
|
||||
rate = getPanel().generationRateN;
|
||||
}
|
||||
|
||||
return rate;
|
||||
}
|
||||
|
||||
|
||||
// Overrides
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getPanel() == TRContent.SolarPanels.CREATIVE) {
|
||||
checkOverfill = false;
|
||||
setEnergy(Integer.MAX_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
// State checking and updating
|
||||
if (world.getTime() % 20 == 0) {
|
||||
canSeeSky = world.isSkyVisible(pos.up());
|
||||
if (lastState != isSunOut()) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, isSunOut()));
|
||||
lastState = isSunOut();
|
||||
}
|
||||
}
|
||||
int powerToAdd;
|
||||
if (isSunOut()) {
|
||||
powerToAdd = getPanel().generationRateD;
|
||||
} else if (canSeeSky) {
|
||||
powerToAdd = getPanel().generationRateN;
|
||||
} else {
|
||||
powerToAdd = 0;
|
||||
updateState();
|
||||
}
|
||||
|
||||
addEnergy(powerToAdd);
|
||||
// Power generation calculations
|
||||
addEnergy(getGenerationRate());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,7 +173,8 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return getPanel().generationRateD;
|
||||
// Solar panel output will only be limited by the cables the users use
|
||||
return EnergyTier.EXTREME.getMaxOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,6 +182,16 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSlotConfig() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyTier getTier() {
|
||||
return getPanel().powerTier;
|
||||
|
@ -141,13 +202,6 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
// Nope
|
||||
}
|
||||
|
||||
public SolarPanels getPanel() {
|
||||
if(panel == null){
|
||||
updatePanel();
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
||||
if (panel == SolarPanels.CREATIVE) {
|
||||
|
@ -188,4 +242,12 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
public ItemStack getToolDrop(final PlayerEntity playerIn) {
|
||||
return new ItemStack(getBlockType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("solar_panel").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).syncEnergyValue()
|
||||
.sync(this::getSunState, this::setSunState)
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
|
@ -32,6 +32,10 @@ import net.minecraft.world.World;
|
|||
import reborncore.api.blockentity.IMachineGuiHandler;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity;
|
||||
import techreborn.blocks.GenericMachineBlock;
|
||||
import techreborn.client.EGui;
|
||||
import techreborn.client.gui.GuiSolar;
|
||||
import techreborn.init.TRContent.SolarPanels;
|
||||
import techreborn.blockentity.generator.SolarPanelBlockEntity;
|
||||
|
||||
|
@ -54,7 +58,10 @@ public class BlockSolarPanel extends BlockMachineBase {
|
|||
|
||||
@Override
|
||||
public IMachineGuiHandler getGui() {
|
||||
return null;
|
||||
if(this.panelType == SolarPanels.CREATIVE){
|
||||
return null;
|
||||
}
|
||||
return EGui.SOLAR_PANEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -74,6 +74,7 @@ public enum EGui implements IMachineGuiHandler {
|
|||
ROLLING_MACHINE,
|
||||
SAWMILL,
|
||||
SCRAPBOXINATOR,
|
||||
SOLAR_PANEL,
|
||||
SEMIFLUID_GENERATOR,
|
||||
THERMAL_GENERATOR,
|
||||
VACUUM_FREEZER,
|
||||
|
|
|
@ -41,6 +41,7 @@ import techreborn.blockentity.data.DataDrivenBEProvider;
|
|||
import techreborn.blockentity.data.DataDrivenGui;
|
||||
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
|
||||
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
|
||||
import techreborn.blockentity.generator.SolarPanelBlockEntity;
|
||||
import techreborn.blockentity.generator.advanced.DieselGeneratorBlockEntity;
|
||||
import techreborn.blockentity.generator.advanced.GasTurbineBlockEntity;
|
||||
import techreborn.blockentity.generator.advanced.SemiFluidGeneratorBlockEntity;
|
||||
|
@ -149,6 +150,8 @@ public class GuiHandler {
|
|||
return new GuiIndustrialSawmill(syncID, player, (IndustrialSawmillBlockEntity) blockEntity);
|
||||
case SCRAPBOXINATOR:
|
||||
return new GuiScrapboxinator(syncID, player, (ScrapboxinatorBlockEntity) blockEntity);
|
||||
case SOLAR_PANEL:
|
||||
return new GuiSolar(syncID, player, (SolarPanelBlockEntity) blockEntity);
|
||||
case SEMIFLUID_GENERATOR:
|
||||
return new GuiSemifluidGenerator(syncID, player, (SemiFluidGeneratorBlockEntity) blockEntity);
|
||||
case THERMAL_GENERATOR:
|
||||
|
|
70
src/main/java/techreborn/client/gui/GuiSolar.java
Normal file
70
src/main/java/techreborn/client/gui/GuiSolar.java
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.blockentity.generator.SolarPanelBlockEntity;
|
||||
|
||||
public class GuiSolar extends GuiBase<BuiltContainer> {
|
||||
|
||||
SolarPanelBlockEntity blockEntity;
|
||||
|
||||
public GuiSolar(int syncID, PlayerEntity player, SolarPanelBlockEntity panel) {
|
||||
super(player, panel, panel.createContainer(syncID, player));
|
||||
this.blockEntity = panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float lastFrameDuration, int mouseX, int mouseY) {
|
||||
super.drawBackground(lastFrameDuration, mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawForeground(int mouseX, int mouseY) {
|
||||
super.drawForeground(mouseX, mouseY);
|
||||
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
|
||||
|
||||
builder.drawMultiEnergyBar(this, 156, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
|
||||
switch (blockEntity.getSunState()) {
|
||||
case SolarPanelBlockEntity.DAYGEN:
|
||||
builder.drawString(this, StringUtils.t("techreborn.message.daygen"), 10, 20, 15129632);
|
||||
break;
|
||||
case SolarPanelBlockEntity.NIGHTGEN:
|
||||
builder.drawString(this, StringUtils.t("techreborn.message.nightgen"), 10, 20, 7566195);
|
||||
break;
|
||||
case SolarPanelBlockEntity.ZEROGEN:
|
||||
builder.drawString(this, StringUtils.t("techreborn.message.zerogen"), 10, 20, 12066591);
|
||||
break;
|
||||
}
|
||||
|
||||
builder.drawString(this, "Generating: " + blockEntity.getGenerationRate() + " E/t", 10, 30, 0);
|
||||
|
||||
}
|
||||
}
|
|
@ -30,6 +30,9 @@ import reborncore.common.config.Config;
|
|||
public class TechRebornConfig {
|
||||
|
||||
// Generators
|
||||
@Config(config = "generators", category = "solarPanelGeneral", key = "internalCapacity", comment = "Multiplier for internal capacity of solar panels (multiplier * day generation rate)")
|
||||
public static int solarInternalCapacityMultiplier = 2000;
|
||||
|
||||
@Config(config = "generators", category = "solarPanelBasic", key = "basicDayRate", comment = "Generation rate during day for Basic Solar Panel (Value in FE)")
|
||||
public static int basicGenerationRateD = 1;
|
||||
|
||||
|
@ -55,10 +58,10 @@ public class TechRebornConfig {
|
|||
public static int ultimateGenerationRateN = 16;
|
||||
|
||||
@Config(config = "generators", category = "solarPanelQuantum", key = "quantumDayRate", comment = "Generation rate during day for Quantum Solar Panel (Value in FE)")
|
||||
public static int quantumGenerationRateD = 1024;
|
||||
public static int quantumGenerationRateD = 2048;
|
||||
|
||||
@Config(config = "generators", category = "solarPanelQuantum", key = "quantumNightRate", comment = "Generation rate during night for Quantum Solar Panel (Value in FE)")
|
||||
public static int quantumGenerationRateN = 64;
|
||||
public static int quantumGenerationRateN = 128;
|
||||
|
||||
@Config(config = "generators", category = "lightning_rod", key = "LightningRodMaxOutput", comment = "Lightning Rod Max Output (Value in EU)")
|
||||
public static int lightningRodMaxOutput = 2048;
|
||||
|
|
|
@ -241,8 +241,8 @@ public class TRContent {
|
|||
block = new BlockSolarPanel(this);
|
||||
this.generationRateD = generationRateD;
|
||||
this.generationRateN = generationRateN;
|
||||
// Buffer for 2 mins of work
|
||||
internalCapacity = generationRateD * 2_400;
|
||||
|
||||
internalCapacity = generationRateD * TechRebornConfig.solarInternalCapacityMultiplier;
|
||||
|
||||
InitUtils.setup(block, name + "_solar_panel");
|
||||
}
|
||||
|
|
|
@ -601,6 +601,9 @@
|
|||
"techreborn.message.nanosaberInactive": "Inactive",
|
||||
"techreborn.message.nanosaberEnergyErrorTo": "Not Enough Energy to",
|
||||
"techreborn.message.nanosaberEnergyError": "Not Enough Energy:",
|
||||
"techreborn.message.daygen": "Panel in direct sunlight",
|
||||
"techreborn.message.nightgen": "Panel in reduced sunlight",
|
||||
"techreborn.message.zerogen": "Panel obstructed from sky",
|
||||
|
||||
"keys.techreborn.category": "TechReborn Category",
|
||||
"keys.techreborn.config": "Config",
|
||||
|
@ -636,7 +639,7 @@
|
|||
"techreborn.tooltip.wip": "WIP Coming Soon",
|
||||
"techreborn.tooltip.inventory": "Inventory",
|
||||
"techreborn.tooltip.upgrades": "Upgrades",
|
||||
"techreborn.tooltip.alarm": "Shift rightclick to change sound",
|
||||
"techreborn.tooltip.alarm": "Shift right-click to change sound",
|
||||
"techreborn.tooltip.generationRate.day": "Generation Rate Day",
|
||||
"techreborn.tooltip.generationRate.night": "Generation Rate Night",
|
||||
|
||||
|
@ -649,7 +652,7 @@
|
|||
"techreborn.manual.refundbtn": "Refund",
|
||||
|
||||
"_comment24": "Advancements",
|
||||
"advancements.techreborn.root.desc": "Now that you have acquired Tech Reborn ore, you might find a tree tap usefull.",
|
||||
"advancements.techreborn.root.desc": "Now that you have acquired Tech Reborn ore, you might find a tree tap useful.",
|
||||
"advancements.techreborn.treetap": "TreeTap",
|
||||
"advancements.techreborn.treetap.desc": "Now that you have crafted a tree tap you will want to use it on a sap spot on a rubber tree.",
|
||||
"advancements.techreborn.sap": "Rubber Sap",
|
||||
|
@ -663,7 +666,7 @@
|
|||
"techreborn:chemical_reactor": "Chemical Reactor",
|
||||
"techreborn:compressor": "Compressor",
|
||||
"techreborn:distillation_tower": "Distillation Tower",
|
||||
"techreborn:extractor": "Extrator",
|
||||
"techreborn:extractor": "Extractor",
|
||||
"techreborn:grinder": "Grinder",
|
||||
"techreborn:implosion_compressor": "Implosion Compressor",
|
||||
"techreborn:industrial_electrolyzer": "Industrial Electrolyzer",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"parent": "minecraft:block/cube_bottom_top",
|
||||
"textures": {
|
||||
"top": "techreborn:block/machines/generators/quantum_solar_panel_top",
|
||||
"bottom": "techreborn:block/machines/generators/generator_bottom",
|
||||
"side": "techreborn:block/machines/generators/solar_panel_side_off"
|
||||
"bottom": "techreborn:block/machines/tier3_machines/quantum_chest_bottom",
|
||||
"side": "techreborn:block/machines/generators/quantum_solar_panel_side_off"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"parent": "minecraft:block/cube_bottom_top",
|
||||
"textures": {
|
||||
"top": "techreborn:block/machines/generators/quantum_solar_panel_top",
|
||||
"bottom": "techreborn:block/machines/generators/generator_bottom",
|
||||
"side": "techreborn:block/machines/generators/solar_panel_side_on"
|
||||
"bottom": "techreborn:block/machines/tier3_machines/quantum_chest_bottom",
|
||||
"side": "techreborn:block/machines/generators/quantum_solar_panel_side_on"
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 321 B |
Binary file not shown.
After Width: | Height: | Size: 322 B |
|
@ -1,22 +1,16 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"DLD",
|
||||
"LDL",
|
||||
"CPC"
|
||||
"AAA",
|
||||
"ABA",
|
||||
"AAA"
|
||||
],
|
||||
"key": {
|
||||
"P": {
|
||||
"A": {
|
||||
"item": "techreborn:ultimate_solar_panel"
|
||||
},
|
||||
"C": {
|
||||
"item": "techreborn:energy_flow_chip"
|
||||
},
|
||||
"D": {
|
||||
"tag": "c:diamond_dust"
|
||||
},
|
||||
"L": {
|
||||
"item": "techreborn:reinforced_glass"
|
||||
"B": {
|
||||
"item": "techreborn:uu_matter"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"DLD",
|
||||
"LDL",
|
||||
"CPC"
|
||||
],
|
||||
"key": {
|
||||
"P": {
|
||||
"item": "techreborn:industrial_machine_frame"
|
||||
},
|
||||
"C": {
|
||||
"item": "techreborn:energy_flow_chip"
|
||||
},
|
||||
"D": {
|
||||
"tag": "c:diamond_dust"
|
||||
},
|
||||
"L": {
|
||||
"item": "techreborn:reinforced_glass"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:quantum_solar_panel"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue