Power Of The Redstone
This commit is contained in:
parent
914bde6c19
commit
1fd2914c92
19 changed files with 290 additions and 27 deletions
|
@ -6,5 +6,5 @@ mc_version=1.19.2
|
|||
forge_version=43.1.3
|
||||
|
||||
group='su.a71.tardim_ic'
|
||||
version=0.7
|
||||
version=0.8
|
||||
archivesBaseName='tardim_ic'
|
|
@ -13,6 +13,11 @@ import net.minecraftforge.registries.DeferredRegister;
|
|||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfaceBlock;
|
||||
import su.a71.tardim_ic.tardim_ic.digital_interface.DigitalInterfaceTileEntity;
|
||||
import su.a71.tardim_ic.tardim_ic.redsone_input.RedstoneInputBlock;
|
||||
import su.a71.tardim_ic.tardim_ic.redsone_input.RedstoneInputTileEntity;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Registration {
|
||||
|
@ -35,9 +40,11 @@ public class Registration {
|
|||
return registryObject;
|
||||
}
|
||||
public static final RegistryObject<Block> DIGITAL_TARDIM_INTERFACE = register("digital_tardim_interface", DigitalInterfaceBlock::new);
|
||||
public static final RegistryObject<Block> REDSTONE_TARDIM_INPUT = register("redstone_tardim_input", RedstoneInputBlock::new);
|
||||
|
||||
// Tile Entities
|
||||
public static final RegistryObject<BlockEntityType<DigitalInterfaceTileEntity>> DIGITAL_TARDIM_INTERFACE_TILEENTITY = Registration.BLOCK_ENTITIES.register("digital_tardim_interface", () -> new BlockEntityType<>(DigitalInterfaceTileEntity::new, Sets.newHashSet(DIGITAL_TARDIM_INTERFACE.get()), null));
|
||||
public static final RegistryObject<BlockEntityType<RedstoneInputTileEntity>> REDSTONE_TARDIM_INPUT_TILEENTITY = Registration.BLOCK_ENTITIES.register("redstone_tardim_input", () -> new BlockEntityType<>(RedstoneInputTileEntity::new, Sets.newHashSet(REDSTONE_TARDIM_INPUT.get()), null));
|
||||
|
||||
// Register our stuff
|
||||
public static void register() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package su.a71.tardim_ic.tardim_ic;
|
||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -7,6 +7,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
@ -1,17 +1,6 @@
|
|||
package su.a71.tardim_ic.tardim_ic;
|
||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.swdteam.common.command.tardim.CommandTardimBase;
|
||||
import com.swdteam.common.command.tardim.CommandTravel;
|
||||
import com.swdteam.common.data.DimensionMapReloadListener;
|
||||
import com.swdteam.common.init.TRDSounds;
|
||||
import com.swdteam.common.item.ItemTardim;
|
||||
import com.swdteam.main.Tardim;
|
||||
import dan200.computercraft.api.lua.LuaFunction;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.lua.ObjectLuaTable;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -31,6 +20,12 @@ import net.minecraft.world.level.levelgen.Heightmap;
|
|||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
|
||||
import dan200.computercraft.api.lua.LuaFunction;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.lua.ObjectLuaTable;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
|
||||
// TODO: Fabric and Forge diffirence? (Bottom: Fabric)
|
||||
import com.swdteam.tardim.TardimData;
|
||||
import com.swdteam.tardim.TardimManager;
|
||||
|
@ -38,6 +33,12 @@ import com.swdteam.tardim.TardimData.Location;
|
|||
//import com.swdteam.tardim.tardim.TardimManager;
|
||||
//import com.swdteam.tardim.tardim.TardimData;
|
||||
|
||||
import com.swdteam.common.command.tardim.CommandTravel;
|
||||
import com.swdteam.common.data.DimensionMapReloadListener;
|
||||
import com.swdteam.common.init.TRDSounds;
|
||||
import com.swdteam.common.item.ItemTardim;
|
||||
import com.swdteam.main.Tardim;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -316,11 +317,11 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
|||
@LuaFunction(mainThread = true)
|
||||
public final ObjectLuaTable getCompanions() throws LuaException {
|
||||
TardimData data = getTardimData();
|
||||
ObjectLuaTable companions = new ObjectLuaTable(Map.of());
|
||||
Map<Integer, String> companions = new HashMap<>();
|
||||
for (int i = 0; i < data.getCompanions().size(); i++) {
|
||||
companions.put(i + 1, data.getCompanions().get(i).getUsername());
|
||||
}
|
||||
return companions;
|
||||
return new ObjectLuaTable(companions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -422,16 +423,18 @@ public class DigitalInterfacePeripheral implements IPeripheral {
|
|||
|
||||
/**
|
||||
* Get online players. Useful for making a GUI for the locate function or just a nice dashboard.
|
||||
*
|
||||
* @return ObjectLuaTable of the online players
|
||||
*/
|
||||
@LuaFunction(mainThread = true)
|
||||
public final ObjectLuaTable getOnlinePlayers() throws LuaException {
|
||||
PlayerList playerList = ServerLifecycleHooks.getCurrentServer().getPlayerList();
|
||||
ObjectLuaTable players = new ObjectLuaTable(Map.of());
|
||||
for (int i = 0; i < playerList.getPlayers().size(); i++) {
|
||||
players.put(i + 1, playerList.getPlayers().get(i).getGameProfile().getName());
|
||||
}
|
||||
return players;
|
||||
Map<Integer, String> players = new HashMap<>();
|
||||
for (int i = 0; i < playerList.getPlayers().size(); i++) {
|
||||
players.put(i + 1, playerList.getPlayers().get(i).getGameProfile().getName());
|
||||
}
|
||||
|
||||
return new ObjectLuaTable(players);
|
||||
}
|
||||
|
||||
/**
|
|
@ -1,6 +1,5 @@
|
|||
package su.a71.tardim_ic.tardim_ic;
|
||||
package su.a71.tardim_ic.tardim_ic.digital_interface;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
@ -8,7 +7,9 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
||||
|
||||
public class DigitalInterfaceTileEntity extends BlockEntity {
|
|
@ -0,0 +1,100 @@
|
|||
package su.a71.tardim_ic.tardim_ic.redsone_input;
|
||||
|
||||
import com.swdteam.common.block.BlockBaseTardimPanel;
|
||||
|
||||
import com.swdteam.common.init.TRDDimensions;
|
||||
import com.swdteam.common.init.TRDSounds;
|
||||
import com.swdteam.network.NetworkHandler;
|
||||
import com.swdteam.network.packets.PacketOpenEditGui;
|
||||
import com.swdteam.tardim.TardimData;
|
||||
import com.swdteam.tardim.TardimManager;
|
||||
import com.swdteam.tileentity.TileEntityBaseTardimPanel;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.DebugPackets;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
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.BlockHitResult;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class RedstoneInputBlock extends BlockBaseTardimPanel implements EntityBlock {
|
||||
private boolean isPowered = false;
|
||||
public RedstoneInputBlock() {
|
||||
super(Properties.of(Material.METAL).strength(2, 4).noOcclusion());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
|
||||
return Registration.REDSTONE_TARDIM_INPUT_TILEENTITY.get().create(pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState blockState, Level w, BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult p_60508_) {
|
||||
if (!w.isClientSide) {
|
||||
|
||||
w.playSound((Player)null, blockPos, (SoundEvent) TRDSounds.TARDIM_BEEP.get(), SoundSource.BLOCKS, 0.3F, 0.5F);
|
||||
|
||||
BlockEntity be = w.getBlockEntity(blockPos);
|
||||
if (be instanceof TileEntityBaseTardimPanel && w.dimension() == TRDDimensions.TARDIS) {
|
||||
TardimData data = TardimManager.getFromPos(blockPos);
|
||||
if (data != null && data.hasPermission(player)) {
|
||||
NetworkHandler.sendTo((ServerPlayer)player, new PacketOpenEditGui(1, blockPos));
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
player.displayClientMessage(
|
||||
Component.literal("You do not have permission").withStyle(ChatFormatting.DARK_RED).withStyle(ChatFormatting.BOLD), true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void neighborChanged(BlockState blockState, Level level, BlockPos blockPos, Block block, BlockPos fromPos, boolean isMoving) {
|
||||
DebugPackets.sendNeighborsUpdatePacket(level, blockPos);
|
||||
|
||||
// get redstone signal
|
||||
Direction direction = blockState.getValue(FACING);
|
||||
int redstoneSignal = level.getSignal(blockPos, direction);
|
||||
if (redstoneSignal > 0 && !isPowered) {
|
||||
isPowered = true;
|
||||
BlockEntity be = level.getBlockEntity(blockPos);
|
||||
if (be instanceof TileEntityBaseTardimPanel && level.dimension() == TRDDimensions.TARDIS) {
|
||||
TardimData data = TardimManager.getFromPos(blockPos);
|
||||
if (data != null) {
|
||||
if (((TileEntityBaseTardimPanel)be).hasCommand()) {
|
||||
((TileEntityBaseTardimPanel)be).execute(FakePlayerFactory.getMinecraft(ServerLifecycleHooks.getCurrentServer().getLevel(level.dimension())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (redstoneSignal == 0 && isPowered)
|
||||
isPowered = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package su.a71.tardim_ic.tardim_ic.redsone_input;
|
||||
|
||||
import com.swdteam.tileentity.TileEntityBaseTardimPanel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.swdteam.common.init.TRDTiles;
|
||||
|
||||
import su.a71.tardim_ic.tardim_ic.Registration;
|
||||
import com.swdteam.tileentity.TileEntityTardimScanner;
|
||||
import com.swdteam.common.block.BlockTardimScanner;
|
||||
|
||||
|
||||
public class RedstoneInputTileEntity extends TileEntityBaseTardimPanel {
|
||||
public RedstoneInputTileEntity(BlockPos pos, BlockState state) {
|
||||
super(Registration.REDSTONE_TARDIM_INPUT_TILEENTITY.get(), pos, state);
|
||||
}
|
||||
|
||||
|
||||
public BlockPos getPos() {
|
||||
return this.worldPosition;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ license = "All rights reserved"
|
|||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId = "tardim_ic" #mandatory
|
||||
version = "1.0" #mandatory
|
||||
version = "0.8" #mandatory
|
||||
# A display name for the mod
|
||||
displayName = "TARDIM: In Control" #mandatory
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
|
@ -13,7 +13,7 @@ description = '''
|
|||
All of time and space, now automated. Control your TARDIM using ComputerCraft: Tweaked.
|
||||
'''
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.cctutorial]] #optional
|
||||
[[dependencies.tardim_ic]] #optional
|
||||
# the modid of the dependency
|
||||
modId = "forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
|
@ -25,13 +25,13 @@ ordering = "NONE"
|
|||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
side = "BOTH"
|
||||
# Here's another dependency
|
||||
[[dependencies.advancedperipherals]]
|
||||
[[dependencies.tardim_ic]]
|
||||
modId = "computercraft"
|
||||
mandatory = true
|
||||
versionRange = "1.95.3"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
[[dependencies.cctutorial]]
|
||||
[[dependencies.tardim_ic]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "tardim_ic:block/redstone_tardim_input"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"block.tardim_ic.digital_tardim_interface": "Digital TARDIM Interface",
|
||||
"block.tardim_ic.redstone_tardim_input": "Redstone TARDIM Input",
|
||||
"itemGroup.tardim_ic": "TARDIM: In Control"
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"block.tardim_ic.digital_tardim_interface": "Digital TARDIM Interface",
|
||||
"block.tardim_ic.redstone_tardim_input": "Redstone TARDIM Input",
|
||||
"itemGroup.tardim_ic": "TARDIM: In Control"
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"block.tardim_ic.digital_tardim_interface": "Циферный Интерфейсъ Хронобудки",
|
||||
"block.tardim_ic.redstone_tardim_input": "Краснокаменный Инпутъ Хронобудки",
|
||||
"itemGroup.tardim_ic": "ТАРДИМЪ: Подъ Контрольемъ"
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"block.tardim_ic.digital_tardim_interface": "Цифровой интерфейс TARDIM",
|
||||
"block.tardim_ic.redstone_tardim_input": "Редстоуновый ввод TARDIM",
|
||||
"itemGroup.tardim_ic": "TARDIM: In Control"
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"credit": "Made with Blockbench",
|
||||
"parent": "block/cube_all",
|
||||
"ambientocclusion": false,
|
||||
"textures": {
|
||||
"1": "tardim_ic:blocks/red_contr",
|
||||
"2": "tardim_ic:blocks/red_contr2",
|
||||
"particle": "tardim_ic:blocks/red_contr"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [0, 0, 0],
|
||||
"to": [16, 16, 16],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 16, 16], "texture": "#2"},
|
||||
"east": {"uv": [0, 0, 16, 16], "texture": "#2"},
|
||||
"south": {"uv": [0, 0, 16, 16], "texture": "#2"},
|
||||
"west": {"uv": [0, 0, 16, 16], "texture": "#2"},
|
||||
"up": {"uv": [0, 0, 16, 16], "texture": "#2"},
|
||||
"down": {"uv": [0, 0, 16, 16], "texture": "#2"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [-0.325, -0.35, -0.35],
|
||||
"to": [16.35, 16.525, 16.275],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 16, 16], "texture": "#1"},
|
||||
"east": {"uv": [0, 0, 16, 16], "texture": "#1"},
|
||||
"south": {"uv": [0, 0, 16, 16], "texture": "#1"},
|
||||
"west": {"uv": [0, 0, 16, 16], "texture": "#1"},
|
||||
"up": {"uv": [0, 0, 16, 16], "texture": "#1"},
|
||||
"down": {"uv": [0, 0, 16, 16], "texture": "#1"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"parent": "tardim_ic:block/redstone_tardim_input",
|
||||
"display": {
|
||||
"thirdperson_righthand": {
|
||||
"rotation": [ 75, 45, 0 ],
|
||||
"scale": [ 0.40, 0.40, 0.40 ],
|
||||
"translation": [ 0, 1, 0 ]
|
||||
},
|
||||
"thirdperson_lefthand": {
|
||||
"rotation": [ 75, 45, 0 ],
|
||||
"scale": [ 0.40, 0.40, 0.40 ],
|
||||
"translation": [ 0, 1, 0 ]
|
||||
},
|
||||
"firstperson_lefthand": {
|
||||
"rotation": [ 0, 45, 0 ],
|
||||
"scale": [ 0.40, 0.40, 0.40 ]
|
||||
},
|
||||
"firstperson_righthand": {
|
||||
"rotation": [ 0, 45, 0 ],
|
||||
"scale": [ 0.40, 0.40, 0.40 ]
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 927 B |
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"animation": {
|
||||
"frametime": 10,
|
||||
"interpolate": true,
|
||||
"frames": [0, 1, 2, 3]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"bonus_rolls": 0,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "tardim_ic:redstone_tardim_input",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"GRG",
|
||||
"RBR",
|
||||
"GRG"
|
||||
],
|
||||
"key": {
|
||||
"G": {
|
||||
"item": "minecraft:gold_ingot",
|
||||
"count": 1
|
||||
},
|
||||
"R": {
|
||||
"item": "minecraft:redstone",
|
||||
"count": 1
|
||||
},
|
||||
"B": {
|
||||
"item": "minecraft:redstone_block",
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "tardim_ic:redstone_tardim_input",
|
||||
"count": 1
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue