Skip to content

Commit

Permalink
new features with problems WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagodefendi committed Nov 19, 2024
1 parent 6b8cab1 commit 692b72d
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 13 deletions.
15 changes: 14 additions & 1 deletion src/main/java/com/defendi/crazyideas/block/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ public class ModBlocks {
public static final DeferredRegister<Block> BLOCKS =
DeferredRegister.create(ForgeRegistries.BLOCKS, CrazyIdeas.MOD_ID);

// SACRED BLOCK ---------------------------------------------------------------------------
public static RegistryObject<Block> HOLY_METAL_BLOCK = registryBlock(
"holy_metal_block",
() -> new Block(BlockBehaviour.Properties.of()
.mapColor(MapColor.METAL)
.sound(SoundType.METAL)
.instrument(NoteBlockInstrument.IRON_XYLOPHONE)
.instrument(NoteBlockInstrument.HARP)
.requiresCorrectToolForDrops()
.strength(8.0F, 6.0F)
)
Expand All @@ -54,6 +55,18 @@ public class ModBlocks {
)
);

// SINFUL BLOCK ---------------------------------------------------------------------------
public static RegistryObject<Block> EVIL_METAL_BLOCK = registryBlock(
"evil_metal_block",
() -> new Block(BlockBehaviour.Properties.of()
.mapColor(MapColor.NETHER)
.sound(SoundType.METAL)
.instrument(NoteBlockInstrument.GUITAR)
.requiresCorrectToolForDrops()
.strength(8.0f, 6.0f)
)
);

private static <T extends Block> RegistryObject<T> registryBlock(String name, Supplier<T> block) {
RegistryObject<T> toReturn = BLOCKS.register(name, block);
registerBlockItem(name, toReturn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ protected ModBlockLootTableProvider(HolderLookup.Provider pRegistries) {
@Override
protected void generate() {
dropSelf(ModBlocks.HOLY_METAL_BLOCK.get());

this.add(
ModBlocks.HOLY_CATALYST_BLOCK.get(),
block -> createSilkTouchOnlyTable(
ModBlocks.HOLY_CATALYST_BLOCK.get()
)
);

dropSelf(ModBlocks.HOLY_LAMP.get());

dropSelf(ModBlocks.EVIL_METAL_BLOCK.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ protected void registerStatesAndModels() {
blockWithItem(ModBlocks.HOLY_METAL_BLOCK);
blockWithItem(ModBlocks.HOLY_CATALYST_BLOCK);
holyLampBlock();

blockWithItem(ModBlocks.EVIL_METAL_BLOCK);
}

private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ public ModBlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Pro
protected void addTags(HolderLookup.Provider provider) {
tag(BlockTags.MINEABLE_WITH_PICKAXE)
.add(
ModBlocks.HOLY_METAL_BLOCK.get()
ModBlocks.HOLY_METAL_BLOCK.get(),

ModBlocks.EVIL_METAL_BLOCK.get()
);

tag(BlockTags.NEEDS_IRON_TOOL)
.add(
ModBlocks.HOLY_METAL_BLOCK.get()
ModBlocks.HOLY_METAL_BLOCK.get(),

ModBlocks.EVIL_METAL_BLOCK.get()
);

tag(ModTags.Blocks.NEED_HOLY_METAL_TOOL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected void registerModels() {
basicItem(ModItems.HOLY_METAL.get());
handheldItem(ModItems.ANGEL_BLADE);

basicItem(ModItems.EVIL_METAL.get());
basicItem(ModItems.HELL_FUEL.get());

basicItem(ModItems.METAL_DETECTOR.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class ModCreativeModeTabs {
.withTabsBefore(SACRED_TAB.getId())
.title(Component.translatable("creativetab.crazyideas.sinful_tab"))
.displayItems((pParameters, pOutput) -> {
pOutput.accept(ModItems.EVIL_METAL.get());
pOutput.accept(ModBlocks.EVIL_METAL_BLOCK.get());
pOutput.accept(ModItems.HELL_FUEL.get());
})
.build()
Expand Down
41 changes: 33 additions & 8 deletions src/main/java/com/defendi/crazyideas/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import com.defendi.crazyideas.item.tool.SwordUnbreakableItem;
import com.defendi.crazyideas.item.utility.ChiselItem;
import com.defendi.crazyideas.item.utility.MetalDetectorItem;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.SwordItem;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
Expand All @@ -20,6 +22,7 @@ public class ModItems {
public static final DeferredRegister<Item> ITEMS =
DeferredRegister.create(ForgeRegistries.ITEMS, CrazyIdeas.MOD_ID);

// SACRED ITEMS -------------------------------------------------------------------------
public static final RegistryObject<Item> HOLY_METAL = ITEMS.register(
"holy_metal",
() -> new Item(
Expand All @@ -40,6 +43,35 @@ public class ModItems {
)
);

// SINFUL ITEMS -------------------------------------------------------------------------
public static final RegistryObject<Item> EVIL_METAL = ITEMS.register(
"evil_metal",
() -> new Item(
new Item.Properties()
)
);

public static final RegistryObject<Item> HELL_FUEL = ITEMS.register(
"hell_fuel",
() -> new FuelItem(
new Item.Properties(),
25600
)
);

public static final RegistryObject<Item> EVIL_METAL_HAMMER = ITEMS.register(
"evil_metal_hammer",
() -> new DiggerItem(
new Item.Properties()
.attributes(PickaxeItem.createAttributes(
ModToolTiers.EVIL_METAL,
6,
-3.5f
))
)
)

// UTILITY ITEMS -------------------------------------------------------------------------
public static final RegistryObject<Item> METAL_DETECTOR = ITEMS.register(
"metal_detector",
() -> new MetalDetectorItem(
Expand All @@ -56,6 +88,7 @@ public class ModItems {
)
);

// JAPAN ITEMS ----------------------------------------------------------------------
public static final RegistryObject<Item> SENZU_BEAN = ITEMS.register(
"senzu_bean",
() -> new SenzuBeanItem(
Expand All @@ -65,14 +98,6 @@ public class ModItems {
)
);

public static final RegistryObject<Item> HELL_FUEL = ITEMS.register(
"hell_fuel",
() -> new FuelItem(
new Item.Properties(),
25600
)
);

// public static final RegistryObject<Item> MOTHER_FLAME = ITEMS.register(
// "mother_flame",
// () -> new Item(
Expand Down
76 changes: 76 additions & 0 deletions src/main/java/com/defendi/crazyideas/item/tool/HammerItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.defendi.crazyideas.item.tool;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;

import java.util.ArrayList;
import java.util.List;

public class HammerItem extends DiggerItem {
public HammerItem(Tier pTier, Properties pProperties) {
super(pTier, BlockTags.MINEABLE_WITH_PICKAXE, pProperties);
}

public static List<BlockPos> getBlockToBeDestroyed(int range, BlockPos initialBlockPos, ServerPlayer player) {
List<BlockPos> positions = new ArrayList<>();

BlockHitResult traceResult = player.level().clip(
new ClipContext(
player.getEyePosition(1f),
(player.getEyePosition(1f)).add(player.getViewVector(1f).scale(6f)),
ClipContext.Block.COLLIDER,
ClipContext.Fluid.NONE,
player
)
);

if (traceResult.getType() == HitResult.Type.MISS) {
return positions;
}

if (traceResult.getDirection() == Direction.DOWN || traceResult.getDirection() == Direction.UP) {
for (int x = 0; x <= range; x++) {
for (int z = 0; z < range; z++){
positions.add(new BlockPos(
initialBlockPos.getX() + x,
initialBlockPos.getY(),
initialBlockPos.getZ() + z
));
}
}
}

if (traceResult.getDirection() == Direction.NORTH || traceResult.getDirection() == Direction.SOUTH) {
for (int x = 0; x <= range; x++) {
for (int y = 0; y < range; y++){
positions.add(new BlockPos(
initialBlockPos.getX() + x,
initialBlockPos.getY() + y,
initialBlockPos.getZ()
));
}
}
}

if (traceResult.getDirection() == Direction.NORTH || traceResult.getDirection() == Direction.SOUTH) {
for (int z = 0; z <= range; z++) {
for (int y = 0; y < range; y++){
positions.add(new BlockPos(
initialBlockPos.getX(),
initialBlockPos.getY() + y,
initialBlockPos.getZ() + z
));
}
}
}

return positions;
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/defendi/crazyideas/item/tool/ModToolTiers.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public class ModToolTiers {
ModTags.Blocks.INCORRECT_FOR_HOLY_METAL_TOOL
);

public static final Tier EVIL_METAL = new ForgeTier(
4000,
8,
11f,
35,
ModTags.Blocks.NEED_HOLY_METAL_TOOL,
() -> Ingredient.of(ModItems.HOLY_METAL.get()),
ModTags.Blocks.INCORRECT_FOR_HOLY_METAL_TOOL
);

public static final Tier ANGEL_TOOL = new ForgeTier(
-1,
10,
Expand Down

0 comments on commit 692b72d

Please sign in to comment.