forked from McJtyMods/TheOneProbe
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
59 additions
and
66 deletions.
There are no files selected for viewing
57 changes: 0 additions & 57 deletions
57
src/main/java/mcjty/theoneprobe/apiimpl/providers/CropInfoProvider.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 |
---|---|---|
@@ -1,58 +1 @@ | ||
package mcjty.theoneprobe.apiimpl.providers; | ||
|
||
import mcjty.theoneprobe.api.*; | ||
import mcjty.theoneprobe.Utilities; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockCocoa; | ||
import net.minecraft.block.BlockStem; | ||
import net.minecraft.block.properties.IProperty; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.init.Items; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.world.World; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Collections; | ||
|
||
public class CropInfoProvider implements IProbeInfoProvider { | ||
|
||
private static final ItemStack PUMPKIN = new ItemStack(Blocks.PUMPKIN); | ||
private static final ItemStack MELON = new ItemStack(Blocks.MELON_BLOCK); | ||
private static final ItemStack COCOA = new ItemStack(Items.DYE, 1, 3); | ||
|
||
@Override | ||
public String getID() { | ||
return Utilities.getProviderId("crop"); | ||
} | ||
|
||
@Override | ||
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, @Nonnull IBlockState blockState, IProbeHitData data) { | ||
Block block = blockState.getBlock(); | ||
if (block instanceof BlockStem || block instanceof BlockCocoa) { | ||
for (IProperty<?> property : blockState.getProperties().keySet()) { | ||
if (!"age".equals(property.getName())) continue; | ||
if (property.getValueClass() == Integer.class) { | ||
//noinspection unchecked | ||
IProperty<Integer> integerProperty = (IProperty<Integer>) property; | ||
int age = blockState.getValue(integerProperty); | ||
int maxAge = Collections.max(integerProperty.getAllowedValues()); | ||
|
||
IProbeInfo horizontalPane = probeInfo.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER)); | ||
if (block == Blocks.PUMPKIN_STEM) horizontalPane.item(PUMPKIN); | ||
else if (block == Blocks.MELON_STEM) horizontalPane.item(MELON); | ||
else if (block == Blocks.COCOA) horizontalPane.item(COCOA); | ||
|
||
if (age == maxAge) { | ||
horizontalPane.text(TextStyleClass.OK + "{*topextras.top.growth_finished*}"); | ||
} else { | ||
horizontalPane.text(TextStyleClass.LABEL + "{*topextras.top.growth*} " + TextStyleClass.WARNING + (age * 100 / maxAge) + "%"); | ||
} | ||
return; | ||
} | ||
return; | ||
} | ||
} | ||
} | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
src/main/resources/assets/theoneprobe/recipes/probegoggles.json
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
{ | ||
"conditions": [ | ||
{ | ||
"type": "forge:mod_loaded", | ||
|