-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Jade/Waila plugin that hides IOtherworldBlocks if covered, f…
- Loading branch information
Showing
3 changed files
with
44 additions
and
2 deletions.
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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/klikli_dev/occultism/integration/waila/OccultismPlugin.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,41 @@ | ||
package com.klikli_dev.occultism.integration.waila; | ||
|
||
import com.klikli_dev.occultism.Occultism; | ||
import com.klikli_dev.occultism.api.common.data.OtherworldBlockTier; | ||
import com.klikli_dev.occultism.common.block.otherworld.IOtherworldBlock; | ||
import com.klikli_dev.occultism.registry.OccultismBlocks; | ||
import com.klikli_dev.occultism.util.CuriosUtil; | ||
import net.minecraft.world.level.block.Blocks; | ||
import snownee.jade.api.*; | ||
|
||
@WailaPlugin | ||
public class OccultismPlugin implements IWailaPlugin { | ||
@Override | ||
public void register(IWailaCommonRegistration registration) { | ||
//TODO register data providers | ||
} | ||
|
||
@Override | ||
public void registerClient(IWailaClientRegistration registration) { | ||
registration.addRayTraceCallback((hitResult, accessor, originalAccessor) -> { | ||
if(accessor!=null) { | ||
boolean hasGoggles = CuriosUtil.hasGoggles(accessor.getPlayer()); | ||
if (accessor instanceof BlockAccessor blockAccessor) { | ||
if (blockAccessor.getBlock() instanceof IOtherworldBlock otherworldBlock) { | ||
if (otherworldBlock.getTier() == OtherworldBlockTier.ONE || hasGoggles) { | ||
if (blockAccessor.getBlockState().getValue(IOtherworldBlock.UNCOVERED)) { | ||
return registration.blockAccessor().from(blockAccessor).blockState(otherworldBlock.getUncoveredBlock().defaultBlockState()).build(); | ||
} else { | ||
return registration.blockAccessor().from(blockAccessor).blockState(otherworldBlock.getCoveredBlock().defaultBlockState()).build(); | ||
} | ||
} else { | ||
return registration.blockAccessor().from(blockAccessor).blockState(otherworldBlock.getCoveredBlock().defaultBlockState()).build(); | ||
} | ||
} | ||
} | ||
} | ||
return accessor; | ||
}); | ||
} | ||
|
||
} |