Files
ForgeMultipart/codechicken/multipart/minecraft/Content.java
T

66 lines
2.2 KiB
Java
Raw Normal View History

2013-05-20 17:09:57 +10:00
package codechicken.multipart.minecraft;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import codechicken.core.vec.BlockCoord;
import codechicken.multipart.MultiPartRegistry.IPartConverter;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.TMultiPart;
public class Content implements IPartFactory, IPartConverter
{
@Override
public TMultiPart createPart(String name, boolean client)
{
if(name.equals("mc_torch")) return new TorchPart();
2013-06-02 13:38:59 +10:00
if(name.equals("mc_lever")) return new LeverPart();
2013-06-03 19:58:06 +10:00
if(name.equals("mc_button")) return new ButtonPart();
2013-06-04 01:47:51 +10:00
if(name.equals("mc_redtorch")) return new RedstoneTorchPart();
2013-05-20 17:09:57 +10:00
return null;
}
public void init()
{
MultiPartRegistry.registerConverter(this);
MultiPartRegistry.registerParts(this, new String[]{
2013-06-02 13:38:59 +10:00
"mc_torch",
2013-06-03 19:58:06 +10:00
"mc_lever",
2013-06-04 01:47:51 +10:00
"mc_button",
"mc_redtorch"
2013-05-20 17:09:57 +10:00
});
}
@Override
public boolean canConvert(int blockID)
{
2013-06-02 13:38:59 +10:00
return blockID == Block.torchWood.blockID ||
2013-06-03 19:58:06 +10:00
blockID == Block.lever.blockID ||
blockID == Block.stoneButton.blockID ||
2013-06-04 01:47:51 +10:00
blockID == Block.woodenButton.blockID ||
blockID == Block.torchRedstoneIdle.blockID ||
blockID == Block.torchRedstoneActive.blockID;
2013-05-20 17:09:57 +10:00
}
@Override
public TMultiPart convert(World world, BlockCoord pos)
{
int id = world.getBlockId(pos.x, pos.y, pos.z);
int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
if(id == Block.torchWood.blockID)
return new TorchPart(meta);
2013-06-02 13:38:59 +10:00
if(id == Block.lever.blockID)
return new LeverPart(meta);
2013-06-03 19:58:06 +10:00
if(id == Block.stoneButton.blockID)
return new ButtonPart(meta);
if(id == Block.woodenButton.blockID)
return new ButtonPart(meta|0x10);
2013-06-04 01:47:51 +10:00
if(id == Block.torchRedstoneIdle.blockID)
return new RedstoneTorchPart(meta);
if(id == Block.torchRedstoneActive.blockID)
return new RedstoneTorchPart(meta|0x10);
2013-05-20 17:09:57 +10:00
return null;
}
}