Compare commits

..

6 Commits

Author SHA1 Message Date
2957a899db Merge pull request 'Sound support + OffHand camo.' (#8) from dev into master
All checks were successful
deploy / deploy (push) Successful in 5m6s
Reviewed-on: #8
2024-03-04 17:04:13 +01:00
6ca266b676 patched sounds on the frames and made it so that it will take the texture of the block in offhand 2024-03-04 16:57:18 +01:00
Adrien1106
4d87ce9753
Merge pull request #1 from quentinlegot/CI-fix
Fix CI while fethcing wrapper-validation-action
2024-03-03 22:54:55 +01:00
e196975f1d
Fix CI while fethcing wrapper-validation-action 2024-03-03 22:53:30 +01:00
e8ce990955 removed w.i.p. mixins 2024-03-03 21:57:22 +01:00
c3e2e626c8 removed useless element in github workflow 2024-03-03 21:49:09 +01:00
10 changed files with 219 additions and 14 deletions

View File

@ -2,12 +2,6 @@ name: Publish mod on Modrinth
on: [ push, workflow_dispatch ] on: [ push, workflow_dispatch ]
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
permissions:
contents: write
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -15,7 +9,7 @@ jobs:
- name: checkout repository - name: checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: validate gradle wrapper - name: validate gradle wrapper
uses: https://github.com/gradle/wrapper-validation-action@v1 uses: gradle/wrapper-validation-action@v2
- name: setup jdk - name: setup jdk
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
@ -31,4 +25,4 @@ jobs:
- name: Publish Modrinth - name: Publish Modrinth
run: ./gradlew modrinth run: ./gradlew modrinth
env: env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

View File

@ -9,7 +9,7 @@ loader_version=0.15.6
# Mod Properties # Mod Properties
modrinth_id = jCpoCBpn modrinth_id = jCpoCBpn
mod_version = 1.3.1 mod_version = 1.3.5
maven_group = fr.adrien1106 maven_group = fr.adrien1106
archives_base_name = ReFramed archives_base_name = ReFramed
mod_id = reframed mod_id = reframed

View File

@ -25,7 +25,7 @@ import java.util.function.BiConsumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* TODO self culling, fix other models, better connected textures, preload items, walking sound, state replacement * TODO self culling, fix other models, better connected textures, preload items
*/ */
public class ReFramed implements ModInitializer { public class ReFramed implements ModInitializer {
public static final String MODID = "reframed"; public static final String MODID = "reframed";

View File

@ -35,7 +35,7 @@ public class ReFramedEntity extends BlockEntity implements ThemeableBlockEntity
protected static final byte REDSTONE_MASK = 0b010; protected static final byte REDSTONE_MASK = 0b010;
protected static final byte SOLIDITY_MASK = 0b100; protected static final byte SOLIDITY_MASK = 0b100;
protected static final String BLOCKSTATE_KEY = "s"; public static final String BLOCKSTATE_KEY = "s";
protected static final String BITFIELD_KEY = "b"; protected static final String BITFIELD_KEY = "b";
public ReFramedEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) { public ReFramedEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {

View File

@ -0,0 +1,48 @@
package fr.adrien1106.reframed.mixin;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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 org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import static fr.adrien1106.reframed.block.ReFramedEntity.BLOCKSTATE_KEY;
@Mixin(BlockItem.class)
public class BlockItemMixin {
@Shadow @Final @Deprecated private Block block;
@Inject(
method = "writeNbtToBlockEntity",
at = @At(
value = "INVOKE_ASSIGN",
target = "Lnet/minecraft/item/BlockItem;getBlockEntityNbt(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/nbt/NbtCompound;",
shift = At.Shift.AFTER
)
)
private static void placeBlockWithOffHandCamo(World world, PlayerEntity player, BlockPos pos, ItemStack stack, CallbackInfoReturnable<Boolean> cir, @Local LocalRef<NbtCompound> compound) {
if (compound.get() != null
|| player.getOffHandStack().isEmpty()
|| !(player.getOffHandStack().getItem() instanceof BlockItem block)
|| block.getBlock() instanceof BlockEntityProvider
|| !Block.isShapeFullCube(block.getBlock().getDefaultState().getCollisionShape(world, pos))
) return;
NbtCompound new_comp = new NbtCompound();
new_comp.put(BLOCKSTATE_KEY + 1, NbtHelper.fromBlockState(block.getBlock().getDefaultState()));
compound.set(new_comp);
}
}

View File

@ -0,0 +1,48 @@
package fr.adrien1106.reframed.mixin.sound;
import com.llamalad7.mixinextras.sugar.Local;
import fr.adrien1106.reframed.block.ReFramedBlock;
import fr.adrien1106.reframed.util.ThemeableBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.BlockItem;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(BlockItem.class)
public class BlockItemMixin {
@Redirect(
method = "place(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/util/ActionResult;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/BlockState;getSoundGroup()Lnet/minecraft/sound/BlockSoundGroup;"
)
)
public BlockSoundGroup getCamoPlaceSound(BlockState state, @Local World world, @Local BlockPos pos) {
if (state.getBlock() instanceof ReFramedBlock frame_block
&& world.getBlockEntity(pos) instanceof ThemeableBlockEntity frame_entity
) {
BlockState camo_state = frame_entity.getTheme(frame_block.getTopThemeIndex(state));
state = camo_state.getBlock() != Blocks.AIR ? camo_state : state;
}
return state.getSoundGroup();
}
@Redirect(
method = "place(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/util/ActionResult;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/item/BlockItem;getPlaceSound(Lnet/minecraft/block/BlockState;)Lnet/minecraft/sound/SoundEvent;"
)
)
private SoundEvent getCamoSoundEvent(BlockItem item, BlockState state, @Local BlockSoundGroup group) {
// I don't know why it wasn't doing that by default
return group.getPlaceSound();
}
}

View File

@ -0,0 +1,38 @@
package fr.adrien1106.reframed.mixin.sound;
import com.llamalad7.mixinextras.sugar.Local;
import fr.adrien1106.reframed.block.ReFramedBlock;
import fr.adrien1106.reframed.util.ThemeableBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Entity.class)
public abstract class EntityMixin {
@Shadow public abstract World getWorld();
@Redirect(
method = "playStepSound",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/BlockState;getSoundGroup()Lnet/minecraft/sound/BlockSoundGroup;"
)
)
private BlockSoundGroup playStepCamoSound(BlockState state, @Local(argsOnly = true) BlockPos pos) {
if (state.getBlock() instanceof ReFramedBlock frame_block
&& getWorld().getBlockEntity(pos) instanceof ThemeableBlockEntity frame_entity
) {
BlockState camo_state = frame_entity.getTheme(frame_block.getTopThemeIndex(state));
state = camo_state.getBlock() != Blocks.AIR ? camo_state : state;
}
return state.getSoundGroup();
}
}

View File

@ -0,0 +1,34 @@
package fr.adrien1106.reframed.mixin.sound;
import fr.adrien1106.reframed.block.ReFramedBlock;
import fr.adrien1106.reframed.util.ThemeableBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(LivingEntity.class)
public class LivingEntityMixin {
@Redirect(
method = "playBlockFallSound",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"
), remap = false
)
private BlockState playCamoFallSound(World world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof ReFramedBlock frame_block
&& world.getBlockEntity(pos) instanceof ThemeableBlockEntity frame_entity
) {
BlockState camo_state = frame_entity.getTheme(frame_block.getTopThemeIndex(state));
state = camo_state.getBlock() != Blocks.AIR ? camo_state : state;
}
return state;
}
}

View File

@ -0,0 +1,39 @@
package fr.adrien1106.reframed.mixin.sound;
import com.llamalad7.mixinextras.sugar.Local;
import fr.adrien1106.reframed.block.ReFramedBlock;
import fr.adrien1106.reframed.util.ThemeableBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(WorldRenderer.class)
public class WorldRendererMixin {
@Shadow @Nullable private ClientWorld world;
@Redirect(
method = "processWorldEvent",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/BlockState;getSoundGroup()Lnet/minecraft/sound/BlockSoundGroup;"
)
)
private BlockSoundGroup getCamoBreakSound(BlockState state, @Local(argsOnly = true) BlockPos pos) {
if (state.getBlock() instanceof ReFramedBlock frame_block
&& world.getBlockEntity(pos) instanceof ThemeableBlockEntity frame_entity
) {
BlockState camo_state = frame_entity.getTheme(frame_block.getTopThemeIndex(state));
state = camo_state.getBlock() != Blocks.AIR ? camo_state : state;
}
return state.getSoundGroup();
}
}

View File

@ -4,10 +4,10 @@
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"plugin": "fr.adrien1106.reframed.mixin.CompatMixinPlugin", "plugin": "fr.adrien1106.reframed.mixin.CompatMixinPlugin",
"mixins": [ "mixins": [
"BlockItemMixin",
"WallBlockAccessor", "WallBlockAccessor",
"particles.MixinEntity", "particles.MixinEntity",
"particles.MixinLivingEntity", "particles.MixinLivingEntity"
"sound.LivingEntityMixin"
], ],
"client": [ "client": [
"MinecraftAccessor", "MinecraftAccessor",
@ -24,7 +24,11 @@
"render.BlockRenderInfoMixin", "render.BlockRenderInfoMixin",
"render.MultipartBakedModelMixin", "render.MultipartBakedModelMixin",
"render.TerrainRenderContextMixin", "render.TerrainRenderContextMixin",
"render.WorldRendererMixin" "render.WorldRendererMixin",
"sound.BlockItemMixin",
"sound.EntityMixin",
"sound.LivingEntityMixin",
"sound.WorldRendererMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1