Compare commits
6 Commits
f3578a4da5
...
2957a899db
Author | SHA1 | Date | |
---|---|---|---|
2957a899db | |||
6ca266b676 | |||
|
4d87ce9753 | ||
e196975f1d | |||
e8ce990955 | |||
c3e2e626c8 |
10
.github/workflows/publish.yml
vendored
10
.github/workflows/publish.yml
vendored
@ -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 }}
|
||||||
|
@ -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
|
||||||
|
@ -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";
|
||||||
|
@ -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) {
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user