Merge pull request #455 from thatsIch/develop
Added skystone, skystone block, skystone brick, skystone small brick, certus quartz, certus quartz pillar, chiseled certus quartz and fluix stars, closes #52
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.StairBlockFeatureHandler;
|
||||
|
||||
|
||||
public abstract class AEBaseStairBlock extends BlockStairs implements IAEFeature
|
||||
{
|
||||
private final IFeatureHandler features;
|
||||
|
||||
protected AEBaseStairBlock( Block block, int meta, EnumSet<AEFeature> features )
|
||||
{
|
||||
super( block, meta );
|
||||
|
||||
this.features = new StairBlockFeatureHandler( features, this, Optional.<String> absent() );
|
||||
this.setBlockName( block.getUnlocalizedName() );
|
||||
|
||||
this.setLightOpacity( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFeatureHandler handler()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
// Override to do stuff
|
||||
}
|
||||
}
|
||||
@@ -18,21 +18,17 @@
|
||||
|
||||
package appeng.block;
|
||||
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
|
||||
public class AEDecorativeBlock extends AEBaseBlock
|
||||
{
|
||||
|
||||
protected AEDecorativeBlock(Class<?> c, Material mat) {
|
||||
super( c, mat );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
public AEDecorativeBlock( Class<? extends AEBaseBlock> c, Material mat )
|
||||
{
|
||||
return super.unmappedGetIcon( w, x, y, z, s );
|
||||
super( c, mat );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,4 +37,9 @@ public class AEDecorativeBlock extends AEBaseBlock
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
|
||||
{
|
||||
return super.unmappedGetIcon( w, x, y, z, s );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,20 @@
|
||||
|
||||
package appeng.block.solids;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class BlockFluix extends AEDecorativeBlock
|
||||
{
|
||||
|
||||
public BlockFluix() {
|
||||
public BlockFluix()
|
||||
{
|
||||
super( BlockFluix.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.block.solids.BlockQuartzChiseled;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class ChiseledQuartzStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public ChiseledQuartzStairBlock( BlockQuartzChiseled block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class FluixStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public FluixStairBlock( Block block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.block.solids.BlockQuartzPillar;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class QuartzPillarStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public QuartzPillarStairBlock( BlockQuartzPillar block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.block.solids.BlockQuartz;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class QuartzStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public QuartzStairBlock( BlockQuartz block )
|
||||
{
|
||||
super( block, 0, EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class SkyStoneBlockStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneBlockStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class SkyStoneBrickStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneBrickStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class SkyStoneSmallBrickStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneSmallBrickStairBlock( Block block, int meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.stair;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import appeng.block.AEBaseStairBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class SkyStoneStairBlock extends AEBaseStairBlock
|
||||
{
|
||||
public SkyStoneStairBlock( Block block, Integer meta )
|
||||
{
|
||||
super( block, meta, EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,13 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
@@ -29,6 +33,14 @@ import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.RecipeSorter.Category;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.Blocks;
|
||||
@@ -90,6 +102,14 @@ import appeng.block.solids.OreQuartzCharged;
|
||||
import appeng.block.spatial.BlockMatrixFrame;
|
||||
import appeng.block.spatial.BlockSpatialIOPort;
|
||||
import appeng.block.spatial.BlockSpatialPylon;
|
||||
import appeng.block.stair.ChiseledQuartzStairBlock;
|
||||
import appeng.block.stair.FluixStairBlock;
|
||||
import appeng.block.stair.QuartzPillarStairBlock;
|
||||
import appeng.block.stair.QuartzStairBlock;
|
||||
import appeng.block.stair.SkyStoneBlockStairBlock;
|
||||
import appeng.block.stair.SkyStoneBrickStairBlock;
|
||||
import appeng.block.stair.SkyStoneSmallBrickStairBlock;
|
||||
import appeng.block.stair.SkyStoneStairBlock;
|
||||
import appeng.block.storage.BlockChest;
|
||||
import appeng.block.storage.BlockDrive;
|
||||
import appeng.block.storage.BlockIOPort;
|
||||
@@ -184,17 +204,9 @@ import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.spatial.BiomeGenStorage;
|
||||
import appeng.spatial.StorageWorldProvider;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.ClassInstantiation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
|
||||
public class Registration
|
||||
{
|
||||
@@ -202,6 +214,7 @@ public class Registration
|
||||
final public static Registration instance = new Registration();
|
||||
|
||||
public final RecipeHandler recipeHandler;
|
||||
final private Multimap<AEFeature, Class> featuresToEntities = ArrayListMultimap.create();
|
||||
public BiomeGenBase storageBiome;
|
||||
|
||||
private Registration()
|
||||
@@ -209,9 +222,7 @@ public class Registration
|
||||
recipeHandler = new RecipeHandler();
|
||||
}
|
||||
|
||||
final private Multimap<AEFeature, Class> featuresToEntities = ArrayListMultimap.create();
|
||||
|
||||
public void PreInit(FMLPreInitializationEvent event)
|
||||
public void PreInit( FMLPreInitializationEvent event )
|
||||
{
|
||||
registerSpatial( false );
|
||||
|
||||
@@ -248,23 +259,23 @@ public class Registration
|
||||
AEItemDefinition materialItem = addFeature( ItemMultiMaterial.class );
|
||||
|
||||
Class materialClass = materials.getClass();
|
||||
for (MaterialType mat : MaterialType.values())
|
||||
for ( MaterialType mat : MaterialType.values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( mat == MaterialType.InvalidType )
|
||||
((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||
( ( ItemMultiMaterial ) materialItem.item() ).createMaterial( mat );
|
||||
else
|
||||
{
|
||||
Field f = materialClass.getField( "material" + mat.name() );
|
||||
IStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||
IStackSrc is = ( ( ItemMultiMaterial ) materialItem.item() ).createMaterial( mat );
|
||||
if ( is != null )
|
||||
f.set( materials, new DamagedItemDefinition( is ) );
|
||||
else
|
||||
f.set( materials, new NullItemDefinition() );
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
catch ( Throwable err )
|
||||
{
|
||||
AELog.severe( "Error creating material: " + mat.name() );
|
||||
throw new RuntimeException( err );
|
||||
@@ -274,19 +285,19 @@ public class Registration
|
||||
AEItemDefinition partItem = addFeature( ItemMultiPart.class );
|
||||
|
||||
Class partClass = parts.getClass();
|
||||
for (PartType type : PartType.values())
|
||||
for ( PartType type : PartType.values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( type == PartType.InvalidType )
|
||||
((ItemMultiPart) partItem.item()).createPart( type, null );
|
||||
( ( ItemMultiPart ) partItem.item() ).createPart( type, null );
|
||||
else
|
||||
{
|
||||
Field f = partClass.getField( "part" + type.name() );
|
||||
Enum variants[] = type.getVariants();
|
||||
if ( variants == null )
|
||||
{
|
||||
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, null );
|
||||
ItemStackSrc is = ( ( ItemMultiPart ) partItem.item() ).createPart( type, null );
|
||||
if ( is != null )
|
||||
f.set( parts, new DamagedItemDefinition( is ) );
|
||||
else
|
||||
@@ -298,11 +309,11 @@ public class Registration
|
||||
{
|
||||
ColoredItemDefinition def = new ColoredItemDefinition();
|
||||
|
||||
for (Enum v : variants)
|
||||
for ( Enum v : variants )
|
||||
{
|
||||
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, v );
|
||||
ItemStackSrc is = ( ( ItemMultiPart ) partItem.item() ).createPart( type, v );
|
||||
if ( is != null )
|
||||
def.add( (AEColor) v, is );
|
||||
def.add( ( AEColor ) v, is );
|
||||
}
|
||||
|
||||
f.set( parts, def );
|
||||
@@ -310,7 +321,7 @@ public class Registration
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
catch ( Throwable err )
|
||||
{
|
||||
AELog.severe( "Error creating part: " + type.name() );
|
||||
throw new RuntimeException( err );
|
||||
@@ -424,7 +435,7 @@ public class Registration
|
||||
items.itemLumenPaintBall = lumenPaintBall = new ColoredItemDefinition();
|
||||
AEItemDefinition pb = addFeature( ItemPaintBall.class );
|
||||
|
||||
for (AEColor c : AEColor.values())
|
||||
for ( AEColor c : AEColor.values() )
|
||||
{
|
||||
if ( c != AEColor.Transparent )
|
||||
{
|
||||
@@ -433,6 +444,17 @@ public class Registration
|
||||
}
|
||||
}
|
||||
|
||||
// stairs
|
||||
this.addFeature( SkyStoneStairBlock.class, blocks.blockSkyStone.block(), 0 );
|
||||
this.addFeature( SkyStoneBlockStairBlock.class, blocks.blockSkyStone.block(), 1 );
|
||||
this.addFeature( SkyStoneBrickStairBlock.class, blocks.blockSkyStone.block(), 2 );
|
||||
this.addFeature( SkyStoneSmallBrickStairBlock.class, blocks.blockSkyStone.block(), 3 );
|
||||
this.addFeature( FluixStairBlock.class, blocks.blockFluix.block() );
|
||||
this.addFeature( QuartzStairBlock.class, blocks.blockQuartz.block() );
|
||||
this.addFeature( ChiseledQuartzStairBlock.class, blocks.blockQuartzChiseled.block() );
|
||||
this.addFeature( QuartzPillarStairBlock.class, blocks.blockQuartzPillar.block() );
|
||||
|
||||
// unsupported developer tools
|
||||
addFeature( ToolEraser.class );
|
||||
addFeature( ToolMeteoritePlacer.class );
|
||||
addFeature( ToolDebugCard.class );
|
||||
@@ -443,96 +465,71 @@ public class Registration
|
||||
addFeature( BlockCubeGenerator.class );
|
||||
}
|
||||
|
||||
private AEItemDefinition addFeature(Class c, Object... Args)
|
||||
private void registerSpatial( boolean force )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
return;
|
||||
|
||||
try
|
||||
AEConfig config = AEConfig.instance;
|
||||
|
||||
if ( storageBiome == null )
|
||||
{
|
||||
java.lang.reflect.Constructor[] con = c.getConstructors();
|
||||
Object obj = null;
|
||||
|
||||
for (Constructor conItem : con)
|
||||
if ( force && config.storageBiomeID == -1 )
|
||||
{
|
||||
Class paramTypes[] = conItem.getParameterTypes();
|
||||
if ( paramTypes.length == Args.length )
|
||||
{
|
||||
boolean valid = true;
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if ( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
for (int idx = 0; idx < paramTypes.length; idx++)
|
||||
{
|
||||
Class cz = Args[idx].getClass();
|
||||
if ( !isClassMatch( paramTypes[idx], cz, Args[idx] ) )
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if ( valid )
|
||||
{
|
||||
obj = conItem.newInstance( Args );
|
||||
break;
|
||||
}
|
||||
}
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
}
|
||||
|
||||
if ( obj instanceof IAEFeature )
|
||||
{
|
||||
IAEFeature feature = (IAEFeature) obj;
|
||||
|
||||
for (AEFeature f : feature.feature().getFeatures())
|
||||
featuresToEntities.put( f, c );
|
||||
|
||||
feature.feature().register();
|
||||
|
||||
feature.postInit();
|
||||
|
||||
return feature.feature();
|
||||
}
|
||||
else if ( obj == null )
|
||||
throw new RuntimeException( "No valid constructor found." );
|
||||
else
|
||||
throw new RuntimeException( "Non AE Feature Registered" );
|
||||
|
||||
if ( !force && config.storageBiomeID != -1 )
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
}
|
||||
catch (Throwable e)
|
||||
|
||||
if ( config.storageProviderID != -1 )
|
||||
{
|
||||
throw new RuntimeException( "Error with Feature: " + c.getName(), e );
|
||||
DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID == -1 && force )
|
||||
{
|
||||
config.storageProviderID = -11;
|
||||
|
||||
while ( !DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false ) )
|
||||
config.storageProviderID--;
|
||||
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isClassMatch(Class expected, Class got, Object value)
|
||||
private AEItemDefinition addFeature( Class<? extends IAEFeature> featureClass, Object... args )
|
||||
{
|
||||
if ( value == null && !expected.isPrimitive() )
|
||||
return true;
|
||||
ClassInstantiation<IAEFeature> instantiation = new ClassInstantiation<IAEFeature>( featureClass, args );
|
||||
Optional<IAEFeature> instance = instantiation.get();
|
||||
|
||||
expected = condense( expected, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class );
|
||||
got = condense( got, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class );
|
||||
|
||||
if ( expected == got || expected.isAssignableFrom( got ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Class condense(Class expected, Class... wrappers)
|
||||
{
|
||||
if ( expected.isPrimitive() )
|
||||
if ( instance.isPresent() )
|
||||
{
|
||||
for (Class clz : wrappers)
|
||||
IAEFeature feature = instance.get();
|
||||
|
||||
for ( AEFeature f : feature.handler().getFeatures() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( expected == clz.getField( "TYPE" ).get( null ) )
|
||||
return clz;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
this.featuresToEntities.put( f, featureClass );
|
||||
}
|
||||
|
||||
feature.handler().register();
|
||||
feature.postInit();
|
||||
|
||||
return feature.handler().getDefinition();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException( "Error with Feature: " + featureClass.getName() );
|
||||
}
|
||||
return expected;
|
||||
}
|
||||
|
||||
public void Init(FMLInitializationEvent event)
|
||||
public void Init( FMLInitializationEvent event )
|
||||
{
|
||||
// Perform ore camouflage!
|
||||
ItemMultiMaterial.instance.makeUnique();
|
||||
@@ -600,19 +597,19 @@ public class Registration
|
||||
CraftingManager.getInstance().getRecipeList().add( new FacadeRecipe() );
|
||||
}
|
||||
|
||||
public void PostInit(FMLPostInitializationEvent event)
|
||||
public void PostInit( FMLPostInitializationEvent event )
|
||||
{
|
||||
registerSpatial( true );
|
||||
|
||||
// default settings..
|
||||
((P2PTunnelRegistry) AEApi.instance().registries().p2pTunnel()).configure();
|
||||
( ( P2PTunnelRegistry ) AEApi.instance().registries().p2pTunnel() ).configure();
|
||||
|
||||
// add to localization..
|
||||
PlayerMessages.values();
|
||||
GuiText.values();
|
||||
|
||||
Api.instance.partHelper.initFMPSupport();
|
||||
((BlockCableBus) AEApi.instance().blocks().blockMultiPart.block()).setupTile();
|
||||
( ( BlockCableBus ) AEApi.instance().blocks().blockMultiPart.block() ).setupTile();
|
||||
|
||||
// Interface
|
||||
Upgrades.CRAFTING.registerItem( AEApi.instance().parts().partInterface.stack( 1 ), 1 );
|
||||
@@ -679,7 +676,7 @@ public class Registration
|
||||
// Inscriber
|
||||
Upgrades.SPEED.registerItem( AEApi.instance().blocks().blockInscriber.stack( 1 ), 3 );
|
||||
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler( (IWirelessTermHandler) AEApi.instance().items().itemWirelessTerminal.item() );
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler( ( IWirelessTermHandler ) AEApi.instance().items().itemWirelessTerminal.item() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) )
|
||||
{
|
||||
@@ -738,19 +735,19 @@ public class Registration
|
||||
/**
|
||||
* world gen
|
||||
*/
|
||||
for (WorldGenType type : WorldGenType.values())
|
||||
for ( WorldGenType type : WorldGenType.values() )
|
||||
{
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForProviderID( type, StorageWorldProvider.class );
|
||||
|
||||
//nether
|
||||
// nether
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, -1 );
|
||||
|
||||
//end
|
||||
// end
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, 1 );
|
||||
}
|
||||
|
||||
//whitelist from config
|
||||
for(int dimension : AEConfig.instance.meteoriteDimensionWhitelist)
|
||||
// whitelist from config
|
||||
for ( int dimension : AEConfig.instance.meteoriteDimensionWhitelist )
|
||||
{
|
||||
AEApi.instance().registries().worldgen().enableWorldGenForDimension( WorldGenType.Meteorites, dimension );
|
||||
}
|
||||
@@ -761,43 +758,4 @@ public class Registration
|
||||
OreDictionaryHandler.instance.bakeRecipes();
|
||||
}
|
||||
|
||||
private void registerSpatial(boolean force)
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
return;
|
||||
|
||||
AEConfig config = AEConfig.instance;
|
||||
|
||||
if ( storageBiome == null )
|
||||
{
|
||||
if ( force && config.storageBiomeID == -1 )
|
||||
{
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if ( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
}
|
||||
|
||||
if ( !force && config.storageBiomeID != -1 )
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID != -1 )
|
||||
{
|
||||
DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID == -1 && force )
|
||||
{
|
||||
config.storageProviderID = -11;
|
||||
|
||||
while (!DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false ))
|
||||
config.storageProviderID--;
|
||||
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
|
||||
|
||||
public class AEBlockDefinition extends BlockDefinition
|
||||
{
|
||||
private final AEBaseBlock block;
|
||||
|
||||
public AEBlockDefinition( AEBaseBlock block, boolean enabled )
|
||||
{
|
||||
super( block, enabled );
|
||||
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return this.block.getTileEntityClass();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AEBlockFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final AEBaseBlock featured;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final AEBlockDefinition definition;
|
||||
|
||||
public AEBlockFeatureHandler( EnumSet<AEFeature> features, AEBaseBlock featured, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.featured = featured;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new AEBlockDefinition( featured, this.enabled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
if ( this.enabled )
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.featured.setCreativeTab( CreativeTab.instance );
|
||||
this.featured.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
this.featured.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( this.featured.getTileEntityClass(), this.featured );
|
||||
}
|
||||
|
||||
Class<? extends AEBaseItemBlock> itemBlockClass = this.featured.getItemBlockClass();
|
||||
|
||||
GameRegistry.registerBlock( this.featured, itemBlockClass, "tile." + name );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,18 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
@@ -34,7 +39,7 @@ import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
|
||||
public class AEFeatureHandler implements AEItemDefinition
|
||||
{
|
||||
@@ -46,8 +51,10 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
|
||||
private Item ItemData;
|
||||
private Block BlockData;
|
||||
private BlockStairs stairData;
|
||||
|
||||
public AEFeatureHandler(EnumSet<AEFeature> features, IAEFeature feature, String subName) {
|
||||
public AEFeatureHandler( EnumSet<AEFeature> features, IAEFeature feature, String subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.feature = feature;
|
||||
this.subName = subName;
|
||||
@@ -58,13 +65,86 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
if ( isFeatureAvailable() )
|
||||
{
|
||||
if ( feature instanceof Item )
|
||||
initItem( (Item) feature );
|
||||
if ( feature instanceof Block )
|
||||
initBlock( (Block) feature );
|
||||
{
|
||||
initItem( ( Item ) feature );
|
||||
}
|
||||
else if ( this.feature instanceof BlockStairs )
|
||||
{
|
||||
this.initStairBlock( ( BlockStairs ) this.feature );
|
||||
}
|
||||
else if ( feature instanceof Block )
|
||||
{
|
||||
initBlock( ( Block ) feature );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(Class o, String subName)
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
boolean enabled = true;
|
||||
|
||||
for ( AEFeature f : features )
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private void initItem( Item i )
|
||||
{
|
||||
ItemData = i;
|
||||
|
||||
String name = getName( i.getClass(), subName );
|
||||
i.setTextureName( "appliedenergistics2:" + name );
|
||||
i.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( i instanceof ItemFacade )
|
||||
i.setCreativeTab( CreativeTabFacade.instance );
|
||||
else
|
||||
i.setCreativeTab( CreativeTab.instance );
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
name = "ItemMultiMaterial";
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
name = "ItemMultiPart";
|
||||
|
||||
GameRegistry.registerItem( i, "item." + name );
|
||||
}
|
||||
|
||||
private void initStairBlock( BlockStairs stair )
|
||||
{
|
||||
this.stairData = stair;
|
||||
|
||||
String name = getName( stair.getClass(), subName );
|
||||
stair.setCreativeTab( CreativeTab.instance );
|
||||
stair.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
stair.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
GameRegistry.registerBlock( stair, "tile." + name );
|
||||
}
|
||||
|
||||
private void initBlock( Block b )
|
||||
{
|
||||
BlockData = b;
|
||||
|
||||
String name = getName( b.getClass(), subName );
|
||||
b.setCreativeTab( CreativeTab.instance );
|
||||
b.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
b.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() && BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = ( AEBaseBlock ) b;
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( bb.getTileEntityClass(), bb );
|
||||
}
|
||||
|
||||
Class<? extends AEBaseItemBlock> itemBlock = AEBaseItemBlock.class;
|
||||
if ( b instanceof AEBaseBlock )
|
||||
itemBlock = ( ( AEBaseBlock ) b ).getItemBlockClass();
|
||||
|
||||
GameRegistry.registerBlock( b, itemBlock, "tile." + name );
|
||||
}
|
||||
|
||||
public static String getName( Class o, String subName )
|
||||
{
|
||||
String name = o.getSimpleName();
|
||||
|
||||
@@ -91,76 +171,42 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
return name;
|
||||
}
|
||||
|
||||
private void initItem(Item i)
|
||||
{
|
||||
ItemData = i;
|
||||
|
||||
String name = getName( i.getClass(), subName );
|
||||
i.setTextureName( "appliedenergistics2:" + name );
|
||||
i.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( i instanceof ItemFacade )
|
||||
i.setCreativeTab( CreativeTabFacade.instance );
|
||||
else
|
||||
i.setCreativeTab( CreativeTab.instance );
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
name = "ItemMultiMaterial";
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
name = "ItemMultiPart";
|
||||
|
||||
GameRegistry.registerItem( i, "item." + name );
|
||||
}
|
||||
|
||||
private void initBlock(Block b)
|
||||
{
|
||||
BlockData = b;
|
||||
|
||||
String name = getName( b.getClass(), subName );
|
||||
b.setCreativeTab( CreativeTab.instance );
|
||||
b.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
b.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() && BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = (AEBaseBlock) b;
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( bb.getTileEntityClass(), bb );
|
||||
}
|
||||
|
||||
Class<? extends AEBaseItemBlock> itemBlock = AEBaseItemBlock.class;
|
||||
if ( b instanceof AEBaseBlock )
|
||||
itemBlock = ((AEBaseBlock) b).getItemBlockClass();
|
||||
|
||||
GameRegistry.registerBlock( b, itemBlock, "tile." + name );
|
||||
}
|
||||
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return features.clone();
|
||||
}
|
||||
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
boolean enabled = true;
|
||||
|
||||
for (AEFeature f : features)
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return BlockData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
if ( this.ItemData != null )
|
||||
{
|
||||
return this.ItemData;
|
||||
}
|
||||
else if ( this.BlockData != null )
|
||||
{
|
||||
return Item.getItemFromBlock( this.BlockData );
|
||||
}
|
||||
else if ( this.stairData != null )
|
||||
{
|
||||
return Item.getItemFromBlock( this.stairData );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
if ( BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = (AEBaseBlock) BlockData;
|
||||
AEBaseBlock bb = ( AEBaseBlock ) BlockData;
|
||||
return bb.getTileEntityClass();
|
||||
}
|
||||
|
||||
@@ -168,15 +214,7 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
if ( ItemData == null && BlockData != null )
|
||||
return Item.getItemFromBlock( BlockData );
|
||||
return ItemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
if ( isFeatureAvailable() )
|
||||
{
|
||||
@@ -190,11 +228,12 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
rv.stackSize = stackSize;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack is)
|
||||
public boolean sameAsStack( ItemStack is )
|
||||
{
|
||||
return isFeatureAvailable() && Platform.isSameItemType( is, stack( 1 ) );
|
||||
}
|
||||
@@ -214,7 +253,7 @@ public class AEFeatureHandler implements AEItemDefinition
|
||||
* @return true if feature is available and the blocks are equal
|
||||
*/
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return isFeatureAvailable() && BlockData != null && world.getBlock( x, y, z ) == BlockData;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockDefinition implements AEItemDefinition
|
||||
{
|
||||
private final Block block;
|
||||
private final boolean enabled;
|
||||
|
||||
public BlockDefinition( Block block, boolean enabled )
|
||||
{
|
||||
this.block = block;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return this.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return Item.getItemFromBlock( this.block );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
if ( this.enabled )
|
||||
{
|
||||
return new ItemStack( this.block );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack( ItemStack comparableItem )
|
||||
{
|
||||
return this.enabled && Platform.isSameItemType( comparableItem, this.stack( 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return this.enabled && world.getBlock( x, y, z ) == this.block;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class FeatureNameExtractor
|
||||
{
|
||||
private Class<?> clazz;
|
||||
private Optional<String> subName;
|
||||
|
||||
public FeatureNameExtractor( Class<?> clazz, Optional<String> subName )
|
||||
{
|
||||
this.clazz = clazz;
|
||||
this.subName = subName;
|
||||
}
|
||||
|
||||
public String get()
|
||||
{
|
||||
String name = this.clazz.getSimpleName();
|
||||
|
||||
if ( name.startsWith( "ItemMultiPart" ) )
|
||||
{
|
||||
name = name.replace( "ItemMultiPart", "ItemPart" );
|
||||
}
|
||||
else if ( name.startsWith( "ItemMultiMaterial" ) )
|
||||
{
|
||||
name = name.replace( "ItemMultiMaterial", "ItemMaterial" );
|
||||
}
|
||||
|
||||
if ( this.subName.isPresent() )
|
||||
{
|
||||
final String subName = this.subName.get();
|
||||
// simple hack to allow me to do get nice names for these without
|
||||
// mode code outside of AEBaseItem
|
||||
if ( subName.startsWith( "P2PTunnel" ) )
|
||||
{
|
||||
return "ItemPart.P2PTunnel";
|
||||
}
|
||||
else if ( subName.equals( "CertusQuartzTools" ) )
|
||||
{
|
||||
return name.replace( "Quartz", "CertusQuartz" );
|
||||
}
|
||||
else if ( subName.equals( "NetherQuartzTools" ) )
|
||||
{
|
||||
return name.replace( "Quartz", "NetherQuartz" );
|
||||
}
|
||||
|
||||
name += "." + subName;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
|
||||
public class FeaturedActiveChecker
|
||||
{
|
||||
private EnumSet<AEFeature> features;
|
||||
|
||||
public FeaturedActiveChecker( EnumSet<AEFeature> features )
|
||||
{
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
public boolean get()
|
||||
{
|
||||
for ( AEFeature f : this.features )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( f ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
public interface IAEFeature
|
||||
{
|
||||
|
||||
public AEFeatureHandler feature();
|
||||
IFeatureHandler handler();
|
||||
|
||||
void postInit();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
|
||||
public interface IFeatureHandler
|
||||
{
|
||||
boolean isFeatureAvailable();
|
||||
|
||||
EnumSet<AEFeature> getFeatures();
|
||||
|
||||
AEItemDefinition getDefinition();
|
||||
|
||||
void register();
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemDefinition implements AEItemDefinition
|
||||
{
|
||||
private final Item item;
|
||||
private final boolean enabled;
|
||||
|
||||
public ItemDefinition( Item item, boolean enabled )
|
||||
{
|
||||
this.item = item;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( int stackSize )
|
||||
{
|
||||
if ( this.enabled )
|
||||
{
|
||||
return new ItemStack( this.item );
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack( ItemStack comparableItem )
|
||||
{
|
||||
return this.enabled && Platform.isSameItemType( comparableItem, this.stack( 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock( IBlockAccess world, int x, int y, int z )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
|
||||
|
||||
public class ItemFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final Item item;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final ItemDefinition definition;
|
||||
|
||||
public ItemFeatureHandler( EnumSet<AEFeature> features, Item item, IAEFeature featured, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.item = item;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new ItemDefinition( item, this.enabled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.item.setTextureName( "appliedenergistics2:" + name );
|
||||
this.item.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( this.item instanceof ItemFacade )
|
||||
{
|
||||
this.item.setCreativeTab( CreativeTabFacade.instance );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item.setCreativeTab( CreativeTab.instance );
|
||||
}
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
{
|
||||
name = "ItemMultiMaterial";
|
||||
}
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
{
|
||||
name = "ItemMultiPart";
|
||||
}
|
||||
|
||||
GameRegistry.registerItem( this.item, "item." + name );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.BlockStairs;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.core.CreativeTab;
|
||||
|
||||
|
||||
public class StairBlockFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final BlockStairs stairs;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final BlockDefinition definition;
|
||||
|
||||
public StairBlockFeatureHandler( EnumSet<AEFeature> features, BlockStairs stairs, Optional<String> subName )
|
||||
{
|
||||
this.features = features;
|
||||
this.stairs = stairs;
|
||||
this.extractor = new FeatureNameExtractor( stairs.getClass(), subName );
|
||||
this.enabled = new FeaturedActiveChecker( features ).get();
|
||||
this.definition = new BlockDefinition( stairs, this.enabled );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEItemDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.stairs.setCreativeTab( CreativeTab.instance );
|
||||
this.stairs.setBlockName( "appliedenergistics2." + name );
|
||||
this.stairs.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
GameRegistry.registerBlock( this.stairs, "tile." + name );
|
||||
}
|
||||
}
|
||||
@@ -22,54 +22,47 @@ package appeng.items;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.FeatureNameExtractor;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.ItemFeatureHandler;
|
||||
|
||||
|
||||
public class AEBaseItem extends Item implements IAEFeature
|
||||
{
|
||||
final String featureFullName;
|
||||
final String featureSubName;
|
||||
AEFeatureHandler feature;
|
||||
private final String fullName;
|
||||
private final Optional<String> subName;
|
||||
private IFeatureHandler feature;
|
||||
|
||||
public AEBaseItem( Class c )
|
||||
{
|
||||
this( c, Optional.<String> absent() );
|
||||
canRepair = false;
|
||||
}
|
||||
|
||||
public AEBaseItem( Class<?> c, Optional<String> subName )
|
||||
{
|
||||
this.subName = subName;
|
||||
this.fullName = new FeatureNameExtractor( c, subName ).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return featureFullName;
|
||||
return this.fullName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEFeatureHandler feature()
|
||||
public IFeatureHandler handler()
|
||||
{
|
||||
return feature;
|
||||
}
|
||||
|
||||
public void setFeature( EnumSet<AEFeature> f )
|
||||
{
|
||||
feature = new AEFeatureHandler( f, this, featureSubName );
|
||||
}
|
||||
|
||||
public AEBaseItem( Class c )
|
||||
{
|
||||
this( c, null );
|
||||
canRepair = false;
|
||||
}
|
||||
|
||||
public AEBaseItem( Class c, String subName )
|
||||
{
|
||||
featureSubName = subName;
|
||||
featureFullName = AEFeatureHandler.getName( c, subName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable( ItemStack itemstack1, ItemStack itemstack2 )
|
||||
{
|
||||
return false;
|
||||
return this.feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,6 +71,11 @@ public class AEBaseItem extends Item implements IAEFeature
|
||||
// override!
|
||||
}
|
||||
|
||||
public void setFeature( EnumSet<AEFeature> f )
|
||||
{
|
||||
this.feature = new ItemFeatureHandler( f, this, this, this.subName );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
public final void addInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation )
|
||||
@@ -85,6 +83,12 @@ public class AEBaseItem extends Item implements IAEFeature
|
||||
this.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable( ItemStack itemstack1, ItemStack itemstack2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -59,13 +61,13 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
final int perType;
|
||||
final double idleDrain;
|
||||
|
||||
public ItemBasicStorageCell( MaterialType whichCell, int Kilobytes )
|
||||
public ItemBasicStorageCell( MaterialType whichCell, int kilobytes )
|
||||
{
|
||||
super( ItemBasicStorageCell.class, Kilobytes + "k" );
|
||||
super( ItemBasicStorageCell.class, Optional.of( kilobytes + "k" ) );
|
||||
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
this.totalBytes = Kilobytes * 1024;
|
||||
this.totalBytes = kilobytes * 1024;
|
||||
this.component = whichCell;
|
||||
|
||||
switch ( this.component )
|
||||
@@ -169,6 +171,18 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
return this.idleDrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory( ItemStack is )
|
||||
{
|
||||
@@ -202,15 +216,10 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
|
||||
public ItemStack onItemRightClick( ItemStack stack, World world, EntityPlayer player )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
disassembleDrive( stack, world, player );
|
||||
return stack;
|
||||
}
|
||||
|
||||
private boolean disassembleDrive( ItemStack stack, World world, EntityPlayer player )
|
||||
@@ -248,28 +257,21 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick( ItemStack stack, World world, EntityPlayer player )
|
||||
{
|
||||
disassembleDrive( stack, world, player );
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return disassembleDrive( stack, world, player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem( ItemStack stack )
|
||||
{
|
||||
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem( ItemStack itemStack )
|
||||
{
|
||||
return AEApi.instance().materials().materialEmptyStorageCell.stack( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem( ItemStack stack )
|
||||
{
|
||||
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,18 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||
import appeng.api.util.WorldCoord;
|
||||
@@ -38,14 +42,16 @@ import appeng.spatial.StorageHelper;
|
||||
import appeng.spatial.StorageWorldProvider;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell
|
||||
{
|
||||
|
||||
final MaterialType component;
|
||||
final int maxRegion;
|
||||
|
||||
public ItemSpatialStorageCell(MaterialType whichCell, int spatialScale) {
|
||||
super( ItemSpatialStorageCell.class, spatialScale + "Cubed" );
|
||||
public ItemSpatialStorageCell( MaterialType whichCell, int spatialScale )
|
||||
{
|
||||
super( ItemSpatialStorageCell.class, Optional.of( spatialScale + "Cubed" ) );
|
||||
setFeature( EnumSet.of( AEFeature.SpatialIO ) );
|
||||
setMaxStackSize( 1 );
|
||||
maxRegion = spatialScale;
|
||||
@@ -53,7 +59,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
WorldCoord wc = getStoredSize( stack );
|
||||
if ( wc.x > 0 )
|
||||
@@ -61,19 +67,19 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpatialStorage(ItemStack is)
|
||||
public boolean isSpatialStorage( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStoredDim(ItemStack is)
|
||||
public int getMaxStoredDim( ItemStack is )
|
||||
{
|
||||
return maxRegion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld(ItemStack is)
|
||||
public World getWorld( ItemStack is )
|
||||
{
|
||||
if ( is.hasTagCompound() )
|
||||
{
|
||||
@@ -97,21 +103,8 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setStoredSize(ItemStack is, int targetX, int targetY, int targetZ)
|
||||
{
|
||||
if ( is.hasTagCompound() )
|
||||
{
|
||||
NBTTagCompound c = is.getTagCompound();
|
||||
int dim = c.getInteger( "StorageDim" );
|
||||
c.setInteger( "sizeX", targetX );
|
||||
c.setInteger( "sizeY", targetY );
|
||||
c.setInteger( "sizeZ", targetZ );
|
||||
WorldSettings.getInstance().setStoredSize( dim, targetX, targetY, targetZ );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldCoord getStoredSize(ItemStack is)
|
||||
public WorldCoord getStoredSize( ItemStack is )
|
||||
{
|
||||
if ( is.hasTagCompound() )
|
||||
{
|
||||
@@ -128,12 +121,12 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldCoord getMin(ItemStack is)
|
||||
public WorldCoord getMin( ItemStack is )
|
||||
{
|
||||
World w = getWorld( is );
|
||||
if ( w != null )
|
||||
{
|
||||
NBTTagCompound info = (NBTTagCompound) w.getWorldInfo().getAdditionalProperty( "storageCell" );
|
||||
NBTTagCompound info = ( NBTTagCompound ) w.getWorldInfo().getAdditionalProperty( "storageCell" );
|
||||
if ( info != null )
|
||||
{
|
||||
return new WorldCoord( info.getInteger( "minX" ), info.getInteger( "minY" ), info.getInteger( "minZ" ) );
|
||||
@@ -143,12 +136,12 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldCoord getMax(ItemStack is)
|
||||
public WorldCoord getMax( ItemStack is )
|
||||
{
|
||||
World w = getWorld( is );
|
||||
if ( w != null )
|
||||
{
|
||||
NBTTagCompound info = (NBTTagCompound) w.getWorldInfo().getAdditionalProperty( "storageCell" );
|
||||
NBTTagCompound info = ( NBTTagCompound ) w.getWorldInfo().getAdditionalProperty( "storageCell" );
|
||||
if ( info != null )
|
||||
{
|
||||
return new WorldCoord( info.getInteger( "maxX" ), info.getInteger( "maxY" ), info.getInteger( "maxZ" ) );
|
||||
@@ -157,18 +150,8 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
return new WorldCoord( 0, 0, 0 );
|
||||
}
|
||||
|
||||
public World createNewWorld(ItemStack is)
|
||||
{
|
||||
NBTTagCompound c = Platform.openNbtData( is );
|
||||
int newDim = DimensionManager.getNextFreeDimId();
|
||||
c.setInteger( "StorageDim", newDim );
|
||||
WorldSettings.getInstance().addStorageCellDim( newDim );
|
||||
DimensionManager.initDimension( newDim );
|
||||
return DimensionManager.getWorld( newDim );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionResult doSpatialTransition(ItemStack is, World w, WorldCoord min, WorldCoord max, boolean doTransition)
|
||||
public TransitionResult doSpatialTransition( ItemStack is, World w, WorldCoord min, WorldCoord max, boolean doTransition )
|
||||
{
|
||||
WorldCoord scale = getStoredSize( is );
|
||||
|
||||
@@ -180,7 +163,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
int floorBuffer = 64;
|
||||
World destination = getWorld( is );
|
||||
|
||||
if ( (scale.x == 0 && scale.y == 0 && scale.z == 0) || (scale.x == targetX && scale.y == targetY && scale.z == targetZ) )
|
||||
if ( ( scale.x == 0 && scale.y == 0 && scale.z == 0 ) || ( scale.x == targetX && scale.y == targetY && scale.z == targetZ ) )
|
||||
{
|
||||
if ( targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize )
|
||||
{
|
||||
@@ -198,4 +181,27 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
return new TransitionResult( false, 0 );
|
||||
}
|
||||
|
||||
public World createNewWorld( ItemStack is )
|
||||
{
|
||||
NBTTagCompound c = Platform.openNbtData( is );
|
||||
int newDim = DimensionManager.getNextFreeDimId();
|
||||
c.setInteger( "StorageDim", newDim );
|
||||
WorldSettings.getInstance().addStorageCellDim( newDim );
|
||||
DimensionManager.initDimension( newDim );
|
||||
return DimensionManager.getWorld( newDim );
|
||||
}
|
||||
|
||||
private void setStoredSize( ItemStack is, int targetX, int targetY, int targetZ )
|
||||
{
|
||||
if ( is.hasTagCompound() )
|
||||
{
|
||||
NBTTagCompound c = is.getTagCompound();
|
||||
int dim = c.getInteger( "StorageDim" );
|
||||
c.setInteger( "sizeX", targetX );
|
||||
c.setInteger( "sizeY", targetY );
|
||||
c.setInteger( "sizeZ", targetZ );
|
||||
WorldSettings.getInstance().setStoredSize( dim, targetX, targetY, targetZ );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@
|
||||
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -28,6 +31,9 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
@@ -46,14 +52,15 @@ import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.NetworkToolViewer;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
@Interface(iface = "buildcraft.api.tools.IToolWrench", iname = "BC")
|
||||
|
||||
@Interface( iface = "buildcraft.api.tools.IToolWrench", iname = "BC" )
|
||||
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, IToolWrench
|
||||
{
|
||||
|
||||
public ToolNetworkTool() {
|
||||
super( ToolNetworkTool.class, null );
|
||||
public ToolNetworkTool()
|
||||
{
|
||||
super( ToolNetworkTool.class, Optional.<String> absent() );
|
||||
|
||||
this.setFeature( EnumSet.of( AEFeature.NetworkTool ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
@@ -61,14 +68,14 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, int x, int y, int z)
|
||||
public IGuiItemObject getGuiObject( ItemStack is, World world, int x, int y, int z )
|
||||
{
|
||||
TileEntity te = world.getTileEntity( x, y, z );
|
||||
return new NetworkToolViewer( is, (IGridHost) (te instanceof IGridHost ? te : null) );
|
||||
return new NetworkToolViewer( is, ( IGridHost ) ( te instanceof IGridHost ? te : null ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack it, World w, EntityPlayer p)
|
||||
public ItemStack onItemRightClick( ItemStack it, World w, EntityPlayer p )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
@@ -93,20 +100,20 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
public boolean onItemUseFirst( ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
MovingObjectPosition mop = new MovingObjectPosition( x, y, z, side, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
|
||||
TileEntity te = world.getTileEntity( x, y, z );
|
||||
if ( te instanceof IPartHost )
|
||||
{
|
||||
SelectedPart part = ((IPartHost) te).selectPart( mop.hitVec );
|
||||
SelectedPart part = ( ( IPartHost ) te ).selectPart( mop.hitVec );
|
||||
if ( part.part != null )
|
||||
{
|
||||
if ( part.part instanceof INetworkToolAgent && !((INetworkToolAgent) part.part).showNetworkInfo( mop ) )
|
||||
if ( part.part instanceof INetworkToolAgent && !( ( INetworkToolAgent ) part.part ).showNetworkInfo( mop ) )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( te instanceof INetworkToolAgent && !((INetworkToolAgent) te).showNetworkInfo( mop ) )
|
||||
else if ( te instanceof INetworkToolAgent && !( ( INetworkToolAgent ) te ).showNetworkInfo( mop ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -118,7 +125,13 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean serverSideToolLogic(ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
@Override
|
||||
public boolean doesSneakBypassUse( World world, int x, int y, int z, EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean serverSideToolLogic( ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
if ( side >= 0 )
|
||||
{
|
||||
@@ -129,7 +142,7 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
if ( b != null && !p.isSneaking() )
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
if ( !(te instanceof IGridHost) )
|
||||
if ( !( te instanceof IGridHost ) )
|
||||
{
|
||||
if ( b.rotateBlock( w, x, y, z, ForgeDirection.getOrientation( side ) ) )
|
||||
{
|
||||
@@ -164,25 +177,19 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player)
|
||||
public boolean canWrench( ItemStack is, EntityPlayer player, int x, int y, int z )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(ItemStack is, EntityPlayer player, int x, int y, int z)
|
||||
public boolean canWrench( EntityPlayer player, int x, int y, int z )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wrenchUsed(EntityPlayer player, int x, int y, int z)
|
||||
public void wrenchUsed( EntityPlayer player, int x, int y, int z )
|
||||
{
|
||||
player.swingItem();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,15 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.packets.PacketLightning;
|
||||
@@ -30,28 +34,30 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.server.ServerHelper;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolChargedStaff extends AEBasePoweredItem
|
||||
{
|
||||
|
||||
public ToolChargedStaff() {
|
||||
super( ToolChargedStaff.class, null );
|
||||
public ToolChargedStaff()
|
||||
{
|
||||
super( ToolChargedStaff.class, Optional.<String> absent() );
|
||||
setFeature( EnumSet.of( AEFeature.ChargedStaff, AEFeature.PoweredTools ) );
|
||||
maxStoredPower = AEConfig.instance.chargedStaffBattery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase hitter)
|
||||
public boolean hitEntity( ItemStack item, EntityLivingBase target, EntityLivingBase hitter )
|
||||
{
|
||||
if ( this.getAECurrentPower( item ) > 300 )
|
||||
{
|
||||
extractAEPower( item, 300 );
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (int x = 0; x < 2; x++)
|
||||
for ( int x = 0; x < 2; x++ )
|
||||
{
|
||||
float dx = (float) (Platform.getRandomFloat() * target.width + target.boundingBox.minX);
|
||||
float dy = (float) (Platform.getRandomFloat() * target.height + target.boundingBox.minY);
|
||||
float dz = (float) (Platform.getRandomFloat() * target.width + target.boundingBox.minZ);
|
||||
float dx = ( float ) ( Platform.getRandomFloat() * target.width + target.boundingBox.minX );
|
||||
float dy = ( float ) ( Platform.getRandomFloat() * target.height + target.boundingBox.minY );
|
||||
float dz = ( float ) ( Platform.getRandomFloat() * target.width + target.boundingBox.minZ );
|
||||
ServerHelper.proxy.sendToAllNearExcept( null, dx, dy, dz, 32.0, target.worldObj, new PacketLightning( dx, dy, dz ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -97,7 +99,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
|
||||
public ToolColorApplicator()
|
||||
{
|
||||
super( ToolColorApplicator.class, null );
|
||||
super( ToolColorApplicator.class, Optional.<String> absent() );
|
||||
setFeature( EnumSet.of( AEFeature.ColorApplicator, AEFeature.PoweredTools ) );
|
||||
maxStoredPower = AEConfig.instance.colorApplicatorBattery;
|
||||
if ( Platform.isClient() )
|
||||
@@ -111,125 +113,6 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject( this, new DispenserBlockTool() );
|
||||
}
|
||||
|
||||
public ItemStack getColor( ItemStack is )
|
||||
{
|
||||
NBTTagCompound c = is.getTagCompound();
|
||||
if ( c != null && c.hasKey( "color" ) )
|
||||
{
|
||||
NBTTagCompound color = c.getCompoundTag( "color" );
|
||||
ItemStack oldColor = ItemStack.loadItemStackFromNBT( color );
|
||||
if ( oldColor != null )
|
||||
return oldColor;
|
||||
}
|
||||
|
||||
return findNextColor( is, null, 0 );
|
||||
}
|
||||
|
||||
public AEColor getColorFromItem( ItemStack paintBall )
|
||||
{
|
||||
if ( paintBall == null )
|
||||
return null;
|
||||
|
||||
if ( paintBall.getItem() instanceof ItemSnowball )
|
||||
return AEColor.Transparent;
|
||||
|
||||
if ( paintBall.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
ItemPaintBall ipb = ( ItemPaintBall ) paintBall.getItem();
|
||||
return ipb.getColor( paintBall );
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] id = OreDictionary.getOreIDs( paintBall );
|
||||
|
||||
for ( int oreID : id )
|
||||
{
|
||||
if ( oreToColor.containsKey( oreID ) )
|
||||
return oreToColor.get( oreID );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public AEColor getActiveColor( ItemStack tol )
|
||||
{
|
||||
return getColorFromItem( getColor( tol ) );
|
||||
}
|
||||
|
||||
private ItemStack findNextColor( ItemStack is, ItemStack anchor, int scrollOffset )
|
||||
{
|
||||
ItemStack newColor = null;
|
||||
|
||||
IMEInventory<IAEItemStack> inv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
|
||||
if ( inv != null )
|
||||
{
|
||||
IItemList<IAEItemStack> itemList = inv.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
if ( anchor == null )
|
||||
{
|
||||
IAEItemStack firstItem = itemList.getFirstItem();
|
||||
if ( firstItem != null )
|
||||
newColor = firstItem.getItemStack();
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkedList<IAEItemStack> list = new LinkedList<IAEItemStack>();
|
||||
|
||||
for ( IAEItemStack i : itemList )
|
||||
list.add( i );
|
||||
|
||||
Collections.sort( list, new Comparator<IAEItemStack>(){
|
||||
|
||||
@Override
|
||||
public int compare( IAEItemStack a, IAEItemStack b )
|
||||
{
|
||||
return ItemSorters.compareInt( a.getItemDamage(), b.getItemDamage() );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
if ( list.size() <= 0 )
|
||||
return null;
|
||||
|
||||
IAEItemStack where = list.getFirst();
|
||||
int cycles = 1 + list.size();
|
||||
|
||||
while ( cycles > 0 && !where.equals( anchor ) )
|
||||
{
|
||||
list.addLast( list.removeFirst() );
|
||||
cycles--;
|
||||
where = list.getFirst();
|
||||
}
|
||||
|
||||
if ( scrollOffset > 0 )
|
||||
list.addLast( list.removeFirst() );
|
||||
|
||||
if ( scrollOffset < 0 )
|
||||
list.addFirst( list.removeLast() );
|
||||
|
||||
return list.get( 0 ).getItemStack();
|
||||
}
|
||||
}
|
||||
|
||||
if ( newColor != null )
|
||||
setColor( is, newColor );
|
||||
|
||||
return newColor;
|
||||
}
|
||||
|
||||
public void setColor( ItemStack is, ItemStack newColor )
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( is );
|
||||
if ( newColor == null )
|
||||
data.removeTag( "color" );
|
||||
else
|
||||
{
|
||||
NBTTagCompound color = new NBTTagCompound();
|
||||
newColor.writeToNBT( color );
|
||||
data.setTag( "color", color );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse( ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
@@ -309,6 +192,138 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName( ItemStack par1ItemStack )
|
||||
{
|
||||
String extra = GuiText.Empty.getLocal();
|
||||
|
||||
AEColor selected = getActiveColor( par1ItemStack );
|
||||
|
||||
if ( selected != null && Platform.isClient() )
|
||||
extra = Platform.gui_localize( selected.unlocalizedName );
|
||||
|
||||
return super.getItemStackDisplayName( par1ItemStack ) + " - " + extra;
|
||||
}
|
||||
|
||||
public AEColor getActiveColor( ItemStack tol )
|
||||
{
|
||||
return getColorFromItem( getColor( tol ) );
|
||||
}
|
||||
|
||||
public AEColor getColorFromItem( ItemStack paintBall )
|
||||
{
|
||||
if ( paintBall == null )
|
||||
return null;
|
||||
|
||||
if ( paintBall.getItem() instanceof ItemSnowball )
|
||||
return AEColor.Transparent;
|
||||
|
||||
if ( paintBall.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
ItemPaintBall ipb = ( ItemPaintBall ) paintBall.getItem();
|
||||
return ipb.getColor( paintBall );
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] id = OreDictionary.getOreIDs( paintBall );
|
||||
|
||||
for ( int oreID : id )
|
||||
{
|
||||
if ( oreToColor.containsKey( oreID ) )
|
||||
return oreToColor.get( oreID );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getColor( ItemStack is )
|
||||
{
|
||||
NBTTagCompound c = is.getTagCompound();
|
||||
if ( c != null && c.hasKey( "color" ) )
|
||||
{
|
||||
NBTTagCompound color = c.getCompoundTag( "color" );
|
||||
ItemStack oldColor = ItemStack.loadItemStackFromNBT( color );
|
||||
if ( oldColor != null )
|
||||
return oldColor;
|
||||
}
|
||||
|
||||
return findNextColor( is, null, 0 );
|
||||
}
|
||||
|
||||
private ItemStack findNextColor( ItemStack is, ItemStack anchor, int scrollOffset )
|
||||
{
|
||||
ItemStack newColor = null;
|
||||
|
||||
IMEInventory<IAEItemStack> inv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
|
||||
if ( inv != null )
|
||||
{
|
||||
IItemList<IAEItemStack> itemList = inv.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
if ( anchor == null )
|
||||
{
|
||||
IAEItemStack firstItem = itemList.getFirstItem();
|
||||
if ( firstItem != null )
|
||||
newColor = firstItem.getItemStack();
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkedList<IAEItemStack> list = new LinkedList<IAEItemStack>();
|
||||
|
||||
for ( IAEItemStack i : itemList )
|
||||
list.add( i );
|
||||
|
||||
Collections.sort( list, new Comparator<IAEItemStack>(){
|
||||
|
||||
@Override
|
||||
public int compare( IAEItemStack a, IAEItemStack b )
|
||||
{
|
||||
return ItemSorters.compareInt( a.getItemDamage(), b.getItemDamage() );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
if ( list.size() <= 0 )
|
||||
return null;
|
||||
|
||||
IAEItemStack where = list.getFirst();
|
||||
int cycles = 1 + list.size();
|
||||
|
||||
while ( cycles > 0 && !where.equals( anchor ) )
|
||||
{
|
||||
list.addLast( list.removeFirst() );
|
||||
cycles--;
|
||||
where = list.getFirst();
|
||||
}
|
||||
|
||||
if ( scrollOffset > 0 )
|
||||
list.addLast( list.removeFirst() );
|
||||
|
||||
if ( scrollOffset < 0 )
|
||||
list.addFirst( list.removeLast() );
|
||||
|
||||
return list.get( 0 ).getItemStack();
|
||||
}
|
||||
}
|
||||
|
||||
if ( newColor != null )
|
||||
setColor( is, newColor );
|
||||
|
||||
return newColor;
|
||||
}
|
||||
|
||||
public void setColor( ItemStack is, ItemStack newColor )
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( is );
|
||||
if ( newColor == null )
|
||||
data.removeTag( "color" );
|
||||
else
|
||||
{
|
||||
NBTTagCompound color = new NBTTagCompound();
|
||||
newColor.writeToNBT( color );
|
||||
data.setTag( "color", color );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recolourBlock( Block blk, ForgeDirection side, World w, int x, int y, int z, ForgeDirection orientation, AEColor newColor, EntityPlayer p )
|
||||
{
|
||||
if ( blk == Blocks.carpet )
|
||||
@@ -376,19 +391,6 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName( ItemStack par1ItemStack )
|
||||
{
|
||||
String extra = GuiText.Empty.getLocal();
|
||||
|
||||
AEColor selected = getActiveColor( par1ItemStack );
|
||||
|
||||
if ( selected != null && Platform.isClient() )
|
||||
extra = Platform.gui_localize( selected.unlocalizedName );
|
||||
|
||||
return super.getItemStackDisplayName( par1ItemStack ) + " - " + extra;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
@@ -458,6 +460,24 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory( ItemStack is )
|
||||
{
|
||||
@@ -484,30 +504,12 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode( ItemStack is, FuzzyMode fzMode )
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWheel( ItemStack is, boolean up )
|
||||
{
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.BlockTNT;
|
||||
@@ -39,6 +42,7 @@ import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.misc.BlockTinyTNT;
|
||||
import appeng.core.AEConfig;
|
||||
@@ -49,116 +53,16 @@ import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.InWorldToolOperationResult;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockTool
|
||||
{
|
||||
|
||||
static class Combo
|
||||
{
|
||||
|
||||
final public Block blk;
|
||||
final public int meta;
|
||||
|
||||
public Combo(Block b, int m) {
|
||||
blk = b;
|
||||
meta = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return blk.hashCode() ^ meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
Combo other = (Combo) obj;
|
||||
return blk == other.blk && meta == other.meta;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static private Hashtable<Combo, InWorldToolOperationResult> heatUp;
|
||||
static private Hashtable<Combo, InWorldToolOperationResult> coolDown;
|
||||
|
||||
static public void heat(Block BlockID, int Metadata, World w, int x, int y, int z)
|
||||
public ToolEntropyManipulator()
|
||||
{
|
||||
InWorldToolOperationResult r = heatUp.get( new Combo( BlockID, Metadata ) );
|
||||
|
||||
if ( r == null )
|
||||
{
|
||||
r = heatUp.get( new Combo( BlockID, OreDictionary.WILDCARD_VALUE ) );
|
||||
}
|
||||
|
||||
if ( r.BlockItem != null )
|
||||
{
|
||||
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
||||
}
|
||||
|
||||
if ( r.Drops != null )
|
||||
{
|
||||
Platform.spawnDrops( w, x, y, z, r.Drops );
|
||||
}
|
||||
}
|
||||
|
||||
static public boolean canHeat(Block BlockID, int Metadata)
|
||||
{
|
||||
InWorldToolOperationResult r = heatUp.get( new Combo( BlockID, Metadata ) );
|
||||
|
||||
if ( r == null )
|
||||
{
|
||||
r = heatUp.get( new Combo( BlockID, OreDictionary.WILDCARD_VALUE ) );
|
||||
}
|
||||
|
||||
return r != null;
|
||||
}
|
||||
|
||||
static public void cool(Block BlockID, int Metadata, World w, int x, int y, int z)
|
||||
{
|
||||
InWorldToolOperationResult r = coolDown.get( new Combo( BlockID, Metadata ) );
|
||||
|
||||
if ( r == null )
|
||||
{
|
||||
r = coolDown.get( new Combo( BlockID, OreDictionary.WILDCARD_VALUE ) );
|
||||
}
|
||||
|
||||
if ( r.BlockItem != null )
|
||||
{
|
||||
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
||||
}
|
||||
|
||||
if ( r.Drops != null )
|
||||
{
|
||||
Platform.spawnDrops( w, x, y, z, r.Drops );
|
||||
}
|
||||
}
|
||||
|
||||
static public boolean canCool(Block BlockID, int Metadata)
|
||||
{
|
||||
InWorldToolOperationResult r = coolDown.get( new Combo( BlockID, Metadata ) );
|
||||
|
||||
if ( r == null )
|
||||
{
|
||||
r = coolDown.get( new Combo( BlockID, OreDictionary.WILDCARD_VALUE ) );
|
||||
}
|
||||
|
||||
return r != null;
|
||||
}
|
||||
|
||||
public ToolEntropyManipulator() {
|
||||
super( ToolEntropyManipulator.class, null );
|
||||
super( ToolEntropyManipulator.class, Optional.<String> absent() );
|
||||
setFeature( EnumSet.of( AEFeature.EntropyManipulator, AEFeature.PoweredTools ) );
|
||||
maxStoredPower = AEConfig.instance.entropyManipulatorBattery;
|
||||
|
||||
@@ -188,8 +92,111 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject( this, new DispenserBlockTool() );
|
||||
}
|
||||
|
||||
static public void heat( Block BlockID, int Metadata, World w, int x, int y, int z )
|
||||
{
|
||||
InWorldToolOperationResult r = heatUp.get( new Combo( BlockID, Metadata ) );
|
||||
|
||||
if ( r == null )
|
||||
{
|
||||
r = heatUp.get( new Combo( BlockID, OreDictionary.WILDCARD_VALUE ) );
|
||||
}
|
||||
|
||||
if ( r.BlockItem != null )
|
||||
{
|
||||
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
||||
}
|
||||
|
||||
if ( r.Drops != null )
|
||||
{
|
||||
Platform.spawnDrops( w, x, y, z, r.Drops );
|
||||
}
|
||||
}
|
||||
|
||||
static class Combo
|
||||
{
|
||||
|
||||
final public Block blk;
|
||||
final public int meta;
|
||||
|
||||
public Combo( Block b, int m )
|
||||
{
|
||||
blk = b;
|
||||
meta = m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return blk.hashCode() ^ meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
Combo other = ( Combo ) obj;
|
||||
return blk == other.blk && meta == other.meta;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static public boolean canHeat( Block BlockID, int Metadata )
|
||||
{
|
||||
InWorldToolOperationResult r = heatUp.get( new Combo( BlockID, Metadata ) );
|
||||
|
||||
if ( r == null )
|
||||
{
|
||||
r = heatUp.get( new Combo( BlockID, OreDictionary.WILDCARD_VALUE ) );
|
||||
}
|
||||
|
||||
return r != null;
|
||||
}
|
||||
|
||||
static public void cool( Block BlockID, int Metadata, World w, int x, int y, int z )
|
||||
{
|
||||
InWorldToolOperationResult r = coolDown.get( new Combo( BlockID, Metadata ) );
|
||||
|
||||
if ( r == null )
|
||||
{
|
||||
r = coolDown.get( new Combo( BlockID, OreDictionary.WILDCARD_VALUE ) );
|
||||
}
|
||||
|
||||
if ( r.BlockItem != null )
|
||||
{
|
||||
w.setBlock( x, y, z, Block.getBlockFromItem( r.BlockItem.getItem() ), r.BlockItem.getItemDamage(), 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
||||
}
|
||||
|
||||
if ( r.Drops != null )
|
||||
{
|
||||
Platform.spawnDrops( w, x, y, z, r.Drops );
|
||||
}
|
||||
}
|
||||
|
||||
static public boolean canCool( Block BlockID, int Metadata )
|
||||
{
|
||||
InWorldToolOperationResult r = coolDown.get( new Combo( BlockID, Metadata ) );
|
||||
|
||||
if ( r == null )
|
||||
{
|
||||
r = coolDown.get( new Combo( BlockID, OreDictionary.WILDCARD_VALUE ) );
|
||||
}
|
||||
|
||||
return r != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack item, EntityLivingBase target, EntityLivingBase hitter)
|
||||
public boolean hitEntity( ItemStack item, EntityLivingBase target, EntityLivingBase hitter )
|
||||
{
|
||||
if ( this.getAECurrentPower( item ) > 1600 )
|
||||
{
|
||||
@@ -201,7 +208,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack item, World w, EntityPlayer p)
|
||||
public ItemStack onItemRightClick( ItemStack item, World w, EntityPlayer p )
|
||||
{
|
||||
MovingObjectPosition target = this.getMovingObjectPositionFromPlayer( w, p, true );
|
||||
|
||||
@@ -229,7 +236,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack item, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
public boolean onItemUse( ItemStack item, EntityPlayer p, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
if ( this.getAECurrentPower( item ) > 1600 )
|
||||
{
|
||||
@@ -253,14 +260,14 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
|
||||
if ( Blk instanceof BlockTNT )
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
||||
((BlockTNT) Blk).func_150114_a( w, x, y, z, 1, p );
|
||||
( ( BlockTNT ) Blk ).func_150114_a( w, x, y, z, 1, p );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( Blk instanceof BlockTinyTNT )
|
||||
{
|
||||
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
||||
((BlockTinyTNT) Blk).startFuse( w, x, y, z, p );
|
||||
( ( BlockTinyTNT ) Blk ).startFuse( w, x, y, z, p );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -276,7 +283,7 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
|
||||
boolean hasFurnaceable = false;
|
||||
boolean canFurnaceable = true;
|
||||
|
||||
for (ItemStack i : stack)
|
||||
for ( ItemStack i : stack )
|
||||
{
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult( i );
|
||||
|
||||
|
||||
@@ -18,9 +18,12 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -39,6 +42,7 @@ import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -73,11 +77,13 @@ import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
{
|
||||
|
||||
public ToolMassCannon() {
|
||||
super( ToolMassCannon.class, null );
|
||||
public ToolMassCannon()
|
||||
{
|
||||
super( ToolMassCannon.class, Optional.<String> absent() );
|
||||
setFeature( EnumSet.of( AEFeature.MatterCannon, AEFeature.PoweredTools ) );
|
||||
maxStoredPower = AEConfig.instance.matterCannonBattery;
|
||||
}
|
||||
@@ -90,7 +96,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
@@ -98,7 +104,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
|
||||
if ( cdi instanceof CellInventoryHandler )
|
||||
{
|
||||
ICellInventory cd = ((ICellInventoryHandler) cdi).getCellInv();
|
||||
ICellInventory cd = ( ( ICellInventoryHandler ) cdi ).getCellInv();
|
||||
if ( cd != null )
|
||||
{
|
||||
lines.add( cd.getUsedBytes() + " " + GuiText.Of.getLocal() + " " + cd.getTotalBytes() + " " + GuiText.BytesUsed.getLocal() );
|
||||
@@ -108,13 +114,13 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack item, World w, EntityPlayer p)
|
||||
public ItemStack onItemRightClick( ItemStack item, World w, EntityPlayer p )
|
||||
{
|
||||
if ( this.getAECurrentPower( item ) > 1600 )
|
||||
{
|
||||
int shots = 1;
|
||||
|
||||
CellUpgrades cu = (CellUpgrades) getUpgradesInventory( item );
|
||||
CellUpgrades cu = ( CellUpgrades ) getUpgradesInventory( item );
|
||||
if ( cu != null )
|
||||
shots += cu.getInstalledUpgrades( Upgrades.SPEED );
|
||||
|
||||
@@ -125,8 +131,8 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
IAEStack aeAmmo = itemList.getFirstItem();
|
||||
if ( aeAmmo instanceof IAEItemStack )
|
||||
{
|
||||
shots = Math.min( shots, (int) aeAmmo.getStackSize() );
|
||||
for (int sh = 0; sh < shots; sh++)
|
||||
shots = Math.min( shots, ( int ) aeAmmo.getStackSize() );
|
||||
for ( int sh = 0; sh < shots; sh++ )
|
||||
{
|
||||
extractAEPower( item, 1600 );
|
||||
|
||||
@@ -134,7 +140,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
return item;
|
||||
|
||||
aeAmmo.setStackSize( 1 );
|
||||
ItemStack ammo = ((IAEItemStack) aeAmmo).getItemStack();
|
||||
ItemStack ammo = ( ( IAEItemStack ) aeAmmo ).getItemStack();
|
||||
if ( ammo == null )
|
||||
return item;
|
||||
|
||||
@@ -144,14 +150,14 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
return item;
|
||||
|
||||
float f = 1.0F;
|
||||
float f1 = p.prevRotationPitch + (p.rotationPitch - p.prevRotationPitch) * f;
|
||||
float f2 = p.prevRotationYaw + (p.rotationYaw - p.prevRotationYaw) * f;
|
||||
double d0 = p.prevPosX + (p.posX - p.prevPosX) * f;
|
||||
double d1 = p.prevPosY + (p.posY - p.prevPosY) * f + 1.62D - p.yOffset;
|
||||
double d2 = p.prevPosZ + (p.posZ - p.prevPosZ) * f;
|
||||
float f1 = p.prevRotationPitch + ( p.rotationPitch - p.prevRotationPitch ) * f;
|
||||
float f2 = p.prevRotationYaw + ( p.rotationYaw - p.prevRotationYaw ) * f;
|
||||
double d0 = p.prevPosX + ( p.posX - p.prevPosX ) * f;
|
||||
double d1 = p.prevPosY + ( p.posY - p.prevPosY ) * f + 1.62D - p.yOffset;
|
||||
double d2 = p.prevPosZ + ( p.posZ - p.prevPosZ ) * f;
|
||||
Vec3 vec3 = Vec3.createVectorHelper( d0, d1, d2 );
|
||||
float f3 = MathHelper.cos( -f2 * 0.017453292F - (float) Math.PI );
|
||||
float f4 = MathHelper.sin( -f2 * 0.017453292F - (float) Math.PI );
|
||||
float f3 = MathHelper.cos( -f2 * 0.017453292F - ( float ) Math.PI );
|
||||
float f4 = MathHelper.sin( -f2 * 0.017453292F - ( float ) Math.PI );
|
||||
float f5 = -MathHelper.cos( -f1 * 0.017453292F );
|
||||
float f6 = MathHelper.sin( -f1 * 0.017453292F );
|
||||
float f7 = f4 * f5;
|
||||
@@ -165,7 +171,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
float penetration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f;
|
||||
if ( penetration <= 0 )
|
||||
{
|
||||
ItemStack type = ((IAEItemStack) aeAmmo).getItemStack();
|
||||
ItemStack type = ( ( IAEItemStack ) aeAmmo ).getItemStack();
|
||||
if ( type.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
shootPaintBalls( type, w, p, vec3, vec31, direction, d0, d1, d2 );
|
||||
@@ -190,7 +196,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
return item;
|
||||
}
|
||||
|
||||
private void shootPaintBalls(ItemStack type, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2)
|
||||
private void shootPaintBalls( ItemStack type, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2 )
|
||||
{
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ),
|
||||
Math.min( vec3.zCoord, vec31.zCoord ), Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ),
|
||||
@@ -201,11 +207,11 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
double closest = 9999999.0D;
|
||||
int l;
|
||||
|
||||
for (l = 0; l < list.size(); ++l)
|
||||
for ( l = 0; l < list.size(); ++l )
|
||||
{
|
||||
Entity entity1 = (Entity) list.get( l );
|
||||
Entity entity1 = ( Entity ) list.get( l );
|
||||
|
||||
if ( !entity1.isDead && entity1 != p && !(entity1 instanceof EntityItem) )
|
||||
if ( !entity1.isDead && entity1 != p && !( entity1 instanceof EntityItem ) )
|
||||
{
|
||||
if ( entity1.isEntityAlive() )
|
||||
{
|
||||
@@ -246,18 +252,18 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
|
||||
try
|
||||
{
|
||||
CommonHelper.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.xCoord,
|
||||
(float) direction.yCoord, (float) direction.zCoord, (byte) (pos == null ? 32 : pos.hitVec.squareDistanceTo( vec ) + 1) ) );
|
||||
CommonHelper.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, ( float ) direction.xCoord,
|
||||
( float ) direction.yCoord, ( float ) direction.zCoord, ( byte ) ( pos == null ? 32 : pos.hitVec.squareDistanceTo( vec ) + 1 ) ) );
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
catch ( Exception err )
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
|
||||
if ( pos != null && type != null && type.getItem() instanceof ItemPaintBall )
|
||||
{
|
||||
ItemPaintBall ipb = (ItemPaintBall) type.getItem();
|
||||
ItemPaintBall ipb = ( ItemPaintBall ) type.getItem();
|
||||
|
||||
AEColor col = ipb.getColor( type );
|
||||
// boolean lit = ipb.isLumen( type );
|
||||
@@ -270,7 +276,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
|
||||
if ( pos.entityHit instanceof EntitySheep )
|
||||
{
|
||||
EntitySheep sh = (EntitySheep) pos.entityHit;
|
||||
EntitySheep sh = ( EntitySheep ) pos.entityHit;
|
||||
sh.setFleeceColor( col.ordinal() );
|
||||
}
|
||||
|
||||
@@ -300,17 +306,17 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
pos.hitVec.xCoord -= x;
|
||||
pos.hitVec.yCoord -= y;
|
||||
pos.hitVec.zCoord -= z;
|
||||
((TilePaint) te).addBlot( type, side.getOpposite(), pos.hitVec );
|
||||
( ( TilePaint ) te ).addBlot( type, side.getOpposite(), pos.hitVec );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void standardAmmo(float penetration, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2)
|
||||
private void standardAmmo( float penetration, World w, EntityPlayer p, Vec3 vec3, Vec3 vec31, Vec3 direction, double d0, double d1, double d2 )
|
||||
{
|
||||
boolean hasDestroyedSomething = true;
|
||||
while (penetration > 0 && hasDestroyedSomething)
|
||||
while ( penetration > 0 && hasDestroyedSomething )
|
||||
{
|
||||
hasDestroyedSomething = false;
|
||||
|
||||
@@ -323,11 +329,11 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
double closest = 9999999.0D;
|
||||
int l;
|
||||
|
||||
for (l = 0; l < list.size(); ++l)
|
||||
for ( l = 0; l < list.size(); ++l )
|
||||
{
|
||||
Entity entity1 = (Entity) list.get( l );
|
||||
Entity entity1 = ( Entity ) list.get( l );
|
||||
|
||||
if ( !entity1.isDead && entity1 != p && !(entity1 instanceof EntityItem) )
|
||||
if ( !entity1.isDead && entity1 != p && !( entity1 instanceof EntityItem ) )
|
||||
{
|
||||
if ( entity1.isEntityAlive() )
|
||||
{
|
||||
@@ -367,11 +373,11 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
|
||||
try
|
||||
{
|
||||
CommonHelper.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, (float) direction.xCoord,
|
||||
(float) direction.yCoord, (float) direction.zCoord, (byte) (pos == null ? 32 : pos.hitVec.squareDistanceTo( vec ) + 1) ) );
|
||||
CommonHelper.proxy.sendToAllNearExcept( null, d0, d1, d2, 128, w, new PacketMatterCannon( d0, d1, d2, ( float ) direction.xCoord,
|
||||
( float ) direction.yCoord, ( float ) direction.zCoord, ( byte ) ( pos == null ? 32 : pos.hitVec.squareDistanceTo( vec ) + 1 ) ) );
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
catch ( Exception err )
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
@@ -383,10 +389,10 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
|
||||
if ( pos.typeOfHit == MovingObjectType.ENTITY )
|
||||
{
|
||||
int dmg = (int) Math.ceil( penetration / 20.0f );
|
||||
int dmg = ( int ) Math.ceil( penetration / 20.0f );
|
||||
if ( pos.entityHit instanceof EntityLivingBase )
|
||||
{
|
||||
EntityLivingBase el = (EntityLivingBase) pos.entityHit;
|
||||
EntityLivingBase el = ( EntityLivingBase ) pos.entityHit;
|
||||
penetration -= dmg;
|
||||
el.knockBack( p, 0, -direction.xCoord, -direction.zCoord );
|
||||
// el.knockBack( p, 0, vec3.xCoord,
|
||||
@@ -434,81 +440,63 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell()
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(ItemStack i)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory(ItemStack is)
|
||||
public IInventory getUpgradesInventory( ItemStack is )
|
||||
{
|
||||
return new CellUpgrades( is, 4 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is)
|
||||
public IInventory getConfigInventory( ItemStack is )
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(ItemStack is)
|
||||
public FuzzyMode getFuzzyMode( ItemStack is )
|
||||
{
|
||||
String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
|
||||
try
|
||||
{
|
||||
return FuzzyMode.valueOf( fz );
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch ( Throwable t )
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode)
|
||||
public void setFuzzyMode( ItemStack is, FuzzyMode fzMode )
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(ItemStack cellItem)
|
||||
public int getBytes( ItemStack cellItem )
|
||||
{
|
||||
return 512;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int BytePerType(ItemStack cell)
|
||||
public int BytePerType( ItemStack cell )
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(ItemStack cellItem)
|
||||
public int getTotalTypes( ItemStack cellItem )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition)
|
||||
public boolean isBlackListed( ItemStack cellItem, IAEItemStack requestedAddition )
|
||||
{
|
||||
float pen = AEApi.instance().registries().matterCannon().getPenetration( requestedAddition.getItemStack() );
|
||||
if ( pen > 0 )
|
||||
@@ -519,4 +507,22 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell( ItemStack i )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdleDrain()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -56,7 +58,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
||||
{
|
||||
public ToolPortableCell()
|
||||
{
|
||||
super( ToolPortableCell.class, null );
|
||||
super( ToolPortableCell.class, Optional.<String> absent() );
|
||||
setFeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) );
|
||||
maxStoredPower = AEConfig.instance.portableCellBattery;
|
||||
}
|
||||
@@ -128,6 +130,18 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory( ItemStack is )
|
||||
{
|
||||
@@ -154,24 +168,12 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedGroupName( Set<ItemStack> others, ItemStack is )
|
||||
{
|
||||
return GuiText.StorageCells.getUnlocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode( ItemStack is, FuzzyMode fzMode )
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject( ItemStack is, World w, int x, int y, int z )
|
||||
{
|
||||
|
||||
@@ -18,14 +18,18 @@
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
@@ -41,24 +45,26 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
|
||||
{
|
||||
|
||||
public ToolWirelessTerminal() {
|
||||
super( ToolWirelessTerminal.class, null );
|
||||
public ToolWirelessTerminal()
|
||||
{
|
||||
super( ToolWirelessTerminal.class, Optional.<String> absent() );
|
||||
setFeature( EnumSet.of( AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools ) );
|
||||
maxStoredPower = AEConfig.instance.wirelessTerminalBattery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack item, World w, EntityPlayer player)
|
||||
public ItemStack onItemRightClick( ItemStack item, World w, EntityPlayer player )
|
||||
{
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui( item, w, player );
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
@@ -80,45 +86,30 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack is)
|
||||
public boolean canHandle( ItemStack is )
|
||||
{
|
||||
return AEApi.instance().items().itemWirelessTerminal.sameAsStack( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usePower(EntityPlayer player, double amount, ItemStack is)
|
||||
public boolean usePower( EntityPlayer player, double amount, ItemStack is )
|
||||
{
|
||||
return this.extractAEPower( is, amount ) >= amount - 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPower(EntityPlayer player, double amt, ItemStack is)
|
||||
public boolean hasPower( EntityPlayer player, double amt, ItemStack is )
|
||||
{
|
||||
return getAECurrentPower( is ) >= amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptionKey(ItemStack item)
|
||||
public IConfigManager getConfigManager( final ItemStack target )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( item );
|
||||
return tag.getString( "encryptionKey" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionKey(ItemStack item, String encKey, String name)
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( item );
|
||||
tag.setString( "encryptionKey", encKey );
|
||||
tag.setString( "name", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager(final ItemStack target)
|
||||
{
|
||||
final ConfigManager out = new ConfigManager( new IConfigManagerHost() {
|
||||
final ConfigManager out = new ConfigManager( new IConfigManagerHost(){
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( target );
|
||||
manager.writeToNBT( data );
|
||||
@@ -130,8 +121,23 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
|
||||
out.readFromNBT( (NBTTagCompound) Platform.openNbtData( target ).copy() );
|
||||
out.readFromNBT( ( NBTTagCompound ) Platform.openNbtData( target ).copy() );
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptionKey( ItemStack item )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( item );
|
||||
return tag.getString( "encryptionKey" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionKey( ItemStack item, String encKey, String name )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( item );
|
||||
tag.setString( "encryptionKey", encKey );
|
||||
tag.setString( "name", name );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,11 +18,17 @@
|
||||
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class AEBasePoweredItem extends RedstoneFlux
|
||||
{
|
||||
|
||||
public AEBasePoweredItem(Class c, String subName) {
|
||||
public AEBasePoweredItem( Class c, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
setMaxStackSize( 1 );
|
||||
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,18 @@
|
||||
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
@@ -33,24 +37,22 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
{
|
||||
|
||||
private enum batteryOperation
|
||||
{
|
||||
STORAGE, INJECT, EXTRACT
|
||||
}
|
||||
|
||||
final String EnergyVar = "internalCurrentPower";
|
||||
public double maxStoredPower = 200000;
|
||||
|
||||
public AERootPoweredItem(Class c, String subName) {
|
||||
public AERootPoweredItem( Class c, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
setMaxDamage( 32 );
|
||||
hasSubtypes = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
double internalCurrentPower = 0;
|
||||
@@ -75,9 +77,15 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamaged(ItemStack stack)
|
||||
public void getSubItems( Item id, CreativeTabs tab, List list )
|
||||
{
|
||||
return true;
|
||||
super.getSubItems( id, tab, list );
|
||||
|
||||
ItemStack charged = new ItemStack( this, 1 );
|
||||
NBTTagCompound tag = Platform.openNbtData( charged );
|
||||
tag.setDouble( "internalCurrentPower", getAEMaxPower( charged ) );
|
||||
tag.setDouble( "internalMaxPower", getAEMaxPower( charged ) );
|
||||
list.add( charged );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,56 +95,31 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDamage(ItemStack stack, int damage)
|
||||
public double getDurabilityForDisplay( ItemStack is )
|
||||
{
|
||||
|
||||
return 1 - getAECurrentPower( is ) / getAEMaxPower( is );
|
||||
}
|
||||
|
||||
final String EnergyVar = "internalCurrentPower";
|
||||
|
||||
private double getInternalBattery(ItemStack is, batteryOperation op, double adjustment)
|
||||
@Override
|
||||
public boolean isDamaged( ItemStack stack )
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( is );
|
||||
return true;
|
||||
}
|
||||
|
||||
double currentStorage = data.getDouble( EnergyVar );
|
||||
double maxStorage = getAEMaxPower( is );
|
||||
@Override
|
||||
public void setDamage( ItemStack stack, int damage )
|
||||
{
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case INJECT:
|
||||
currentStorage += adjustment;
|
||||
if ( currentStorage > maxStorage )
|
||||
{
|
||||
double diff = currentStorage - maxStorage;
|
||||
data.setDouble( EnergyVar, maxStorage );
|
||||
return diff;
|
||||
}
|
||||
data.setDouble( EnergyVar, currentStorage );
|
||||
return 0;
|
||||
case EXTRACT:
|
||||
if ( currentStorage > adjustment )
|
||||
{
|
||||
currentStorage -= adjustment;
|
||||
data.setDouble( EnergyVar, currentStorage );
|
||||
return adjustment;
|
||||
}
|
||||
data.setDouble( EnergyVar, 0 );
|
||||
return currentStorage;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return currentStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* inject external
|
||||
*/
|
||||
double injectExternalPower(PowerUnits input, ItemStack is, double amount, boolean simulate)
|
||||
double injectExternalPower( PowerUnits input, ItemStack is, double amount, boolean simulate )
|
||||
{
|
||||
if ( simulate )
|
||||
{
|
||||
int requiredEU = (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( is ) - getAECurrentPower( is ) );
|
||||
int requiredEU = ( int ) PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( is ) - getAECurrentPower( is ) );
|
||||
if ( amount < requiredEU )
|
||||
return 0;
|
||||
return amount - requiredEU;
|
||||
@@ -149,51 +132,73 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower(ItemStack is, double amt)
|
||||
public double injectAEPower( ItemStack is, double amt )
|
||||
{
|
||||
return getInternalBattery( is, batteryOperation.INJECT, amt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(ItemStack is, double amt)
|
||||
public double extractAEPower( ItemStack is, double amt )
|
||||
{
|
||||
return getInternalBattery( is, batteryOperation.EXTRACT, amt );
|
||||
}
|
||||
|
||||
private double getInternalBattery( ItemStack is, batteryOperation op, double adjustment )
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( is );
|
||||
|
||||
double currentStorage = data.getDouble( EnergyVar );
|
||||
double maxStorage = getAEMaxPower( is );
|
||||
|
||||
switch ( op )
|
||||
{
|
||||
case INJECT:
|
||||
currentStorage += adjustment;
|
||||
if ( currentStorage > maxStorage )
|
||||
{
|
||||
double diff = currentStorage - maxStorage;
|
||||
data.setDouble( EnergyVar, maxStorage );
|
||||
return diff;
|
||||
}
|
||||
data.setDouble( EnergyVar, currentStorage );
|
||||
return 0;
|
||||
case EXTRACT:
|
||||
if ( currentStorage > adjustment )
|
||||
{
|
||||
currentStorage -= adjustment;
|
||||
data.setDouble( EnergyVar, currentStorage );
|
||||
return adjustment;
|
||||
}
|
||||
data.setDouble( EnergyVar, 0 );
|
||||
return currentStorage;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return currentStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAEMaxPower(ItemStack is)
|
||||
public double getAEMaxPower( ItemStack is )
|
||||
{
|
||||
return maxStoredPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAECurrentPower(ItemStack is)
|
||||
public double getAECurrentPower( ItemStack is )
|
||||
{
|
||||
return getInternalBattery( is, batteryOperation.STORAGE, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getPowerFlow(ItemStack is)
|
||||
public AccessRestriction getPowerFlow( ItemStack is )
|
||||
{
|
||||
return AccessRestriction.WRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack is)
|
||||
private enum batteryOperation
|
||||
{
|
||||
return 1 - getAECurrentPower( is ) / getAEMaxPower( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
super.getSubItems( id, tab, list );
|
||||
|
||||
ItemStack charged = new ItemStack( this, 1 );
|
||||
NBTTagCompound tag = Platform.openNbtData( charged );
|
||||
tag.setDouble( "internalCurrentPower", getAEMaxPower( charged ) );
|
||||
tag.setDouble( "internalMaxPower", getAEMaxPower( charged ) );
|
||||
list.add( charged );
|
||||
STORAGE, INJECT, EXTRACT
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,27 +18,34 @@
|
||||
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
import ic2.api.item.IElectricItemManager;
|
||||
import ic2.api.item.ISpecialElectricItem;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import ic2.api.item.IElectricItemManager;
|
||||
import ic2.api.item.ISpecialElectricItem;
|
||||
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.transformer.annotations.integration.InterfaceList;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
|
||||
@InterfaceList(value = { @Interface(iface = "ic2.api.item.ISpecialElectricItem", iname = "IC2"),
|
||||
@Interface(iface = "ic2.api.item.IElectricItemManager", iname = "IC2") })
|
||||
|
||||
@InterfaceList( value = { @Interface( iface = "ic2.api.item.ISpecialElectricItem", iname = "IC2" ),
|
||||
@Interface( iface = "ic2.api.item.IElectricItemManager", iname = "IC2" ) } )
|
||||
public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem
|
||||
{
|
||||
|
||||
public IC2(Class c, String subName) {
|
||||
public IC2( Class c, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double charge(ItemStack is, double amount, int tier, boolean ignoreTransferLimit, boolean simulate)
|
||||
public double charge( ItemStack is, double amount, int tier, boolean ignoreTransferLimit, boolean simulate )
|
||||
{
|
||||
double addedAmt = amount;
|
||||
double limit = getTransferLimit( is );
|
||||
@@ -46,29 +53,29 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe
|
||||
if ( !ignoreTransferLimit && amount > limit )
|
||||
addedAmt = limit;
|
||||
|
||||
return addedAmt - ((int) injectExternalPower( PowerUnits.EU, is, addedAmt, simulate ));
|
||||
return addedAmt - ( ( int ) injectExternalPower( PowerUnits.EU, is, addedAmt, simulate ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double discharge(ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate)
|
||||
public double discharge( ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCharge(ItemStack is)
|
||||
public double getCharge( ItemStack is )
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAECurrentPower( is ) );
|
||||
return ( int ) PowerUnits.AE.convertTo( PowerUnits.EU, getAECurrentPower( is ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse(ItemStack is, double amount)
|
||||
public boolean canUse( ItemStack is, double amount )
|
||||
{
|
||||
return getCharge( is ) > amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean use(ItemStack is, double amount, EntityLivingBase entity)
|
||||
public boolean use( ItemStack is, double amount, EntityLivingBase entity )
|
||||
{
|
||||
if ( canUse( is, amount ) )
|
||||
{
|
||||
@@ -80,56 +87,56 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity)
|
||||
public void chargeFromArmor( ItemStack itemStack, EntityLivingBase entity )
|
||||
{
|
||||
// wtf?
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTip(ItemStack itemStack)
|
||||
public String getToolTip( ItemStack itemStack )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(ItemStack itemStack)
|
||||
public boolean canProvideEnergy( ItemStack itemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getChargedItem(ItemStack itemStack)
|
||||
public Item getChargedItem( ItemStack itemStack )
|
||||
{
|
||||
return itemStack.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getEmptyItem(ItemStack itemStack)
|
||||
public Item getEmptyItem( ItemStack itemStack )
|
||||
{
|
||||
return itemStack.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxCharge(ItemStack itemStack)
|
||||
public double getMaxCharge( ItemStack itemStack )
|
||||
{
|
||||
return PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTier(ItemStack itemStack)
|
||||
public int getTier( ItemStack itemStack )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTransferLimit(ItemStack itemStack)
|
||||
public double getTransferLimit( ItemStack itemStack )
|
||||
{
|
||||
return Math.max( 32, getMaxCharge( itemStack ) / 200 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(iname = "IC2")
|
||||
public IElectricItemManager getManager(ItemStack itemStack)
|
||||
@Method( iname = "IC2" )
|
||||
public IElectricItemManager getManager( ItemStack itemStack )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -18,41 +18,48 @@
|
||||
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
|
||||
@Interface(iface = "cofh.api.energy.IEnergyContainerItem", iname = "RFItem")
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
|
||||
|
||||
@Interface( iface = "cofh.api.energy.IEnergyContainerItem", iname = "RFItem" )
|
||||
public class RedstoneFlux extends IC2 implements IEnergyContainerItem
|
||||
{
|
||||
|
||||
public RedstoneFlux(Class c, String subName) {
|
||||
public RedstoneFlux( Class c, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack is, int maxReceive, boolean simulate)
|
||||
public int receiveEnergy( ItemStack is, int maxReceive, boolean simulate )
|
||||
{
|
||||
return maxReceive - (int) injectExternalPower( PowerUnits.RF, is, maxReceive, simulate );
|
||||
return maxReceive - ( int ) injectExternalPower( PowerUnits.RF, is, maxReceive, simulate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate)
|
||||
public int extractEnergy( ItemStack container, int maxExtract, boolean simulate )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack is)
|
||||
public int getEnergyStored( ItemStack is )
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, getAECurrentPower( is ) );
|
||||
return ( int ) PowerUnits.AE.convertTo( PowerUnits.RF, getAECurrentPower( is ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack is)
|
||||
public int getMaxEnergyStored( ItemStack is )
|
||||
{
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, getAEMaxPower( is ) );
|
||||
return ( int ) PowerUnits.AE.convertTo( PowerUnits.RF, getAEMaxPower( is ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,36 +18,36 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.ItemFeatureHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolQuartzAxe extends ItemAxe implements IAEFeature
|
||||
{
|
||||
private final AEFeature type;
|
||||
private final IFeatureHandler feature;
|
||||
|
||||
final AEFeature type;
|
||||
final AEFeatureHandler feature;
|
||||
|
||||
@Override
|
||||
public AEFeatureHandler feature()
|
||||
public ToolQuartzAxe( AEFeature Type )
|
||||
{
|
||||
return feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack a, ItemStack b)
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
|
||||
public ToolQuartzAxe(AEFeature Type) {
|
||||
super( ToolMaterial.IRON );
|
||||
feature = new AEFeatureHandler( EnumSet.of( type = Type, AEFeature.QuartzAxe ), this, Type.name() );
|
||||
this.feature = new ItemFeatureHandler( EnumSet.of( type = Type, AEFeature.QuartzAxe ), this, this, Optional.of( Type.name() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFeatureHandler handler()
|
||||
{
|
||||
return this.feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,4 +55,10 @@ public class ToolQuartzAxe extends ItemAxe implements IAEFeature
|
||||
{
|
||||
// override!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( ItemStack a, ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,16 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.core.features.AEFeature;
|
||||
@@ -32,20 +36,46 @@ import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
|
||||
{
|
||||
|
||||
final AEFeature type;
|
||||
|
||||
public ToolQuartzCuttingKnife(AEFeature Type) {
|
||||
super( ToolQuartzCuttingKnife.class, Type.name() );
|
||||
public ToolQuartzCuttingKnife( AEFeature Type )
|
||||
{
|
||||
super( ToolQuartzCuttingKnife.class, Optional.of( Type.name() ) );
|
||||
|
||||
setFeature( EnumSet.of( type = Type, AEFeature.QuartzKnife ) );
|
||||
setMaxDamage( 50 );
|
||||
setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack a, ItemStack b)
|
||||
public boolean onItemUse( ItemStack is, EntityPlayer p, World w, int x, int y, int z, int s, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_QUARTZ_KNIFE );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick( ItemStack it, World w, EntityPlayer p )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_QUARTZ_KNIFE );
|
||||
p.swingItem();
|
||||
return it;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesContainerItemLeaveCraftingGrid( ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( ItemStack a, ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
@@ -57,43 +87,20 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack it, World w, EntityPlayer p)
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_QUARTZ_KNIFE );
|
||||
p.swingItem();
|
||||
return it;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack is, EntityPlayer p, World w, int x, int y, int z, int s, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_QUARTZ_KNIFE );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
public ItemStack getContainerItem( ItemStack itemStack )
|
||||
{
|
||||
itemStack.setItemDamage( itemStack.getItemDamage() + 1 );
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, int x, int y, int z)
|
||||
public boolean hasContainerItem( ItemStack stack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject( ItemStack is, World world, int x, int y, int z )
|
||||
{
|
||||
return new QuartzKnifeObj( is );
|
||||
}
|
||||
|
||||
@@ -18,36 +18,38 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.ItemFeatureHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolQuartzHoe extends ItemHoe implements IAEFeature
|
||||
{
|
||||
private final AEFeature feature;
|
||||
private final IFeatureHandler handler;
|
||||
|
||||
final AEFeature type;
|
||||
final AEFeatureHandler feature;
|
||||
|
||||
@Override
|
||||
public AEFeatureHandler feature()
|
||||
public ToolQuartzHoe( AEFeature feature )
|
||||
{
|
||||
return feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack a, ItemStack b)
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
|
||||
public ToolQuartzHoe(AEFeature Type) {
|
||||
super( ToolMaterial.IRON );
|
||||
feature = new AEFeatureHandler( EnumSet.of( type = Type, AEFeature.QuartzHoe ), this, Type.name() );
|
||||
|
||||
this.feature = feature;
|
||||
this.handler = new ItemFeatureHandler( EnumSet.of( feature, AEFeature.QuartzHoe ), this, this, Optional.of( feature.name() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFeatureHandler handler()
|
||||
{
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,4 +57,10 @@ public class ToolQuartzHoe extends ItemHoe implements IAEFeature
|
||||
{
|
||||
// override!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( ItemStack a, ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( feature, a, b );
|
||||
}
|
||||
}
|
||||
@@ -18,36 +18,38 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.ItemFeatureHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolQuartzPickaxe extends ItemPickaxe implements IAEFeature
|
||||
{
|
||||
private final AEFeature type;
|
||||
private final IFeatureHandler feature;
|
||||
|
||||
final AEFeature type;
|
||||
final AEFeatureHandler feature;
|
||||
|
||||
@Override
|
||||
public AEFeatureHandler feature()
|
||||
public ToolQuartzPickaxe( AEFeature Type )
|
||||
{
|
||||
return feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack a, ItemStack b)
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
|
||||
public ToolQuartzPickaxe(AEFeature Type) {
|
||||
super( ToolMaterial.IRON );
|
||||
feature = new AEFeatureHandler( EnumSet.of( type = Type, AEFeature.QuartzPickaxe ), this, Type.name() );
|
||||
|
||||
this.type = Type;
|
||||
this.feature = new ItemFeatureHandler( EnumSet.of( Type, AEFeature.QuartzPickaxe ), this, this, Optional.of( Type.name() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFeatureHandler handler()
|
||||
{
|
||||
return this.feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,4 +57,10 @@ public class ToolQuartzPickaxe extends ItemPickaxe implements IAEFeature
|
||||
{
|
||||
// override!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( ItemStack a, ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,36 +18,37 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.ItemFeatureHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolQuartzSpade extends ItemSpade implements IAEFeature
|
||||
{
|
||||
private final AEFeature type;
|
||||
private final IFeatureHandler handler;
|
||||
|
||||
final AEFeature type;
|
||||
final AEFeatureHandler feature;
|
||||
|
||||
@Override
|
||||
public AEFeatureHandler feature()
|
||||
public ToolQuartzSpade( AEFeature Type )
|
||||
{
|
||||
return feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack a, ItemStack b)
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
|
||||
public ToolQuartzSpade(AEFeature Type) {
|
||||
super( ToolMaterial.IRON );
|
||||
feature = new AEFeatureHandler( EnumSet.of( type = Type, AEFeature.QuartzSpade ), this, Type.name() );
|
||||
|
||||
this.handler = new ItemFeatureHandler( EnumSet.of( type = Type, AEFeature.QuartzSpade ), this, this, Optional.of( Type.name() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFeatureHandler handler()
|
||||
{
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,4 +56,10 @@ public class ToolQuartzSpade extends ItemSpade implements IAEFeature
|
||||
{
|
||||
// override!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( ItemStack a, ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,41 +18,47 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.ItemFeatureHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolQuartzSword extends ItemSword implements IAEFeature
|
||||
{
|
||||
private final AEFeature type;
|
||||
private final IFeatureHandler feature;
|
||||
|
||||
final AEFeature type;
|
||||
final AEFeatureHandler feature;
|
||||
public ToolQuartzSword( AEFeature Type )
|
||||
{
|
||||
super( ToolMaterial.IRON );
|
||||
feature = new ItemFeatureHandler( EnumSet.of( type = Type, AEFeature.QuartzSword ), this, this, Optional.of( Type.name() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEFeatureHandler feature()
|
||||
public IFeatureHandler handler()
|
||||
{
|
||||
return feature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack a, ItemStack b)
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
|
||||
public ToolQuartzSword(AEFeature Type) {
|
||||
super( ToolMaterial.IRON );
|
||||
feature = new AEFeatureHandler( EnumSet.of( type = Type, AEFeature.QuartzSword ), this, Type.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
// override!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable( ItemStack a, ItemStack b )
|
||||
{
|
||||
return Platform.canRepair( type, a, b );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,27 +18,34 @@
|
||||
|
||||
package appeng.items.tools.quartz;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
@Interface(iface = "buildcraft.api.tools.IToolWrench", iname = "BC")
|
||||
|
||||
@Interface( iface = "buildcraft.api.tools.IToolWrench", iname = "BC" )
|
||||
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWrench
|
||||
{
|
||||
|
||||
public ToolQuartzWrench(AEFeature type) {
|
||||
super( ToolQuartzWrench.class, type.name() );
|
||||
public ToolQuartzWrench( AEFeature type )
|
||||
{
|
||||
super( ToolQuartzWrench.class, Optional.of( type.name() ) );
|
||||
|
||||
this.setFeature( EnumSet.of( type, AEFeature.QuartzWrench ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
@@ -46,7 +53,7 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
public boolean onItemUseFirst( ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
Block b = world.getBlock( x, y, z );
|
||||
if ( b != null && !player.isSneaking() && Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) )
|
||||
@@ -67,25 +74,25 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren
|
||||
|
||||
@Override
|
||||
// public boolean shouldPassSneakingClickToBlock(World w, int x, int y, int z)
|
||||
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player)
|
||||
public boolean doesSneakBypassUse( World world, int x, int y, int z, EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(ItemStack is, EntityPlayer player, int x, int y, int z)
|
||||
public boolean canWrench( ItemStack is, EntityPlayer player, int x, int y, int z )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(EntityPlayer player, int x, int y, int z)
|
||||
public boolean canWrench( EntityPlayer player, int x, int y, int z )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wrenchUsed(EntityPlayer player, int x, int y, int z)
|
||||
public void wrenchUsed( EntityPlayer player, int x, int y, int z )
|
||||
{
|
||||
player.swingItem();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.util;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
public class ClassInstantiation<T>
|
||||
{
|
||||
private final Class<? extends T> template;
|
||||
private final Object[] args;
|
||||
|
||||
public ClassInstantiation( Class<? extends T> template, Object... args )
|
||||
{
|
||||
this.template = template;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public Optional<T> get()
|
||||
{
|
||||
@SuppressWarnings( "unchecked" )
|
||||
Constructor<T>[] constructors = ( Constructor<T>[] ) this.template.getConstructors();
|
||||
|
||||
for ( Constructor<T> constructor : constructors )
|
||||
{
|
||||
Class<?>[] paramTypes = constructor.getParameterTypes();
|
||||
if ( paramTypes.length == args.length )
|
||||
{
|
||||
boolean valid = true;
|
||||
|
||||
for ( int idx = 0; idx < paramTypes.length; idx++ )
|
||||
{
|
||||
Class<?> cz = args[idx].getClass();
|
||||
if ( !isClassMatch( paramTypes[idx], cz, args[idx] ) )
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if ( valid )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Optional.of( constructor.newInstance( args ) );
|
||||
}
|
||||
catch ( InstantiationException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch ( IllegalAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch ( InvocationTargetException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
private boolean isClassMatch( Class<?> expected, Class<?> got, Object value )
|
||||
{
|
||||
if ( value == null && !expected.isPrimitive() )
|
||||
return true;
|
||||
|
||||
expected = condense( expected, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class );
|
||||
got = condense( got, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class );
|
||||
|
||||
return expected == got || expected.isAssignableFrom( got );
|
||||
}
|
||||
|
||||
private Class<?> condense( Class<?> expected, Class<?>... wrappers )
|
||||
{
|
||||
if ( expected.isPrimitive() )
|
||||
{
|
||||
for ( Class clz : wrappers )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( expected == clz.getField( "TYPE" ).get( null ) )
|
||||
return clz;
|
||||
}
|
||||
catch ( Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
return expected;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user