diff --git a/ChangeLog.txt b/ChangeLog.txt index 0b91b11c..dadf4869 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,9 @@ -1/13/2015 0.8.8.4b-rv2 +1/15/2015 0.8.9.0b-rv2 + Fixes #122: Assembler will now connect to a network with a security terminal. + Fixes #123: Added wrench focus. + Began work on Essentia vibration chamber. + +1/13/2015 0.8.8.4b-rv2 Added forge version information to dependencies. Clarified permission API. Fixes #117: Added config option for gearbox models. diff --git a/build.gradle b/build.gradle index 2430566f..1cab4559 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "0.8.8.4b-rv2" +version = "0.8.9.0b-rv2" group= "thaumicenergistics" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "thaumicenergistics" diff --git a/src/main/java/thaumicenergistics/ThaumicEnergistics.java b/src/main/java/thaumicenergistics/ThaumicEnergistics.java index 31ca429d..ca7d845b 100644 --- a/src/main/java/thaumicenergistics/ThaumicEnergistics.java +++ b/src/main/java/thaumicenergistics/ThaumicEnergistics.java @@ -33,7 +33,7 @@ public class ThaumicEnergistics /** * Current version of the mod. */ - public static final String VERSION = "0.8.8.4b-rv2"; // Note: don't forget to change the build.gradle file as well + public static final String VERSION = "0.8.9.0b-rv2"; // Note: don't forget to change the build.gradle file as well /** * Singleton instance @@ -155,4 +155,8 @@ public class ThaumicEnergistics ThELog.endSection( "PreInit", startTime ); } + // TODO: Sync server configs + // TODO: Knowledge Inscriber GUI, add particles like focal manipulator + // TODO: Use area packets over tile sync when possible + } diff --git a/src/main/java/thaumicenergistics/api/Blocks.java b/src/main/java/thaumicenergistics/api/Blocks.java index 5b96fc1c..3a886dcd 100644 --- a/src/main/java/thaumicenergistics/api/Blocks.java +++ b/src/main/java/thaumicenergistics/api/Blocks.java @@ -15,4 +15,6 @@ public abstract class Blocks public IItemDescription ArcaneAssembler; public IItemDescription KnowledgeInscriber; + + public IItemDescription EssentiaVibrationChamber; } diff --git a/src/main/java/thaumicenergistics/blocks/AbstractBlockAEWrenchable.java b/src/main/java/thaumicenergistics/blocks/AbstractBlockAEWrenchable.java index 51999f86..b1a3f312 100644 --- a/src/main/java/thaumicenergistics/blocks/AbstractBlockAEWrenchable.java +++ b/src/main/java/thaumicenergistics/blocks/AbstractBlockAEWrenchable.java @@ -5,6 +5,7 @@ import net.minecraft.block.material.Material; 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.items.IAEWrench; public abstract class AbstractBlockAEWrenchable @@ -105,7 +106,8 @@ public abstract class AbstractBlockAEWrenchable } // Let the subclass handle the event - return this.onWrenched( world, x, y, z, side ); + //return this.onWrenched( world, x, y, z, side ); + return true; } } @@ -113,4 +115,10 @@ public abstract class AbstractBlockAEWrenchable } + @Override + public boolean rotateBlock( final World world, final int x, final int y, final int z, final ForgeDirection side ) + { + return this.onWrenched( world, x, y, z, side.ordinal() ); + } + } diff --git a/src/main/java/thaumicenergistics/blocks/BlockArcaneAssembler.java b/src/main/java/thaumicenergistics/blocks/BlockArcaneAssembler.java index 1b6bb98e..cf85b5d2 100644 --- a/src/main/java/thaumicenergistics/blocks/BlockArcaneAssembler.java +++ b/src/main/java/thaumicenergistics/blocks/BlockArcaneAssembler.java @@ -111,13 +111,9 @@ public class BlockArcaneAssembler * Creates a new Arcane Assembler tile */ @Override - public TileEntity createNewTileEntity( final World p_149915_1_, final int p_149915_2_ ) + public TileEntity createNewTileEntity( final World world, final int metadata ) { - TileArcaneAssembler assembler = new TileArcaneAssembler(); - - assembler.setupAssemblerTile(); - - return assembler; + return new TileArcaneAssembler().setupAssemblerTile(); } /** @@ -192,12 +188,21 @@ public class BlockArcaneAssembler public void onBlockPlacedBy( final World world, final int x, final int y, final int z, final EntityLivingBase player, final ItemStack itemStack ) { // Get the tile - TileArcaneAssembler tile = (TileArcaneAssembler)world.getTileEntity( x, y, z ); + TileArcaneAssembler assembler = (TileArcaneAssembler)world.getTileEntity( x, y, z ); - if( ( tile != null ) && ( itemStack.getTagCompound() != null ) ) + if( assembler != null ) { - // Load the saved data - tile.onLoadNBT( itemStack.getTagCompound() ); + if( itemStack.getTagCompound() != null ) + { + // Load the saved data + assembler.onLoadNBT( itemStack.getTagCompound() ); + } + + if( player instanceof EntityPlayer ) + { + // Set the owner + assembler.setOwner( (EntityPlayer)player ); + } } } diff --git a/src/main/java/thaumicenergistics/blocks/BlockEssentiaVibrationChamber.java b/src/main/java/thaumicenergistics/blocks/BlockEssentiaVibrationChamber.java new file mode 100644 index 00000000..021cda0e --- /dev/null +++ b/src/main/java/thaumicenergistics/blocks/BlockEssentiaVibrationChamber.java @@ -0,0 +1,220 @@ +package thaumicenergistics.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import thaumicenergistics.ThaumicEnergistics; +import thaumicenergistics.registries.BlockEnum; +import thaumicenergistics.texture.BlockTextureManager; +import thaumicenergistics.tileentities.TileEssentiaVibrationChamber; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockEssentiaVibrationChamber + extends AbstractBlockAEWrenchable +{ + public static final int[] FACE_DIRS = new int[] { 2, 5, 3, 4 }; + + private static final int FLAG_ON = 8, BITS_SIDE = 7; + + public BlockEssentiaVibrationChamber() + { + // Call super with material machine (iron) + super( Material.iron ); + + // Basic hardness + this.setHardness( 1.0f ); + + // Sound of metal + this.setStepSound( Block.soundTypeMetal ); + + // Place in the ThE creative tab + this.setCreativeTab( ThaumicEnergistics.ThETab ); + } + + /** + * Gets the side that represents the face of the block. + * + * @param metaData + * @return + */ + public static final ForgeDirection getFaceSideFromMeta( final int metaData ) + { + int index = ( metaData & BlockEssentiaVibrationChamber.BITS_SIDE ) - 1; + + return ForgeDirection.VALID_DIRECTIONS[BlockEssentiaVibrationChamber.FACE_DIRS[index]]; + + } + + /** + * Sets the index of the side that should be the face. + * + * @param world + * @param x + * @param y + * @param z + * @param index + */ + public static final void setBlockFaceIndex( final World world, final int x, final int y, final int z, int index ) + { + // Ensure index bits are clean + index = index % BlockEssentiaVibrationChamber.FACE_DIRS.length; + + // Get the block meta data + int metaData = world.getBlockMetadata( x, y, z ); + + // Extract the on/off flag + int onFlag = metaData & BlockEssentiaVibrationChamber.FLAG_ON; + + // Combine + metaData = ( index + 1 ) | onFlag; + + // Set + world.setBlockMetadataWithNotify( x, y, z, metaData, 3 ); + } + + /** + * Sets the face texture to on or off. + * + * @param world + * @param x + * @param y + * @param z + * @param isOn + */ + public static final void setBlockOnState( final World world, final int x, final int y, final int z, final boolean isOn ) + { + // Get the block meta data, stripping the ON flags + int metaData = world.getBlockMetadata( x, y, z ) & BlockEssentiaVibrationChamber.BITS_SIDE; + + // Combine + if( isOn ) + { + metaData |= BlockEssentiaVibrationChamber.FLAG_ON; + } + + // Set + world.setBlockMetadataWithNotify( x, y, z, metaData, 2 ); + } + + @Override + protected boolean onWrenched( final World world, final int x, final int y, final int z, final int side ) + { + // Get and increment the meta data, striping ON flag + int index = ( world.getBlockMetadata( x, y, z ) & BlockEssentiaVibrationChamber.BITS_SIDE ); + + // Bounds check + if( index >= BlockEssentiaVibrationChamber.FACE_DIRS.length ) + { + index = 0; + } + + // Set + BlockEssentiaVibrationChamber.setBlockFaceIndex( world, x, y, z, index ); + + return true; + } + + @Override + public TileEntity createNewTileEntity( final World world, final int metaData ) + { + return new TileEssentiaVibrationChamber().setupChamberTile(); + } + + /** + * Gets the standard block icon. + */ + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon( final int side, final int meta ) + { + // Inventory icons + if( meta == 0 ) + { + if( side == 4 ) + { + // Face off + return BlockTextureManager.ESSENTIA_VIBRATION_CHAMBER.getTextures()[1]; + } + + // Sides + return BlockTextureManager.ESSENTIA_VIBRATION_CHAMBER.getTextures()[0]; + } + + int index = ( meta & BlockEssentiaVibrationChamber.BITS_SIDE ) - 1; + + // World icons + // Is face? + if( side == BlockEssentiaVibrationChamber.FACE_DIRS[index] ) + { + if( ( meta & BlockEssentiaVibrationChamber.FLAG_ON ) > 0 ) + { + // Face on + return BlockTextureManager.ESSENTIA_VIBRATION_CHAMBER.getTextures()[2]; + } + + // Face off + return BlockTextureManager.ESSENTIA_VIBRATION_CHAMBER.getTextures()[1]; + } + + // Sides + return BlockTextureManager.ESSENTIA_VIBRATION_CHAMBER.getTextures()[0]; + + } + + /** + * Gets the unlocalized name of the block. + */ + @Override + public String getUnlocalizedName() + { + return BlockEnum.ESSENTIA_VIBRATION_CHAMBER.getUnlocalizedName(); + } + + @Override + public void onBlockPlacedBy( final World world, final int x, final int y, final int z, final EntityLivingBase player, final ItemStack itemStack ) + { + // Get the tile + TileEssentiaVibrationChamber chamber = (TileEssentiaVibrationChamber)world.getTileEntity( x, y, z ); + + if( chamber != null ) + { + if( itemStack.getTagCompound() != null ) + { + //TODO: Load the saved data + //chamber.onLoadNBT( itemStack.getTagCompound() ); + } + + if( player instanceof EntityPlayer ) + { + // Set the owner + chamber.setOwner( (EntityPlayer)player ); + } + } + + // Get the index based on which direction the player is turned + int index = MathHelper.floor_double( ( player.rotationYaw * 4.0F / 360.0F ) + 0.5D ) & 3; + + // Set the meta data + world.setBlockMetadataWithNotify( x, y, z, ( index + 1 ), 2 ); + } + + /** + * Taken care of by texture manager + */ + @SideOnly(Side.CLIENT) + @Override + public final void registerBlockIcons( final IIconRegister register ) + { + // Ignored + } + +} diff --git a/src/main/java/thaumicenergistics/blocks/BlockKnowledgeInscriber.java b/src/main/java/thaumicenergistics/blocks/BlockKnowledgeInscriber.java index eb17dd60..58f194e5 100644 --- a/src/main/java/thaumicenergistics/blocks/BlockKnowledgeInscriber.java +++ b/src/main/java/thaumicenergistics/blocks/BlockKnowledgeInscriber.java @@ -152,7 +152,7 @@ public class BlockKnowledgeInscriber public void onBlockPlacedBy( final World world, final int x, final int y, final int z, final EntityLivingBase player, final ItemStack itemStack ) { // Set the metadata to up - world.setBlockMetadataWithNotify( x, y, z, 0, 3 ); + world.setBlockMetadataWithNotify( x, y, z, 0, 2 ); } /** diff --git a/src/main/java/thaumicenergistics/gui/GuiKnowledgeInscriber.java b/src/main/java/thaumicenergistics/gui/GuiKnowledgeInscriber.java index f4d5c70a..524f2ec4 100644 --- a/src/main/java/thaumicenergistics/gui/GuiKnowledgeInscriber.java +++ b/src/main/java/thaumicenergistics/gui/GuiKnowledgeInscriber.java @@ -12,6 +12,7 @@ import thaumicenergistics.container.ContainerKnowledgeInscriber.CoreSaveState; import thaumicenergistics.gui.abstraction.AbstractGuiBase; import thaumicenergistics.gui.buttons.ButtonSaveDelete; import thaumicenergistics.network.packet.server.PacketServerKnowledgeInscriber; +import thaumicenergistics.registries.ThEStrings; import thaumicenergistics.texture.GuiTextureManager; public class GuiKnowledgeInscriber @@ -64,8 +65,8 @@ public class GuiKnowledgeInscriber this.xSize = GuiKnowledgeInscriber.GUI_WIDTH; this.ySize = GuiKnowledgeInscriber.GUI_HEIGHT; - // TODO: Localize title - this.title = "Knowledge Inscriber"; + // Set title + this.title = ThEStrings.Block_KnowledgeInscriber.getLocalized(); } @Override diff --git a/src/main/java/thaumicenergistics/implementaion/ThEBlocks.java b/src/main/java/thaumicenergistics/implementaion/ThEBlocks.java index bfa4e31f..7ca0bdb9 100644 --- a/src/main/java/thaumicenergistics/implementaion/ThEBlocks.java +++ b/src/main/java/thaumicenergistics/implementaion/ThEBlocks.java @@ -15,5 +15,6 @@ class ThEBlocks this.EssentiaCellWorkbench = new ThEDescription( BlockEnum.ESSENTIA_CELL_WORKBENCH.getBlock() ); this.ArcaneAssembler = new ThEDescription( BlockEnum.ARCANE_ASSEMBLER.getBlock() ); this.KnowledgeInscriber = new ThEDescription( BlockEnum.KNOWLEDGE_INSCRIBER.getBlock() ); + this.EssentiaVibrationChamber = new ThEDescription( BlockEnum.ESSENTIA_VIBRATION_CHAMBER.getBlock() ); } } diff --git a/src/main/java/thaumicenergistics/integration/tc/EssentiaTransportHelper.java b/src/main/java/thaumicenergistics/integration/tc/EssentiaTransportHelper.java new file mode 100644 index 00000000..a2b4e23b --- /dev/null +++ b/src/main/java/thaumicenergistics/integration/tc/EssentiaTransportHelper.java @@ -0,0 +1,99 @@ +package thaumicenergistics.integration.tc; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.IEssentiaTransport; +import appeng.api.config.Actionable; + +public class EssentiaTransportHelper +{ + /** + * Instance. + */ + public static final EssentiaTransportHelper instance = new EssentiaTransportHelper(); + + /** + * Private constructor. + */ + private EssentiaTransportHelper() + { + // Intentionally Empty + } + + public void takeEssentiaFromTransportNeighbors( final IEssentiaTransportWithSimulate destination, final World world, final int x, final int y, + final int z ) + { + // Null checks + if( ( destination == null ) || ( world == null ) ) + { + return; + } + + // For each side + for( ForgeDirection destinationSide : ForgeDirection.VALID_DIRECTIONS ) + { + // Can the destination accept essentia from this side? + if( !destination.canInputFrom( destinationSide ) ) + { + // Destination can not accept essentia from this side + continue; + } + + // Get the source + TileEntity sourceTile = world.getTileEntity( destinationSide.offsetX + x, destinationSide.offsetY + y, destinationSide.offsetZ + z ); + + // Ensure the source is a transport + if( !( sourceTile instanceof IEssentiaTransport ) ) + { + // Invalid source + continue; + } + + // Cast + IEssentiaTransport source = (IEssentiaTransport)sourceTile; + + // Get the opposite direction + ForgeDirection sourceSide = destinationSide.getOpposite(); + + // Can the source output to this side? + if( !source.canOutputTo( sourceSide ) ) + { + // Source can not output to this side + continue; + } + + // Does the source have any essentia to give? + if( source.getEssentiaAmount( sourceSide ) <= 0 ) + { + // No essentia from this side + continue; + } + + // Does the destination have enough suction? + int dSuck = destination.getSuctionAmount( destinationSide ); + if( ( dSuck < source.getMinimumSuction() ) || ( dSuck < source.getSuctionAmount( sourceSide ) ) ) + { + // Destination does not have enough suction. + continue; + } + + // Get the source aspect + Aspect sourceAspect = source.getEssentiaType( sourceSide ); + if( sourceAspect == null ) + { + // Invalid aspect + continue; + } + + // Simulate an injection + if( destination.addEssentia( sourceAspect, 1, destinationSide, Actionable.SIMULATE ) == 1 ) + { + // Inject + destination.addEssentia( sourceAspect, source.takeEssentia( sourceAspect, 1, sourceSide ), destinationSide, Actionable.MODULATE ); + } + } + } + +} diff --git a/src/main/java/thaumicenergistics/integration/tc/IEssentiaTransportWithSimulate.java b/src/main/java/thaumicenergistics/integration/tc/IEssentiaTransportWithSimulate.java new file mode 100644 index 00000000..ceb32e9e --- /dev/null +++ b/src/main/java/thaumicenergistics/integration/tc/IEssentiaTransportWithSimulate.java @@ -0,0 +1,21 @@ +package thaumicenergistics.integration.tc; + +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.IEssentiaTransport; +import appeng.api.config.Actionable; + +public interface IEssentiaTransportWithSimulate + extends IEssentiaTransport +{ + /** + * Adds essentia to the transport. + * + * @param aspect + * @param amount + * @param side + * @param mode + * @return + */ + public int addEssentia( final Aspect aspect, final int amount, final ForgeDirection side, Actionable mode ); +} diff --git a/src/main/java/thaumicenergistics/items/ItemFocusAEWrench.java b/src/main/java/thaumicenergistics/items/ItemFocusAEWrench.java new file mode 100644 index 00000000..d820a676 --- /dev/null +++ b/src/main/java/thaumicenergistics/items/ItemFocusAEWrench.java @@ -0,0 +1,260 @@ +package thaumicenergistics.items; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.MovingObjectPosition.MovingObjectType; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.wands.FocusUpgradeType; +import thaumcraft.api.wands.ItemFocusBasic; +import thaumcraft.common.items.wands.ItemWandCasting; +import thaumicenergistics.ThaumicEnergistics; +import thaumicenergistics.network.packet.client.PacketAreaParticleFX; +import thaumicenergistics.registries.ThEStrings; +import thaumicenergistics.util.EffectiveSide; +import appeng.api.AEApi; + +public class ItemFocusAEWrench + extends ItemFocusBasic +{ + + /** + * Wrench used for dismantling. + */ + private final ItemStack psuedoWrench = AEApi.instance().items().itemCertusQuartzWrench.stack( 1 ); + + /** + * How much vis is cost to use the focus. + */ + private final AspectList castCost = new AspectList(); + + public ItemFocusAEWrench() + { + this.castCost.add( Aspect.FIRE, 10 ); + this.castCost.add( Aspect.AIR, 10 ); + } + + private void activateWrenchLeftClick( final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, + final ItemStack wandStack ) + { + // Is this server side? + if( world.isRemote ) + { + // Ignored client side + return; + } + // Get the block + Block block = world.getBlock( x, y, z ); + + // Ensure the block is valid + if( ( block == null ) || ( block == Blocks.air ) ) + { + // Invalid block + return; + } + + // Ensure the player is allowed to modify the block + if( !world.canMineBlock( player, x, y, z ) ) + { + // Player can not modify block + return; + } + + // Validate wand + if( ( wandStack == null ) || !( wandStack.getItem() instanceof ItemWandCasting ) ) + { + // Invalid wand + return; + } + + // Get the wand + ItemWandCasting wand = (ItemWandCasting)wandStack.getItem(); + + // Ensure there is enough vis for the cast + if( !wand.consumeAllVis( wandStack, player, this.castCost, false, false ) ) + { + // Not enough vis + return; + } + + // Attempt to rotate the block + if( block.rotateBlock( world, x, y, z, ForgeDirection.getOrientation( side ) ) ) + { + // Spawn beam + new PacketAreaParticleFX().createWrenchFX( world, player.posX, player.posY, player.posZ, x, y, z, Aspect.ENERGY ).sendToAllAround( 20 ); + + // Consume vis + wand.consumeAllVis( wandStack, player, this.castCost, true, false ); + + // Fire an update + block.onNeighborBlockChange( world, x, y, z, Blocks.air ); + } + + } + + private void activateWrenchRightClick( final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, + final float hitX, final float hitY, final float hitZ, final ItemStack wandStack ) + { + // Is this server side? + if( world.isRemote ) + { + // Ignored client side + return; + } + + // Get the block that was clicked + Block block = world.getBlock( x, y, z ); + + // Ensure the block is valid + if( ( block == null ) || ( block == Blocks.air ) ) + { + // Invalid block + return; + } + + // Validate wand + if( ( wandStack == null ) || !( wandStack.getItem() instanceof ItemWandCasting ) ) + { + // Invalid wand + return; + } + + // Get the wand + ItemWandCasting wand = (ItemWandCasting)wandStack.getItem(); + + // Ensure there is enough vis for the cast + if( !wand.consumeAllVis( wandStack, player, this.castCost, false, false ) ) + { + // Not enough vis + return; + } + + // Get the index of the players selected hotbar slot + int heldIndex = player.inventory.currentItem; + + // Save what the player is holding + ItemStack prevHolding = player.inventory.mainInventory[heldIndex]; + + // Set the wrench as what the player is holding + player.inventory.mainInventory[heldIndex] = this.psuedoWrench; + + try + { + // Call onActivate + if( block.onBlockActivated( world, x, y, z, player, side, hitX, hitY, hitZ ) ) + { + // Spawn beam + new PacketAreaParticleFX().createWrenchFX( world, player.posX, player.posY, player.posZ, x, y, z, Aspect.ENERGY ).sendToAllAround( 20 ); + + // Use vis + wand.consumeAllVis( wandStack, player, this.castCost, true, false ); + } + } + finally + { + // Restore what the player was holding + player.inventory.mainInventory[heldIndex] = prevHolding; + } + + } + + @Override + public int getActivationCooldown( final ItemStack focusstack ) + { + // 250ms between uses + return 250; + } + + @Override + public int getFocusColor( final ItemStack itemStack ) + { + return Aspect.ENERGY.getColor(); + } + + @Override + public FocusUpgradeType[] getPossibleUpgradesByRank( final ItemStack itemStack, final int rank ) + { + return new FocusUpgradeType[0]; + } + + @Override + public String getUnlocalizedName() + { + return ThEStrings.Item_FocusAEWrench.getUnlocalized(); + } + + @Override + public String getUnlocalizedName( final ItemStack itemStack ) + { + return ThEStrings.Item_FocusAEWrench.getUnlocalized(); + } + + @Override + public AspectList getVisCost( final ItemStack itemStack ) + { + + return this.castCost; + } + + /** + * Called when the player left-clicks + */ + @Override + public boolean onEntitySwing( final EntityLivingBase entity, final ItemStack wandStack ) + { + // Is the entity a player, and is the player sneaking? + if( ( entity instanceof EntityPlayer ) && ( entity.isSneaking() ) ) + { + // Ray trace + MovingObjectPosition position = this.getMovingObjectPositionFromPlayer( entity.worldObj, (EntityPlayer)entity, false ); + + // Was a block hit? + if( ( position != null ) && ( position.typeOfHit == MovingObjectType.BLOCK ) ) + { + // Activation ignored on client side + if( EffectiveSide.isServerSide() ) + { + // Use the wrench + this.activateWrenchLeftClick( entity.worldObj, position.blockX, position.blockY, position.blockZ, (EntityPlayer)entity, + position.sideHit, wandStack ); + } + + return true; + } + } + + return false; + + } + + /** + * Called when the player right-clicks + */ + @Override + public ItemStack onFocusRightClick( final ItemStack wandStack, final World world, final EntityPlayer player, final MovingObjectPosition position ) + { + // Is the player sneaking, and was a block clicked? + if( ( player.isSneaking() ) && ( position != null ) && ( position.typeOfHit == MovingObjectType.BLOCK ) ) + { + // Use the wrench + this.activateWrenchRightClick( world, position.blockX, position.blockY, position.blockZ, player, position.sideHit, + (float)position.hitVec.xCoord, (float)position.hitVec.yCoord, (float)position.hitVec.zCoord, wandStack ); + } + + return wandStack; + } + + @Override + public void registerIcons( final IIconRegister iconRegister ) + { + this.icon = iconRegister.registerIcon( ThaumicEnergistics.MOD_ID + ":foci.aewrench" ); + } + +} diff --git a/src/main/java/thaumicenergistics/network/ChannelHandler.java b/src/main/java/thaumicenergistics/network/ChannelHandler.java index 6756e78e..6ff75192 100644 --- a/src/main/java/thaumicenergistics/network/ChannelHandler.java +++ b/src/main/java/thaumicenergistics/network/ChannelHandler.java @@ -2,9 +2,8 @@ package thaumicenergistics.network; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.Packet; -import net.minecraft.world.World; import thaumicenergistics.ThaumicEnergistics; +import thaumicenergistics.network.handlers.HandlerAreaParticleFX; import thaumicenergistics.network.handlers.HandlerClientAspectSlot; import thaumicenergistics.network.handlers.HandlerClientEssentiaCellTerminal; import thaumicenergistics.network.handlers.HandlerClientEssentiaStorageBus; @@ -24,6 +23,7 @@ import thaumicenergistics.network.handlers.part.HandlerServerEssentiaIOBus; import thaumicenergistics.network.handlers.part.HandlerServerEssentiaLevelEmitter; import thaumicenergistics.network.handlers.part.HandlerServerEssentiaStorageBus; import thaumicenergistics.network.packet.AbstractPacket; +import thaumicenergistics.network.packet.client.PacketAreaParticleFX; import thaumicenergistics.network.packet.client.PacketClientArcaneCraftingTerminal; import thaumicenergistics.network.packet.client.PacketClientAspectSlot; import thaumicenergistics.network.packet.client.PacketClientEssentiaCellTerminal; @@ -43,6 +43,7 @@ import thaumicenergistics.network.packet.server.PacketServerEssentiaStorageBus; import thaumicenergistics.network.packet.server.PacketServerKnowledgeInscriber; import thaumicenergistics.network.packet.server.PacketServerPriority; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; @@ -55,50 +56,54 @@ public class ChannelHandler { byte discriminator = 0; + // Aspect slot wrapper.registerMessage( HandlerClientAspectSlot.class, PacketClientAspectSlot.class, discriminator++ , Side.CLIENT ); wrapper.registerMessage( HandlerServerAspectSlot.class, PacketServerAspectSlot.class, discriminator++ , Side.SERVER ); + // Essentia import/export bus wrapper.registerMessage( HandlerClientEssentiaIOBus.class, PacketClientEssentiaIOBus.class, discriminator++ , Side.CLIENT ); wrapper.registerMessage( HandlerServerEssentiaIOBus.class, PacketServerEssentiaIOBus.class, discriminator++ , Side.SERVER ); + // Essentia storage bus wrapper.registerMessage( HandlerClientEssentiaStorageBus.class, PacketClientEssentiaStorageBus.class, discriminator++ , Side.CLIENT ); wrapper.registerMessage( HandlerServerEssentiaStorageBus.class, PacketServerEssentiaStorageBus.class, discriminator++ , Side.SERVER ); + // Essentia level emitter wrapper.registerMessage( HandlerClientEssentiaLevelEmitter.class, PacketClientEssentiaEmitter.class, discriminator++ , Side.CLIENT ); wrapper.registerMessage( HandlerServerEssentiaLevelEmitter.class, PacketServerEssentiaEmitter.class, discriminator++ , Side.SERVER ); + // Essentia terminal wrapper.registerMessage( HandlerServerEssentiaCellTerminal.class, PacketServerEssentiaCellTerminal.class, discriminator++ , Side.SERVER ); wrapper.registerMessage( HandlerClientEssentiaCellTerminal.class, PacketClientEssentiaCellTerminal.class, discriminator++ , Side.CLIENT ); + // Arcane crafting terminal wrapper.registerMessage( HandlerClientArcaneCraftingTerminal.class, PacketClientArcaneCraftingTerminal.class, discriminator++ , Side.CLIENT ); wrapper.registerMessage( HandlerServerArcaneCraftingTerminal.class, PacketServerArcaneCraftingTerminal.class, discriminator++ , Side.SERVER ); + // Change GUI wrapper.registerMessage( HandlerServerChangeGui.class, PacketServerChangeGui.class, discriminator++ , Side.SERVER ); + // Priority GUI wrapper.registerMessage( HandlerClientPriority.class, PacketClientPriority.class, discriminator++ , Side.CLIENT ); wrapper.registerMessage( HandlerServerPriority.class, PacketServerPriority.class, discriminator++ , Side.SERVER ); + // Essentia cell workbench wrapper.registerMessage( HandlerServerEssentiaCellWorkbench.class, PacketServerEssentiaCellWorkbench.class, discriminator++ , Side.SERVER ); + // Knowledge inscriber wrapper.registerMessage( HandlerClientKnowledgeInscriber.class, PacketClientKnowledgeInscriber.class, discriminator++ , Side.CLIENT ); wrapper.registerMessage( HandlerServerKnowledgeInscriber.class, PacketServerKnowledgeInscriber.class, discriminator++ , Side.SERVER ); + // Particle FX + wrapper.registerMessage( HandlerAreaParticleFX.class, PacketAreaParticleFX.class, discriminator++ , Side.CLIENT ); + } - public static void sendPacketToAllPlayers( final AbstractPacket packet ) + public static void sendPacketToAllAround( final AbstractPacket packet, final int dimension, final double x, final double y, final double z, + final int range ) { - wrapper.sendToAll( packet ); - } - - public static void sendPacketToAllPlayers( final Packet packet, final World world ) - { - for( Object player : world.playerEntities ) - { - if( player instanceof EntityPlayerMP ) - { - ( (EntityPlayerMP)player ).playerNetServerHandler.sendPacket( packet ); - } - } + TargetPoint p = new TargetPoint( dimension, x, y, z, range ); + wrapper.sendToAllAround( packet, p ); } public static void sendPacketToPlayer( final AbstractPacket packet, final EntityPlayer player ) diff --git a/src/main/java/thaumicenergistics/network/handlers/HandlerAreaParticleFX.java b/src/main/java/thaumicenergistics/network/handlers/HandlerAreaParticleFX.java new file mode 100644 index 00000000..b482ebc7 --- /dev/null +++ b/src/main/java/thaumicenergistics/network/handlers/HandlerAreaParticleFX.java @@ -0,0 +1,19 @@ +package thaumicenergistics.network.handlers; + +import thaumicenergistics.network.packet.client.PacketAreaParticleFX; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; + +public class HandlerAreaParticleFX + implements IMessageHandler +{ + + @Override + public IMessage onMessage( final PacketAreaParticleFX message, final MessageContext ctx ) + { + message.execute(); + return null; + } + +} diff --git a/src/main/java/thaumicenergistics/network/packet/AbstractAreaPacket.java b/src/main/java/thaumicenergistics/network/packet/AbstractAreaPacket.java new file mode 100644 index 00000000..83562015 --- /dev/null +++ b/src/main/java/thaumicenergistics/network/packet/AbstractAreaPacket.java @@ -0,0 +1,76 @@ +package thaumicenergistics.network.packet; + +import io.netty.buffer.ByteBuf; +import net.minecraft.world.World; +import thaumicenergistics.network.ChannelHandler; +import thaumicenergistics.util.EffectiveSide; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class AbstractAreaPacket + extends AbstractPacket +{ + + /** + * Target coords. + */ + protected float targetX, targetY, targetZ; + + /** + * Target world. + */ + protected World targetWorld; + + @SideOnly(Side.CLIENT) + private void setClientWorld() + { + this.targetWorld = FMLClientHandler.instance().getClient().theWorld; + } + + @Override + protected void readData( final ByteBuf stream ) + { + // Read target coords + this.targetX = stream.readFloat(); + this.targetY = stream.readFloat(); + this.targetZ = stream.readFloat(); + } + + @Override + protected void writeData( final ByteBuf stream ) + { + // Write target coords + stream.writeFloat( this.targetX ); + stream.writeFloat( this.targetY ); + stream.writeFloat( this.targetZ ); + } + + @Override + public final void execute() + { + // Ensure this is client side + if( EffectiveSide.isClientSide() ) + { + this.setClientWorld(); + this.wrappedExecute(); + } + } + + /** + * Sends the packet to all players within range + * + * @param dimension + * @param x + * @param y + * @param z + * @param range + */ + public void sendToAllAround( final int range ) + { + ChannelHandler.sendPacketToAllAround( this, this.targetWorld.provider.dimensionId, this.targetX, this.targetY, this.targetZ, range ); + } + + @SideOnly(Side.CLIENT) + public abstract void wrappedExecute(); +} diff --git a/src/main/java/thaumicenergistics/network/packet/AbstractClientPacket.java b/src/main/java/thaumicenergistics/network/packet/AbstractClientPacket.java index 5787e8b8..42ca40ae 100644 --- a/src/main/java/thaumicenergistics/network/packet/AbstractClientPacket.java +++ b/src/main/java/thaumicenergistics/network/packet/AbstractClientPacket.java @@ -33,14 +33,6 @@ public abstract class AbstractClientPacket } } - /** - * Send this packet to all players. - */ - public void sendPacketToAllPlayers() - { - ChannelHandler.sendPacketToAllPlayers( this ); - } - /** * Send this packet to the player. * diff --git a/src/main/java/thaumicenergistics/network/packet/client/PacketAreaParticleFX.java b/src/main/java/thaumicenergistics/network/packet/client/PacketAreaParticleFX.java new file mode 100644 index 00000000..f08e47ed --- /dev/null +++ b/src/main/java/thaumicenergistics/network/packet/client/PacketAreaParticleFX.java @@ -0,0 +1,151 @@ +package thaumicenergistics.network.packet.client; + +import io.netty.buffer.ByteBuf; +import java.awt.Color; +import net.minecraft.client.Minecraft; +import net.minecraft.world.World; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.client.fx.ParticleEngine; +import thaumcraft.client.fx.beams.FXBeam; +import thaumicenergistics.network.packet.AbstractAreaPacket; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class PacketAreaParticleFX + extends AbstractAreaPacket +{ + + private static final byte MODE_WRENCH_FX = 0; + + /** + * Destination coords. + */ + private float dX, dY, dZ; + + /** + * Color of the FX. + */ + private int aspectColor; + + @SideOnly(Side.CLIENT) + private void addWrenchFX() + { + // Get the color + Color color = new Color( this.aspectColor ); + + // Create the particle + FXBeam beam = new FXBeam( this.targetWorld, this.targetX, this.targetY + 1.5D, this.targetZ, this.dX + 0.5D, this.dY + 0.5D, this.dZ + 0.5D, + color.getRed() / 255.0F, color.getGreen() / 255.0F, color.getBlue() / 255.0F, 6 ); + + // Set the width + beam.width = 0.2F; + + // Add the particle to thaumcraft engine + ParticleEngine.instance.addEffect( this.targetWorld, beam ); + } + + @Override + protected void readData( final ByteBuf stream ) + { + // Call super + super.readData( stream ); + + switch ( this.mode ) + { + case PacketAreaParticleFX.MODE_WRENCH_FX: + + // Read the destination + this.dX = stream.readFloat(); + this.dY = stream.readFloat(); + this.dZ = stream.readFloat(); + + // Read the color + this.aspectColor = stream.readInt(); + break; + } + + } + + @Override + protected void writeData( final ByteBuf stream ) + { + // Call super + super.writeData( stream ); + + switch ( this.mode ) + { + case PacketAreaParticleFX.MODE_WRENCH_FX: + // Write the destination + stream.writeFloat( this.dX ); + stream.writeFloat( this.dY ); + stream.writeFloat( this.dZ ); + + // Write the color + stream.writeInt( this.aspectColor ); + break; + } + } + + /** + * Creates an FX packet. + * + * @param world + * @param sourceX + * @param sourceY + * @param sourceZ + * @param destinationX + * @param destinationY + * @param destinationZ + * @param aspectColor + * @return + */ + public PacketAreaParticleFX createWrenchFX( final World world, final double sourceX, final double sourceY, final double sourceZ, + final double destinationX, final double destinationY, final double destinationZ, + final Aspect aspectColor ) + { + // Set the mode + this.mode = PacketAreaParticleFX.MODE_WRENCH_FX; + + // Set the world + this.targetWorld = world; + + // Set the target coords + this.targetX = (float)sourceX; + this.targetY = (float)sourceY; + this.targetZ = (float)sourceZ; + + // Set the destination values + this.dX = (float)destinationX; + this.dY = (float)destinationY; + this.dZ = (float)destinationZ; + + // Set the aspect color + this.aspectColor = aspectColor.getColor(); + + return this; + } + + @SideOnly(Side.CLIENT) + @Override + public void wrappedExecute() + { + // Ensure the world is valid + if( this.targetWorld == null ) + { + return; + } + + // Has the player set particles to minimum? + if( Minecraft.getMinecraft().gameSettings.particleSetting == 2 ) + { + return; + } + + switch ( this.mode ) + { + case PacketAreaParticleFX.MODE_WRENCH_FX: + this.addWrenchFX(); + break; + } + } +} diff --git a/src/main/java/thaumicenergistics/registries/BlockEnum.java b/src/main/java/thaumicenergistics/registries/BlockEnum.java index 2d6eb3b4..db0bc49e 100644 --- a/src/main/java/thaumicenergistics/registries/BlockEnum.java +++ b/src/main/java/thaumicenergistics/registries/BlockEnum.java @@ -4,6 +4,7 @@ import net.minecraft.block.Block; import thaumicenergistics.blocks.BlockArcaneAssembler; import thaumicenergistics.blocks.BlockEssentiaCellWorkbench; import thaumicenergistics.blocks.BlockEssentiaProvider; +import thaumicenergistics.blocks.BlockEssentiaVibrationChamber; import thaumicenergistics.blocks.BlockGearBox; import thaumicenergistics.blocks.BlockGolemGearBox; import thaumicenergistics.blocks.BlockInfusionProvider; @@ -17,7 +18,8 @@ public enum BlockEnum THAUMIUM_GEAR_BOX (ThEStrings.Block_ThaumiumGearbox, new BlockGolemGearBox()), ESSENTIA_CELL_WORKBENCH (ThEStrings.Block_EssentiaCellWorkbench, new BlockEssentiaCellWorkbench()), ARCANE_ASSEMBLER (ThEStrings.Block_ArcaneAssembler, new BlockArcaneAssembler()), - KNOWLEDGE_INSCRIBER (ThEStrings.Block_KnowledgeInscriber, new BlockKnowledgeInscriber()); + KNOWLEDGE_INSCRIBER (ThEStrings.Block_KnowledgeInscriber, new BlockKnowledgeInscriber()), + ESSENTIA_VIBRATION_CHAMBER (ThEStrings.Block_EssentiaVibrationChamber, new BlockEssentiaVibrationChamber()); private Block block; diff --git a/src/main/java/thaumicenergistics/registries/ItemEnum.java b/src/main/java/thaumicenergistics/registries/ItemEnum.java index a2a1dddf..ced44c8b 100644 --- a/src/main/java/thaumicenergistics/registries/ItemEnum.java +++ b/src/main/java/thaumicenergistics/registries/ItemEnum.java @@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack; import thaumicenergistics.ThaumicEnergistics; import thaumicenergistics.items.ItemAEPart; import thaumicenergistics.items.ItemEssentiaCell; +import thaumicenergistics.items.ItemFocusAEWrench; import thaumicenergistics.items.ItemKnowledgeCore; import thaumicenergistics.items.ItemMaterial; import thaumicenergistics.items.ItemStorageCasing; @@ -19,7 +20,8 @@ public enum ItemEnum STORAGE_CASING ("storage.casing", new ItemStorageCasing()), MATERIAL ("material", new ItemMaterial()), WIRELESS_TERMINAL ("wireless.essentia.terminal", new ItemWirelessEssentiaTerminal()), - KNOWLEDGE_CORE ("knowledge.core", new ItemKnowledgeCore()); + KNOWLEDGE_CORE ("knowledge.core", new ItemKnowledgeCore()), + FOCUS_AEWRENCH ("focus.aewrench", new ItemFocusAEWrench()); /** * Internal name of the item. diff --git a/src/main/java/thaumicenergistics/registries/ResearchRegistry.java b/src/main/java/thaumicenergistics/registries/ResearchRegistry.java index bb41f222..de87c9bb 100644 --- a/src/main/java/thaumicenergistics/registries/ResearchRegistry.java +++ b/src/main/java/thaumicenergistics/registries/ResearchRegistry.java @@ -29,8 +29,9 @@ public class ResearchRegistry INFUSION ("INFUSION", "ARTIFICE", -6, 0), VISPOWER ("VISPOWER", "THAUMATURGY", 2, -1), COREUSE ("COREUSE", "GOLEMANCY", 4, 3), - DUPE ("ALCHEMICALDUPLICATION", "ALCHEMY", -6, -7), - WARDED ("WARDEDARCANA", "ARTIFICE", 0, 2); + DUPE ("ALCHEMICALDUPLICATION", "ALCHEMY", -5, -6), + WARDED ("WARDEDARCANA", "ARTIFICE", 0, 2), + FOCUSFIRE ("FOCUSFIRE", "THAUMATURGY", -4, -7); private String realResearchKey; private String realResearchCategory; @@ -73,9 +74,10 @@ public class ResearchRegistry VISINTERFACE ("VISINT", 2, 0), IRONGEARBOX ("IRONGEARBOX", 3, 2), THAUMIUMGEARBOX ("THAUMGBOX", 3, 3), - CERTUSDUPE ("CERTUSDUPE", -6, -6), + CERTUSDUPE ("CERTUSDUPE", -5, -5), ARCANEASSEMBLER ("ARCANEASSEMBLER", 4, 0), - KNOWLEDGEINSCRIBER ("KNOWLEDGEINSCRIBER", 4, -2); + KNOWLEDGEINSCRIBER ("KNOWLEDGEINSCRIBER", 4, -2), + FOCUSWRENCH ("FOCUSWRENCH", -3, -7); private String internalName; @@ -583,6 +585,27 @@ public class ResearchRegistry ResearchTypes.VISINTERFACE.researchItem.registerResearchItem(); } + private static void registerWrenchFocus() + { + // Set the research aspects + AspectList focusAspects = new AspectList(); + focusAspects.add( Aspect.MECHANISM, 6 ); + focusAspects.add( Aspect.TOOL, 5 ); + focusAspects.add( Aspect.MAGIC, 3 ); + + // Set the icon + ItemStack focusIcon = ItemEnum.FOCUS_AEWRENCH.getItemStackWithSize( 1 ); + + // Set the pages + ResearchPage[] focusPages = new ResearchPage[] { new ResearchPage( ResearchTypes.FOCUSWRENCH.getPageName( 1 ) ) }; + + // Create the research + ResearchTypes.FOCUSWRENCH.createResearchItem( focusAspects, COMPLEXITY_SMALL, focusIcon, focusPages ); + ResearchTypes.FOCUSWRENCH.researchItem.setParents( PseudoResearchTypes.FOCUSFIRE.getKey() ).setSecondary(); + ResearchTypes.FOCUSWRENCH.researchItem.registerResearchItem(); + + } + public static void registerResearch() { // Create our research tab @@ -639,6 +662,9 @@ public class ResearchRegistry // Knowledge Inscriber + Core ResearchRegistry.registerKnowledgeInscriber(); + // Wrench focus + ResearchRegistry.registerWrenchFocus(); + // Place parents ResearchRegistry.addPseudoParents(); } diff --git a/src/main/java/thaumicenergistics/registries/ThEStrings.java b/src/main/java/thaumicenergistics/registries/ThEStrings.java index b50593a3..4939b50f 100644 --- a/src/main/java/thaumicenergistics/registries/ThEStrings.java +++ b/src/main/java/thaumicenergistics/registries/ThEStrings.java @@ -22,6 +22,7 @@ public enum ThEStrings Block_EssentiaCellWorkbench ("block.essentia.cell.workbench", true), Block_ArcaneAssembler ("block.arcane.assembler", true), Block_KnowledgeInscriber ("block.knowledge.inscriber", true), + Block_EssentiaVibrationChamber ("block.essentia.vibration.chamber", true), // Parts Part_EssentiaImportBus ("aeparts.essentia.ImportBus", true), @@ -48,6 +49,7 @@ public enum ThEStrings Item_IronGear ("item.material.iron.gear", true), Item_WirelessEssentiaTerminal ("item.wireless.essentia.terminal", true), Item_KnowledgeCore ("item.knowledge.core", true), + Item_FocusAEWrench ("item.focus.aewrench", true), // Tooltips Tooltip_CellBytes ("tooltip.essentia.cell.bytes", false), diff --git a/src/main/java/thaumicenergistics/registries/TileEnum.java b/src/main/java/thaumicenergistics/registries/TileEnum.java index 1299f593..7804bd6e 100644 --- a/src/main/java/thaumicenergistics/registries/TileEnum.java +++ b/src/main/java/thaumicenergistics/registries/TileEnum.java @@ -4,6 +4,7 @@ import thaumicenergistics.ThaumicEnergistics; import thaumicenergistics.tileentities.TileArcaneAssembler; import thaumicenergistics.tileentities.TileEssentiaCellWorkbench; import thaumicenergistics.tileentities.TileEssentiaProvider; +import thaumicenergistics.tileentities.TileEssentiaVibrationChamber; import thaumicenergistics.tileentities.TileGearBox; import thaumicenergistics.tileentities.TileInfusionProvider; import thaumicenergistics.tileentities.TileKnowledgeInscriber; @@ -15,7 +16,8 @@ public enum TileEnum GearBox ("TileGearBox", TileGearBox.class), CellWorkbench ("TileEssentiaCellWorkbench", TileEssentiaCellWorkbench.class), ArcaneAssembler ("TileArcaneAssembler", TileArcaneAssembler.class), - KnowledgeInscriber ("TileKnowledgeInscriber", TileKnowledgeInscriber.class); + KnowledgeInscriber ("TileKnowledgeInscriber", TileKnowledgeInscriber.class), + EssentiaVibrationChamber ("TileEssentiaVibrationChamber", TileEssentiaVibrationChamber.class); /** * Unique ID of the tile entity diff --git a/src/main/java/thaumicenergistics/texture/BlockTextureManager.java b/src/main/java/thaumicenergistics/texture/BlockTextureManager.java index d4de8fdd..94a1f920 100644 --- a/src/main/java/thaumicenergistics/texture/BlockTextureManager.java +++ b/src/main/java/thaumicenergistics/texture/BlockTextureManager.java @@ -41,7 +41,10 @@ public enum BlockTextureManager ARCANE_ASSEMBLER (TextureTypes.Block, new String[] { "arcane.assembler.fallback" }), - KNOWLEDGE_INSCRIBER (TextureTypes.Block, new String[] { "knowledge.inscriber.side", "knowledge.inscriber.top", "knowledge.inscriber.bottom" }); + KNOWLEDGE_INSCRIBER (TextureTypes.Block, new String[] { "knowledge.inscriber.side", "knowledge.inscriber.top", "knowledge.inscriber.bottom" }), + + ESSENTIA_VIBRATION_CHAMBER (TextureTypes.Block, new String[] { "essentia.vibration.chamber.side", "essentia.vibration.chamber.face.off", + "essentia.vibration.chamber.face.on", }); private enum TextureTypes { diff --git a/src/main/java/thaumicenergistics/tileentities/TileArcaneAssembler.java b/src/main/java/thaumicenergistics/tileentities/TileArcaneAssembler.java index 45b9caab..7a811671 100644 --- a/src/main/java/thaumicenergistics/tileentities/TileArcaneAssembler.java +++ b/src/main/java/thaumicenergistics/tileentities/TileArcaneAssembler.java @@ -339,8 +339,6 @@ public class TileArcaneAssembler double powerRequired = ( TileArcaneAssembler.ACTIVE_POWER + ( ( TileArcaneAssembler.ACTIVE_POWER * this.upgradeCount ) / 2.0D ) ) * this.warpPowerMultiplier; - System.out.println( powerRequired ); - // Attempt to take power IEnergyGrid eGrid = this.gridProxy.getEnergy(); double powerExtracted = eGrid.extractAEPower( powerRequired, Actionable.MODULATE, PowerMultiplier.CONFIG ); @@ -1200,10 +1198,20 @@ public class TileArcaneAssembler return false; } + /** + * Sets the owner of this tile. + * + * @param player + */ + public void setOwner( final EntityPlayer player ) + { + this.gridProxy.setOwner( player ); + } + /** * Configures the Assembler. */ - public void setupAssemblerTile() + public TileArcaneAssembler setupAssemblerTile() { // Ignored on client side if( FMLCommonHandler.instance().getEffectiveSide().isServer() ) @@ -1214,6 +1222,8 @@ public class TileArcaneAssembler // Set that we require a channel this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL ); } + + return this; } } diff --git a/src/main/java/thaumicenergistics/tileentities/TileEssentiaProvider.java b/src/main/java/thaumicenergistics/tileentities/TileEssentiaProvider.java index a87a9104..5df8da40 100644 --- a/src/main/java/thaumicenergistics/tileentities/TileEssentiaProvider.java +++ b/src/main/java/thaumicenergistics/tileentities/TileEssentiaProvider.java @@ -7,13 +7,15 @@ import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.IEssentiaTransport; import thaumicenergistics.api.ThEApi; import thaumicenergistics.aspect.AspectStack; +import thaumicenergistics.integration.tc.EssentiaTransportHelper; +import thaumicenergistics.integration.tc.IEssentiaTransportWithSimulate; import appeng.api.config.Actionable; import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; public class TileEssentiaProvider extends TileProviderBase - implements IEssentiaTransport + implements IEssentiaTransportWithSimulate { /** * How often should the tile tick. @@ -74,7 +76,28 @@ public class TileEssentiaProvider @Override public int addEssentia( final Aspect aspect, final int amount, final ForgeDirection side ) { - return this.injectEssentiaIntoNetwork( aspect, amount, Actionable.MODULATE ); + return this.addEssentia( aspect, amount, side, Actionable.MODULATE ); + } + + @Override + public int addEssentia( final Aspect aspect, final int amount, final ForgeDirection side, final Actionable mode ) + { + // Validate amount + if( amount <= 0 ) + { + // Invalid amount + return 0; + } + + // Get the amount injected + int acceptedAmount = this.injectEssentiaIntoNetwork( aspect, amount, mode ); + + if( ( mode == Actionable.MODULATE ) && ( acceptedAmount > 0 ) ) + { + this.tickRate = TileEssentiaProvider.TICK_RATE_URGENT; + } + + return acceptedAmount; } @Override @@ -179,59 +202,8 @@ public class TileEssentiaProvider // Assume idle this.tickRate = TileEssentiaProvider.TICK_RATE_IDLE; - // Search every side - for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS ) - { - // Get the tile - TileEntity tile = this.worldObj.getTileEntity( side.offsetX + this.xCoord, side.offsetY + this.yCoord, side.offsetZ + this.zCoord ); - - // Ensure it is a transport - if( !( tile instanceof IEssentiaTransport ) ) - { - // Not transport, skip it. - continue; - } - - // Cast - IEssentiaTransport transport = (IEssentiaTransport)tile; - ForgeDirection opSide = side.getOpposite(); - - // Does the transport have essentia to give? - if( transport.getEssentiaAmount( opSide ) == 0 ) - { - // No essentia. - continue; - } - - // Set tick rate to urgent. - this.tickRate = TileEssentiaProvider.TICK_RATE_URGENT; - - // Is there enough suction to pull it out? - if( ( this.getSuctionAmount( side ) < transport.getMinimumSuction() ) || - ( this.getSuctionAmount( side ) < transport.getSuctionAmount( opSide ) ) ) - { - // Not enough suction. - continue; - } - - // Get the aspect of the essentia. - Aspect aspect = transport.getEssentiaType( side ); - - // Ensure there is an aspect - if( aspect == null ) - { - // Null aspect - continue; - } - - // Can the essentia be imported? - if( this.injectEssentiaIntoNetwork( aspect, 1, Actionable.SIMULATE ) == 1 ) - { - // Take from tile and import - this.injectEssentiaIntoNetwork( aspect, transport.takeEssentia( aspect, 1, opSide ), Actionable.MODULATE ); - - } - } + // Take essentia from the neighbors + EssentiaTransportHelper.instance.takeEssentiaFromTransportNeighbors( this, this.worldObj, this.xCoord, this.yCoord, this.zCoord ); } } diff --git a/src/main/java/thaumicenergistics/tileentities/TileEssentiaVibrationChamber.java b/src/main/java/thaumicenergistics/tileentities/TileEssentiaVibrationChamber.java new file mode 100644 index 00000000..0e832838 --- /dev/null +++ b/src/main/java/thaumicenergistics/tileentities/TileEssentiaVibrationChamber.java @@ -0,0 +1,338 @@ +package thaumicenergistics.tileentities; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.aspects.IAspectSource; +import thaumicenergistics.api.ThEApi; +import thaumicenergistics.blocks.BlockEssentiaVibrationChamber; +import thaumicenergistics.integration.tc.EssentiaTransportHelper; +import thaumicenergistics.integration.tc.IEssentiaTransportWithSimulate; +import appeng.api.config.Actionable; +import appeng.api.networking.IGridNode; +import appeng.api.networking.ticking.IGridTickable; +import appeng.api.networking.ticking.TickRateModulation; +import appeng.api.networking.ticking.TickingRequest; +import appeng.api.util.AECableType; +import appeng.api.util.DimensionalCoord; +import appeng.tile.grid.AENetworkTile; +import cpw.mods.fml.common.FMLCommonHandler; + +public class TileEssentiaVibrationChamber + extends AENetworkTile + implements IGridTickable, IEssentiaTransportWithSimulate, IAspectSource +{ + /** + * Ticking rates. + */ + private static final int TICKRATE_IDLE = 40, TICKRATE_URGENT = 10; + + /** + * The maximum amount of stored essentia. + */ + private static final int MAX_ESSENTIA_STORED = 64; + + /** + * How much essentia is stored. + */ + private int storedEssentiaAmount = 0; + + /** + * The type of essentia that is stored. + */ + private Aspect storedEssentiaAspect = null; + + /** + * The rate at which ticks should arrive. + */ + private TickRateModulation tickRate = TickRateModulation.SAME; + + @Override + protected ItemStack getItemFromTile( final Object obj ) + { + // Return the itemstack the visually represents this tile + return ThEApi.instance().blocks().EssentiaVibrationChamber.getStack(); + + } + + @Override + public int addEssentia( final Aspect aspect, final int amount, final ForgeDirection side ) + { + return this.addEssentia( aspect, amount, side, Actionable.MODULATE ); + } + + @Override + public int addEssentia( final Aspect aspect, final int amount, final ForgeDirection side, final Actionable mode ) + { + // Validate essentia type + if( ( this.storedEssentiaAspect != null ) && ( this.storedEssentiaAspect != aspect ) ) + { + // Essentia type does not match + return 0; + } + + // Calculate how much will be stored + int addedAmount = Math.min( amount, TileEssentiaVibrationChamber.MAX_ESSENTIA_STORED - this.storedEssentiaAmount ); + + if( ( addedAmount > 0 ) && ( mode == Actionable.MODULATE ) ) + { + // Set aspect if needed + if( this.storedEssentiaAspect == null ) + { + this.storedEssentiaAspect = aspect; + } + + // Add to the amount + this.storedEssentiaAmount += addedAmount; + + // Adjust tick rate + this.tickRate = TickRateModulation.FASTER; + } + + return addedAmount; + + } + + @Override + public int addToContainer( final Aspect aspect, final int amount ) + { + return this.addEssentia( aspect, amount, null, Actionable.MODULATE ); + } + + @Override + public boolean canInputFrom( final ForgeDirection side ) + { + return( side != BlockEssentiaVibrationChamber.getFaceSideFromMeta( this.getBlockMetadata() ) ); + } + + /** + * Can not output. + */ + @Override + public boolean canOutputTo( final ForgeDirection side ) + { + return false; + } + + @Override + public int containerContains( final Aspect aspect ) + { + return( aspect == this.storedEssentiaAspect ? this.storedEssentiaAmount : 0 ); + } + + @Override + public boolean doesContainerAccept( final Aspect aspect ) + { + // Is there stored essentia? + if( this.storedEssentiaAspect != null ) + { + // Match to stored essentia + return aspect == this.storedEssentiaAspect; + } + + // Nothing is stored, accepts ignis or potentia + return( ( aspect == Aspect.FIRE ) || ( aspect == Aspect.ENERGY ) ); + } + + @Deprecated + @Override + public boolean doesContainerContain( final AspectList aspectList ) + { + // Is there stored essentia? + if( this.storedEssentiaAspect == null ) + { + return false; + } + + return aspectList.aspects.containsKey( this.storedEssentiaAspect ); + } + + @Override + public boolean doesContainerContainAmount( final Aspect aspect, final int amount ) + { + // Does the stored essentia match the aspect? + if( ( this.storedEssentiaAspect == null ) || ( this.storedEssentiaAspect != aspect ) ) + { + // Does not match + return false; + } + + return( this.storedEssentiaAmount >= amount ); + } + + @Override + public AspectList getAspects() + { + // Create a new list + AspectList aspectList = new AspectList(); + + // Is there stored essentia? + if( this.storedEssentiaAspect != null ) + { + // Add the essentia aspect and amount + aspectList.add( this.storedEssentiaAspect, this.storedEssentiaAmount ); + } + + return aspectList; + } + + @Override + public AECableType getCableConnectionType( final ForgeDirection dir ) + { + return AECableType.COVERED; + } + + /** + * Can not output. + */ + @Override + public int getEssentiaAmount( final ForgeDirection side ) + { + return this.storedEssentiaAmount; + } + + /** + * Can not output. + */ + @Override + public Aspect getEssentiaType( final ForgeDirection side ) + { + return this.storedEssentiaAspect; + } + + @Override + public DimensionalCoord getLocation() + { + return new DimensionalCoord( this ); + } + + /** + * Can not output. + */ + @Override + public int getMinimumSuction() + { + return 0; + } + + @Override + public int getSuctionAmount( final ForgeDirection side ) + { + return( this.storedEssentiaAmount < TileEssentiaVibrationChamber.MAX_ESSENTIA_STORED ? 128 : 0 ); + } + + @Override + public Aspect getSuctionType( final ForgeDirection side ) + { + // TODO rotate suction type if empty, else set to stored type + return Aspect.FIRE; + } + + @Override + public TickingRequest getTickingRequest( final IGridNode node ) + { + // TODO: Sleep + return new TickingRequest( TileEssentiaVibrationChamber.TICKRATE_URGENT, TileEssentiaVibrationChamber.TICKRATE_IDLE, false, false ); + + } + + @Override + public boolean isConnectable( final ForgeDirection side ) + { + return( side != BlockEssentiaVibrationChamber.getFaceSideFromMeta( this.getBlockMetadata() ) ); + } + + /** + * Full block, not extension needed. + */ + @Override + public boolean renderExtendedTube() + { + return false; + } + + @Override + public void setAspects( final AspectList aspectList ) + { + // Ignored + } + + /** + * Sets the owner of this tile. + * + * @param player + */ + public void setOwner( final EntityPlayer player ) + { + this.gridProxy.setOwner( player ); + } + + @Override + public void setSuction( final Aspect aspect, final int amount ) + { + // Ignored + } + + /** + * Sets up the chamber + * + * @return + */ + public TileEssentiaVibrationChamber setupChamberTile() + { + // Ignored on client side + if( FMLCommonHandler.instance().getEffectiveSide().isServer() ) + { + // Set idle power usage to zero + this.gridProxy.setIdlePowerUsage( 0.0D ); + } + + return this; + } + + /** + * Can not output. + */ + @Override + public int takeEssentia( final Aspect aspect, final int amount, final ForgeDirection side ) + { + return 0; + } + + /** + * Can not output. + */ + @Override + public boolean takeFromContainer( final Aspect aspect, final int amount ) + { + return false; + } + + /** + * Can not output. + */ + @Deprecated + @Override + public boolean takeFromContainer( final AspectList arg0 ) + { + return false; + } + + @Override + public TickRateModulation tickingRequest( final IGridNode node, final int TicksSinceLastCall ) + { + // Assume slower + this.tickRate = TickRateModulation.SLOWER; + + // Does the essentia need to be replenished? + if( this.storedEssentiaAmount < TileEssentiaVibrationChamber.MAX_ESSENTIA_STORED ) + { + // Replenish essentia + EssentiaTransportHelper.instance.takeEssentiaFromTransportNeighbors( this, this.worldObj, this.xCoord, this.yCoord, this.zCoord ); + } + + return this.tickRate; + } +} diff --git a/src/main/resources/assets/thaumicenergistics/lang/en_US.lang b/src/main/resources/assets/thaumicenergistics/lang/en_US.lang index 58164c6f..d9169b16 100644 --- a/src/main/resources/assets/thaumicenergistics/lang/en_US.lang +++ b/src/main/resources/assets/thaumicenergistics/lang/en_US.lang @@ -13,6 +13,7 @@ thaumicenergistics.block.golem.gear.box.name=Thaumium Gear Box thaumicenergistics.block.essentia.cell.workbench.name=Essentia Cell Workbench thaumicenergistics.block.arcane.assembler.name=Arcane Assembler thaumicenergistics.block.knowledge.inscriber.name=Knowledge Inscriber +thaumicenergistics.block.essentia.vibration.chamber.name=Essentia Vibration Chamber #Cable parts thaumicenergistics.aeparts.essentia.ImportBus.name=Essentia Import Bus @@ -39,6 +40,7 @@ thaumicenergistics.item.material.coalescence.core.name=Coalescence Core thaumicenergistics.item.material.iron.gear.name=Iron Gear thaumicenergistics.item.wireless.essentia.terminal.name=Wireless Essentia Terminal thaumicenergistics.item.knowledge.core.name=Knowledge Core +thaumicenergistics.item.focus.aewrench.name=Wand Focus: AE Wrench #Tooltips thaumicenergistics.tooltip.essentia.cell.bytes=%d of %d bytes used. @@ -146,3 +148,8 @@ tc.research_text.thaumicenergistics.TEARCANEASSEMBLER=Magical Molecule Assembly thaumicenergistics.research_page.TEARCANEASSEMBLER.1=While examining the §lMolecular Assembler§r it occurs to you that it may be possible to modify the assembler to produce arcane items. You conclude that by infusing the assembler with the appropriate shards it will be able to regulate vis flow into items. It will also need a moderate amount of vis storage, and the §lSilverwood Scepter§r seems the best choice.
Note: A fully charged scepter is required for the infusion. thaumicenergistics.research_page.TEARCANEASSEMBLER.2=§lPattern Storage§r
The assembler itself does not store crafting recipes. Further research may be required to devise a pattern storage medium.
§lVis Replenishment§r
Replenishing the assembler's internal vis storage will require the services of a §lVis Relay Interface§r.
§lAcceleration Cards§r
Each card decreases crafting time by 20% and increases power required by 50%. thaumicenergistics.research_page.TEARCANEASSEMBLER.3=§lVis Discounts§r
Due to the inclusion of the crafting scepter, the assembler has a base vis discount equal to that of the scepter. The discount can be further enhanced by providing the assembler vis discount armor. The discount for each aspect can be viewed by hovering over the aspect in the GUI.
Keep in mind that the assembler is not immune to the effects of warping gear. For each point of warp the assembler must draw an additional 15% power to remain stable. This effect only applies during crafting. + +# Research Wrench Focus +tc.research_name.thaumicenergistics.TEFOCUSWRENCH=Wand Focus: AE Wrench +tc.research_text.thaumicenergistics.TEFOCUSWRENCH=Some Assembly Required +thaumicenergistics.research_page.TEFOCUSWRENCH.1=Stuff diff --git a/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.face.off.png b/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.face.off.png new file mode 100644 index 00000000..4bfcb24b Binary files /dev/null and b/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.face.off.png differ diff --git a/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.face.on.png b/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.face.on.png new file mode 100644 index 00000000..da3e4122 Binary files /dev/null and b/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.face.on.png differ diff --git a/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.side.png b/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.side.png new file mode 100644 index 00000000..a4f39d35 Binary files /dev/null and b/src/main/resources/assets/thaumicenergistics/textures/blocks/essentia.vibration.chamber.side.png differ diff --git a/src/main/resources/assets/thaumicenergistics/textures/items/foci.aewrench.png b/src/main/resources/assets/thaumicenergistics/textures/items/foci.aewrench.png new file mode 100644 index 00000000..515676f9 Binary files /dev/null and b/src/main/resources/assets/thaumicenergistics/textures/items/foci.aewrench.png differ