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 cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||||
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
||||||
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class BlockAtomicReconstructor extends BlockContainerBase implements IActAddItemOrBlock{
|
public class BlockAtomicReconstructor extends BlockContainerBase implements IActAddItemOrBlock{
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private IIcon frontIcon;
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private IIcon topIcon;
|
||||||
|
|
||||||
public BlockAtomicReconstructor(){
|
public BlockAtomicReconstructor(){
|
||||||
super(Material.rock);
|
super(Material.rock);
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
this.setHarvestLevel("pickaxe", 0);
|
||||||
|
@ -37,14 +43,35 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IAct
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@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;
|
return this.blockIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerBlockIcons(IIconRegister iconReg){
|
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
|
@Override
|
||||||
|
|
|
@ -13,10 +13,7 @@ package ellpeck.actuallyadditions.ore;
|
||||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
||||||
import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
|
import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
|
||||||
import ellpeck.actuallyadditions.items.InitItems;
|
import ellpeck.actuallyadditions.items.InitItems;
|
||||||
import ellpeck.actuallyadditions.items.metalists.TheDusts;
|
import ellpeck.actuallyadditions.items.metalists.*;
|
||||||
import ellpeck.actuallyadditions.items.metalists.TheFoods;
|
|
||||||
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
|
|
||||||
import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops;
|
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
@ -59,7 +56,7 @@ public class InitOreDict{
|
||||||
addOre(Blocks.double_plant, 4, "flowerRoseBush");
|
addOre(Blocks.double_plant, 4, "flowerRoseBush");
|
||||||
addOre(Blocks.double_plant, 5, "flowerPeony");
|
addOre(Blocks.double_plant, 5, "flowerPeony");
|
||||||
|
|
||||||
//My Ores
|
//Ores
|
||||||
addOre(InitItems.itemDust, TheDusts.IRON.ordinal(), "dustIron");
|
addOre(InitItems.itemDust, TheDusts.IRON.ordinal(), "dustIron");
|
||||||
addOre(InitItems.itemDust, TheDusts.GOLD.ordinal(), "dustGold");
|
addOre(InitItems.itemDust, TheDusts.GOLD.ordinal(), "dustGold");
|
||||||
addOre(InitItems.itemDust, TheDusts.DIAMOND.ordinal(), "dustDiamond");
|
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.COAL.ordinal(), "dustCoal");
|
||||||
addOre(InitItems.itemDust, TheDusts.QUARTZ_BLACK.ordinal(), "dustQuartzBlack");
|
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(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), "oreQuartzBlack");
|
||||||
|
|
||||||
addOre(InitItems.itemCanolaSeed, "seedCanola");
|
addOre(InitItems.itemCanolaSeed, "seedCanola");
|
||||||
|
|
|
@ -10,33 +10,41 @@
|
||||||
|
|
||||||
package ellpeck.actuallyadditions.recipe;
|
package ellpeck.actuallyadditions.recipe;
|
||||||
|
|
||||||
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
import net.minecraft.item.ItemStack;
|
||||||
import ellpeck.actuallyadditions.items.metalists.TheCrystals;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class AtomicReconstructorRecipeHandler{
|
public class AtomicReconstructorRecipeHandler{
|
||||||
|
|
||||||
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
|
public static ArrayList<Recipe> recipes = new ArrayList<Recipe>();
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
addRecipe(Blocks.redstone_block, 0, InitBlocks.blockCrystal, TheCrystals.REDSTONE.ordinal());
|
addRecipe("blockRedstone", "blockCrystalRed");
|
||||||
addRecipe(Blocks.lapis_block, 0, InitBlocks.blockCrystal, TheCrystals.LAPIS.ordinal());
|
addRecipe("blockLapis", "blockCrystalBlue");
|
||||||
addRecipe(Blocks.diamond_block, 0, InitBlocks.blockCrystal, TheCrystals.DIAMOND.ordinal());
|
addRecipe("blockDiamond", "blockCrystalLightBlue");
|
||||||
addRecipe(Blocks.coal_block, 0, InitBlocks.blockCrystal, TheCrystals.COAL.ordinal());
|
addRecipe("blockEmerald", "blockCrystalGreen");
|
||||||
addRecipe(Blocks.emerald_block, 0, InitBlocks.blockCrystal, TheCrystals.EMERALD.ordinal());
|
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){
|
public static void addRecipe(String input, String output){
|
||||||
recipes.add(new Recipe(input, inputMeta, output, outputMeta));
|
recipes.add(new Recipe(input, output));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Recipe getRecipe(Block input, int inputMeta){
|
public static Recipe getRecipe(ItemStack input){
|
||||||
for(Recipe recipe : recipes){
|
for(Recipe recipe : recipes){
|
||||||
if(recipe.input == input && recipe.inputMeta == inputMeta){
|
int[] ids = OreDictionary.getOreIDs(input);
|
||||||
return recipe;
|
for(int id : ids){
|
||||||
|
if(Objects.equals(OreDictionary.getOreName(id), recipe.input)){
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -44,18 +52,21 @@ public class AtomicReconstructorRecipeHandler{
|
||||||
|
|
||||||
public static class Recipe{
|
public static class Recipe{
|
||||||
|
|
||||||
public Block input;
|
public String input;
|
||||||
public int inputMeta;
|
public String output;
|
||||||
public Block output;
|
|
||||||
public int outputMeta;
|
|
||||||
|
|
||||||
public Recipe(Block input, int inputMeta, Block output, int outputMeta){
|
public Recipe(String input, String output){
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.inputMeta = inputMeta;
|
|
||||||
this.output = output;
|
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.WorldPos;
|
||||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
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.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TileEntityAtomicReconstructor extends TileEntityBase{
|
public class TileEntityAtomicReconstructor extends TileEntityBase{
|
||||||
|
|
||||||
private int currentTime;
|
private int currentTime;
|
||||||
|
@ -25,37 +31,67 @@ public class TileEntityAtomicReconstructor extends TileEntityBase{
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
if(!this.worldObj.isRemote){
|
if(!this.worldObj.isRemote){
|
||||||
if(this.currentTime > 0){
|
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||||
this.currentTime--;
|
if(this.currentTime > 0){
|
||||||
if(this.currentTime <= 0){
|
this.currentTime--;
|
||||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
if(this.currentTime <= 0){
|
||||||
|
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||||
|
|
||||||
for(int i = 0; i < 10; i++){
|
for(int i = 0; i < 10; i++){
|
||||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||||
if(coordsBlock != null){
|
if(coordsBlock != null){
|
||||||
if(!coordsBlock.getBlock().isAir(coordsBlock.getWorld(), coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){
|
if(!coordsBlock.getBlock().isAir(coordsBlock.getWorld(), coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){
|
||||||
//Converting the Blocks
|
int range = 2; //TODO Config
|
||||||
int range = 2; //TODO Config
|
|
||||||
for(int reachX = -range; reachX < range+1; reachX++){
|
//Converting the Blocks
|
||||||
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
for(int reachX = -range; reachX < range+1; reachX++){
|
||||||
for(int reachY = -range; reachY < range+1; reachY++){
|
for(int reachZ = -range; reachZ < range+1; reachZ++){
|
||||||
WorldPos pos = new WorldPos(worldObj, coordsBlock.getX()+reachX, coordsBlock.getY()+reachY, coordsBlock.getZ()+reachZ);
|
for(int reachY = -range; reachY < range+1; reachY++){
|
||||||
AtomicReconstructorRecipeHandler.Recipe recipe = AtomicReconstructorRecipeHandler.getRecipe(pos.getBlock(), pos.getMetadata());
|
WorldPos pos = new WorldPos(worldObj, coordsBlock.getX()+reachX, coordsBlock.getY()+reachY, coordsBlock.getZ()+reachZ);
|
||||||
if(recipe != null){
|
AtomicReconstructorRecipeHandler.Recipe recipe = AtomicReconstructorRecipeHandler.getRecipe(new ItemStack(pos.getBlock(), pos.getMetadata()));
|
||||||
pos.setBlock(recipe.output, recipe.outputMeta, 2);
|
if(recipe != null){
|
||||||
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;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else{
|
||||||
else{
|
this.currentTime = 40; //TODO Config
|
||||||
this.currentTime = 40; //TODO Config
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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