Alloy furnace - Preserve custom name when removed
... And that should be all for the fucking alloy furnace. Nice (if true).
This commit is contained in:
parent
63e3c2dbc3
commit
fa79a85fd9
5 changed files with 66 additions and 6 deletions
2
TODO.txt
2
TODO.txt
|
@ -43,8 +43,6 @@ materials.ores No Rock salt
|
||||||
materials.ores No Tin
|
materials.ores No Tin
|
||||||
materials.ores No Zinc
|
materials.ores No Zinc
|
||||||
-------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------
|
||||||
tech.base No Alloy furnace
|
|
||||||
-> check item behaviour
|
|
||||||
tech.base No Coke oven
|
tech.base No Coke oven
|
||||||
-------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------
|
||||||
animals ??? Goats
|
animals ??? Goats
|
||||||
|
|
|
@ -5,7 +5,7 @@ import mmm.utils.UNetwork;
|
||||||
import mmm.utils.URegistry;
|
import mmm.utils.URegistry;
|
||||||
import mmm.utils.gui.GUIUtils;
|
import mmm.utils.gui.GUIUtils;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlockSpecial;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public enum AlloyFurnace {
|
||||||
this.INACTIVE = new TBAFBlock( false );
|
this.INACTIVE = new TBAFBlock( false );
|
||||||
this.ACTIVE = new TBAFBlock( true );
|
this.ACTIVE = new TBAFBlock( true );
|
||||||
|
|
||||||
this.ITEM = new ItemBlockSpecial( this.INACTIVE )//
|
this.ITEM = new ItemBlock( this.INACTIVE )//
|
||||||
.setMaxStackSize( 16 )//
|
.setMaxStackSize( 16 )//
|
||||||
.setCreativeTab( this.INACTIVE.getCreativeTabToDisplayOn( ) );
|
.setCreativeTab( this.INACTIVE.getCreativeTabToDisplayOn( ) );
|
||||||
URegistry.setIdentifiers( this.ITEM , "tech" , "base" , "alloy_furnace" );
|
URegistry.setIdentifiers( this.ITEM , "tech" , "base" , "alloy_furnace" );
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package mmm.tech.base.alloy_furnace;
|
package mmm.tech.base.alloy_furnace;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -267,6 +268,14 @@ public class TBAFBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List< ItemStack > getDrops( final IBlockAccess world , final BlockPos pos , final IBlockState state ,
|
||||||
|
final int fortune )
|
||||||
|
{
|
||||||
|
return new ArrayList< ItemStack >( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
// DIRECTION
|
// DIRECTION
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
|
@ -304,6 +313,23 @@ public class TBAFBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy( final World worldIn , final BlockPos pos , final IBlockState state ,
|
||||||
|
final EntityLivingBase placer , final ItemStack stack )
|
||||||
|
{
|
||||||
|
worldIn.setBlockState( pos , state.withProperty( //
|
||||||
|
TBAFBlock.FACING , placer.getHorizontalFacing( ).getOpposite( ) ) , 2 );
|
||||||
|
|
||||||
|
if ( stack.hasDisplayName( ) ) {
|
||||||
|
System.err.println( "HAZ A NAME!" );
|
||||||
|
final TileEntity tileentity = worldIn.getTileEntity( pos );
|
||||||
|
if ( tileentity instanceof TBAFTileEntity ) {
|
||||||
|
( (TBAFTileEntity) tileentity ).setCustomName( stack.getDisplayName( ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState onBlockPlaced( final World worldIn , final BlockPos pos , final EnumFacing facing ,
|
public IBlockState onBlockPlaced( final World worldIn , final BlockPos pos , final EnumFacing facing ,
|
||||||
final float hitX , final float hitY , final float hitZ , final int meta , final EntityLivingBase placer )
|
final float hitX , final float hitY , final float hitZ , final int meta , final EntityLivingBase placer )
|
||||||
|
@ -368,6 +394,12 @@ public class TBAFBlock
|
||||||
InventoryHelper.dropInventoryItems( worldIn , pos , afte.input );
|
InventoryHelper.dropInventoryItems( worldIn , pos , afte.input );
|
||||||
InventoryHelper.dropInventoryItems( worldIn , pos , afte.fuel );
|
InventoryHelper.dropInventoryItems( worldIn , pos , afte.fuel );
|
||||||
InventoryHelper.dropInventoryItems( worldIn , pos , afte.output );
|
InventoryHelper.dropInventoryItems( worldIn , pos , afte.output );
|
||||||
|
|
||||||
|
final ItemStack stack = new ItemStack( AlloyFurnace.INSTANCE.ITEM , 1 );
|
||||||
|
if ( afte.hasCustomName( ) ) {
|
||||||
|
stack.setStackDisplayName( afte.getName( ) );
|
||||||
|
}
|
||||||
|
InventoryHelper.spawnItemStack( worldIn , pos.getX( ) , pos.getY( ) , pos.getZ( ) , stack );
|
||||||
}
|
}
|
||||||
worldIn.updateComparatorOutputLevel( pos , this );
|
worldIn.updateComparatorOutputLevel( pos , this );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.util.ITickable;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.IWorldNameable;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.Constants.NBT;
|
import net.minecraftforge.common.util.Constants.NBT;
|
||||||
|
@ -30,7 +31,7 @@ import net.minecraftforge.items.wrapper.InvWrapper;
|
||||||
|
|
||||||
public class TBAFTileEntity
|
public class TBAFTileEntity
|
||||||
extends TileEntity
|
extends TileEntity
|
||||||
implements ITickable , I_TBConfigurableActivation
|
implements ITickable , I_TBConfigurableActivation , IWorldNameable
|
||||||
{
|
{
|
||||||
/** Input hopper allows invalid input? */
|
/** Input hopper allows invalid input? */
|
||||||
public static final int F_IH_INVALID = 1 << 0;
|
public static final int F_IH_INVALID = 1 << 0;
|
||||||
|
@ -91,6 +92,8 @@ public class TBAFTileEntity
|
||||||
public final UInventoryGrid fuel;
|
public final UInventoryGrid fuel;
|
||||||
public final UInventoryGrid output;
|
public final UInventoryGrid output;
|
||||||
|
|
||||||
|
private String customName;
|
||||||
|
|
||||||
public MAlloyRecipe recipe;
|
public MAlloyRecipe recipe;
|
||||||
|
|
||||||
private MAlloyRecipe alloying;
|
private MAlloyRecipe alloying;
|
||||||
|
@ -122,6 +125,26 @@ public class TBAFTileEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName( )
|
||||||
|
{
|
||||||
|
return this.hasCustomName( ) ? this.customName : "tile.mmm.tech.base.alloy_furnace.inactive.name";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomName( )
|
||||||
|
{
|
||||||
|
return this.customName != null && !this.customName.isEmpty( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setCustomName( final String name )
|
||||||
|
{
|
||||||
|
this.customName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRefresh( final World world , final BlockPos pos , final IBlockState oldState ,
|
public boolean shouldRefresh( final World world , final BlockPos pos , final IBlockState oldState ,
|
||||||
final IBlockState newSate )
|
final IBlockState newSate )
|
||||||
|
@ -134,6 +157,9 @@ public class TBAFTileEntity
|
||||||
public void readFromNBT( final NBTTagCompound compound )
|
public void readFromNBT( final NBTTagCompound compound )
|
||||||
{
|
{
|
||||||
super.readFromNBT( compound );
|
super.readFromNBT( compound );
|
||||||
|
if ( compound.hasKey( "CustomName" , 8 ) ) {
|
||||||
|
this.customName = compound.getString( "CustomName" );
|
||||||
|
}
|
||||||
this.input.deserializeNBT( compound.getTagList( "Input" , NBT.TAG_COMPOUND ) );
|
this.input.deserializeNBT( compound.getTagList( "Input" , NBT.TAG_COMPOUND ) );
|
||||||
this.fuel.deserializeNBT( compound.getTagList( "Fuel" , NBT.TAG_COMPOUND ) );
|
this.fuel.deserializeNBT( compound.getTagList( "Fuel" , NBT.TAG_COMPOUND ) );
|
||||||
this.output.deserializeNBT( compound.getTagList( "Output" , NBT.TAG_COMPOUND ) );
|
this.output.deserializeNBT( compound.getTagList( "Output" , NBT.TAG_COMPOUND ) );
|
||||||
|
@ -145,6 +171,9 @@ public class TBAFTileEntity
|
||||||
public NBTTagCompound writeToNBT( final NBTTagCompound compound )
|
public NBTTagCompound writeToNBT( final NBTTagCompound compound )
|
||||||
{
|
{
|
||||||
super.writeToNBT( compound );
|
super.writeToNBT( compound );
|
||||||
|
if ( this.hasCustomName( ) ) {
|
||||||
|
compound.setString( "CustomName" , this.customName );
|
||||||
|
}
|
||||||
compound.setTag( "Input" , this.input.serializeNBT( ) );
|
compound.setTag( "Input" , this.input.serializeNBT( ) );
|
||||||
compound.setTag( "Fuel" , this.fuel.serializeNBT( ) );
|
compound.setTag( "Fuel" , this.fuel.serializeNBT( ) );
|
||||||
compound.setTag( "Output" , this.output.serializeNBT( ) );
|
compound.setTag( "Output" , this.output.serializeNBT( ) );
|
||||||
|
@ -650,4 +679,5 @@ public class TBAFTileEntity
|
||||||
final float ratio = total / ( 15.0f * nValues );
|
final float ratio = total / ( 15.0f * nValues );
|
||||||
return MathHelper.floor_float( ratio * 14.0f ) + ( total == 0 ? 0 : 1 );
|
return MathHelper.floor_float( ratio * 14.0f ) + ( total == 0 ? 0 : 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ gui.mmm.tech.base.am.powered=Redstone Activates
|
||||||
gui.mmm.tech.base.am.unpowered=Redstone Disables
|
gui.mmm.tech.base.am.unpowered=Redstone Disables
|
||||||
gui.mmm.tech.base.am.disabled=Deactivated
|
gui.mmm.tech.base.am.disabled=Deactivated
|
||||||
|
|
||||||
item.mmm.tech.base.alloy_furnace.name=Alloy Furnace
|
tile.mmm.tech.base.alloy_furnace.inactive.name=Alloy Furnace
|
||||||
container.mmm.alloy_furnace.contents=Furnace Contents
|
container.mmm.alloy_furnace.contents=Furnace Contents
|
||||||
container.mmm.alloy_furnace.recipe=Alloy Selection
|
container.mmm.alloy_furnace.recipe=Alloy Selection
|
||||||
container.mmm.alloy_furnace.select=Select Alloy
|
container.mmm.alloy_furnace.select=Select Alloy
|
||||||
|
|
Reference in a new issue