Skip to content

Commit

Permalink
More @SideOnly(Side.CLIENT)
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed May 29, 2024
1 parent 65df806 commit 3ea07b3
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 66 deletions.
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;
}
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/mcjty/theoneprobe/config/TopModGuiFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.IModGuiFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.Set;

@SideOnly(Side.CLIENT)
public class TopModGuiFactory implements IModGuiFactory {

@Override
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/mcjty/theoneprobe/gui/HitBox.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package mcjty.theoneprobe.gui;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
class HitBox {
private final int x1;
private final int y1;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/mcjty/theoneprobe/gui/Preset.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import mcjty.theoneprobe.api.TextStyleClass;
import org.apache.commons.lang3.tuple.Pair;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.HashMap;
import java.util.Map;

@SideOnly(Side.CLIENT)
class Preset {
private final String name;
private final int boxBorderColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import static mcjty.theoneprobe.api.TextStyleClass.ERROR;
@SideOnly(Side.CLIENT)
public class OverlayRenderer {

private static Map<Pair<Integer,BlockPos>, Pair<Long, ProbeInfo>> cachedInfo = new HashMap<>();
Expand Down
50 changes: 48 additions & 2 deletions src/main/resources/assets/theoneprobe/lang/fr_fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,52 @@ item.theoneprobe.diamond_helmet_probe.name=Casque en diamant avec Sonde
item.theoneprobe.gold_helmet_probe.name=Casque en or avec Sonde
item.theoneprobe.iron_helmet_probe.name=Casque en fer avec Sonde
item.theoneprobe.creativeprobe.name=La Sonde créative
item.theoneprobe.probenote.name=The One Probe: à lire

itemGroup.Probe=La Sonde
theoneprobe.probe.harvestable_indicator=Harvestable
theoneprobe.probe.not_harvestable_indicator=Not Harvestable
theoneprobe.probe.notool_indicator=No Tool
theoneprobe.probe.empty_indicator=Empty
theoneprobe.probe.bottle_indicator=Bottle
theoneprobe.probe.bottles_indicator=Bottles
theoneprobe.probe.enchanting_power_indicator=Enchanting Power:
theoneprobe.probe.tnt_fuse_indicator=TNT Fuse:
theoneprobe.probe.fuel_indicator=Fuel:
theoneprobe.probe.power_indicator=Power:
theoneprobe.probe.time_indicator=Time:
theoneprobe.probe.error_indicator=Error:
theoneprobe.probe.tool_indicator=Tool:
theoneprobe.probe.growing_time_indicator=Growing Time:
theoneprobe.probe.health_indicator=Health:
theoneprobe.probe.rotation_indicator=Rotation:
theoneprobe.probe.unknown_owner_indicator=Unknown owner
theoneprobe.probe.owned_by_indicator=Owned by:
theoneprobe.probe.jump_height_indicator=Jump height:
theoneprobe.probe.speed_indicator=Speed:
theoneprobe.probe.playing_indicator=Playing:
theoneprobe.probe.collar_color_indicator=Collar Color:

config.theoneprobe.config.title=The One Probe Config

gui.theoneprobe.gui_note.title=Things you should know about §6The One Probe
gui.theoneprobe.gui_note.body.1=§lThis mod can show a tooltip on screen
gui.theoneprobe.gui_note.body.2=§lwhen you look at a block or an entity
gui.theoneprobe.gui_note.needed.1=In this pack the probe is configured to be
gui.theoneprobe.gui_note.needed.2=required in order to see the tooltip
gui.theoneprobe.gui_note.not_needed.1=In this pack the probe is configured to be not
gui.theoneprobe.gui_note.not_needed.2=required in order to see the tooltip
gui.theoneprobe.gui_note.needed_for_extended.1=In this pack the probe is configured to be
gui.theoneprobe.gui_note.needed_for_extended.2=required to see extended information (when
gui.theoneprobe.gui_note.needed_for_extended.3=sneaking) but not for basic information
gui.theoneprobe.gui_note.needed_hard.1=In this pack the probe is configured to be
gui.theoneprobe.gui_note.needed_hard.2=required in order to see the tooltip
gui.theoneprobe.gui_note.needed_hard.3=This is set server side
gui.theoneprobe.gui_note.tail.1=Check out the 'Mod Options... for many client'
gui.theoneprobe.gui_note.tail.2=side configuration settings or sneak-right click
gui.theoneprobe.gui_note.tail.3=this note for more user-friendly setup
gui.theoneprobe.gui_note.button.title=§l§aYou can change this here:
gui.theoneprobe.gui_note.button.needed=Needed
gui.theoneprobe.gui_note.button.not_needed=Not needed
gui.theoneprobe.gui_note.button.extended=Extended

item.theoneprobe.probenote.name=The One Probe: à lire
itemGroup.Probe=La Sonde
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"conditions": [
{
"type": "forge:mod_loaded",
Expand Down

0 comments on commit 3ea07b3

Please sign in to comment.