Skip to content

Commit

Permalink
Add Filler Module
Browse files Browse the repository at this point in the history
Add Enhanced Filler With Chest
Add Redstone Hammer
  • Loading branch information
PTOM76 committed Sep 20, 2021
1 parent b92b2d9 commit ac204c8
Show file tree
Hide file tree
Showing 49 changed files with 614 additions and 99 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ loader_version=0.11.6

fabric_version=0.40.1+1.17

mod_version = 1.0.2
mod_version = 1.1.0
maven_group = ml.pkom
archives_base_name = EnhancedQuarries-1.17.1
2 changes: 2 additions & 0 deletions src/main/java/ml/pkom/enhancedquarries/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Blocks {

public static Filler NORMAL_FILLER = NormalFiller.getFiller();
public static Filler ENHANCED_FILLER = EnhancedFiller.getFiller();
public static Filler ENHANCED_FILLER_WITH_CHEST = EnhancedFillerWithChest.getFiller();

public static Block NORMAL_MARKER = NormalMarker.getBlock();
public static Block FRAME = Frame.getBlock();
Expand All @@ -25,6 +26,7 @@ public static void init() {

Registry.register(Registry.BLOCK, EnhancedQuarries.id("normal_filler"), NORMAL_FILLER);
Registry.register(Registry.BLOCK, EnhancedQuarries.id("enhanced_filler"), ENHANCED_FILLER);
Registry.register(Registry.BLOCK, EnhancedQuarries.id("enhanced_filler_with_chest"), ENHANCED_FILLER_WITH_CHEST);

Registry.register(Registry.BLOCK, EnhancedQuarries.id("normal_marker"), NORMAL_MARKER);
Registry.register(Registry.BLOCK, EnhancedQuarries.id("frame"), FRAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class EnhancedQuarries implements ModInitializer {

public static final String MOD_ID = "enhanced_quarries";
public static final String MOD_NAME = "Enhanced Quarries";
public static final String VERSION = "1.0.2";
public static final String VERSION = "1.1.0";
public static EnhancedQuarries instance;
private static final Logger LOGGER = LogManager.getLogger();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public static void init() {
addPattern(new FillerCraftingPattern(create(Items.fillerTOWER), ItemStack.EMPTY, BRICKS, BRICKS, ItemStack.EMPTY, BRICKS, BRICKS, ItemStack.EMPTY, BRICKS, BRICKS));
addPattern(new FillerCraftingPattern(create(Items.fillerVERTICAL_LAYER), SLAB_BRICKS, EMPTY, SLAB_BRICKS, SLAB_BRICKS, EMPTY, SLAB_BRICKS, SLAB_BRICKS, EMPTY, SLAB_BRICKS));
addPattern(new FillerCraftingPattern(create(Items.fillerHORIZONTAL_LAYER), SLAB_BRICKS, SLAB_BRICKS, SLAB_BRICKS, EMPTY, EMPTY, EMPTY, SLAB_BRICKS, SLAB_BRICKS, SLAB_BRICKS));

addPattern(new FillerCraftingPattern(create(Items.fillerSTAIRS), EMPTY, EMPTY, BRICKS, EMPTY, BRICKS, BRICKS, BRICKS, BRICKS, BRICKS));
addPattern(new FillerCraftingPattern(create(Items.fillerPYRAMID), EMPTY, EMPTY, EMPTY, EMPTY, BRICKS, EMPTY, BRICKS, BRICKS, BRICKS));
addPattern(new FillerCraftingPattern(create(Items.fillerCUT_STAIRS), EMPTY, EMPTY, GLASS, EMPTY, GLASS, GLASS, GLASS, GLASS, GLASS));
addPattern(new FillerCraftingPattern(create(Items.fillerCUT_PYRAMID), EMPTY, EMPTY, EMPTY, EMPTY, GLASS, EMPTY, GLASS, GLASS, GLASS));
}

public static ItemStack create(Item item) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/ml/pkom/enhancedquarries/FillerModules.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ public static void init() {
Registry.register(EnhancedQuarries.id("tower"), Items.fillerTOWER);
Registry.register(EnhancedQuarries.id("delete_fluid"), Items.fillerDELETE_FLUID);
Registry.register(EnhancedQuarries.id("floor_replace"), Items.fillerFLOOR_REPLACE);
Registry.register(EnhancedQuarries.id("stairs"), Items.fillerSTAIRS);
Registry.register(EnhancedQuarries.id("pyramid"), Items.fillerPYRAMID);
Registry.register(EnhancedQuarries.id("cut_stairs"), Items.fillerCUT_STAIRS);
Registry.register(EnhancedQuarries.id("cut_pyramid"), Items.fillerCUT_PYRAMID);
}
}
77 changes: 0 additions & 77 deletions src/main/java/ml/pkom/enhancedquarries/IInventory.java

This file was deleted.

23 changes: 20 additions & 3 deletions src/main/java/ml/pkom/enhancedquarries/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Items {

public static Item NORMAL_FILLER = new BlockItem(Blocks.NORMAL_FILLER, new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
public static Item ENHANCED_FILLER = new BlockItem(Blocks.ENHANCED_FILLER, new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
public static Item ENHANCED_FILLER_WITH_CHEST = new BlockItem(Blocks.ENHANCED_FILLER_WITH_CHEST, new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));

public static Item NORMAL_MARKER = new BlockItem(Blocks.NORMAL_MARKER, new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
public static Item FRAME = new BlockItem(Blocks.FRAME, new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
Expand Down Expand Up @@ -47,11 +48,20 @@ public class Items {
// 積み上げ
public static FillerModuleItem fillerTOWER = new TowerModule(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
// 液体除去(未実装)
public static FillerModuleItem fillerDELETE_FLUID = new DeleteFluidModule(new FabricItemSettings()); //.group(EnhancedQuarries.FILLER_PLUS_GROUP)
public static FillerModuleItem fillerDELETE_FLUID = new DeleteFluidModule(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
// 床張り替え
public static FillerModuleItem fillerFLOOR_REPLACE = new FloorReplaceModule(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));


// 階段
public static FillerModuleItem fillerSTAIRS = new CreateStairsModule(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
// 四角錐
public static FillerModuleItem fillerPYRAMID = new CreatePyramidModule(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
// 階段撤去
public static FillerModuleItem fillerCUT_STAIRS = new CutStairsModule(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
// 四角錐撤去
public static FillerModuleItem fillerCUT_PYRAMID = new CutPyramidModule(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));

// 赤石ハンマー
public static Item REDSTONE_HAMMER = new RedstoneHammer(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));

// 素材
public static Item REFINED_GEAR = new Item(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
Expand All @@ -67,6 +77,7 @@ public static void init() {

Registry.register(Registry.ITEM, EnhancedQuarries.id("normal_filler"), NORMAL_FILLER);
Registry.register(Registry.ITEM, EnhancedQuarries.id("enhanced_filler"), ENHANCED_FILLER);
Registry.register(Registry.ITEM, EnhancedQuarries.id("enhanced_filler_with_chest"), ENHANCED_FILLER_WITH_CHEST);

Registry.register(Registry.ITEM, EnhancedQuarries.id("normal_marker"), NORMAL_MARKER);
Registry.register(Registry.ITEM, EnhancedQuarries.id("frame"), FRAME);
Expand All @@ -89,6 +100,12 @@ public static void init() {
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_tower"), fillerTOWER);
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_delete_fluid"), fillerDELETE_FLUID);
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_floor_replace"), fillerFLOOR_REPLACE);
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_create_stairs"), fillerSTAIRS);
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_create_pyramid"), fillerPYRAMID);
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_cut_stairs"), fillerCUT_STAIRS);
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_cut_pyramid"), fillerCUT_PYRAMID);

Registry.register(Registry.ITEM, EnhancedQuarries.id("redstone_hammer"), REDSTONE_HAMMER);

Registry.register(Registry.ITEM, EnhancedQuarries.id("refined_gear"), REFINED_GEAR);
Registry.register(Registry.ITEM, EnhancedQuarries.id("enhanced_refined_gear"), ENHANCED_REFINED_GEAR);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/ml/pkom/enhancedquarries/ScreenHandlers.java
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);
}
}
2 changes: 2 additions & 0 deletions src/main/java/ml/pkom/enhancedquarries/Screens.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ml.pkom.enhancedquarries;

import ml.pkom.enhancedquarries.screen.FillerScreen;
import ml.pkom.enhancedquarries.screen.FillerWithChestScreen;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
Expand All @@ -9,5 +10,6 @@ public class Screens {
@Environment(EnvType.CLIENT)
public static void init() {
ScreenRegistry.register(ScreenHandlers.FILLER_SCREEN_HANDLER_TYPE, FillerScreen::new);
ScreenRegistry.register(ScreenHandlers.FILLER_WITH_CHEST_SCREEN_HANDLER_TYPE, FillerWithChestScreen::new);
}
}
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(""));
}
}
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 src/main/java/ml/pkom/enhancedquarries/item/RedstoneHammer.java
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);
}
}
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;
}
}
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;
}
}
Loading

0 comments on commit ac204c8

Please sign in to comment.