-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to opt out of aura handling (closes #1), made aura info c…
…apability actually registered (closes #2)
- Loading branch information
1 parent
dfd5454
commit a13b929
Showing
13 changed files
with
278 additions
and
10 deletions.
There are no files selected for viewing
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,8 +1,8 @@ | ||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties. | ||
# This is required to provide enough memory for the Minecraft decompilation process. | ||
org.gradle.jvmargs=-Xmx3G | ||
version=1.0.1 | ||
apiversion=1.0.1 | ||
version=1.0.2 | ||
apiversion=1.0.2 | ||
mcversion=1.12.2 | ||
forgeminversion=14.23.5.2768 | ||
forgeversion=14.23.5.2847 |
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
66 changes: 66 additions & 0 deletions
66
src/main/java/thecodex6824/auracontrol/SimpleCapabilityProvider.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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* AuraControl | ||
* Copyright (c) 2020 TheCodex6824. | ||
* | ||
* This file is part of AuraControl. | ||
* | ||
* AuraControl is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* AuraControl is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with AuraControl. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package thecodex6824.auracontrol; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraftforge.common.capabilities.Capability; | ||
import net.minecraftforge.common.capabilities.ICapabilitySerializable; | ||
|
||
public class SimpleCapabilityProvider<C> implements ICapabilitySerializable<NBTTagCompound> { | ||
|
||
protected C instance; | ||
protected Capability<C> cap; | ||
|
||
public SimpleCapabilityProvider(C inst, Capability<C> c) { | ||
cap = c; | ||
instance = inst; | ||
} | ||
|
||
@Override | ||
public void deserializeNBT(NBTTagCompound nbt) { | ||
cap.readNBT(instance, null, nbt); | ||
} | ||
|
||
@Override | ||
public NBTTagCompound serializeNBT() { | ||
return (NBTTagCompound) cap.writeNBT(instance, null); | ||
} | ||
|
||
@Override | ||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) { | ||
return capability == cap; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) { | ||
// in case some mod decides to query caps before they were set up | ||
if (cap != null && capability == cap) | ||
return cap.cast(instance); | ||
|
||
return null; | ||
} | ||
|
||
} |
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
Oops, something went wrong.