Skip to content

Commit 7421a35

Browse files
author
BastouP411
committed
Modifiend how peripherals work (state on and state off)
1 parent 56e4d60 commit 7421a35

File tree

63 files changed

+530
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+530
-268
lines changed

src/main/java/fr/bastoup/bperipherals/database/DBFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import fr.bastoup.bperipherals.beans.QueryResult;
55
import fr.bastoup.bperipherals.beans.SQLResult;
66
import fr.bastoup.bperipherals.beans.UpdateResult;
7-
import fr.bastoup.bperipherals.peripherals.PeripheralDatabase;
7+
import fr.bastoup.bperipherals.peripherals.database.PeripheralDatabase;
88

99
import java.sql.*;
1010

src/main/java/fr/bastoup/bperipherals/init/ModBlocks.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package fr.bastoup.bperipherals.init;
22

3-
import fr.bastoup.bperipherals.blocks.BlockCryptographicAccelerator;
4-
import fr.bastoup.bperipherals.blocks.BlockDatabase;
5-
import fr.bastoup.bperipherals.blocks.BlockFEMeter;
3+
import fr.bastoup.bperipherals.peripherals.cryprographicaccelerator.BlockCryptographicAccelerator;
4+
import fr.bastoup.bperipherals.peripherals.database.BlockDatabase;
5+
import fr.bastoup.bperipherals.peripherals.femeter.BlockFEMeter;
6+
import fr.bastoup.bperipherals.peripherals.magcardreader.BlockMagCardReader;
67
import net.minecraft.block.Block;
78

89
import java.util.ArrayList;
@@ -14,4 +15,5 @@ public class ModBlocks {
1415
public static final Block FE_METER = new BlockFEMeter();
1516
public static final Block DATABASE = new BlockDatabase();
1617
public static final Block CRYPTOGRAPHIC_ACCELERATOR = new BlockCryptographicAccelerator();
18+
public static final Block MAG_CARD_READER = new BlockMagCardReader();
1719
}

src/main/java/fr/bastoup/bperipherals/init/ModContainerTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package fr.bastoup.bperipherals.init;
22

3-
import fr.bastoup.bperipherals.containers.ContainerDatabase;
3+
import fr.bastoup.bperipherals.peripherals.database.ContainerDatabase;
44
import fr.bastoup.bperipherals.util.BPeripheralsProperties;
55
import net.minecraft.inventory.container.ContainerType;
66
import net.minecraft.util.ResourceLocation;

src/main/java/fr/bastoup/bperipherals/init/ModItems.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package fr.bastoup.bperipherals.init;
22

3-
import fr.bastoup.bperipherals.items.ItemBase;
3+
import fr.bastoup.bperipherals.util.items.ItemBase;
44
import net.minecraft.item.Item;
55

66
import java.util.ArrayList;

src/main/java/fr/bastoup/bperipherals/init/ModTileTypes.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package fr.bastoup.bperipherals.init;
22

3-
import dan200.computercraft.api.lua.ILuaAPIFactory;
4-
import fr.bastoup.bperipherals.tileentities.TileCryptographicAccelerator;
5-
import fr.bastoup.bperipherals.tileentities.TileDatabase;
6-
import fr.bastoup.bperipherals.tileentities.TileFEMeter;
3+
import fr.bastoup.bperipherals.peripherals.cryprographicaccelerator.TileCryptographicAccelerator;
4+
import fr.bastoup.bperipherals.peripherals.database.TileDatabase;
5+
import fr.bastoup.bperipherals.peripherals.femeter.TileFEMeter;
6+
import fr.bastoup.bperipherals.peripherals.magcardreader.TileMagCardReader;
77
import fr.bastoup.bperipherals.util.BPeripheralsProperties;
88
import net.minecraft.tileentity.TileEntityType;
99
import net.minecraft.util.ResourceLocation;
@@ -16,4 +16,7 @@ public class ModTileTypes {
1616
.build(null).setRegistryName(new ResourceLocation(BPeripheralsProperties.MODID, "database"));
1717
public static final TileEntityType<TileCryptographicAccelerator> CRYPTOGRAPHIC_ACCELERATOR = (TileEntityType<TileCryptographicAccelerator>) TileEntityType.Builder.create(TileCryptographicAccelerator::new, ModBlocks.CRYPTOGRAPHIC_ACCELERATOR)
1818
.build(null).setRegistryName(new ResourceLocation(BPeripheralsProperties.MODID, "cryptographic_accelerator"));
19+
public static final TileEntityType<TileMagCardReader> MAG_CARD_READER = (TileEntityType<TileMagCardReader>) TileEntityType.Builder.create(TileMagCardReader::new, ModBlocks.MAG_CARD_READER)
20+
.build(null).setRegistryName(new ResourceLocation(BPeripheralsProperties.MODID, "mag_card_reader"));
21+
1922
}

src/main/java/fr/bastoup/bperipherals/blocks/BlockCryptographicAccelerator.java renamed to src/main/java/fr/bastoup/bperipherals/peripherals/cryprographicaccelerator/BlockCryptographicAccelerator.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
package fr.bastoup.bperipherals.blocks;
1+
package fr.bastoup.bperipherals.peripherals.cryprographicaccelerator;
22

33
import fr.bastoup.bperipherals.init.ModTileTypes;
4+
import fr.bastoup.bperipherals.util.blocks.BlockPeripheral;
45
import net.minecraft.block.BlockState;
56
import net.minecraft.block.material.Material;
67
import net.minecraft.tileentity.TileEntity;
7-
import net.minecraft.util.Direction;
88
import net.minecraft.world.IBlockReader;
99

1010
import javax.annotation.Nullable;
1111

12-
public class BlockCryptographicAccelerator extends BlockOrientable{
12+
public class BlockCryptographicAccelerator extends BlockPeripheral {
1313

1414
public BlockCryptographicAccelerator() {
1515
super(Properties.create(Material.ROCK).hardnessAndResistance(2.0F), "cryptographic_accelerator");
16-
17-
setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
1816
}
1917

2018
@Override

src/main/java/fr/bastoup/bperipherals/peripherals/PeripheralCryptographicAccelerator.java renamed to src/main/java/fr/bastoup/bperipherals/peripherals/cryprographicaccelerator/PeripheralCryptographicAccelerator.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
package fr.bastoup.bperipherals.peripherals;
1+
package fr.bastoup.bperipherals.peripherals.cryprographicaccelerator;
22

3-
import dan200.computercraft.api.lua.IArguments;
43
import dan200.computercraft.api.lua.LuaException;
54
import dan200.computercraft.api.lua.LuaFunction;
6-
import dan200.computercraft.api.peripheral.IComputerAccess;
75
import dan200.computercraft.api.peripheral.IPeripheral;
8-
import fr.bastoup.bperipherals.tileentities.TileCryptographicAccelerator;
96
import fr.bastoup.bperipherals.util.Util;
10-
import org.squiddev.cobalt.LuaString;
7+
import fr.bastoup.bperipherals.util.peripherals.BPeripheral;
118

129
import javax.annotation.Nonnull;
1310
import javax.annotation.Nullable;
@@ -26,14 +23,13 @@
2623
import java.util.HashMap;
2724
import java.util.Map;
2825

29-
public class PeripheralCryptographicAccelerator implements IPeripheral {
26+
public class PeripheralCryptographicAccelerator extends BPeripheral {
3027

3128
public static final String TYPE = "cryptographic_accelerator";
3229

33-
private final TileCryptographicAccelerator tile;
3430

3531
public PeripheralCryptographicAccelerator(TileCryptographicAccelerator tile) {
36-
this.tile = tile;
32+
super(tile);
3733
}
3834

3935
@Nonnull
@@ -42,22 +38,6 @@ public String getType() {
4238
return TYPE;
4339
}
4440

45-
@Override
46-
public void attach(@Nonnull IComputerAccess computer) {
47-
48-
}
49-
50-
@Override
51-
public void detach(@Nonnull IComputerAccess computer) {
52-
53-
}
54-
55-
@Nullable
56-
@Override
57-
public Object getTarget() {
58-
return tile;
59-
}
60-
6141
@Override
6242
public boolean equals(@Nullable IPeripheral other) {
6343
return other instanceof PeripheralCryptographicAccelerator && ((TileCryptographicAccelerator) other.getTarget()).getWorld().equals(tile.getWorld()) &&
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package fr.bastoup.bperipherals.peripherals.cryprographicaccelerator;
2+
3+
import fr.bastoup.bperipherals.init.ModTileTypes;
4+
import fr.bastoup.bperipherals.util.tiles.TilePeripheral;
5+
6+
public class TileCryptographicAccelerator extends TilePeripheral {
7+
public TileCryptographicAccelerator() {
8+
super(ModTileTypes.CRYPTOGRAPHIC_ACCELERATOR);
9+
this.setPeripheral(new PeripheralCryptographicAccelerator(this));
10+
}
11+
}

src/main/java/fr/bastoup/bperipherals/blocks/BlockDatabase.java renamed to src/main/java/fr/bastoup/bperipherals/peripherals/database/BlockDatabase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package fr.bastoup.bperipherals.blocks;
1+
package fr.bastoup.bperipherals.peripherals.database;
22

33
import fr.bastoup.bperipherals.init.ModTileTypes;
4-
import fr.bastoup.bperipherals.tileentities.TileDatabase;
54
import fr.bastoup.bperipherals.util.BPeripheralsProperties;
5+
import fr.bastoup.bperipherals.util.blocks.BlockPeripheral;
66
import net.minecraft.block.Block;
77
import net.minecraft.block.BlockState;
88
import net.minecraft.block.material.Material;
@@ -26,7 +26,7 @@
2626
@Mod.EventBusSubscriber(
2727
modid = BPeripheralsProperties.MODID
2828
)
29-
public class BlockDatabase extends BlockOrientable {
29+
public class BlockDatabase extends BlockPeripheral {
3030

3131
public static final BooleanProperty DISK_INSERTED = BooleanProperty.create("disk");
3232

src/main/java/fr/bastoup/bperipherals/containers/ContainerDatabase.java renamed to src/main/java/fr/bastoup/bperipherals/peripherals/database/ContainerDatabase.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
package fr.bastoup.bperipherals.containers;
1+
package fr.bastoup.bperipherals.peripherals.database;
22

3-
import fr.bastoup.bperipherals.capabilites.DatabaseInventory;
43
import fr.bastoup.bperipherals.init.ModContainerTypes;
54
import net.minecraft.entity.player.PlayerEntity;
65
import net.minecraft.entity.player.PlayerInventory;
@@ -14,9 +13,9 @@
1413

1514
public class ContainerDatabase extends Container {
1615

17-
private final DatabaseInventory inventory;
16+
private final InventoryDatabase inventory;
1817

19-
public ContainerDatabase(int id, PlayerInventory player, DatabaseInventory inventory) {
18+
public ContainerDatabase(int id, PlayerInventory player, InventoryDatabase inventory) {
2019
super(ModContainerTypes.DATABASE, id);
2120
this.inventory = inventory;
2221
this.addSlot(new SlotItemHandler(inventory, 0, 80, 35));
@@ -34,7 +33,7 @@ public ContainerDatabase(int id, PlayerInventory player, DatabaseInventory inven
3433
}
3534

3635
public ContainerDatabase(int i, PlayerInventory inventory, PacketBuffer buffer) {
37-
this(i, inventory, new DatabaseInventory(null));
36+
this(i, inventory, new InventoryDatabase(null));
3837
}
3938

4039
public boolean canInteractWith(@Nonnull PlayerEntity player) {

0 commit comments

Comments
 (0)