-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f24833
commit 069984c
Showing
28 changed files
with
706 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[Architectury Transformer DEBUG] Closed File Systems for /home/walksanator/git/mods/HexTweaks/common/build/libs/hextweaks-1.0.0.jar | ||
[Architectury Transformer DEBUG] Closed File Systems for /home/walksanator/git/mods/HexTweaks/common/build/libs/hextweaks-2.2.1.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
common/src/main/java/net/walksanator/hextweaks/blocks/BlockRegister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net.walksanator.hextweaks.blocks; | ||
|
||
import at.petrak.hexcasting.xplat.IXplatAbstractions; | ||
import dev.architectury.registry.registries.DeferredRegister; | ||
import dev.architectury.registry.registries.RegistrySupplier; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.world.item.BlockItem; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockBehaviour; | ||
import net.minecraft.world.level.material.Material; | ||
import net.walksanator.hextweaks.HexTweaks; | ||
|
||
public class BlockRegister { | ||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(HexTweaks.MOD_ID, Registry.BLOCK_REGISTRY); | ||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(HexTweaks.MOD_ID,Registry.ITEM_REGISTRY); | ||
public static final RegistrySupplier<Block> CRYSTALLIZED_SCROLL_BLOCK = BLOCKS.register("crystallizedbookblock", | ||
() -> new CrystalizedScrollBlock(BlockBehaviour.Properties.of(Material.AMETHYST))); | ||
|
||
public static void register() { | ||
BLOCKS.register(); | ||
|
||
for (RegistrySupplier<Block> block : BLOCKS) { | ||
ITEMS.register(block.getId(), | ||
() -> new BlockItem(block.get(), new Item.Properties().tab(IXplatAbstractions.INSTANCE.getTab()))); | ||
} | ||
ITEMS.register(); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
common/src/main/java/net/walksanator/hextweaks/blocks/CrystalizedScrollBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package net.walksanator.hextweaks.blocks; | ||
|
||
import at.petrak.hexcasting.api.PatternRegistry; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.StringTag; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.item.ItemEntity; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.walksanator.hextweaks.HexTweaks; | ||
import net.walksanator.hextweaks.items.CrystallizedScroll; | ||
import net.walksanator.hextweaks.items.ItemRegister; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Random; | ||
|
||
import static net.walksanator.hextweaks.patterns.PatternRegister.lookupPatternIllegal; | ||
|
||
public class CrystalizedScrollBlock extends Block { | ||
|
||
public CrystalizedScrollBlock(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("deprecation") | ||
public void onPlace(@NotNull BlockState newState, Level level, @NotNull BlockPos position, @NotNull BlockState OldState, boolean movedByPiston) { | ||
if (!level.isClientSide) { | ||
Random rand = new Random(); | ||
//create the item | ||
ItemStack scroll = new ItemStack(ItemRegister.CRYSTALLIZED_SCROLL.get()); | ||
|
||
//create the data | ||
CompoundTag ctag = new CompoundTag(); | ||
|
||
ResourceLocation target = HexTweaks.GrandSpells.get( | ||
rand.nextInt(HexTweaks.GrandSpells.size()) | ||
); | ||
|
||
PatternRegistry.PatternEntry entry = lookupPatternIllegal( //use the illegal lookup method since Grand spells can have Illegal signatures | ||
target | ||
); | ||
|
||
ctag.put(CrystallizedScroll.TAG_PATTERN, | ||
entry.prototype().serializeToNBT() | ||
); | ||
ctag.put(CrystallizedScroll.TAG_OP_ID,StringTag.valueOf(target.toString())); | ||
|
||
scroll.setTag(ctag); | ||
|
||
//turn the item into an entity | ||
ItemEntity scroll_ent = new ItemEntity(level,position.getX(),position.getY(),position.getZ(),scroll); | ||
|
||
//spawn | ||
level.addFreshEntity(scroll_ent); | ||
level.setBlockAndUpdate(position,Blocks.AIR.defaultBlockState()); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
common/src/main/java/net/walksanator/hextweaks/items/CrystallizedScroll.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.walksanator.hextweaks.items; | ||
|
||
import at.petrak.hexcasting.api.item.IotaHolderItem; | ||
import at.petrak.hexcasting.api.spell.iota.Iota; | ||
import at.petrak.hexcasting.common.items.ItemScroll; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CrystallizedScroll extends ItemScroll implements IotaHolderItem { | ||
public CrystallizedScroll(Properties properties) { | ||
super(properties,1); | ||
} | ||
|
||
@Override | ||
public boolean canWrite(ItemStack stack, @Nullable Iota iota) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void writeDatum(ItemStack stack, @Nullable Iota iota) {}//you cannot write to it | ||
|
||
|
||
@Override | ||
public boolean isFoil(@NotNull ItemStack stack) {return true;} | ||
} |
24 changes: 24 additions & 0 deletions
24
common/src/main/java/net/walksanator/hextweaks/items/ItemRegister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.walksanator.hextweaks.items; | ||
|
||
import at.petrak.hexcasting.xplat.IXplatAbstractions; | ||
import dev.architectury.registry.registries.DeferredRegister; | ||
import dev.architectury.registry.registries.RegistrySupplier; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.Rarity; | ||
import net.walksanator.hextweaks.HexTweaks; | ||
|
||
public class ItemRegister { | ||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(HexTweaks.MOD_ID, Registry.ITEM_REGISTRY); | ||
public static final RegistrySupplier<Item> CRYSTALLIZED_SCROLL = ITEMS.register("crystallized_scroll", | ||
() -> new CrystallizedScroll(props().rarity(Rarity.EPIC))); | ||
public static Item.Properties props() { | ||
return new Item.Properties().tab(IXplatAbstractions.INSTANCE.getTab()); | ||
} | ||
|
||
public static void register() { | ||
ITEMS.register(); | ||
} | ||
|
||
|
||
} |
27 changes: 27 additions & 0 deletions
27
common/src/main/java/net/walksanator/hextweaks/mixin/MixinPatternRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.walksanator.hextweaks.mixin; | ||
|
||
import at.petrak.hexcasting.api.PatternRegistry; | ||
import at.petrak.hexcasting.api.spell.Action; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
import java.util.concurrent.ConcurrentMap; | ||
|
||
@Mixin(PatternRegistry.class) | ||
public interface MixinPatternRegistry { | ||
@Accessor("actionLookup") | ||
static ConcurrentMap<ResourceLocation, Action> getActionLookup() { | ||
throw new AssertionError(); | ||
} | ||
|
||
@Accessor("perWorldPatternLookup") | ||
static ConcurrentMap<ResourceLocation,?> getPerWorldPatternLookup() { | ||
throw new AssertionError(); | ||
} | ||
|
||
@Accessor("regularPatternLookup") | ||
static ConcurrentMap<String,?> getRegularPatternLookup() { | ||
throw new AssertionError(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/net/walksanator/hextweaks/mixin/MixinPerWorldEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.walksanator.hextweaks.mixin; | ||
|
||
import at.petrak.hexcasting.api.spell.math.HexPattern; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(targets = "at.petrak.hexcasting.api.PatternRegistry$PerWorldEntry") | ||
public interface MixinPerWorldEntry { | ||
@Accessor | ||
HexPattern getPrototype(); | ||
|
||
@Accessor | ||
ResourceLocation getOpId(); | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/net/walksanator/hextweaks/mixin/MixinRegularEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.walksanator.hextweaks.mixin; | ||
|
||
import at.petrak.hexcasting.api.spell.math.HexDir; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(targets = "at.petrak.hexcasting.api.PatternRegistry$RegularEntry") | ||
public interface MixinRegularEntry { | ||
@Accessor | ||
HexDir getPreferredStart(); | ||
|
||
@Accessor | ||
ResourceLocation getOpId(); | ||
} |
Oops, something went wrong.