forked from J0B10/storage-drawers-kappa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.3: Revamp Config, and fix an issue with TOP.
- Loading branch information
1 parent
9f7934f
commit 115f686
Showing
7 changed files
with
88 additions
and
62 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
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
12 changes: 12 additions & 0 deletions
12
src/main/java/io/github/nomiceu/integration/TOP/TOPCompat.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 io.github.nomiceu.integration.TOP; | ||
|
||
import io.github.nomiceu.integration.TOP.provider.DrawerLogoProvider; | ||
import mcjty.theoneprobe.TheOneProbe; | ||
import mcjty.theoneprobe.api.ITheOneProbe; | ||
|
||
public class TOPCompat { | ||
public static void registerProviders() { | ||
ITheOneProbe TOP = TheOneProbe.theOneProbeImp; | ||
TOP.registerBlockDisplayOverride(new DrawerLogoProvider()); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/io/github/nomiceu/integration/TOP/provider/DrawerLogoProvider.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,61 @@ | ||
package io.github.nomiceu.integration.TOP.provider; | ||
|
||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers; | ||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers; | ||
import io.github.nomiceu.GTDConfig; | ||
import mcjty.theoneprobe.Tools; | ||
import mcjty.theoneprobe.api.*; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.world.World; | ||
import mcjty.theoneprobe.config.Config; | ||
|
||
import java.util.Objects; | ||
|
||
import static com.jaquadro.minecraft.storagedrawers.StorageDrawers.config; | ||
import static mcjty.theoneprobe.api.TextStyleClass.MODNAME; | ||
|
||
public class DrawerLogoProvider implements IBlockDisplayOverride { | ||
@Override | ||
public boolean overrideStandardInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer entityPlayer, World world, IBlockState blockState, IProbeHitData probeHitData) { | ||
Block block = blockState.getBlock(); | ||
if (!(block instanceof BlockDrawers) || !GTDConfig.fixTOPTaped) | ||
return false; | ||
|
||
String modid = Tools.getModName(block); | ||
|
||
TileEntityDrawers tile = (TileEntityDrawers) Objects.requireNonNull(world.getTileEntity(probeHitData.getPos())); | ||
|
||
if (!config.cache.keepContentsOnBreak || tile.isSealed()) | ||
return false; | ||
|
||
ItemStack pickBlock = probeHitData.getPickBlock(); | ||
|
||
if (pickBlock == null || pickBlock.isEmpty()) | ||
return false; | ||
|
||
if (pickBlock.hasTagCompound() && pickBlock.getTagCompound() != null) { | ||
if (pickBlock.getTagCompound().hasKey("tile")){ | ||
NBTTagCompound compound = pickBlock.getTagCompound(); | ||
compound.removeTag("tile"); | ||
pickBlock.setTagCompound(compound); | ||
} | ||
} | ||
|
||
if (Tools.show(mode, Config.getRealConfig().getShowModName())) | ||
probeInfo.horizontal() | ||
.item(pickBlock) | ||
.vertical() | ||
.itemLabel(pickBlock) | ||
.text(MODNAME + modid); | ||
else | ||
probeInfo.horizontal(probeInfo.defaultLayoutStyle() | ||
.alignment(ElementAlignment.ALIGN_CENTER)) | ||
.item(pickBlock); | ||
|
||
return true; | ||
} | ||
} |
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