Skip to content

Commit

Permalink
Merge branch 'main' into fix-misc-docs-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gamma-delta authored Sep 9, 2024
2 parents 2a5683e + 26c882b commit 8cea4f1
Show file tree
Hide file tree
Showing 34 changed files with 647 additions and 646 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"values": [
"hexcasting:overcast",
"hexcasting:shame"
"hexcasting:overcast"
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"values": [
"hexcasting:overcast",
"hexcasting:shame"
"hexcasting:overcast"
]
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"values": [
"hexcasting:overcast",
"hexcasting:shame"
"hexcasting:overcast"
]
}

This file was deleted.

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 @@ -5,7 +5,6 @@
import at.petrak.hexcasting.common.msgs.MsgShiftScrollC2S;
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.item.Item;

Expand Down Expand Up @@ -46,7 +45,7 @@ public static boolean onScroll(double delta, boolean needsSneaking) {
public static void clientTickEnd() {
if (mainHandDelta != 0 || offHandDelta != 0) {
IClientXplatAbstractions.INSTANCE.sendPacketToServer(
new MsgShiftScrollC2S(mainHandDelta, offHandDelta, Screen.hasControlDown(),
new MsgShiftScrollC2S(mainHandDelta, offHandDelta, Minecraft.getInstance().options.keySprint.isDown(),
HexConfig.client().invertSpellbookScrollDirection(),
HexConfig.client().invertAbacusScrollDirection()));
mainHandDelta = 0;
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 @@ -8,23 +8,36 @@ import at.petrak.hexcasting.api.casting.getPositiveDoubleUnderInclusive
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.common.casting.actions.selectors.OpGetEntitiesBy
import net.minecraft.core.BlockPos
import net.minecraft.util.Mth
import net.minecraft.world.level.Level
import net.minecraft.world.phys.AABB
import net.minecraft.world.phys.Vec3

class OpExplode(val fire: Boolean) : SpellAction {
override val argc: Int
get() = 2

override fun execute(
args: List<Iota>,
env: CastingEnvironment
args: List<Iota>,
env: CastingEnvironment
): SpellAction.Result {
val pos = args.getVec3(0, argc)
var pos = args.getVec3(0, argc)
val strength = args.getPositiveDoubleUnderInclusive(1, 10.0, argc)
env.assertVecInRange(pos)

// Prevent the footgun of explosions exactly at an entity's eye position not doing damage
val eps = 0.01;
val epsv = Vec3(eps, eps, eps)
val aabb = AABB(pos.subtract(epsv), pos.add(epsv))
val tooCloseToEyePos = env.world.getEntities(null, aabb) {
OpGetEntitiesBy.isReasonablySelectable(env, it)
}.any { it.eyePosition.distanceToSqr(pos) == 0.0 }
if (tooCloseToEyePos) {
pos = pos.add(0.0, 0.000001, 0.0)
}

val clampedStrength = Mth.clamp(strength, 0.0, 10.0)
val cost = MediaConstants.DUST_UNIT * (3 * clampedStrength + if (fire) 1.0 else 0.125)
return SpellAction.Result(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getPositiveInt
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.casting.mishaps.MishapShameOnYou
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes

object OpDuplicateN : ConstMediaAction {
override val argc: Int
get() = 2

override fun execute(args: List<Iota>, env: CastingEnvironment): List<Iota> {
val count = args.getPositiveInt(1, argc)
var count = args.getPositiveInt(1, argc)

if (count > 1000) {
throw MishapShameOnYou()
if (count > HexIotaTypes.MAX_SERIALIZATION_TOTAL) {
// If we throw here, the message will point to us, which usually doesn't happen.
// So ensure that this check has no user-facing effects, just cap to MAX_SERIALIZATION_TOTAL,
// which will unconditionally trigger Too Many Iotas after we return.
count = HexIotaTypes.MAX_SERIALIZATION_TOTAL
}

return (List(count) { args[0] })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@

public class HexDamageTypes {
public static final ResourceKey<DamageType> OVERCAST = ResourceKey.create(Registries.DAMAGE_TYPE, modLoc("overcast"));
public static final ResourceKey<DamageType> SHAME_ON_YOU = ResourceKey.create(Registries.DAMAGE_TYPE, modLoc("shame"));

public static void bootstrap(BootstapContext<DamageType> ctx) {
ctx.register(OVERCAST, new DamageType(
"hexcasting.overcast",
DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER,
0f
));

ctx.register(SHAME_ON_YOU, new DamageType(
"hexcasting.shame",
DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER,
0f
));
}
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ protected void addTags(@NotNull HolderLookup.Provider provider) {
DamageTypeTags.BYPASSES_EFFECTS,
DamageTypeTags.BYPASSES_SHIELD
);

add(HexDamageTypes.SHAME_ON_YOU,
DamageTypeTags.BYPASSES_ARMOR,
DamageTypeTags.BYPASSES_EFFECTS,
DamageTypeTags.BYPASSES_INVULNERABILITY,
DamageTypeTags.BYPASSES_SHIELD
);
}

@SafeVarargs
Expand Down
Loading

0 comments on commit 8cea4f1

Please sign in to comment.