mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Added Atomic Reconstructor, made it function (Still needs particles etc. though)
This commit is contained in:
parent
50f2dbba0d
commit
fbd869dc7b
11 changed files with 233 additions and 13 deletions
|
@ -35,6 +35,7 @@ import ellpeck.actuallyadditions.misc.*;
|
|||
import ellpeck.actuallyadditions.network.PacketHandler;
|
||||
import ellpeck.actuallyadditions.ore.InitOreDict;
|
||||
import ellpeck.actuallyadditions.proxy.IProxy;
|
||||
import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler;
|
||||
import ellpeck.actuallyadditions.recipe.FuelHandler;
|
||||
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
|
||||
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
|
||||
|
@ -100,6 +101,7 @@ public class ActuallyAdditions{
|
|||
ItemCrafting.initMashedFoodRecipes();
|
||||
HairyBallHandler.init();
|
||||
TreasureChestHandler.init();
|
||||
AtomicReconstructorRecipeHandler.init();
|
||||
InitForeignPaxels.init();
|
||||
proxy.postInit(event);
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This file ("BlockAtomicReconstructor.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
||||
import net.minecraft.block.BlockPistonBase;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockAtomicReconstructor extends BlockContainerBase implements IActAddItemOrBlock{
|
||||
|
||||
public BlockAtomicReconstructor(){
|
||||
super(Material.rock);
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
this.setHardness(6F);
|
||||
this.setResistance(20F);
|
||||
this.setStepSound(soundTypeStone);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata){
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
this.blockIcon = Blocks.stone.getIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return "blockAtomicReconstructor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.epic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int i){
|
||||
return new TileEntityAtomicReconstructor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
|
||||
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
|
||||
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
|
||||
}
|
||||
}
|
|
@ -107,6 +107,9 @@ public class InitBlocks{
|
|||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Blocks...");
|
||||
|
||||
blockAtomicReconstructor = new BlockAtomicReconstructor();
|
||||
BlockUtil.register(blockAtomicReconstructor);
|
||||
|
||||
blockCrystal = new BlockCrystal();
|
||||
BlockUtil.register(blockCrystal, BlockCrystal.TheItemBlock.class);
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ import java.util.List;
|
|||
|
||||
public class ItemCrystal extends Item implements IActAddItemOrBlock{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon[] textures;
|
||||
|
||||
public ItemCrystal(){
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
|
@ -43,8 +46,8 @@ public class ItemCrystal extends Item implements IActAddItemOrBlock{
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int pass){
|
||||
return stack.getItemDamage() >= BlockCrystal.allCrystals.length ? super.getColorFromItemStack(stack, pass) : BlockCrystal.allCrystals[stack.getItemDamage()].color;
|
||||
public IIcon getIconFromDamage(int par1){
|
||||
return par1 >= this.textures.length ? null : this.textures[par1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,12 +55,6 @@ public class ItemCrystal extends Item implements IActAddItemOrBlock{
|
|||
return stack.getItemDamage() >= BlockCrystal.allCrystals.length ? EnumRarity.common : BlockCrystal.allCrystals[stack.getItemDamage()].rarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int pass){
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list){
|
||||
|
@ -69,7 +66,10 @@ public class ItemCrystal extends Item implements IActAddItemOrBlock{
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconReg){
|
||||
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
|
||||
this.textures = new IIcon[BlockCrystal.allCrystals.length];
|
||||
for(int i = 0; i < this.textures.length; i++){
|
||||
this.textures[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+BlockCrystal.allCrystals[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,10 +14,11 @@ import net.minecraft.item.EnumRarity;
|
|||
|
||||
public enum TheCrystals{
|
||||
|
||||
REDSTONE("Red", EnumRarity.rare, 12595250),
|
||||
LAPIS("Blue", EnumRarity.uncommon, 24983),
|
||||
DIAMOND("LightBlue", EnumRarity.epic, 40140),
|
||||
COAL("Black", EnumRarity.uncommon, 2500135);
|
||||
REDSTONE("Red", EnumRarity.rare, 16318464),
|
||||
LAPIS("Blue", EnumRarity.uncommon, 131437),
|
||||
DIAMOND("LightBlue", EnumRarity.epic, 9211636),
|
||||
COAL("Black", EnumRarity.uncommon, 986895),
|
||||
EMERALD("Green", EnumRarity.epic, 382466);
|
||||
|
||||
public final String name;
|
||||
public final EnumRarity rarity;
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* This file ("AtomicReconstructorRecipeHandler.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.recipe;
|
||||
|
||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.items.metalists.TheCrystals;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AtomicReconstructorRecipeHandler{
|
||||
|
||||
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
|
||||
|
||||
public static void init(){
|
||||
addRecipe(Blocks.redstone_block, 0, InitBlocks.blockCrystal, TheCrystals.REDSTONE.ordinal());
|
||||
addRecipe(Blocks.lapis_block, 0, InitBlocks.blockCrystal, TheCrystals.LAPIS.ordinal());
|
||||
addRecipe(Blocks.diamond_block, 0, InitBlocks.blockCrystal, TheCrystals.DIAMOND.ordinal());
|
||||
addRecipe(Blocks.coal_block, 0, InitBlocks.blockCrystal, TheCrystals.COAL.ordinal());
|
||||
addRecipe(Blocks.emerald_block, 0, InitBlocks.blockCrystal, TheCrystals.EMERALD.ordinal());
|
||||
}
|
||||
|
||||
public static void addRecipe(Block input, int inputMeta, Block output, int outputMeta){
|
||||
recipes.add(new Recipe(input, inputMeta, output, outputMeta));
|
||||
}
|
||||
|
||||
public static Recipe getRecipe(Block input, int inputMeta){
|
||||
for(Recipe recipe : recipes){
|
||||
if(recipe.input == input && recipe.inputMeta == inputMeta){
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Recipe{
|
||||
|
||||
public Block input;
|
||||
public int inputMeta;
|
||||
public Block output;
|
||||
public int outputMeta;
|
||||
|
||||
public Recipe(Block input, int inputMeta, Block output, int outputMeta){
|
||||
this.input = input;
|
||||
this.inputMeta = inputMeta;
|
||||
this.output = output;
|
||||
this.outputMeta = outputMeta;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* This file ("TileEntityAtomicReconstructor.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.tile;
|
||||
|
||||
import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityAtomicReconstructor extends TileEntityBase{
|
||||
|
||||
private int currentTime;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
if(!this.worldObj.isRemote){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||
if(coordsBlock != null){
|
||||
if(!coordsBlock.getBlock().isAir(coordsBlock.getWorld(), coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){
|
||||
//Converting the Blocks
|
||||
int range = 2; //TODO Config
|
||||
for(int reachX = -range; reachX < range+1; reachX++){
|
||||
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
||||
for(int reachY = -range; reachY < range+1; reachY++){
|
||||
WorldPos pos = new WorldPos(worldObj, coordsBlock.getX()+reachX, coordsBlock.getY()+reachY, coordsBlock.getZ()+reachZ);
|
||||
AtomicReconstructorRecipeHandler.Recipe recipe = AtomicReconstructorRecipeHandler.getRecipe(pos.getBlock(), pos.getMetadata());
|
||||
if(recipe != null){
|
||||
pos.setBlock(recipe.output, recipe.outputMeta, 2);
|
||||
this.worldObj.playAuxSFX(2001, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), Block.getIdFromBlock(pos.getBlock())+(pos.getMetadata() << 12));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.currentTime = 40; //TODO Config
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.writeSyncableNBT(compound, sync);
|
||||
compound.setInteger("CurrentTime", this.currentTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.readSyncableNBT(compound, sync);
|
||||
this.currentTime = compound.getInteger("CurrentTime");
|
||||
}
|
||||
|
||||
}
|
|
@ -24,6 +24,7 @@ public abstract class TileEntityBase extends TileEntity{
|
|||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Registering TileEntities...");
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityCompost.class, ModUtil.MOD_ID_LOWER+":tileEntityCompost");
|
||||
GameRegistry.registerTileEntity(TileEntityFeeder.class, ModUtil.MOD_ID_LOWER+":tileEntityFeeder");
|
||||
GameRegistry.registerTileEntity(TileEntityGiantChest.class, ModUtil.MOD_ID_LOWER+":tileEntityGiantChest");
|
||||
|
@ -62,6 +63,7 @@ public abstract class TileEntityBase extends TileEntity{
|
|||
GameRegistry.registerTileEntity(TileEntityDirectionalBreaker.class, ModUtil.MOD_ID_LOWER+":tileEntityDirectionalBreaker");
|
||||
GameRegistry.registerTileEntity(TileEntityRangedCollector.class, ModUtil.MOD_ID_LOWER+":tileEntityRangedCollector");
|
||||
GameRegistry.registerTileEntity(TileEntityLaserRelay.class, ModUtil.MOD_ID_LOWER+":tileEntityLaserRelay");
|
||||
GameRegistry.registerTileEntity(TileEntityAtomicReconstructor.class, ModUtil.MOD_ID_LOWER+":tileEntityAtomicReconstructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -68,6 +68,12 @@ public class WorldPos{
|
|||
return pos != null && this.x == pos.getX() && this.y == pos.getY() && this.z == pos.getZ() && this.getWorld() == pos.getWorld();
|
||||
}
|
||||
|
||||
public void setBlock(Block block, int meta, int flag){
|
||||
if(this.getWorld() != null){
|
||||
this.getWorld().setBlock(this.x, this.y, this.z, block, meta, flag);
|
||||
}
|
||||
}
|
||||
|
||||
public int getX(){
|
||||
return this.x;
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 384 B After Width: | Height: | Size: 264 B |
Binary file not shown.
Before Width: | Height: | Size: 429 B |
Loading…
Reference in a new issue