Skip to content

Commit

Permalink
Dev-5!
Browse files Browse the repository at this point in the history
Fixed the enchantment indicator looking weird
Fully translated en_ud.lang and fr_fr.lang
@ParametersAreNonnullByDefault to what needs it
Better mcmod.info
  • Loading branch information
strubium committed Jun 4, 2024
1 parent 4805e2c commit d857aaf
Show file tree
Hide file tree
Showing 27 changed files with 177 additions and 165 deletions.
5 changes: 3 additions & 2 deletions src/api/java/baubles/api/BaubleType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package baubles.api;

@SuppressWarnings("unused")
public enum BaubleType {
AMULET(0),
RING(1,2),
Expand All @@ -9,9 +10,9 @@ public enum BaubleType {
BODY(5),
CHARM(6);

int[] validSlots;
final int[] validSlots;

private BaubleType(int ... validSlots) {
BaubleType(int ... validSlots) {
this.validSlots = validSlots;
}

Expand Down
4 changes: 3 additions & 1 deletion src/api/java/baubles/api/BaublesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public static IBaublesItemHandler getBaublesHandler(EntityPlayer player)
public static IInventory getBaubles(EntityPlayer player)
{
IBaublesItemHandler handler = player.getCapability(BaublesCapabilities.CAPABILITY_BAUBLES, null);
handler.setPlayer(player);
if (handler != null) {
handler.setPlayer(player);
}
return new BaublesInventoryWrapper(handler, player);
}

Expand Down
18 changes: 9 additions & 9 deletions src/api/java/baubles/api/IBauble.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,53 @@
*
* @author Azanor
*/

@SuppressWarnings("unused")
public interface IBauble {

/**
* This method return the type of bauble this is.
* Type is used to determine the slots it can go into.
*/
public BaubleType getBaubleType(ItemStack itemstack);
BaubleType getBaubleType(ItemStack itemstack);

/**
* This method is called once per tick if the bauble is being worn by a player
*/
public default void onWornTick(ItemStack itemstack, EntityLivingBase player) {
default void onWornTick(ItemStack itemstack, EntityLivingBase player) {
}

/**
* This method is called when the bauble is equipped by a player
*/
public default void onEquipped(ItemStack itemstack, EntityLivingBase player) {
default void onEquipped(ItemStack itemstack, EntityLivingBase player) {
}

/**
* This method is called when the bauble is unequipped by a player
*/
public default void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
default void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
}

/**
* can this bauble be placed in a bauble slot
*/
public default boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
default boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
return true;
}

/**
* Can this bauble be removed from a bauble slot
*/
public default boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
default boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
return true;
}

/**
* Will bauble automatically sync to client if a change is detected in its NBT or damage values?
* Default is off, so override and set to true if you want to auto sync.
* This sync is not instant, but occurs every 10 ticks (.5 seconds).
* This sync is not instant, but occurs every 10 ticks (.5 seconds at 20tps).
*/
public default boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) {
default boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) {
return false;
}
}
2 changes: 1 addition & 1 deletion src/api/java/baubles/api/cap/BaubleItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import baubles.api.BaubleType;
import baubles.api.IBauble;
import net.minecraft.item.ItemStack;

@SuppressWarnings("unused")
public class BaubleItem implements IBauble
{
private BaubleType baubleType;
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/baubles/api/cap/BaublesContainerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable;

@SuppressWarnings("unused")
public class BaublesContainerProvider implements INBTSerializable<NBTTagCompound>, ICapabilityProvider {

private final BaublesContainer container;
Expand Down
8 changes: 4 additions & 4 deletions src/api/java/baubles/api/cap/IBaublesItemHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

public interface IBaublesItemHandler extends IItemHandlerModifiable {

public boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player);
boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player);

/**
* Used internally to prevent equip/unequip events from triggering when they shouldn't
*/
public boolean isEventBlocked();
public void setEventBlock(boolean blockEvents);
boolean isEventBlocked();
void setEventBlock(boolean blockEvents);

/**
* Used internally for syncing. Indicates if the inventory has changed since last sync
*/
boolean isChanged(int slot);
void setChanged(int slot, boolean changed);

public void setPlayer(EntityLivingBase player);
void setPlayer(EntityLivingBase player);
}
7 changes: 7 additions & 0 deletions src/api/java/baubles/api/inv/BaublesInventoryWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;

import javax.annotation.ParametersAreNonnullByDefault;

public class BaublesInventoryWrapper implements IInventory {
final IBaublesItemHandler handler;
final EntityPlayer player;
Expand Down Expand Up @@ -66,6 +68,7 @@ public ItemStack removeStackFromSlot(int index) {
}

@Override
@ParametersAreNonnullByDefault
public void setInventorySlotContents(int index, ItemStack stack) {
handler.setStackInSlot(index, stack);
}
Expand All @@ -79,17 +82,21 @@ public int getInventoryStackLimit() {
public void markDirty() { }

@Override
@ParametersAreNonnullByDefault
public boolean isUsableByPlayer(EntityPlayer player) {
return true;
}

@Override
@ParametersAreNonnullByDefault
public void openInventory(EntityPlayer player) { }

@Override
@ParametersAreNonnullByDefault
public void closeInventory(EntityPlayer player) { }

@Override
@ParametersAreNonnullByDefault
public boolean isItemValidForSlot(int index, ItemStack stack) {
return handler.isItemValidForSlot(index, stack, player);
}
Expand Down
9 changes: 5 additions & 4 deletions src/api/java/baubles/api/render/IRenderBauble.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
import net.minecraft.util.math.MathHelper;

/**
* A Bauble Item that implements this will be have hooks to render something on
* A Bauble Item that implements this will have hooks to render something on
* the player while its equipped.
* This class doesn't extend IBauble to make the API not depend on the Baubles
* API, but the item in question still needs to implement IBauble.
*/
@SuppressWarnings("unused")
public interface IRenderBauble {

/**
Expand All @@ -30,7 +31,7 @@ public interface IRenderBauble {
* the RenderType passed in. Make sure to check against the type parameter for
* rendering.
*/
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks);
void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks);

/**
* A few helper methods for the render.
Expand Down Expand Up @@ -94,7 +95,7 @@ public static void translateToChest() {
}
}

public enum RenderType {
enum RenderType {
/**
* Render Type for the player's body, translations apply on the player's rotation.
* Sneaking is not handled and should be done during the render.
Expand All @@ -107,6 +108,6 @@ public enum RenderType {
* Sneaking is not handled and should be done during the render.
* @see IRenderBauble.Helper
*/
HEAD;
HEAD
}
}
6 changes: 2 additions & 4 deletions src/main/java/mcjty/theoneprobe/TheOneProbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
import java.util.function.Function;

@Mod(modid = TheOneProbe.MODID, name="TheOneProbe",
dependencies =
"after:forge@[" + TheOneProbe.MIN_FORGE11_VER + ",);" +
"after:tesla",
dependencies = "after:forge@[" + TheOneProbe.MIN_FORGE11_VER + ",);",
version = TheOneProbe.VERSION,
acceptedMinecraftVersions = "[1.12,1.13)",
acceptedMinecraftVersions = "[1.12,1.13]",
guiFactory = "mcjty.theoneprobe.config.TopModGuiFactory")
public class TheOneProbe {
public static final String MODID = "theoneprobe";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IProbeInfoAccessor {
/**
* Add information for the probe info for the given block. This is always
* called server side.
* The given probeInfo object represents a vertical layout. So adding elements to that
* The given <code>probeInfo</code> object represents a vertical layout. So adding elements to that
* will cause them to be grouped vertically.
*/
void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IProbeInfoEntityAccessor {
/**
* Add information for the probe info for the given entity. This is always
* called server side.
* The given probeInfo object represents a vertical layout. So adding elements to that
* The given <code>probeInfo</code> object represents a vertical layout. So adding elements to that
* will cause them to be grouped vertically.
*/
void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, Entity entity, IProbeHitEntityData data);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/mcjty/theoneprobe/api/ITheOneProbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
public interface ITheOneProbe {

/**
* Optionally register a provider for your probe information. You don't have to do this. You
* Optionally: register a provider for your probe information. You don't have to do this, as you
* can also implement IProbeInfoAccessor in your block instead. If you register a provider
* with the same string ID as one that already exists it will replace that provider. This
* with the same string ID as one that already exists, it will replace that provider. This
* is one way to replace the standard providers. TheOneProbe has the following standard
* providers (registered in the given order):
*
Expand All @@ -23,12 +23,12 @@ public interface ITheOneProbe {
* and then use that. i.e. this is the provider that takes care of making sure
* that IProbeInfoAccessor works.
*
* @param provider
* @param provider The provider to register
*/
void registerProvider(IProbeInfoProvider provider);

/**
* Optionally register a provider for your probe information. You don't have to do this. You
* Optionally: register a provider for your probe information. You don't have to do this, as you
* can also implement IProbeInfoAccessor in your block instead. If you register a provider
* with the same string ID as one that already exists it will replace that provider. This
* is one way to replace the standard providers. TheOneProbe has the following standard
Expand All @@ -42,7 +42,7 @@ public interface ITheOneProbe {
* and then use that. i.e. this is the provider that takes care of making sure
* that IProbeInfoEntityAccessor works.
*
* @param provider
* @param provider The provider to register
*/
void registerEntityProvider(IProbeInfoEntityProvider provider);

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/mcjty/theoneprobe/apiimpl/TheOneProbeImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public class TheOneProbeImp implements ITheOneProbe {
public static int ELEMENT_ICON;
public static int ELEMENT_ITEMLABEL;

private List<IProbeConfigProvider> configProviders = new ArrayList<>();
private final List<IProbeConfigProvider> configProviders = new ArrayList<>();

private List<IProbeInfoProvider> providers = new ArrayList<>();
private List<IProbeInfoEntityProvider> entityProviders = new ArrayList<>();
private List<IBlockDisplayOverride> blockOverrides = new ArrayList<>();
private List<IEntityDisplayOverride> entityOverrides = new ArrayList<>();
private Map<Integer,IElementFactory> factories = new HashMap<>();
private final List<IBlockDisplayOverride> blockOverrides = new ArrayList<>();
private final List<IEntityDisplayOverride> entityOverrides = new ArrayList<>();
private final Map<Integer,IElementFactory> factories = new HashMap<>();
private int lastId = 0;

public TheOneProbeImp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void showChestInfo(ProbeMode mode, IProbeInfo probeInfo, World world, Blo

if (!stacks.isEmpty()) {
boolean showDetailed = Tools.show(mode, config.getShowChestContentsDetailed()) && stacks.size() <= ConfigSetup.showItemDetailThresshold;
showChestContents(probeInfo, world, pos, stacks, showDetailed);
showChestContents(probeInfo, stacks, showDetailed);
}
}
}
Expand All @@ -76,7 +76,7 @@ private static void addItemStack(List<ItemStack> stacks, Set<Item> foundItems, @
}
}

private static void showChestContents(IProbeInfo probeInfo, World world, BlockPos pos, List<ItemStack> stacks, boolean detailed) {
private static void showChestContents(IProbeInfo probeInfo, List<ItemStack> stacks, boolean detailed) {
IProbeInfo vertical;
IProbeInfo horizontal = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ public void addProbeEntityInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlaye
.text(LABEL + "Revenge Timer: " + INFO + revengeTimer);
}
if (entity instanceof EntityAgeable) {
if (vertical == null) {
vertical = probeInfo.vertical(new LayoutStyle().borderColor(0xffff4444).spacing(2));
}

EntityAgeable entityAgeable = (EntityAgeable) entity;
int growingAge = entityAgeable.getGrowingAge();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void showDebugInfo(IProbeInfo probeInfo, World world, IBlockState blockS
.text(LABEL + "Light: " + INFO + block.getLightValue(blockState, world, pos));
TileEntity te = world.getTileEntity(pos);
if (te != null) {
vertical.text(LABEL + "TE: " + INFO + te.getClass().getSimpleName());
vertical.text(LABEL + "TileEntity: " + INFO + te.getClass().getSimpleName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play
}
}
if (!handled) {
showStandardBlockInfo(config, mode, probeInfo, blockState, block, world, pos, player, data);
showStandardBlockInfo(config, mode, probeInfo, blockState, block, data);
}

if (Tools.show(mode, config.getShowCropPercentage())) {
Expand All @@ -74,7 +74,7 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play
showRedstonePower(probeInfo, world, blockState, data, block, Tools.show(mode, config.getShowLeverSetting()));
}
if (Tools.show(mode, config.getShowLeverSetting())) {
showLeverSetting(probeInfo, world, blockState, data, block);
showLeverSetting(probeInfo, blockState, block);
}

ChestInfoTools.showChestInfo(mode, probeInfo, world, pos, config);
Expand Down Expand Up @@ -146,7 +146,7 @@ private void showRedstonePower(IProbeInfo probeInfo, World world, IBlockState bl
}
}

private void showLeverSetting(IProbeInfo probeInfo, World world, IBlockState blockState, IProbeHitData data, Block block) {
private void showLeverSetting(IProbeInfo probeInfo, IBlockState blockState, Block block) {
if (block instanceof BlockLever) {
Boolean powered = blockState.getValue(BlockLever.POWERED);
probeInfo.horizontal().item(new ItemStack(Items.REDSTONE), probeInfo.defaultItemStyle().width(14).height(14))
Expand Down Expand Up @@ -252,8 +252,8 @@ private void showGrowthLevel(IProbeInfo probeInfo, IBlockState blockState) {
}
}

public static void showStandardBlockInfo(IProbeConfig config, ProbeMode mode, IProbeInfo probeInfo, IBlockState blockState, Block block, World world,
BlockPos pos, EntityPlayer player, IProbeHitData data) {
public static void showStandardBlockInfo(IProbeConfig config, ProbeMode mode, IProbeInfo probeInfo, IBlockState blockState, Block block,
IProbeHitData data) {
String modid = Tools.getModName(block);

ItemStack pickBlock = data.getPickBlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

public class EnchantingPowerInfoProvider implements IProbeInfoProvider {

private static final ItemStack ENCHANTED_BOOK = new ItemStack(Items.ENCHANTED_BOOK);

@Override
public String getID() {
return Utilities.getProviderId("enchanting_power");
Expand Down Expand Up @@ -46,7 +44,8 @@ public void addProbeInfo(ProbeMode mode, @Nonnull IProbeInfo probeInfo, EntityPl
}
if (enchantingPower > 0.0F) {
probeInfo.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER))
.item(ENCHANTED_BOOK).text(TextStyleClass.LABEL + "{*theoneprobe.probe.enchanting_power_indicator*} " + TextFormatting.LIGHT_PURPLE + Utilities.FORMAT.format(enchantingPower));
.item(new ItemStack(Items.ENCHANTED_BOOK), probeInfo.defaultItemStyle().width(16).height(16))
.text(TextStyleClass.LABEL + "{*theoneprobe.probe.enchanting_power_indicator*} " + TextFormatting.LIGHT_PURPLE + Utilities.FORMAT.format(enchantingPower));
}
}
}
Loading

0 comments on commit d857aaf

Please sign in to comment.