AutoSwitch support (#2175). Thanks to dexman545

This commit is contained in:
Deximus-Maximus 2020-07-28 08:13:19 -04:00 committed by GitHub
parent d0c32e8efb
commit a0644ac434
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 1 deletions

View file

@ -93,6 +93,8 @@ dependencies {
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
modApi 'teamreborn:energy:0.1.0'
optionalDependency "com.github.dexman545:autoswitch-api:-SNAPSHOT"
}
def optionalDependency(String dep) {

View file

@ -0,0 +1,42 @@
package techreborn.compat.autoswitch;
import autoswitch.api.AutoSwitchApi;
import autoswitch.api.AutoSwitchMap;
import autoswitch.api.DurabilityGetter;
import net.minecraft.item.Item;
import net.minecraft.tag.Tag;
import org.apache.commons.lang3.tuple.Pair;
import reborncore.common.util.ItemUtils;
import techreborn.items.tool.ChainsawItem;
import techreborn.items.tool.DrillItem;
import techreborn.items.tool.JackhammerItem;
import techreborn.items.tool.advanced.RockCutterItem;
import techreborn.items.tool.basic.ElectricTreetapItem;
import techreborn.items.tool.industrial.NanosaberItem;
import techreborn.items.tool.industrial.OmniToolItem;
public class AutoSwitchApiImpl implements AutoSwitchApi {
@Override
public void moddedTargets(AutoSwitchMap<String, Object> targets, AutoSwitchMap<String, String> actionConfig, AutoSwitchMap<String, String> usableConfig) {
}
@Override
public void moddedToolGroups(AutoSwitchMap<String, Pair<Tag<Item>, Class<?>>> toolGroupings) {
}
@Override
public void customDamageSystems(AutoSwitchMap<Class<?>, DurabilityGetter> damageMap) {
// Multiple by 100 to get percentage out of decimal form
damageMap.put(DrillItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack));
damageMap.put(ChainsawItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack));
damageMap.put(JackhammerItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack));
damageMap.put(NanosaberItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack));
damageMap.put(OmniToolItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack));
damageMap.put(ElectricTreetapItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack));
damageMap.put(RockCutterItem.class, stack -> 100 * ItemUtils.getPowerForDurabilityBar(stack));
}
}

View file

@ -24,7 +24,10 @@
],
"libcd": [
"techreborn.compat.libcd.LibCDPlugin"
]
],
"autoswitch": [
"techreborn.compat.autoswitch.AutoSwitchApiImpl"
]
},
"depends": {
"fabricloader": ">=0.6.3",