mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Fixed Atomic Reconstructor Recipes, added Item Support & textures!
This commit is contained in:
parent
db3abb0f05
commit
2be8b18d71
7 changed files with 135 additions and 51 deletions
|
@ -14,19 +14,25 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
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.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockAtomicReconstructor extends BlockContainerBase implements IActAddItemOrBlock{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon frontIcon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon topIcon;
|
||||
|
||||
public BlockAtomicReconstructor(){
|
||||
super(Material.rock);
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
|
@ -37,14 +43,35 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IAct
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata){
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(side != meta && (side == 0 || side == 1)){
|
||||
return this.topIcon;
|
||||
}
|
||||
if(side == meta){
|
||||
return this.frontIcon;
|
||||
}
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta){
|
||||
if(side == 0 || side == 1){
|
||||
return this.topIcon;
|
||||
}
|
||||
if(side == 3){
|
||||
return this.frontIcon;
|
||||
}
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
this.blockIcon = Blocks.stone.getIcon(0, 0);
|
||||
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
|
||||
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Front");
|
||||
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Top");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,10 +13,7 @@ package ellpeck.actuallyadditions.ore;
|
|||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||
import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
|
||||
import ellpeck.actuallyadditions.items.InitItems;
|
||||
import ellpeck.actuallyadditions.items.metalists.TheDusts;
|
||||
import ellpeck.actuallyadditions.items.metalists.TheFoods;
|
||||
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
|
||||
import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops;
|
||||
import ellpeck.actuallyadditions.items.metalists.*;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -59,7 +56,7 @@ public class InitOreDict{
|
|||
addOre(Blocks.double_plant, 4, "flowerRoseBush");
|
||||
addOre(Blocks.double_plant, 5, "flowerPeony");
|
||||
|
||||
//My Ores
|
||||
//Ores
|
||||
addOre(InitItems.itemDust, TheDusts.IRON.ordinal(), "dustIron");
|
||||
addOre(InitItems.itemDust, TheDusts.GOLD.ordinal(), "dustGold");
|
||||
addOre(InitItems.itemDust, TheDusts.DIAMOND.ordinal(), "dustDiamond");
|
||||
|
@ -69,6 +66,19 @@ public class InitOreDict{
|
|||
addOre(InitItems.itemDust, TheDusts.COAL.ordinal(), "dustCoal");
|
||||
addOre(InitItems.itemDust, TheDusts.QUARTZ_BLACK.ordinal(), "dustQuartzBlack");
|
||||
|
||||
//Crystals
|
||||
addOre(InitItems.itemCrystal, TheCrystals.REDSTONE.ordinal(), "crystalRed");
|
||||
addOre(InitItems.itemCrystal, TheCrystals.LAPIS.ordinal(), "crystalBlue");
|
||||
addOre(InitItems.itemCrystal, TheCrystals.DIAMOND.ordinal(), "crystalLightBlue");
|
||||
addOre(InitItems.itemCrystal, TheCrystals.EMERALD.ordinal(), "crystalGreen");
|
||||
addOre(InitItems.itemCrystal, TheCrystals.COAL.ordinal(), "crystalBlack");
|
||||
|
||||
addOre(InitBlocks.blockCrystal, TheCrystals.REDSTONE.ordinal(), "blockCrystalRed");
|
||||
addOre(InitBlocks.blockCrystal, TheCrystals.LAPIS.ordinal(), "blockCrystalBlue");
|
||||
addOre(InitBlocks.blockCrystal, TheCrystals.DIAMOND.ordinal(), "blockCrystalLightBlue");
|
||||
addOre(InitBlocks.blockCrystal, TheCrystals.EMERALD.ordinal(), "blockCrystalGreen");
|
||||
addOre(InitBlocks.blockCrystal, TheCrystals.COAL.ordinal(), "blockCrystalBlack");
|
||||
|
||||
addOre(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), "oreQuartzBlack");
|
||||
|
||||
addOre(InitItems.itemCanolaSeed, "seedCanola");
|
||||
|
|
|
@ -10,52 +10,63 @@
|
|||
|
||||
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 net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
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());
|
||||
addRecipe("blockRedstone", "blockCrystalRed");
|
||||
addRecipe("blockLapis", "blockCrystalBlue");
|
||||
addRecipe("blockDiamond", "blockCrystalLightBlue");
|
||||
addRecipe("blockEmerald", "blockCrystalGreen");
|
||||
addRecipe("blockCoal", "blockCrystalBlack");
|
||||
|
||||
addRecipe("dustRedstone", "crystalRed");
|
||||
addRecipe("gemLapis", "crystalBlue");
|
||||
addRecipe("gemDiamond", "crystalLightBlue");
|
||||
addRecipe("gemEmerald", "crystalGreen");
|
||||
addRecipe("coal", "crystalBlack");
|
||||
}
|
||||
|
||||
public static void addRecipe(Block input, int inputMeta, Block output, int outputMeta){
|
||||
recipes.add(new Recipe(input, inputMeta, output, outputMeta));
|
||||
public static void addRecipe(String input, String output){
|
||||
recipes.add(new Recipe(input, output));
|
||||
}
|
||||
|
||||
public static Recipe getRecipe(Block input, int inputMeta){
|
||||
public static Recipe getRecipe(ItemStack input){
|
||||
for(Recipe recipe : recipes){
|
||||
if(recipe.input == input && recipe.inputMeta == inputMeta){
|
||||
int[] ids = OreDictionary.getOreIDs(input);
|
||||
for(int id : ids){
|
||||
if(Objects.equals(OreDictionary.getOreName(id), recipe.input)){
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Recipe{
|
||||
|
||||
public Block input;
|
||||
public int inputMeta;
|
||||
public Block output;
|
||||
public int outputMeta;
|
||||
public String input;
|
||||
public String output;
|
||||
|
||||
public Recipe(Block input, int inputMeta, Block output, int outputMeta){
|
||||
public Recipe(String input, String output){
|
||||
this.input = input;
|
||||
this.inputMeta = inputMeta;
|
||||
this.output = output;
|
||||
this.outputMeta = outputMeta;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ItemStack getFirstOutput(){
|
||||
ArrayList<ItemStack> stacks = OreDictionary.getOres(this.output);
|
||||
if(stacks != null && !stacks.isEmpty()){
|
||||
return stacks.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,9 +14,15 @@ import ellpeck.actuallyadditions.recipe.AtomicReconstructorRecipeHandler;
|
|||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileEntityAtomicReconstructor extends TileEntityBase{
|
||||
|
||||
private int currentTime;
|
||||
|
@ -25,6 +31,7 @@ public class TileEntityAtomicReconstructor extends TileEntityBase{
|
|||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
if(!this.worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
|
@ -34,20 +41,48 @@ public class TileEntityAtomicReconstructor extends TileEntityBase{
|
|||
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
|
||||
|
||||
//Converting the Blocks
|
||||
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());
|
||||
AtomicReconstructorRecipeHandler.Recipe recipe = AtomicReconstructorRecipeHandler.getRecipe(new ItemStack(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));
|
||||
ItemStack output = recipe.getFirstOutput();
|
||||
if(output != null){
|
||||
if(output.getItem() instanceof ItemBlock){
|
||||
this.worldObj.playAuxSFX(2001, pos.getX(), pos.getY(), pos.getZ(), Block.getIdFromBlock(pos.getBlock())+(pos.getMetadata() << 12));
|
||||
pos.setBlock(Block.getBlockFromItem(output.getItem()), output.getItemDamage(), 2);
|
||||
}
|
||||
else{
|
||||
EntityItem item = new EntityItem(worldObj, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy());
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Converting the Items
|
||||
ArrayList<EntityItem> items = (ArrayList<EntityItem>)worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(coordsBlock.getX()-range, coordsBlock.getY()-range, coordsBlock.getZ()-range, coordsBlock.getX()+range, coordsBlock.getY()+range, coordsBlock.getZ()+range));
|
||||
for(EntityItem item : items){
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack != null){
|
||||
AtomicReconstructorRecipeHandler.Recipe recipe = AtomicReconstructorRecipeHandler.getRecipe(stack);
|
||||
if(recipe != null){
|
||||
ItemStack output = recipe.getFirstOutput();
|
||||
if(output != null){
|
||||
ItemStack outputCopy = output.copy();
|
||||
outputCopy.stackSize = stack.stackSize;
|
||||
item.setEntityItemStack(outputCopy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +94,7 @@ public class TileEntityAtomicReconstructor extends TileEntityBase{
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 378 B |
Binary file not shown.
After Width: | Height: | Size: 376 B |
Binary file not shown.
After Width: | Height: | Size: 318 B |
Loading…
Reference in a new issue