-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Abbie5/jade-wthit
Add Jade and WTHIT plugins
- Loading branch information
Showing
7 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/de/dafuqs/revelationary/compat/jade/RevelationaryJadePlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.dafuqs.revelationary.compat.jade; | ||
|
||
import de.dafuqs.revelationary.api.revelations.RevelationAware; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import snownee.jade.api.BlockAccessor; | ||
import snownee.jade.api.IWailaClientRegistration; | ||
import snownee.jade.api.IWailaPlugin; | ||
|
||
public class RevelationaryJadePlugin implements IWailaPlugin { | ||
@Override | ||
public void registerClient(IWailaClientRegistration registration) { | ||
registration.addRayTraceCallback((hitResult, accessor, originalAccessor) -> { | ||
if (accessor instanceof BlockAccessor blockAccessor) { | ||
PlayerEntity player = accessor.getPlayer(); | ||
if (player.isCreative() || player.isSpectator()) { | ||
return accessor; | ||
} | ||
|
||
if (blockAccessor.getBlock() instanceof RevelationAware aware) { | ||
if (!aware.isVisibleTo(player)) { | ||
BlockState cloakedState = aware.getBlockStateCloaks().get(blockAccessor.getBlockState()); | ||
return registration.blockAccessor().from(blockAccessor).blockState(cloakedState).build(); | ||
} | ||
} | ||
} | ||
|
||
return accessor; | ||
}); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/de/dafuqs/revelationary/compat/wthit/CloakedBlockComponentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package de.dafuqs.revelationary.compat.wthit; | ||
|
||
import de.dafuqs.revelationary.api.revelations.RevelationAware; | ||
import mcp.mobius.waila.api.IBlockAccessor; | ||
import mcp.mobius.waila.api.IBlockComponentProvider; | ||
import mcp.mobius.waila.api.IPluginConfig; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CloakedBlockComponentProvider implements IBlockComponentProvider { | ||
@Override | ||
public @Nullable BlockState getOverride(IBlockAccessor accessor, IPluginConfig config) { | ||
PlayerEntity player = accessor.getPlayer(); | ||
|
||
RevelationAware aware = (RevelationAware) accessor.getBlock(); | ||
if (!aware.isVisibleTo(player)) { | ||
return aware.getBlockStateCloaks().get(accessor.getBlockState()); | ||
} | ||
|
||
return accessor.getBlockState(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/de/dafuqs/revelationary/compat/wthit/RevelationaryWthitPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package de.dafuqs.revelationary.compat.wthit; | ||
|
||
import de.dafuqs.revelationary.api.revelations.RevelationAware; | ||
import mcp.mobius.waila.api.IRegistrar; | ||
import mcp.mobius.waila.api.IWailaPlugin; | ||
|
||
public class RevelationaryWthitPlugin implements IWailaPlugin { | ||
@Override | ||
public void register(IRegistrar registrar) { | ||
registrar.addOverride(new CloakedBlockComponentProvider(), RevelationAware.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"revelationary:plugin": { | ||
"initializer": "de.dafuqs.revelationary.compat.wthit.RevelationaryWthitPlugin" | ||
} | ||
} |