-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable compatibility with other milking mods
- first mod: Milk All The Mobs (issue #10)
- Loading branch information
Showing
3 changed files
with
78 additions
and
5 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
26 changes: 26 additions & 0 deletions
26
src/main/java/cech12/ceramicbucket/compat/MilkAllTheMobs.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,26 @@ | ||
package cech12.ceramicbucket.compat; | ||
|
||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.passive.PigEntity; | ||
import net.minecraft.entity.passive.SheepEntity; | ||
import net.minecraft.entity.passive.horse.DonkeyEntity; | ||
import net.minecraft.entity.passive.horse.HorseEntity; | ||
import net.minecraft.entity.passive.horse.LlamaEntity; | ||
import net.minecraft.entity.passive.horse.MuleEntity; | ||
|
||
public class MilkAllTheMobs extends ModCompat.Mod implements ModCompat.MobMilkingMod { | ||
|
||
public MilkAllTheMobs() { | ||
super("milkatmobs"); | ||
} | ||
|
||
@Override | ||
public boolean canEntityBeMilked(LivingEntity entity) { | ||
return entity instanceof SheepEntity | ||
|| entity instanceof LlamaEntity | ||
|| entity instanceof PigEntity | ||
|| entity instanceof DonkeyEntity | ||
|| entity instanceof HorseEntity | ||
|| entity instanceof MuleEntity; | ||
} | ||
} |
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,42 @@ | ||
package cech12.ceramicbucket.compat; | ||
|
||
|
||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraftforge.fml.ModList; | ||
|
||
public class ModCompat { | ||
|
||
public static final Mod[] MODS = { | ||
new MilkAllTheMobs() | ||
}; | ||
|
||
public static boolean canEntityBeMilked(LivingEntity entity) { | ||
for (Mod mod : MODS) { | ||
if (mod.isLoaded() && mod instanceof MobMilkingMod && ((MobMilkingMod)mod).canEntityBeMilked(entity)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static class Mod { | ||
|
||
protected String name; | ||
|
||
public Mod(String name) { | ||
this.name = name; | ||
} | ||
|
||
public boolean isLoaded() { | ||
return ModList.get().isLoaded(this.name); | ||
} | ||
|
||
} | ||
|
||
public interface MobMilkingMod { | ||
|
||
boolean canEntityBeMilked(LivingEntity entity); | ||
|
||
} | ||
|
||
} |