Skip to content

Commit

Permalink
Make Break Block super cheap on conjured blocks (including a new fanc…
Browse files Browse the repository at this point in the history
…y tag)
  • Loading branch information
gamma-delta committed Aug 27, 2024
1 parent 140e7d5 commit 7da86e1
Show file tree
Hide file tree
Showing 12 changed files with 537 additions and 517 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import at.petrak.hexcasting.api.casting.ActionRegistryEntry;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
Expand Down Expand Up @@ -47,6 +45,8 @@ public static final class Blocks {
// Used to determine what blocks should be replaced with air by OpDestroyFluid
public static final TagKey<Block> WATER_PLANTS = create("water_plants");

public static final TagKey<Block> CHEAP_TO_BREAK_BLOCK = create("cheap_to_break_block");

public static TagKey<Block> create(String name) {
return TagKey.create(Registries.BLOCK, modLoc(name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.api.mod.HexTags
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerPlayer
Expand All @@ -18,16 +19,18 @@ object OpBreakBlock : SpellAction {
get() = 1

override fun execute(
args: List<Iota>,
env: CastingEnvironment
args: List<Iota>,
env: CastingEnvironment
): SpellAction.Result {
val vecPos = args.getVec3(0, argc)
val pos = BlockPos.containing(vecPos)
env.assertPosInRangeForEditing(pos)

val isCheap = env.world.getBlockState(pos).`is`(HexTags.Blocks.CHEAP_TO_BREAK_BLOCK)

return SpellAction.Result(
Spell(pos),
MediaConstants.DUST_UNIT / 8,
if (isCheap) MediaConstants.DUST_UNIT / 100 else MediaConstants.DUST_UNIT / 8,
listOf(ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0))
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
public class HexBlockTagProvider extends PaucalBlockTagProvider {
public final IXplatTags xtags;

public HexBlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, IXplatTags xtags) {
public HexBlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider,
IXplatTags xtags) {
super(output, lookupProvider);
this.xtags = xtags;
}
Expand Down Expand Up @@ -94,18 +95,17 @@ protected void addTags(HolderLookup.Provider provider) {
add(tag(BlockTags.STAIRS),
HexBlocks.EDIFIED_STAIRS);
add(tag(BlockTags.FENCES),
HexBlocks.EDIFIED_FENCE);
HexBlocks.EDIFIED_FENCE);
add(tag(BlockTags.WOODEN_FENCES),
HexBlocks.EDIFIED_FENCE);
HexBlocks.EDIFIED_FENCE);
add(tag(BlockTags.FENCE_GATES),
HexBlocks.EDIFIED_FENCE_GATE);
HexBlocks.EDIFIED_FENCE_GATE);
add(tag(BlockTags.UNSTABLE_BOTTOM_CENTER),
HexBlocks.EDIFIED_FENCE_GATE);

HexBlocks.EDIFIED_FENCE_GATE);


add(tag(BlockTags.WOODEN_FENCES),
HexBlocks.EDIFIED_FENCE);
HexBlocks.EDIFIED_FENCE);
add(tag(BlockTags.WOODEN_STAIRS),
HexBlocks.EDIFIED_STAIRS);
add(tag(BlockTags.DOORS),
Expand All @@ -127,6 +127,8 @@ protected void addTags(HolderLookup.Provider provider) {

add(tag(HexTags.Blocks.WATER_PLANTS),
Blocks.KELP, Blocks.KELP_PLANT, Blocks.SEAGRASS, Blocks.TALL_SEAGRASS);
add(tag(HexTags.Blocks.CHEAP_TO_BREAK_BLOCK),
HexBlocks.CONJURED_BLOCK, HexBlocks.CONJURED_LIGHT);
}

void add(TagAppender<Block> appender, Block... blocks) {
Expand Down
Loading

0 comments on commit 7da86e1

Please sign in to comment.