add throwable packages to dispensers and stripes pipes

This commit is contained in:
Adrian 2015-07-23 18:41:11 +02:00
parent cbd6b3168f
commit 18fa3411ac
4 changed files with 38 additions and 1 deletions

View file

@ -1,9 +1,13 @@
Improvements:
* Packages can now be thrown via Dispensers and Stripes Pipes (asie)
Bugs fixed:
* [#2892] Disconnect on large-resolution Zone Planner fullscreen (asie)
* [#2891] Boxes ignoring the south and east boundaries when rounding (hea3ven)
* Accidentally setting an area in the Zone Planner GUI upon pressing fullscreen (asie)
* Paintbrush not being re-dyeable if not fully used (asie)
* Robots going to unreachable stations passing through walls (hea3ven)
* Stripes Pipe "breaking" fluid blocks (asie)
* Wrench failing to rotate double chests and beds (asie)
* fix robots going to unreachable stations (hea3ven)

View file

@ -9,6 +9,7 @@
package buildcraft;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@ -55,6 +56,7 @@ import buildcraft.silicon.TilePackager;
import buildcraft.silicon.TileProgrammingTable;
import buildcraft.silicon.TileStampingTable;
import buildcraft.silicon.network.PacketHandlerSilicon;
import buildcraft.transport.stripes.StripesHandlerDispenser;
@Mod(name = "BuildCraft Silicon", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Silicon", dependencies = DefaultProps.DEPENDENCY_CORE)
public class BuildCraftSilicon extends BuildCraftMod {
@ -143,6 +145,9 @@ public class BuildCraftSilicon extends BuildCraftMod {
loadRecipes();
}
BlockDispenser.dispenseBehaviorRegistry.putObject(packageItem, new ItemPackage.DispenseBehaviour());
StripesHandlerDispenser.items.add(packageItem);
SiliconProxy.proxy.registerRenderers();
}

View file

@ -25,6 +25,11 @@ public class EntityPackage extends EntityThrowable {
this.pkg = stack;
}
public EntityPackage(World world, double x, double y, double z, ItemStack stack) {
super(world, x, y, z);
this.pkg = stack;
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);

View file

@ -2,12 +2,16 @@ package buildcraft.silicon;
import java.util.List;
import net.minecraft.block.BlockDispenser;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.creativetab.CreativeTabs;
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.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -17,6 +21,25 @@ import buildcraft.core.lib.utils.NBTUtils;
import buildcraft.silicon.render.PackageFontRenderer;
public class ItemPackage extends ItemBuildCraft {
public static final class DispenseBehaviour extends BehaviorDefaultDispenseItem {
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
if (stack != null && stack.getItem() instanceof ItemPackage) {
World world = source.getWorld();
EnumFacing enumfacing = BlockDispenser.func_149937_b(source.getBlockMetadata());
EntityPackage entityPackage = new EntityPackage(source.getWorld(),
source.getX() + enumfacing.getFrontOffsetX(),
source.getY() + enumfacing.getFrontOffsetY(),
source.getZ() + enumfacing.getFrontOffsetZ(), stack.copy());
entityPackage.setThrowableHeading(enumfacing.getFrontOffsetX(), enumfacing.getFrontOffsetY() + 0.1F, enumfacing.getFrontOffsetZ(), 1.1F, 6.0F);
world.spawnEntityInWorld(entityPackage);
stack.splitStack(1);
}
return stack;
}
}
public ItemPackage() {
super();
setMaxStackSize(1);