Skip to content

Commit

Permalink
blacklist block and entity type tag
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Feb 7, 2021
1 parent b2998ee commit a0d24d3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/mcp/mobius/waila/Waila.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.tag.TagRegistry;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityType;
import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -27,6 +31,9 @@ public class Waila implements ModInitializer {
.create()
);

public static final Tag<Block> BLOCK_BLACKLIST = TagRegistry.block(new Identifier(MODID, "blacklist"));
public static final Tag<EntityType<?>> ENTITY_BLACKLIST = TagRegistry.entityType(new Identifier(MODID, "blacklist"));

@Override
public void onInitialize() {
NetworkHandler.init();
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/mcp/mobius/waila/overlay/WailaTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public void tickClient() {
if (target != null && target.getType() == HitResult.Type.BLOCK) {
DataAccessor accessor = DataAccessor.INSTANCE;
accessor.set(world, player, target);

if (accessor.block.isIn(Waila.BLOCK_BLACKLIST)) {
tooltip = null;
return;
}

ItemStack targetStack = RayTracing.INSTANCE.getTargetStack(); // Here we get either the proper stack or the override
accessor.stack = targetStack;

Expand All @@ -101,6 +107,11 @@ public void tickClient() {
DataAccessor accessor = DataAccessor.INSTANCE;
accessor.set(world, player, target);

if (accessor.entity.getType().isIn(Waila.ENTITY_BLACKLIST)) {
tooltip = null;
return;
}

Entity targetEnt = RayTracing.INSTANCE.getTargetEntity(); // This need to be replaced by the override check.

if (targetEnt != null) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/data/waila/tags/blocks/blacklist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values" : [
"minecraft:barrier",
"minecraft:structure_void"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"replace": false,
"values" : [
]
}

0 comments on commit a0d24d3

Please sign in to comment.