Skip to content

Commit 7123dfe

Browse files
committed
tell us what block we just broke
1 parent d04444c commit 7123dfe

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

src/main/java/dev/dfonline/codeclient/config/Config.java

+26-12
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class Config {
4545
public boolean ChestPeeker = true;
4646
public int ChestPeekerX = 0;
4747
public int ChestPeekerY = -4;
48+
public boolean ReportBrokenBlock = true;
4849

4950
private void save() {
5051
try {
@@ -77,6 +78,7 @@ private void save() {
7778
object.addProperty("ChestPeeker",ChestPeeker);
7879
object.addProperty("ChestPeekerX",ChestPeekerX);
7980
object.addProperty("ChestPeekerY",ChestPeekerY);
81+
object.addProperty("ReportBrokenBlock",ReportBrokenBlock);
8082
FileManager.writeConfig(object.toString());
8183
} catch (Exception e) {
8284
CodeClient.LOGGER.info("Couldn't save config: " + e);
@@ -261,20 +263,32 @@ public YetAnotherConfigLib getLibConfig() {
261263
)
262264
.controller(TickBoxControllerBuilder::create)
263265
.build())
264-
.option(Option.createBuilder(float.class)
265-
.name(Text.literal("Reach Distance"))
266-
.description(OptionDescription.createBuilder()
267-
.text(Text.literal("Extend your reach distance, moving you forward if you can't reach."))
268-
.build())
266+
// .option(Option.createBuilder(float.class)
267+
// .name(Text.literal("Reach Distance"))
268+
// .description(OptionDescription.createBuilder()
269+
// .text(Text.literal("Extend your reach distance, moving you forward if you can't reach."))
270+
// .build())
271+
// .binding(
272+
// 5f,
273+
// () -> ReachDistance,
274+
// opt -> ReachDistance = opt
275+
// )
276+
// .controller(opt -> FloatSliderControllerBuilder.create(opt)
277+
// .range(5f, 10f)
278+
// .step(0.1f))
279+
// .available(false)
280+
// .build())
281+
.option(Option.createBuilder(boolean.class)
282+
.name(Text.literal("Report Broken Blocks"))
283+
.description(
284+
OptionDescription.of(Text.literal("Get a message on breaking a block telling you what it did."),
285+
Text.literal("Only works for Player Event, Entity Event, Function, Call Function, Process, and Start Process")))
269286
.binding(
270-
5f,
271-
() -> ReachDistance,
272-
opt -> ReachDistance = opt
287+
true,
288+
() -> ReportBrokenBlock,
289+
opt -> ReportBrokenBlock = opt
273290
)
274-
.controller(opt -> FloatSliderControllerBuilder.create(opt)
275-
.range(5f, 10f)
276-
.step(0.1f))
277-
.available(false)
291+
.controller(TickBoxControllerBuilder::create)
278292
.build())
279293
.option(Option.createBuilder(LayerInteractionMode.class)
280294
.name(Text.literal("Layer Interaction"))

src/main/java/dev/dfonline/codeclient/dev/InteractionManager.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.JsonElement;
44
import com.google.gson.JsonObject;
55
import com.google.gson.JsonParser;
6+
import dev.dfonline.codeclient.ChatType;
67
import dev.dfonline.codeclient.CodeClient;
78
import dev.dfonline.codeclient.Utility;
89
import dev.dfonline.codeclient.config.Config;
@@ -13,6 +14,7 @@
1314
import net.minecraft.block.Block;
1415
import net.minecraft.block.BlockState;
1516
import net.minecraft.block.Blocks;
17+
import net.minecraft.block.entity.SignBlockEntity;
1618
import net.minecraft.client.sound.PositionedSoundInstance;
1719
import net.minecraft.client.world.ClientWorld;
1820
import net.minecraft.entity.EntityDimensions;
@@ -47,6 +49,8 @@
4749
import java.util.Objects;
4850

4951
public class InteractionManager {
52+
private static final List<Block> validBlocks = List.of(Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.EMERALD_BLOCK, Blocks.EMERALD_ORE, Blocks.DIAMOND_BLOCK, Blocks.GOLD_BLOCK);
53+
5054
/**
5155
* Assuming pos is in a codespace.
5256
* @param pos The targeted pos.
@@ -70,7 +74,12 @@ public static boolean onBreakBlock(BlockPos pos) {
7074
}
7175
}
7276
BlockPos breakPos = isBlockBreakable(pos);
73-
if(breakPos != null) BlockBreakDeltaCalculator.breakBlock(pos);
77+
if(breakPos != null) {
78+
if(Config.getConfig().ReportBrokenBlock && validBlocks.contains(CodeClient.MC.world.getBlockState(breakPos).getBlock()) && CodeClient.MC.world.getBlockEntity(breakPos.west()) instanceof SignBlockEntity sign) {
79+
if(!sign.getFrontText().getMessage(1,false).equals(Text.empty())) Utility.sendMessage(Text.empty().formatted(Formatting.AQUA).append(Text.literal("You just broke ")).append(Text.empty().formatted(Formatting.WHITE).append(sign.getFrontText().getMessage(1,false))).append(Text.literal(".")), ChatType.INFO);
80+
}
81+
BlockBreakDeltaCalculator.breakBlock(pos);
82+
}
7483
if(Config.getConfig().CustomBlockInteractions) {
7584
if(breakPos != null) {
7685
breakCodeBlock(breakPos);

0 commit comments

Comments
 (0)