Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Added

- Updated to Minecraft 1.21.1 ([#985](https://github.com/FallingColors/HexMod/pull/985)) @SuperKnux @slava110
- Added the Storage Locus, a spell circle component that lets a circle stop depending on its caster's inventory ([#1364](https://github.com/FallingColors/HexMod/pull/1364)) @Robotgiggle
- Added Simulate, which causes the next pattern drawn to be simulated (to check for mishaps) rather than executed ([#1194](https://github.com/FallingColors/HexMod/pull/1194)) @Robotgiggle
- Added Coalescing Distillation, which performs the null-coalescing operation ([#1196](https://github.com/FallingColors/HexMod/pull/1196)) @Robotgiggle
- Added the `hex_unbreakable` tag for blocks that should be immune to Break Block regardless of the configured mining tier ([#1186](https://github.com/FallingColors/HexMod/pull/1186)) @Robotgiggle @slava110
Expand All @@ -25,9 +26,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Iotas included via the above process are now popped from the original stack
- Entity iotas no longer become Null if the referenced entity ceases to exist or becomes unloaded ([#1299](https://github.com/FallingColors/HexMod/pull/1299)) @Robotgiggle
- Augur's Purification now returns false for nonexistent or unloaded entity iotas ([#1299](https://github.com/FallingColors/HexMod/pull/1299)) @Robotgiggle

### Changed

- The media cost of Impulse now scales linearly rather than quadratically ([#1145](https://github.com/FallingColors/HexMod/pull/1145)) @Robotgiggle
- Erase Item is now free for most items ([#1359](https://github.com/FallingColors/HexMod/pull/1359)) @beholderface

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"variants": {
"facing=down,open=false": {
"model": "hexcasting:block/chest_locus",
"x": 180
},
"facing=down,open=true": {
"model": "hexcasting:block/chest_locus_open",
"x": 180
},
"facing=east,open=false": {
"model": "hexcasting:block/chest_locus",
"x": 270,
"y": 270
},
"facing=east,open=true": {
"model": "hexcasting:block/chest_locus_open",
"x": 270,
"y": 270
},
"facing=north,open=false": {
"model": "hexcasting:block/chest_locus",
"x": 270,
"y": 180
},
"facing=north,open=true": {
"model": "hexcasting:block/chest_locus_open",
"x": 270,
"y": 180
},
"facing=south,open=false": {
"model": "hexcasting:block/chest_locus",
"x": 270
},
"facing=south,open=true": {
"model": "hexcasting:block/chest_locus_open",
"x": 270
},
"facing=up,open=false": {
"model": "hexcasting:block/chest_locus"
},
"facing=up,open=true": {
"model": "hexcasting:block/chest_locus_open"
},
"facing=west,open=false": {
"model": "hexcasting:block/chest_locus",
"x": 270,
"y": 90
},
"facing=west,open=true": {
"model": "hexcasting:block/chest_locus_open",
"x": 270,
"y": 90
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "hexcasting:block/chest_locus"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"enlightenment": {
"conditions": {
"health_used": {
"min": 0.8
},
"media_generated": {},
"mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion": {
"max": 1.0,
"min": 2.2250738585072014E-308
}
},
"trigger": "hexcasting:overcast"
},
"has_the_recipe": {
"conditions": {
"recipe": "hexcasting:locus/chest"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"enlightenment"
]
],
"rewards": {
"recipes": [
"hexcasting:locus/chest"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "hexcasting:locus/chest"
}
],
"rolls": 1.0
}
],
"random_sequence": "hexcasting:blocks/locus/chest"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "minecraft:crafting_shaped",
"category": "redstone",
"key": {
"C": {
"item": "minecraft:chest"
},
"E": {
"item": "hexcasting:edified_planks"
},
"S": {
"item": "hexcasting:slate"
}
},
"pattern": [
" E ",
"ECE",
" S "
],
"result": {
"count": 1,
"id": "hexcasting:locus/chest"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class CircleExecutionState {
TAG_REACHED_POSITIONS = "reached_positions",
TAG_CURRENT_POS = "current_pos",
TAG_ENTERED_FROM = "entered_from",
TAG_INVENTORY_POS = "inventory_pos",
TAG_IMAGE = "image",
TAG_CASTER = "caster",
TAG_PIGMENT = "pigment",
Expand All @@ -47,6 +48,7 @@ public class CircleExecutionState {
public final HashSet<BlockPos> reachedPositions;
public BlockPos currentPos;
public Direction enteredFrom;
public @Nullable BlockPos inventoryPos;
public CastingImage currentImage;
public @Nullable UUID caster;
public @Nullable FrozenPigment casterPigment;
Expand All @@ -60,13 +62,14 @@ public class CircleExecutionState {


protected CircleExecutionState(BlockPos impetusPos, Direction impetusDir, HashSet<BlockPos> reachedPositions,
BlockPos currentPos, Direction enteredFrom, CastingImage currentImage, @Nullable UUID caster,
BlockPos currentPos, Direction enteredFrom, BlockPos inventoryPos, CastingImage currentImage, @Nullable UUID caster,
@Nullable FrozenPigment casterPigment, Long reachedSlate, BlockPos greaterCorner, BlockPos lesserCorner) {
this.impetusPos = impetusPos;
this.impetusDir = impetusDir;
this.reachedPositions = reachedPositions;
this.currentPos = currentPos;
this.enteredFrom = enteredFrom;
this.inventoryPos = inventoryPos;
this.currentImage = currentImage;
this.caster = caster;
this.casterPigment = casterPigment;
Expand Down Expand Up @@ -170,7 +173,7 @@ protected CircleExecutionState(BlockPos impetusPos, Direction impetusDir, HashSe
return new Result.Ok<>(
new CircleExecutionState(impetus.getBlockPos(), impetus.getStartDirection(),
reachedPositions, impetus.getBlockPos().offset(impetus.getStartDirection().getNormal()),
impetus.getStartDirection(), new CastingImage(), casterUUID, colorizer, 0L,
impetus.getStartDirection(), null, new CastingImage(), casterUUID, colorizer, 0L,
positiveBlock, negativeBlock));
}

Expand All @@ -188,6 +191,8 @@ public CompoundTag save() {

out.put(TAG_CURRENT_POS, NbtUtils.writeBlockPos(this.currentPos));
out.putByte(TAG_ENTERED_FROM, (byte) this.enteredFrom.ordinal());
if (this.inventoryPos != null)
out.put(TAG_INVENTORY_POS, NbtUtils.writeBlockPos(this.inventoryPos));
out.put(TAG_IMAGE, CastingImage.getCODEC().encodeStart(NbtOps.INSTANCE, currentImage).getOrThrow());

if (this.caster != null)
Expand Down Expand Up @@ -217,6 +222,7 @@ public static CircleExecutionState load(CompoundTag nbt, ServerLevel world) {

var currentPos = NbtUtils.readBlockPos(nbt, TAG_CURRENT_POS).orElseThrow();
var enteredFrom = Direction.values()[nbt.getByte(TAG_ENTERED_FROM)];
var inventoryPos = NbtUtils.readBlockPos(nbt, TAG_INVENTORY_POS).orElse(null);
var image = CastingImage.getCODEC().parse(NbtOps.INSTANCE, nbt.getCompound(TAG_IMAGE)).getOrThrow();

var reachedSlate = nbt.getLong(TAG_REACHED_NUMBER);
Expand All @@ -232,7 +238,7 @@ public static CircleExecutionState load(CompoundTag nbt, ServerLevel world) {
pigment = FrozenPigment.CODEC.parse(NbtOps.INSTANCE, nbt.getCompound(TAG_PIGMENT)).getOrThrow();

return new CircleExecutionState(startPos, startDir, reachedPositions, currentPos,
enteredFrom, image, caster, pigment, reachedSlate, positivePos, negativePos);
enteredFrom, inventoryPos, image, caster, pigment, reachedSlate, positivePos, negativePos);
}

private static Optional<BlockPos> readBlockPos(int[] aint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import at.petrak.hexcasting.api.casting.mishaps.MishapDisallowedSpell;
import at.petrak.hexcasting.api.mod.HexConfig;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.common.blocks.circles.BlockEntityChestLocus;
import at.petrak.hexcasting.common.lib.HexAttributes;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -163,26 +164,52 @@ public InteractionHand getCastingHand() {
}

@Override
// TODO: Could do something like get items in inventories adjacent to the circle?
public List<ItemStack> getUsableStacks(StackDiscoveryMode mode) {
if (this.getCastingEntity() instanceof ServerPlayer caster)
var invPos = this.execState.inventoryPos;
if (invPos != null && world.getBlockEntity(invPos) instanceof BlockEntityChestLocus chestLocus) {
return switch (mode) {
// top row of items is the "hotbar" for use in filtering
case QUERY -> chestLocus.getItems().subList(0,9);
// reverse order so non-hotbar items are prioritized for extraction
case EXTRACTION -> chestLocus.getItems().reversed();
};
} else if (this.getCastingEntity() instanceof ServerPlayer caster) {
return getUsableStacksForPlayer(mode, null, caster);
}
return new ArrayList<>();
}

@Override
// TODO: Adjacent inv!
public List<HeldItemInfo> getPrimaryStacks() {
if (this.getCastingEntity() instanceof ServerPlayer caster)
var invPos = this.execState.inventoryPos;
if (invPos != null && world.getBlockEntity(invPos) instanceof BlockEntityChestLocus chestLocus) {
// slot 0 is treated as the "offhand"
return List.of(new HeldItemInfo(chestLocus.getItem(0), InteractionHand.OFF_HAND));
} else if (this.getCastingEntity() instanceof ServerPlayer caster) {
return getPrimaryStacksForPlayer(InteractionHand.OFF_HAND, caster);
}
return List.of();
}

@Override
// TODO: Adjacent inv!
public boolean replaceItem(Predicate<ItemStack> stackOk, ItemStack replaceWith, @Nullable InteractionHand hand) {
if (this.getCastingEntity() instanceof ServerPlayer caster)
var invPos = this.execState.inventoryPos;
if (invPos != null && world.getBlockEntity(invPos) instanceof BlockEntityChestLocus chestLocus) {
if (hand != null && stackOk.test(chestLocus.getItem(0))) {
// slot 0 is treated as the "offhand"
chestLocus.setItem(0, replaceWith);
return true;
} else {
for (int i = 26; i >= 0; i--) {
if (stackOk.test(chestLocus.getItem(i))) {
chestLocus.setItem(0, replaceWith);
return true;
}
}
}
} else if (this.getCastingEntity() instanceof ServerPlayer caster) {
return replaceItemForPlayer(stackOk, replaceWith, hand, caster);
}
return false;
}

Expand Down
Loading
Loading