Skip to content

Commit

Permalink
Begin working on laser arm
Browse files Browse the repository at this point in the history
  • Loading branch information
Rearth committed Mar 8, 2024
1 parent a664769 commit 652f3c2
Show file tree
Hide file tree
Showing 35 changed files with 3,367 additions and 58 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ archives_base_name=oritech
fabric_version=0.95.0+1.20.4

owo_version=0.12.0+1.20.3
geckolib_version=1.20.4:4.4.1
geckolib_version=1.20.4:4.4.2
reborn_energy_version=3.0.0
rei_version=14.0.688
27 changes: 15 additions & 12 deletions src/main/generated/.cache/19c08d24c255c2719fbb8ac01f9dff290b763461
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
// 1.20.4 2024-03-07T09:58:48.9465567 Oritech/Model Definitions
ee822d455f99c8c53c789fdb744979f678ca2729 assets\oritech\blockstates\fertilizer_block.json
46af77abe62b29d232feadccde429fd59d5603fc assets\oritech\blockstates\placer_block.json
// 1.20.4 2024-03-07T19:17:34.0084518 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
3d37038977380bd685f913e722cc3b1c3a25c35d assets\oritech\models\item\atomic_forge_block.json
3fcaea2f05319816f7904137763182c4106c91a9 assets\oritech\blockstates\destroyer_block.json
e6f197ee5ac22cd68bc502a86d40b65bfe40884a assets\oritech\models\item\target_designator.json
53f76976c5fe0593fa89a4b835dde07c96b07067 assets\oritech\blockstates\centrifuge_block.json
95eae9b13fb2835f15057d2fd4d9550192064ca4 assets\oritech\models\item\grinder_block.json
3ceff0ef4325bb269831205626285bc857c60de8 assets\oritech\models\item\destroyer_block.json
964457f56e25b66dfef2160c8618bcaba2b640aa assets\oritech\blockstates\pulverizer_block.json
001d7907def5667f14bbdce07c9d6198efa45e71 assets\oritech\blockstates\laser_arm_block.json
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
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
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
53f76976c5fe0593fa89a4b835dde07c96b07067 assets\oritech\blockstates\centrifuge_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
7ee14de0149c70d1145dbf338518690b536cc02e assets\oritech\models\item\powered_furnace_block.json
746b98d721e5ae0d96dd769e71b786afa8c2d142 assets\oritech\models\item\banana_block.json
230eb8fa77942cdf46509bea8df75b48f82e9e8e assets\oritech\blockstates\machine_frame_block.json
9caec2452545622571a137712307b8e0e669af9e assets\oritech\models\block\block_fertilizer_head.json
95eae9b13fb2835f15057d2fd4d9550192064ca4 assets\oritech\models\item\grinder_block.json
54472f85797924c842326a60299d72263cb2c301 assets\oritech\blockstates\block_destroyer_head.json
4021223f19511a9e81a833342c1d05f5af891c10 assets\oritech\blockstates\atomic_forge_block.json
ff59e92a557b29eeb7f85b1c15ef206c5b99aff6 assets\oritech\models\item\foundry_block.json
c641d411ad252487b93d779cee9028b9ee920281 assets\oritech\blockstates\machine_core_basic.json
3ceff0ef4325bb269831205626285bc857c60de8 assets\oritech\models\item\destroyer_block.json
a5afa0ba8780ec08bd0a9284bc08e0c681fe7158 assets\oritech\blockstates\block_placer_head.json
f29468ff950a191567ab35557334666099ccd7cc assets\oritech\blockstates\assembler_block.json
964457f56e25b66dfef2160c8618bcaba2b640aa assets\oritech\blockstates\pulverizer_block.json
5054284e6d5fe0785ac93bdda5101c47337953cf assets\oritech\models\item\machine_frame_block.json
e4497bad8afbd4f4b4e830d892284a05718b06dd assets\oritech\models\block\machine_core_basic.json
505d30e3b61ee0ba1f2616e1226689e2cdb7ab58 assets\oritech\models\block\addon_indicator_block.json
3810f72943d88c81d3ab6b4329d437911c859621 assets\oritech\blockstates\powered_furnace_block.json
1b9cd3719105dc1e03398de41f2cab37337816fe assets\oritech\blockstates\machine_core_good.json
5462a2453fcdd2f8b99129894aec60f282d29ca9 assets\oritech\models\item\pulverizer_block.json
a3f9b72f6f36d42af4e5c3a87d7e180b2e36a2ed assets\oritech\models\item\machine_core_good.json
a5651b8d4a27308b40c404f7cd3abcf9769b64b6 assets\oritech\models\item\machine_core_basic.json
469ea8a66c529fe26bc029c21092e7f062ed0e40 assets\oritech\models\block\banana_block.json
d35ecef5df9198b12dc04267780c727c144b1959 assets\oritech\models\item\assembler_block.json
d39d7a8eaa54d12c155fb1acd1722e322c0aeac3 assets\oritech\models\block\block_destroyer_head.json
Expand All @@ -43,5 +46,5 @@ b909a1e7a747bcbfaba3d33391ed75c361dff0c6 assets\oritech\blockstates\foundry_bloc
f53b229ded70f8ae0bff50e829d62326601b0fe8 assets\oritech\models\block\block_placer_head.json
b7e73ae6ffd983038af7540301bf488242562790 assets\oritech\models\block\fertilizer_block.json
66c23bb916995ef1664b6119475d183a66f32624 assets\oritech\blockstates\block_fertilizer_head.json
2f7dfa17792770a034a13f117e6b8b1942b459e4 assets\oritech\models\block\placer_block.json
42580a93e058faa5381bfac746ed2a200ec5f323 assets\oritech\models\item\laser_arm_block.json
3166a5959c87c4465c5eed82034d3178c4b8b518 assets\oritech\models\block\machine_core_good.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "oritech:block/laser_arm_block"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "oritech:block/laser_arm_block"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "oritech:item/target_designator"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt

// first time created
if (isAssembled && !wasAssembled) {
NetworkContent.MACHINE_CHANNEL.serverHandle(machineEntity).send(new NetworkContent.MachineEventPacket(pos));
NetworkContent.MACHINE_CHANNEL.serverHandle(machineEntity).send(new NetworkContent.MachineSetupEventPacket(pos));
return ActionResult.SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void readNbt(NbtCompound nbt) {
inventory.readNbtList(nbt.getList("inventory", NbtElement.COMPOUND_TYPE));
energyStorage.amount = nbt.getLong("energy_stored");

getAddonNbtData(nbt);
loadAddonNbtData(nbt);
updateEnergyContainer();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected void onFinalCommit() {
markNetDirty();
}
};

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

public MachineBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, int energyPerTick) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@

import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import rearth.oritech.block.base.block.MultiblockMachine;
import rearth.oritech.util.ImplementedInventory;
import rearth.oritech.util.InventoryProvider;
import rearth.oritech.util.MultiblockMachineController;
import team.reborn.energy.api.EnergyStorage;

import java.util.ArrayList;
import java.util.List;

public abstract class MultiblockFrameInteractionEntity extends ItemEnergyFrameInteractionBlockEntity implements MultiblockMachineController {

Expand Down Expand Up @@ -47,13 +40,13 @@ public void setCoreQuality(float quality) {
@Override
public void writeNbt(NbtCompound nbt) {
super.writeNbt(nbt);
addToNbt(nbt);
addMultiblockToNbt(nbt);
}

@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
getFromNbt(nbt);
loadMultiblockNbtData(nbt);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import rearth.oritech.block.base.block.MultiblockMachine;
import rearth.oritech.util.ImplementedInventory;
import rearth.oritech.util.InventoryProvider;
import rearth.oritech.util.MultiblockMachineController;
import team.reborn.energy.api.EnergyStorage;
Expand Down Expand Up @@ -42,13 +41,13 @@ public void setCoreQuality(float quality) {
@Override
public void writeNbt(NbtCompound nbt) {
super.writeNbt(nbt);
addToNbt(nbt);
addMultiblockToNbt(nbt);
}

@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
getFromNbt(nbt);
loadMultiblockNbtData(nbt);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
package rearth.oritech.block.base.entity;

import io.wispforest.owo.serialization.Endec;
import io.wispforest.owo.serialization.endec.BuiltInEndecs;
import io.wispforest.owo.serialization.endec.StructEndecBuilder;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import org.jetbrains.annotations.Nullable;
import rearth.oritech.block.blocks.machines.addons.EnergyAddonBlock;
import rearth.oritech.block.blocks.machines.addons.MachineAddonBlock;
import rearth.oritech.block.entity.machines.addons.AddonBlockEntity;
import rearth.oritech.client.ui.UpgradableMachineScreenHandler;
import rearth.oritech.init.recipes.OritechRecipeType;
import rearth.oritech.util.*;

import java.util.*;
Expand All @@ -47,7 +36,7 @@ public void writeNbt(NbtCompound nbt) {
@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
getAddonNbtData(nbt);
loadAddonNbtData(nbt);

updateEnergyContainer();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package rearth.oritech.block.blocks.machines.interaction;

import com.mojang.serialization.MapCodec;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.minecraft.block.*;
import net.minecraft.block.AbstractBlock.Settings;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import rearth.oritech.block.base.entity.FrameInteractionBlockEntity;
import rearth.oritech.block.base.entity.UpgradableMachineBlockEntity;
import rearth.oritech.block.entity.machines.interaction.DestroyerBlockEntity;
import rearth.oritech.block.entity.machines.interaction.LaserArmBlockEntity;
import rearth.oritech.network.NetworkContent;
import rearth.oritech.util.MachineAddonController;
import rearth.oritech.util.MultiblockMachineController;

import java.util.Objects;

public class LaserArmBlock extends Block implements BlockEntityProvider {

public static final BooleanProperty ASSEMBLED = BooleanProperty.of("machine_assembled");

public LaserArmBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(ASSEMBLED, false));
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(ASSEMBLED);
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {

if (!world.isClient) {

var entity = world.getBlockEntity(pos);
if (!(entity instanceof LaserArmBlockEntity laserArm)) {
return ActionResult.SUCCESS;
}

var wasAssembled = state.get(ASSEMBLED);
var isAssembled = laserArm.initMultiblock(state);

// first time created
if (isAssembled && !wasAssembled) {
NetworkContent.MACHINE_CHANNEL.serverHandle(entity).send(new NetworkContent.MachineSetupEventPacket(pos));
return ActionResult.SUCCESS;
}

if (!isAssembled) {
player.sendMessage(Text.literal("Machine is not assembled. Please add missing core blocks"));
return ActionResult.SUCCESS;
}

laserArm.initAddons();
laserArm.testTarget(state);

}

return ActionResult.SUCCESS;
}

@Override
public BlockState onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {

if (!world.isClient() && state.get(ASSEMBLED)) {

var entity = world.getBlockEntity(pos);
if (entity instanceof MultiblockMachineController machineEntity) {
machineEntity.onControllerBroken();
}
}

return super.onBreak(world, pos, state, player);
}

@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.ENTITYBLOCK_ANIMATED;
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new LaserArmBlockEntity(pos, state);
}

@SuppressWarnings({"rawtypes", "unchecked"})
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return (world1, pos, state1, blockEntity) -> {
if (blockEntity instanceof BlockEntityTicker ticker)
ticker.tick(world1, pos, state1, blockEntity);
};
}
}
Loading

0 comments on commit 652f3c2

Please sign in to comment.