Skip to content

Commit

Permalink
Add the Dog Deaggravator.
Browse files Browse the repository at this point in the history
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
multiplemonomials committed Jul 4, 2015
1 parent b80663f commit ca84d5d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import buildcraft.additionalpipes.gates.GateProvider;
import buildcraft.additionalpipes.gates.TriggerPipeClosed;
import buildcraft.additionalpipes.gui.GuiHandler;
import buildcraft.additionalpipes.item.ItemDogDeaggravator;
import buildcraft.additionalpipes.network.PacketHandler;
import buildcraft.additionalpipes.pipes.APPipe;
import buildcraft.additionalpipes.pipes.PipeItemsAddition;
Expand Down Expand Up @@ -132,6 +133,9 @@ public class AdditionalPipes {
// chunk loader
public Block blockChunkLoader;

//dog deaggravator
public Item dogDeaggravator;

public ITriggerInternal triggerPipeClosed;

@EventHandler
Expand Down Expand Up @@ -206,11 +210,14 @@ public void init(FMLInitializationEvent event)

// ChunkLoader
blockChunkLoader = new BlockChunkLoader();
blockChunkLoader.setBlockName("TeleportTether");
blockChunkLoader.setBlockName("teleportTether");
GameRegistry.registerBlock(blockChunkLoader, ItemBlock.class, "chunkLoader");
GameRegistry.registerTileEntity(TileChunkLoader.class, "TeleportTether");
GameRegistry.addRecipe(new ItemStack(blockChunkLoader), new Object[] { "iii", "iLi", "iii", 'i', Items.iron_ingot, 'L', new ItemStack(Items.dye, 1, 4) });

dogDeaggravator = new ItemDogDeaggravator();
GameRegistry.registerItem(dogDeaggravator, ItemDogDeaggravator.NAME);

Log.info("Running Teleport Manager Tests");
TeleportManagerTest.runAllTests();

Expand Down
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"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public EnumRarity getRarity(ItemStack stack) {
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
super.addInformation(stack, player, list, advanced);
String key = "tip." + stack.getItem().getClass().getSimpleName();
String key = "tooltip." + stack.getItem().getClass().getSimpleName();

list.add(StatCollector.translateToLocal(key));
}
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/assets/additionalpipes/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ item.PipeItemsAddition.name=Addition Transport Pipe
item.PipeLiquidsObsidian.name=Obsidian Fluid Pipe
item.PipeItemsJeweled.name=Jeweled Transport Pipe

#regular items & blocks
item.dogDeaggravator.name=Dog Deaggravator
block.teleportTether.name=Teleport Tether

gui.pipeItemsDistributor=Distribution Pipe
gui.pipeItemsPriorityInsertion=Priority Insertion Pipe
gui.PipeItemsAdvancedWood=Advanced Wooden Pipe
Expand All @@ -39,7 +43,9 @@ gate.pipeClosed=Pipe Closed (Storing Items)
key.lasers=Toggle chunk loading boundaries display

#tooltip for teleport pipes
tip.ItemPipeAP=No more long pipelines!
tooltip.ItemPipeAP=No more long pipelines!

tooltip.dogDeaggravator=Calms down attacking wolves

itemGroup.buildcraft.apcreativetab=Additional Pipes

Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/assets/additionalpipes/sounds.json
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ca84d5d

Please sign in to comment.