Add ProjectE API

This commit is contained in:
raoulvdberge
2017-09-02 14:20:18 +02:00
parent 0fc75c5a43
commit 78cd47a619
30 changed files with 1075 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
package moze_intel.projecte.api.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
/**
* This interfaces specifies items that perform a specific function every tick when inside an Alchemical Bag, on a player
*
* @author williewillus
*/
public interface IAlchBagItem {
/**
* Called on both client and server every time the alchemical bag ticks this item
*
* @param inv The inventory of the bag
* @param player The player whose bag is being ticked
* @param stack The ItemStack being ticked
* @return Whether the inventory was changed by this item ticking
*/
boolean updateInAlchBag(@Nonnull IItemHandler inv, @Nonnull EntityPlayer player, @Nonnull ItemStack stack);
}

View File

@@ -0,0 +1,24 @@
package moze_intel.projecte.api.item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
/**
* This interface specifies items that perform a specific function every tick when inside an Alchemical Chest
*
* @author williewillus
*/
public interface IAlchChestItem {
/**
* Called on both client and server every time the alchemical chest ticks this item
* Implementers that modify the chest inventory (serverside) MUST call markDirty() on the tile entity.
* If you do not, your changes may not be saved when the world/chunk unloads!
*
* @param world The World
* @param stack The ItemStack being ticked
*/
void updateInAlchChest(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ItemStack stack);
}

View File

@@ -0,0 +1,23 @@
package moze_intel.projecte.api.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* This interface specifies items that perform a specific function when the Extra Function key is activated (default C)
*/
public interface IExtraFunction {
/**
* Called serverside when the server receives a Extra Function key packet
*
* @param stack The ItemStack performing this function
* @param player The player performing this function
* @param hand The hand this stack was in, or null if the call was not from the player's hands
* @return Whether the operation succeeded
*/
boolean doExtraFunction(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, @Nullable EnumHand hand);
}

View File

@@ -0,0 +1,31 @@
package moze_intel.projecte.api.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* This interface specifies items that have a charge that changes when the respective keybinding is activated (default V)
*/
public interface IItemCharge {
/**
* Returns the current charge on the given ItemStack
*
* @param stack Stack whose charge we want
* @return The charge on the stack
*/
byte getCharge(@Nonnull ItemStack stack);
/**
* Called serverside when the player presses the charge keybinding; reading sneaking state is up to you
*
* @param player The player
* @param stack The item being charged
* @param hand The hand this stack was in, or null if the call was not from the player's hands
* @return Whether the operation succeeded
*/
boolean changeCharge(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nullable EnumHand hand);
}

View File

@@ -0,0 +1,46 @@
package moze_intel.projecte.api.item;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
/**
* This interface defines the contract for items that wish to expose their internal EMC storage for external manipulation
*
* @author williewillus
*/
public interface IItemEmc {
/**
* Adds EMC to the itemstack
*
* @param stack The itemstack to add to
* @param toAdd The maximum amount to add
* @return The amount that was actually added
*/
double addEmc(@Nonnull ItemStack stack, double toAdd);
/**
* Extracts EMC from the itemstack
*
* @param stack The itemstack to remove from
* @param toRemove The maximum amount to remove
* @return The amount that was actually extracted
*/
double extractEmc(@Nonnull ItemStack stack, double toRemove);
/**
* Gets the current EMC this stack is showing to the public
*
* @param stack The stack to query
* @return The current publicly-accessible EMC stored in this stack
*/
double getStoredEmc(@Nonnull ItemStack stack);
/**
* Gets the maximum EMC that is allowed to be stored in this stack
*
* @param stack The stack to query
* @return The maximum amount of publicly-accessible EMC that can be stored in this stack
*/
double getMaximumEmc(@Nonnull ItemStack stack);
}

View File

@@ -0,0 +1,31 @@
package moze_intel.projecte.api.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* This interface specifies items that switch between modes when the mode switch keybind is activated (default G)
*/
public interface IModeChanger {
/**
* Gets the mode from this ItemStack
*
* @param stack The stack we want the mode of
* @return The mode of this ItemStack
*/
byte getMode(@Nonnull ItemStack stack);
/**
* Called serverside when the player presses change mode
*
* @param player The player pressing the change mode key
* @param stack The stack whose mode we are changing
* @param hand The hand this stack was in, or null if the call was not from the player's hands
* @return Whether the operation succeeded
*/
boolean changeMode(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nullable EnumHand hand);
}

View File

@@ -0,0 +1,35 @@
package moze_intel.projecte.api.item;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import java.util.List;
/**
* This interface specifies items that perform a specific function every tick when inside an activated Dark Matter Pedestal
*
* @author williewillus
*/
public interface IPedestalItem {
@SideOnly(Side.CLIENT)
String TOOLTIPDISABLED = TextFormatting.RED + I18n.format("pe.pedestal.item_disabled");
/***
* Called on both client and server each time an active DMPedestalTile ticks with this item inside
*/
void updateInPedestal(@Nonnull World world, @Nonnull BlockPos pos);
/***
* Called clientside when inside the pedestal gui to add special function descriptions
* @return Brief strings describing the item's function in an activated pedestal
*/
@SideOnly(Side.CLIENT)
@Nonnull
List<String> getPedestalDescription();
}

View File

@@ -0,0 +1,23 @@
package moze_intel.projecte.api.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* This interface specifies items that fire a projectile when the Shoot Projectile keybind is activated (default R)
*/
public interface IProjectileShooter {
/**
* Called serverside when the player presses the Fire Projectile Button
*
* @param player The player pressing the key
* @param stack The stack we are using to shoot
* @param hand The hand this stack was in, or null if the call was not from the player's hands
* @return If the projectile was actually fired
*/
boolean shootProjectile(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nullable EnumHand hand);
}