-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocky Chroniclers #796
base: main
Are you sure you want to change the base?
Blocky Chroniclers #796
Changes from all commits
473aa7d
1595dc0
1c3e4db
0b282e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package at.petrak.hexcasting.api.casting.mishaps | ||
|
||
import com.mojang.datafixers.util.Either | ||
import net.minecraft.core.BlockPos | ||
import net.minecraft.world.entity.Entity | ||
import net.minecraft.world.item.ItemStack | ||
import net.minecraft.world.phys.Vec3 | ||
|
||
// a silly stupid wrapper for throwing arbitrary badness mishaps (the ones that have a .of(thing, stub) constructor. | ||
class MishapBad { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this should just be a function in ActionUtils or something. Or if it has to be its own class for some reason, it should at least be abstract. |
||
companion object { | ||
@JvmStatic | ||
fun of(thing: Any, stub: String): Mishap { | ||
return when(thing){ | ||
is Either<*, *> -> thing.map({l -> of(l, stub)}, {r -> of(r, stub)}) | ||
is Entity -> MishapBadEntity.of(thing, stub) | ||
is BlockPos -> MishapBadBlock.of(thing, stub) | ||
is Vec3 -> MishapBadLocation(thing, stub) | ||
is ItemStack -> MishapBadOffhandItem.of(thing, stub) | ||
else -> throw IllegalArgumentException() | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
package at.petrak.hexcasting.common.blocks.akashic; | ||
|
||
import at.petrak.hexcasting.api.addldata.ADIotaHolder.ADIotaHolderReadOnly; | ||
import at.petrak.hexcasting.api.block.HexBlockEntity; | ||
import at.petrak.hexcasting.api.casting.iota.Iota; | ||
import at.petrak.hexcasting.api.casting.iota.IotaType; | ||
import at.petrak.hexcasting.api.casting.iota.PatternIota; | ||
import at.petrak.hexcasting.api.casting.math.HexPattern; | ||
import at.petrak.hexcasting.client.render.HexPatternPoints; | ||
import at.petrak.hexcasting.common.lib.HexBlockEntities; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class BlockEntityAkashicBookshelf extends HexBlockEntity { | ||
public class BlockEntityAkashicBookshelf extends HexBlockEntity implements ADIotaHolderReadOnly { | ||
public static final String TAG_PATTERN = "pattern"; | ||
public static final String TAG_IOTA = "iota"; | ||
public static final String TAG_DUMMY = "dummy"; | ||
|
@@ -89,4 +92,20 @@ protected void loadModData(CompoundTag tag) { | |
this.iotaTag = null; | ||
} | ||
} | ||
|
||
@Override | ||
public CompoundTag readIotaTag(){ | ||
if(pattern == null){ | ||
return IotaType.serialize(emptyIota()); | ||
} | ||
return IotaType.serialize(new PatternIota(pattern)); | ||
} | ||
|
||
@Override | ||
public Iota readIota(ServerLevel world) { | ||
if(pattern == null){ | ||
return emptyIota(); | ||
} | ||
return new PatternIota(pattern); | ||
} | ||
Comment on lines
+96
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels weird for the logic here to be duplicated... not sure how to fix it though. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
package at.petrak.hexcasting.common.blocks.circles; | ||
|
||
import at.petrak.hexcasting.api.addldata.ADIotaHolder; | ||
import at.petrak.hexcasting.api.block.HexBlockEntity; | ||
import at.petrak.hexcasting.api.casting.iota.Iota; | ||
import at.petrak.hexcasting.api.casting.iota.IotaType; | ||
import at.petrak.hexcasting.api.casting.iota.NullIota; | ||
import at.petrak.hexcasting.api.casting.iota.PatternIota; | ||
import at.petrak.hexcasting.api.casting.math.HexPattern; | ||
import at.petrak.hexcasting.common.lib.HexBlockEntities; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.Tag; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class BlockEntitySlate extends HexBlockEntity { | ||
public class BlockEntitySlate extends HexBlockEntity implements ADIotaHolder { | ||
public static final String TAG_PATTERN = "pattern"; | ||
|
||
@Nullable | ||
|
@@ -42,4 +48,39 @@ protected void loadModData(CompoundTag tag) { | |
} | ||
} | ||
|
||
@Override | ||
public CompoundTag readIotaTag(){ | ||
if(pattern == null){ | ||
return IotaType.serialize(emptyIota()); | ||
} | ||
return IotaType.serialize(new PatternIota(pattern)); | ||
} | ||
|
||
@Override | ||
public Iota readIota(ServerLevel world) { | ||
if(pattern == null){ | ||
return emptyIota(); | ||
} | ||
return new PatternIota(pattern); | ||
} | ||
|
||
@Override | ||
public boolean writeIota(@Nullable Iota iota, boolean simulate){ | ||
if(!simulate){ | ||
if(iota instanceof PatternIota pIota){ | ||
this.pattern = pIota.getPattern(); | ||
sync(); | ||
} | ||
if(iota instanceof NullIota || iota == null){ | ||
this.pattern = null; | ||
sync(); | ||
} | ||
} | ||
return iota instanceof PatternIota || iota instanceof NullIota || iota == null; | ||
Comment on lines
+69
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels weirdly duplicated, but idk how to fix it ( |
||
} | ||
|
||
@Override | ||
public boolean writeable(){ | ||
return true; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should there also be a WriteOnly version?