new conveyor wand item that masquerades as a conveyor block, performing autoplacement! (from downstream spacefork)

This commit is contained in:
George Paton 2025-03-31 18:19:34 +11:00
parent 54d2314496
commit e02142d255
22 changed files with 989 additions and 150 deletions

View File

@ -1921,12 +1921,12 @@ public class ModBlocks {
radio_torch_logic = new RadioTorchLogic().setBlockName("radio_torch_logic").setHardness(0.1F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); radio_torch_logic = new RadioTorchLogic().setBlockName("radio_torch_logic").setHardness(0.1F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
radio_telex = new RadioTelex().setBlockName("radio_telex").setHardness(3F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":radio_telex"); radio_telex = new RadioTelex().setBlockName("radio_telex").setHardness(3F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":radio_telex");
conveyor = new BlockConveyor().setBlockName("conveyor").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor"); conveyor = new BlockConveyor().setBlockName("conveyor").setHardness(2.0F).setResistance(2.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":conveyor");
conveyor_express = new BlockConveyorExpress().setBlockName("conveyor_express").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor_express"); conveyor_express = new BlockConveyorExpress().setBlockName("conveyor_express").setHardness(2.0F).setResistance(2.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":conveyor_express");
conveyor_double = new BlockConveyorDouble().setBlockName("conveyor_double").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor_double"); conveyor_double = new BlockConveyorDouble().setBlockName("conveyor_double").setHardness(2.0F).setResistance(2.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":conveyor_double");
conveyor_triple = new BlockConveyorTriple().setBlockName("conveyor_triple").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor_triple"); conveyor_triple = new BlockConveyorTriple().setBlockName("conveyor_triple").setHardness(2.0F).setResistance(2.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":conveyor_triple");
conveyor_chute = new BlockConveyorChute().setBlockName("conveyor_chute").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor"); conveyor_chute = new BlockConveyorChute().setBlockName("conveyor_chute").setHardness(2.0F).setResistance(2.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":conveyor");
conveyor_lift = new BlockConveyorLift().setBlockName("conveyor_lift").setHardness(2.0F).setResistance(2.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":conveyor"); conveyor_lift = new BlockConveyorLift().setBlockName("conveyor_lift").setHardness(2.0F).setResistance(2.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":conveyor");
crane_extractor = new CraneExtractor().setBlockName("crane_extractor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crane_extractor = new CraneExtractor().setBlockName("crane_extractor").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
crane_inserter = new CraneInserter().setBlockName("crane_inserter").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crane_inserter = new CraneInserter().setBlockName("crane_inserter").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
crane_grabber = new CraneGrabber().setBlockName("crane_grabber").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); crane_grabber = new CraneGrabber().setBlockName("crane_grabber").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);

View File

@ -1,8 +1,56 @@
package com.hbm.blocks.network; package com.hbm.blocks.network;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockConveyor extends BlockConveyorBendable { public class BlockConveyor extends BlockConveyorBendable {
public BlockConveyor() { public BlockConveyor() {
super(); super();
} }
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return ModItems.conveyor_wand;
}
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
if(tool != ToolType.SCREWDRIVER)
return false;
int meta = world.getBlockMetadata(x, y, z);
int newMeta = meta;
int dir = getPathDirection(meta);
if(!player.isSneaking()) {
if(meta > 9) meta -= 8;
if(meta > 5) meta -= 4;
newMeta = ForgeDirection.getOrientation(meta).getRotation(ForgeDirection.UP).ordinal() + dir * 4;
} else {
if(dir < 2) {
newMeta += 4;
} else {
newMeta -= 8;
// switcheroo
world.setBlock(x, y, z, ModBlocks.conveyor_lift, newMeta, 3);
return true;
}
}
world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
return true;
}
} }

View File

@ -74,6 +74,14 @@ public abstract class BlockConveyorBase extends Block implements IConveyorBelt,
return ret; return ret;
} }
public ForgeDirection getInputDirection(World world, int x, int y, int z) {
return ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
}
public ForgeDirection getOutputDirection(World world, int x, int y, int z) {
return ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)).getOpposite();
}
public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) { public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) {
return ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)); return ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
} }

View File

@ -50,6 +50,26 @@ public abstract class BlockConveyorBendable extends BlockConveyorBase implements
return super.getIcon(side, metadata); return super.getIcon(side, metadata);
} }
@Override
public ForgeDirection getInputDirection(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
int dir = getPathDirection(meta);
return ForgeDirection.getOrientation(meta - dir * 4);
}
@Override
public ForgeDirection getOutputDirection(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
int dir = getPathDirection(meta);
meta -= dir * 4;
ForgeDirection primary = ForgeDirection.getOrientation(meta).getOpposite();
if(dir == 2) return primary.getRotation(ForgeDirection.UP);
if(dir == 1) return primary.getRotation(ForgeDirection.DOWN);
return primary;
}
@Override @Override
public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) { public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) {

View File

@ -1,18 +1,26 @@
package com.hbm.blocks.network; package com.hbm.blocks.network;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import api.hbm.block.IToolable;
import api.hbm.conveyor.IConveyorBelt; import api.hbm.conveyor.IConveyorBelt;
import api.hbm.conveyor.IEnterableBlock; import api.hbm.conveyor.IEnterableBlock;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class BlockConveyorChute extends BlockConveyorBase { public class BlockConveyorChute extends BlockConveyorBase implements IToolable {
@Override @Override
public Vec3 getTravelLocation(World world, int x, int y, int z, Vec3 itemPos, double speed) { public Vec3 getTravelLocation(World world, int x, int y, int z, Vec3 itemPos, double speed) {
@ -69,4 +77,30 @@ public class BlockConveyorChute extends BlockConveyorBase {
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
return true; return true;
} }
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return ModItems.conveyor_wand;
}
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
if(tool != ToolType.SCREWDRIVER)
return false;
int meta = world.getBlockMetadata(x, y, z);
int newMeta = meta;
if(!player.isSneaking()) {
if(meta > 9) meta -= 8;
if(meta > 5) meta -= 4;
newMeta = ForgeDirection.getOrientation(meta).getRotation(ForgeDirection.UP).ordinal();
world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
} else {
world.setBlock(x, y, z, ModBlocks.conveyor, newMeta, 3);
}
return true;
}
} }

View File

@ -1,5 +1,10 @@
package com.hbm.blocks.network; package com.hbm.blocks.network;
import java.util.Random;
import com.hbm.items.ModItems;
import net.minecraft.item.Item;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -29,4 +34,15 @@ public class BlockConveyorDouble extends BlockConveyorBendable {
return Vec3.createVectorHelper(posX, y + 0.25, posZ); return Vec3.createVectorHelper(posX, y + 0.25, posZ);
} }
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return ModItems.conveyor_wand;
}
@Override
public int damageDropped(int meta) {
return 2;
}
} }

View File

@ -1,5 +1,10 @@
package com.hbm.blocks.network; package com.hbm.blocks.network;
import java.util.Random;
import com.hbm.items.ModItems;
import net.minecraft.item.Item;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -9,4 +14,15 @@ public class BlockConveyorExpress extends BlockConveyorBendable {
public Vec3 getTravelLocation(World world, int x, int y, int z, Vec3 itemPos, double speed) { public Vec3 getTravelLocation(World world, int x, int y, int z, Vec3 itemPos, double speed) {
return super.getTravelLocation(world, x, y, z, itemPos, speed * 3); return super.getTravelLocation(world, x, y, z, itemPos, speed * 3);
} }
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return ModItems.conveyor_wand;
}
@Override
public int damageDropped(int meta) {
return 1;
}
} }

View File

@ -1,17 +1,25 @@
package com.hbm.blocks.network; package com.hbm.blocks.network;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import api.hbm.block.IToolable;
import api.hbm.conveyor.IConveyorBelt; import api.hbm.conveyor.IConveyorBelt;
import api.hbm.conveyor.IEnterableBlock; import api.hbm.conveyor.IEnterableBlock;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class BlockConveyorLift extends BlockConveyorBase { public class BlockConveyorLift extends BlockConveyorBase implements IToolable {
@Override @Override
public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) { public ForgeDirection getTravelDirection(World world, int x, int y, int z, Vec3 itemPos) {
@ -75,4 +83,30 @@ public class BlockConveyorLift extends BlockConveyorBase {
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
return true; return true;
} }
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return ModItems.conveyor_wand;
}
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
if(tool != ToolType.SCREWDRIVER)
return false;
int meta = world.getBlockMetadata(x, y, z);
int newMeta = meta;
if(!player.isSneaking()) {
if(meta > 9) meta -= 8;
if(meta > 5) meta -= 4;
newMeta = ForgeDirection.getOrientation(meta).getRotation(ForgeDirection.UP).ordinal();
world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
} else {
world.setBlock(x, y, z, ModBlocks.conveyor_chute, newMeta, 3);
}
return true;
}
} }

View File

@ -1,5 +1,10 @@
package com.hbm.blocks.network; package com.hbm.blocks.network;
import java.util.Random;
import com.hbm.items.ModItems;
import net.minecraft.item.Item;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -29,4 +34,15 @@ public class BlockConveyorTriple extends BlockConveyorBendable {
return Vec3.createVectorHelper(posX, y + 0.25, posZ); return Vec3.createVectorHelper(posX, y + 0.25, posZ);
} }
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return ModItems.conveyor_wand;
}
@Override
public int damageDropped(int meta) {
return 3;
}
} }

View File

@ -3,6 +3,7 @@ package com.hbm.blocks.network;
import api.hbm.block.IToolable; import api.hbm.block.IToolable;
import com.hbm.blocks.IBlockSideRotation; import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ITooltipProvider;
import com.hbm.items.tool.ItemConveyorWand;
import com.hbm.items.tool.ItemTooling; import com.hbm.items.tool.ItemTooling;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
@ -76,6 +77,8 @@ public abstract class BlockCraneBase extends BlockContainer implements IBlockSid
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTooling) { if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTooling) {
return false; return false;
} else if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemConveyorWand) {
return false;
} else if(world.isRemote) { } else if(world.isRemote) {
return true; return true;
} else if(!player.isSneaking()) { } else if(!player.isSneaking()) {

View File

@ -2250,6 +2250,8 @@ public class ModItems {
public static Item mysteryshovel; public static Item mysteryshovel;
public static Item memory; public static Item memory;
public static Item conveyor_wand;
public static void initializeItem() public static void initializeItem()
{ {
redstone_sword = new RedstoneSword(ToolMaterial.STONE).setUnlocalizedName("redstone_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":redstone_sword"); redstone_sword = new RedstoneSword(ToolMaterial.STONE).setUnlocalizedName("redstone_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":redstone_sword");
@ -5029,6 +5031,8 @@ public class ModItems {
mysteryshovel = new ItemMS().setUnlocalizedName("mysteryshovel").setFull3D().setMaxStackSize(1).setTextureName(RefStrings.MODID + ":cursed_shovel"); mysteryshovel = new ItemMS().setUnlocalizedName("mysteryshovel").setFull3D().setMaxStackSize(1).setTextureName(RefStrings.MODID + ":cursed_shovel");
memory = new ItemBattery(Long.MAX_VALUE / 100L, 100000000000000L, 100000000000000L).setUnlocalizedName("memory").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":mo8_anim"); memory = new ItemBattery(Long.MAX_VALUE / 100L, 100000000000000L, 100000000000000L).setUnlocalizedName("memory").setMaxStackSize(1).setTextureName(RefStrings.MODID + ":mo8_anim");
conveyor_wand = new ItemConveyorWand().setUnlocalizedName("conveyor_wand").setCreativeTab(MainRegistry.machineTab).setFull3D().setTextureName(RefStrings.MODID + ":wand_s");
GunFactory.init(); GunFactory.init();
FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.mud_fluid, 1000), new ItemStack(ModItems.bucket_mud), new ItemStack(Items.bucket)); FluidContainerRegistry.registerFluidContainer(new FluidStack(ModBlocks.mud_fluid, 1000), new ItemStack(ModItems.bucket_mud), new ItemStack(Items.bucket));
@ -7237,6 +7241,7 @@ public class ModItems {
GameRegistry.registerItem(bob_nuclear, bob_nuclear.getUnlocalizedName()); GameRegistry.registerItem(bob_nuclear, bob_nuclear.getUnlocalizedName());
GameRegistry.registerItem(mysteryshovel, mysteryshovel.getUnlocalizedName()); GameRegistry.registerItem(mysteryshovel, mysteryshovel.getUnlocalizedName());
GameRegistry.registerItem(memory, memory.getUnlocalizedName()); GameRegistry.registerItem(memory, memory.getUnlocalizedName());
GameRegistry.registerItem(conveyor_wand, conveyor_wand.getUnlocalizedName());
} }
public static void addRemap(String unloc, Item item, Enum sub) { public static void addRemap(String unloc, Item item, Enum sub) {

View File

@ -0,0 +1,495 @@
package com.hbm.items.tool;
import java.util.List;
import java.util.Locale;
import org.lwjgl.input.Keyboard;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.network.BlockConveyorBase;
import com.hbm.blocks.network.BlockConveyorBendable;
import com.hbm.blocks.network.BlockCraneBase;
import com.hbm.render.util.RenderOverhead;
import com.hbm.util.I18nUtil;
import com.hbm.wiaj.WorldInAJar;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.world.BlockEvent;
public class ItemConveyorWand extends Item {
public ItemConveyorWand() {
setHasSubtypes(true);
}
public static enum ConveyorType {
REGULAR,
EXPRESS,
DOUBLE,
TRIPLE
}
public static ConveyorType getType(ItemStack stack) {
if(stack == null) return ConveyorType.REGULAR;
return ConveyorType.values()[stack.getItemDamage()];
}
public static Block getConveyorBlock(ConveyorType type) {
switch(type) {
case EXPRESS: return ModBlocks.conveyor_express;
case DOUBLE: return ModBlocks.conveyor_double;
case TRIPLE: return ModBlocks.conveyor_triple;
default: return ModBlocks.conveyor;
}
}
public static boolean hasSnakesAndLadders(ConveyorType type) {
return type == ConveyorType.REGULAR;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
for(ConveyorType type : ConveyorType.values()) {
list.add(new ItemStack(item, 1, type.ordinal()));
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName() + "." + getType(stack).name().toLowerCase(Locale.US);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
for(String s : I18nUtil.resolveKeyArray(super.getUnlocalizedName(stack) + ".desc")) {
list.add(EnumChatFormatting.YELLOW + s);
}
if(hasSnakesAndLadders(getType(stack))) {
list.add(EnumChatFormatting.AQUA + I18nUtil.resolveKey(super.getUnlocalizedName(stack) + ".vertical.desc"));
}
} else {
list.add(EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC + "Hold <" + EnumChatFormatting.YELLOW + "" + EnumChatFormatting.ITALIC + "LSHIFT" + EnumChatFormatting.DARK_GRAY
+ "" + EnumChatFormatting.ITALIC + "> to display more info");
}
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float fx, float fy, float fz) {
if(player.isSneaking() && !stack.hasTagCompound()) {
ForgeDirection dir = ForgeDirection.getOrientation(side);
Block onBlock = world.getBlock(x, y, z);
int onMeta = world.getBlockMetadata(x, y, z);
ConveyorType type = getType(stack);
if(hasSnakesAndLadders(type) && onBlock == ModBlocks.conveyor && onMeta < 6) {
if(dir == ForgeDirection.UP) {
onBlock = ModBlocks.conveyor_lift;
world.setBlock(x, y, z, onBlock, onMeta, 3);
} else if(dir == ForgeDirection.DOWN) {
onBlock = ModBlocks.conveyor_chute;
world.setBlock(x, y, z, onBlock, onMeta, 3);
}
}
Block toPlace = getConveyorBlock(type);
if(hasSnakesAndLadders(type)) {
if(onBlock == ModBlocks.conveyor_lift && dir == ForgeDirection.UP) toPlace = ModBlocks.conveyor_lift;
if(onBlock == ModBlocks.conveyor_chute && dir == ForgeDirection.DOWN) toPlace = ModBlocks.conveyor_chute;
}
x += dir.offsetX;
y += dir.offsetY;
z += dir.offsetZ;
if(world.getBlock(x, y, z).isReplaceable(world, x, y, z)) {
world.setBlock(x, y, z, toPlace);
toPlace.onBlockPlacedBy(world, x, y, z, player, stack);
stack.stackSize--;
}
return true;
}
// If placing on top of a conveyor block, auto-snap to edge if possible
// this makes it easier to connect without having to click the small edge of a conveyor
Block onBlock = world.getBlock(x, y, z);
if(onBlock instanceof BlockConveyorBendable) {
BlockConveyorBase bendable = (BlockConveyorBase) onBlock;
ForgeDirection moveDir = stack.hasTagCompound() ? bendable.getInputDirection(world, x, y, z) : bendable.getOutputDirection(world, x, y, z);
int ox = x + moveDir.offsetX;
int oy = y + moveDir.offsetY;
int oz = z + moveDir.offsetZ;
if(world.getBlock(ox, oy, oz).isReplaceable(world, ox, oy, oz)) {
side = moveDir.ordinal();
}
}
if(!stack.hasTagCompound()) {
// Starting placement
NBTTagCompound nbt = stack.stackTagCompound = new NBTTagCompound();
nbt.setInteger("x", x);
nbt.setInteger("y", y);
nbt.setInteger("z", z);
nbt.setInteger("side", side);
int count = 0;
if(player.capabilities.isCreativeMode) {
count = 256;
} else {
for(ItemStack inventoryStack : player.inventory.mainInventory) {
if(inventoryStack != null && inventoryStack.getItem() == this && inventoryStack.getItemDamage() == stack.getItemDamage()) {
count += inventoryStack.stackSize;
}
}
}
nbt.setInteger("count", count);
} else {
// Constructing conveyor
NBTTagCompound nbt = stack.stackTagCompound;
int sx = nbt.getInteger("x");
int sy = nbt.getInteger("y");
int sz = nbt.getInteger("z");
int sSide = nbt.getInteger("side");
int count = nbt.getInteger("count");
if(!world.isRemote) {
ConveyorType type = getType(stack);
// pretend to construct, if it doesn't fail, actually construct
int constructCount = construct(world, null, type, player, sx, sy, sz, sSide, x, y, z, side, 0, 0, 0, count);
if(constructCount > 0) {
int toRemove = construct(world, world, type, player, sx, sy, sz, sSide, x, y, z, side, 0, 0, 0, count);
if(!player.capabilities.isCreativeMode) {
for(ItemStack inventoryStack : player.inventory.mainInventory) {
if(inventoryStack != null && inventoryStack.getItem() == this && inventoryStack.getItemDamage() == stack.getItemDamage()) {
int removing = Math.min(toRemove, inventoryStack.stackSize);
inventoryStack.stackSize -= removing;
toRemove -= removing;
}
if(toRemove <= 0) break;
}
player.inventoryContainer.detectAndSendChanges();
}
player.addChatMessage(new ChatComponentText("Conveyor built!"));
} else if(constructCount == 0) {
player.addChatMessage(new ChatComponentText("Not enough conveyors, build cancelled"));
} else {
player.addChatMessage(new ChatComponentText("Conveyor obstructed, build cancelled"));
}
} else {
RenderOverhead.clearActionPreview();
lastMop = null;
}
stack.stackTagCompound = null;
}
return true; // always eat interactions
}
private static MovingObjectPosition lastMop;
private static int lastSide;
private static float lastYaw;
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean inHand) {
if(!(entity instanceof EntityPlayer)) return;
EntityPlayer player = (EntityPlayer) entity;
if(!inHand && stack.hasTagCompound()) {
ItemStack held = player.getHeldItem();
if(held == null || held.getItem() != this || held.getItemDamage() != stack.getItemDamage()) {
stack.stackTagCompound = null;
if(!world.isRemote) {
RenderOverhead.clearActionPreview();
lastMop = null;
}
}
}
// clientside prediction only
if(!world.isRemote && inHand) {
if(!stack.hasTagCompound()) {
RenderOverhead.clearActionPreview();
lastMop = null;
return;
}
MovingObjectPosition mop = Minecraft.getMinecraft().objectMouseOver;
if(mop == null || mop.typeOfHit != MovingObjectType.BLOCK) {
RenderOverhead.clearActionPreview();
lastMop = null;
return;
}
int x = mop.blockX;
int y = mop.blockY;
int z = mop.blockZ;
int side = mop.sideHit;
Block onBlock = world.getBlock(x, y, z);
if(onBlock instanceof BlockConveyorBendable) {
BlockConveyorBase bendable = (BlockConveyorBase) onBlock;
ForgeDirection moveDir = bendable.getInputDirection(world, x, y, z);
int ox = x + moveDir.offsetX;
int oy = y + moveDir.offsetY;
int oz = z + moveDir.offsetZ;
if(world.getBlock(ox, oy, oz).isReplaceable(world, ox, oy, oz)) {
side = moveDir.ordinal();
}
}
if(lastMop != null && mop.blockX == lastMop.blockX && mop.blockY == lastMop.blockY && mop.blockZ == lastMop.blockZ && side == lastSide && Math.abs(lastYaw - player.rotationYaw) < 15) return;
lastMop = mop;
lastYaw = player.rotationYaw;
lastSide = side;
NBTTagCompound nbt = stack.stackTagCompound;
int sx = nbt.getInteger("x");
int sy = nbt.getInteger("y");
int sz = nbt.getInteger("z");
int sSide = nbt.getInteger("side");
int count = nbt.getInteger("count");
// Size has a one block buffer on both sides, for overshooting conveyors
int sizeX = Math.abs(sx - x) + 3;
int sizeY = Math.abs(sy - y) + 3;
int sizeZ = Math.abs(sz - z) + 3;
int minX = Math.min(sx, x) - 1;
int minY = Math.min(sy, y) - 1;
int minZ = Math.min(sz, z) - 1;
WorldInAJar wiaj = new WorldInAJar(sizeX, sizeY, sizeZ);
boolean pathSuccess = construct(world, wiaj, getType(stack), player, sx, sy, sz, sSide, x, y, z, side, minX, minY, minZ, count) > 0;
RenderOverhead.setActionPreview(wiaj, minX, minY, minZ, pathSuccess);
}
}
// In creative, auto delete connected conveyors
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer playerEntity) {
World world = playerEntity.worldObj;
Block block = world.getBlock(x, y, z);
if(!playerEntity.capabilities.isCreativeMode) return false;
if(!(playerEntity instanceof EntityPlayerMP)) return false;
EntityPlayerMP player = (EntityPlayerMP) playerEntity;
if(!world.isRemote && block instanceof BlockConveyorBase) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
breakExtra(world, player, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, 32);
}
}
return false;
}
private void breakExtra(World world, EntityPlayerMP player, int x, int y, int z, int depth) {
depth--;
if(depth <= 0) return;
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if(!(block instanceof BlockConveyorBase)) return;
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
if(event.isCanceled())
return;
block.onBlockHarvested(world, x, y, z, meta, player);
if(block.removedByPlayer(world, player, x, y, z, false)) {
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
}
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
breakExtra(world, player, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, depth);
}
}
// attempts to construct a conveyor between two points, including bends, lifts, and chutes
private static int construct(World routeWorld, IBlockAccess buildWorld, ConveyorType type, EntityPlayer player, int x1, int y1, int z1, int side1, int x2, int y2, int z2, int side2, int box, int boy, int boz, int max) {
ForgeDirection dir = ForgeDirection.getOrientation(side1);
ForgeDirection targetDir = ForgeDirection.getOrientation(side2);
// if placing within a single block, we have to handle rotation specially, treating it like a manual placement with player facing
if(x1 == x2 && y1 == y2 && z1 == z2 && side1 == side2 && (dir == ForgeDirection.UP || dir == ForgeDirection.DOWN)) {
int meta = getFacingMeta(player);
y1 += dir.offsetY;
if(!routeWorld.getBlock(x1, y1, z1).isReplaceable(routeWorld, x1, y1, z1)) return -1;
Block block = getConveyorBlock(type);
if(buildWorld instanceof World) {
((World) buildWorld).setBlock(x1 - box, y1 - boy, z1 - boz, block, meta, 3);
} else if(buildWorld instanceof WorldInAJar) {
((WorldInAJar) buildWorld).setBlock(x1 - box, y1 - boy, z1 - boz, block, meta);
}
return 1;
}
boolean hasVertical = hasSnakesAndLadders(type);
int tx = x2 + targetDir.offsetX;
int ty = y2 + targetDir.offsetY;
int tz = z2 + targetDir.offsetZ;
int x = x1 + dir.offsetX;
int y = y1 + dir.offsetY;
int z = z1 + dir.offsetZ;
if(dir == ForgeDirection.UP || dir == ForgeDirection.DOWN) {
dir = getTargetDirection(x, y, z, x2, y2, z2, hasVertical);
}
Block targetBlock = routeWorld.getBlock(x2, y2, z2);
boolean isTargetHorizontal = targetDir != ForgeDirection.UP && targetDir != ForgeDirection.DOWN;
boolean shouldTurnToTarget = isTargetHorizontal || targetBlock instanceof BlockCraneBase || targetBlock == ModBlocks.conveyor_lift || targetBlock == ModBlocks.conveyor_chute;
ForgeDirection horDir = dir == ForgeDirection.UP || dir == ForgeDirection.DOWN ? ForgeDirection.getOrientation(getFacingMeta(player)).getOpposite() : dir;
// Initial dropdown to floor level, if possible
if(y > ty) {
if(routeWorld.getBlock(x, y - 1, z).isReplaceable(routeWorld, x, y - 1, z)) {
dir = ForgeDirection.DOWN;
}
}
for(int loopDepth = 1; loopDepth <= max; loopDepth++) {
if(!routeWorld.getBlock(x, y, z).isReplaceable(routeWorld, x, y, z)) return -1;
Block block = getConveyorForDirection(type, dir);
int meta = getConveyorMetaForDirection(block, dir, targetDir, horDir);
int ox = x + dir.offsetX;
int oy = y + dir.offsetY;
int oz = z + dir.offsetZ;
// check if we should turn before continuing
int fromDistance = taxiDistance(x, y, z, tx, ty, tz);
int toDistance = taxiDistance(ox, oy, oz, tx, ty, tz);
int finalDistance = taxiDistance(ox, oy, oz, x2, y2, z2);
boolean notAtTarget = (shouldTurnToTarget ? finalDistance : fromDistance) > 0;
boolean willBeObstructed = notAtTarget && !routeWorld.getBlock(ox, oy, oz).isReplaceable(routeWorld, ox, oy, oz);
boolean shouldTurn = (toDistance >= fromDistance && notAtTarget) || willBeObstructed;
if(shouldTurn) {
ForgeDirection newDir = getTargetDirection(x, y, z, shouldTurnToTarget ? x2 : tx, shouldTurnToTarget ? y2 : ty, shouldTurnToTarget ? z2 : tz, tx, ty, tz, dir, willBeObstructed, hasVertical);
if(newDir == ForgeDirection.UP) {
block = ModBlocks.conveyor_lift;
} else if(newDir == ForgeDirection.DOWN) {
block = ModBlocks.conveyor_chute;
} else if(dir.getRotation(ForgeDirection.UP) == newDir) {
meta += 8;
} else if(dir.getRotation(ForgeDirection.DOWN) == newDir) {
meta += 4;
}
dir = newDir;
if(dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) horDir = dir;
}
if(buildWorld instanceof World) {
((World) buildWorld).setBlock(x - box, y - boy, z - boz, block, meta, 3);
} else if(buildWorld instanceof WorldInAJar) {
((WorldInAJar) buildWorld).setBlock(x - box, y - boy, z - boz, block, meta);
}
if(x == tx && y == ty && z == tz) return loopDepth;
x += dir.offsetX;
y += dir.offsetY;
z += dir.offsetZ;
}
return 0;
}
private static int getFacingMeta(EntityPlayer player) {
int meta = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
switch(meta) {
case 0: return 2;
case 1: return 5;
case 2: return 3;
case 3: return 4;
}
return 2;
}
private static int getConveyorMetaForDirection(Block block, ForgeDirection dir, ForgeDirection targetDir, ForgeDirection horDir) {
if(block != ModBlocks.conveyor_chute && block != ModBlocks.conveyor_lift) return dir.getOpposite().ordinal();
if(targetDir == ForgeDirection.UP || targetDir == ForgeDirection.DOWN) return horDir.getOpposite().ordinal();
return targetDir.ordinal();
}
private static Block getConveyorForDirection(ConveyorType type, ForgeDirection dir) {
if(dir == ForgeDirection.UP) return ModBlocks.conveyor_lift;
if(dir == ForgeDirection.DOWN) return ModBlocks.conveyor_chute;
return getConveyorBlock(type);
}
private static ForgeDirection getTargetDirection(int x1, int y1, int z1, int x2, int y2, int z2, boolean hasVertical) {
return getTargetDirection(x1, y1, z1, x2, y2, z2, x2, y2, z2, null, false, hasVertical);
}
private static ForgeDirection getTargetDirection(int x1, int y1, int z1, int x2, int y2, int z2, int tx, int ty, int tz, ForgeDirection heading, boolean willBeObstructed, boolean hasVertical) {
if(hasVertical && (y1 != y2 || y1 != ty) && (willBeObstructed || (x1 == x2 && z1 == z2) || (x1 == tx && z1 == tz))) return y1 > y2 ? ForgeDirection.DOWN : ForgeDirection.UP;
if(Math.abs(x1 - x2) > Math.abs(z1 - z2)) {
if(heading == ForgeDirection.EAST || heading == ForgeDirection.WEST) return z1 > z2 ? ForgeDirection.NORTH : ForgeDirection.SOUTH;
return x1 > x2 ? ForgeDirection.WEST : ForgeDirection.EAST;
} else {
if(heading == ForgeDirection.NORTH || heading == ForgeDirection.SOUTH) return x1 > x2 ? ForgeDirection.WEST : ForgeDirection.EAST;
return z1 > z2 ? ForgeDirection.NORTH : ForgeDirection.SOUTH;
}
}
private static int taxiDistance(int x1, int y1, int z1, int x2, int y2, int z2) {
return Math.abs(x1 - x2) + Math.abs(y1 - y2) + Math.abs(z1 - z2);
}
}

View File

@ -66,7 +66,8 @@ import com.hbm.render.anim.BusAnimation;
import com.hbm.render.entity.rocket.*; import com.hbm.render.entity.rocket.*;
import com.hbm.render.item.*; import com.hbm.render.item.*;
import com.hbm.render.item.ItemRenderMissileGeneric.RenderMissileType; import com.hbm.render.item.ItemRenderMissileGeneric.RenderMissileType;
import com.hbm.render.item.block.ItemRenderDecoBlock; import com.hbm.render.item.block.ItemRenderBlock;
import com.hbm.render.item.block.ItemRenderDecoBlock;
import com.hbm.render.item.weapon.*; import com.hbm.render.item.weapon.*;
import com.hbm.render.loader.HmfModelLoader; import com.hbm.render.loader.HmfModelLoader;
import com.hbm.render.model.ModelPigeon; import com.hbm.render.model.ModelPigeon;
@ -559,6 +560,7 @@ public class ClientProxy extends ServerProxy {
MinecraftForgeClient.registerItemRenderer(ModItems.multitool_decon, new ItemRenderMultitool()); MinecraftForgeClient.registerItemRenderer(ModItems.multitool_decon, new ItemRenderMultitool());
//blocks //blocks
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.steel_roof), new ItemRenderDecoBlock()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.steel_roof), new ItemRenderDecoBlock());
MinecraftForgeClient.registerItemRenderer(ModItems.conveyor_wand, new ItemRenderBlock(ModBlocks.conveyor, ModBlocks.conveyor_express, ModBlocks.conveyor_double, ModBlocks.conveyor_triple));
} }
@Override @Override

View File

@ -31,6 +31,7 @@ import com.hbm.items.machine.ItemCircuit.EnumCircuitType;
import com.hbm.items.special.ItemCircuitStarComponent.CircuitComponentType; import com.hbm.items.special.ItemCircuitStarComponent.CircuitComponentType;
import com.hbm.items.special.ItemHolotapeImage.EnumHoloImage; import com.hbm.items.special.ItemHolotapeImage.EnumHoloImage;
import com.hbm.items.special.ItemPlasticScrap.ScrapType; import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.items.tool.ItemConveyorWand.ConveyorType;
import com.hbm.items.tool.ItemDrone.EnumDroneType; import com.hbm.items.tool.ItemDrone.EnumDroneType;
import com.hbm.items.tool.ItemGuideBook.BookType; import com.hbm.items.tool.ItemGuideBook.BookType;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
@ -220,14 +221,12 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModBlocks.radio_torch_counter, 4), new Object[] { "G", "R", "I", 'G', "dustGlowstone", 'R', Blocks.redstone_torch, 'I', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE) }); addRecipeAuto(new ItemStack(ModBlocks.radio_torch_counter, 4), new Object[] { "G", "R", "I", 'G', "dustGlowstone", 'R', Blocks.redstone_torch, 'I', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE) });
addRecipeAuto(new ItemStack(ModBlocks.radio_telex, 2), new Object[] { "SCR", "W#W", "WWW", 'S', ModBlocks.radio_torch_sender, 'C', ModItems.crt_display, 'R', ModBlocks.radio_torch_receiver, 'W', KEY_PLANKS, '#', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ANALOG) }); addRecipeAuto(new ItemStack(ModBlocks.radio_telex, 2), new Object[] { "SCR", "W#W", "WWW", 'S', ModBlocks.radio_torch_sender, 'C', ModItems.crt_display, 'R', ModBlocks.radio_torch_receiver, 'W', KEY_PLANKS, '#', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.ANALOG) });
addRecipeAuto(new ItemStack(ModBlocks.conveyor, 16), new Object[] { "LLL", "I I", "LLL", 'L', Items.leather, 'I', IRON.ingot() }); addRecipeAuto(DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR, 16), new Object[] { "LLL", "I I", "LLL", 'L', Items.leather, 'I', IRON.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.conveyor, 16), new Object[] { "RSR", "I I", "RSR", 'I', IRON.ingot(), 'R', DictFrame.fromOne(ModItems.plant_item, EnumPlantType.ROPE), 'S', IRON.plate() }); addRecipeAuto(DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR, 16), new Object[] { "RSR", "I I", "RSR", 'I', IRON.ingot(), 'R', DictFrame.fromOne(ModItems.plant_item, EnumPlantType.ROPE), 'S', IRON.plate() });
addRecipeAuto(new ItemStack(ModBlocks.conveyor, 64), new Object[] { "LLL", "I I", "LLL", 'L', ANY_RUBBER.ingot(), 'I', IRON.ingot() }); addRecipeAuto(DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR, 64), new Object[] { "LLL", "I I", "LLL", 'L', ANY_RUBBER.ingot(), 'I', IRON.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.conveyor_express, 8), new Object[] { "CCC", "CLC", "CCC", 'C', ModBlocks.conveyor, 'L', Fluids.LUBRICANT.getDict(1_000) }); addRecipeAuto(DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.EXPRESS, 8), new Object[] { "CCC", "CLC", "CCC", 'C', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR), 'L', Fluids.LUBRICANT.getDict(1_000) });
addRecipeAuto(new ItemStack(ModBlocks.conveyor_double, 3), new Object[] { "CPC", "CPC", "CPC", 'C', ModBlocks.conveyor, 'P', IRON.plate() }); addRecipeAuto(DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.DOUBLE), new Object[] { "CPC", 'C', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR), 'P', IRON.plate() });
addRecipeAuto(new ItemStack(ModBlocks.conveyor_triple, 3), new Object[] { "CPC", "CPC", "CPC", 'C', ModBlocks.conveyor_double, 'P', STEEL.plate() }); addRecipeAuto(DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.TRIPLE), new Object[] { "DPC", 'C', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR), 'D', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.DOUBLE), 'P', STEEL.plate() });
addRecipeAuto(new ItemStack(ModBlocks.conveyor_chute, 3), new Object[] { "IGI", "IGI", "ICI" , 'I', IRON.ingot(), 'G', ModBlocks.steel_grate, 'C', ModBlocks.conveyor });
addRecipeAuto(new ItemStack(ModBlocks.conveyor_lift, 3), new Object[] { "IGI", "IGI", "ICI" , 'I', IRON.ingot(), 'G', ModBlocks.chain, 'C', ModBlocks.conveyor });
//addRecipeAuto(new ItemStack(Item.getItemFromBlock(ModBlocks.machine_difurnace_off), 1), new Object[] { "T T", "PHP", "TFT", 'T', W.ingot(), 'P', ModItems.board_copper, 'H', Blocks.hopper, 'F', Blocks.furnace }); //addRecipeAuto(new ItemStack(Item.getItemFromBlock(ModBlocks.machine_difurnace_off), 1), new Object[] { "T T", "PHP", "TFT", 'T', W.ingot(), 'P', ModItems.board_copper, 'H', Blocks.hopper, 'F', Blocks.furnace });
addRecipeAuto(new ItemStack(ModBlocks.machine_difurnace_extension, 1), new Object[] { " C ", "BGB", "BGB", 'C', CU.plate(), 'B', ModItems.ingot_firebrick, 'G', ModBlocks.steel_grate }); addRecipeAuto(new ItemStack(ModBlocks.machine_difurnace_extension, 1), new Object[] { " C ", "BGB", "BGB", 'C', CU.plate(), 'B', ModItems.ingot_firebrick, 'G', ModBlocks.steel_grate });
@ -938,18 +937,18 @@ public class CraftingManager {
for(int i = 0; i < craneCasing.length / 2; i++) { for(int i = 0; i < craneCasing.length / 2; i++) {
Object casing = craneCasing[i * 2]; Object casing = craneCasing[i * 2];
int amount = (int) craneCasing[i * 2 + 1]; int amount = (int) craneCasing[i * 2 + 1];
addRecipeAuto(new ItemStack(ModBlocks.crane_inserter, amount), new Object[] { "CCC", "C C", "CBC", 'C', casing, 'B', ModBlocks.conveyor }); addRecipeAuto(new ItemStack(ModBlocks.crane_inserter, amount), new Object[] { "CCC", "C C", "CBC", 'C', casing, 'B', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR) });
addRecipeAuto(new ItemStack(ModBlocks.crane_extractor, amount), new Object[] { "CCC", "CPC", "CBC", 'C', casing, 'B', ModBlocks.conveyor, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC) }); addRecipeAuto(new ItemStack(ModBlocks.crane_extractor, amount), new Object[] { "CCC", "CPC", "CBC", 'C', casing, 'B', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR), 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC) });
addRecipeAuto(new ItemStack(ModBlocks.crane_grabber, amount), new Object[] { "C C", "P P", "CBC", 'C', casing, 'B', ModBlocks.conveyor, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC) }); addRecipeAuto(new ItemStack(ModBlocks.crane_grabber, amount), new Object[] { "C C", "P P", "CBC", 'C', casing, 'B', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR), 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC) });
} }
addRecipeAuto(new ItemStack(ModBlocks.crane_boxer), new Object[] { "WWW", "WPW", "CCC", 'W', KEY_PLANKS, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'C', ModBlocks.conveyor }); addRecipeAuto(new ItemStack(ModBlocks.crane_boxer), new Object[] { "WWW", "WPW", "CCC", 'W', KEY_PLANKS, 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'C', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR) });
addRecipeAuto(new ItemStack(ModBlocks.crane_unboxer), new Object[] { "WWW", "WPW", "CCC", 'W', KEY_STICK, 'P', Items.shears, 'C', ModBlocks.conveyor }); addRecipeAuto(new ItemStack(ModBlocks.crane_unboxer), new Object[] { "WWW", "WPW", "CCC", 'W', KEY_STICK, 'P', Items.shears, 'C', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR) });
addRecipeAuto(new ItemStack(ModBlocks.crane_router), new Object[] { "PIP", "ICI", "PIP", 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'I', ModItems.plate_polymer, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC) }); addRecipeAuto(new ItemStack(ModBlocks.crane_router), new Object[] { "PIP", "ICI", "PIP", 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'I', ModItems.plate_polymer, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC) });
addRecipeAuto(new ItemStack(ModBlocks.crane_splitter), new Object[] { "III", "PCP", "III", 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'I', STEEL.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE) }); addRecipeAuto(new ItemStack(ModBlocks.crane_splitter), new Object[] { "III", "PCP", "III", 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'I', STEEL.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.VACUUM_TUBE) });
addRecipeAuto(new ItemStack(ModBlocks.crane_partitioner), new Object[] { " M ", "BCB", 'M', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.CHIP), 'B', ModBlocks.conveyor, 'C', ModBlocks.crate_steel }); addRecipeAuto(new ItemStack(ModBlocks.crane_partitioner), new Object[] { " M ", "BCB", 'M', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.CHIP), 'B', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR), 'C', ModBlocks.crate_steel });
addRecipeAuto(new ItemStack(ModBlocks.machine_conveyor_press), new Object[] { "CPC", "CBC", "CCC", 'C', CU.plate(), 'P', ModBlocks.machine_epress, 'B', ModBlocks.conveyor }); addRecipeAuto(new ItemStack(ModBlocks.machine_conveyor_press), new Object[] { "CPC", "CBC", "CCC", 'C', CU.plate(), 'P', ModBlocks.machine_epress, 'B', DictFrame.fromOne(ModItems.conveyor_wand, ConveyorType.REGULAR) });
addRecipeAuto(new ItemStack(ModBlocks.radar_screen), new Object[] { "PCP", "SRS", "PCP", 'P', ANY_PLASTIC.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), 'S', STEEL.plate(), 'R', ModItems.crt_display }); addRecipeAuto(new ItemStack(ModBlocks.radar_screen), new Object[] { "PCP", "SRS", "PCP", 'P', ANY_PLASTIC.ingot(), 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), 'S', STEEL.plate(), 'R', ModItems.crt_display });
addRecipeAuto(new ItemStack(ModItems.radar_linker), new Object[] { "S", "C", "P", 'S', ModItems.crt_display, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), 'P', STEEL.plate() }); addRecipeAuto(new ItemStack(ModItems.radar_linker), new Object[] { "S", "C", "P", 'S', ModItems.crt_display, 'C', DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC), 'P', STEEL.plate() });

View File

@ -64,9 +64,6 @@ import com.hbm.util.ArmorRegistry.HazardClass;
import com.hbm.wiaj.GuiWorldInAJar; import com.hbm.wiaj.GuiWorldInAJar;
import com.hbm.wiaj.cannery.CanneryBase; import com.hbm.wiaj.cannery.CanneryBase;
import com.hbm.wiaj.cannery.Jars; import com.hbm.wiaj.cannery.Jars;
import com.hbm.util.ArmorRegistry;
import com.hbm.util.ArmorUtil;
import com.hbm.util.DamageResistanceHandler;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
@ -1320,6 +1317,8 @@ public class ModEventHandlerClient {
RenderOverhead.renderThermalSight(event.partialTicks); RenderOverhead.renderThermalSight(event.partialTicks);
} }
} }
RenderOverhead.renderActionPreview(event.partialTicks);
} }
@SubscribeEvent(priority = EventPriority.HIGHEST) @SubscribeEvent(priority = EventPriority.HIGHEST)

View File

@ -84,6 +84,13 @@ public class NEIConfig implements IConfigureNEI {
API.hideItem(new ItemStack(ModBlocks.spotlight_halogen_off)); API.hideItem(new ItemStack(ModBlocks.spotlight_halogen_off));
API.hideItem(new ItemStack(ModBlocks.spotlight_beam)); API.hideItem(new ItemStack(ModBlocks.spotlight_beam));
API.hideItem(new ItemStack(ModBlocks.conveyor));
API.hideItem(new ItemStack(ModBlocks.conveyor_chute));
API.hideItem(new ItemStack(ModBlocks.conveyor_lift));
API.hideItem(new ItemStack(ModBlocks.conveyor_express));
API.hideItem(new ItemStack(ModBlocks.conveyor_double));
API.hideItem(new ItemStack(ModBlocks.conveyor_triple));
API.registerHighlightIdentifier(ModBlocks.plushie, new IHighlightHandler() { API.registerHighlightIdentifier(ModBlocks.plushie, new IHighlightHandler() {
@Override public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) { @Override public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
int x = mop.blockX; int x = mop.blockX;

View File

@ -0,0 +1,42 @@
package com.hbm.render.item.block;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
public class ItemRenderBlock implements IItemRenderer {
private final Block[] blocks;
private RenderBlocks renderBlocks = new RenderBlocks();
public ItemRenderBlock(Block... blocks) {
this.blocks = blocks;
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
textureManager.bindTexture(textureManager.getResourceLocation(0));
renderBlocks.renderBlockAsItem(blocks[item.getItemDamage()], 0, 1.0F);
}
}

View File

@ -9,13 +9,17 @@ import java.util.Map.Entry;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.wiaj.WorldInAJar;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@ -366,4 +370,77 @@ public class RenderOverhead {
return this; return this;
} }
} }
private static WorldInAJar actionPreviewWorld;
private static int offsetX;
private static int offsetY;
private static int offsetZ;
private static boolean actionPreviewSuccess;
private static boolean clearPreview;
public static void setActionPreview(WorldInAJar wiaj, int x, int y, int z, boolean canAction) {
actionPreviewWorld = wiaj;
offsetX = x;
offsetY = y;
offsetZ = z;
actionPreviewSuccess = canAction;
}
// Prevents thread unsafe null exception
public static void clearActionPreview() {
clearPreview = true;
}
public static void renderActionPreview(float partialTicks) {
if(clearPreview) {
actionPreviewWorld = null;
clearPreview = false;
}
if(actionPreviewWorld == null) return;
RenderBlocks renderer = new RenderBlocks(actionPreviewWorld);
renderer.enableAO = true;
actionPreviewWorld.lightlevel = 15;
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_BLEND);
GL11.glPushMatrix();
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
double x = player.prevPosX + (player.posX - player.prevPosX) * partialTicks;
double y = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
double z = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;
GL11.glTranslated(offsetX - x, offsetY - y, offsetZ - z);
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator.instance.startDrawingQuads();
Tessellator.instance.disableColor();
if(actionPreviewSuccess) {
GL11.glColor3f(0, 1, 1);
} else {
GL11.glColor3f(1, 0, 0);
}
for(int ix = 0; ix < actionPreviewWorld.sizeX; ix++) {
for(int iy = 0; iy < actionPreviewWorld.sizeY; iy++) {
for(int iz = 0; iz < actionPreviewWorld.sizeZ; iz++) {
try { renderer.renderBlockByRenderType(actionPreviewWorld.getBlock(ix, iy, iz), ix, iy, iz); } catch(Exception ex) { }
}
}
}
Tessellator.instance.draw();
GL11.glShadeModel(GL11.GL_FLAT);
}
GL11.glPopMatrix();
}
} }

View File

@ -1897,6 +1897,10 @@ item.combine_scrap.name=CMB Schrott
item.component_emitter.name=Emitterkomponente item.component_emitter.name=Emitterkomponente
item.component_limiter.name=Stabilisatorkomponente item.component_limiter.name=Stabilisatorkomponente
item.containment_box.name=Sicherheitsbehälter item.containment_box.name=Sicherheitsbehälter
item.conveyor_wand.regular.name=Förderband
item.conveyor_wand.express.name=Expressförderband
item.conveyor_wand.double.name=Zweispuriges Förderband
item.conveyor_wand.triple.name=Dreispuriges Förderband
item.cordite.name=Kordit item.cordite.name=Kordit
item.cotton_candy.name=Radioaktive Zuckerwatte item.cotton_candy.name=Radioaktive Zuckerwatte
item.crackpipe.name=Gesundheitspfeife item.crackpipe.name=Gesundheitspfeife

View File

@ -2672,6 +2672,12 @@ item.combine_scrap.name=CMB Scrap Metal
item.component_emitter.name=Emitter Component item.component_emitter.name=Emitter Component
item.component_limiter.name=Stabilizer Component item.component_limiter.name=Stabilizer Component
item.containment_box.name=Containment Box item.containment_box.name=Containment Box
item.conveyor_wand.regular.name=Conveyor Belt
item.conveyor_wand.express.name=Express Conveyor Belt
item.conveyor_wand.double.name=Double-Lane Conveyor Belt
item.conveyor_wand.triple.name=Triple-Lane Conveyor Belt
item.conveyor_wand.desc=Moves items dropped on it$Click two points to create a conveyor$Crouch click to manually place$Click with a screwdriver to rotate$Crouch click with a screwdriver to change types
item.conveyor_wand.vertical.desc=Is capable of placing lifts & chutes to move items vertically
item.cordite.name=Cordite item.cordite.name=Cordite
item.cotton_candy.name=Radioactive Cotton Candy item.cotton_candy.name=Radioactive Cotton Candy
item.crackpipe.name=Health Pipe item.crackpipe.name=Health Pipe

View File

@ -2662,6 +2662,10 @@ item.combine_scrap.name=Металлолом Альянса
item.component_emitter.name=Компонент излучателя item.component_emitter.name=Компонент излучателя
item.component_limiter.name=Компонент стабилизатора item.component_limiter.name=Компонент стабилизатора
item.containment_box.name=Защитная коробка item.containment_box.name=Защитная коробка
item.conveyor_wand.regular.name=Конвейер
item.conveyor_wand.express.name=Быстрый конвейер
item.conveyor_wand.double.name=Двухполосный конвейер
item.conveyor_wand.triple.name=Трёхполосный конвейер
item.cordite.name=Кордит item.cordite.name=Кордит
item.cotton_candy.name=Радиоактивная сахарная вата item.cotton_candy.name=Радиоактивная сахарная вата
item.crackpipe.name=Оздоровительная трубка item.crackpipe.name=Оздоровительная трубка

View File

@ -2548,6 +2548,10 @@ item.combine_scrap.name=CMB钢废料
item.component_emitter.name=发射器组件 item.component_emitter.name=发射器组件
item.component_limiter.name=稳定器组件 item.component_limiter.name=稳定器组件
item.containment_box.name=安全盒 item.containment_box.name=安全盒
item.conveyor_wand.regular.name=输送带
item.conveyor_wand.express.name=快速输送带
item.conveyor_wand.double.name=双轨道输送带
item.conveyor_wand.triple.name=三轨道输送带
item.cordite.name=无烟线状火药 item.cordite.name=无烟线状火药
item.cotton_candy.name=放射性棉花糖 item.cotton_candy.name=放射性棉花糖
item.crackpipe.name=健康烟壶 item.crackpipe.name=健康烟壶