Skip to content

Commit

Permalink
Add machine energy acceptor addon
Browse files Browse the repository at this point in the history
  • Loading branch information
Rearth committed Feb 21, 2024
1 parent fca30c0 commit 03364a6
Show file tree
Hide file tree
Showing 14 changed files with 512 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// 1.20.4 2024-02-19T22:05:27.589798 Oritech/Model Definitions
// 1.20.4 2024-02-21T21:51:37.9684867 Oritech/Model Definitions
3d6f377b938592ac22aca17bd64561a6579ad217 assets\oritech\blockstates\grinder_block.json
90e28b721796ff7ee21c8eefe4525f03a251d2fb assets\oritech\models\block\machine_extender.json
16b697f4a40bfdcd8c39629776b97696e80681c7 assets\oritech\blockstates\machine_efficiency_addon.json
e9e01eaa866f29f36a31fd6872a4b1a499ce830b assets\oritech\models\item\machine_inventory_proxy_addon.json
eafe84c787830ab2a866e0878e9ed718d58659f5 assets\oritech\blockstates\banana_block.json
b5ee97616ae0d2da17dfaecf45aa42f2cf19f691 assets\oritech\blockstates\machine_extender.json
eafe84c787830ab2a866e0878e9ed718d58659f5 assets\oritech\blockstates\banana_block.json
c9c5614f832a38e30b60d0a15d75292159b16455 assets\oritech\models\item\machine_speed_addon.json
25864df3cd7786f2bf4fe6fa9855b3cf366c28ca assets\oritech\models\item\banana.json
b8bc03092cb1eb686ede01daffc7421253af860c assets\oritech\models\item\machine_extender.json
63f14855c688ce7ec236097ce232dd381cbc1538 assets\oritech\blockstates\addon_indicator_block.json
746b98d721e5ae0d96dd769e71b786afa8c2d142 assets\oritech\models\item\banana_block.json
63f14855c688ce7ec236097ce232dd381cbc1538 assets\oritech\blockstates\addon_indicator_block.json
7eb395cd65df72caf43bedc54067cbf53940fd6c assets\oritech\blockstates\machine_speed_addon.json
95eae9b13fb2835f15057d2fd4d9550192064ca4 assets\oritech\models\item\grinder_block.json
c641d411ad252487b93d779cee9028b9ee920281 assets\oritech\blockstates\machine_core_basic.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import org.jetbrains.annotations.Nullable;
import rearth.oritech.block.custom.machines.addons.CapacitorAddonBlock;
import rearth.oritech.block.custom.machines.addons.EnergyAddonBlock;
import rearth.oritech.block.custom.machines.addons.MachineAddonBlock;
import rearth.oritech.block.entity.machines.addons.AddonBlockEntity;
import rearth.oritech.client.ui.UpgradableMachineScreenHandler;
Expand Down Expand Up @@ -199,7 +199,7 @@ private void gatherAddonStats(List<AddonBlock> addons) {
speed *= addon.addonBlock.getSpeedMultiplier();
efficiency *= addon.addonBlock.getEfficiencyMultiplier();

if (addon.addonBlock instanceof CapacitorAddonBlock capacitorBlock) {
if (addon.addonBlock instanceof EnergyAddonBlock capacitorBlock) {
energyAmount += capacitorBlock.getAddedCapacity();
energyInsert += capacitorBlock.getAddedInsert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@

import net.minecraft.block.entity.BlockEntity;
import org.jetbrains.annotations.NotNull;
import rearth.oritech.block.entity.machines.addons.CapacitorAddonBlockEntity;
import rearth.oritech.block.entity.machines.addons.EnergyAcceptorAddonBlockEntity;

public class CapacitorAddonBlock extends MachineAddonBlock {
public class EnergyAddonBlock extends MachineAddonBlock {

private final long addedCapacity;
private final long addedInsert;
private final boolean acceptEnergy;

public CapacitorAddonBlock(Settings settings, boolean extender, float speedMultiplier, float efficiencyMultiplier, long addedCapacity, long addedInsert) {
public EnergyAddonBlock(Settings settings, boolean extender, float speedMultiplier, float efficiencyMultiplier, long addedCapacity, long addedInsert, boolean acceptEnergy) {
super(settings, extender, speedMultiplier, efficiencyMultiplier);
this.addedCapacity = addedCapacity;
this.addedInsert = addedInsert;
this.acceptEnergy = acceptEnergy;
}

@Override
public @NotNull Class<? extends BlockEntity> getBlockEntityType() {
return CapacitorAddonBlockEntity.class;
if (acceptEnergy) {
return EnergyAcceptorAddonBlockEntity.class;
} else {
return super.getBlockEntityType();
}
}

public long getAddedCapacity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

import java.util.Objects;

public class CapacitorAddonBlockEntity extends AddonBlockEntity implements EnergyProvider {
public class EnergyAcceptorAddonBlockEntity extends AddonBlockEntity implements EnergyProvider {
private final DelegatingEnergyStorage delegatedStorage = new DelegatingEnergyStorage(this::getMainStorage, this::isConnected);

private UpgradableMachineBlockEntity cachedController;

public CapacitorAddonBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntitiesContent.CAPACITOR_ADDON_ENTITY, pos, state);
public EnergyAcceptorAddonBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntitiesContent.ENERGY_ACCEPTOR_ADDON_ENTITY, pos, state);
}

private boolean isConnected() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
import io.wispforest.owo.ui.container.FlowLayout;
import io.wispforest.owo.ui.container.OverlayContainer;
import io.wispforest.owo.ui.core.*;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3i;
import rearth.oritech.Oritech;
import rearth.oritech.block.base.entity.MultiblockMachineEntity;
import rearth.oritech.block.base.entity.UpgradableMachineBlockEntity;
import rearth.oritech.block.custom.machines.addons.CapacitorAddonBlock;
import rearth.oritech.block.custom.machines.addons.EnergyAddonBlock;
import rearth.oritech.block.custom.machines.addons.MachineAddonBlock;
import rearth.oritech.client.ui.components.BlockPreviewComponent;
import rearth.oritech.init.BlockContent;
Expand Down Expand Up @@ -123,10 +121,12 @@ public void addMachinePreview(FlowLayout sidePanel) {
@Override
public void remove() {
super.remove();
handler.showSlots();
//handler.showSlots();
}
};

floatingPanel.zIndex(2000); // so it renders in front of itemslots

floatingPanel
.horizontalAlignment(HorizontalAlignment.CENTER)
.verticalAlignment(VerticalAlignment.CENTER);
Expand Down Expand Up @@ -170,7 +170,7 @@ public void remove() {
bottomPanel.child(Components.label(Text.of("⚡ " + String.format(pattern, efficiency) + "% ")).color(EFFICIENCY_COLOR).tooltip(Text.of("Energy Efficiency")));
}

if (addonBlockType instanceof CapacitorAddonBlock capacitorAddonBlock) {
if (addonBlockType instanceof EnergyAddonBlock capacitorAddonBlock) {
bottomPanel.child(Components.label(Text.of("\uD83D\uDD0B " + capacitorAddonBlock.getAddedCapacity() + "RF ")).color(CAPACITY_COLOR).tooltip(Text.of("Added Capacity")));
bottomPanel.child(Components.label(Text.of("\uD83D\uDCC8 " + capacitorAddonBlock.getAddedInsert() + "RF/t ")).color(THROUGPUT_COLOR).tooltip(Text.of("Added Throughput")));
}
Expand Down Expand Up @@ -206,7 +206,7 @@ public void remove() {

var openAddonsButton = Components.button(Text.of("Details"), button -> {
root.child(floatingPanel);
handler.hideSlots();
// handler.hideSlots();
});

sidePanel.child(openAddonsButton);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/rearth/oritech/init/BlockContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import rearth.oritech.block.custom.machines.AssemblerBlock;
import rearth.oritech.block.custom.machines.GrinderBlock;
import rearth.oritech.block.custom.machines.PulverizerBlock;
import rearth.oritech.block.custom.machines.addons.CapacitorAddonBlock;
import rearth.oritech.block.custom.machines.addons.EnergyAddonBlock;
import rearth.oritech.block.custom.machines.addons.InventoryProxyAddonBlock;
import rearth.oritech.block.custom.machines.addons.MachineAddonBlock;
import rearth.oritech.util.item.OritechGeoItem;
Expand Down Expand Up @@ -43,7 +43,8 @@ public class BlockContent implements BlockRegistryContainer {
public static final Block MACHINE_CORE_GOOD = new MachineCoreBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), 6);
public static final Block MACHINE_SPEED_ADDON = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 0.9f, 1.025f);
public static final Block MACHINE_EFFICIENCY_ADDON = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 0.9f);
public static final Block MACHINE_CAPACITOR_ADDON = new CapacitorAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 1f, 10000, 500);
public static final Block MACHINE_CAPACITOR_ADDON = new EnergyAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 1f, 20000, 500, false);
public static final Block MACHINE_ACCEPTOR_ADDON = new EnergyAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 1f, 5000, 50, true);
public static final Block MACHINE_INVENTORY_PROXY_ADDON = new InventoryProxyAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), false, 1, 1f);
public static final Block MACHINE_EXTENDER = new MachineAddonBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque(), true, 1, 1);

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/rearth/oritech/init/BlockEntitiesContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import rearth.oritech.block.entity.machines.MachineCoreEntity;
import rearth.oritech.block.entity.machines.PulverizerBlockEntity;
import rearth.oritech.block.entity.machines.addons.AddonBlockEntity;
import rearth.oritech.block.entity.machines.addons.CapacitorAddonBlockEntity;
import rearth.oritech.block.entity.machines.addons.EnergyAcceptorAddonBlockEntity;
import rearth.oritech.block.entity.machines.addons.InventoryProxyAddonBlockEntity;
import rearth.oritech.util.EnergyProvider;
import team.reborn.energy.api.EnergyStorage;
Expand All @@ -33,14 +33,15 @@ public class BlockEntitiesContent implements AutoRegistryContainer<BlockEntityTy
public static final BlockEntityType<AssemblerBlockEntity> ASSEMBLER_ENTITY = FabricBlockEntityTypeBuilder.create(AssemblerBlockEntity::new, BlockContent.ASSEMBLER_BLOCK).build();

@AssignSidedEnergy
public static final BlockEntityType<CapacitorAddonBlockEntity> CAPACITOR_ADDON_ENTITY = FabricBlockEntityTypeBuilder.create(CapacitorAddonBlockEntity::new, BlockContent.MACHINE_CAPACITOR_ADDON).build();
public static final BlockEntityType<EnergyAcceptorAddonBlockEntity> ENERGY_ACCEPTOR_ADDON_ENTITY = FabricBlockEntityTypeBuilder.create(EnergyAcceptorAddonBlockEntity::new, BlockContent.MACHINE_ACCEPTOR_ADDON).build();

public static final BlockEntityType<InventoryProxyAddonBlockEntity> INVENTORY_PROXY_ADDON_ENTITY = FabricBlockEntityTypeBuilder.create(InventoryProxyAddonBlockEntity::new, BlockContent.MACHINE_INVENTORY_PROXY_ADDON).build();

public static final BlockEntityType<AddonBlockEntity> ADDON_ENTITY = FabricBlockEntityTypeBuilder.create(AddonBlockEntity::new,
BlockContent.MACHINE_SPEED_ADDON,
BlockContent.MACHINE_EFFICIENCY_ADDON,
BlockContent.MACHINE_EXTENDER
BlockContent.MACHINE_EXTENDER,
BlockContent.MACHINE_CAPACITOR_ADDON
).build();

@AssignSidedEnergy
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"variants": {
"face=wall,facing=north,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"x": 90,
"y": 0
},
"face=wall,facing=north,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"x": 90,
"y": 0
},
"face=wall,facing=south,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"x": 90,
"y": 180
},
"face=wall,facing=south,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"x": 90,
"y": 180
},
"face=wall,facing=west,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"x": 90,
"y": 270
},
"face=wall,facing=west,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"x": 90,
"y": 270
},
"face=wall,facing=east,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"x": 90,
"y": 90
},
"face=wall,facing=east,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"x": 90,
"y": 90
},
"face=floor,facing=north,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on"
},
"face=floor,facing=north,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon"
},
"face=floor,facing=south,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"y": 180
},
"face=floor,facing=south,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"y": 180
},
"face=floor,facing=west,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"y": 270
},
"face=floor,facing=west,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"y": 270
},
"face=floor,facing=east,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"y": 90
},
"face=floor,facing=east,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"y": 90
},
"face=ceiling,facing=north,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"x": 180,
"y": 180
},
"face=ceiling,facing=north,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"x": 180,
"y": 180
},
"face=ceiling,facing=south,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"x": 0
},
"face=ceiling,facing=south,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"x": 0
},
"face=ceiling,facing=west,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"x": 180,
"y": 90
},
"face=ceiling,facing=west,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"x": 180,
"y": 90
},
"face=ceiling,facing=east,addon_used=true": {
"model": "oritech:block/machine_acceptor_addon_on",
"x": 180,
"y": 270
},
"face=ceiling,facing=east,addon_used=false": {
"model": "oritech:block/machine_acceptor_addon",
"x": 180,
"y": 270
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/assets/oritech/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"block.oritech.assembler_block": "Assembler",
"block.oritech.machine_core": "Machine core",
"block.oritech.machine_speed_addon": "Speed Addon",
"block.oritech.machine_efficiency_addon": "Efficiency Addon",
"block.oritech.machine_efficiency_addon": "Energy Efficiency Addon",
"block.oritech.machine_capacitor_addon": "Capacitor Addon",
"block.oritech.machine_acceptor_addon": "Energy Acceptor Addon",
"block.oritech.machine_inventory_proxy_addon": "Inventory Proxy Addon",
"block.oritech.machine_extender": "Machine Extender"
}
Loading

0 comments on commit 03364a6

Please sign in to comment.