-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
557 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "oritech:block/item_pipe" | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/generated/assets/oritech/blockstates/item_pipe_connection.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "oritech:block/item_pipe_connection" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"parent": "oritech:block/item_pipe" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/rearth/oritech/block/blocks/pipes/ItemPipeBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package rearth.oritech.block.blocks.pipes; | ||
|
||
import net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup; | ||
import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.util.math.Direction; | ||
import rearth.oritech.block.entity.pipes.GenericPipeInterfaceEntity; | ||
import rearth.oritech.init.BlockContent; | ||
|
||
public class ItemPipeBlock extends GenericPipeBlock { | ||
|
||
public static GenericPipeInterfaceEntity.PipeNetworkData ITEM_PIPE_DATA = new GenericPipeInterfaceEntity.PipeNetworkData(); | ||
|
||
public ItemPipeBlock(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public BlockApiLookup<?, Direction> getSidesLookup() { | ||
return ItemStorage.SIDED; | ||
} | ||
|
||
@Override | ||
public BlockState getConnectionBlock() { | ||
return BlockContent.ITEM_PIPE_CONNECTION.getDefaultState(); | ||
} | ||
|
||
@Override | ||
public BlockState getNormalBlock() { | ||
return BlockContent.ITEM_PIPE.getDefaultState(); | ||
} | ||
|
||
@Override | ||
public String getPipeTypeName() { | ||
return "item"; | ||
} | ||
|
||
@Override | ||
public boolean connectToBlockType(Block block) { | ||
return block instanceof ItemPipeBlock || block instanceof ItemPipeConnectionBlock; | ||
} | ||
|
||
@Override | ||
public GenericPipeInterfaceEntity.PipeNetworkData getNetworkData() { | ||
return ITEM_PIPE_DATA; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
src/main/java/rearth/oritech/block/blocks/pipes/ItemPipeConnectionBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package rearth.oritech.block.blocks.pipes; | ||
|
||
import net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup; | ||
import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.state.StateManager; | ||
import net.minecraft.state.property.BooleanProperty; | ||
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.entity.pipes.GenericPipeInterfaceEntity; | ||
import rearth.oritech.block.entity.pipes.ItemPipeInterfaceEntity; | ||
import rearth.oritech.init.BlockContent; | ||
|
||
import static rearth.oritech.block.blocks.pipes.ItemPipeBlock.ITEM_PIPE_DATA; | ||
|
||
public class ItemPipeConnectionBlock extends GenericPipeConnectionBlock { | ||
|
||
public static final BooleanProperty EXTRACT = BooleanProperty.of("extract"); | ||
|
||
public ItemPipeConnectionBlock(Settings settings) { | ||
super(settings); | ||
this.setDefaultState(this.getDefaultState().with(EXTRACT, false)); | ||
} | ||
|
||
@Override | ||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { | ||
super.appendProperties(builder); | ||
builder.add(EXTRACT); | ||
} | ||
|
||
@Override | ||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { | ||
|
||
if (world.isClient) return ActionResult.SUCCESS; | ||
|
||
var oldExtract = state.get(EXTRACT); | ||
world.setBlockState(pos, state.with(EXTRACT, !oldExtract)); | ||
System.out.println("changed extract to: " + !oldExtract); | ||
|
||
return ActionResult.SUCCESS; | ||
} | ||
|
||
@Override | ||
public BlockApiLookup<?, Direction> getSidesLookup() { | ||
return ItemStorage.SIDED; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { | ||
return new ItemPipeInterfaceEntity(pos, state); | ||
} | ||
|
||
@Override | ||
public BlockState getConnectionBlock() { | ||
return BlockContent.ITEM_PIPE_CONNECTION.getDefaultState(); | ||
} | ||
|
||
@Override | ||
public BlockState getNormalBlock() { | ||
return BlockContent.ITEM_PIPE.getDefaultState(); | ||
} | ||
|
||
@Override | ||
public String getPipeTypeName() { | ||
return "item"; | ||
} | ||
|
||
@Override | ||
public boolean connectToBlockType(Block block) { | ||
return block instanceof ItemPipeBlock || block instanceof ItemPipeConnectionBlock; | ||
} | ||
|
||
@Override | ||
public GenericPipeInterfaceEntity.PipeNetworkData getNetworkData() { | ||
return ITEM_PIPE_DATA; | ||
} | ||
} |
Oops, something went wrong.