That's one heck of a commit you've got there...
I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
@@ -57,8 +57,8 @@ public final class DamageSafetyChecker {
|
||||
* This allows wizardry to request that users add it to the blacklist.
|
||||
* @param fallback The fallback damage source for when excessive looping is detected. This <b>must not</b> be the
|
||||
* same as the re-applied source, or this method is pointless! Usually it will be more general.
|
||||
* @param knockback True to apply knockback as normal, false to use the knockback-free methods in WizardryUtilities.
|
||||
* {@link WizardryUtilities#attackEntityWithoutKnockback(Entity, DamageSource, float)}.
|
||||
* @param knockback True to apply knockback as normal, false to use the knockback-free methods in WizardryUtilities
|
||||
* (see {@link WizardryUtilities#attackEntityWithoutKnockback(Entity, DamageSource, float)}).
|
||||
*/
|
||||
public static boolean attackEntitySafely(Entity target, DamageSource source, float damage,
|
||||
String originalSourceName, DamageSource fallback, boolean knockback){
|
||||
@@ -67,6 +67,7 @@ public final class DamageSafetyChecker {
|
||||
if(originalSourceName.equals(sourceName)){
|
||||
// Blacklist behaviour
|
||||
// Same as fallback behaviour, but without the log message
|
||||
// No harm in still incrementing the counter
|
||||
attacksThisTick++;
|
||||
return knockback ? target.attackEntityFrom(fallback, damage)
|
||||
: WizardryUtilities.attackEntityWithoutKnockback(target, fallback, damage);
|
||||
@@ -99,8 +100,9 @@ public final class DamageSafetyChecker {
|
||||
|
||||
/**
|
||||
* See {@link DamageSafetyChecker#attackEntitySafely(Entity, DamageSource, float, String, DamageSource, boolean)}.
|
||||
* This version is for when the original source is used as a fallback, i.e. when a damage source is being replaced
|
||||
* for technical reasons (e.g. summoned creatures) rather than as part of a game mechanic (e.g. shadow ward).
|
||||
* This version is for when the source being replaced is used as a fallback, i.e. when a damage source is being
|
||||
* replaced for technical reasons (e.g. summoned creatures) rather than as part of a game mechanic (e.g. shadow ward).
|
||||
* This means that if excessive looping is detected, the code will work as if the event was never intercepted.
|
||||
*/
|
||||
public static boolean attackEntitySafely(Entity target, DamageSource source, float damage, DamageSource originalSource, boolean knockback){
|
||||
return attackEntitySafely(target, source, damage, originalSource.getDamageType(), originalSource, knockback);
|
||||
@@ -122,9 +124,9 @@ public final class DamageSafetyChecker {
|
||||
boolean vanillaName = VANILLA_DAMAGE_NAMES.contains(originalSourceName);
|
||||
|
||||
if(aborted){
|
||||
Wizardry.logger.warn("Entity attack excessive call limit exceeded, aborting entity damage entirely!");
|
||||
Wizardry.logger.warn("SoundLoopSpellEntity attack excessive call limit reached, aborting entity damage entirely!");
|
||||
}else{
|
||||
Wizardry.logger.warn("Entity attack excessive call threshold exceeded, substituting for non-entity-based " +
|
||||
Wizardry.logger.warn("SoundLoopSpellEntity attack excessive call threshold reached, substituting for non-entity-based " +
|
||||
"damage to avert a crash.");
|
||||
}
|
||||
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package electroblob.wizardry.integration.antiqueatlas;
|
||||
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import hunternif.mc.atlas.api.AtlasAPI;
|
||||
import hunternif.mc.atlas.registry.MarkerType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
/**
|
||||
* This class handles all of wizardry's integration with the <i>Antique Atlas</i> mod. This class contains only the code
|
||||
* that requires Antique Atlas to be loaded in order to run. Conversely, all code that requires Antique Atlas to be
|
||||
* loaded is located within this class or another class in the package {@code electroblob.wizardry.integration.antiqueatlas}.
|
||||
*
|
||||
* @since Wizardry 4.2
|
||||
* @author Electroblob
|
||||
*/
|
||||
public class WizardryAntiqueAtlasIntegration {
|
||||
|
||||
public static final String ANTIQUE_ATLAS_MOD_ID = "antiqueatlas";
|
||||
|
||||
private static final ResourceLocation TOWER_MARKER = new ResourceLocation(Wizardry.MODID, "wizard_tower");
|
||||
private static final ResourceLocation SHRINE_MARKER = new ResourceLocation(Wizardry.MODID, "shrine");
|
||||
private static final ResourceLocation OBELISK_MARKER = new ResourceLocation(Wizardry.MODID, "obelisk");
|
||||
|
||||
private static boolean antiqueAtlasLoaded;
|
||||
|
||||
public static void init(){
|
||||
antiqueAtlasLoaded = Loader.isModLoaded(ANTIQUE_ATLAS_MOD_ID);
|
||||
Wizardry.proxy.registerAtlasMarkers(); // Needs routing through the proxies to make sure it's only client-side
|
||||
}
|
||||
|
||||
public static boolean enabled(){
|
||||
return Wizardry.settings.antiqueAtlasIntegration && antiqueAtlasLoaded;
|
||||
}
|
||||
|
||||
/** Places a global wizard tower marker in all antique atlases at the given coordinates in the given world if
|
||||
* {@link electroblob.wizardry.Settings#autoTowerMarkers} is enabled. Server side only! */
|
||||
public static void markTower(World world, int x, int z){
|
||||
if(enabled() && Wizardry.settings.autoTowerMarkers){
|
||||
AtlasAPI.getMarkerAPI().putGlobalMarker(world, false, TOWER_MARKER.toString(), "integration.antiqueatlas.marker." + TOWER_MARKER.toString(), x, z);
|
||||
}
|
||||
}
|
||||
|
||||
/** Places a global obelisk marker in all antique atlases at the given coordinates in the given world if
|
||||
* {@link electroblob.wizardry.Settings#autoObeliskMarkers} is enabled. Server side only! */
|
||||
public static void markObelisk(World world, int x, int z){
|
||||
if(enabled() && Wizardry.settings.autoObeliskMarkers){
|
||||
AtlasAPI.getMarkerAPI().putGlobalMarker(world, false, OBELISK_MARKER.toString(), "integration.antiqueatlas.marker." + OBELISK_MARKER.toString(), x, z);
|
||||
}
|
||||
}
|
||||
|
||||
/** Places a global shrine marker in all antique atlases at the given coordinates in the given world if
|
||||
* {@link electroblob.wizardry.Settings#autoShrineMarkers} is enabled. Server side only! */
|
||||
public static void markShrine(World world, int x, int z){
|
||||
if(enabled() && Wizardry.settings.autoShrineMarkers){
|
||||
AtlasAPI.getMarkerAPI().putGlobalMarker(world, false, SHRINE_MARKER.toString(), "integration.antiqueatlas.marker." + SHRINE_MARKER.toString(), x, z);
|
||||
}
|
||||
}
|
||||
|
||||
/** Registers the marker icons with Antique Atlas. Client side only! */
|
||||
public static void registerMarkers(){
|
||||
|
||||
if(!enabled()) return;
|
||||
|
||||
AtlasAPI.getMarkerAPI().registerMarker(new MarkerType(TOWER_MARKER, new ResourceLocation(Wizardry.MODID, "textures/integration/antiqueatlas/wizard_tower.png")));
|
||||
AtlasAPI.getMarkerAPI().registerMarker(new MarkerType(SHRINE_MARKER, new ResourceLocation(Wizardry.MODID, "textures/integration/antiqueatlas/shrine.png")));
|
||||
AtlasAPI.getMarkerAPI().registerMarker(new MarkerType(OBELISK_MARKER, new ResourceLocation(Wizardry.MODID, "textures/integration/antiqueatlas/obelisk.png")));
|
||||
}
|
||||
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package electroblob.wizardry.integration.baubles;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.BaublesApi;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.api.cap.BaublesCapabilities;
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.item.ItemArtefact;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This class handles all of wizardry's integration with the <i>Baubles</i> mod. This class contains only the code
|
||||
* that requires Baubles to be loaded in order to run. Conversely, all code that requires Baubles to be loaded is
|
||||
* located within this class or another class in the package {@code electroblob.wizardry.integration.baubles}.
|
||||
*
|
||||
* @since Wizardry 4.2
|
||||
* @author Electroblob
|
||||
*/
|
||||
public final class WizardryBaublesIntegration {
|
||||
|
||||
public static final String BAUBLES_MOD_ID = "baubles";
|
||||
|
||||
private static final Map<ItemArtefact.Type, BaubleType> ARTEFACT_TYPE_MAP = new EnumMap<>(ItemArtefact.Type.class);
|
||||
|
||||
private static boolean baublesLoaded;
|
||||
|
||||
public static void init(){
|
||||
|
||||
baublesLoaded = Loader.isModLoaded(BAUBLES_MOD_ID);
|
||||
|
||||
if(!enabled()) return;
|
||||
|
||||
ARTEFACT_TYPE_MAP.put(ItemArtefact.Type.RING, BaubleType.RING);
|
||||
ARTEFACT_TYPE_MAP.put(ItemArtefact.Type.AMULET, BaubleType.AMULET);
|
||||
ARTEFACT_TYPE_MAP.put(ItemArtefact.Type.CHARM, BaubleType.CHARM);
|
||||
}
|
||||
|
||||
public static boolean enabled(){
|
||||
return Wizardry.settings.baublesIntegration && baublesLoaded;
|
||||
}
|
||||
|
||||
// Wrappers for BaublesApi methods
|
||||
|
||||
/**
|
||||
* Return true if the given item is equipped in any bauble slot.
|
||||
* @param player The player whose inventory is to be checked.
|
||||
* @param item The item to check for.
|
||||
* @return True if the given item is equipped in a bauble slot, false otherwise.
|
||||
*/
|
||||
public static boolean isBaubleEquipped(EntityPlayer player, Item item){
|
||||
return BaublesApi.isBaubleEquipped(player, item) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of artefact stacks equipped of the given types.
|
||||
* @param player The player whose inventory is to be checked.
|
||||
* @param types Zero or more artefact types to check for. If omitted, searches for all types.
|
||||
* @return A list of equipped artefact {@code ItemStacks}.
|
||||
*/
|
||||
// This could return all ItemStacks, but if an artefact type is given this doesn't really make sense.
|
||||
public static List<ItemArtefact> getEquippedArtefacts(EntityPlayer player, ItemArtefact.Type... types){
|
||||
|
||||
List<ItemArtefact> artefacts = new ArrayList<>();
|
||||
|
||||
for(ItemArtefact.Type type : types){
|
||||
for(int slot : ARTEFACT_TYPE_MAP.get(type).getValidSlots()){
|
||||
ItemStack stack = BaublesApi.getBaublesHandler(player).getStackInSlot(slot);
|
||||
if(stack.getItem() instanceof ItemArtefact) artefacts.add((ItemArtefact)stack.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
return artefacts;
|
||||
}
|
||||
|
||||
// Shamelessly copied from The Twilight Forest, with a few modifications
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final class ArtefactBaubleProvider implements ICapabilityProvider {
|
||||
|
||||
private BaubleType type;
|
||||
|
||||
public ArtefactBaubleProvider(ItemArtefact.Type type){
|
||||
this.type = ARTEFACT_TYPE_MAP.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing){
|
||||
return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing){
|
||||
// This lambda expression is an implementation of the entire IBauble interface
|
||||
return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE ? (T)(IBauble)itemStack -> type : null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user