forked from DaStormBringer/AdditionalPipesBC2
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because it is a real pain when you accidentally punch your friend on a server and all your dogs attack him forever.
- Loading branch information
1 parent
b80663f
commit ca84d5d
Showing
7 changed files
with
86 additions
and
3 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
61 changes: 61 additions & 0 deletions
61
src/main/java/buildcraft/additionalpipes/item/ItemDogDeaggravator.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,61 @@ | ||
package buildcraft.additionalpipes.item; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import net.minecraft.entity.passive.EntityWolf; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.AxisAlignedBB; | ||
import net.minecraft.util.StatCollector; | ||
import net.minecraft.world.World; | ||
import buildcraft.additionalpipes.AdditionalPipes; | ||
import buildcraft.additionalpipes.utils.Log; | ||
|
||
public class ItemDogDeaggravator extends Item | ||
{ | ||
public static final String NAME = "dogDeaggravator"; | ||
|
||
public ItemDogDeaggravator() | ||
{ | ||
setUnlocalizedName(NAME); | ||
setTextureName(AdditionalPipes.MODID + ':' + NAME); | ||
setCreativeTab(AdditionalPipes.instance.creativeTab); | ||
} | ||
|
||
@Override | ||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) | ||
{ | ||
//this code adapted from EntityAIHurtByTarget.startExecuting() | ||
double horizontalRange = 16; | ||
List<?> list = world.getEntitiesWithinAABB(EntityWolf.class, AxisAlignedBB.getBoundingBox(player.posX, player.posY, player.posZ, | ||
player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).expand(horizontalRange, 10.0D, horizontalRange)); | ||
Iterator<?> iterator = list.iterator(); | ||
int wolfCounter = 0; | ||
|
||
while(iterator.hasNext()) | ||
{ | ||
EntityWolf wolf = (EntityWolf)iterator.next(); | ||
|
||
if(wolf.isTamed() && wolf.isOnSameTeam(player)) | ||
{ | ||
++wolfCounter; | ||
wolf.setAttackTarget(null); | ||
} | ||
} | ||
|
||
world.playSoundAtEntity(player, "additionalpipes:bellRing", 1, 1); | ||
Log.debug("Cleared attack target on " + wolfCounter + " wolves."); | ||
|
||
return itemStack; | ||
|
||
} | ||
|
||
@SuppressWarnings({ "unchecked", "rawtypes" }) | ||
@Override | ||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) | ||
{ | ||
list.add(StatCollector.translateToLocal("tooltip.dogDeaggravator")); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"bellRing": { | ||
"category": "master", | ||
"sounds": [{ | ||
"name": "copper-bell", | ||
"stream": false | ||
}] | ||
} | ||
} |
Binary file not shown.
Binary file added
BIN
+310 Bytes
src/main/resources/assets/additionalpipes/textures/items/dogDeaggravator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.