i am typing words
This commit is contained in:
parent
cb77be134a
commit
c2c3ac6baa
14 changed files with 145 additions and 75 deletions
|
@ -1,58 +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.ItemScroll;
|
||||
import at.petrak.hexcasting.common.items.ItemSlate;
|
||||
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;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import java.util.function.Function;
|
||||
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
|
||||
|
||||
// https://github.com/VazkiiMods/Quark/blob/ace90bfcc26db4c50a179f026134e2577987c2b1/src/main/java/vazkii/quark/content/client/module/ImprovedTooltipsModule.java
|
||||
public class HexTooltips {
|
||||
public static void init() {
|
||||
register(PatternTooltipGreeble.class);
|
||||
}
|
||||
|
||||
private static <T extends ClientTooltipComponent & TooltipComponent> void register(Class<T> clazz) {
|
||||
MinecraftForgeClient.registerTooltipComponentFactory(clazz, Function.identity());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void makeTooltip(RenderTooltipEvent.GatherComponents evt) {
|
||||
ItemStack stack = evt.getItemStack();
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.is(HexItems.SCROLL.get())) {
|
||||
var tag = stack.getOrCreateTag();
|
||||
if (tag.contains(ItemScroll.TAG_PATTERN, Tag.TAG_COMPOUND)) {
|
||||
var pattern = HexPattern.DeserializeFromNBT(tag.getCompound(ItemScroll.TAG_PATTERN));
|
||||
evt.getTooltipElements().add(Either.right(new PatternTooltipGreeble(
|
||||
pattern,
|
||||
tag.contains(ItemScroll.TAG_OP_ID, Tag.TAG_STRING)
|
||||
? PatternTooltipGreeble.ANCIENT_BG : PatternTooltipGreeble.PRISTINE_BG)));
|
||||
}
|
||||
} else if (stack.is(HexItems.SLATE.get()) && ItemSlate.hasPattern(stack)) {
|
||||
var tag = stack.getOrCreateTag()
|
||||
.getCompound("BlockEntityTag")
|
||||
.getCompound(BlockEntitySlate.TAG_PATTERN);
|
||||
var pattern = HexPattern.DeserializeFromNBT(tag);
|
||||
evt.getTooltipElements().add(Either.right(new PatternTooltipGreeble(
|
||||
pattern,
|
||||
PatternTooltipGreeble.SLATE_BG)));
|
||||
|
||||
}
|
||||
}
|
||||
IClientXplatAbstractions.INSTANCE.registerIdentityTooltipMapping(PatternTooltipGreeble.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ItemAbacus extends Item implements DataHolderItem {
|
|||
}
|
||||
tag.putDouble(TAG_VALUE, 0d);
|
||||
|
||||
player.playSound(HexSounds.ABACUS_SHAKE.get(), 1f, 1f);
|
||||
player.playSound(HexSounds.ABACUS_SHAKE, 1f, 1f);
|
||||
|
||||
var key = "hexcasting.tooltip.abacus.reset";
|
||||
if (oldNum == 69) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package at.petrak.hexcasting.common.items;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.api.item.DataHolderItem;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.api.spell.Widget;
|
||||
|
@ -16,9 +15,11 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
public class ItemFocus extends Item implements DataHolderItem {
|
||||
public static final ResourceLocation DATATYPE_PRED = new ResourceLocation(HexMod.MOD_ID, "datatype");
|
||||
public static final ResourceLocation SEALED_PRED = new ResourceLocation(HexMod.MOD_ID, "sealed");
|
||||
public static final ResourceLocation DATATYPE_PRED = modLoc("datatype");
|
||||
public static final ResourceLocation SEALED_PRED = modLoc("sealed");
|
||||
|
||||
public static final String TAG_DATA = "data";
|
||||
public static final String TAG_SEALED = "sealed";
|
||||
|
@ -42,7 +43,8 @@ public class ItemFocus extends Item implements DataHolderItem {
|
|||
|
||||
@Override
|
||||
public String getDescriptionId(ItemStack stack) {
|
||||
return super.getDescriptionId(stack) + (stack.hasTag() && stack.getTag().getBoolean(TAG_SEALED) ? ".sealed" : "");
|
||||
return super.getDescriptionId(stack) + (stack.hasTag() && stack.getTag()
|
||||
.getBoolean(TAG_SEALED) ? ".sealed" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,8 +64,9 @@ public class ItemFocus extends Item implements DataHolderItem {
|
|||
if (datum == null) {
|
||||
tag.remove(TAG_DATA);
|
||||
tag.remove(TAG_SEALED);
|
||||
} else if (!tag.getBoolean(TAG_SEALED))
|
||||
} else if (!tag.getBoolean(TAG_SEALED)) {
|
||||
tag.put(TAG_DATA, datum.serializeToNBT());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package at.petrak.hexcasting.common.items;
|
||||
|
||||
import at.petrak.hexcasting.common.lib.HexMessages;
|
||||
import at.petrak.hexcasting.annotations.SoftImplement;
|
||||
import at.petrak.hexcasting.common.network.MsgUpdateComparatorVisualsAck;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockSource;
|
||||
|
@ -26,8 +27,6 @@ import net.minecraft.world.level.block.DispenserBlock;
|
|||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -47,8 +46,9 @@ public class ItemLens extends Item implements Wearable {
|
|||
});
|
||||
}
|
||||
|
||||
// In fabric impled with extension property?
|
||||
@Nullable
|
||||
@Override
|
||||
@SoftImplement("forge")
|
||||
public EquipmentSlot getEquipmentSlot(ItemStack stack) {
|
||||
return EquipmentSlot.HEAD;
|
||||
}
|
||||
|
@ -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 = player.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue();
|
||||
double reachAttribute = IXplatAbstractions.INSTANCE.getReachDistance(player);
|
||||
double distance = player.isCreative() ? reachAttribute : reachAttribute - 0.5;
|
||||
var hitResult = player.pick(distance, 0, false);
|
||||
if (hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
|
@ -109,13 +109,11 @@ 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));
|
||||
IXplatAbstractions.INSTANCE.sendPacketToPlayer(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));
|
||||
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, new MsgUpdateComparatorVisualsAck(pos, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package at.petrak.hexcasting.common.items;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.api.item.DataHolderItem;
|
||||
import at.petrak.hexcasting.api.spell.DatumType;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.common.entities.EntityWallScroll;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.client.gui.PatternTooltipGreeble;
|
||||
import at.petrak.hexcasting.common.entities.EntityWallScroll;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -16,12 +16,17 @@ 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.inventory.tooltip.TooltipComponent;
|
||||
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;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
/**
|
||||
* TAG_OP_ID and TAG_PATTERN: "Ancient Scroll of %s" (Great Spells)
|
||||
* <br>
|
||||
|
@ -34,7 +39,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
public class ItemScroll extends Item implements DataHolderItem {
|
||||
public static final String TAG_OP_ID = "op_id";
|
||||
public static final String TAG_PATTERN = "pattern";
|
||||
public static final ResourceLocation ANCIENT_PREDICATE = new ResourceLocation(HexMod.MOD_ID, "ancient");
|
||||
public static final ResourceLocation ANCIENT_PREDICATE = modLoc("ancient");
|
||||
|
||||
public ItemScroll(Properties pProperties) {
|
||||
super(pProperties);
|
||||
|
@ -55,7 +60,8 @@ public class ItemScroll extends Item implements DataHolderItem {
|
|||
|
||||
@Override
|
||||
public boolean canWrite(ItemStack stack, SpellDatum<?> datum) {
|
||||
return datum != null && datum.getType() == DatumType.PATTERN && (!stack.hasTag() || !stack.getTag().contains(TAG_PATTERN, Tag.TAG_COMPOUND));
|
||||
return datum != null && datum.getType() == DatumType.PATTERN && (!stack.hasTag() || !stack.getTag()
|
||||
.contains(TAG_PATTERN, Tag.TAG_COMPOUND));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,4 +124,18 @@ public class ItemScroll extends Item implements DataHolderItem {
|
|||
}
|
||||
|
||||
// purposely no hover text
|
||||
|
||||
@Override
|
||||
public Optional<TooltipComponent> getTooltipImage(ItemStack stack) {
|
||||
var tag = stack.getOrCreateTag();
|
||||
if (tag.contains(ItemScroll.TAG_PATTERN, Tag.TAG_COMPOUND)) {
|
||||
var pattern = HexPattern.DeserializeFromNBT(tag.getCompound(ItemScroll.TAG_PATTERN));
|
||||
return Optional.of(new PatternTooltipGreeble(
|
||||
pattern,
|
||||
tag.contains(ItemScroll.TAG_OP_ID, Tag.TAG_STRING)
|
||||
? PatternTooltipGreeble.ANCIENT_BG : PatternTooltipGreeble.PRISTINE_BG));
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package at.petrak.hexcasting.common.items;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.annotations.SoftImplement;
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.api.item.DataHolderItem;
|
||||
import at.petrak.hexcasting.api.spell.DatumType;
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern;
|
||||
import at.petrak.hexcasting.client.gui.PatternTooltipGreeble;
|
||||
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
@ -13,14 +15,19 @@ import net.minecraft.network.chat.TranslatableComponent;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
public class ItemSlate extends BlockItem implements DataHolderItem {
|
||||
public static final ResourceLocation WRITTEN_PRED = new ResourceLocation(HexMod.MOD_ID, "written");
|
||||
public static final ResourceLocation WRITTEN_PRED = modLoc("written");
|
||||
|
||||
public ItemSlate(Block pBlock, Properties pProperties) {
|
||||
super(pBlock, pProperties);
|
||||
|
@ -28,7 +35,7 @@ public class ItemSlate extends BlockItem implements DataHolderItem {
|
|||
|
||||
@Override
|
||||
public Component getName(ItemStack pStack) {
|
||||
var key = "block." + HexMod.MOD_ID + ".slate." + (hasPattern(pStack) ? "written" : "blank");
|
||||
var key = "block." + HexAPI.MOD_ID + ".slate." + (hasPattern(pStack) ? "written" : "blank");
|
||||
return new TranslatableComponent(key);
|
||||
}
|
||||
|
||||
|
@ -42,13 +49,14 @@ public class ItemSlate extends BlockItem implements DataHolderItem {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO: what the hell does this do and how to do it on forge
|
||||
@SoftImplement("forge")
|
||||
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) {
|
||||
var tag = stack.getTagElement("BlockEntityTag");
|
||||
if (tag != null && tag.isEmpty()) {
|
||||
stack.removeTagKey("BlockEntityTag");
|
||||
}
|
||||
return super.onEntityItemUpdate(stack, entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,4 +107,18 @@ public class ItemSlate extends BlockItem implements DataHolderItem {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TooltipComponent> getTooltipImage(ItemStack stack) {
|
||||
if (ItemSlate.hasPattern(stack)) {
|
||||
var tag = stack.getOrCreateTag()
|
||||
.getCompound("BlockEntityTag")
|
||||
.getCompound(BlockEntitySlate.TAG_PATTERN);
|
||||
var pattern = HexPattern.DeserializeFromNBT(tag);
|
||||
return Optional.of(new PatternTooltipGreeble(
|
||||
pattern,
|
||||
PatternTooltipGreeble.SLATE_BG));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package at.petrak.hexcasting.xplat;
|
|||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.particle.ParticleProvider;
|
||||
import net.minecraft.client.particle.SpriteSet;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -10,6 +11,7 @@ import net.minecraft.core.particles.ParticleOptions;
|
|||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
@ -26,6 +28,8 @@ public interface IClientXplatAbstractions {
|
|||
<T extends ParticleOptions> void registerParticleType(ParticleType<T> type,
|
||||
Function<SpriteSet, ParticleProvider<T>> factory);
|
||||
|
||||
<T extends ClientTooltipComponent & TooltipComponent> void registerIdentityTooltipMapping(Class<T> clazz);
|
||||
|
||||
IClientXplatAbstractions INSTANCE = find();
|
||||
|
||||
private static IClientXplatAbstractions find() {
|
||||
|
|
|
@ -14,9 +14,12 @@ import net.minecraft.core.BlockPos;
|
|||
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.player.Player;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -43,6 +46,8 @@ public interface IXplatAbstractions {
|
|||
|
||||
void sendPacketNear(Vec3 pos, double radius, ServerLevel dimension, IMessage packet);
|
||||
|
||||
Attribute getReachDistance();
|
||||
|
||||
// Things that used to be caps
|
||||
|
||||
/**
|
||||
|
@ -86,6 +91,13 @@ public interface IXplatAbstractions {
|
|||
|
||||
int getRawColor(FrozenColorizer colorizer, float time, Vec3 position);
|
||||
|
||||
// Items
|
||||
|
||||
/**
|
||||
* No-op on forge (use a SoftImplement)
|
||||
*/
|
||||
Item.Properties addEquipSlotFabric(Item.Properties props, EquipmentSlot slot);
|
||||
|
||||
// Blocks
|
||||
|
||||
<T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
|
||||
|
|
|
@ -12,6 +12,10 @@ repositories {
|
|||
maven {
|
||||
url 'https://ladysnake.jfrog.io/artifactory/mods'
|
||||
}
|
||||
maven {
|
||||
name "entity reach"
|
||||
url "https://maven.jamieswhiteshirt.com/libs-release/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -30,6 +34,9 @@ dependencies {
|
|||
implementation "me.zeroeightsix:fiber:$fiberVersion"
|
||||
|
||||
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-api:$cardinalComponentsVersion"
|
||||
|
||||
modImplementation "com.jamieswhiteshirt:reach-entity-attributes:2.1.1"
|
||||
include "com.jamieswhiteshirt:reach-entity-attributes:2.1.1"
|
||||
}
|
||||
|
||||
loom {
|
||||
|
|
|
@ -6,6 +6,8 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
|||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.particle.ParticleProvider;
|
||||
import net.minecraft.client.particle.SpriteSet;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -14,6 +16,7 @@ import net.minecraft.core.particles.ParticleOptions;
|
|||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
@ -40,4 +43,14 @@ public class FabricClientXplatImpl implements IClientXplatAbstractions {
|
|||
Function<SpriteSet, ParticleProvider<T>> factory) {
|
||||
ParticleFactoryRegistry.getInstance().register(type, factory::apply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ClientTooltipComponent & TooltipComponent> void registerIdentityTooltipMapping(Class<T> clazz) {
|
||||
TooltipComponentCallback.EVENT.register(data -> {
|
||||
if (clazz.isAssignableFrom(data.getClass())) {
|
||||
return clazz.cast(data);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
|||
import at.petrak.hexcasting.xplat.Platform;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
|
||||
|
@ -24,7 +25,9 @@ import net.minecraft.core.BlockPos;
|
|||
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.player.Player;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -51,6 +54,11 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attribute getReachDistance() {
|
||||
return jaredFixYourSite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacketToPlayer(ServerPlayer target, IMessage packet) {
|
||||
ServerPlayNetworking.send(target, packet.getFabricId(), packet.toBuf());
|
||||
|
@ -225,4 +233,9 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item.Properties addEquipSlotFabric(Item.Properties props, EquipmentSlot slot) {
|
||||
new FabricItemSettings().
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,15 @@ public class ForgeHexClientInitializer {
|
|||
|
||||
var evBus = MinecraftForge.EVENT_BUS;
|
||||
|
||||
evBus.addListener(
|
||||
(RenderLevelLastEvent e) -> HexAdditionalRenderers.overlayLevel(e.getPoseStack(), e.getPartialTick()));
|
||||
evBus.addListener((RenderLevelLastEvent e) ->
|
||||
HexAdditionalRenderers.overlayLevel(e.getPoseStack(), e.getPartialTick()));
|
||||
|
||||
evBus.addListener((RenderGameOverlayEvent.PreLayer e) ->
|
||||
HexAdditionalRenderers.overlayGui(e.getMatrixStack(), e.getPartialTicks()));
|
||||
|
||||
evBus.addListener(EventPriority.LOWEST, (ParticleFactoryRegisterEvent e) ->
|
||||
RegisterClientStuff.registerParticles());
|
||||
|
||||
evBus.addListener((TickEvent.ClientTickEvent e) -> ClientTickCounter.onTick());
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import at.petrak.hexcasting.common.network.IMessage;
|
|||
import at.petrak.hexcasting.forge.network.ForgePacketHandler;
|
||||
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.particle.ParticleProvider;
|
||||
import net.minecraft.client.particle.SpriteSet;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
|
@ -14,7 +15,9 @@ import net.minecraft.core.particles.ParticleOptions;
|
|||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -40,4 +43,9 @@ public class ForgeClientXplatImpl implements IClientXplatAbstractions {
|
|||
Function<SpriteSet, ParticleProvider<T>> factory) {
|
||||
Minecraft.getInstance().particleEngine.register(type, factory::apply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ClientTooltipComponent & TooltipComponent> void registerIdentityTooltipMapping(Class<T> clazz) {
|
||||
MinecraftForgeClient.registerTooltipComponentFactory(clazz, Function.identity());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,12 @@ 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.player.Player;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -43,6 +46,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.TierSortingRegistry;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
@ -63,6 +67,11 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
return FMLLoader.getDist() == Dist.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attribute getReachDistance() {
|
||||
return ForgeMod.REACH_DISTANCE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void brainsweep(Mob mob) {
|
||||
if (Brainsweeping.isValidTarget(mob)) {
|
||||
|
@ -282,6 +291,11 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
return !bs.requiresCorrectToolForDrops() || TierSortingRegistry.isCorrectTierForDrops(tier, bs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item.Properties addEquipSlotFabric(Item.Properties props, EquipmentSlot slot) {
|
||||
return props;
|
||||
}
|
||||
|
||||
public static final String TAG_BRAINSWEPT = "hexcasting:brainswept";
|
||||
public static final String TAG_SENTINEL_EXISTS = "hexcasting:sentinel_exists";
|
||||
public static final String TAG_SENTINEL_GREATER = "hexcasting:sentinel_extends_range";
|
||||
|
|
Loading…
Reference in a new issue