holy shit we are disturbingly close to compiling
This commit is contained in:
parent
c2c3ac6baa
commit
69e1649037
22 changed files with 150 additions and 83 deletions
|
@ -33,7 +33,7 @@ public class OvercastTrigger extends SimpleCriterionTrigger<OvercastTrigger.Inst
|
|||
|
||||
public void trigger(ServerPlayer player, int manaGenerated) {
|
||||
super.trigger(player, inst -> {
|
||||
var manaToHealth = HexConfig.manaToHealthRate.get();
|
||||
var manaToHealth = HexConfig.common().manaToHealthRate();
|
||||
var healthUsed = manaGenerated / manaToHealth;
|
||||
return inst.test(manaGenerated, healthUsed, player.getHealth() - (float) healthUsed);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package at.petrak.hexcasting.api.client;
|
||||
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -45,10 +46,11 @@ public final class ScryingLensOverlayRegistry {
|
|||
public static void receiveComparatorValue(BlockPos pos, int value) {
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
if (player != null) {
|
||||
if (pos == null || value == -1)
|
||||
if (pos == null || value == -1) {
|
||||
comparatorData.remove(player);
|
||||
else
|
||||
} else {
|
||||
comparatorData.put(player, new Pair<>(pos, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,20 +60,25 @@ public final class ScryingLensOverlayRegistry {
|
|||
var level = mc.level;
|
||||
var result = mc.hitResult;
|
||||
|
||||
if (player == null || level == null || result == null || result.getType() != HitResult.Type.BLOCK)
|
||||
if (player == null || level == null || result == null || result.getType() != HitResult.Type.BLOCK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var comparatorValue = comparatorData.get(player);
|
||||
if (comparatorValue == null)
|
||||
if (comparatorValue == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var pos = ((BlockHitResult)result).getBlockPos();
|
||||
if (!pos.equals(comparatorValue.getFirst()))
|
||||
var pos = ((BlockHitResult) result).getBlockPos();
|
||||
if (!pos.equals(comparatorValue.getFirst())) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var state = mc.level.getBlockState(pos);
|
||||
if ((onlyRealComparators && !state.is(Blocks.COMPARATOR)) || (!onlyRealComparators && !state.hasAnalogOutputSignal()))
|
||||
if ((onlyRealComparators && !state.is(
|
||||
Blocks.COMPARATOR)) || (!onlyRealComparators && !state.hasAnalogOutputSignal())) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return comparatorValue.getSecond();
|
||||
}
|
||||
|
@ -82,7 +89,7 @@ public final class ScryingLensOverlayRegistry {
|
|||
* @throws IllegalArgumentException if the block is already registered.
|
||||
*/
|
||||
public static void addDisplayer(Block block, OverlayBuilder displayer) {
|
||||
addDisplayer(block.getRegistryName(), displayer);
|
||||
addDisplayer(IXplatAbstractions.INSTANCE.getID(block), displayer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,10 +118,10 @@ public final class ScryingLensOverlayRegistry {
|
|||
* Internal use only.
|
||||
*/
|
||||
public static @NotNull List<Pair<ItemStack, Component>> getLines(BlockState state, BlockPos pos,
|
||||
LocalPlayer observer, ClientLevel world,
|
||||
Direction hitFace, @Nullable InteractionHand lensHand) {
|
||||
LocalPlayer observer, ClientLevel world,
|
||||
Direction hitFace, @Nullable InteractionHand lensHand) {
|
||||
List<Pair<ItemStack, Component>> lines = Lists.newArrayList();
|
||||
var idLookedup = ID_LOOKUP.get(state.getBlock().getRegistryName());
|
||||
var idLookedup = ID_LOOKUP.get(IXplatAbstractions.INSTANCE.getID(state.getBlock()));
|
||||
if (idLookedup != null) {
|
||||
idLookedup.addLines(lines, state, pos, observer, world, hitFace, lensHand);
|
||||
}
|
||||
|
@ -136,9 +143,9 @@ public final class ScryingLensOverlayRegistry {
|
|||
@FunctionalInterface
|
||||
public interface OverlayBuilder {
|
||||
void addLines(List<Pair<ItemStack, Component>> lines,
|
||||
BlockState state, BlockPos pos, LocalPlayer observer,
|
||||
ClientLevel world,
|
||||
Direction hitFace, @Nullable InteractionHand lensHand);
|
||||
BlockState state, BlockPos pos, LocalPlayer observer,
|
||||
ClientLevel world,
|
||||
Direction hitFace, @Nullable InteractionHand lensHand);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,7 +154,7 @@ public final class ScryingLensOverlayRegistry {
|
|||
@FunctionalInterface
|
||||
public interface OverlayPredicate {
|
||||
boolean test(BlockState state, BlockPos pos, LocalPlayer observer,
|
||||
ClientLevel world,
|
||||
Direction hitFace, @Nullable InteractionHand lensHand);
|
||||
ClientLevel world,
|
||||
Direction hitFace, @Nullable InteractionHand lensHand);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package at.petrak.hexcasting.client;
|
||||
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexMessages;
|
||||
import at.petrak.hexcasting.common.network.MsgShiftScrollSyn;
|
||||
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class ShiftScrollListener {
|
||||
@SubscribeEvent
|
||||
public static void onScroll(InputEvent.MouseScrollEvent evt) {
|
||||
public static boolean onScroll(double delta) {
|
||||
LocalPlayer player = Minecraft.getInstance().player;
|
||||
// not .isCrouching! that fails for players who are not on the ground
|
||||
// yes, this does work if you remap your sneak key
|
||||
|
@ -26,14 +23,16 @@ public class ShiftScrollListener {
|
|||
}
|
||||
|
||||
if (hand != null) {
|
||||
evt.setCanceled(true);
|
||||
HexMessages.getNetwork().sendToServer(new MsgShiftScrollSyn(hand, evt.getScrollDelta(),
|
||||
Screen.hasControlDown()));
|
||||
IClientXplatAbstractions.INSTANCE.sendPacketToServer(
|
||||
new MsgShiftScrollSyn(hand, delta, Screen.hasControlDown()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean IsScrollableItem(Item item) {
|
||||
return item == HexItems.SPELLBOOK.get() || item == HexItems.ABACUS.get();
|
||||
return item == HexItems.SPELLBOOK || item == HexItems.ABACUS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package at.petrak.hexcasting.client.entity;
|
||||
|
||||
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.common.entities.EntityWallScroll;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
@ -22,13 +21,12 @@ import net.minecraft.world.phys.Vec2;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
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");
|
||||
private static final ResourceLocation WHITE = new ResourceLocation(HexMod.MOD_ID,
|
||||
"textures/entity/white.png");
|
||||
private static final ResourceLocation PRISTINE_BG = modLoc("textures/entity/scroll.png");
|
||||
private static final ResourceLocation ANCIENT_BG = modLoc("textures/entity/scroll_ancient.png");
|
||||
private static final ResourceLocation WHITE = modLoc("textures/entity/white.png");
|
||||
|
||||
public WallScrollRenderer(EntityRendererProvider.Context p_174008_) {
|
||||
super(p_174008_);
|
||||
|
@ -120,7 +118,7 @@ public class WallScrollRenderer extends EntityRenderer<EntityWallScroll> {
|
|||
if (wallScroll.getShowsStrokeOrder()) {
|
||||
var animTime = wallScroll.tickCount;
|
||||
var pointCircuit =
|
||||
(animTime * HexConfig.Client.patternPointSpeedMultiplier.get()) % (points.size() + 10);
|
||||
(animTime * HexConfig.client().patternPointSpeedMultiplier()) % (points.size() + 10);
|
||||
if (pointCircuit < points.size() - 1) {
|
||||
var pointMacro = Mth.floor(pointCircuit);
|
||||
var pointMicro = pointCircuit - pointMacro;
|
||||
|
|
|
@ -453,12 +453,12 @@ public class RegisterPatterns {
|
|||
var directions = pat.directions();
|
||||
|
||||
HexDir flatDir;
|
||||
if (pat.angles().isEmpty()) {
|
||||
if (pat.getAngles().isEmpty()) {
|
||||
return null;
|
||||
} else if (pat.angles().get(0) == HexAngle.LEFT_BACK) {
|
||||
} else if (pat.getAngles().get(0) == HexAngle.LEFT_BACK) {
|
||||
flatDir = directions.get(0).rotatedBy(HexAngle.LEFT);
|
||||
} else {
|
||||
flatDir = pat.startDir();
|
||||
flatDir = pat.getStartDir();
|
||||
}
|
||||
|
||||
var mask = new BooleanArrayList();
|
||||
|
|
|
@ -2,9 +2,9 @@ package at.petrak.hexcasting.common.command;
|
|||
|
||||
import at.petrak.hexcasting.api.PatternRegistry;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemScroll;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.common.items.ItemScroll;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
|
@ -12,6 +12,7 @@ import net.minecraft.commands.arguments.ResourceLocationArgument;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
|
@ -24,7 +25,7 @@ public class ListPatternsCommand {
|
|||
var lookup = PatternRegistry.getPerWorldPatterns(ctx.getSource().getLevel());
|
||||
var listing = lookup.entrySet()
|
||||
.stream()
|
||||
.sorted((a, b) -> a.getValue().getFirst().compareNamespaced(b.getValue().getFirst()))
|
||||
.sorted((a, b) -> compareResLoc(a.getValue().getFirst(), b.getValue().getFirst()))
|
||||
.toList();
|
||||
|
||||
ctx.getSource().sendSuccess(new TranslatableComponent("command.hexcasting.pats.listing"), false);
|
||||
|
@ -51,7 +52,7 @@ public class ListPatternsCommand {
|
|||
tag.put(ItemScroll.TAG_PATTERN,
|
||||
pat.serializeToNBT());
|
||||
|
||||
var stack = new ItemStack(HexItems.SCROLL.get());
|
||||
var stack = new ItemStack(HexItems.SCROLL);
|
||||
stack.setTag(tag);
|
||||
|
||||
ctx.getSource().sendSuccess(
|
||||
|
@ -87,7 +88,7 @@ public class ListPatternsCommand {
|
|||
tag.put(ItemScroll.TAG_PATTERN,
|
||||
HexPattern.FromAnglesSig(pattern, startDir).serializeToNBT());
|
||||
|
||||
var stack = new ItemStack(HexItems.SCROLL.get());
|
||||
var stack = new ItemStack(HexItems.SCROLL);
|
||||
stack.setTag(tag);
|
||||
|
||||
var stackEntity = player.drop(stack, false);
|
||||
|
@ -106,4 +107,12 @@ public class ListPatternsCommand {
|
|||
}))
|
||||
);
|
||||
}
|
||||
|
||||
private static int compareResLoc(ResourceLocation a, ResourceLocation b) {
|
||||
var ns = a.getNamespace().compareTo(b.getNamespace());
|
||||
if (ns != 0) {
|
||||
return ns;
|
||||
}
|
||||
return a.getPath().compareTo(b.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class ItemLens extends Item implements Wearable {
|
|||
private static final Map<ServerPlayer, Pair<BlockPos, Integer>> comparatorDataMap = new WeakHashMap<>();
|
||||
|
||||
private void sendComparatorDataToClient(ServerPlayer player) {
|
||||
double reachAttribute = IXplatAbstractions.INSTANCE.getReachDistance(player);
|
||||
double reachAttribute = player.getAttribute(IXplatAbstractions.INSTANCE.getReachDistance()).getValue();
|
||||
double distance = player.isCreative() ? reachAttribute : reachAttribute - 0.5;
|
||||
var hitResult = player.pick(distance, 0, false);
|
||||
if (hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
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;
|
||||
import at.petrak.hexcasting.common.items.magic.*;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -44,7 +44,10 @@ public class HexItems {
|
|||
public static final ItemWand WAND_WARPED = make("wand_warped", new ItemWand(unstackable()));
|
||||
public static final ItemWand WAND_AKASHIC = make("wand_akashic", new ItemWand(unstackable()));
|
||||
|
||||
public static final ItemLens SCRYING_LENS = make("lens", new ItemLens(unstackable()));
|
||||
public static final ItemLens SCRYING_LENS = make("lens", new ItemLens(
|
||||
IXplatAbstractions.INSTANCE.addEquipSlotFabric(EquipmentSlot.HEAD)
|
||||
.stacksTo(1)
|
||||
.tab(IXplatAbstractions.INSTANCE.getTab())));
|
||||
|
||||
public static final ItemAbacus ABACUS = make("abacus", new ItemAbacus(unstackable()));
|
||||
public static final ItemFocus FOCUS = make("focus", new ItemFocus(unstackable()));
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
|
||||
import at.petrak.hexcasting.api.mod.HexItemTags;
|
||||
import at.petrak.hexcasting.api.player.HexPlayerDataHelper;
|
||||
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.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 at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -16,7 +15,6 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -79,7 +77,7 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern
|
|||
}
|
||||
}
|
||||
|
||||
var harness = HexPlayerDataHelper.getHarness(sender, this.handUsed);
|
||||
var harness = IXplatAbstractions.INSTANCE.getHarness(sender, this.handUsed);
|
||||
|
||||
ControllerInfo clientInfo;
|
||||
if (autoFail) {
|
||||
|
@ -90,25 +88,24 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern
|
|||
|
||||
if (clientInfo.getWasSpellCast() && clientInfo.getHasCastingSound()) {
|
||||
sender.level.playSound(null, sender.getX(), sender.getY(), sender.getZ(),
|
||||
HexSounds.ACTUALLY_CAST.get(), SoundSource.PLAYERS, 1f,
|
||||
HexSounds.ACTUALLY_CAST, SoundSource.PLAYERS, 1f,
|
||||
1f + ((float) Math.random() - 0.5f) * 0.2f);
|
||||
}
|
||||
}
|
||||
|
||||
if (clientInfo.isStackClear()) {
|
||||
HexPlayerDataHelper.setHarness(sender, null);
|
||||
HexPlayerDataHelper.setPatterns(sender, List.of());
|
||||
IXplatAbstractions.INSTANCE.setHarness(sender, null);
|
||||
IXplatAbstractions.INSTANCE.setPatterns(sender, List.of());
|
||||
} else {
|
||||
HexPlayerDataHelper.setHarness(sender, harness);
|
||||
IXplatAbstractions.INSTANCE.setHarness(sender, harness);
|
||||
if (!resolvedPatterns.isEmpty()) {
|
||||
resolvedPatterns.get(resolvedPatterns.size() - 1).setValid(clientInfo.getWasPrevPatternInvalid() ?
|
||||
ResolvedPatternValidity.ERROR : ResolvedPatternValidity.OK);
|
||||
}
|
||||
HexPlayerDataHelper.setPatterns(sender, resolvedPatterns);
|
||||
IXplatAbstractions.INSTANCE.setPatterns(sender, resolvedPatterns);
|
||||
}
|
||||
|
||||
HexMessages.getNetwork()
|
||||
.send(PacketDistributor.PLAYER.with(() -> sender), new MsgNewSpellPatternAck(clientInfo));
|
||||
IXplatAbstractions.INSTANCE.sendPacketToPlayer(sender, new MsgNewSpellPatternAck(clientInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
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.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.ChatFormatting;
|
||||
|
@ -49,9 +49,9 @@ public record MsgShiftScrollSyn(InteractionHand hand, double scrollDelta, boolea
|
|||
public void handle(MinecraftServer server, ServerPlayer sender) {
|
||||
var stack = sender.getItemInHand(hand);
|
||||
|
||||
if (stack.getItem() == HexItems.SPELLBOOK.get()) {
|
||||
if (stack.getItem() == HexItems.SPELLBOOK) {
|
||||
spellbook(sender, stack);
|
||||
} else if (stack.getItem() == HexItems.ABACUS.get()) {
|
||||
} else if (stack.getItem() == HexItems.ABACUS) {
|
||||
abacus(sender, stack);
|
||||
}
|
||||
}
|
||||
|
@ -122,9 +122,9 @@ public record MsgShiftScrollSyn(InteractionHand hand, double scrollDelta, boolea
|
|||
pitch *= (increase ? 1.05f : 0.95f);
|
||||
pitch += (Math.random() - 0.5) * 0.1;
|
||||
sender.level.playSound(null, sender.getX(), sender.getY(), sender.getZ(),
|
||||
HexSounds.ABACUS.get(), SoundSource.PLAYERS, 0.5f, pitch);
|
||||
HexSounds.ABACUS, SoundSource.PLAYERS, 0.5f, pitch);
|
||||
|
||||
var datumTag = HexItems.ABACUS.get().readDatumTag(stack);
|
||||
var datumTag = HexItems.ABACUS.readDatumTag(stack);
|
||||
if (datumTag != null) {
|
||||
var popup = SpellDatum.DisplayFromTag(datumTag);
|
||||
sender.displayClientMessage(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.recipe;
|
||||
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemFocus;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -27,7 +27,7 @@ public class SealFocusRecipe extends CustomRecipe {
|
|||
for (int i = 0; i < inv.getContainerSize(); i++) {
|
||||
var stack = inv.getItem(i);
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.is(HexItems.FOCUS.get())) {
|
||||
if (stack.is(HexItems.FOCUS)) {
|
||||
if (foundOkFocus) {
|
||||
return false;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class SealFocusRecipe extends CustomRecipe {
|
|||
|
||||
for (int i = 0; i < inv.getContainerSize(); i++) {
|
||||
var stack = inv.getItem(i);
|
||||
if (stack.is(HexItems.FOCUS.get())) {
|
||||
if (stack.is(HexItems.FOCUS)) {
|
||||
out = stack.copy();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.recipe;
|
||||
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.items.ItemSpellbook;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -27,7 +27,7 @@ public class SealSpellbookRecipe extends CustomRecipe {
|
|||
for (int i = 0; i < inv.getContainerSize(); i++) {
|
||||
var stack = inv.getItem(i);
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.is(HexItems.SPELLBOOK.get())) {
|
||||
if (stack.is(HexItems.SPELLBOOK)) {
|
||||
if (foundOkSpellbook) {
|
||||
return false;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class SealSpellbookRecipe extends CustomRecipe {
|
|||
|
||||
for (int i = 0; i < inv.getContainerSize(); i++) {
|
||||
var stack = inv.getItem(i);
|
||||
if (stack.is(HexItems.SPELLBOOK.get())) {
|
||||
if (stack.is(HexItems.SPELLBOOK)) {
|
||||
out = stack.copy();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package at.petrak.hexcasting.common.recipe.ingredient;
|
||||
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
@ -21,8 +22,9 @@ public record VillagerIngredient(
|
|||
@Override
|
||||
public boolean test(Villager villager) {
|
||||
var data = villager.getVillagerData();
|
||||
|
||||
return (this.profession == null || this.profession.equals(data.getProfession().getRegistryName()))
|
||||
ResourceLocation profID = IXplatAbstractions.INSTANCE.getID(data.getProfession());
|
||||
|
||||
return (this.profession == null || this.profession.equals(profID))
|
||||
&& (this.biome == null || this.biome.equals(Registry.VILLAGER_TYPE.getKey(data.getType())))
|
||||
&& this.minLevel <= data.getLevel();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
package at.petrak.hexcasting.interop.patchouli;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||
|
@ -47,7 +47,7 @@ public class MultiCraftingProcessor implements IComponentProcessor {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
HexMod.getLogger().warn("Missing crafting recipe " + name);
|
||||
HexAPI.LOGGER.warn("Missing crafting recipe " + name);
|
||||
}
|
||||
}
|
||||
this.hasCustomHeading = variables.has("heading");
|
||||
|
|
|
@ -11,12 +11,14 @@ import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
|||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -96,19 +98,24 @@ public interface IXplatAbstractions {
|
|||
/**
|
||||
* No-op on forge (use a SoftImplement)
|
||||
*/
|
||||
Item.Properties addEquipSlotFabric(Item.Properties props, EquipmentSlot slot);
|
||||
Item.Properties addEquipSlotFabric(EquipmentSlot slot);
|
||||
|
||||
// Blocks
|
||||
|
||||
<T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
|
||||
Block... blocks);
|
||||
|
||||
|
||||
// misc
|
||||
|
||||
CreativeModeTab getTab();
|
||||
|
||||
boolean isCorrectTierForDrops(Tier tier, BlockState bs);
|
||||
|
||||
ResourceLocation getID(Block block);
|
||||
|
||||
ResourceLocation getID(VillagerProfession profession);
|
||||
|
||||
|
||||
IXplatAbstractions INSTANCE = find();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Optional;
|
|||
|
||||
// https://github.com/VazkiiMods/Botania/blob/1.18.x/Fabric/src/main/java/vazkii/botania/fabric/mixin/FabricMixinAxeItem.java
|
||||
@Mixin(AxeItem.class)
|
||||
public class AxeItemMixin {
|
||||
public class FabricAxeItemMixin {
|
||||
@Inject(method = "getStripped", at = @At("RETURN"), cancellable = true)
|
||||
private void stripBlock(BlockState state, CallbackInfoReturnable<Optional<BlockState>> cir) {
|
||||
if (cir.getReturnValue().isEmpty()) {
|
|
@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(Villager.class)
|
||||
public class VillagerTurnIntoWitchMixin {
|
||||
public class FabricVillagerTurnIntoWitchMixin {
|
||||
@Inject(method = "thunderHit", locals = LocalCapture.PRINT, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"))
|
||||
public void onThunderHit(CallbackInfo cb) {
|
||||
// todo
|
|
@ -0,0 +1,17 @@
|
|||
package at.petrak.hexcasting.fabric.mixin.client;
|
||||
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(MouseHandler.class)
|
||||
public class FabricMouseHandlerMixin {
|
||||
// TODO post event
|
||||
@Inject(method = "onScroll", cancellable = true, locals = LocalCapture.PRINT, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isSpectator()Z"))
|
||||
private void onScroll(CallbackInfo ci, double delta) {
|
||||
|
||||
}
|
||||
}
|
|
@ -22,12 +22,15 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
|||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -190,6 +193,16 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
return FabricBlockEntityTypeBuilder.create(func::apply, blocks).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID(Block block) {
|
||||
return Registry.BLOCK.getKey(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID(VillagerProfession profession) {
|
||||
return Registry.VILLAGER_PROFESSION.getKey(profession);
|
||||
}
|
||||
|
||||
private static CreativeModeTab TAB = null;
|
||||
|
||||
@Override
|
||||
|
@ -235,7 +248,7 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Item.Properties addEquipSlotFabric(Item.Properties props, EquipmentSlot slot) {
|
||||
new FabricItemSettings().
|
||||
public Item.Properties addEquipSlotFabric(EquipmentSlot slot) {
|
||||
return new FabricItemSettings().equipmentSlot(s -> slot);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
"compatibilityLevel": "JAVA_17",
|
||||
"refmap": "hexcasting.mixins.refmap.json",
|
||||
"package": "at.petrak.hexcasting.fabric.mixin",
|
||||
"mixins": ["AxeItemMixin", "VillagerTurnIntoWitchMixin"]
|
||||
"mixins": ["FabricAxeItemMixin", "FabricVillagerTurnIntoWitchMixin"],
|
||||
"client": ["client.FabricMouseHandlerMixin"]
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@ package at.petrak.hexcasting;
|
|||
import at.petrak.hexcasting.client.ClientTickCounter;
|
||||
import at.petrak.hexcasting.client.HexAdditionalRenderers;
|
||||
import at.petrak.hexcasting.client.RegisterClientStuff;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderLevelLastEvent;
|
||||
import at.petrak.hexcasting.client.ShiftScrollListener;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
|
@ -31,6 +29,11 @@ public class ForgeHexClientInitializer {
|
|||
RegisterClientStuff.registerParticles());
|
||||
|
||||
evBus.addListener((TickEvent.ClientTickEvent e) -> ClientTickCounter.onTick());
|
||||
|
||||
evBus.addListener((InputEvent.MouseScrollEvent e) -> {
|
||||
var cancel = ShiftScrollListener.onScroll(e.getScrollDelta());
|
||||
e.setCanceled(cancel);
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -35,6 +35,7 @@ import net.minecraft.world.InteractionHand;
|
|||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -264,6 +265,16 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
return BlockEntityType.Builder.of(func::apply, blocks).build(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID(Block block) {
|
||||
return block.getRegistryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID(VillagerProfession profession) {
|
||||
return profession.getRegistryName();
|
||||
}
|
||||
|
||||
private static CreativeModeTab TAB = null;
|
||||
|
||||
@Override
|
||||
|
@ -292,8 +303,8 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Item.Properties addEquipSlotFabric(Item.Properties props, EquipmentSlot slot) {
|
||||
return props;
|
||||
public Item.Properties addEquipSlotFabric(EquipmentSlot slot) {
|
||||
return new Item.Properties();
|
||||
}
|
||||
|
||||
public static final String TAG_BRAINSWEPT = "hexcasting:brainswept";
|
||||
|
|
Loading…
Reference in a new issue