Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加更好的告示牌交互功能 #111

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/main/java/dev/dubhe/curtain/CurtainRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;

import static dev.dubhe.curtain.api.rules.Categories.BUGFIX;
import static dev.dubhe.curtain.api.rules.Categories.CLIENT;
import static dev.dubhe.curtain.api.rules.Categories.COMMAND;
import static dev.dubhe.curtain.api.rules.Categories.CREATIVE;
import static dev.dubhe.curtain.api.rules.Categories.DISPENSER;
import static dev.dubhe.curtain.api.rules.Categories.FEATURE;
import static dev.dubhe.curtain.api.rules.Categories.SURVIVAL;
import static dev.dubhe.curtain.api.rules.Categories.TNT;
import static dev.dubhe.curtain.api.rules.Categories.*;


public class CurtainRules {
Expand Down Expand Up @@ -335,4 +328,10 @@ public boolean validate(CommandSourceStack source, CurtainRule<Double> rule, Str
suggestions = {"true", "false"}
)
public static boolean openFakePlayerEnderChest = false;

@Rule(
categories = {SURVIVAL},
suggestions = {"true", "false"}
)
public static boolean betterSignInteraction = false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dev.dubhe.curtain.mixins.rules.better_sign_interaction;

import dev.dubhe.curtain.CurtainRules;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.SignBlock;
import net.minecraft.world.level.block.WallSignBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(SignBlock.class)
public abstract class SignBlockMixin {
private final SignBlock self = (SignBlock) (Object) this;

@Inject(method = "use", at = @At(value = "INVOKE",target = "Lnet/minecraft/world/level/Level;playSound(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/core/BlockPos;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;)V"), cancellable = true)
public void use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir) {
if (CurtainRules.betterSignInteraction && self instanceof WallSignBlock) {
Direction direction = state.getValue(WallSignBlock.FACING);
BlockPos blockPos = pos.relative(direction, -1);
BlockState blockState = level.getBlockState(blockPos);
BlockHitResult hitResult = new BlockHitResult(Vec3.atCenterOf(blockPos), direction, blockPos, false);
if (blockState.getBlock() instanceof WallSignBlock) return;
else blockState.use(level, player, hand, hitResult);
cir.setReturnValue(InteractionResult.SUCCESS);
}
}
}
27 changes: 15 additions & 12 deletions src/main/resources/assets/curtain/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,39 +88,42 @@
"curtain.rules.creative_no_clip.name": "Creative No Clip",
"curtain.rules.creative_no_clip.desc": "On servers it needs to be set on both\nclient and server to function properly.\nHas no effect when set on the server only\nCan allow to phase through walls\nif only set on the carpet client side\nbut requires some trapdoor magic to\nallow the player to enter blocks",

"curtain.rules.optimized_tnt.name": "optimizedTNT",
"curtain.rules.optimized_tnt.name": "Optimized TNT",
"curtain.rules.optimized_tnt.desc": "TNT causes less lag when exploding in the same spot and in liquids",

"curtain.rules.tnt_random_range.name": "TNT Random Range",
"curtain.rules.tnt_random_range.desc": "Sets the tnt random explosion range to a fixed value\nSet to -1 for default behavior",

"curtain.rules.tnt_primer_momentum_removed.name": "tntPrimerMomentumRemoved",
"curtain.rules.tnt_primer_momentum_removed.name": "TNT Primer Momentum Removed",
"curtain.rules.tnt_primer_momentum_removed.desc": "Removes random TNT momentum when primed",

"curtain.rules.hardcode_tnt_angle.name": "hardcodeTNTangle",
"curtain.rules.hardcode_tnt_angle.name": "Hardcode TNT angle",
"curtain.rules.hardcode_tnt_angle.desc": "Sets the horizontal random angle on TNT for debugging of TNT contraptions\nSet to -1 for default behavior",

"curtain.rules.merge_tnt.name": "mergeTNT",
"curtain.rules.merge_tnt.name": "Merge TNT",
"curtain.rules.merge_tnt.desc": "Merges stationary primed TNT entities",

"curtain.rules.ctrl_q_crafting_fix.name": "ctrlQCraftingFix",
"curtain.rules.ctrl_q_crafting_fix.name": "Ctrl+Q Crafting Fix",
"curtain.rules.ctrl_q_crafting_fix.desc": "Dropping entire stacks works also from on the crafting UI result slot",

"curtain.rules.quick_leaf_decay.name": "quickLeafDecay",
"curtain.rules.quick_leaf_decay.name": "Quick Leaf Decay",
"curtain.rules.quick_leaf_decay.desc": "Leaves fall off quickly after cutting down a tree",

"curtain.rules.custom_motd.name": "customMOTD",
"curtain.rules.custom_motd.name": "Custom MOTD",
"curtain.rules.custom_motd.desc": "Sets a different motd message on client trying to connect to the server\nuse '_' to use the startup setting from server.properties",

"curtain.rules.turtle_egg_trampled_disabled.name": "turtleEggTrampledDisabled",
"curtain.rules.turtle_egg_trampled_disabled.name": "Turtle Egg Trampled Disabled",
"curtain.rules.turtle_egg_trampled_disabled.desc": "Stopping turtle eggs from being destroyed by physical trampling",

"curtain.rules.farmland_trampled_disabled.name": "FarmlandTrampledDisabled",
"curtain.rules.farmland_trampled_disabled.name": "Farmland Trampled Disabled",
"curtain.rules.farmland_trampled_disabled.desc": "Stopping farmlands from being destroyed by physical trampling",

"curtain.rules.fake_player_name_prefix.name": "fakePlayerNamePrefix",
"curtain.rules.fake_player_name_prefix.name": "Fake Player Name Prefix",
"curtain.rules.fake_player_name_prefix.desc": "Add the specified prefix to the name of the fake player summoned by the /player command",

"curtain.rules.fake_player_name_suffix.name": "fakePlayerNameSuffix",
"curtain.rules.fake_player_name_suffix.desc": "Add the specified prefix to the name of the fake player summoned by the /player command"
"curtain.rules.fake_player_name_suffix.name": "Fake Player Name Suffix",
"curtain.rules.fake_player_name_suffix.desc": "Add the specified prefix to the name of the fake player summoned by the /player command",

"curtain.rules.better_sign_interaction.name": "Better Sign Interaction",
"curtain.rules.better_sign_interaction.desc": "Make the block attached to the sign interact when you right-click it"
}
5 changes: 4 additions & 1 deletion src/main/resources/assets/curtain/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,8 @@
"curtain.rules.fake_player_name_prefix.desc": "为/player指令召唤出来的假人名称添加指定前缀",

"curtain.rules.fake_player_name_suffix.name": "假人名称后缀",
"curtain.rules.fake_player_name_suffix.desc": "为/player指令召唤出来的假人名称添加指定后缀"
"curtain.rules.fake_player_name_suffix.desc": "为/player指令召唤出来的假人名称添加指定后缀",

"curtain.rules.better_sign_interaction.name": "更好的告示牌交互",
"curtain.rules.better_sign_interaction.desc": "右键涂蜡的告示牌时与之附着的方块产生交互"
}
1 change: 1 addition & 0 deletions src/main/resources/curtain.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"ServerChunkCacheMixin",
"ServerPlayerMixin",
"event.player.PickaxeItemMixin",
"rules.better_sign_interaction.SignBlockMixin",
"rules.cactus.DispenserBlockMixin",
"rules.cactus.HopperBlockMixin",
"rules.cactus.LevelMixin",
Expand Down
Loading