Skip to content

Commit

Permalink
Begin adding basic generator, improve laser arm optics and block brea…
Browse files Browse the repository at this point in the history
…king logic
  • Loading branch information
Rearth committed Mar 11, 2024
1 parent 55c659b commit 1ee3b79
Show file tree
Hide file tree
Showing 29 changed files with 853 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.4 2024-03-07T19:17:34.0084518 Oritech/Model Definitions
// 1.20.4 2024-03-11T15:36:48.2448916 Oritech/Model Definitions
3d6f377b938592ac22aca17bd64561a6579ad217 assets\oritech\blockstates\grinder_block.json
8ede0997449fd1c3f65a07df184768a843b473ed assets\oritech\models\item\centrifuge_block.json
90e28b721796ff7ee21c8eefe4525f03a251d2fb assets\oritech\models\block\machine_extender.json
Expand All @@ -12,14 +12,17 @@ e6f197ee5ac22cd68bc502a86d40b65bfe40884a assets\oritech\models\item\target_desig
e4497bad8afbd4f4b4e830d892284a05718b06dd assets\oritech\models\block\machine_core_basic.json
505d30e3b61ee0ba1f2616e1226689e2cdb7ab58 assets\oritech\models\block\addon_indicator_block.json
a5651b8d4a27308b40c404f7cd3abcf9769b64b6 assets\oritech\models\item\machine_core_basic.json
e109fcba8a22fe480b127c3f8972d80bf3821f51 assets\oritech\blockstates\basic_generator_block.json
2f7dfa17792770a034a13f117e6b8b1942b459e4 assets\oritech\models\block\placer_block.json
ee822d455f99c8c53c789fdb744979f678ca2729 assets\oritech\blockstates\fertilizer_block.json
46af77abe62b29d232feadccde429fd59d5603fc assets\oritech\blockstates\placer_block.json
3d37038977380bd685f913e722cc3b1c3a25c35d assets\oritech\models\item\atomic_forge_block.json
3be551406a325c82d9ec237b4b2e9e12fa5736d5 assets\oritech\blockstates\test_generator_block.json
eafe84c787830ab2a866e0878e9ed718d58659f5 assets\oritech\blockstates\banana_block.json
b5ee97616ae0d2da17dfaecf45aa42f2cf19f691 assets\oritech\blockstates\machine_extender.json
25864df3cd7786f2bf4fe6fa9855b3cf366c28ca assets\oritech\models\item\banana.json
1fdbeb99862a58436d745edb768b503539ecb295 assets\oritech\models\item\placer_block.json
58b38bcc6c404953490330d4cc797464b6874d88 assets\oritech\models\item\test_generator_block.json
b8bc03092cb1eb686ede01daffc7421253af860c assets\oritech\models\item\machine_extender.json
9cd64a2fe3b9a0ee479646d36cc0302bcd7cab4f assets\oritech\models\block\destroyer_block.json
63f14855c688ce7ec236097ce232dd381cbc1538 assets\oritech\blockstates\addon_indicator_block.json
Expand All @@ -30,12 +33,13 @@ b8bc03092cb1eb686ede01daffc7421253af860c assets\oritech\models\item\machine_exte
54472f85797924c842326a60299d72263cb2c301 assets\oritech\blockstates\block_destroyer_head.json
4021223f19511a9e81a833342c1d05f5af891c10 assets\oritech\blockstates\atomic_forge_block.json
ff59e92a557b29eeb7f85b1c15ef206c5b99aff6 assets\oritech\models\item\foundry_block.json
907e1d1717c926ebc0455ebe3291c7e917eb74d2 assets\oritech\models\item\basic_generator_block.json
c641d411ad252487b93d779cee9028b9ee920281 assets\oritech\blockstates\machine_core_basic.json
a5afa0ba8780ec08bd0a9284bc08e0c681fe7158 assets\oritech\blockstates\block_placer_head.json
f29468ff950a191567ab35557334666099ccd7cc assets\oritech\blockstates\assembler_block.json
5054284e6d5fe0785ac93bdda5101c47337953cf assets\oritech\models\item\machine_frame_block.json
3810f72943d88c81d3ab6b4329d437911c859621 assets\oritech\blockstates\powered_furnace_block.json
1b9cd3719105dc1e03398de41f2cab37337816fe assets\oritech\blockstates\machine_core_good.json
3810f72943d88c81d3ab6b4329d437911c859621 assets\oritech\blockstates\powered_furnace_block.json
5462a2453fcdd2f8b99129894aec60f282d29ca9 assets\oritech\models\item\pulverizer_block.json
a3f9b72f6f36d42af4e5c3a87d7e180b2e36a2ed assets\oritech\models\item\machine_core_good.json
469ea8a66c529fe26bc029c21092e7f062ed0e40 assets\oritech\models\block\banana_block.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "oritech:block/basic_generator_block"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "oritech:block/test_generator_block"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "oritech:block/basic_generator_block"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "oritech:block/test_generator_block"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.fabricmc.fabric.api.transfer.v1.item.InventoryStorage;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.CombinedStorage;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
Expand All @@ -19,15 +16,13 @@
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
Expand All @@ -46,7 +41,10 @@
import software.bernie.geckolib.util.GeckoLibUtil;
import team.reborn.energy.api.EnergyStorage;

import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

public abstract class MachineBlockEntity extends BlockEntity
implements ExtendedScreenHandlerFactory, GeoBlockEntity, EnergyProvider, ScreenProvider, InventoryProvider, BlockEntityTicker<MachineBlockEntity> {
Expand All @@ -57,28 +55,24 @@ public abstract class MachineBlockEntity extends BlockEntity
public static final RawAnimation IDLE = RawAnimation.begin().thenPlayAndHold("idle");
public static final RawAnimation WORKING = RawAnimation.begin().thenLoop("working");
protected final AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this);
private final AnimationController<MachineBlockEntity> animationController = getAnimationController();

protected final SimpleInventory inventory = new SimpleMachineInventory(getInventorySize());
// crafting / processing
protected int progress;
private final AnimationController<MachineBlockEntity> animationController = getAnimationController();
protected int energyPerTick;
protected OritechRecipe currentRecipe = OritechRecipe.DUMMY;
protected InventoryInputMode inventoryInputMode = InventoryInputMode.FILL_LEFT_TO_RIGHT;

// network state
protected boolean networkDirty = true;

//own storage
protected final DynamicEnergyStorage energyStorage = new DynamicEnergyStorage(getDefaultCapacity(), getDefaultInsertRate(), 0) {
protected final DynamicEnergyStorage energyStorage = new DynamicEnergyStorage(getDefaultCapacity(), getDefaultInsertRate(), getDefaultExtractionRate()) {
@Override
public void onFinalCommit() {
super.onFinalCommit();
markNetDirty();
}
};

protected final SimpleInventory inventory = new SimpleMachineInventory(getInventorySize());

public MachineBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, int energyPerTick) {
super(type, pos, state);
this.energyPerTick = energyPerTick;
Expand Down Expand Up @@ -133,7 +127,7 @@ protected void useEnergy() {
energyStorage.amount -= calculateEnergyUsage();
}

private float calculateEnergyUsage() {
protected float calculateEnergyUsage() {
return energyPerTick * getEfficiencyMultiplier() * (1 / getSpeedMultiplier());
}

Expand All @@ -159,7 +153,7 @@ private boolean isActivelyViewed() {
return closestPlayer != null && closestPlayer.currentScreenHandler instanceof BasicMachineScreenHandler handler && getPos().equals(handler.getBlockPos());
}

private void sendNetworkEntry() {
protected void sendNetworkEntry() {
NetworkContent.MACHINE_CHANNEL.serverHandle(this).send(new NetworkContent.MachineSyncPacket(getPos(), energyStorage.amount, energyStorage.capacity, energyStorage.maxInsert, progress, currentRecipe, inventoryInputMode));
networkDirty = false;
}
Expand Down Expand Up @@ -241,7 +235,7 @@ protected boolean canAddToSlot(ItemStack input, ItemStack slot) {
return true;
}

private Optional<RecipeEntry<OritechRecipe>> getRecipe() {
protected Optional<RecipeEntry<OritechRecipe>> getRecipe() {
return Objects.requireNonNull(world).getRecipeManager().getFirstMatch(getOwnRecipeType(), getInputInventory(), world);
}

Expand Down Expand Up @@ -545,8 +539,17 @@ public float getDisplayedEnergyUsage() {
return calculateEnergyUsage();
}

public long getDefaultCapacity() {return 5000;}
public long getDefaultInsertRate() {return 100;}
public long getDefaultCapacity() {
return 5000;
}

public long getDefaultInsertRate() {
return 100;
}

public long getDefaultExtractionRate() {
return 0;
}

@Override
public Inventory getDisplayedInventory() {
Expand Down
Loading

0 comments on commit 1ee3b79

Please sign in to comment.