get like halfway thru unjanking fire

This commit is contained in:
gamma-delta 2022-05-09 09:34:52 -05:00
parent d76b370eee
commit 6f6566a575
11 changed files with 109 additions and 75 deletions

View file

@ -2,14 +2,14 @@ package at.petrak.hexcasting.api.block.circle;
import at.petrak.hexcasting.api.block.HexBlockEntity;
import at.petrak.hexcasting.api.misc.FrozenColorizer;
import at.petrak.hexcasting.api.mod.HexApiItems;
import at.petrak.hexcasting.api.mod.HexApiSounds;
import at.petrak.hexcasting.api.mod.HexConfig;
import at.petrak.hexcasting.api.spell.ParticleSpray;
import at.petrak.hexcasting.api.spell.casting.CastingContext;
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
import at.petrak.hexcasting.api.spell.casting.SpellCircleContext;
import at.petrak.hexcasting.api.utils.ManaHelper;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.multiplayer.ClientLevel;
@ -30,6 +30,7 @@ import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.WorldlyContainer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
@ -118,7 +119,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
var dustCount = (float) beai.getMana() / (float) HexConfig.common().dustManaAmount();
var dustCmp = new TranslatableComponent("hexcasting.tooltip.lens.impetus.mana",
String.format("%.2f", dustCount));
lines.add(new Pair<>(new ItemStack(HexApiItems.AMETHYST_DUST), dustCmp));
lines.add(new Pair<>(new ItemStack(HexItems.AMETHYST_DUST), dustCmp));
var mishap = this.getLastMishap();
if (mishap != null) {
@ -302,7 +303,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
}
if (castSpell && makeSound) {
this.level.playSound(null, this.getBlockPos(), HexApiSounds.SPELL_CIRCLE_CAST, SoundSource.BLOCKS,
this.level.playSound(null, this.getBlockPos(), HexSounds.SPELL_CIRCLE_CAST, SoundSource.BLOCKS,
2f, 1f);
}
@ -389,14 +390,14 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
var spray = new ParticleSpray(vpos, vecOutDir.scale(success ? 1.0 : 1.5), success ? 0.1 : 0.5,
Mth.PI / (success ? 4 : 2), success ? 30 : 100);
spray.sprayParticles(serverLevel,
success ? this.colorizer : new FrozenColorizer(new ItemStack(HexApiItems.COLORIZER_RED),
success ? this.colorizer : new FrozenColorizer(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.RED)),
this.activator));
}
var pitch = 1f;
var sound = HexApiSounds.SPELL_CIRCLE_FAIL;
var sound = HexSounds.SPELL_CIRCLE_FAIL;
if (success) {
sound = HexApiSounds.SPELL_CIRCLE_FIND_BLOCK;
sound = HexSounds.SPELL_CIRCLE_FIND_BLOCK;
// This is a good use of my time
var note = this.trackedBlocks.size() - 1;
var semitone = this.semitoneFromScale(note);

View file

@ -1,27 +0,0 @@
package at.petrak.hexcasting.api.mod;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.registries.ObjectHolder;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("ConstantConditions")
@ApiStatus.Internal
@ObjectHolder("hexcasting")
public class HexApiSounds {
@NotNull
@ObjectHolder("spellcircle.cast")
public static final SoundEvent SPELL_CIRCLE_CAST = null;
@NotNull
@ObjectHolder("spellcircle.fail")
public static final SoundEvent SPELL_CIRCLE_FAIL = null;
@NotNull
@ObjectHolder("spellcircle.find_block")
public static final SoundEvent SPELL_CIRCLE_FIND_BLOCK = null;
@NotNull
@ObjectHolder("casting.fail_pattern")
public static final SoundEvent FAIL_PATTERN = null;
}

View file

@ -0,0 +1,36 @@
package at.petrak.hexcasting.common.blocks;
import at.petrak.hexcasting.annotations.SoftImplement;
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;
/**
* Does absolutely nothing on Fabric; the flammable block registry is for that.
*/
public class BlockFlammable extends Block {
public final int burn, spread;
public BlockFlammable(Properties $$0, int burn, int spread) {
super($$0);
this.burn = burn;
this.spread = spread;
}
@SoftImplement("forge")
public boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return true;
}
@SoftImplement("forge")
public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return burn;
}
@SoftImplement("forge")
public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return spread;
}
}

View file

@ -1,9 +1,10 @@
package at.petrak.hexcasting.common.blocks.akashic;
import at.petrak.hexcasting.annotations.SoftImplement;
import at.petrak.hexcasting.api.spell.DatumType;
import at.petrak.hexcasting.api.spell.SpellDatum;
import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.items.ItemScroll;
import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.lib.HexSounds;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -59,20 +60,20 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En
if (!pLevel.isClientSide()) {
scroll.writeDatum(stack, SpellDatum.make(shelf.getPattern()));
}
pLevel.playSound(pPlayer, pPos, HexSounds.SCROLL_SCRIBBLE.get(), SoundSource.BLOCKS, 1f, 1f);
pLevel.playSound(pPlayer, pPos, HexSounds.SCROLL_SCRIBBLE, SoundSource.BLOCKS, 1f, 1f);
return InteractionResult.sidedSuccess(pLevel.isClientSide);
} else if (pPlayer.isDiscrete() && pHand == InteractionHand.MAIN_HAND && stack.isEmpty()) {
if (!pLevel.isClientSide()) {
shelf.setNewData(null, null, DatumType.EMPTY);
var recordPos = HexBlocks.AKASHIC_BOOKSHELF.get().getRecordPosition(pPos, pState, pLevel);
var recordPos = HexBlocks.AKASHIC_BOOKSHELF.getRecordPosition(pPos, pState, pLevel);
if (recordPos != null &&
pLevel.getBlockEntity(recordPos) instanceof BlockEntityAkashicRecord record) {
record.revalidateAllBookshelves();
}
}
pLevel.playSound(pPlayer, pPos, HexSounds.SCROLL_SCRIBBLE.get(), SoundSource.BLOCKS,
pLevel.playSound(pPlayer, pPos, HexSounds.SCROLL_SCRIBBLE, SoundSource.BLOCKS,
1f, 0.8f);
return InteractionResult.sidedSuccess(pLevel.isClientSide);
}
@ -85,7 +86,7 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En
public void onPlace(BlockState pState, Level world, BlockPos pos, BlockState pOldState, boolean pIsMoving) {
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) {
var recordPos = BlockAkashicFloodfiller.floodFillFor(pos, world,
(here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD.get()));
(here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD));
if (pOldState.getBlock() != pState.getBlock()) {
tile.setNewData(recordPos, recordPos == null ? null : tile.getPattern(),
recordPos == null ? DatumType.EMPTY : pState.getValue(DATUM_TYPE));
@ -98,7 +99,7 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En
boolean pIsMoving) {
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) {
var recordPos = BlockAkashicFloodfiller.floodFillFor(pos, world,
(here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD.get()));
(here, bs, level) -> bs.is(HexBlocks.AKASHIC_RECORD));
tile.setNewData(recordPos, recordPos == null ? null : tile.getPattern(),
recordPos == null ? DatumType.EMPTY : pState.getValue(DATUM_TYPE));
}
@ -114,7 +115,8 @@ public class BlockAkashicBookshelf extends BlockAkashicFloodfiller implements En
return this.defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite());
}
@Override
// TODO: fabric
@SoftImplement("Forge")
public float getEnchantPowerBonus(BlockState state, LevelReader level, BlockPos pos) {
return 1;
}

View file

@ -1,5 +1,6 @@
package at.petrak.hexcasting.common.blocks.akashic;
import at.petrak.hexcasting.annotations.SoftImplement;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
@ -11,17 +12,17 @@ public class BlockAkashicLeaves extends LeavesBlock {
super(props);
}
@Override
@SoftImplement("forge")
public boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return true;
}
@Override
@SoftImplement("forge")
public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return 60;
}
@Override
@SoftImplement("forge")
public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
return 30;
}

View file

@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus;
import at.petrak.hexcasting.api.spell.DatumType;
import at.petrak.hexcasting.common.blocks.BlockConjured;
import at.petrak.hexcasting.common.blocks.BlockConjuredLight;
import at.petrak.hexcasting.common.blocks.BlockFlammable;
import at.petrak.hexcasting.common.blocks.akashic.*;
import at.petrak.hexcasting.common.blocks.circles.BlockEmptyImpetus;
import at.petrak.hexcasting.common.blocks.circles.BlockSlate;
@ -168,20 +169,20 @@ public class HexBlocks {
.strength(1f)
.lightLevel($ -> 15)));
public static final Block AKASHIC_LOG = blockItem("akashic_log",
new BlockFlammable(akashicWoody(), 5, 5));
public static final BlockAxis AKASHIC_LOG_STRIPPED = blockItem("akashic_log_stripped",
new BlockAkashicLog(akashicWoody()));
public static final Block AKASHIC_LOG = blockItem("akashic_log",
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 5, 5));
public static final Block AKASHIC_WOOD_STRIPPED = blockItem("akashic_wood_stripped",
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 5, 5));
public static final Block AKASHIC_WOOD = blockItem("akashic_log",
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 5, 5));
new BlockFlammable(akashicWoody(), 5, 5));
public static final Block AKASHIC_WOOD_STRIPPED = blockItem("akashic_wood_stripped",
new BlockFlammable(akashicWoody(), 5, 5));
public static final Block AKASHIC_PLANKS = blockItem("akashic_planks",
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 20, 5));
new BlockFlammable(akashicWoody(), 20, 5));
public static final Block AKASHIC_PANEL = blockItem("akashic_panel",
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 20, 5));
new BlockFlammable(akashicWoody(), 20, 5));
public static final Block AKASHIC_TILE = blockItem("akashic_tile",
IXplatAbstractions.INSTANCE.makeFlammable(akashicWoody(), 20, 5));
new BlockFlammable(akashicWoody(), 20, 5));
public static final DoorBlock AKASHIC_DOOR = blockItem("akashic_door",
new BlockHexDoor(akashicWoody().noOcclusion()));
public static final TrapDoorBlock AKASHIC_TRAPDOOR = blockItem("akashic_trapdoor",

View file

@ -22,7 +22,6 @@ import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
@ -92,8 +91,6 @@ public interface IXplatAbstractions {
<T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
Block... blocks);
Block makeFlammable(BlockBehaviour.Properties properties, int flammability, int spreadSpeed);
// misc
CreativeModeTab getTab();

View file

@ -10,6 +10,7 @@ import at.petrak.hexcasting.fabric.event.VillagerConversionCallback
import at.petrak.hexcasting.fabric.network.FabricPacketHandler
import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.event.player.UseEntityCallback
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry
import net.minecraft.commands.synchronization.ArgumentTypes
import net.minecraft.commands.synchronization.EmptyArgumentSerializer
import net.minecraft.core.Registry
@ -49,6 +50,43 @@ object FabricHexInitializer : ModInitializer {
HexBlockEntities.registerTiles(bind(Registry.BLOCK_ENTITY_TYPE))
HexParticles.registerParticles(bind(Registry.PARTICLE_TYPE))
// Done with soft implements in forge
val flameOn = FlammableBlockRegistry.getDefaultInstance()
for (log in listOf(
HexBlocks.AKASHIC_LOG,
HexBlocks.AKASHIC_LOG_STRIPPED,
HexBlocks.AKASHIC_WOOD,
HexBlocks.AKASHIC_LOG_STRIPPED,
)) {
flameOn.add(log, 5, 5)
}
for (wood in listOf(
HexBlocks.AKASHIC_PLANKS,
HexBlocks.AKASHIC_PANEL,
HexBlocks.AKASHIC_TILE,
HexBlocks.AKASHIC_DOOR,
HexBlocks.AKASHIC_TRAPDOOR,
HexBlocks.AKASHIC_STAIRS,
HexBlocks.AKASHIC_SLAB,
HexBlocks.AKASHIC_STAIRS,
HexBlocks.AKASHIC_SLAB,
HexBlocks.AKASHIC_BUTTON,
HexBlocks.AKASHIC_PRESSURE_PLATE,
)) {
flameOn.add(wood, 20, 5)
}
for (papery in listOf(
HexBlocks.SCROLL_PAPER,
HexBlocks.SCROLL_PAPER_LANTERN,
HexBlocks.ANCIENT_SCROLL_PAPER,
HexBlocks.ANCIENT_SCROLL_PAPER_LANTERN,
HexBlocks.AKASHIC_LEAVES1,
HexBlocks.AKASHIC_LEAVES2,
HexBlocks.AKASHIC_LEAVES3,
)) {
flameOn.add(papery, 100, 60)
}
}
private fun <T> bind(registry: Registry<in T>): BiConsumer<T, ResourceLocation> =

View file

@ -19,7 +19,6 @@ import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
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;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
@ -31,7 +30,6 @@ import net.minecraft.world.item.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
@ -184,14 +182,6 @@ public class FabricXplatImpl implements IXplatAbstractions {
return FabricBlockEntityTypeBuilder.create(func::apply, blocks).build();
}
@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
@ -221,14 +211,16 @@ public class FabricXplatImpl implements IXplatAbstractions {
@Override
public boolean isCorrectTierForDrops(Tier tier, BlockState bs) {
if (!bs.requiresCorrectToolForDrops())
if (!bs.requiresCorrectToolForDrops()) {
return true;
}
int level = HexConfig.server()
.opBreakHarvestLevelBecauseForgeThoughtItWasAGoodIdeaToImplementHarvestTiersUsingAnHonestToGodTopoSort();
for (var tool : HARVEST_TOOLS_BY_LEVEL.get(level)) {
if (tool.isCorrectToolForDrops(bs))
if (tool.isCorrectToolForDrops(bs)) {
return true;
}
}
return false;

View file

@ -15,7 +15,6 @@ import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.misc.Brainsweeping;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.forge.block.BlockBurns;
import at.petrak.hexcasting.forge.cap.CapSyncers;
import at.petrak.hexcasting.forge.cap.HexCapabilities;
import at.petrak.hexcasting.forge.network.ForgePacketHandler;
@ -41,7 +40,6 @@ import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
@ -257,11 +255,6 @@ public class ForgeXplatImpl implements IXplatAbstractions {
return BlockEntityType.Builder.of(func::apply, blocks).build(null);
}
@Override
public Block makeFlammable(BlockBehaviour.Properties properties, int flammability, int spreadSpeed) {
return new BlockBurns(properties, flammability, spreadSpeed);
}
private static CreativeModeTab TAB = null;
@Override

View file

@ -7,7 +7,7 @@ modID=hexcasting
modName=Hex Casting
minecraftVersion=1.18.2
modVersion=0.8.0
modVersion=0.9.0
paucalVersion=0.3.4
patchouliVersion=67