not-working painting scrolls

This commit is contained in:
gamma-delta 2022-03-23 15:41:17 -05:00
parent 7524df6d90
commit 405313a1fe
22 changed files with 635 additions and 24 deletions

View file

@ -172,6 +172,10 @@ afecba3144e00505977a4ab4de7940f949ab7818 data/hexcasting/loot_modifiers/scroll_d
0e8c8a56161586a4021487b27059ca151465af67 data/hexcasting/loot_modifiers/scroll_jungle.json
50e7ad657a0ab43f3bd632120e09f109791aaf34 data/hexcasting/loot_modifiers/scroll_shipwreck.json
7ffa361bd8a108b504fe450749b42997dc898e5e data/hexcasting/loot_modifiers/scroll_stronghold_library.json
5944235a01e31fbe3f2799f667b6deb2f8a62ca6 data/hexcasting/loot_tables/blocks/empty_impetus.json
c87dcdb39d1d9cb0429763bbd32631cbf15047aa data/hexcasting/loot_tables/blocks/impetus_rightclick.json
17e53b980127473558a1a544e59d329a4701e7cc data/hexcasting/loot_tables/blocks/slate.json
33b4d5e6928828898fea92523f7cb81f9b4eac36 data/hexcasting/loot_tables/blocks/slate_block.json
6b4459635b3d53cc2b6836fa97d29244a65b412d data/hexcasting/recipes/abacus.json
6e6e4d01097c10316892e274f33cb0faaf9dc0df data/hexcasting/recipes/artifact.json
1cb9f605890a215a965e1088abd3013bd34e0fc0 data/hexcasting/recipes/brainsweep/budding_amethyst.json
@ -219,4 +223,4 @@ d14cf2f8f0895a5b6dc09b7582c0abf1c2514adf data/hexcasting/recipes/sub_sandwich.js
33b9d3a5e65343fc0e442e17d55a1eaa08943c8f data/hexcasting/recipes/trinket.json
14d6be5d47b54676a349564ea32c045c76c39b45 data/hexcasting/recipes/uuid_colorizer.json
0521d57838cb3e9795fc02ce47aa58db3b0188f9 data/hexcasting/recipes/wand.json
cf2e739eb059c69251e4a1305b259aff866f6f5f data/minecraft/tags/blocks/mineable/pickaxe.json
1d891cd7bbbd24f4fe36eff375cdbc3e3e34fc8f data/minecraft/tags/blocks/mineable/pickaxe.json

View file

@ -0,0 +1,16 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "empty_impetus",
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "hexcasting:empty_impetus"
}
]
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "impetus_rightclick",
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "hexcasting:impetus_rightclick"
}
]
}
]
}

View file

@ -0,0 +1,29 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "slate",
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "pattern",
"target": "BlockEntityTag.pattern",
"op": "replace"
}
]
}
],
"name": "hexcasting:slate"
}
]
}
]
}

View file

@ -0,0 +1,16 @@
{
"type": "minecraft:block",
"pools": [
{
"name": "slate_block",
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "hexcasting:slate_block"
}
]
}
]
}

View file

@ -3,6 +3,7 @@
"values": [
"hexcasting:slate_block",
"hexcasting:slate",
"hexcasting:empty_impetus",
"hexcasting:impetus_rightclick"
]
}

View file

@ -6,6 +6,7 @@ import at.petrak.hexcasting.common.blocks.HexBlocks
import at.petrak.hexcasting.common.casting.RegisterPatterns
import at.petrak.hexcasting.common.casting.operators.spells.great.OpFlight
import at.petrak.hexcasting.common.command.HexCommands
import at.petrak.hexcasting.common.entities.HexEntities
import at.petrak.hexcasting.common.items.HexItems
import at.petrak.hexcasting.common.lib.HexCapabilities
import at.petrak.hexcasting.common.lib.HexSounds
@ -62,6 +63,7 @@ object HexMod {
HexItems.ITEMS.register(modBus)
HexBlocks.BLOCKS.register(modBus)
HexBlocks.BLOCK_ENTITIES.register(modBus)
HexEntities.ENTITIES.register(modBus)
HexLootModifiers.LOOT_MODS.register(modBus)
HexSounds.SOUNDS.register(modBus)
HexParticles.PARTICLES.register(modBus)

View file

@ -3,11 +3,13 @@ package at.petrak.hexcasting.client;
import at.petrak.hexcasting.HexConfig;
import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry;
import at.petrak.hexcasting.api.spell.SpellDatum;
import at.petrak.hexcasting.client.entity.WallScrollRenderer;
import at.petrak.hexcasting.client.particles.ConjureParticle;
import at.petrak.hexcasting.common.blocks.HexBlocks;
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockAbstractImpetus;
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockEntityAbstractImpetus;
import at.petrak.hexcasting.common.entities.HexEntities;
import at.petrak.hexcasting.common.items.HexItems;
import at.petrak.hexcasting.common.items.ItemFocus;
import at.petrak.hexcasting.common.items.ItemScroll;
@ -20,6 +22,7 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
@ -31,6 +34,7 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
import net.minecraftforge.client.model.ForgeModelBakery;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
@ -99,6 +103,10 @@ public class RegisterClientStuff {
renderLayers(ItemBlockRenderTypes::setRenderLayer);
EntityRenderers.register(HexEntities.WALL_SCROLL.get(), WallScrollRenderer::new);
ForgeModelBakery.addSpecialModel(WallScrollRenderer.ANCIENT_MODEL);
ForgeModelBakery.addSpecialModel(WallScrollRenderer.PRISTINE_MODEL);
addScryingLensStuff();
}

View file

@ -4,6 +4,7 @@ import at.petrak.hexcasting.HexConfig
import at.petrak.hexcasting.HexUtils
import at.petrak.hexcasting.client.gui.SQRT_3
import at.petrak.hexcasting.hexmath.HexCoord
import at.petrak.hexcasting.hexmath.HexPattern
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.PoseStack
@ -20,6 +21,7 @@ import net.minecraft.world.level.levelgen.synth.PerlinNoise
import net.minecraft.world.phys.Vec2
import kotlin.math.absoluteValue
import kotlin.math.floor
import kotlin.math.min
import kotlin.math.roundToInt
import net.minecraft.util.FastColor.ARGB32 as FC
@ -173,7 +175,7 @@ object RenderLib {
return emptyList()
}
val mc = Minecraft.getInstance()
val zSeed = (mc.frameTime.toDouble() + mc.level!!.levelData.gameTime) * speed
val zSeed = (mc.frameTime.toDouble() + (mc.level?.levelData?.gameTime ?: 0)) * speed
// Create our output list of zap points
val zappyPts = mutableListOf(points[0])
// For each segment in the original...
@ -272,6 +274,33 @@ object RenderLib {
)
}
/**
* Return the scale and dots formed by the pattern when centered.
*/
@JvmStatic
fun getCenteredPattern(pattern: HexPattern, width: Float, height: Float, minSize: Float): Pair<Float, List<Vec2>> {
// Do two passes: one with a random size to find a good COM and one with the real calculation
val com1: Vec2 = pattern.getCenter(1f)
val lines1: List<Vec2> = pattern.toLines(1f, Vec2.ZERO)
var maxDx = -1f
var maxDy = -1f
for (dot in lines1) {
val dx = Mth.abs(dot.x - com1.x)
if (dx > maxDx) {
maxDx = dx
}
val dy = Mth.abs(dot.y - com1.y)
if (dy > maxDy) {
maxDy = dy
}
}
val scale =
min(minSize, min(width / 3f / maxDx, height / 3f / maxDy))
val com2: Vec2 = pattern.getCenter(scale)
val lines2: List<Vec2> = pattern.toLines(scale, com2.negated())
return Pair(scale, lines2)
}
@JvmStatic
fun renderItemStackInGui(ms: PoseStack, stack: ItemStack, x: Int, y: Int) {
transferMsToGl(ms) { Minecraft.getInstance().itemRenderer.renderAndDecorateItem(stack, x, y) }

View file

@ -0,0 +1,88 @@
package at.petrak.hexcasting.client.entity;
import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.common.entities.EntityWallScroll;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
public class WallScrollRenderer extends EntityRenderer<EntityWallScroll> {
private static final ResourceLocation PRISTINE_BG = new ResourceLocation(HexMod.MOD_ID,
"textures/entity/scroll.png");
private static final ResourceLocation ANCIENT_BG = new ResourceLocation(HexMod.MOD_ID,
"textures/entity/scroll_ancient.png");
public static final ModelResourceLocation PRISTINE_MODEL = new ModelResourceLocation(
new ResourceLocation(HexMod.MOD_ID, "wall_scroll"), "inventory");
public static final ModelResourceLocation ANCIENT_MODEL = new ModelResourceLocation(
new ResourceLocation(HexMod.MOD_ID, "wall_scroll_ancient"), "inventory");
public WallScrollRenderer(EntityRendererProvider.Context p_174008_) {
super(p_174008_);
}
// I do as the PaintingRenderer guides
@Override
public void render(EntityWallScroll wallScroll, float yaw, float partialTicks, PoseStack ps,
MultiBufferSource buf, int packedLight) {
var mc = Minecraft.getInstance();
var blockRenderer = mc.getBlockRenderer();
var modelManager = mc.getModelManager();
ps.pushPose();
ps.mulPose(Vector3f.YP.rotationDegrees(90f - yaw));
// X is backwards, Y is down, Z is to the right
ps.translate(-1f / 32f, -0.5, -0.5);
blockRenderer.getModelRenderer()
.renderModel(ps.last(), buf.getBuffer(Sheets.cutoutBlockSheet()),
null,
modelManager.getModel(wallScroll.isAncient ? ANCIENT_MODEL : PRISTINE_MODEL),
1f, 1f, 1f, packedLight, OverlayTexture.NO_OVERLAY);
if (wallScroll.zappyPoints != null) {
var oldShader = RenderSystem.getShader();
RenderSystem.setShader(GameRenderer::getPositionTexShader);
ps.pushPose();
ps.mulPose(Vector3f.YP.rotationDegrees(-90f));
ps.translate(0, 0, 1.01f / 16f);
float scale = 1f / 16f;
ps.scale(scale, scale, 1);
var mat = ps.last().pose();
var outer = 0xff_d2c8c8;
var inner = 0xc8_322b33;
RenderLib.drawLineSeq(mat, wallScroll.zappyPoints, 5f, 0, outer, outer, null);
RenderLib.drawLineSeq(mat, wallScroll.zappyPoints, 2f, 0, inner, inner);
ps.popPose();
RenderSystem.setShader(() -> oldShader);
}
ps.popPose();
super.render(wallScroll, yaw, partialTicks, ps, buf, packedLight);
}
@Override
public ResourceLocation getTextureLocation(EntityWallScroll wallScroll) {
if (wallScroll.isAncient) {
return ANCIENT_BG;
} else {
return PRISTINE_BG;
}
}
}

View file

@ -12,7 +12,6 @@ import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
import net.minecraft.world.phys.Vec2;
@ -40,28 +39,12 @@ public class PatternTooltipGreeble implements ClientTooltipComponent, TooltipCom
public PatternTooltipGreeble(HexPattern pattern, ResourceLocation background) {
this.pattern = pattern;
this.background = background;
// Do two passes: one with a random size to find a good COM and one with the real calculation
var com1 = this.pattern.getCenter(1);
var lines1 = this.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;
}
}
this.scale = Math.min(8f, Math.min(SIZE / 3f / maxDx, SIZE / 3f / maxDy));
var com2 = this.pattern.getCenter(this.scale);
var lines2 = this.pattern.toLines(this.scale, com2.negated());
this.zappyPoints = RenderLib.makeZappy(lines2, 10f, 0.8f, 0f);
this.pathfinderDots = lines2.stream().distinct().collect(Collectors.toList());
var pair = RenderLib.getCenteredPattern(pattern, SIZE, SIZE, 8f);
this.scale = pair.getFirst();
var dots = pair.getSecond();
this.zappyPoints = RenderLib.makeZappy(dots, 10f, 0.8f, 0f);
this.pathfinderDots = dots.stream().distinct().collect(Collectors.toList());
}
@Override

View file

@ -5,6 +5,9 @@ import at.petrak.hexcasting.api.PatternRegistry;
import at.petrak.hexcasting.api.spell.Operator;
import at.petrak.hexcasting.api.spell.SpellDatum;
import at.petrak.hexcasting.common.casting.operators.*;
import at.petrak.hexcasting.common.casting.operators.circles.OpCircleBounds;
import at.petrak.hexcasting.common.casting.operators.circles.OpImpetusDir;
import at.petrak.hexcasting.common.casting.operators.circles.OpImpetusPos;
import at.petrak.hexcasting.common.casting.operators.eval.OpEval;
import at.petrak.hexcasting.common.casting.operators.eval.OpEvalDelay;
import at.petrak.hexcasting.common.casting.operators.eval.OpForEach;
@ -57,6 +60,17 @@ public class RegisterPatterns {
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("weaqa", HexDir.EAST), prefix("raycast/entity"),
OpEntityRaycast.INSTANCE);
// == spell circle getters ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqae", HexDir.SOUTH_WEST),
prefix("circle/impetus_pos"), OpImpetusPos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqaewede", HexDir.SOUTH_WEST),
prefix("circle/impetus_dir"), OpImpetusDir.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqaewdd", HexDir.SOUTH_WEST),
prefix("circle/bounds/min"), new OpCircleBounds(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqwqawaaqa", HexDir.WEST),
prefix("circle/bounds/max"), new OpCircleBounds(true));
// == Modify Stack ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("a", HexDir.EAST), prefix("undo"), OpUndo.INSTANCE);

View file

@ -0,0 +1,142 @@
package at.petrak.hexcasting.common.entities;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.common.items.ItemScroll;
import at.petrak.hexcasting.hexmath.HexPattern;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.decoration.HangingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec2;
import net.minecraftforge.entity.IEntityAdditionalSpawnData;
import net.minecraftforge.network.NetworkHooks;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class EntityWallScroll extends HangingEntity implements IEntityAdditionalSpawnData {
public ItemStack scroll;
public HexPattern pattern;
public List<Vec2> zappyPoints;
public boolean isAncient;
public EntityWallScroll(EntityType<? extends EntityWallScroll> type, Level world) {
super(type, world);
}
public EntityWallScroll(Level world, BlockPos pos, Direction dir, ItemStack scroll) {
super(HexEntities.WALL_SCROLL.get(), world, pos);
this.loadDataFromScrollItem(scroll);
this.setDirection(dir);
}
private void loadDataFromScrollItem(ItemStack scroll) {
this.scroll = scroll;
var tag = scroll.getTag();
if (tag != null) {
var pattern = HexPattern.DeserializeFromNBT(tag.getCompound(ItemScroll.TAG_PATTERN));
var pair = RenderLib.getCenteredPattern(pattern, 48, 48, 8f);
var dots = pair.getSecond();
this.zappyPoints = RenderLib.makeZappy(dots, 10f, 0.8f, 0f);
this.isAncient = tag.contains(ItemScroll.TAG_OP_ID);
} else {
this.pattern = null;
this.zappyPoints = null;
this.isAncient = false;
}
}
@Override
public int getWidth() {
return 48;
}
@Override
public int getHeight() {
return 48;
}
@Override
public void dropItem(@Nullable Entity pBrokenEntity) {
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F);
if (pBrokenEntity instanceof Player player) {
if (player.getAbilities().instabuild) {
return;
}
}
this.spawnAtLocation(this.scroll);
}
}
@Override
public void playPlacementSound() {
this.playSound(SoundEvents.PAINTING_PLACE, 1.0F, 1.0F);
}
@Override
public Packet<?> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
@Override
public void writeSpawnData(FriendlyByteBuf buf) {
buf.writeVarInt(this.direction.ordinal());
buf.writeItem(this.scroll);
}
@Override
public void readSpawnData(FriendlyByteBuf buf) {
this.direction = Direction.values()[buf.readVarInt()];
var scroll = buf.readItem();
this.loadDataFromScrollItem(scroll);
this.setDirection(this.direction);
}
@Override
public void addAdditionalSaveData(CompoundTag tag) {
tag.putByte("direction", (byte) this.direction.ordinal());
tag.put("scroll", this.scroll.serializeNBT());
super.addAdditionalSaveData(tag);
}
@Override
public void readAdditionalSaveData(CompoundTag tag) {
this.direction = Direction.values()[tag.getByte("direction")];
var scroll = ItemStack.EMPTY.copy();
scroll.deserializeNBT(tag.getCompound("scroll"));
super.readAdditionalSaveData(tag);
this.setDirection(this.direction);
this.loadDataFromScrollItem(scroll);
}
@Override
public void moveTo(double pX, double pY, double pZ, float pYaw, float pPitch) {
this.setPos(pX, pY, pZ);
}
@Override
public void lerpTo(double pX, double pY, double pZ, float pYaw, float pPitch, int pPosRotationIncrements,
boolean pTeleport) {
BlockPos blockpos = this.pos.offset(pX - this.getX(), pY - this.getY(), pZ - this.getZ());
this.setPos(blockpos.getX(), blockpos.getY(), blockpos.getZ());
}
@Override
public ItemStack getPickedResult(HitResult target) {
return this.scroll.copy();
}
}

View file

@ -0,0 +1,18 @@
package at.petrak.hexcasting.common.entities;
import at.petrak.hexcasting.HexMod;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class HexEntities {
public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES,
HexMod.MOD_ID);
public static final RegistryObject<EntityType<EntityWallScroll>> WALL_SCROLL = ENTITIES.register("wall_scroll",
() -> EntityType.Builder.<EntityWallScroll>of(EntityWallScroll::new, MobCategory.MISC)
.sized(0.5F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE)
.build("wall_scroll"));
}

View file

@ -1,11 +1,19 @@
package at.petrak.hexcasting.common.items;
import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.common.entities.EntityWallScroll;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.gameevent.GameEvent;
/**
* TAG_OP_ID and TAG_PATTERN: "Ancient Scroll of %s" (Great Spells)
@ -25,6 +33,46 @@ public class ItemScroll extends Item {
super(pProperties);
}
@Override
public InteractionResult useOn(UseOnContext ctx) {
var posClicked = ctx.getClickedPos();
var direction = ctx.getClickedFace();
var posInFront = posClicked.relative(direction);
Player player = ctx.getPlayer();
ItemStack itemstack = ctx.getItemInHand();
if (player != null && !this.mayPlace(player, direction, itemstack, posInFront)) {
return InteractionResult.FAIL;
} else {
var level = ctx.getLevel();
var scrollStack = itemstack.copy();
scrollStack.setCount(1);
var scrollEntity = new EntityWallScroll(level, posInFront, direction, scrollStack);
// i guess
var compoundtag = itemstack.getTag();
if (compoundtag != null) {
EntityType.updateCustomEntityTag(level, player, scrollEntity, compoundtag);
}
if (scrollEntity.survives()) {
if (!level.isClientSide) {
scrollEntity.playPlacementSound();
level.gameEvent(player, GameEvent.ENTITY_PLACE, posClicked);
level.addFreshEntity(scrollEntity);
}
itemstack.shrink(1);
return InteractionResult.sidedSuccess(level.isClientSide);
} else {
return InteractionResult.CONSUME;
}
}
}
protected boolean mayPlace(Player pPlayer, Direction pDirection, ItemStack pHangingEntityStack, BlockPos pPos) {
return !pDirection.getAxis().isVertical() && pPlayer.mayUseItemAt(pPos, pDirection, pHangingEntityStack);
}
@Override
public Component getName(ItemStack pStack) {
var tag = pStack.getOrCreateTag();

View file

@ -19,6 +19,7 @@ public class HexBlockTags extends BlockTagsProvider {
tag(BlockTags.MINEABLE_WITH_PICKAXE)
.add(HexBlocks.SLATE_BLOCK.get())
.add(HexBlocks.SLATE.get())
.add(HexBlocks.EMPTY_IMPETUS.get())
.add(HexBlocks.IMPETUS_RIGHTCLICK.get());
}
}

View file

@ -20,6 +20,7 @@ public class HexDataGenerators {
gen.addProvider(new HexLootModifiers(gen));
gen.addProvider(new HexAdvancements(gen, efh));
gen.addProvider(new HexBlockTags(gen, efh));
gen.addProvider(new HexLootTables(gen));
}
}
}

View file

@ -0,0 +1,94 @@
package at.petrak.hexcasting.datagen;
import at.petrak.hexcasting.common.blocks.HexBlocks;
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DataProvider;
import net.minecraft.data.HashCache;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
// https://github.com/XuulMedia/Flint-Age/blob/4638289130ef80dafe9b6a3fdcb461a72688100f/src/main/java/xuul/flint/datagen/BaseLootTableProvider.java#L61
// auugh mojang whyyyy
public class HexLootTables extends LootTableProvider {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
private final DataGenerator generator;
protected final Map<Block, LootTable.Builder> lootTables = new HashMap<>();
public HexLootTables(DataGenerator pGenerator) {
super(pGenerator);
this.generator = pGenerator;
}
protected void addTables() {
dropSelfTable(HexBlocks.EMPTY_IMPETUS.get());
dropSelfTable(HexBlocks.IMPETUS_RIGHTCLICK.get());
dropSelfTable(HexBlocks.SLATE_BLOCK.get());
var slatePool = LootPool.lootPool().name("slate").
setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(HexBlocks.SLATE.get())
.apply(CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY)
.copy(BlockEntitySlate.TAG_PATTERN, "BlockEntityTag." + BlockEntitySlate.TAG_PATTERN)));
lootTables.put(HexBlocks.SLATE.get(), LootTable.lootTable().withPool(slatePool));
}
protected void dropSelfTable(Block block) {
dropSelfTable(block.getRegistryName().getPath(), block);
}
protected void dropSelfTable(String name, Block block) {
var pool = LootPool.lootPool()
.name(name)
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(block));
var loot = LootTable.lootTable().withPool(pool);
lootTables.put(block, loot);
}
@Override
public void run(HashCache cache) {
addTables();
var tables = new HashMap<ResourceLocation, LootTable>();
for (var entry : lootTables.entrySet()) {
tables.put(entry.getKey().getLootTable(), entry.getValue().setParamSet(LootContextParamSets.BLOCK).build());
}
writeTables(cache, tables);
}
private void writeTables(HashCache cache, Map<ResourceLocation, LootTable> tables) {
Path outputFolder = this.generator.getOutputFolder();
tables.forEach((key, lootTable) -> {
Path path = outputFolder.resolve("data/" + key.getNamespace() + "/loot_tables/" + key.getPath() + ".json");
try {
DataProvider.save(GSON, cache, LootTables.serialize(lootTable), path);
} catch (IOException e) {
}
});
}
@Override
public String getName() {
return "Flint LootTables";
}
}

View file

@ -104,6 +104,10 @@
"hexcasting.spell.hexcasting:raycast": "Archer's Distillation",
"hexcasting.spell.hexcasting:raycast/axis": "Architect's Distillation",
"hexcasting.spell.hexcasting:raycast/entity": "Scout's Distillation",
"hexcasting.spell.hexcasting:circle/impetus_pos": "Waystone Reflection",
"hexcasting.spell.hexcasting:circle/impetus_dir": "Lodestone Reflection",
"hexcasting.spell.hexcasting:circle/bounds/min": "Lesser Fold Reflection",
"hexcasting.spell.hexcasting:circle/bounds/max": "Greater Fold Reflection",
"hexcasting.spell.hexcasting:append": "Integration Distillation",
"hexcasting.spell.hexcasting:concat": "Combination Distillation",
"hexcasting.spell.hexcasting:index": "Selection Distillation",
@ -524,6 +528,13 @@
"hexcasting.page.meta.6": "More specifically, for each element in the second list, it will:$(li)Create a new stack, with everything on the current stack plus that element$(li)Draw all the patterns in the first list$(li)Save all the iotas remaining on the stack to a list$(br)Then, after all is said and done, pushes the list of saved iotas onto the main stack.$(br2)No wonder all the practitioners of this art go mad.",
"hexcasting.page.meta.7": "Like $(action)Scribe's Reflection/$, but the iota is read out of an item entity instead of my other hand.",
"hexcasting.entry.circle_patterns": "Spell Circle Patterns",
"hexcasting.page.circle_patterns.1": "These patterns must be cast from a $(item)Spell Circle/$; trying to cast them through a $(item)Staff/$ will fail.",
"hexcasting.page.circle_patterns.2": "Returns the position of the $(item)Impetus/$ of this spell circle.",
"hexcasting.page.circle_patterns.3": "Returns the direction the $(item)Impetus/$ of this spell circle is facing as a unit vector.",
"hexcasting.page.circle_patterns.4": "Returns the position of the lower-north-west corner of the bounds of this spell circle.",
"hexcasting.page.circle_patterns.5": "Returns the position of the upper-south-east corner of the bounds of this spell circle.",
"_comment": "Normal Spells",
"hexcasting.entry.itempicking": "Working with Items",

View file

@ -0,0 +1,22 @@
{
"credit": "Made with Blockbench",
"texture_size": [48, 48],
"textures": {
"0": "hexcasting:entity/scroll",
"particle": "hexcasting:entity/scroll"
},
"elements": [
{
"from": [0, -16, -16],
"to": [1, 32, 32],
"faces": {
"north": {"uv": [15.66667, 0, 16, 16], "texture": "#0"},
"east": {"uv": [0, 0, 16, 16], "texture": "#0"},
"south": {"uv": [0, 0, 0.33333, 16], "texture": "#0"},
"west": {"uv": [0, 0, 16, 16], "texture": "#0"},
"up": {"uv": [0, 0, 16, 0.33333], "rotation": 90, "texture": "#0"},
"down": {"uv": [0, 15.66667, 16, 16], "rotation": 90, "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,22 @@
{
"credit": "Made with Blockbench",
"texture_size": [48, 48],
"textures": {
"0": "hexcasting:entity/scroll_ancient",
"particle": "hexcasting:entity/scroll_ancient"
},
"elements": [
{
"from": [0, -16, -16],
"to": [1, 32, 32],
"faces": {
"north": {"uv": [15.66667, 0, 16, 16], "texture": "#0"},
"east": {"uv": [0, 0, 16, 16], "texture": "#0"},
"south": {"uv": [0, 0, 0.33333, 16], "texture": "#0"},
"west": {"uv": [0, 0, 16, 16], "texture": "#0"},
"up": {"uv": [0, 0, 16, 0.33333], "rotation": 90, "texture": "#0"},
"down": {"uv": [0, 15.66667, 16, 16], "rotation": 90, "texture": "#0"}
}
}
]
}

View file

@ -0,0 +1,46 @@
{
"name": "hexcasting.entry.circle_patterns",
"category": "hexcasting:patterns",
"icon": "hexcasting:empty_impetus",
"sortnum": 9,
"advancement": "hexcasting:enlightenment",
"entry_color": "54398a",
"pages": [
{
"type": "patchouli:text",
"text": "hexcasting.page.circle_patterns.1"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:circle/impetus_pos",
"anchor": "hexcasting:circle/impetus_pos",
"input": "",
"output": "vector",
"text": "hexcasting.page.circle_patterns.2"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:circle/impetus_dir",
"anchor": "hexcasting:circle/impetus_dir",
"input": "",
"output": "vector",
"text": "hexcasting.page.circle_patterns.3"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:circle/bounds/min",
"anchor": "hexcasting:circle/bounds/min",
"input": "",
"output": "vector",
"text": "hexcasting.page.circle_patterns.4"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:circle/bounds/max",
"anchor": "hexcasting:circle/bounds/max",
"input": "",
"output": "vector",
"text": "hexcasting.page.circle_patterns.5"
}
]
}