-
-
Save loordgek/bb6b9822d9ddadac09ac9af6e5c96de0 to your computer and use it in GitHub Desktop.
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
package loordgek.itemhandlerv2.test; | |
import loordgek.itemhandlerv2.CapbilityItemHandler; | |
import loordgek.itemhandlerv2.wrappers.InvWrapper; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.util.EnumFacing; | |
import net.minecraftforge.common.capabilities.Capability; | |
import net.minecraftforge.common.capabilities.ICapabilityProvider; | |
import javax.annotation.Nonnull; | |
import javax.annotation.Nullable; | |
public class CapPlayerProvider implements ICapabilityProvider { | |
private final EntityPlayer player; | |
private InvWrapper playerinv; | |
public CapPlayerProvider(EntityPlayer player) { | |
this.player = player; | |
} | |
@Override | |
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) { | |
if (playerinv == null){ | |
playerinv = new InvWrapper(player.inventory); | |
} | |
return capability == CapbilityItemHandler.ITEM_HANDLER_CAPABILITY; | |
} | |
@Nullable | |
@Override | |
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) { | |
if (playerinv == null){ | |
playerinv = new InvWrapper(player.inventory); | |
} | |
return capability == CapbilityItemHandler.ITEM_HANDLER_CAPABILITY ? CapbilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerinv) : null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment