Awareness block #53
3
.gitignore
vendored
3
.gitignore
vendored
@ -79,5 +79,8 @@ run
|
|||||||
# Blender
|
# Blender
|
||||||
*.blend1
|
*.blend1
|
||||||
|
|
||||||
|
# Affinity lock files
|
||||||
|
*.af*~lock~
|
||||||
|
|
||||||
# File generated by JDT.LS
|
# File generated by JDT.LS
|
||||||
.factorypath
|
.factorypath
|
||||||
|
BIN
assets/awareness_block.afdesign
Normal file
BIN
assets/awareness_block.afdesign
Normal file
Binary file not shown.
1
assets/awareness_block.bbmodel
Normal file
1
assets/awareness_block.bbmodel
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"meta":{"format_version":"4.9","model_format":"java_block","box_uv":false},"name":"awareness_block","parent":"","ambientocclusion":true,"front_gui_light":false,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"unhandled_root_fields":{},"resolution":{"width":64,"height":64},"elements":[{"name":"cube","box_uv":false,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[0,0,0],"to":[16,16,16],"autouv":0,"color":5,"origin":[0,0,0],"faces":{"north":{"uv":[0,0,21.33333333333333,64],"texture":0},"east":{"uv":[0,0,21.33333333333333,64],"texture":0},"south":{"uv":[0,0,21.333333333333336,64],"texture":0},"west":{"uv":[0,0,21.33333333333333,64],"texture":0},"up":{"uv":[42.6666666666667,64,21.333333333333325,0],"texture":0},"down":{"uv":[64,0,42.666666666666664,64],"texture":0}},"type":"cube","uuid":"093840f4-e7a5-ccc7-4565-3d95fec652e1"}],"outliner":["093840f4-e7a5-ccc7-4565-3d95fec652e1"],"textures":[{"path":"/Users/blakerain/dev/bans-minecraft/utamacraft/src/main/resources/assets/utamacraft/textures/block/awareness_block.png","name":"awareness_block.png","folder":"block","namespace":"utamacraft","id":"0","width":48,"height":16,"uv_width":64,"uv_height":64,"particle":true,"layers_enabled":false,"sync_to_project":"","render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"internal":true,"saved":true,"uuid":"a4330a6a-e91c-51be-5e67-a49d5592f046","relative_path":"../../src/main/resources/assets/utamacraft/textures/block/awareness_block.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAQCAYAAABQrvyxAAAAAXNSR0IArs4c6QAABV9JREFUSEtlVk2PFFUUPe9VdTd7ozA9/TGOusYQcGUARSFx5WKii9EMwY0bRFzAOMwOM+BKxLgwMcj4sSCZnSsVo2JMDErUv+ACZLpn2p2Z7qp65pz7Xk0TKplU1VTf9+4599xzn5vtzoUsy1EWE3ifISDAe49QBVShQuY9qhDAi98RKlRVBec8nAPa7RlkWYayLC0uxPgQ9Lss86iqFO+1TlWVMd7h/v1/kOc5JpOJ1mE874y1eHsGnNbi97Ks4L2Dcw5ubv6pwA3KooDPvJI4/NY1bTR9/XTlpF6ZStqEuPq9jjZIABjPqygKbc4I/o5gFR+m4wNGo5EAEUCe5fCKASaTMUisxQclmxIgoY08F8GuN/dEKCZk32uX586u49aHp7D43g18tfpqRA8cPXsdP3ywBO+ckoBjMSr0+z0Uqh4Td7pzMxKScROxl5LfrY6BqQRgvDNW4owjy7wTUKPREDG78VQB9w9wcCiphE5vLlRliUajhcNnruHW1VNYvHgDX66+IgYITuCdx5Ez1/DjlZPagKwx4W5nFopvNmumTGIOeZ5hMiki+4yx/1u8ARsOBijKEnv2tPQ/yrQsC3jnBWBnvFPHqMqSrjNgXKvd6QXqudlo4tnTn4r9QwefxsLCAjY2Nur7b3f+xLmPv8alN19SFVzU+8y+vVqw2WjU8qJ8qGsyxasuPxClRhCm53v37qpqrVZL7/wbj8doNVuSCBdVb1nRMYnVVr9SQp3e41QlMp+rAj9/9AYur118IPmXT7+PlaXjWFv/FheWTtjCUQLdTkfPpndL9sGy7zZwavDEPt+Hw4GSzBvUO4FZ/1AiNJREQqaEg/q0Km1/VbQ392RgEMmiRBKAc8sX6pKurX+D5ddfwOUvbgoIHYrouVu/11XSXJwLJubTu/UGv6n9zenEtDnLaLQtWZAUAqdsUiX4npyJazNHytIcio0NuG5/XhJiQ3KR59/5HHScZw4dwO3f/xDrK0snQBDnF48h4wLJMgH1wDSAVInpxpXmy1IyMFtMlgtsDYdw3nrCbNOcR7ILUE4kgVUhMAIsCgLz+u56/XlBISKCYIJHznymShw8sB+/3r4j5lkBMk9n4e9YXjJIG01y4hpMMFmpefa0i4TIYLJGYGtrS+uIQO2fI+c8iHZNh0sNwP3lTFVZO5Fs1Lqf2oqdDSfb/O+Xq6D+pXs5iERu+owDjTb6UHz07OTfWjvFS+dJciW2t20OUONFSceyAWmkWCXSoDQzoFVbxTjQJCGiT1HyeQBH394FsPzaMVuR31QFY5kbzLZnxF4dL5+mVjkDyJRNXmPREk9V4vNgc1OMJqdS9QLQaDZQFmXsDfaLgeH+XFsDjwDNhWyAsLuJ7PvVvfXwSA/HLw3APrTmM7dhQ8629yl3Picd8zsTsXFv7KeJmo4VFu+xuXlfFaV06P+UnFj3RlLqDzV2PN6k/UmE6/TmQ+psIiJR3737qJL8+y71adep65Z4ah5ZnQd63Y4ab9oaH5aOSc6Amd0q3jk1MS3UXEaObkeEKB2SOj345HIImIw5YB1cOswlZ2AynyzuNl6v/Yg2fHFtYJMkHSOibRoAY5+MyYX4LTaw6TmKeqquxmiF4dZQkpBl+gy5bNSUQLeZDk+zgXez3TgHlFXclItQkzdXHsPC2l/YWNlfJ29a91qUk5ig5/pdOxtFr58+mSZQaRhpcsZGTKz+OxrVAyvNER0ElYedOqfPPuxRJkCyJDf2gBDJGivpkbrTcInDQxrnkTn5b/R1gul22nWJk3RM3/R+rmn8Kz4OJsK1I7XDYDBUD/FbLT3nNXGn/5eO3LwzjtUhmP8BPwfdeSKKTmYAAAAASUVORK5CYII="}],"display":{"thirdperson_righthand":{"scale":[0.25,0.25,0.25]},"thirdperson_lefthand":{"scale":[0.25,0.25,0.25]},"firstperson_righthand":{"scale":[0.5,0.5,0.5]},"firstperson_lefthand":{"scale":[0.5,0.5,0.5]},"ground":{"scale":[0.5,0.5,0.5]},"gui":{"rotation":[21,137,0],"scale":[0.66,0.66,0.66]},"head":{"translation":[0,1.75,0],"scale":[0.9,0.9,0.9]},"fixed":{"translation":[0,0,0.75],"scale":[1,1,0.05]}}}
|
Binary file not shown.
BIN
assets/noise.blend
Normal file
BIN
assets/noise.blend
Normal file
Binary file not shown.
BIN
assets/noise.png
Normal file
BIN
assets/noise.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 846 B |
@ -149,6 +149,10 @@ repositories {
|
|||||||
name = "Illusive Soulworks maven"
|
name = "Illusive Soulworks maven"
|
||||||
url = "https://maven.theillusivec4.top/"
|
url = "https://maven.theillusivec4.top/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url = "https://www.cursemaven.com"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -175,6 +179,9 @@ dependencies {
|
|||||||
|
|
||||||
// Mekanism: useful for testing energy and so on.
|
// Mekanism: useful for testing energy and so on.
|
||||||
runtimeOnly(fg.deobf("mekanism:Mekanism:${minecraft_version}-${mekanism_version}"))
|
runtimeOnly(fg.deobf("mekanism:Mekanism:${minecraft_version}-${mekanism_version}"))
|
||||||
|
|
||||||
|
// Storage Drawers: useful for testing different storage interfaces.
|
||||||
|
runtimeOnly(fg.deobf("curse.maven:storage-drawers-223852:3884263"))
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
|
@ -56,7 +56,7 @@ mod_name=Utamacraft Mod
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT License
|
mod_license=MIT License
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=0.2.3-1.19
|
mod_version=0.2.4-1.19
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
@ -64,4 +64,4 @@ mod_group_id=net.banutama.utamacraft
|
|||||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||||
mod_authors=BanUtama, InstaGibKyd
|
mod_authors=BanUtama, InstaGibKyd
|
||||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||||
mod_description=The mod for Ban's Minecraft Server
|
mod_description=The mod for Ban's Minecraft Server
|
||||||
|
@ -2,8 +2,10 @@ package net.banutama.utamacraft;
|
|||||||
|
|
||||||
import dan200.computercraft.api.ForgeComputerCraftAPI;
|
import dan200.computercraft.api.ForgeComputerCraftAPI;
|
||||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||||
|
import net.banutama.utamacraft.block.entity.AwarenessBlockEntity;
|
||||||
import net.banutama.utamacraft.block.entity.InsolatorBlockEntity;
|
import net.banutama.utamacraft.block.entity.InsolatorBlockEntity;
|
||||||
import net.banutama.utamacraft.integrations.computercraft.PeripheralProvider;
|
import net.banutama.utamacraft.integrations.computercraft.PeripheralProvider;
|
||||||
|
import net.banutama.utamacraft.integrations.computercraft.peripheral.AwarenessBlockPeripheral;
|
||||||
import net.banutama.utamacraft.integrations.computercraft.peripheral.InsolatorPeripheral;
|
import net.banutama.utamacraft.integrations.computercraft.peripheral.InsolatorPeripheral;
|
||||||
import net.banutama.utamacraft.integrations.computercraft.turtles.TurtlePlayerUpgrade;
|
import net.banutama.utamacraft.integrations.computercraft.turtles.TurtlePlayerUpgrade;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
@ -29,6 +31,8 @@ public class CCRegistration {
|
|||||||
TURTLE_SERIALIZERS.register(bus);
|
TURTLE_SERIALIZERS.register(bus);
|
||||||
|
|
||||||
peripheralProvider.registerBlockPeripheral(InsolatorPeripheral::new, InsolatorBlockEntity.class::isInstance);
|
peripheralProvider.registerBlockPeripheral(InsolatorPeripheral::new, InsolatorBlockEntity.class::isInstance);
|
||||||
|
peripheralProvider.registerBlockPeripheral(AwarenessBlockPeripheral::new,
|
||||||
|
AwarenessBlockEntity.class::isInstance);
|
||||||
|
|
||||||
ForgeComputerCraftAPI.registerPeripheralProvider(peripheralProvider);
|
ForgeComputerCraftAPI.registerPeripheralProvider(peripheralProvider);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package net.banutama.utamacraft.block.custom;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import net.banutama.utamacraft.block.entity.ModBlockEntities;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.RenderShape;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.material.Material;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
|
public class AwarenessBlock extends BaseEntityBlock {
|
||||||
|
public static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 16, 16);
|
||||||
|
|
||||||
|
public AwarenessBlock() {
|
||||||
|
super(getProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Block.Properties getProperties() {
|
||||||
|
return Block.Properties.of(Material.METAL).strength(6.0f).requiresCorrectToolForDrops().noOcclusion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull RenderShape getRenderShape(@NotNull BlockState state) {
|
||||||
|
return RenderShape.MODEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
|
||||||
|
return ModBlockEntities.AWARENESS_BLOCK.get().create(pos, state);
|
||||||
|
}
|
||||||
|
}
|
@ -17,34 +17,29 @@ import net.minecraftforge.registries.DeferredRegister;
|
|||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
|
|
||||||
public class ModBlocks {
|
public class ModBlocks {
|
||||||
public static final DeferredRegister<Block> BLOCKS =
|
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS,
|
||||||
DeferredRegister.create(ForgeRegistries.BLOCKS, Utamacraft.MOD_ID);
|
Utamacraft.MOD_ID);
|
||||||
|
|
||||||
public static final RegistryObject<Block> ETHEREAL_GLASS =
|
public static final RegistryObject<Block> ETHEREAL_GLASS = registerBlock("ethereal_glass", EtherealGlassBlock::new);
|
||||||
registerBlock("ethereal_glass", EtherealGlassBlock::new);
|
public static final RegistryObject<Block> ETHEREAL_GLASS_TINTED = registerBlock("ethereal_glass_tinted",
|
||||||
public static final RegistryObject<Block> ETHEREAL_GLASS_TINTED =
|
EtherealGlassTintedBlock::new);
|
||||||
registerBlock("ethereal_glass_tinted", EtherealGlassTintedBlock::new);
|
public static final RegistryObject<Block> TUNGSTEN_ORE = registerBlock("tungsten_ore",
|
||||||
public static final RegistryObject<Block> TUNGSTEN_ORE =
|
() -> new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE)
|
||||||
registerBlock("tungsten_ore",
|
.strength(6.0f)
|
||||||
() -> new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE)
|
.requiresCorrectToolForDrops(),
|
||||||
.strength(6.0f)
|
UniformInt.of(3, 7)));
|
||||||
.requiresCorrectToolForDrops(),
|
public static final RegistryObject<Block> DEEPSLATE_TUNGSTEN_ORE = registerBlock("deepslate_tungsten_ore",
|
||||||
UniformInt.of(3, 7)));
|
() -> new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE)
|
||||||
public static final RegistryObject<Block> DEEPSLATE_TUNGSTEN_ORE =
|
.strength(6.0f)
|
||||||
registerBlock("deepslate_tungsten_ore",
|
.requiresCorrectToolForDrops(),
|
||||||
() -> new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE)
|
UniformInt.of(3, 7)));
|
||||||
.strength(6.0f)
|
public static final RegistryObject<Block> TUNGSTEN_BLOCK = registerBlock("tungsten_block",
|
||||||
.requiresCorrectToolForDrops(),
|
() -> new Block(BlockBehaviour.Properties.of(Material.METAL)
|
||||||
UniformInt.of(3, 7)));
|
.strength(12.0f)
|
||||||
public static final RegistryObject<Block> TUNGSTEN_BLOCK =
|
.requiresCorrectToolForDrops()));
|
||||||
registerBlock("tungsten_block",
|
public static final RegistryObject<Block> INSOLATOR = registerBlock("insolator", InsolatorBlock::new);
|
||||||
() -> new Block(BlockBehaviour.Properties.of(Material.METAL)
|
public static final RegistryObject<Block> AWARENESS_BLOCK = registerBlock("awareness_block", AwarenessBlock::new);
|
||||||
.strength(12.0f)
|
|
||||||
.requiresCorrectToolForDrops()));
|
|
||||||
public static final RegistryObject<Block> INSOLATOR =
|
|
||||||
registerBlock("insolator", InsolatorBlock::new);
|
|
||||||
|
|
||||||
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) {
|
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) {
|
||||||
RegistryObject<T> registered_block = BLOCKS.register(name, block);
|
RegistryObject<T> registered_block = BLOCKS.register(name, block);
|
||||||
@ -53,7 +48,8 @@ public class ModBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) {
|
private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) {
|
||||||
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(ModCreativeModeTab.TAB)));
|
ModItems.ITEMS.register(name,
|
||||||
|
() -> new BlockItem(block.get(), new Item.Properties().tab(ModCreativeModeTab.TAB)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(IEventBus bus) {
|
public static void register(IEventBus bus) {
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package net.banutama.utamacraft.block.entity;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
public class AwarenessBlockEntity extends BlockEntity {
|
||||||
|
public AwarenessBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
super(ModBlockEntities.AWARENESS_BLOCK.get(), pos, state);
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,10 @@ public class ModBlockEntities {
|
|||||||
"insolator",
|
"insolator",
|
||||||
() -> BlockEntityType.Builder.of(InsolatorBlockEntity::new, ModBlocks.INSOLATOR.get()).build(null));
|
() -> BlockEntityType.Builder.of(InsolatorBlockEntity::new, ModBlocks.INSOLATOR.get()).build(null));
|
||||||
|
|
||||||
|
public static final RegistryObject<BlockEntityType<AwarenessBlockEntity>> AWARENESS_BLOCK = BLOCK_ENTITIES.register(
|
||||||
|
"awareness_block",
|
||||||
|
() -> BlockEntityType.Builder.of(AwarenessBlockEntity::new, ModBlocks.AWARENESS_BLOCK.get()).build(null));
|
||||||
|
|
||||||
public static void register(IEventBus bus) {
|
public static void register(IEventBus bus) {
|
||||||
BLOCK_ENTITIES.register(bus);
|
BLOCK_ENTITIES.register(bus);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,128 @@
|
|||||||
|
package net.banutama.utamacraft.integrations.computercraft.peripheral;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.lua.IArguments;
|
||||||
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
import dan200.computercraft.api.lua.LuaFunction;
|
||||||
|
import dan200.computercraft.api.lua.MethodResult;
|
||||||
|
import net.banutama.utamacraft.block.entity.AwarenessBlockEntity;
|
||||||
|
import net.banutama.utamacraft.util.LuaConverter;
|
||||||
|
import net.banutama.utamacraft.util.WorldScan;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
|
public class AwarenessBlockPeripheral extends BasePeripheral {
|
||||||
|
public static final String PERIPHERAL_TYPE = "awareness_block";
|
||||||
|
|
||||||
|
protected AwarenessBlockPeripheral(BasePeripheralOwner owner) {
|
||||||
|
super(PERIPHERAL_TYPE, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AwarenessBlockPeripheral(BlockEntity blockEntity) {
|
||||||
|
this(new BlockEntityPeripheralOwner(blockEntity));
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction(mainThread = true)
|
||||||
|
public final @NotNull MethodResult scan(@NotNull IArguments arguments) throws LuaException {
|
||||||
|
int radius = arguments.getInt(0);
|
||||||
|
if (radius < 1) {
|
||||||
|
return MethodResult.of(null, "Radius must be greater than zero");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(owner instanceof BlockEntityPeripheralOwner blockOwner)) {
|
||||||
|
return MethodResult.of(null, "Owner of this AwarenessBlockPeripheral is not a BlockEntityPeripheralOwner");
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockEntity blockEntity = blockOwner.getBlockEntity();
|
||||||
|
if (!(blockEntity instanceof AwarenessBlockEntity block)) {
|
||||||
|
return MethodResult.of(null,
|
||||||
|
"Owner of this AwarenessBlockEntity has a BlockEntityProviderOwner with a BlockEntity that is not an AwarenessBlockEntity");
|
||||||
|
}
|
||||||
|
|
||||||
|
Level level = blockEntity.getLevel();
|
||||||
|
BlockPos origin = blockEntity.getBlockPos();
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
{
|
||||||
|
Map<String, Object> originMap = new HashMap<>();
|
||||||
|
originMap.put("x", origin.getX());
|
||||||
|
originMap.put("y", origin.getY());
|
||||||
|
originMap.put("z", origin.getZ());
|
||||||
|
result.put("origin", originMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, ?>> blocks = new ArrayList<>();
|
||||||
|
WorldScan.scanBlocks(level, origin, radius, (state, pos) -> {
|
||||||
|
blocks.add(describeBlock(level, origin, state, pos));
|
||||||
|
});
|
||||||
|
|
||||||
|
result.put("blocks", blocks);
|
||||||
|
|
||||||
|
return MethodResult.of(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashMap<String, Object> describeBlock(Level level, BlockPos origin, BlockState state, BlockPos pos) {
|
||||||
|
HashMap<String, Object> blockInfo = new HashMap<>(5);
|
||||||
|
|
||||||
|
blockInfo.put("x", pos.getX() - origin.getX());
|
||||||
|
blockInfo.put("y", pos.getY() - origin.getY());
|
||||||
|
blockInfo.put("z", pos.getZ() - origin.getZ());
|
||||||
|
|
||||||
|
Block block = state.getBlock();
|
||||||
|
ResourceLocation name = ForgeRegistries.BLOCKS.getKey(block);
|
||||||
|
blockInfo.put("name", name == null ? "unknown" : name.toString());
|
||||||
|
blockInfo.put("tags", LuaConverter.tagsToList(() -> block.builtInRegistryHolder().tags()));
|
||||||
|
|
||||||
|
describeBlockEntity(blockInfo, level, pos);
|
||||||
|
|
||||||
|
return blockInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void describeBlockEntity(HashMap<String, Object> blockInfo, Level level, BlockPos pos) {
|
||||||
|
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||||
|
|
||||||
|
if (blockEntity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
describeInventories(blockInfo, blockEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void describeInventories(HashMap<String, Object> blockInfo, BlockEntity entity) {
|
||||||
|
IItemHandler mainInventory = entity.getCapability(ForgeCapabilities.ITEM_HANDLER).resolve().orElse(null);
|
||||||
|
|
||||||
|
if (mainInventory != null) {
|
||||||
|
blockInfo.put("inventory", describeInventory(mainInventory));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashMap<String, Object> describeInventory(IItemHandler inventory) {
|
||||||
|
List<Map<String, ?>> slots = new ArrayList<>();
|
||||||
|
for (int i = 0; i < inventory.getSlots(); ++i) {
|
||||||
|
HashMap<String, Object> itemInfo = new HashMap<>(2);
|
||||||
|
ResourceLocation itemName = ForgeRegistries.ITEMS.getKey(inventory.getStackInSlot(i).getItem());
|
||||||
|
itemInfo.put("name", itemName == null ? "unknown" : itemName.toString());
|
||||||
|
itemInfo.put("count", inventory.getStackInSlot(i).getCount());
|
||||||
|
slots.add(itemInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, Object> inventoryInfo = new HashMap<>(2);
|
||||||
|
inventoryInfo.put("size", inventory.getSlots());
|
||||||
|
inventoryInfo.put("slots", slots);
|
||||||
|
return inventoryInfo;
|
||||||
|
}
|
||||||
|
}
|
19
src/main/java/net/banutama/utamacraft/util/LuaConverter.java
Normal file
19
src/main/java/net/banutama/utamacraft/util/LuaConverter.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package net.banutama.utamacraft.util;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import net.minecraft.tags.TagKey;
|
||||||
|
|
||||||
|
public class LuaConverter {
|
||||||
|
public static <T> List<String> tagsToList(@NotNull Supplier<Stream<TagKey<T>>> tags) {
|
||||||
|
return tags.get().map(LuaConverter::tagToString).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> String tagToString(@NotNull TagKey<T> tag) {
|
||||||
|
return tag.registry().location() + "/" + tag.location();
|
||||||
|
}
|
||||||
|
}
|
29
src/main/java/net/banutama/utamacraft/util/WorldScan.java
Normal file
29
src/main/java/net/banutama/utamacraft/util/WorldScan.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package net.banutama.utamacraft.util;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
public class WorldScan {
|
||||||
|
public static void scanBlocks(Level level, BlockPos origin, int r,
|
||||||
|
BiConsumer<BlockState, BlockPos> consumer) {
|
||||||
|
int ox = origin.getX();
|
||||||
|
int oy = origin.getY();
|
||||||
|
int oz = origin.getZ();
|
||||||
|
|
||||||
|
for (int x = ox - r; x <= ox + r; ++x) {
|
||||||
|
for (int y = oy - r; y <= oy + r; ++y) {
|
||||||
|
for (int z = oz - r; z <= oz + r; ++z) {
|
||||||
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
|
BlockState state = level.getBlockState(pos);
|
||||||
|
|
||||||
|
if (!state.isAir()) {
|
||||||
|
consumer.accept(state, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"": {
|
||||||
|
"model": "utamacraft:block/awareness_block"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +1,26 @@
|
|||||||
{
|
{
|
||||||
|
"block.utamacraft.awareness_block": "Awareness Block",
|
||||||
"block.utamacraft.deepslate_tungsten_ore": "Deepslate Tungsten Ore",
|
"block.utamacraft.deepslate_tungsten_ore": "Deepslate Tungsten Ore",
|
||||||
"block.utamacraft.ethereal_glass": "Ethereal Glass",
|
"block.utamacraft.ethereal_glass": "Ethereal Glass",
|
||||||
"block.utamacraft.ethereal_glass_tinted": "Tinted Ethereal Glass",
|
"block.utamacraft.ethereal_glass_tinted": "Tinted Ethereal Glass",
|
||||||
"block.utamacraft.insolator": "Insolator",
|
"block.utamacraft.insolator": "Insolator",
|
||||||
"block.utamacraft.tungsten_block": "Tungsten Block",
|
"block.utamacraft.tungsten_block": "Tungsten Block",
|
||||||
"block.utamacraft.tungsten_ore": "Tungsten Ore",
|
"block.utamacraft.tungsten_ore": "Tungsten Ore",
|
||||||
|
"block_entity.utamacraft.awareness_block": "Awareness Block",
|
||||||
"block_entity.utamacraft.insolator": "Insolator",
|
"block_entity.utamacraft.insolator": "Insolator",
|
||||||
|
"gui.utamacraft.insolator.dump": "Dump",
|
||||||
|
"gui.utamacraft.insolator.dump.tooltip": "Dump the fluid contents of the Insolator",
|
||||||
|
"gui.utamacraft.insolator.dump.tooltip.empty": "No fluid contents to dump from Insolator",
|
||||||
|
"item.utamacraft.awareness_block": "Awareness Block",
|
||||||
"item.utamacraft.bulb": "Bulb",
|
"item.utamacraft.bulb": "Bulb",
|
||||||
"item.utamacraft.fiber_glass": "Fiberglass",
|
"item.utamacraft.fiber_glass": "Fiberglass",
|
||||||
"item.utamacraft.fire_ward": "Fire Ward Necklace",
|
"item.utamacraft.fire_ward": "Fire Ward Necklace",
|
||||||
"item.utamacraft.insolator": "Insolator",
|
"item.utamacraft.insolator": "Insolator",
|
||||||
"item.utamacraft.pcb": "Printed Circuit Board",
|
"item.utamacraft.pcb": "Printed Circuit Board",
|
||||||
"item.utamacraft.player_peripheral": "Player peripheral",
|
"item.utamacraft.player_peripheral": "Player peripheral",
|
||||||
"item.utamacraft.tungsten_raw": "Raw Tungsten",
|
|
||||||
"item.utamacraft.tungsten_block": "Tungsten Block",
|
"item.utamacraft.tungsten_block": "Tungsten Block",
|
||||||
"item.utamacraft.tungsten_ingot": "Tungsten Ingot",
|
"item.utamacraft.tungsten_ingot": "Tungsten Ingot",
|
||||||
|
"item.utamacraft.tungsten_raw": "Raw Tungsten",
|
||||||
"itemGroup.utamacraft_tab": "Utamacraft",
|
"itemGroup.utamacraft_tab": "Utamacraft",
|
||||||
"tooltip.utamacraft.energy": "Energy",
|
"tooltip.utamacraft.energy": "Energy",
|
||||||
"tooltip.utamacraft.energy.amount": "%s FE",
|
"tooltip.utamacraft.energy.amount": "%s FE",
|
||||||
@ -22,11 +28,8 @@
|
|||||||
"tooltip.utamacraft.ethereal_glass": "Glass that is not solid to players",
|
"tooltip.utamacraft.ethereal_glass": "Glass that is not solid to players",
|
||||||
"tooltip.utamacraft.ethereal_glass_tinted": "Glass that is not solid to players and blocks light",
|
"tooltip.utamacraft.ethereal_glass_tinted": "Glass that is not solid to players and blocks light",
|
||||||
"tooltip.utamacraft.fire_ward": "Protects the player from fire damage",
|
"tooltip.utamacraft.fire_ward": "Protects the player from fire damage",
|
||||||
"tooltip.utamacraft.fluid.empty": "Empty",
|
|
||||||
"tooltip.utamacraft.fluid.amount": "%s mB",
|
"tooltip.utamacraft.fluid.amount": "%s mB",
|
||||||
"tooltip.utamacraft.fluid.amount.with_capacity": "%s / %s mB",
|
"tooltip.utamacraft.fluid.amount.with_capacity": "%s / %s mB",
|
||||||
"turtle.utamacraft.player_turtle": "Player",
|
"tooltip.utamacraft.fluid.empty": "Empty",
|
||||||
"gui.utamacraft.insolator.dump": "Dump",
|
"turtle.utamacraft.player_turtle": "Player"
|
||||||
"gui.utamacraft.insolator.dump.tooltip": "Dump the fluid contents of the Insolator",
|
|
||||||
"gui.utamacraft.insolator.dump.tooltip.empty": "No fluid contents to dump from Insolator"
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"credit": "Made with Blockbench",
|
||||||
|
"texture_size": [64, 64],
|
||||||
|
"textures": {
|
||||||
|
"0": "utamacraft:block/awareness_block",
|
||||||
|
"particle": "utamacraft:block/awareness_block"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"from": [0, 0, 0],
|
||||||
|
"to": [16, 16, 16],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [0, 0, 5.33333, 16], "texture": "#0"},
|
||||||
|
"east": {"uv": [0, 0, 5.33333, 16], "texture": "#0"},
|
||||||
|
"south": {"uv": [0, 0, 5.33333, 16], "texture": "#0"},
|
||||||
|
"west": {"uv": [0, 0, 5.33333, 16], "texture": "#0"},
|
||||||
|
"up": {"uv": [10.66667, 16, 5.33333, 0], "texture": "#0"},
|
||||||
|
"down": {"uv": [16, 0, 10.66667, 16], "texture": "#0"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"display": {
|
||||||
|
"thirdperson_righthand": {
|
||||||
|
"scale": [0.25, 0.25, 0.25]
|
||||||
|
},
|
||||||
|
"thirdperson_lefthand": {
|
||||||
|
"scale": [0.25, 0.25, 0.25]
|
||||||
|
},
|
||||||
|
"firstperson_righthand": {
|
||||||
|
"scale": [0.5, 0.5, 0.5]
|
||||||
|
},
|
||||||
|
"firstperson_lefthand": {
|
||||||
|
"scale": [0.5, 0.5, 0.5]
|
||||||
|
},
|
||||||
|
"ground": {
|
||||||
|
"scale": [0.5, 0.5, 0.5]
|
||||||
|
},
|
||||||
|
"gui": {
|
||||||
|
"rotation": [21, 137, 0],
|
||||||
|
"scale": [0.66, 0.66, 0.66]
|
||||||
|
},
|
||||||
|
"head": {
|
||||||
|
"translation": [0, 1.75, 0],
|
||||||
|
"scale": [0.9, 0.9, 0.9]
|
||||||
|
},
|
||||||
|
"fixed": {
|
||||||
|
"translation": [0, 0, 0.75],
|
||||||
|
"scale": [1, 1, 0.05]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"parent": "utamacraft:block/awareness_block"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"homepage": "https://git.blakerain.com/bans-minecraft/utamacraft",
|
"homepage": "https://git.blakerain.com/bans-minecraft/utamacraft",
|
||||||
"1.19.2": {
|
"1.19.2": {
|
||||||
|
"0.2.4-1.19": "Add some fixes and new textures",
|
||||||
"0.2.3-1.19": "Add CC peripheral for Insolator",
|
"0.2.3-1.19": "Add CC peripheral for Insolator",
|
||||||
"0.2.2-1.19": "Fix bugs with Insolator",
|
"0.2.2-1.19": "Fix bugs with Insolator",
|
||||||
"0.2.1-1.19": "Fixed mixin bug",
|
"0.2.1-1.19": "Fixed mixin bug",
|
||||||
@ -10,7 +11,7 @@
|
|||||||
"0.0.1-1.19": "Initial release"
|
"0.0.1-1.19": "Initial release"
|
||||||
},
|
},
|
||||||
"promos": {
|
"promos": {
|
||||||
"1.19.2-latest": "0.2.3-1.19",
|
"1.19.2-latest": "0.2.4-1.19",
|
||||||
"1.19.2-recommended": "0.2.3-1.19"
|
"1.19.2-recommended": "0.2.4-1.19"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user