block emtity
This commit is contained in:
parent
f6a07672f1
commit
bcf5a3fe3b
64 changed files with 494 additions and 359 deletions
|
@ -9,6 +9,7 @@ archivesBaseName = "${modID}-common-${minecraftVersion}"
|
|||
|
||||
minecraft {
|
||||
version(minecraftVersion)
|
||||
|
||||
runs {
|
||||
if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) {
|
||||
server(project.hasProperty('common_server_run_name') ? project.findProperty('common_server_run_name') : 'vanilla_server') {
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package at.petrak.hexcasting.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
// https://github.com/VazkiiMods/Botania/blob/1.18.x/Common/src/main/java/vazkii/botania/common/annotations/SoftImplement.java
|
||||
// yoinky sploinky
|
||||
|
||||
/**
|
||||
* A purely-documentative annotation.
|
||||
* This annotation is used by developers in xplat code. The annotated method is intended
|
||||
* to "soft implement" a certain method in a loader specific interface that cannot be
|
||||
* named in xplat code and thus cannot be checked with @Override.
|
||||
* In this context, "soft implement" means to implement the method by matching the signature
|
||||
* with the intended interface method.
|
||||
* Examples of interfaces that we would use this for is IForgeItem or FabricItem.
|
||||
* <p>
|
||||
* The intent is that we audit such sites every major Minecraft version or so, to ensure
|
||||
* that they still properly override the intended target.
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SoftImplement {
|
||||
/**
|
||||
* What interface we're soft implementing
|
||||
*/
|
||||
String value();
|
||||
}
|
|
@ -5,12 +5,12 @@ import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
|||
import at.petrak.hexcasting.api.mod.HexApiItems;
|
||||
import at.petrak.hexcasting.api.mod.HexApiSounds;
|
||||
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||
import at.petrak.hexcasting.api.player.HexPlayerDataHelper;
|
||||
import at.petrak.hexcasting.api.spell.ParticleSpray;
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext;
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
||||
import at.petrak.hexcasting.api.spell.casting.SpellCircleContext;
|
||||
import at.petrak.hexcasting.api.utils.ManaHelper;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -28,10 +28,10 @@ import net.minecraft.sounds.SoundSource;
|
|||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.WorldlyContainer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -39,18 +39,12 @@ import net.minecraft.world.phys.AABB;
|
|||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implements ICapabilityProvider {
|
||||
public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implements WorldlyContainer {
|
||||
public static final String
|
||||
TAG_ACTIVATOR = "activator",
|
||||
TAG_COLORIZER = "colorizer",
|
||||
|
@ -74,11 +68,9 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
|
|||
private Component lastMishap = null;
|
||||
|
||||
private int mana = 0;
|
||||
private final LazyOptional<IItemHandler> inventoryHandlerLazy;
|
||||
|
||||
public BlockEntityAbstractImpetus(BlockEntityType<?> pType, BlockPos pWorldPosition, BlockState pBlockState) {
|
||||
super(pType, pWorldPosition, pBlockState);
|
||||
inventoryHandlerLazy = LazyOptional.of(() -> ITEM_HANDLER);
|
||||
}
|
||||
|
||||
abstract public boolean activatorAlwaysInRange();
|
||||
|
@ -110,7 +102,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
|
|||
this.nextBlock = this.getBlockPos();
|
||||
this.trackedBlocks = new ArrayList<>();
|
||||
this.knownBlocks = new HashSet<>();
|
||||
this.colorizer = HexPlayerDataHelper.getColorizer(activator);
|
||||
this.colorizer = IXplatAbstractions.INSTANCE.getColorizer(activator);
|
||||
|
||||
this.level.setBlockAndUpdate(this.getBlockPos(),
|
||||
this.getBlockState().setValue(BlockAbstractImpetus.ENERGIZED, true));
|
||||
|
@ -123,7 +115,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
|
|||
LocalPlayer observer, ClientLevel world,
|
||||
Direction hitFace, InteractionHand lensHand) {
|
||||
if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) {
|
||||
var dustCount = (float) beai.getMana() / (float) HexConfig.dustManaAmount.get();
|
||||
var dustCount = (float) beai.getMana() / (float) HexConfig.common().dustManaAmount();
|
||||
var dustCmp = new TranslatableComponent("hexcasting.tooltip.lens.impetus.mana",
|
||||
String.format("%.2f", dustCount));
|
||||
lines.add(new Pair<>(new ItemStack(HexApiItems.AMETHYST_DUST), dustCmp));
|
||||
|
@ -135,21 +127,6 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
|
|||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
|
||||
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return inventoryHandlerLazy.cast();
|
||||
}
|
||||
return super.getCapability(cap, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateCaps() {
|
||||
super.invalidateCaps();
|
||||
inventoryHandlerLazy.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveModData(CompoundTag tag) {
|
||||
if (this.activator != null && this.colorizer != null && this.nextBlock != null && this.trackedBlocks != null) {
|
||||
|
@ -385,7 +362,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
|
|||
}
|
||||
}
|
||||
|
||||
if (this.trackedBlocks.size() > HexConfig.Server.maxSpellCircleLength.get()) {
|
||||
if (this.trackedBlocks.size() > HexConfig.server().maxSpellCircleLength()) {
|
||||
return this.trackedBlocks.get(this.trackedBlocks.size() - 1);
|
||||
}
|
||||
|
||||
|
@ -501,47 +478,78 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
|
|||
private static final int[] BAD_TIME = {0, 0, 12, 7, 6, 5, 3, 0, 3, 5};
|
||||
private static final int[] SUSSY_BAKA = {5, 8, 10, 11, 10, 8, 5, 3, 7, 5};
|
||||
|
||||
protected IItemHandler ITEM_HANDLER = new IItemHandler() {
|
||||
@Override
|
||||
public int getSlots() {
|
||||
return 1;
|
||||
}
|
||||
private static final int[] SLOTS = {0};
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public int[] getSlotsForFace(Direction var1) {
|
||||
return SLOTS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {
|
||||
var manamount = ManaHelper.extractMana(stack, -1, true, simulate);
|
||||
if (manamount > 0) {
|
||||
if (!simulate) {
|
||||
BlockEntityAbstractImpetus.this.mana += manamount;
|
||||
BlockEntityAbstractImpetus.this.setChanged();
|
||||
level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), Block.UPDATE_CLIENTS);
|
||||
}
|
||||
return ItemStack.EMPTY.copy();
|
||||
}
|
||||
return stack.copy();
|
||||
}
|
||||
@Override
|
||||
public boolean canPlaceItemThroughFace(int index, ItemStack stack, @Nullable Direction dir) {
|
||||
return this.canPlaceItem(index, stack);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||
return ItemStack.EMPTY.copy();
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeItemThroughFace(int var1, ItemStack var2, Direction var3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return 64;
|
||||
}
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @NotNull ItemStack stack) {
|
||||
return ManaHelper.extractMana(stack, -1, false, true) > 0;
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int index) {
|
||||
return ItemStack.EMPTY.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeItem(int index, int count) {
|
||||
return ItemStack.EMPTY.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeItemNoUpdate(int index) {
|
||||
return ItemStack.EMPTY.copy();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int index, ItemStack stack) {
|
||||
var manamount = ManaHelper.extractMana(stack, -1, true, false);
|
||||
if (manamount > 0) {
|
||||
this.mana += manamount;
|
||||
this.sync();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChanged() {
|
||||
this.sync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceItem(int index, ItemStack stack) {
|
||||
var manamount = ManaHelper.extractMana(stack, -1, true, true);
|
||||
return manamount > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearContent() {
|
||||
this.mana = 0;
|
||||
this.stopCasting();
|
||||
this.sync();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.client;
|
|||
|
||||
import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry;
|
||||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.api.player.HexPlayerDataHelper;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
|
@ -47,7 +47,7 @@ public class HexAdditionalRenderers {
|
|||
}
|
||||
|
||||
private static void renderSentinel(Sentinel sentinel, LocalPlayer owner,
|
||||
PoseStack ps, float partialTicks) {
|
||||
PoseStack ps, float partialTicks) {
|
||||
ps.pushPose();
|
||||
|
||||
// zero vector is the player
|
||||
|
@ -85,7 +85,7 @@ public class HexAdditionalRenderers {
|
|||
var colorizer = HexPlayerDataHelper.getColorizer(owner);
|
||||
BiConsumer<float[], float[]> v = (l, r) -> {
|
||||
int lcolor = colorizer.getColor(time, new Vec3(l[0], l[1], l[2])),
|
||||
rcolor = colorizer.getColor(time, new Vec3(r[0], r[1], r[2]));
|
||||
rcolor = colorizer.getColor(time, new Vec3(r[0], r[1], r[2]));
|
||||
var normal = new Vector3f(r[0] - l[0], r[1] - l[1], r[2] - l[2]);
|
||||
normal.normalize();
|
||||
buf.vertex(neo, l[0], l[1], l[2])
|
||||
|
@ -200,8 +200,9 @@ public class HexAdditionalRenderers {
|
|||
mc.font.drawShadow(ps, actualLine, tx, ty, 0xffffffff);
|
||||
ps.translate(0, 9, 0);
|
||||
}
|
||||
if (textLines.isEmpty())
|
||||
if (textLines.isEmpty()) {
|
||||
ps.translate(0, 9, 0);
|
||||
}
|
||||
|
||||
ps.translate(0, 6, 0);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package at.petrak.hexcasting.client;
|
||||
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.client.gui.PatternTooltipGreeble;
|
||||
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemScroll;
|
||||
import at.petrak.hexcasting.common.items.ItemSlate;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
|
|
@ -12,15 +12,16 @@ import at.petrak.hexcasting.client.be.BlockEntityAkashicBookshelfRenderer;
|
|||
import at.petrak.hexcasting.client.be.BlockEntitySlateRenderer;
|
||||
import at.petrak.hexcasting.client.entity.WallScrollRenderer;
|
||||
import at.petrak.hexcasting.client.particles.ConjureParticle;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockEntities;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf;
|
||||
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicRecord;
|
||||
import at.petrak.hexcasting.common.entities.HexEntities;
|
||||
import at.petrak.hexcasting.common.items.*;
|
||||
import at.petrak.hexcasting.common.items.magic.ItemManaBattery;
|
||||
import at.petrak.hexcasting.common.items.magic.ItemPackagedHex;
|
||||
import at.petrak.hexcasting.common.particles.HexParticles;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexParticles;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.client;
|
||||
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.network.HexMessages;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexMessages;
|
||||
import at.petrak.hexcasting.common.network.MsgShiftScrollSyn;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
|
|
|
@ -20,82 +20,82 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public class BlockEntitySlateRenderer implements BlockEntityRenderer<BlockEntitySlate> {
|
||||
|
||||
public BlockEntitySlateRenderer(BlockEntityRendererProvider.Context ctx) {
|
||||
// NO-OP
|
||||
}
|
||||
public BlockEntitySlateRenderer(BlockEntityRendererProvider.Context ctx) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BlockEntitySlate tile, float pPartialTick, PoseStack ps,
|
||||
MultiBufferSource buffer, int light, int overlay) {
|
||||
if (tile.pattern == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void render(BlockEntitySlate tile, float pPartialTick, PoseStack ps,
|
||||
MultiBufferSource buffer, int light, int overlay) {
|
||||
if (tile.pattern == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bs = tile.getBlockState();
|
||||
var bs = tile.getBlockState();
|
||||
|
||||
var oldShader = RenderSystem.getShader();
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||
RenderSystem.enableDepthTest();
|
||||
var oldShader = RenderSystem.getShader();
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||
RenderSystem.enableDepthTest();
|
||||
|
||||
ps.pushPose();
|
||||
ps.pushPose();
|
||||
|
||||
ps.translate(0.5, 0.5, 0.5);
|
||||
var attchFace = bs.getValue(BlockSlate.ATTACH_FACE);
|
||||
if (attchFace == AttachFace.WALL) {
|
||||
var quarters = (-bs.getValue(BlockSlate.FACING).get2DDataValue()) % 4;
|
||||
ps.mulPose(new Quaternion(Vector3f.YP, Mth.HALF_PI * quarters, false));
|
||||
ps.mulPose(new Quaternion(Vector3f.ZP, Mth.PI, false));
|
||||
} else {
|
||||
var neg = attchFace == AttachFace.FLOOR ? -1 : 1;
|
||||
ps.mulPose(new Quaternion(
|
||||
Vector3f.XP,
|
||||
neg * Mth.HALF_PI,
|
||||
false));
|
||||
var quarters = (bs.getValue(BlockSlate.FACING).get2DDataValue() + 2) % 4;
|
||||
ps.mulPose(new Quaternion(Vector3f.ZP, neg * Mth.HALF_PI * quarters, false));
|
||||
}
|
||||
ps.translate(0.5, 0.5, 0.5);
|
||||
var attchFace = bs.getValue(BlockSlate.ATTACH_FACE);
|
||||
if (attchFace == AttachFace.WALL) {
|
||||
var quarters = (-bs.getValue(BlockSlate.FACING).get2DDataValue()) % 4;
|
||||
ps.mulPose(new Quaternion(Vector3f.YP, Mth.HALF_PI * quarters, false));
|
||||
ps.mulPose(new Quaternion(Vector3f.ZP, Mth.PI, false));
|
||||
} else {
|
||||
var neg = attchFace == AttachFace.FLOOR ? -1 : 1;
|
||||
ps.mulPose(new Quaternion(
|
||||
Vector3f.XP,
|
||||
neg * Mth.HALF_PI,
|
||||
false));
|
||||
var quarters = (bs.getValue(BlockSlate.FACING).get2DDataValue() + 2) % 4;
|
||||
ps.mulPose(new Quaternion(Vector3f.ZP, neg * Mth.HALF_PI * quarters, false));
|
||||
}
|
||||
|
||||
// and now Z is out?
|
||||
ps.translate(0, 0, -0.5);
|
||||
ps.scale(1 / 16f, 1 / 16f, 1 / 16f);
|
||||
ps.translate(0, 0, 1.01);
|
||||
// and now Z is out?
|
||||
ps.translate(0, 0, -0.5);
|
||||
ps.scale(1 / 16f, 1 / 16f, 1 / 16f);
|
||||
ps.translate(0, 0, 1.01);
|
||||
|
||||
// yoink code from the pattern greeble
|
||||
// Do two passes: one with a random size to find a good COM and one with the real calculation
|
||||
var com1 = tile.pattern.getCenter(1);
|
||||
var lines1 = tile.pattern.toLines(1, Vec2.ZERO);
|
||||
// yoink code from the pattern greeble
|
||||
// Do two passes: one with a random size to find a good COM and one with the real calculation
|
||||
var com1 = tile.pattern.getCenter(1);
|
||||
var lines1 = tile.pattern.toLines(1, Vec2.ZERO);
|
||||
|
||||
var maxDx = -1f;
|
||||
var maxDy = -1f;
|
||||
for (var dot : lines1) {
|
||||
var dx = Mth.abs(dot.x - com1.x);
|
||||
if (dx > maxDx) {
|
||||
maxDx = dx;
|
||||
}
|
||||
var dy = Mth.abs(dot.y - com1.y);
|
||||
if (dy > maxDy) {
|
||||
maxDy = dy;
|
||||
}
|
||||
}
|
||||
var scale = Math.min(3.8f, Math.min(16 / 2.5f / maxDx, 16 / 2.5f / maxDy));
|
||||
var maxDx = -1f;
|
||||
var maxDy = -1f;
|
||||
for (var dot : lines1) {
|
||||
var dx = Mth.abs(dot.x - com1.x);
|
||||
if (dx > maxDx) {
|
||||
maxDx = dx;
|
||||
}
|
||||
var dy = Mth.abs(dot.y - com1.y);
|
||||
if (dy > maxDy) {
|
||||
maxDy = dy;
|
||||
}
|
||||
}
|
||||
var scale = Math.min(3.8f, Math.min(16 / 2.5f / maxDx, 16 / 2.5f / maxDy));
|
||||
|
||||
var com2 = tile.pattern.getCenter(scale);
|
||||
var lines2 = tile.pattern.toLines(scale, com2.negated());
|
||||
// For some reason it is mirrored left to right and i can't seem to posestack-fu it into shape
|
||||
for (int i = 0; i < lines2.size(); i++) {
|
||||
var v = lines2.get(i);
|
||||
lines2.set(i, new Vec2(-v.x, v.y));
|
||||
}
|
||||
var com2 = tile.pattern.getCenter(scale);
|
||||
var lines2 = tile.pattern.toLines(scale, com2.negated());
|
||||
// For some reason it is mirrored left to right and i can't seem to posestack-fu it into shape
|
||||
for (int i = 0; i < lines2.size(); i++) {
|
||||
var v = lines2.get(i);
|
||||
lines2.set(i, new Vec2(-v.x, v.y));
|
||||
}
|
||||
|
||||
var isLit = bs.getValue(BlockSlate.ENERGIZED);
|
||||
var zappy = RenderLib.makeZappy(lines2, 10f, isLit ? 2.5f : 0.5f, isLit ? 0.1f : 0f);
|
||||
var isLit = bs.getValue(BlockSlate.ENERGIZED);
|
||||
var zappy = RenderLib.makeZappy(lines2, 10f, isLit ? 2.5f : 0.5f, isLit ? 0.1f : 0f);
|
||||
|
||||
int outer = isLit ? 0xff_64c8ff : 0xff_d2c8c8;
|
||||
int inner = isLit ? RenderLib.screenCol(outer) : 0xc8_322b33;
|
||||
RenderLib.drawLineSeq(ps.last().pose(), zappy, 1f, 0f, outer, outer);
|
||||
RenderLib.drawLineSeq(ps.last().pose(), zappy, 0.4f, 0.01f, inner, inner);
|
||||
int outer = isLit ? 0xff_64c8ff : 0xff_d2c8c8;
|
||||
int inner = isLit ? RenderLib.screenCol(outer) : 0xc8_322b33;
|
||||
RenderLib.drawLineSeq(ps.last().pose(), zappy, 1f, 0f, outer, outer);
|
||||
RenderLib.drawLineSeq(ps.last().pose(), zappy, 0.4f, 0.01f, inner, inner);
|
||||
|
||||
ps.popPose();
|
||||
RenderSystem.setShader(() -> oldShader);
|
||||
}
|
||||
ps.popPose();
|
||||
RenderSystem.setShader(() -> oldShader);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import at.petrak.hexcasting.client.sound.GridSoundInstance
|
|||
import at.petrak.hexcasting.api.spell.casting.ControllerInfo
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternValidity
|
||||
import at.petrak.hexcasting.common.items.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
import at.petrak.hexcasting.common.items.ItemSpellbook
|
||||
import at.petrak.hexcasting.common.lib.HexSounds
|
||||
import at.petrak.hexcasting.common.network.HexMessages
|
||||
import at.petrak.hexcasting.common.lib.HexMessages
|
||||
import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn
|
||||
import at.petrak.hexcasting.common.network.MsgShiftScrollSyn
|
||||
import at.petrak.hexcasting.api.spell.math.HexAngle
|
||||
|
@ -33,9 +33,11 @@ import net.minecraft.world.phys.Vec2
|
|||
import kotlin.math.atan2
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class GuiSpellcasting(private val handOpenedWith: InteractionHand,
|
||||
private var patterns: MutableList<ResolvedPattern>,
|
||||
private var stackDescs: List<Component>) : Screen(TextComponent("")) {
|
||||
class GuiSpellcasting(
|
||||
private val handOpenedWith: InteractionHand,
|
||||
private var patterns: MutableList<ResolvedPattern>,
|
||||
private var stackDescs: List<Component>
|
||||
) : Screen(TextComponent("")) {
|
||||
private var drawState: PatternDrawState = PatternDrawState.BetweenPatterns
|
||||
private val usedSpots: MutableSet<HexCoord> = HashSet()
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityConjured;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
|
@ -56,7 +57,8 @@ public class BlockConjured extends Block implements EntityBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos, Player player) {
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos,
|
||||
Player player) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
@ -95,7 +97,8 @@ public class BlockConjured extends Block implements EntityBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NotNull VoxelShape getVisualShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
|
||||
public @NotNull VoxelShape getVisualShape(BlockState pState, BlockGetter pLevel, BlockPos pPos,
|
||||
CollisionContext pContext) {
|
||||
return Shapes.empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf;
|
||||
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicRecord;
|
||||
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
|
||||
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockEntityLookingImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockEntityRightClickImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockEntityStoredPlayerImpetus;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class HexBlockEntities {
|
||||
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(
|
||||
ForgeRegistries.BLOCK_ENTITIES, HexMod.MOD_ID);
|
||||
|
||||
public static final RegistryObject<BlockEntityType<BlockEntityConjured>> CONJURED_TILE = BLOCK_ENTITIES.register(
|
||||
"conjured_tile",
|
||||
() -> BlockEntityType.Builder.of(BlockEntityConjured::new, HexBlocks.CONJURED_LIGHT.get(), HexBlocks.CONJURED_BLOCK.get()).build(null));
|
||||
|
||||
public static final RegistryObject<BlockEntityType<BlockEntityAkashicBookshelf>> AKASHIC_BOOKSHELF_TILE = BLOCK_ENTITIES.register(
|
||||
"akashic_bookshelf_tile",
|
||||
() -> BlockEntityType.Builder.of(BlockEntityAkashicBookshelf::new, HexBlocks.AKASHIC_BOOKSHELF.get())
|
||||
.build(null));
|
||||
public static final RegistryObject<BlockEntityType<BlockEntityAkashicRecord>> AKASHIC_RECORD_TILE = BLOCK_ENTITIES.register(
|
||||
"akashic_record_tile",
|
||||
() -> BlockEntityType.Builder.of(BlockEntityAkashicRecord::new, HexBlocks.AKASHIC_RECORD.get()).build(null));
|
||||
|
||||
public static final RegistryObject<BlockEntityType<BlockEntityStoredPlayerImpetus>> IMPETUS_STOREDPLAYER_TILE =
|
||||
BLOCK_ENTITIES.register("impetus_storedplayer_tile",
|
||||
() -> BlockEntityType.Builder.of(BlockEntityStoredPlayerImpetus::new, HexBlocks.IMPETUS_STOREDPLAYER.get())
|
||||
.build(null));
|
||||
public static final RegistryObject<BlockEntityType<BlockEntityLookingImpetus>> IMPETUS_LOOK_TILE =
|
||||
BLOCK_ENTITIES.register("impetus_look_tile",
|
||||
() -> BlockEntityType.Builder.of(BlockEntityLookingImpetus::new, HexBlocks.IMPETUS_LOOK.get()).build(null));
|
||||
public static final RegistryObject<BlockEntityType<BlockEntityRightClickImpetus>> IMPETUS_RIGHTCLICK_TILE =
|
||||
BLOCK_ENTITIES.register("impetus_rightclick_tile",
|
||||
() -> BlockEntityType.Builder.of(BlockEntityRightClickImpetus::new, HexBlocks.IMPETUS_RIGHTCLICK.get())
|
||||
.build(null));
|
||||
|
||||
public static final RegistryObject<BlockEntityType<BlockEntitySlate>> SLATE_TILE = BLOCK_ENTITIES.register(
|
||||
"slate_tile",
|
||||
() -> BlockEntityType.Builder.of(BlockEntitySlate::new, HexBlocks.SLATE.get()).build(null));
|
||||
}
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.blocks.akashic;
|
|||
|
||||
import at.petrak.hexcasting.api.spell.DatumType;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import at.petrak.hexcasting.common.items.ItemScroll;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -39,7 +39,8 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable BlockPos getRecordPosition(BlockPos herePos, BlockState state, Level world) {
|
||||
public @Nullable
|
||||
BlockPos getRecordPosition(BlockPos herePos, BlockState state, Level world) {
|
||||
// time saving measure?
|
||||
if (world.getBlockEntity(herePos) instanceof BlockEntityAkashicBookshelf tile &&
|
||||
tile.getRecordPos() != null && world.getBlockEntity(
|
||||
|
@ -86,17 +87,20 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En
|
|||
var recordPos = BlockAkashicFloodfiller.floodFillFor(pos, world,
|
||||
(here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD.get()));
|
||||
if (pOldState.getBlock() != pState.getBlock()) {
|
||||
tile.setNewData(recordPos, recordPos == null ? null : tile.getPattern(), recordPos == null ? DatumType.EMPTY : pState.getValue(DATUM_TYPE));
|
||||
tile.setNewData(recordPos, recordPos == null ? null : tile.getPattern(),
|
||||
recordPos == null ? DatumType.EMPTY : pState.getValue(DATUM_TYPE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState pState, Level world, BlockPos pos, Block pBlock, BlockPos pFromPos, boolean pIsMoving) {
|
||||
public void neighborChanged(BlockState pState, Level world, BlockPos pos, Block pBlock, BlockPos pFromPos,
|
||||
boolean pIsMoving) {
|
||||
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) {
|
||||
var recordPos = BlockAkashicFloodfiller.floodFillFor(pos, world,
|
||||
(here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD.get()));
|
||||
tile.setNewData(recordPos, recordPos == null ? null : tile.getPattern(), recordPos == null ? DatumType.EMPTY : pState.getValue(DATUM_TYPE));
|
||||
(here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD.get()));
|
||||
tile.setNewData(recordPos, recordPos == null ? null : tile.getPattern(),
|
||||
recordPos == null ? DatumType.EMPTY : pState.getValue(DATUM_TYPE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.common.blocks.akashic;
|
||||
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -17,7 +17,8 @@ public class BlockAkashicFloodfiller extends Block {
|
|||
super(p_49795_);
|
||||
}
|
||||
|
||||
public @Nullable BlockPos getRecordPosition(BlockPos here, BlockState state, Level world) {
|
||||
public @Nullable
|
||||
BlockPos getRecordPosition(BlockPos here, BlockState state, Level world) {
|
||||
return floodFillFor(here, world,
|
||||
(pos, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD.get()));
|
||||
}
|
||||
|
@ -37,7 +38,8 @@ public class BlockAkashicFloodfiller extends Block {
|
|||
}
|
||||
|
||||
|
||||
public static @Nullable BlockPos floodFillFor(BlockPos start, Level world,
|
||||
public static @Nullable
|
||||
BlockPos floodFillFor(BlockPos start, Level world,
|
||||
TriPredicate<BlockPos, BlockState, Level> isValid, TriPredicate<BlockPos, BlockState, Level> isTarget) {
|
||||
var seenBlocks = new HashSet<BlockPos>();
|
||||
var todo = new ArrayDeque<BlockPos>();
|
||||
|
@ -62,7 +64,8 @@ public class BlockAkashicFloodfiller extends Block {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable BlockPos floodFillFor(BlockPos start, Level world,
|
||||
public static @Nullable
|
||||
BlockPos floodFillFor(BlockPos start, Level world,
|
||||
TriPredicate<BlockPos, BlockState, Level> isTarget) {
|
||||
return floodFillFor(start, world, BlockAkashicFloodfiller::canItBeFloodedThrough, isTarget);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package at.petrak.hexcasting.common.blocks.akashic;
|
||||
|
||||
import at.petrak.hexcasting.api.block.HexBlockEntity;
|
||||
import at.petrak.hexcasting.api.spell.DatumType;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockEntities;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.paucal.api.PaucalBlockEntity;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
|
@ -11,7 +11,7 @@ import net.minecraft.nbt.Tag;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BlockEntityAkashicBookshelf extends PaucalBlockEntity {
|
||||
public class BlockEntityAkashicBookshelf extends HexBlockEntity {
|
||||
public static final String TAG_RECORD_POS = "record_pos";
|
||||
public static final String TAG_PATTERN = "pattern";
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class BlockEntityAkashicBookshelf extends PaucalBlockEntity {
|
|||
private HexPattern pattern = null;
|
||||
|
||||
public BlockEntityAkashicBookshelf(BlockPos pWorldPosition, BlockState pBlockState) {
|
||||
super(HexBlockEntities.AKASHIC_BOOKSHELF_TILE.get(), pWorldPosition, pBlockState);
|
||||
super(HexBlockEntities.AKASHIC_BOOKSHELF_TILE, pWorldPosition, pBlockState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -53,7 +53,8 @@ public class BlockEntityAkashicBookshelf extends PaucalBlockEntity {
|
|||
|
||||
@Override
|
||||
protected void saveModData(CompoundTag compoundTag) {
|
||||
compoundTag.put(TAG_RECORD_POS, this.recordPos == null ? new CompoundTag() : NbtUtils.writeBlockPos(this.recordPos));
|
||||
compoundTag.put(TAG_RECORD_POS,
|
||||
this.recordPos == null ? new CompoundTag() : NbtUtils.writeBlockPos(this.recordPos));
|
||||
compoundTag.put(TAG_PATTERN, this.pattern == null ? new CompoundTag() : this.pattern.serializeToNBT());
|
||||
}
|
||||
|
||||
|
@ -63,8 +64,8 @@ public class BlockEntityAkashicBookshelf extends PaucalBlockEntity {
|
|||
CompoundTag pattern = compoundTag.getCompound(TAG_PATTERN);
|
||||
|
||||
if (recordPos.contains("X", Tag.TAG_ANY_NUMERIC) &&
|
||||
recordPos.contains("Y", Tag.TAG_ANY_NUMERIC) &&
|
||||
recordPos.contains("Z", Tag.TAG_ANY_NUMERIC)) {
|
||||
recordPos.contains("Y", Tag.TAG_ANY_NUMERIC) &&
|
||||
recordPos.contains("Z", Tag.TAG_ANY_NUMERIC)) {
|
||||
this.recordPos = NbtUtils.readBlockPos(recordPos);
|
||||
} else {
|
||||
this.recordPos = null;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package at.petrak.hexcasting.common.blocks.akashic;
|
||||
|
||||
import at.petrak.hexcasting.api.block.HexBlockEntity;
|
||||
import at.petrak.hexcasting.api.spell.DatumType;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockEntities;
|
||||
import at.petrak.hexcasting.api.spell.math.HexDir;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.paucal.api.PaucalBlockEntity;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -19,7 +19,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
public class BlockEntityAkashicRecord extends PaucalBlockEntity {
|
||||
public class BlockEntityAkashicRecord extends HexBlockEntity {
|
||||
public static final String TAG_LOOKUP = "lookup",
|
||||
TAG_POS = "pos",
|
||||
TAG_DATUM = "datum",
|
||||
|
@ -44,7 +44,8 @@ public class BlockEntityAkashicRecord extends PaucalBlockEntity {
|
|||
* <p>
|
||||
* Will never clobber anything.
|
||||
*/
|
||||
public @Nullable BlockPos addNewDatum(HexPattern key, SpellDatum<?> datum) {
|
||||
public @Nullable
|
||||
BlockPos addNewDatum(HexPattern key, SpellDatum<?> datum) {
|
||||
String entryKey = getKey(key);
|
||||
if (this.entries.containsKey(entryKey)) {
|
||||
return null; // would clobber
|
||||
|
@ -68,12 +69,14 @@ public class BlockEntityAkashicRecord extends PaucalBlockEntity {
|
|||
|
||||
private String getKey(HexPattern key) {
|
||||
String angles = key.anglesSignature();
|
||||
if (angles.isEmpty())
|
||||
if (angles.isEmpty()) {
|
||||
return "empty"; // contains non-angle characters, so can't occur any way other than this
|
||||
}
|
||||
return angles;
|
||||
}
|
||||
|
||||
public @Nullable SpellDatum<?> lookupPattern(HexPattern key, ServerLevel slevel) {
|
||||
public @Nullable
|
||||
SpellDatum<?> lookupPattern(HexPattern key, ServerLevel slevel) {
|
||||
var entry = this.entries.get(getKey(key));
|
||||
if (entry == null) {
|
||||
return null;
|
||||
|
@ -114,9 +117,10 @@ public class BlockEntityAkashicRecord extends PaucalBlockEntity {
|
|||
if (BlockAkashicFloodfiller.canItBeFloodedThrough(neighbor, bs, this.level)) {
|
||||
todo.add(neighbor);
|
||||
if (this.level.getBlockEntity(neighbor) instanceof BlockEntityAkashicBookshelf &&
|
||||
bs.hasProperty(BlockAkashicBookshelf.DATUM_TYPE) &&
|
||||
bs.getValue(BlockAkashicBookshelf.DATUM_TYPE) != DatumType.EMPTY)
|
||||
bs.hasProperty(BlockAkashicBookshelf.DATUM_TYPE) &&
|
||||
bs.getValue(BlockAkashicBookshelf.DATUM_TYPE) != DatumType.EMPTY) {
|
||||
validPoses.add(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package at.petrak.hexcasting.common.blocks.circles;
|
||||
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockEntities;
|
||||
import at.petrak.hexcasting.api.block.HexBlockEntity;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.paucal.api.PaucalBlockEntity;
|
||||
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.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BlockEntitySlate extends PaucalBlockEntity {
|
||||
public class BlockEntitySlate extends HexBlockEntity {
|
||||
public static final String TAG_PATTERN = "pattern";
|
||||
|
||||
@Nullable
|
||||
public HexPattern pattern;
|
||||
|
||||
public BlockEntitySlate(BlockPos pos, BlockState state) {
|
||||
super(HexBlockEntities.SLATE_TILE.get(), pos, state);
|
||||
super(HexBlockEntities.SLATE_TILE, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,12 +32,14 @@ public class BlockEntitySlate extends PaucalBlockEntity {
|
|||
protected void loadModData(CompoundTag tag) {
|
||||
if (tag.contains(TAG_PATTERN, Tag.TAG_COMPOUND)) {
|
||||
CompoundTag patternTag = tag.getCompound(TAG_PATTERN);
|
||||
if (HexPattern.IsHexPattern(patternTag))
|
||||
if (HexPattern.IsHexPattern(patternTag)) {
|
||||
this.pattern = HexPattern.DeserializeFromNBT(patternTag);
|
||||
else
|
||||
} else {
|
||||
this.pattern = null;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
this.pattern = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.blocks.circles;
|
|||
import at.petrak.hexcasting.api.block.circle.BlockCircleComponent;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
|
@ -85,7 +85,8 @@ public class BlockSlate extends BlockCircleComponent implements EntityBlock, Sim
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable HexPattern getPattern(BlockPos pos, BlockState bs, Level world) {
|
||||
public @Nullable
|
||||
HexPattern getPattern(BlockPos pos, BlockState bs, Level world) {
|
||||
if (world.getBlockEntity(pos) instanceof BlockEntitySlate tile) {
|
||||
return tile.pattern;
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package at.petrak.hexcasting.common.blocks.circles.impetuses;
|
||||
|
||||
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockEntities;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityLookingImpetus;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
@ -27,7 +28,7 @@ public class BlockLookingImpetus extends BlockAbstractImpetus {
|
|||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level pLevel, BlockState pState,
|
||||
BlockEntityType<T> type) {
|
||||
if (!pLevel.isClientSide) {
|
||||
return createTickerHelper(type, HexBlockEntities.IMPETUS_LOOK_TILE.get(),
|
||||
return createTickerHelper(type, HexBlockEntities.IMPETUS_LOOK_TILE,
|
||||
BlockEntityLookingImpetus::serverTick);
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.common.blocks.circles.impetuses;
|
||||
|
||||
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityRightClickImpetus;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
|
|
|
@ -3,6 +3,7 @@ package at.petrak.hexcasting.common.blocks.circles.impetuses;
|
|||
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus;
|
||||
import at.petrak.hexcasting.api.cap.HexCapabilities;
|
||||
import at.petrak.hexcasting.api.spell.DatumType;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityStoredPlayerImpetus;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
package at.petrak.hexcasting.common.blocks.entity;
|
||||
|
||||
import at.petrak.hexcasting.api.block.HexBlockEntity;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjured;
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjuredLight;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
import at.petrak.hexcasting.common.particles.ConjureParticleOptions;
|
||||
import at.petrak.paucal.api.PaucalBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -11,14 +14,14 @@ import net.minecraft.world.phys.Vec3;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockEntityConjured extends PaucalBlockEntity {
|
||||
public class BlockEntityConjured extends HexBlockEntity {
|
||||
private static final Random RANDOM = new Random();
|
||||
private FrozenColorizer colorizer = FrozenColorizer.DEFAULT.get();
|
||||
|
||||
public static final String TAG_COLORIZER = "tag_colorizer";
|
||||
|
||||
public BlockEntityConjured(BlockPos pos, BlockState state) {
|
||||
super(HexBlockEntities.CONJURED_TILE.get(), pos, state);
|
||||
super(HexBlockEntities.CONJURED_TILE, pos, state);
|
||||
}
|
||||
|
||||
public void walkParticle(Entity pEntity) {
|
||||
|
@ -101,25 +104,6 @@ public class BlockEntityConjured extends PaucalBlockEntity {
|
|||
|
||||
public void setColorizer(FrozenColorizer colorizer) {
|
||||
this.colorizer = colorizer;
|
||||
this.setChanged();
|
||||
this.sync();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setChanged() {
|
||||
// if (this.level == null) {
|
||||
// return;
|
||||
// }
|
||||
// this.level.sendBlockUpdated(this.worldPosition, this.getBlockState(), this.getBlockState(),
|
||||
// Block.UPDATE_CLIENTS);
|
||||
// super.setChanged();
|
||||
// }
|
||||
//
|
||||
// public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
// return ClientboundBlockEntityDataPacket.create(this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
|
||||
// this.load(Objects.requireNonNull(pkt.getTag()));
|
||||
// }
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package at.petrak.hexcasting.common.blocks.circles.impetuses;
|
||||
package at.petrak.hexcasting.common.blocks.entity;
|
||||
|
||||
import at.petrak.hexcasting.api.block.circle.BlockCircleComponent;
|
||||
import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockEntities;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -24,7 +24,7 @@ public class BlockEntityLookingImpetus extends BlockEntityAbstractImpetus {
|
|||
private int lookAmount = 0;
|
||||
|
||||
public BlockEntityLookingImpetus(BlockPos pWorldPosition, BlockState pBlockState) {
|
||||
super(HexBlockEntities.IMPETUS_LOOK_TILE.get(), pWorldPosition, pBlockState);
|
||||
super(HexBlockEntities.IMPETUS_LOOK_TILE, pWorldPosition, pBlockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,7 +80,7 @@ public class BlockEntityLookingImpetus extends BlockEntityAbstractImpetus {
|
|||
var t = (float) newLook / MAX_LOOK_AMOUNT;
|
||||
var pitch = Mth.lerp(t, 0.5f, 1.2f);
|
||||
var volume = Mth.lerp(t, 0.2f, 1.2f);
|
||||
level.playSound(null, pos, HexSounds.IMPETUS_LOOK_TICK.get(), SoundSource.BLOCKS, volume, pitch);
|
||||
level.playSound(null, pos, HexSounds.IMPETUS_LOOK_TICK, SoundSource.BLOCKS, volume, pitch);
|
||||
}
|
||||
self.lookAmount = newLook;
|
||||
self.setChanged();
|
|
@ -1,13 +1,13 @@
|
|||
package at.petrak.hexcasting.common.blocks.circles.impetuses;
|
||||
package at.petrak.hexcasting.common.blocks.entity;
|
||||
|
||||
import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockEntities;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class BlockEntityRightClickImpetus extends BlockEntityAbstractImpetus {
|
||||
public BlockEntityRightClickImpetus(BlockPos pWorldPosition, BlockState pBlockState) {
|
||||
super(HexBlockEntities.IMPETUS_RIGHTCLICK_TILE.get(), pWorldPosition, pBlockState);
|
||||
super(HexBlockEntities.IMPETUS_RIGHTCLICK_TILE, pWorldPosition, pBlockState);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.blocks.circles.impetuses;
|
||||
package at.petrak.hexcasting.common.blocks.entity;
|
||||
|
||||
import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockEntities;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
@ -29,7 +29,7 @@ public class BlockEntityStoredPlayerImpetus extends BlockEntityAbstractImpetus {
|
|||
private UUID storedPlayer = null;
|
||||
|
||||
public BlockEntityStoredPlayerImpetus(BlockPos pWorldPosition, BlockState pBlockState) {
|
||||
super(HexBlockEntities.IMPETUS_STOREDPLAYER_TILE.get(), pWorldPosition, pBlockState);
|
||||
super(HexBlockEntities.IMPETUS_STOREDPLAYER_TILE, pWorldPosition, pBlockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,7 +38,8 @@ public class BlockEntityStoredPlayerImpetus extends BlockEntityAbstractImpetus {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable Player getPlayer() {
|
||||
protected @Nullable
|
||||
Player getPlayer() {
|
||||
return this.storedPlayer == null ? null : this.level.getPlayerByUUID(this.storedPlayer);
|
||||
}
|
||||
|
||||
|
@ -48,7 +49,8 @@ public class BlockEntityStoredPlayerImpetus extends BlockEntityAbstractImpetus {
|
|||
}
|
||||
|
||||
// just feels wrong to use the protected method
|
||||
public @Nullable Player getStoredPlayer() {
|
||||
public @Nullable
|
||||
Player getStoredPlayer() {
|
||||
return this.getPlayer();
|
||||
}
|
||||
|
||||
|
@ -62,10 +64,9 @@ public class BlockEntityStoredPlayerImpetus extends BlockEntityAbstractImpetus {
|
|||
|
||||
var bound = this.getPlayer();
|
||||
if (bound != null) {
|
||||
var tag = new CompoundTag();
|
||||
String name = bound.getScoreboardName();
|
||||
tag.putString("SkullOwner", name);
|
||||
var head = new ItemStack(Items.PLAYER_HEAD, 1, tag);
|
||||
var head = new ItemStack(Items.PLAYER_HEAD);
|
||||
head.getOrCreateTag().putString("SkullOwner", name);
|
||||
lines.add(
|
||||
new Pair<>(head, new TranslatableComponent("hexcasting.tooltip.lens.impetus.storedplayer", name)));
|
||||
} else {
|
|
@ -28,7 +28,7 @@ import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpDestroySe
|
|||
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpGetSentinelPos;
|
||||
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpGetSentinelWayfind;
|
||||
import at.petrak.hexcasting.common.casting.operators.stack.*;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.api.spell.math.HexAngle;
|
||||
import at.petrak.hexcasting.api.spell.math.HexDir;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
|
@ -338,7 +338,7 @@ public class RegisterPatterns {
|
|||
|
||||
// e
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aaq", HexDir.EAST), prefix("const/double/e"),
|
||||
Operator.makeConstantOp(SpellDatum.make(Math.E)));
|
||||
Operator.makeConstantOp(SpellDatum.make(Math.E)));
|
||||
|
||||
// == Entities ==
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.RenderedSpell
|
|||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.SpellOperator
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.common.network.HexMessages
|
||||
import at.petrak.hexcasting.common.lib.HexMessages
|
||||
import at.petrak.hexcasting.common.network.MsgBeepAck
|
||||
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
|
|
@ -7,7 +7,7 @@ import at.petrak.hexcasting.api.spell.SpellDatum
|
|||
import at.petrak.hexcasting.api.spell.SpellOperator
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapImmuneEntity
|
||||
import at.petrak.hexcasting.common.network.HexMessages
|
||||
import at.petrak.hexcasting.common.lib.HexMessages
|
||||
import at.petrak.hexcasting.common.network.MsgBlinkAck
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.Entity
|
||||
|
|
|
@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.spell.RenderedSpell
|
|||
import at.petrak.hexcasting.api.spell.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.SpellOperator
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjured
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.player.HexPlayerDataHelper
|
||||
import net.minecraft.core.BlockPos
|
||||
|
|
|
@ -10,11 +10,10 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
|
|||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadItem
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem
|
||||
import at.petrak.hexcasting.api.utils.ManaHelper
|
||||
import at.petrak.hexcasting.common.items.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
import at.petrak.hexcasting.common.items.magic.ItemManaHolder
|
||||
import net.minecraft.world.entity.item.ItemEntity
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
|
||||
object OpMakeBattery : SpellOperator {
|
||||
override val argc = 1
|
||||
|
|
|
@ -7,7 +7,7 @@ import at.petrak.hexcasting.api.spell.SpellDatum
|
|||
import at.petrak.hexcasting.api.spell.SpellOperator
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingContext
|
||||
import at.petrak.hexcasting.api.spell.mishaps.MishapImmuneEntity
|
||||
import at.petrak.hexcasting.common.network.HexMessages
|
||||
import at.petrak.hexcasting.common.lib.HexMessages
|
||||
import at.petrak.hexcasting.common.network.MsgBlinkAck
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.entity.Entity
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.command;
|
|||
|
||||
import at.petrak.hexcasting.api.PatternRegistry;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemScroll;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
@ -31,7 +31,8 @@ public class ListPatternsCommand {
|
|||
for (var pair : listing) {
|
||||
ctx.getSource().sendSuccess(new TextComponent(pair.getValue().getFirst().toString())
|
||||
.append(": ")
|
||||
.append(SpellDatum.make(HexPattern.FromAnglesSig(pair.getKey(), pair.getValue().getSecond())).display()), false);
|
||||
.append(SpellDatum.make(HexPattern.FromAnglesSig(pair.getKey(), pair.getValue().getSecond()))
|
||||
.display()), false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.entities;
|
||||
|
||||
import at.petrak.hexcasting.client.RenderLib;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemScroll;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.common.items;
|
||||
|
||||
import at.petrak.hexcasting.common.network.HexMessages;
|
||||
import at.petrak.hexcasting.common.lib.HexMessages;
|
||||
import at.petrak.hexcasting.common.network.MsgUpdateComparatorVisualsAck;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -39,7 +39,8 @@ public class ItemLens extends Item implements Wearable {
|
|||
public ItemLens(Properties pProperties) {
|
||||
super(pProperties);
|
||||
DispenserBlock.registerBehavior(this, new OptionalDispenseItemBehavior() {
|
||||
protected @NotNull ItemStack execute(@NotNull BlockSource world, @NotNull ItemStack stack) {
|
||||
protected @NotNull
|
||||
ItemStack execute(@NotNull BlockSource world, @NotNull ItemStack stack) {
|
||||
this.setSuccess(ArmorItem.dispenseArmor(world, stack));
|
||||
return stack;
|
||||
}
|
||||
|
@ -75,8 +76,9 @@ public class ItemLens extends Item implements Wearable {
|
|||
if (!pLevel.isClientSide() && pEntity instanceof ServerPlayer player) {
|
||||
if (pStack == player.getItemBySlot(EquipmentSlot.HEAD) ||
|
||||
pStack == player.getItemBySlot(EquipmentSlot.MAINHAND) ||
|
||||
pStack == player.getItemBySlot(EquipmentSlot.OFFHAND))
|
||||
sendComparatorDataToClient(player);
|
||||
pStack == player.getItemBySlot(EquipmentSlot.OFFHAND)) {
|
||||
sendComparatorDataToClient(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,17 +89,19 @@ public class ItemLens extends Item implements Wearable {
|
|||
double distance = player.isCreative() ? reachAttribute : reachAttribute - 0.5;
|
||||
var hitResult = player.pick(distance, 0, false);
|
||||
if (hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
var pos = ((BlockHitResult)hitResult).getBlockPos();
|
||||
var pos = ((BlockHitResult) hitResult).getBlockPos();
|
||||
var state = player.level.getBlockState(pos);
|
||||
if (state.is(Blocks.COMPARATOR)) {
|
||||
syncComparatorValue(player, pos, state.getDirectSignal(player.level, pos, state.getValue(BlockStateProperties.HORIZONTAL_FACING)));
|
||||
syncComparatorValue(player, pos,
|
||||
state.getDirectSignal(player.level, pos, state.getValue(BlockStateProperties.HORIZONTAL_FACING)));
|
||||
} else if (state.hasAnalogOutputSignal()) {
|
||||
syncComparatorValue(player, pos, state.getAnalogOutputSignal(player.level, pos));
|
||||
} else {
|
||||
syncComparatorValue(player, null, -1);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
syncComparatorValue(player, null, -1);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncComparatorValue(ServerPlayer player, BlockPos pos, int value) {
|
||||
|
@ -105,11 +109,13 @@ public class ItemLens extends Item implements Wearable {
|
|||
if (value == -1) {
|
||||
if (previous != null) {
|
||||
comparatorDataMap.remove(player);
|
||||
HexMessages.getNetwork().send(PacketDistributor.PLAYER.with(() -> player), new MsgUpdateComparatorVisualsAck(null, -1));
|
||||
HexMessages.getNetwork()
|
||||
.send(PacketDistributor.PLAYER.with(() -> player), new MsgUpdateComparatorVisualsAck(null, -1));
|
||||
}
|
||||
} else if (previous == null || (!pos.equals(previous.getFirst()) || value != previous.getSecond())) {
|
||||
comparatorDataMap.put(player, new Pair<>(pos, value));
|
||||
HexMessages.getNetwork().send(PacketDistributor.PLAYER.with(() -> player), new MsgUpdateComparatorVisualsAck(pos, value));
|
||||
HexMessages.getNetwork()
|
||||
.send(PacketDistributor.PLAYER.with(() -> player), new MsgUpdateComparatorVisualsAck(pos, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,16 +45,18 @@ public class ItemSlate extends BlockItem implements DataHolderItem {
|
|||
@Override
|
||||
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) {
|
||||
var tag = stack.getTagElement("BlockEntityTag");
|
||||
if (tag != null && tag.isEmpty())
|
||||
if (tag != null && tag.isEmpty()) {
|
||||
stack.removeTagKey("BlockEntityTag");
|
||||
}
|
||||
return super.onEntityItemUpdate(stack, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack pStack, Level pLevel, Entity pEntity, int pSlotId, boolean pIsSelected) {
|
||||
var tag = pStack.getTagElement("BlockEntityTag");
|
||||
if (tag != null && tag.isEmpty())
|
||||
if (tag != null && tag.isEmpty()) {
|
||||
pStack.removeTagKey("BlockEntityTag");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,15 +86,17 @@ public class ItemSlate extends BlockItem implements DataHolderItem {
|
|||
|
||||
@Override
|
||||
public void writeDatum(ItemStack stack, SpellDatum<?> datum) {
|
||||
if (this.canWrite(stack, datum))
|
||||
if (this.canWrite(stack, datum)) {
|
||||
if (datum == null) {
|
||||
var beTag = stack.getOrCreateTagElement("BlockEntityTag");
|
||||
beTag.remove(BlockEntitySlate.TAG_PATTERN);
|
||||
if (beTag.isEmpty())
|
||||
if (beTag.isEmpty()) {
|
||||
stack.removeTagKey("BlockEntityTag");
|
||||
}
|
||||
} else if (datum.getPayload() instanceof HexPattern pat) {
|
||||
var beTag = stack.getOrCreateTagElement("BlockEntityTag");
|
||||
beTag.put(BlockEntitySlate.TAG_PATTERN, pat.serializeToNBT());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf;
|
||||
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicRecord;
|
||||
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityConjured;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityLookingImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityRightClickImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityStoredPlayerImpetus;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class HexBlockEntities {
|
||||
public static void registerTiles(BiConsumer<BlockEntityType<?>, ResourceLocation> r) {
|
||||
for (var e : BLOCK_ENTITIES.entrySet()) {
|
||||
r.accept(e.getValue(), e.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<ResourceLocation, BlockEntityType<?>> BLOCK_ENTITIES = new LinkedHashMap<>();
|
||||
|
||||
public static final BlockEntityType<BlockEntityConjured> CONJURED_TILE = register(
|
||||
"conjured_tile",
|
||||
BlockEntityConjured::new, HexBlocks.CONJURED_LIGHT, HexBlocks.CONJURED_BLOCK);
|
||||
|
||||
public static final BlockEntityType<BlockEntityAkashicBookshelf> AKASHIC_BOOKSHELF_TILE = register(
|
||||
"akashic_bookshelf_tile",
|
||||
BlockEntityAkashicBookshelf::new, HexBlocks.AKASHIC_BOOKSHELF);
|
||||
public static final BlockEntityType<BlockEntityAkashicRecord> AKASHIC_RECORD_TILE = register(
|
||||
"akashic_record_tile",
|
||||
BlockEntityAkashicRecord::new, HexBlocks.AKASHIC_RECORD);
|
||||
|
||||
public static final BlockEntityType<BlockEntityStoredPlayerImpetus> IMPETUS_STOREDPLAYER_TILE = register(
|
||||
"impetus_storedplayer_tile",
|
||||
BlockEntityStoredPlayerImpetus::new, HexBlocks.IMPETUS_STOREDPLAYER);
|
||||
public static final BlockEntityType<BlockEntityLookingImpetus> IMPETUS_LOOK_TILE = register(
|
||||
"impetus_look_tile",
|
||||
BlockEntityLookingImpetus::new, HexBlocks.IMPETUS_LOOK);
|
||||
public static final BlockEntityType<BlockEntityRightClickImpetus> IMPETUS_RIGHTCLICK_TILE = register(
|
||||
"impetus_rightclick_tile",
|
||||
BlockEntityRightClickImpetus::new, HexBlocks.IMPETUS_RIGHTCLICK);
|
||||
|
||||
public static final BlockEntityType<BlockEntitySlate> SLATE_TILE = register(
|
||||
"slate_tile",
|
||||
BlockEntitySlate::new, HexBlocks.SLATE);
|
||||
|
||||
private static <T extends BlockEntity> BlockEntityType<T> register(String id,
|
||||
BiFunction<BlockPos, BlockState, T> func, Block... blocks) {
|
||||
var ret = IXplatAbstractions.INSTANCE.createBlockEntityType(func, blocks);
|
||||
var old = BLOCK_ENTITIES.put(new ResourceLocation(HexAPI.MOD_ID, id), ret);
|
||||
if (old != null) {
|
||||
throw new IllegalArgumentException("Duplicate id " + id);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import net.minecraft.resources.ResourceLocation;
|
|
@ -1,7 +1,9 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus;
|
||||
import at.petrak.hexcasting.api.spell.DatumType;
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjured;
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjuredLight;
|
||||
import at.petrak.hexcasting.common.blocks.akashic.*;
|
||||
import at.petrak.hexcasting.common.blocks.circles.BlockEmptyImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.circles.BlockSlate;
|
||||
|
@ -11,7 +13,6 @@ import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockLookingImpetus;
|
|||
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockRightClickImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockStoredPlayerImpetus;
|
||||
import at.petrak.hexcasting.common.blocks.decoration.*;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.resources.ResourceLocation;
|
|
@ -1,5 +1,8 @@
|
|||
package at.petrak.hexcasting.common.command;
|
||||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.common.command.BrainsweepCommand;
|
||||
import at.petrak.hexcasting.common.command.ListPatternsCommand;
|
||||
import at.petrak.hexcasting.common.command.RecalcPatternsCommand;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.common.items;
|
||||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.items.*;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemDyeColorizer;
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer;
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemUUIDColorizer;
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.common.particles;
|
||||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.common.particles.ConjureParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.misc;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.data.worldgen.features.FeatureUtils;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
|
||||
public class HexMessages {
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
|||
import at.petrak.hexcasting.api.spell.casting.ResolvedPatternValidity;
|
||||
import at.petrak.hexcasting.api.spell.math.HexCoord;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.common.lib.HexMessages;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemAbacus;
|
||||
import at.petrak.hexcasting.common.items.ItemSpellbook;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package at.petrak.hexcasting.common.particles;
|
||||
|
||||
import at.petrak.hexcasting.common.lib.HexParticles;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.common.recipe;
|
||||
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -11,25 +11,27 @@ import net.minecraftforge.registries.RegistryObject;
|
|||
|
||||
public final class HexComposting {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void setup(FMLCommonSetupEvent evt) {
|
||||
compostBlock(HexBlocks.AKASHIC_LEAVES1, 0.3F);
|
||||
compostBlock(HexBlocks.AKASHIC_LEAVES2, 0.3F);
|
||||
compostBlock(HexBlocks.AKASHIC_LEAVES3, 0.3F);
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void setup(FMLCommonSetupEvent evt) {
|
||||
compostBlock(HexBlocks.AKASHIC_LEAVES1, 0.3F);
|
||||
compostBlock(HexBlocks.AKASHIC_LEAVES2, 0.3F);
|
||||
compostBlock(HexBlocks.AKASHIC_LEAVES3, 0.3F);
|
||||
}
|
||||
|
||||
private static <T extends Item> void compostItem(RegistryObject<T> itemHolder, float chance) {
|
||||
T item = itemHolder.get();
|
||||
private static <T extends Item> void compostItem(RegistryObject<T> itemHolder, float chance) {
|
||||
T item = itemHolder.get();
|
||||
|
||||
if (item != Items.AIR)
|
||||
if (item != Items.AIR) {
|
||||
ComposterBlock.COMPOSTABLES.put(item, chance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends Block> void compostBlock(RegistryObject<T> blockHolder, float chance) {
|
||||
T block = blockHolder.get();
|
||||
Item item = block.asItem();
|
||||
private static <T extends Block> void compostBlock(RegistryObject<T> blockHolder, float chance) {
|
||||
T block = blockHolder.get();
|
||||
Item item = block.asItem();
|
||||
|
||||
if (item != Items.AIR)
|
||||
if (item != Items.AIR) {
|
||||
ComposterBlock.COMPOSTABLES.put(item, chance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.common.recipe;
|
||||
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemFocus;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.common.recipe;
|
||||
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemSpellbook;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
|
|
|
@ -13,6 +13,7 @@ import at.petrak.hexcasting.common.command.PatternResLocArgument;
|
|||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypes;
|
||||
import net.minecraft.commands.synchronization.EmptyArgumentSerializer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
|
@ -20,12 +21,16 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -86,6 +91,9 @@ public interface IXplatAbstractions {
|
|||
|
||||
// Blocks
|
||||
|
||||
<T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
|
||||
Block... blocks);
|
||||
|
||||
Block makeFlammable(BlockBehaviour.Properties properties, int flammability, int spreadSpeed);
|
||||
|
||||
// misc
|
||||
|
@ -117,4 +125,5 @@ public interface IXplatAbstractions {
|
|||
return provider.get();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import at.petrak.hexcasting.common.blocks.HexBlocks
|
||||
import at.petrak.hexcasting.common.items.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexSounds
|
||||
import at.petrak.hexcasting.common.misc.Brainsweeping
|
||||
import at.petrak.hexcasting.fabric.FabricHexConfig
|
||||
|
@ -33,6 +34,7 @@ object FabricHexInitializer : ModInitializer {
|
|||
HexBlocks.registerBlocks(bind(Registry.BLOCK))
|
||||
HexBlocks.registerBlockItems(bind(Registry.ITEM))
|
||||
HexItems.registerItems(bind(Registry.ITEM))
|
||||
HexBlockEntities.registerTiles(bind(Registry.BLOCK_ENTITY_TYPE))
|
||||
}
|
||||
|
||||
private fun <T> bind(registry: Registry<in T>): BiConsumer<T, ResourceLocation> =
|
||||
|
|
|
@ -6,7 +6,7 @@ import at.petrak.hexcasting.api.item.HexHolderItem;
|
|||
import at.petrak.hexcasting.api.item.ManaHolderItem;
|
||||
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import dev.onyxstudios.cca.api.v3.component.ComponentKey;
|
||||
import dev.onyxstudios.cca.api.v3.component.ComponentRegistry;
|
||||
import dev.onyxstudios.cca.api.v3.entity.EntityComponentFactoryRegistry;
|
||||
|
|
|
@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.player.FlightAbility;
|
|||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.fabric.cc.HexCardinalComponents;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
|
@ -17,8 +17,10 @@ import net.fabricmc.api.EnvType;
|
|||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
|
@ -26,11 +28,15 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
|
@ -135,19 +141,22 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ManaHolder findManaHolder(ItemStack stack) {
|
||||
public @Nullable
|
||||
ManaHolder findManaHolder(ItemStack stack) {
|
||||
var cc = HexCardinalComponents.MANA_HOLDER.maybeGet(stack);
|
||||
return cc.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable DataHolder findDataHolder(ItemStack stack) {
|
||||
public @Nullable
|
||||
DataHolder findDataHolder(ItemStack stack) {
|
||||
var cc = HexCardinalComponents.DATA_HOLDER.maybeGet(stack);
|
||||
return cc.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable HexHolder findHexHolder(ItemStack stack) {
|
||||
public @Nullable
|
||||
HexHolder findHexHolder(ItemStack stack) {
|
||||
var cc = HexCardinalComponents.HEX_HOLDER.maybeGet(stack);
|
||||
return cc.orElse(null);
|
||||
}
|
||||
|
@ -163,6 +172,12 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
return cc.map(col -> col.color(colorizer.owner(), time, position)).orElse(0xff_ff00dc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
|
||||
Block... blocks) {
|
||||
return FabricBlockEntityTypeBuilder.create(func::apply, blocks).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeFlammable(BlockBehaviour.Properties properties, int flammability, int spreadSpeed) {
|
||||
var out = new Block(properties);
|
||||
|
|
|
@ -4,8 +4,9 @@ import at.petrak.hexcasting.api.HexAPI
|
|||
import at.petrak.hexcasting.api.PatternRegistry
|
||||
import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers
|
||||
import at.petrak.hexcasting.api.mod.HexConfig
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks
|
||||
import at.petrak.hexcasting.common.items.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexSounds
|
||||
import at.petrak.hexcasting.common.misc.Brainsweeping
|
||||
import at.petrak.hexcasting.forge.ForgeHexConfig
|
||||
|
@ -59,6 +60,7 @@ object ForgeHexInitializer {
|
|||
bind(ForgeRegistries.SOUND_EVENTS, HexSounds::registerSounds)
|
||||
bind(ForgeRegistries.BLOCKS, HexBlocks::registerBlocks)
|
||||
bind(ForgeRegistries.ITEMS, HexBlocks::registerBlockItems)
|
||||
bind(ForgeRegistries.BLOCK_ENTITIES, HexBlockEntities::registerTiles)
|
||||
bind(ForgeRegistries.ITEMS, HexItems::registerItems)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import at.petrak.hexcasting.api.item.ManaHolderItem;
|
|||
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -203,13 +203,15 @@ public class ForgeCapabilityHandler {
|
|||
ItemStack stack) implements DataHolder {
|
||||
|
||||
@Override
|
||||
public @Nullable CompoundTag readRawDatum() {
|
||||
public @Nullable
|
||||
CompoundTag readRawDatum() {
|
||||
SpellDatum<?> datum = provider.apply(stack);
|
||||
return datum == null ? null : datum.serializeToNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable SpellDatum<?> readDatum(ServerLevel world) {
|
||||
public @Nullable
|
||||
SpellDatum<?> readDatum(ServerLevel world) {
|
||||
return provider.apply(stack);
|
||||
}
|
||||
|
||||
|
@ -223,17 +225,20 @@ public class ForgeCapabilityHandler {
|
|||
ItemStack stack) implements DataHolder {
|
||||
|
||||
@Override
|
||||
public @Nullable CompoundTag readRawDatum() {
|
||||
public @Nullable
|
||||
CompoundTag readRawDatum() {
|
||||
return holder.readDatumTag(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable SpellDatum<?> readDatum(ServerLevel world) {
|
||||
public @Nullable
|
||||
SpellDatum<?> readDatum(ServerLevel world) {
|
||||
return holder.readDatum(stack, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable SpellDatum<?> emptyDatum() {
|
||||
public @Nullable
|
||||
SpellDatum<?> emptyDatum() {
|
||||
return holder.emptyDatum(stack);
|
||||
}
|
||||
|
||||
|
@ -258,7 +263,8 @@ public class ForgeCapabilityHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<HexPattern> getPatterns() {
|
||||
public @Nullable
|
||||
List<HexPattern> getPatterns() {
|
||||
return holder.getPatterns(stack);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.HexAPI;
|
|||
import at.petrak.hexcasting.api.advancements.FailToCastGreatSpellTrigger;
|
||||
import at.petrak.hexcasting.api.advancements.OvercastTrigger;
|
||||
import at.petrak.hexcasting.api.advancements.SpendManaTrigger;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.paucal.api.datagen.PaucalAdvancementProvider;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.DisplayInfo;
|
||||
|
|
|
@ -3,10 +3,10 @@ package at.petrak.hexcasting.forge.datagen;
|
|||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.api.block.circle.BlockCircleComponent;
|
||||
import at.petrak.hexcasting.api.spell.DatumType;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf;
|
||||
import at.petrak.hexcasting.common.blocks.circles.BlockSlate;
|
||||
import at.petrak.hexcasting.common.blocks.circles.directrix.BlockRedstoneDirectrix;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import at.petrak.paucal.api.datagen.PaucalBlockStateAndModelProvider;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package at.petrak.hexcasting.forge.datagen;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockTags;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockTags;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.tags.BlockTagsProvider;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package at.petrak.hexcasting.forge.datagen;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import at.petrak.hexcasting.common.items.*;
|
||||
import at.petrak.hexcasting.common.items.magic.ItemManaBattery;
|
||||
import at.petrak.hexcasting.common.items.magic.ItemPackagedHex;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.paucal.api.datagen.PaucalItemModelProvider;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
|
|
@ -2,8 +2,8 @@ package at.petrak.hexcasting.forge.datagen;
|
|||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.api.mod.HexItemTags;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlockTags;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockTags;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.tags.BlockTagsProvider;
|
||||
import net.minecraft.data.tags.ItemTagsProvider;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.forge.datagen;
|
||||
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import at.petrak.paucal.api.datagen.PaucalLootTableProvider;
|
||||
import net.minecraft.advancements.critereon.EnchantmentPredicate;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
|
|
|
@ -3,8 +3,8 @@ package at.petrak.hexcasting.forge.datagen;
|
|||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.api.advancements.OvercastTrigger;
|
||||
import at.petrak.hexcasting.api.mod.HexItemTags;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexBlocks;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemWand;
|
||||
import at.petrak.hexcasting.common.recipe.SealFocusRecipe;
|
||||
import at.petrak.hexcasting.common.recipe.SealSpellbookRecipe;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.forge.datagen.lootmods;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.paucal.api.lootmod.PaucalAddItemModifier;
|
||||
import at.petrak.paucal.api.lootmod.PaucalLootMods;
|
||||
import net.minecraft.advancements.critereon.EnchantmentPredicate;
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.forge.datagen.lootmods;
|
|||
|
||||
import at.petrak.hexcasting.api.PatternRegistry;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemScroll;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
|
|
@ -12,7 +12,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext;
|
|||
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
||||
import at.petrak.hexcasting.api.utils.HexUtils;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.misc.Brainsweeping;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.forge.block.BlockBurns;
|
||||
|
@ -22,6 +22,7 @@ import at.petrak.hexcasting.forge.network.ForgePacketHandler;
|
|||
import at.petrak.hexcasting.forge.network.MsgBrainsweepAck;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import at.petrak.hexcasting.xplat.Platform;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -37,7 +38,10 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
|
@ -46,6 +50,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class ForgeXplatImpl implements IXplatAbstractions {
|
||||
@Override
|
||||
|
@ -196,19 +201,22 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ManaHolder findManaHolder(ItemStack stack) {
|
||||
public @Nullable
|
||||
ManaHolder findManaHolder(ItemStack stack) {
|
||||
var maybeCap = stack.getCapability(HexCapabilities.MANA).resolve();
|
||||
return maybeCap.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable DataHolder findDataHolder(ItemStack stack) {
|
||||
public @Nullable
|
||||
DataHolder findDataHolder(ItemStack stack) {
|
||||
var maybeCap = stack.getCapability(HexCapabilities.DATUM).resolve();
|
||||
return maybeCap.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable HexHolder findHexHolder(ItemStack stack) {
|
||||
public @Nullable
|
||||
HexHolder findHexHolder(ItemStack stack) {
|
||||
var maybeCap = stack.getCapability(HexCapabilities.STORED_HEX).resolve();
|
||||
return maybeCap.orElse(null);
|
||||
}
|
||||
|
@ -239,6 +247,12 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
ForgePacketHandler.getNetwork().sendToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
|
||||
Block... blocks) {
|
||||
return BlockEntityType.Builder.of(func::apply, blocks).build(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeFlammable(BlockBehaviour.Properties properties, int flammability, int spreadSpeed) {
|
||||
return new BlockBurns(properties, flammability, spreadSpeed);
|
||||
|
|
Loading…
Reference in a new issue