Entropy Manipulator Can now be dispensed.
Matter Cannon Can now be dispensed.
This commit is contained in:
+1
-1
Submodule api updated: 8c7e3f1c77...2a5fdff792
@@ -0,0 +1,38 @@
|
||||
package appeng.helpers;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import appeng.items.tools.powered.ToolEntropyManipulator;
|
||||
import appeng.util.Platform;
|
||||
|
||||
final public class DispenserEntropyManipulator extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
|
||||
@Override
|
||||
protected ItemStack dispenseStack(IBlockSource dispenser, ItemStack dispensedItem)
|
||||
{
|
||||
Item i = dispensedItem.getItem();
|
||||
if ( i instanceof ToolEntropyManipulator )
|
||||
{
|
||||
EnumFacing enumfacing = BlockDispenser.func_149937_b( dispenser.getBlockMetadata() );
|
||||
ToolEntropyManipulator tm = (ToolEntropyManipulator) i;
|
||||
|
||||
World w = dispenser.getWorld();
|
||||
if ( w instanceof WorldServer )
|
||||
{
|
||||
int x = dispenser.getXInt() + enumfacing.getFrontOffsetX();
|
||||
int y = dispenser.getYInt() + enumfacing.getFrontOffsetY();
|
||||
int z = dispenser.getZInt() + enumfacing.getFrontOffsetZ();
|
||||
|
||||
tm.onItemUse( dispensedItem, Platform.getPlayer( (WorldServer) w ), w, x, y, z, enumfacing.ordinal(), 0.5f, 0.5f, 0.5f );
|
||||
}
|
||||
}
|
||||
return dispensedItem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package appeng.helpers;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.items.tools.powered.ToolMassCannon;
|
||||
import appeng.util.Platform;
|
||||
|
||||
final public class DispenserMatterCannon extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
|
||||
@Override
|
||||
protected ItemStack dispenseStack(IBlockSource dispenser, ItemStack dispensedItem)
|
||||
{
|
||||
Item i = dispensedItem.getItem();
|
||||
if ( i instanceof ToolMassCannon )
|
||||
{
|
||||
EnumFacing enumfacing = BlockDispenser.func_149937_b( dispenser.getBlockMetadata() );
|
||||
ForgeDirection dir = ForgeDirection.UNKNOWN;
|
||||
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( enumfacing.getFrontOffsetX() == d.offsetX && enumfacing.getFrontOffsetY() == d.offsetY && enumfacing.getFrontOffsetZ() == d.offsetZ )
|
||||
dir = d;
|
||||
}
|
||||
|
||||
ToolMassCannon tm = (ToolMassCannon) i;
|
||||
|
||||
World w = dispenser.getWorld();
|
||||
if ( w instanceof WorldServer )
|
||||
{
|
||||
EntityPlayer p = Platform.getPlayer( (WorldServer) w );
|
||||
Platform.configurePlayer( p, dir, dispenser.getBlockTileEntity() );
|
||||
|
||||
p.posX += dir.offsetX;
|
||||
p.posY += dir.offsetY;
|
||||
p.posZ += dir.offsetZ;
|
||||
|
||||
dispensedItem = tm.onItemRightClick( dispensedItem, w, p );
|
||||
}
|
||||
}
|
||||
return dispensedItem;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.BlockTNT;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -23,6 +24,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import appeng.block.misc.BlockTinyTNT;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.DispenserEntropyManipulator;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.InWorldToolOperationResult;
|
||||
import appeng.util.Platform;
|
||||
@@ -154,6 +156,14 @@ public class ToolEntropyManipulator extends AEBasePoweredItem
|
||||
heatUp.put( new Combo( Blocks.snow, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.flowing_water ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
super.postInit();
|
||||
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject( this, new DispenserEntropyManipulator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase hitter)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -35,6 +36,7 @@ import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.packets.PacketMatterCannon;
|
||||
import appeng.helpers.DispenserMatterCannon;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
@@ -51,6 +53,13 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
maxStoredPower = AEConfig.instance.mattercannon_battery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
super.postInit();
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject( this, new DispenserMatterCannon() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
|
||||
{
|
||||
|
||||
@@ -382,41 +382,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
if ( i instanceof ItemBlock || i instanceof IPlantable )
|
||||
{
|
||||
EntityPlayer player = Platform.getPlayer( (WorldServer) w );
|
||||
|
||||
float pitch = 0.0f, yaw = 0.0f;
|
||||
player.yOffset = 1.8f;
|
||||
|
||||
switch (side)
|
||||
{
|
||||
case DOWN:
|
||||
pitch = 90.0f;
|
||||
player.yOffset = -1.8f;
|
||||
break;
|
||||
case EAST:
|
||||
yaw = -90.0f;
|
||||
break;
|
||||
case NORTH:
|
||||
yaw = 180.0f;
|
||||
break;
|
||||
case SOUTH:
|
||||
yaw = 0.0f;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
case UP:
|
||||
pitch = 90.0f;
|
||||
break;
|
||||
case WEST:
|
||||
yaw = 90.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
player.posX = (float) tile.xCoord + 0.5;
|
||||
player.posY = (float) tile.yCoord + 0.5;
|
||||
player.posZ = (float) tile.zCoord + 0.5;
|
||||
|
||||
player.rotationPitch = player.prevCameraPitch = player.cameraPitch = pitch;
|
||||
player.rotationYaw = player.prevCameraYaw = player.cameraYaw = yaw;
|
||||
Platform.configurePlayer( player, side, tile );
|
||||
|
||||
maxStorage = is.stackSize;
|
||||
worked = true;
|
||||
|
||||
@@ -1478,4 +1478,42 @@ public class Platform
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void configurePlayer(EntityPlayer player, ForgeDirection side, TileEntity tile)
|
||||
{
|
||||
float pitch = 0.0f, yaw = 0.0f;
|
||||
player.yOffset = 1.8f;
|
||||
|
||||
switch (side)
|
||||
{
|
||||
case DOWN:
|
||||
pitch = 90.0f;
|
||||
player.yOffset = -1.8f;
|
||||
break;
|
||||
case EAST:
|
||||
yaw = -90.0f;
|
||||
break;
|
||||
case NORTH:
|
||||
yaw = 180.0f;
|
||||
break;
|
||||
case SOUTH:
|
||||
yaw = 0.0f;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
break;
|
||||
case UP:
|
||||
pitch = 90.0f;
|
||||
break;
|
||||
case WEST:
|
||||
yaw = 90.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
player.posX = (float) tile.xCoord + 0.5;
|
||||
player.posY = (float) tile.yCoord + 0.5;
|
||||
player.posZ = (float) tile.zCoord + 0.5;
|
||||
|
||||
player.rotationPitch = player.prevCameraPitch = player.cameraPitch = pitch;
|
||||
player.rotationYaw = player.prevCameraYaw = player.cameraYaw = yaw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user