-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Enhanced Filler With Chest Add Redstone Hammer
- Loading branch information
Showing
49 changed files
with
614 additions
and
99 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
package ml.pkom.enhancedquarries; | ||
|
||
import ml.pkom.enhancedquarries.screen.FillerScreenHandler; | ||
import ml.pkom.enhancedquarries.screen.FillerWithChestScreenHandler; | ||
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; | ||
import net.minecraft.screen.ScreenHandlerType; | ||
|
||
public class ScreenHandlers { | ||
public static ScreenHandlerType<FillerScreenHandler> FILLER_SCREEN_HANDLER_TYPE; | ||
public static ScreenHandlerType<FillerWithChestScreenHandler> FILLER_WITH_CHEST_SCREEN_HANDLER_TYPE; | ||
|
||
public static void init() { | ||
FILLER_SCREEN_HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(EnhancedQuarries.id("filler"), FillerScreenHandler::new); | ||
FILLER_WITH_CHEST_SCREEN_HANDLER_TYPE = ScreenHandlerRegistry.registerSimple(EnhancedQuarries.id("filler_with_chest"), FillerWithChestScreenHandler::new); | ||
} | ||
} |
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
62 changes: 62 additions & 0 deletions
62
src/main/java/ml/pkom/enhancedquarries/block/EnhancedFillerWithChest.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,62 @@ | ||
package ml.pkom.enhancedquarries.block; | ||
|
||
import ml.pkom.enhancedquarries.block.base.Filler; | ||
import ml.pkom.enhancedquarries.event.TileCreateEvent; | ||
import ml.pkom.enhancedquarries.screen.FillerWithChestScreenHandler; | ||
import ml.pkom.enhancedquarries.tile.EnhancedFillerWithChestTile; | ||
import ml.pkom.enhancedquarries.tile.base.FillerTile; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.screen.NamedScreenHandlerFactory; | ||
import net.minecraft.screen.SimpleNamedScreenHandlerFactory; | ||
import net.minecraft.text.LiteralText; | ||
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.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class EnhancedFillerWithChest extends Filler { | ||
|
||
public EnhancedFillerWithChest() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public BlockEntity createBlockEntity(TileCreateEvent event) { | ||
return new EnhancedFillerWithChestTile(event); | ||
} | ||
|
||
// instance | ||
public static Filler INSTANCE = new EnhancedFillerWithChest(); | ||
|
||
public static Filler getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
public static Filler getFiller() { | ||
return getInstance(); | ||
} | ||
// ---- | ||
|
||
@Override | ||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hitResult) { | ||
if (world.isClient()) | ||
return ActionResult.SUCCESS; | ||
NamedScreenHandlerFactory namedScreenHandlerFactory = createScreenHandlerFactory(state, world, pos); | ||
if (namedScreenHandlerFactory != null) { | ||
player.openHandledScreen(namedScreenHandlerFactory); | ||
} | ||
|
||
return ActionResult.CONSUME; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) { | ||
FillerTile fillerTile = (FillerTile) world.getBlockEntity(pos); | ||
return new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> new FillerWithChestScreenHandler(i, playerInventory, fillerTile.getInventory(), fillerTile.getCraftingInventory()), new LiteralText("")); | ||
} | ||
} |
5 changes: 4 additions & 1 deletion
5
src/main/java/ml/pkom/enhancedquarries/inventory/FillerInventory.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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package ml.pkom.enhancedquarries.inventory; | ||
|
||
import net.minecraft.inventory.Inventory; | ||
import net.minecraft.inventory.SimpleInventory; | ||
|
||
public class FillerInventory extends SimpleInventory { | ||
public FillerInventory() { | ||
super(27); | ||
} | ||
|
||
public FillerInventory(int size) { | ||
super(size); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/ml/pkom/enhancedquarries/item/RedstoneHammer.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,27 @@ | ||
package ml.pkom.enhancedquarries.item; | ||
|
||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.item.ItemUsageContext; | ||
import net.minecraft.item.PickaxeItem; | ||
import net.minecraft.item.ToolMaterials; | ||
import net.minecraft.util.ActionResult; | ||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity; | ||
|
||
public class RedstoneHammer extends PickaxeItem { | ||
public RedstoneHammer(Settings settings) { | ||
super(ToolMaterials.STONE, 1, -3f, settings); | ||
} | ||
|
||
@Override | ||
public ActionResult useOnBlock(ItemUsageContext context) { | ||
if (context.getWorld().getBlockEntity(context.getBlockPos()) != null) { | ||
BlockEntity blockEntity = context.getWorld().getBlockEntity(context.getBlockPos()); | ||
if (blockEntity instanceof PowerAcceptorBlockEntity) { | ||
PowerAcceptorBlockEntity energyStorage = (PowerAcceptorBlockEntity) blockEntity; | ||
energyStorage.addEnergy(1); | ||
return ActionResult.SUCCESS; | ||
} | ||
} | ||
return super.useOnBlock(context); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/ml/pkom/enhancedquarries/item/fillermodule/CreatePyramidModule.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,33 @@ | ||
package ml.pkom.enhancedquarries.item.fillermodule; | ||
|
||
import ml.pkom.enhancedquarries.event.FillerModuleReturn; | ||
import ml.pkom.enhancedquarries.event.FillerProcessEvent; | ||
import ml.pkom.enhancedquarries.item.base.FillerModuleItem; | ||
import net.minecraft.block.AirBlock; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.FluidBlock; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class CreatePyramidModule extends FillerModuleItem { | ||
public CreatePyramidModule(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public FillerModuleReturn onProcessInRange(FillerProcessEvent e) { | ||
if (e.getProcessBlock() instanceof AirBlock || e.getProcessBlock() instanceof FluidBlock) { | ||
int procX = e.getProcessPos().getX(); | ||
int procZ = e.getProcessPos().getZ(); | ||
int procY = e.getProcessPos().getY(); | ||
int diffY = procY - e.getPos1().getY(); | ||
if (procX >= e.getPos1().getX() + diffY && procX <= e.getPos2().getX() - diffY && procZ <= e.getPos1().getZ() - diffY && procZ >= e.getPos2().getZ() + diffY) { | ||
ItemStack stack = e.getTile().getInventoryStack(); | ||
if (stack.isEmpty()) return FillerModuleReturn.RETURN_FALSE; | ||
Block block = Block.getBlockFromItem(stack.getItem()); | ||
if (block.equals(e.getProcessBlock())) return FillerModuleReturn.CONTINUE; | ||
if (e.getTile().tryPlacing(e.getProcessPos(), block, stack)) return FillerModuleReturn.RETURN_TRUE; | ||
} | ||
} | ||
return FillerModuleReturn.CONTINUE; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/ml/pkom/enhancedquarries/item/fillermodule/CreateStairsModule.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,34 @@ | ||
package ml.pkom.enhancedquarries.item.fillermodule; | ||
|
||
import ml.pkom.enhancedquarries.event.FillerModuleReturn; | ||
import ml.pkom.enhancedquarries.event.FillerProcessEvent; | ||
import ml.pkom.enhancedquarries.item.base.FillerModuleItem; | ||
import net.minecraft.block.AirBlock; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.FluidBlock; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.math.Direction; | ||
|
||
public class CreateStairsModule extends FillerModuleItem { | ||
public CreateStairsModule(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public FillerModuleReturn onProcessInRange(FillerProcessEvent e) { | ||
if (e.getProcessBlock() instanceof AirBlock || e.getProcessBlock() instanceof FluidBlock) { | ||
int procX = e.getProcessPos().getX(); | ||
int procZ = e.getProcessPos().getZ(); | ||
int procY = e.getProcessPos().getY(); | ||
int diffY = procY - e.getPos1().getY(); | ||
if ((procX >= e.getPos1().getX() + diffY && e.getTile().getFacing().equals(Direction.SOUTH)) || (procX <= e.getPos2().getX() - diffY && e.getTile().getFacing().equals(Direction.NORTH)) || (procZ <= e.getPos1().getZ() - diffY && e.getTile().getFacing().equals(Direction.EAST)) || (procZ >= e.getPos2().getZ() + diffY && e.getTile().getFacing().equals(Direction.WEST))) { | ||
ItemStack stack = e.getTile().getInventoryStack(); | ||
if (stack.isEmpty()) return FillerModuleReturn.RETURN_FALSE; | ||
Block block = Block.getBlockFromItem(stack.getItem()); | ||
if (block.equals(e.getProcessBlock())) return FillerModuleReturn.CONTINUE; | ||
if (e.getTile().tryPlacing(e.getProcessPos(), block, stack)) return FillerModuleReturn.RETURN_TRUE; | ||
} | ||
} | ||
return FillerModuleReturn.CONTINUE; | ||
} | ||
} |
Oops, something went wrong.