MOAR abstraction
This commit is contained in:
parent
c8d8562c99
commit
4acaa05897
23 changed files with 262 additions and 158 deletions
|
@ -1,33 +0,0 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class BlockBurns extends Block {
|
||||
private final int flammability;
|
||||
private final int spreadSpeed;
|
||||
|
||||
public BlockBurns(Properties props, int flammability, int spreadSpeed) {
|
||||
super(props);
|
||||
this.flammability = flammability;
|
||||
this.spreadSpeed = spreadSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
|
||||
return flammability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
|
||||
return spreadSpeed;
|
||||
}
|
||||
}
|
|
@ -10,10 +10,9 @@ import at.petrak.hexcasting.common.blocks.circles.directrix.BlockRedstoneDirectr
|
|||
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.BlockAxis;
|
||||
import at.petrak.hexcasting.common.blocks.decoration.BlockSconce;
|
||||
import at.petrak.hexcasting.common.blocks.decoration.BlockStrippable;
|
||||
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;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
@ -153,14 +152,15 @@ public class HexBlocks {
|
|||
public static final AmethystBlock AMETHYST_TILES = blockItem("amethyst_tiles",
|
||||
new AmethystBlock(BlockBehaviour.Properties.copy(Blocks.AMETHYST_BLOCK)));
|
||||
public static final Block SCROLL_PAPER = blockItem("scroll_paper",
|
||||
new BlockBurns(papery(MaterialColor.TERRACOTTA_WHITE), 100, 60));
|
||||
IXplatAbstractions.INSTANCE.makeFlammable(papery(MaterialColor.TERRACOTTA_WHITE), 100, 60));
|
||||
public static final Block ANCIENT_SCROLL_PAPER = blockItem("ancient_scroll_paper",
|
||||
new BlockBurns(papery(MaterialColor.TERRACOTTA_ORANGE), 100, 60));
|
||||
IXplatAbstractions.INSTANCE.makeFlammable(papery(MaterialColor.TERRACOTTA_ORANGE), 100, 60));
|
||||
public static final Block SCROLL_PAPER_LANTERN = blockItem("scroll_paper_lantern",
|
||||
new BlockBurns(papery(MaterialColor.TERRACOTTA_WHITE).lightLevel($ -> 15), 100, 60));
|
||||
IXplatAbstractions.INSTANCE.makeFlammable(papery(MaterialColor.TERRACOTTA_WHITE).lightLevel($ -> 15), 100, 60));
|
||||
public static final Block ANCIENT_SCROLL_PAPER_LANTERN = blockItem(
|
||||
"ancient_scroll_paper_lantern",
|
||||
new BlockBurns(papery(MaterialColor.TERRACOTTA_ORANGE).lightLevel($ -> 12), 100, 60));
|
||||
IXplatAbstractions.INSTANCE.makeFlammable(papery(MaterialColor.TERRACOTTA_ORANGE).lightLevel($ -> 12), 100,
|
||||
60));
|
||||
public static final BlockSconce SCONCE = blockItem("amethyst_sconce",
|
||||
new BlockSconce(BlockBehaviour.Properties.of(Material.AMETHYST, MaterialColor.COLOR_PURPLE)
|
||||
.sound(SoundType.AMETHYST)
|
||||
|
@ -172,28 +172,27 @@ public class HexBlocks {
|
|||
public static final BlockStrippable AKASHIC_LOG = blockItem("akashic_log",
|
||||
new BlockAkashicWood(akashicWoody(), () -> AKASHIC_LOG_STRIPPED));
|
||||
public static final Block AKASHIC_WOOD_STRIPPED = blockItem("akashic_wood_stripped",
|
||||
new BlockBurns(akashicWoody(), 5, 5));
|
||||
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 5, 5));
|
||||
public static final BlockStrippable AKASHIC_WOOD = blockItem("akashic_wood",
|
||||
new BlockStrippable(akashicWoody(), () -> AKASHIC_WOOD_STRIPPED));
|
||||
public static final Block AKASHIC_PLANKS = blockItem("akashic_planks",
|
||||
new BlockBurns(akashicWoody(), 20, 5));
|
||||
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 20, 5));
|
||||
public static final Block AKASHIC_PANEL = blockItem("akashic_panel",
|
||||
new BlockBurns(akashicWoody(), 20, 5));
|
||||
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 20, 5));
|
||||
public static final Block AKASHIC_TILE = blockItem("akashic_tile",
|
||||
new BlockBurns(akashicWoody(), 20, 5));
|
||||
// todo: mixin? AT?
|
||||
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 20, 5));
|
||||
public static final DoorBlock AKASHIC_DOOR = blockItem("akashic_door",
|
||||
new DoorBlock(akashicWoody().noOcclusion()));
|
||||
new BlockHexDoor(akashicWoody().noOcclusion()));
|
||||
public static final TrapDoorBlock AKASHIC_TRAPDOOR = blockItem("akashic_trapdoor",
|
||||
new TrapDoorBlock(akashicWoody().noOcclusion()));
|
||||
new BlockHexTrapdoor(akashicWoody().noOcclusion()));
|
||||
public static final StairBlock AKASHIC_STAIRS = blockItem("akashic_stairs",
|
||||
new StairBlock(AKASHIC_PLANKS.defaultBlockState(), akashicWoody().noOcclusion()));
|
||||
new BlockHexStairs(AKASHIC_PLANKS.defaultBlockState(), akashicWoody().noOcclusion()));
|
||||
public static final SlabBlock AKASHIC_SLAB = blockItem("akashic_slab",
|
||||
new SlabBlock(akashicWoody().noOcclusion()));
|
||||
public static final WoodButtonBlock AKASHIC_BUTTON = blockItem("akashic_button",
|
||||
new WoodButtonBlock(akashicWoody().noOcclusion()));
|
||||
new BlockHexWoodButton(akashicWoody().noOcclusion()));
|
||||
public static final PressurePlateBlock AKASHIC_PRESSURE_PLATE = blockItem("akashic_pressure_plate",
|
||||
new PressurePlateBlock(PressurePlateBlock.Sensitivity.EVERYTHING, akashicWoody().noOcclusion()));
|
||||
new BlockHexPressurePlate(PressurePlateBlock.Sensitivity.EVERYTHING, akashicWoody().noOcclusion()));
|
||||
public static final BlockAkashicLeaves AKASHIC_LEAVES1 = blockItem("akashic_leaves1",
|
||||
new BlockAkashicLeaves(leaves(MaterialColor.COLOR_PURPLE)));
|
||||
public static final BlockAkashicLeaves AKASHIC_LEAVES2 = blockItem("akashic_leaves2",
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package at.petrak.hexcasting.common.blocks.decoration;
|
||||
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
|
||||
public class BlockHexDoor extends DoorBlock {
|
||||
public BlockHexDoor(Properties $$0) {
|
||||
super($$0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package at.petrak.hexcasting.common.blocks.decoration;
|
||||
|
||||
import net.minecraft.world.level.block.PressurePlateBlock;
|
||||
|
||||
public class BlockHexPressurePlate extends PressurePlateBlock {
|
||||
public BlockHexPressurePlate(Sensitivity $$0, Properties $$1) {
|
||||
super($$0, $$1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package at.petrak.hexcasting.common.blocks.decoration;
|
||||
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class BlockHexStairs extends StairBlock {
|
||||
public BlockHexStairs(BlockState $$0, Properties $$1) {
|
||||
super($$0, $$1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package at.petrak.hexcasting.common.blocks.decoration;
|
||||
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
|
||||
public class BlockHexTrapdoor extends TrapDoorBlock {
|
||||
public BlockHexTrapdoor(Properties $$0) {
|
||||
super($$0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package at.petrak.hexcasting.common.blocks.decoration;
|
||||
|
||||
import net.minecraft.world.level.block.WoodButtonBlock;
|
||||
|
||||
public class BlockHexWoodButton extends WoodButtonBlock {
|
||||
public BlockHexWoodButton(Properties $$0) {
|
||||
super($$0);
|
||||
}
|
||||
}
|
|
@ -1,21 +1,20 @@
|
|||
package at.petrak.hexcasting.common.items;
|
||||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.common.blocks.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 net.minecraft.core.NonNullList;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
|
@ -31,31 +30,6 @@ public class HexItems {
|
|||
|
||||
private static final Map<ResourceLocation, Item> ITEMS = new LinkedHashMap<>(); // preserve insertion order
|
||||
|
||||
public static final CreativeModeTab TAB = new CreativeModeTab(HexAPI.MOD_ID) {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(SPELLBOOK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemList(NonNullList<ItemStack> items) {
|
||||
super.fillItemList(items);
|
||||
|
||||
var manamounts = new int[]{
|
||||
100_000,
|
||||
1_000_000,
|
||||
10_000_000,
|
||||
100_000_000,
|
||||
1_000_000_000,
|
||||
};
|
||||
for (int manamount : manamounts) {
|
||||
var stack = new ItemStack(BATTERY);
|
||||
items.add(ItemManaHolder.withMana(stack, manamount, manamount));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static final Item AMETHYST_DUST = make("amethyst_dust", new Item(props()));
|
||||
public static final Item CHARGED_AMETHYST = make("charged_amethyst", new Item(props()));
|
||||
|
||||
|
@ -109,7 +83,7 @@ public class HexItems {
|
|||
//
|
||||
|
||||
public static Item.Properties props() {
|
||||
return new Item.Properties().tab(TAB);
|
||||
return new Item.Properties().tab(IXplatAbstractions.INSTANCE.getTab());
|
||||
}
|
||||
|
||||
public static Item.Properties unstackable() {
|
||||
|
@ -127,4 +101,22 @@ public class HexItems {
|
|||
private static <T extends Item> T make(String id, T item) {
|
||||
return make(modLoc(id), item);
|
||||
}
|
||||
|
||||
public static ItemStack tabIcon() {
|
||||
return new ItemStack(SPELLBOOK);
|
||||
}
|
||||
|
||||
public static void fillTab(List<ItemStack> items) {
|
||||
var manamounts = new int[]{
|
||||
100_000,
|
||||
1_000_000,
|
||||
10_000_000,
|
||||
100_000_000,
|
||||
1_000_000_000,
|
||||
};
|
||||
for (int manamount : manamounts) {
|
||||
var stack = new ItemStack(BATTERY);
|
||||
items.add(ItemManaHolder.withMana(stack, manamount, manamount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +1,50 @@
|
|||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import static at.petrak.hexcasting.common.lib.RegisterHelper.prefix;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
public class HexSounds {
|
||||
public static final DeferredRegister<SoundEvent> SOUNDS = DeferredRegister.create(
|
||||
ForgeRegistries.SOUND_EVENTS,
|
||||
HexMod.MOD_ID);
|
||||
public static void registerSounds(BiConsumer<SoundEvent, ResourceLocation> r) {
|
||||
for (var e : SOUNDS.entrySet()) {
|
||||
r.accept(e.getValue(), e.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public static final RegistryObject<SoundEvent> ADD_LINE = sound("casting.add_line");
|
||||
public static final RegistryObject<SoundEvent> START_PATTERN = sound("casting.start_pattern");
|
||||
public static final RegistryObject<SoundEvent> ADD_PATTERN = sound("casting.add_pattern");
|
||||
public static final RegistryObject<SoundEvent> FAIL_PATTERN = sound("casting.fail_pattern");
|
||||
public static final RegistryObject<SoundEvent> CASTING_AMBIANCE = sound("casting.ambiance");
|
||||
public static final RegistryObject<SoundEvent> ACTUALLY_CAST = sound("casting.cast");
|
||||
private static final Map<ResourceLocation, SoundEvent> SOUNDS = new LinkedHashMap<>();
|
||||
|
||||
public static final RegistryObject<SoundEvent> ABACUS = sound("abacus");
|
||||
public static final RegistryObject<SoundEvent> ABACUS_SHAKE = sound("abacus.shake");
|
||||
public static final SoundEvent ADD_LINE = sound("casting.add_line");
|
||||
public static final SoundEvent START_PATTERN = sound("casting.start_pattern");
|
||||
public static final SoundEvent ADD_PATTERN = sound("casting.add_pattern");
|
||||
public static final SoundEvent FAIL_PATTERN = sound("casting.fail_pattern");
|
||||
public static final SoundEvent CASTING_AMBIANCE = sound("casting.ambiance");
|
||||
public static final SoundEvent ACTUALLY_CAST = sound("casting.cast");
|
||||
|
||||
public static final RegistryObject<SoundEvent> SPELL_CIRCLE_FIND_BLOCK = sound("spellcircle.find_block");
|
||||
public static final RegistryObject<SoundEvent> SPELL_CIRCLE_FAIL = sound("spellcircle.fail");
|
||||
public static final RegistryObject<SoundEvent> SPELL_CIRCLE_CAST = sound("spellcircle.cast");
|
||||
public static final SoundEvent ABACUS = sound("abacus");
|
||||
public static final SoundEvent ABACUS_SHAKE = sound("abacus.shake");
|
||||
|
||||
public static final RegistryObject<SoundEvent> SCROLL_DUST = sound("scroll.dust");
|
||||
public static final RegistryObject<SoundEvent> SCROLL_SCRIBBLE = sound("scroll.scribble");
|
||||
public static final SoundEvent SPELL_CIRCLE_FIND_BLOCK = sound("spellcircle.find_block");
|
||||
public static final SoundEvent SPELL_CIRCLE_FAIL = sound("spellcircle.fail");
|
||||
public static final SoundEvent SPELL_CIRCLE_CAST = sound("spellcircle.cast");
|
||||
|
||||
public static final RegistryObject<SoundEvent> IMPETUS_LOOK_TICK = sound("impetus.fletcher.tick");
|
||||
public static final RegistryObject<SoundEvent> IMPETUS_STOREDPLAYER_DING = sound("impetus.cleric.register");
|
||||
public static final SoundEvent SCROLL_DUST = sound("scroll.dust");
|
||||
public static final SoundEvent SCROLL_SCRIBBLE = sound("scroll.scribble");
|
||||
|
||||
private static RegistryObject<SoundEvent> sound(String name) {
|
||||
return SOUNDS.register(name, () -> new SoundEvent(prefix(name)));
|
||||
public static final SoundEvent IMPETUS_LOOK_TICK = sound("impetus.fletcher.tick");
|
||||
public static final SoundEvent IMPETUS_STOREDPLAYER_DING = sound("impetus.cleric.register");
|
||||
|
||||
private static SoundEvent sound(String name) {
|
||||
var id = modLoc(name);
|
||||
var sound = new SoundEvent(id);
|
||||
var old = SOUNDS.put(id, sound);
|
||||
if (old != null) {
|
||||
throw new IllegalArgumentException("Typo? Duplicate id " + name);
|
||||
}
|
||||
return sound;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
public class RegisterHelper {
|
||||
// yoinked from botnia
|
||||
public static <V extends IForgeRegistryEntry<V>> void register(IForgeRegistry<V> reg, ResourceLocation name,
|
||||
IForgeRegistryEntry<V> thing) {
|
||||
reg.register(thing.setRegistryName(name));
|
||||
}
|
||||
|
||||
public static <V extends IForgeRegistryEntry<V>> void register(IForgeRegistry<V> reg, String name,
|
||||
IForgeRegistryEntry<V> thing) {
|
||||
register(reg, prefix(name), thing);
|
||||
}
|
||||
|
||||
public static ResourceLocation prefix(String path) {
|
||||
return new ResourceLocation(HexMod.MOD_ID, path);
|
||||
}
|
||||
}
|
|
@ -61,7 +61,7 @@ public record MsgNewSpellPatternAck(ControllerInfo info) implements IMessage {
|
|||
var mc = Minecraft.getInstance();
|
||||
if (self.info().isStackClear()) {
|
||||
// don't pay attention to the screen, so it also stops when we die
|
||||
mc.getSoundManager().stop(HexSounds.CASTING_AMBIANCE.getId(), null);
|
||||
mc.getSoundManager().stop(HexSounds.CASTING_AMBIANCE.getLocation(), null);
|
||||
}
|
||||
var screen = Minecraft.getInstance().screen;
|
||||
if (screen instanceof GuiSpellcasting spellGui) {
|
||||
|
|
|
@ -8,15 +8,16 @@ import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
|||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
||||
import at.petrak.hexcasting.common.command.PatternResLocArgument;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.common.network.MsgColorizerUpdateAck;
|
||||
import at.petrak.hexcasting.common.network.MsgSentinelStatusUpdateAck;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypes;
|
||||
import net.minecraft.commands.synchronization.EmptyArgumentSerializer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
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.state.BlockBehaviour;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -71,13 +72,13 @@ public interface IXplatAbstractions {
|
|||
|
||||
int getRawColor(FrozenColorizer colorizer, float time, Vec3 position);
|
||||
|
||||
default void syncSentinel(ServerPlayer player) {
|
||||
this.sendPacketToPlayer(player, new MsgSentinelStatusUpdateAck(this.getSentinel(player)));
|
||||
}
|
||||
// Blocks
|
||||
|
||||
default void syncColorizer(ServerPlayer player) {
|
||||
this.sendPacketToPlayer(player, new MsgColorizerUpdateAck(this.getColorizer(player)));
|
||||
}
|
||||
Block makeFlammable(BlockBehaviour.Properties properties, int flammability, int spreadSpeed);
|
||||
|
||||
// misc
|
||||
|
||||
CreativeModeTab getTab();
|
||||
|
||||
default void init() {
|
||||
HexAPI.LOGGER.info("Hello Hexcasting! This is {}!", this.platform());
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
"block.hexcasting.akashic_leaves3": "Citrine Edified Leaves",
|
||||
|
||||
"itemGroup.hexcasting": "Hexcasting",
|
||||
"itemGroup.hexcasting.creative_tab": "Hexcasting",
|
||||
|
||||
"hexcasting.tooltip.spellbook.page": "Selected Page %d/%d",
|
||||
"hexcasting.tooltip.spellbook.page.sealed": "Selected Page %d/%d (%s)",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import at.petrak.hexcasting.common.blocks.HexBlocks
|
||||
import at.petrak.hexcasting.common.items.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexSounds
|
||||
import at.petrak.hexcasting.common.misc.Brainsweeping
|
||||
import at.petrak.hexcasting.fabric.FabricHexConfig
|
||||
import at.petrak.hexcasting.fabric.network.FabricPacketHandler
|
||||
|
@ -26,6 +27,7 @@ object FabricHexInitializer : ModInitializer {
|
|||
}
|
||||
|
||||
fun initRegistries() {
|
||||
HexSounds.registerSounds(bind(Registry.SOUND_EVENT))
|
||||
HexBlocks.registerBlocks(bind(Registry.BLOCK))
|
||||
HexBlocks.registerBlockItems(bind(Registry.ITEM))
|
||||
HexItems.registerItems(bind(Registry.ITEM))
|
||||
|
|
|
@ -29,18 +29,12 @@ public class FabricPacketHandler {
|
|||
makeClientBoundHandler(MsgNewSpellPatternAck::deserialize, MsgNewSpellPatternAck::handle));
|
||||
ClientPlayNetworking.registerGlobalReceiver(
|
||||
MsgBlinkAck.ID, makeClientBoundHandler(MsgBlinkAck::deserialize, MsgBlinkAck::handle));
|
||||
ClientPlayNetworking.registerGlobalReceiver(MsgSentinelStatusUpdateAck.ID,
|
||||
makeClientBoundHandler(MsgSentinelStatusUpdateAck::deserialize, MsgSentinelStatusUpdateAck::handle));
|
||||
ClientPlayNetworking.registerGlobalReceiver(MsgColorizerUpdateAck.ID,
|
||||
makeClientBoundHandler(MsgColorizerUpdateAck::deserialize, MsgColorizerUpdateAck::handle));
|
||||
ClientPlayNetworking.registerGlobalReceiver(MsgCastParticleAck.ID,
|
||||
makeClientBoundHandler(MsgCastParticleAck::deserialize, MsgCastParticleAck::handle));
|
||||
ClientPlayNetworking.registerGlobalReceiver(MsgOpenSpellGuiAck.ID,
|
||||
makeClientBoundHandler(MsgOpenSpellGuiAck::deserialize, MsgOpenSpellGuiAck::handle));
|
||||
ClientPlayNetworking.registerGlobalReceiver(MsgBeepAck.ID,
|
||||
makeClientBoundHandler(MsgBeepAck::deserialize, MsgBeepAck::handle));
|
||||
ClientPlayNetworking.registerGlobalReceiver(MsgBrainsweepAck.ID,
|
||||
makeClientBoundHandler(MsgBrainsweepAck::deserialize, MsgBrainsweepAck::handle));
|
||||
ClientPlayNetworking.registerGlobalReceiver(MsgUpdateComparatorVisualsAck.ID,
|
||||
makeClientBoundHandler(MsgUpdateComparatorVisualsAck::deserialize, MsgUpdateComparatorVisualsAck::handle));
|
||||
}
|
||||
|
|
|
@ -5,23 +5,31 @@ 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.network.IMessage;
|
||||
import at.petrak.hexcasting.fabric.cc.HexCardinalComponents;
|
||||
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.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
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.state.BlockBehaviour;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
public class FabricXplatImpl implements IXplatAbstractions {
|
||||
@Override
|
||||
public Platform platform() {
|
||||
|
@ -132,4 +140,26 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
var cc = HexCardinalComponents.COLORIZER.maybeGet(colorizer.item());
|
||||
return cc.map(col -> col.color(colorizer.owner(), time, position)).orElse(0xff_ff00dc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeFlammable(BlockBehaviour.Properties properties, int flammability, int spreadSpeed) {
|
||||
var out = new Block(properties);
|
||||
FlammableBlockRegistry.getDefaultInstance().add(out, flammability, spreadSpeed);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
private static CreativeModeTab TAB = null;
|
||||
|
||||
@Override
|
||||
public CreativeModeTab getTab() {
|
||||
if (TAB == null) {
|
||||
TAB = FabricItemGroupBuilder.create(modLoc("creative_tab"))
|
||||
.icon(HexItems::tabIcon)
|
||||
.appendItems(HexItems::fillTab)
|
||||
.build();
|
||||
}
|
||||
|
||||
return TAB;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ 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.HexSounds
|
||||
import at.petrak.hexcasting.common.misc.Brainsweeping
|
||||
import at.petrak.hexcasting.forge.ForgeHexConfig
|
||||
import at.petrak.hexcasting.forge.cap.CapSyncers
|
||||
|
@ -53,6 +54,7 @@ object ForgeHexInitializer {
|
|||
}
|
||||
|
||||
fun initRegistry() {
|
||||
bind(ForgeRegistries.SOUND_EVENTS, HexSounds::registerSounds)
|
||||
bind(ForgeRegistries.BLOCKS, HexBlocks::registerBlocks)
|
||||
bind(ForgeRegistries.ITEMS, HexBlocks::registerBlockItems)
|
||||
bind(ForgeRegistries.ITEMS, HexItems::registerItems)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package at.petrak.hexcasting.forge.cap;
|
||||
|
||||
import at.petrak.hexcasting.forge.network.MsgColorizerUpdateAck;
|
||||
import at.petrak.hexcasting.forge.network.MsgSentinelStatusUpdateAck;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
|
@ -35,8 +37,8 @@ public class CapSyncers {
|
|||
return;
|
||||
}
|
||||
|
||||
IXplatAbstractions.INSTANCE.syncSentinel(player);
|
||||
IXplatAbstractions.INSTANCE.syncColorizer(player);
|
||||
syncSentinel(player);
|
||||
syncColorizer(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -45,7 +47,17 @@ public class CapSyncers {
|
|||
return;
|
||||
}
|
||||
|
||||
IXplatAbstractions.INSTANCE.syncSentinel(player);
|
||||
IXplatAbstractions.INSTANCE.syncColorizer(player);
|
||||
syncSentinel(player);
|
||||
syncColorizer(player);
|
||||
}
|
||||
|
||||
public static void syncSentinel(ServerPlayer player) {
|
||||
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player,
|
||||
new MsgSentinelStatusUpdateAck(IXplatAbstractions.INSTANCE.getSentinel(player)));
|
||||
}
|
||||
|
||||
public static void syncColorizer(ServerPlayer player) {
|
||||
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player,
|
||||
new MsgColorizerUpdateAck(IXplatAbstractions.INSTANCE.getColorizer(player)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
package at.petrak.hexcasting.forge.network;
|
||||
|
||||
import at.petrak.hexcasting.common.misc.Brainsweeping;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
|
@ -44,7 +45,7 @@ public record MsgBrainsweepAck(int target) implements IMessage {
|
|||
var level = Minecraft.getInstance().level;
|
||||
if (level != null) {
|
||||
Entity entity = level.getEntity(msg.target());
|
||||
if (entity instanceof LivingEntity living) {
|
||||
if (entity instanceof Mob living) {
|
||||
Brainsweeping.brainsweep(living);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
package at.petrak.hexcasting.forge.network;
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.player.HexPlayerDataHelper;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
@ -39,7 +40,7 @@ public record MsgColorizerUpdateAck(FrozenColorizer update) implements IMessage
|
|||
public void run() {
|
||||
var player = Minecraft.getInstance().player;
|
||||
if (player != null) {
|
||||
HexPlayerDataHelper.setColorizer(player, self.update());
|
||||
IXplatAbstractions.INSTANCE.setColorizer(player, self.update());
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,7 +1,8 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
package at.petrak.hexcasting.forge.network;
|
||||
|
||||
import at.petrak.hexcasting.api.player.HexPlayerDataHelper;
|
||||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -50,7 +51,7 @@ public record MsgSentinelStatusUpdateAck(Sentinel update) implements IMessage {
|
|||
public void run() {
|
||||
var player = Minecraft.getInstance().player;
|
||||
if (player != null) {
|
||||
HexPlayerDataHelper.setSentinel(player, self.update());
|
||||
IXplatAbstractions.INSTANCE.setSentinel(player, self.update());
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,5 +1,6 @@
|
|||
package at.petrak.hexcasting.forge.xplat;
|
||||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.api.addldata.Colorizer;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.player.FlightAbility;
|
||||
|
@ -8,13 +9,17 @@ 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.misc.Brainsweeping;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.common.network.MsgBrainsweepAck;
|
||||
import at.petrak.hexcasting.forge.cap.CapSyncers;
|
||||
import at.petrak.hexcasting.forge.cap.HexCapabilities;
|
||||
import at.petrak.hexcasting.forge.network.ForgePacketHandler;
|
||||
import at.petrak.hexcasting.forge.network.MsgBrainsweepAck;
|
||||
import at.petrak.hexcasting.forge.xplat.block.BlockBurns;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import at.petrak.hexcasting.xplat.Platform;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
@ -26,7 +31,10 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
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.state.BlockBehaviour;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
|
@ -82,7 +90,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
tag.put(TAG_COLOR, colorizer.serialize());
|
||||
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
this.syncColorizer(serverPlayer);
|
||||
CapSyncers.syncColorizer(serverPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +109,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
this.syncSentinel(serverPlayer);
|
||||
CapSyncers.syncSentinel(serverPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,6 +217,32 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
ForgePacketHandler.getNetwork().sendToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block makeFlammable(BlockBehaviour.Properties properties, int flammability, int spreadSpeed) {
|
||||
return new BlockBurns(properties, flammability, spreadSpeed);
|
||||
}
|
||||
|
||||
private static CreativeModeTab TAB = null;
|
||||
|
||||
@Override
|
||||
public CreativeModeTab getTab() {
|
||||
if (TAB == null) {
|
||||
TAB = new CreativeModeTab(HexAPI.MOD_ID) {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return HexItems.tabIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemList(NonNullList<ItemStack> p_40778_) {
|
||||
super.fillItemList(p_40778_);
|
||||
HexItems.fillTab(p_40778_);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return TAB;
|
||||
}
|
||||
|
||||
public static final String TAG_BRAINSWEPT = "hexcasting:brainswept";
|
||||
public static final String TAG_SENTINEL_EXISTS = "hexcasting:sentinel_exists";
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package at.petrak.hexcasting.forge.xplat.block;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class BlockBurns extends Block {
|
||||
private final int flammability;
|
||||
private final int spreadSpeed;
|
||||
|
||||
public BlockBurns(Properties props, int flammability, int spreadSpeed) {
|
||||
super(props);
|
||||
this.flammability = flammability;
|
||||
this.spreadSpeed = spreadSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
|
||||
return flammability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
|
||||
return spreadSpeed;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue