-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Release] still v0.1.1 just hexdoc bump. also add coping saw, script,…
… and context modifiers
- Loading branch information
1 parent
b2c6739
commit 5f5f36d
Showing
20 changed files
with
266 additions
and
23 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
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
17 changes: 17 additions & 0 deletions
17
common/src/main/java/com/samsthenerd/hexgloop/blocks/BlockSentinelBed.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 |
---|---|---|
@@ -1,9 +1,26 @@ | ||
package com.samsthenerd.hexgloop.blocks; | ||
|
||
import com.samsthenerd.hexgloop.casting.ContextModificationHandlers.Modification; | ||
|
||
import at.petrak.hexcasting.api.spell.casting.CastingContext; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
public class BlockSentinelBed extends Block implements ICatPost{ | ||
public BlockSentinelBed (Settings settings){ | ||
super(settings); | ||
} | ||
|
||
public static Modification ambitModifier(CastingContext ctx, Vec3d pos, Boolean original){ | ||
ServerPlayerEntity caster = ctx.getCaster(); | ||
if(!original && caster != null){ | ||
BlockState state = caster.getWorld().getBlockState(new BlockPos(pos)); | ||
if(state.getBlock() == HexGloopBlocks.SENTINEL_BED_BLOCK.get()) | ||
return Modification.ENABLE; | ||
} | ||
return Modification.NONE; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
common/src/main/java/com/samsthenerd/hexgloop/casting/ContextModificationHandlers.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,48 @@ | ||
package com.samsthenerd.hexgloop.casting; | ||
|
||
import java.util.Comparator; | ||
import java.util.PriorityQueue; | ||
import java.util.Queue; | ||
import java.util.function.BiFunction; | ||
|
||
import com.samsthenerd.hexgloop.blocks.BlockSentinelBed; | ||
import com.samsthenerd.hexgloop.items.ItemCopingSaw; | ||
|
||
import at.petrak.hexcasting.api.spell.casting.CastingContext; | ||
import net.minecraft.data.client.BlockStateVariantMap.TriFunction; | ||
import net.minecraft.util.Pair; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
// registry for various context modifiers, handled by mixins | ||
public class ContextModificationHandlers { | ||
public static Comparator<Pair<?, Integer>> comparator = (Pair<?, Integer> a, Pair<?, Integer> b) -> { | ||
return b.getRight().compareTo(a.getRight()); | ||
}; | ||
|
||
public static Queue<Pair<BiFunction<CastingContext, Boolean, Modification>, Integer>> ENLIGHTENMENT_MODIFIERS = new PriorityQueue<>(comparator); | ||
public static Queue<Pair<BiFunction<CastingContext, Boolean, Modification>, Integer>> OVERCAST_MODIFIERS = new PriorityQueue<>(comparator); | ||
public static Queue<Pair<TriFunction<CastingContext, Vec3d, Boolean, Modification>, Integer>> AMBIT_MODIFIERS = new PriorityQueue<>(comparator); | ||
|
||
public static enum Modification { | ||
NONE, | ||
ENABLE, | ||
DISABLE | ||
} | ||
|
||
public static void registerEnlightenmentModifier(BiFunction<CastingContext, Boolean, Modification> modifier, int ordering){ | ||
ENLIGHTENMENT_MODIFIERS.add(new Pair<>(modifier, ordering)); | ||
} | ||
|
||
public static void registerOvercastModifier(BiFunction<CastingContext, Boolean, Modification> modifier, int ordering){ | ||
OVERCAST_MODIFIERS.add(new Pair<>(modifier, ordering)); | ||
} | ||
|
||
public static void registerAmbitModifier(TriFunction<CastingContext, Vec3d, Boolean, Modification> modifier, int ordering){ | ||
AMBIT_MODIFIERS.add(new Pair<>(modifier, ordering)); | ||
} | ||
|
||
public static void init(){ | ||
registerAmbitModifier(BlockSentinelBed::ambitModifier, 0); | ||
registerOvercastModifier(ItemCopingSaw::overcastModifer, 100000); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
common/src/main/java/com/samsthenerd/hexgloop/items/ItemCopingSaw.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,25 @@ | ||
package com.samsthenerd.hexgloop.items; | ||
|
||
import com.samsthenerd.hexgloop.casting.ContextModificationHandlers.Modification; | ||
|
||
import at.petrak.hexcasting.api.spell.casting.CastingContext; | ||
import net.minecraft.entity.player.PlayerInventory; | ||
import net.minecraft.item.Item; | ||
|
||
public class ItemCopingSaw extends Item{ | ||
public ItemCopingSaw(Settings settings){ | ||
super(settings); | ||
} | ||
|
||
public static Modification overcastModifer(CastingContext ctx, Boolean original){ | ||
if(ctx.getCaster() != null){ | ||
PlayerInventory pInv = ctx.getCaster().getInventory(); | ||
for(int i = 0; i < PlayerInventory.getHotbarSize(); i++){ | ||
if(pInv.getStack(i).getItem() == HexGloopItems.COPING_SAW_ITEM.get()){ | ||
return Modification.DISABLE; | ||
} | ||
} | ||
} | ||
return Modification.NONE; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
common/src/main/java/com/samsthenerd/hexgloop/items/ItemLibraryCard.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,45 @@ | ||
package com.samsthenerd.hexgloop.items; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.nbt.NbtElement; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.registry.Registry; | ||
import net.minecraft.util.registry.RegistryKey; | ||
import net.minecraft.world.World; | ||
|
||
public class ItemLibraryCard extends Item { | ||
|
||
public static String TAG_DIMENSION = "bound_dimension"; | ||
public static String DIMENSION_PREDICATE = "hexgloop:dimension"; | ||
|
||
public ItemLibraryCard(Settings settings) { | ||
super(settings); | ||
} | ||
|
||
public void setDimension(ItemStack stack, RegistryKey<World> dim){ | ||
stack.getOrCreateNbt().putString(TAG_DIMENSION, dim.getValue().toString()); | ||
} | ||
|
||
@Nullable | ||
public RegistryKey<World> getDimension(ItemStack stack){ | ||
NbtCompound nbt = stack.getNbt(); | ||
if(nbt == null || !nbt.contains(TAG_DIMENSION, NbtElement.STRING_TYPE)) | ||
return null; | ||
return RegistryKey.of(Registry.WORLD_KEY, new Identifier(nbt.getString(TAG_DIMENSION))); | ||
} | ||
|
||
public static final List<RegistryKey<World>> DIMENSIONS = List.of(World.OVERWORLD, World.NETHER, World.END); | ||
|
||
public float getPredicateValue(RegistryKey<World> dim){ | ||
if(dim == null) | ||
return 0; | ||
|
||
return 1; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...n/java/com/samsthenerd/hexgloop/mixins/castingmodifiers/MixinCastingContextModifiers.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,67 @@ | ||
package com.samsthenerd.hexgloop.mixins.castingmodifiers; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyReturnValue; | ||
import com.samsthenerd.hexgloop.casting.ContextModificationHandlers; | ||
import com.samsthenerd.hexgloop.casting.ContextModificationHandlers.Modification; | ||
|
||
import at.petrak.hexcasting.api.spell.casting.CastingContext; | ||
import net.minecraft.data.client.BlockStateVariantMap.TriFunction; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Pair; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
@Mixin(CastingContext.class) | ||
public class MixinCastingContextModifiers { | ||
@Shadow | ||
@Final | ||
private ServerPlayerEntity caster; | ||
|
||
@ModifyReturnValue(method="isVecInRange(Lnet/minecraft/util/math/Vec3d;)Z", | ||
at=@At("RETURN")) | ||
public boolean doAmbitModification(boolean original, Vec3d pos){ | ||
boolean current = original; | ||
for(Pair<TriFunction<CastingContext, Vec3d, Boolean, Modification>, Integer> pair : ContextModificationHandlers.AMBIT_MODIFIERS){ | ||
TriFunction<CastingContext, Vec3d, Boolean, Modification> modifier = pair.getLeft(); | ||
Modification mod = modifier.apply((CastingContext)(Object)this, pos, current); | ||
if(mod != Modification.NONE){ | ||
current = (mod == Modification.ENABLE); | ||
} | ||
} | ||
return current; | ||
} | ||
|
||
@ModifyReturnValue(method="isCasterEnlightened()Z", at=@At("RETURN"), remap = false) | ||
public boolean doEnlightenmentModification(boolean original){ | ||
boolean current = original; | ||
for(Pair<BiFunction<CastingContext, Boolean, Modification>, Integer> pair : ContextModificationHandlers.ENLIGHTENMENT_MODIFIERS){ | ||
BiFunction<CastingContext, Boolean, Modification> modifier = pair.getLeft(); | ||
Modification mod = modifier.apply((CastingContext)(Object)this, current); | ||
if(mod != Modification.NONE){ | ||
current = (mod == Modification.ENABLE); | ||
} | ||
} | ||
return current; | ||
} | ||
|
||
@ModifyReturnValue(method="getCanOvercast()Z", at=@At("RETURN"), remap = false) | ||
public boolean doOvercastModification(boolean original){ | ||
boolean current = original; | ||
for(Pair<BiFunction<CastingContext, Boolean, Modification>, Integer> pair : ContextModificationHandlers.OVERCAST_MODIFIERS){ | ||
BiFunction<CastingContext, Boolean, Modification> modifier = pair.getLeft(); | ||
Modification mod = modifier.apply((CastingContext)(Object)this, current); | ||
if(mod != Modification.NONE){ | ||
current = (mod == Modification.ENABLE); | ||
} | ||
} | ||
return current; | ||
} | ||
|
||
|
||
} |
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
6 changes: 6 additions & 0 deletions
6
common/src/main/resources/assets/hexgloop/models/item/coping_saw.json
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,6 @@ | ||
{ | ||
"parent": "item/handheld_rod", | ||
"textures": { | ||
"layer0": "hexgloop:item/coping_saw" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
common/src/main/resources/assets/hexgloop/models/item/longinus_staff.json
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,6 +1,6 @@ | ||
{ | ||
"parent": "minecraft:item/handheld_rod", | ||
"textures": { | ||
"layer0": "hexgloop:item/morestaffs/longinus_staff" | ||
"layer0": "hexgloop:item/morestaffs/longinus" | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
common/src/main/resources/assets/hexgloop/models/item/script.json
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,20 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"overrides": [ | ||
{ | ||
"model": "hexgloop:item/script", | ||
"predicate": { | ||
"hexcasting:overlay_layer": 0.0 | ||
} | ||
}, | ||
{ | ||
"model": "hexgloop:item/script_written", | ||
"predicate": { | ||
"hexcasting:overlay_layer": 1.0 | ||
} | ||
} | ||
], | ||
"textures": { | ||
"layer0": "hexgloop:item/script/base" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
common/src/main/resources/assets/hexgloop/models/item/script_written.json
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,7 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "hexgloop:item/script/base", | ||
"layer1": "hexgloop:item/script/overlay" | ||
} | ||
} |
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
1 change: 0 additions & 1 deletion
1
doc/src/hexdoc_hexgloop/_templates/pages/patchouli/smelting.html.jinja
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
Oops, something went wrong.