Skip to content

Commit

Permalink
Added sensor item conduits.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Apr 15, 2024
1 parent 86c4fbe commit b06e733
Show file tree
Hide file tree
Showing 32 changed files with 745 additions and 103 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ dependencies {
implementation project(path: ":catalyst:multiblocks",configuration: "namedElements")
implementation project(path: ":catalyst:effects",configuration: "namedElements")

implementation project(path: ":retrostorage",configuration: "namedElements")
//implementation project(path: ":retrostorage",configuration: "namedElements")

modImplementation "DragonFly:dragonfly:${project.dragonfly_version}"
modImplementation "BTWaila:btwaila:${project.btwaila_version}"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bta_version=7.1
loader_version=0.15.6-babric.4-bta

# Mods
halplibe_version=3.5.2
halplibe_version=3.5.3
modmenu_version=2.0.5
dragonfly_version=1.4.7-7.1
btwaila_version=1.0.9-7.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,21 @@ public class SignalIndustries implements ModInitializer, GameStartEntrypoint {
)
.build(new BlockItemConduit("basic.conduit.item.restrict",config.getInt("BlockIDs.basicRestrictItemConduit"),Tier.BASIC,Material.glass, PipeType.RESTRICT));

public static final Block basicSensorItemConduit = new BlockBuilder(MOD_ID)
.setTextures("item_conduit_basic_sensor_off.png")
.setLuminance(0)
.setResistance(1)
.setHardness(1)
.setBlockSound(BlockSounds.GLASS)
.setBlockModel(
new BlockModelDragonFly(
ModelHelper.getOrCreateBlockModel(MOD_ID,"conduit/item/basic/sensor/off/conduit_all.json"),
ModelHelper.getOrCreateBlockState(MOD_ID,"basic_item_conduit_sensor.json"),
new ItemConduitStateInterpreter(),
true
)
)
.build(new BlockItemConduit("basic.conduit.item.sensor",config.getInt("BlockIDs.basicSensorItemConduit"),Tier.BASIC,Material.glass, PipeType.SENSOR));

public static final Block infiniteEnergyCell = new BlockBuilder(MOD_ID)
.setTextures("cell_prototype.png")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.util.helper.MathHelper;
import net.minecraft.core.world.World;
import net.minecraft.core.world.WorldSource;
import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidPipe;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered;
import sunsetsatellite.signalindustries.gui.GuiFluidIOConfig;
import sunsetsatellite.signalindustries.gui.GuiRestrictPipeConfig;
import sunsetsatellite.signalindustries.gui.GuiSensorPipeConfig;
import sunsetsatellite.signalindustries.inventories.TileEntityConduit;
import sunsetsatellite.signalindustries.inventories.TileEntityItemConduit;
import sunsetsatellite.signalindustries.util.PipeMode;
Expand Down Expand Up @@ -54,6 +56,11 @@ public boolean blockActivated(World world, int i, int j, int k, EntityPlayer ent
SignalIndustries.displayGui(entityplayer, new GuiRestrictPipeConfig(entityplayer, tile, null), tile, tile.x,tile.y,tile.z);
return true;
}
if(!world.isClientSide && type == PipeType.SENSOR) {
TileEntityItemConduit tile = (TileEntityItemConduit) world.getBlockTileEntity(i,j,k);
SignalIndustries.displayGui(entityplayer, new GuiSensorPipeConfig(entityplayer.inventory, tile), tile, tile.x,tile.y,tile.z);
return true;
}
return false;
}

Expand Down Expand Up @@ -87,6 +94,24 @@ public void onBlockRemoved(World world, int i, int j, int k, int data) {
super.onBlockRemoved(world, i, j, k, data);
}

@Override
public boolean canProvidePower() {
return true;
}

@Override
public boolean isPoweringTo(WorldSource worldSource, int x, int y, int z, int side) {
TileEntityItemConduit tile = (TileEntityItemConduit)worldSource.getBlockTileEntity(x, y, z);
return tile != null && tile.type == PipeType.SENSOR && tile.sensorActive;
}

@Override
public boolean isIndirectlyPoweringTo(World world, int x, int y, int z, int side) {
TileEntityItemConduit tile = (TileEntityItemConduit)world.getBlockTileEntity(x, y, z);
return tile != null && tile.type == PipeType.SENSOR && tile.sensorActive;
}

@Override
public boolean renderAsNormalBlock() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public String getDescription(ItemStack stack) {

@Override
public void onBlockRemoved(World world, int i, int j, int k, int data) {
TileEntityExtractor tile = (TileEntityExtractor) world.getBlockTileEntity(i, j, k);
TileEntityTieredMachineBase tile = (TileEntityTieredMachineBase) world.getBlockTileEntity(i, j, k);
if (tile != null) {
for (Direction dir : Direction.values()) {
TileEntity tile2 = dir.getTileEntity(world, tile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sunsetsatellite.signalindustries.blocks.BlockFluidConduit;
import sunsetsatellite.signalindustries.inventories.TileEntityInserter;
import sunsetsatellite.signalindustries.inventories.TileEntityItemConduit;
import sunsetsatellite.signalindustries.util.PipeType;
import useless.dragonfly.model.blockstates.processed.MetaStateInterpreter;

import java.util.HashMap;
Expand Down Expand Up @@ -47,7 +48,12 @@ public HashMap<String, String> getStateMap(WorldSource worldSource, int i, int j
}
states.put(direction.getName().toLowerCase(), String.valueOf(show));
if(tile != null){
states.put("restrict_"+direction.getName().toLowerCase(), String.valueOf(tile.restrictDirections.get(direction)));
if(tile.type == PipeType.RESTRICT){
states.put("restrict_"+direction.getName().toLowerCase(), String.valueOf(tile.restrictDirections.get(direction)));
} else if (tile.type == PipeType.SENSOR) {
states.put("sensor_active",String.valueOf(tile.sensorActive));

}
states.put("mode",tile.mode.name());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package sunsetsatellite.signalindustries.containers;

import net.minecraft.core.InventoryAction;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.player.inventory.Container;
import net.minecraft.core.player.inventory.IInventory;
import net.minecraft.core.player.inventory.slot.Slot;
import sunsetsatellite.signalindustries.inventories.TileEntityItemConduit;
import sunsetsatellite.signalindustries.inventories.machines.TileEntityAssembler;

import java.util.List;

public class ContainerSensorPipe extends Container {

public ContainerSensorPipe(IInventory iInventory){
for(int j = 0; j < 3; j++)
{
for(int i1 = 0; i1 < 9; i1++)
{
addSlot(new Slot(iInventory, i1 + j * 9 + 9, 8 + i1 * 18, 84 + j * 18));
}

}

for(int k = 0; k < 9; k++)
{
addSlot(new Slot(iInventory, k, 8 + k * 18, 142));
}
}

public List<Integer> getMoveSlots(InventoryAction action, Slot slot, int target, EntityPlayer player) {
if (slot.id == 0) {
return this.getSlots(0, 1, false);
} else if (slot.id >= 1 && slot.id <= 4) {
return this.getSlots(1, 4, false);
} else if (slot.id >= 5 && slot.id <= 8) {
return this.getSlots(5, 4, false);
} else {
if (action == InventoryAction.MOVE_SIMILAR) {
if (slot.id >= 9 && slot.id <= 44) {
return this.getSlots(9, 36, false);
}
} else {
if (slot.id >= 9 && slot.id <= 35) {
return this.getSlots(9, 27, false);
}

if (slot.id >= 36 && slot.id <= 44) {
return this.getSlots(36, 9, false);
}
}

return null;
}
}

public List<Integer> getTargetSlots(InventoryAction action, Slot slot, int target, EntityPlayer player) {
if (slot.id >= 9 && slot.id <= 44) {
if (target == 1) {
return this.getSlots(1, 4, false);
} else if (target == 2) {
return this.getSlots(5, 4, false);
} else {
return slot.id < 36 ? this.getSlots(36, 9, false) : this.getSlots(9, 27, false);
}
} else {
return slot.id == 0 ? this.getSlots(9, 36, true) : this.getSlots(9, 36, false);
}
}
@Override
public boolean isUsableByPlayer(EntityPlayer entityPlayer) {
return true;
}
}
Loading

0 comments on commit b06e733

Please sign in to comment.