More core update work

This commit is contained in:
Calclavia 2014-07-15 18:58:44 -04:00
parent 0db386ba12
commit eeee9532ab
22 changed files with 446 additions and 515 deletions

View file

@ -1,80 +0,0 @@
package resonantinduction.core;
import java.awt.Color;
import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import resonant.lib.render.fx.FxLaser;
import universalelectricity.api.vector.IVector3;
import universalelectricity.core.transform.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** @author Calclavia */
@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy
{
@Override
public void preInit()
{
MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE);
}
@Override
public boolean isPaused()
{
if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic())
{
GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
if (screen != null)
{
if (screen.doesGuiPauseGame())
{
return true;
}
}
}
return false;
}
@Override
public boolean isGraphicsFancy()
{
return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics;
}
@Override
public void renderBlockParticle(World world, Vector3 position, Vector3 velocity, int blockID, float scale)
{
this.renderBlockParticle(world, position.x, position.y, position.z, velocity, blockID, scale);
}
@Override
public void renderBlockParticle(World world, double x, double y, double z, Vector3 velocity, int blockID, float scale)
{
EntityFX fx = new EntityDiggingFX(world, x, y, z, velocity.x, velocity.y, velocity.z, Block.blocksList[blockID], 0, 0);
fx.multipleParticleScaleBy(scale);
fx.noClip = true;
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
}
@Override
public void renderBeam(World world, IVector3 position, IVector3 hit, Color color, int age)
{
renderBeam(world, position, hit, color.getRed(), color.getGreen(), color.getBlue(), age);
}
@Override
public void renderBeam(World world, IVector3 position, IVector3 target, float red, float green, float blue, int age)
{
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FxLaser(world, position, target, red, green, blue, age));
}
}

View file

@ -0,0 +1,58 @@
package resonantinduction.core
import java.awt.Color
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.block.Block
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.particle.{EntityDiggingFX, EntityFX}
import net.minecraft.world.World
import universalelectricity.core.transform.vector.Vector3
/** @author Calclavia */
@SideOnly(Side.CLIENT) class ClientProxy extends CommonProxy
{
override def isPaused: Boolean =
{
if (FMLClientHandler.instance.getClient.isSingleplayer && !FMLClientHandler.instance.getClient.getIntegratedServer.getPublic)
{
val screen: GuiScreen = FMLClientHandler.instance.getClient.currentScreen
if (screen != null)
{
if (screen.doesGuiPauseGame)
{
return true
}
}
}
return false
}
override def isGraphicsFancy: Boolean =
{
return FMLClientHandler.instance.getClient.gameSettings.fancyGraphics
}
override def renderBlockParticle(world: World, position: Vector3, velocity: Vector3, blockID: Int, scale: Float)
{
this.renderBlockParticle(world, position.x, position.y, position.z, velocity, blockID, scale)
}
def renderBlockParticle(world: World, x: Double, y: Double, z: Double, velocity: Vector3, block: Block, scale: Float)
{
val fx: EntityFX = new EntityDiggingFX(world, x, y, z, velocity.x, velocity.y, velocity.z, block, 0, 0)
fx.multipleParticleScaleBy(scale)
fx.noClip = true
FMLClientHandler.instance.getClient.effectRenderer.addEffect(fx)
}
override def renderBeam(world: World, position: Vector3, hit: Vector3, color: Color, age: Int)
{
renderBeam(world, position, hit, color.getRed, color.getGreen, color.getBlue, age)
}
override def renderBeam(world: World, position: Vector3, target: Vector3, red: Float, green: Float, blue: Float, age: Int)
{
}
}

View file

@ -1,45 +0,0 @@
/**
*
*/
package resonantinduction.core;
import java.awt.Color;
import net.minecraft.world.World;
import resonant.lib.prefab.ProxyBase;
import universalelectricity.api.vector.IVector3;
import universalelectricity.core.transform.vector.Vector3;
/** @author Calclavia */
public class CommonProxy extends ProxyBase
{
public boolean isPaused()
{
return false;
}
public boolean isGraphicsFancy()
{
return false;
}
public void renderBlockParticle(World world, double x, double y, double z, Vector3 velocity, int blockID, float scale)
{
}
public void renderBlockParticle(World world, Vector3 position, Vector3 velocity, int blockID, float scale)
{
}
public void renderBeam(World world, IVector3 position, IVector3 hit, Color color, int age)
{
}
public void renderBeam(World world, IVector3 position, IVector3 target, float red, float green, float blue, int age)
{
}
}

View file

@ -0,0 +1,42 @@
/**
* @Calclavia
*/
package resonantinduction.core
import java.awt._
import net.minecraft.world.World
import resonant.lib.prefab.AbstractProxy
import universalelectricity.core.transform.vector.Vector3
/**
* @author Calclavia
*/
class CommonProxy extends AbstractProxy
{
def isPaused: Boolean =
{
return false
}
def isGraphicsFancy: Boolean =
{
return false
}
def renderBlockParticle(world: World, x: Double, y: Double, z: Double, velocity: Vector3, blockID: Int, scale: Float)
{
}
def renderBlockParticle(world: World, position: Vector3, velocity: Vector3, blockID: Int, scale: Float)
{
}
def renderBeam(world: World, position: Vector3, hit: Vector3, color: Color, age: Int)
{
}
def renderBeam(world: World, position: Vector3, target: Vector3, red: Float, green: Float, blue: Float, age: Int)
{
}
}

View file

@ -8,7 +8,7 @@ import net.minecraft.item.{Item, ItemStack}
import net.minecraftforge.fluids.BlockFluidFinite
import resonant.content.loader.{ContentHolder, ExplicitContentName}
import resonant.lib.ore.OreGenerator
import resonantinduction.core.content.BlockIndustrialStone
import resonantinduction.core.content.BlockDecoration
import resonantinduction.core.resource.fluid.ItemResourceBucket
import resonantinduction.core.resource.{ItemResourceDust, TileDust}
@ -50,7 +50,7 @@ object CoreContent extends ContentHolder
var generationOreCopper: OreGenerator = null
var generationOreTin: OreGenerator = null
val decoration: Block = new BlockIndustrialStone()
val decoration: Block = new BlockDecoration()
@ExplicitContentName("dust")
val blockDust: Block = new TileDust().setCreativeTab(null)
@ExplicitContentName("refinedDust")
@ -86,11 +86,11 @@ object CoreContent extends ContentHolder
* Decoration
*/
recipes += shaped(new ItemStack(decoration, 8, 3), "XXX", "XCX", "XXX", 'X', Blocks.cobblestone, 'C', new ItemStack(Items.coal, 1, 1))
recipes +=(decoration, 3, new ItemStack(decoration, 1, 5), 5)
recipes +=(decoration, new ItemStack(decoration, 1, 4), 5)
recipes += (new ItemStack(decoration, 3), new ItemStack(decoration, 1, 5), 5)
recipes += (decoration, new ItemStack(decoration, 1, 4), 5)
recipes += shaped(new ItemStack(decoration, 8, 7), "XXX", "XVX", "XXX", 'X', new ItemStack(decoration), 'V', Blocks.vine)
recipes += shaped(new ItemStack(decoration, 4), "XX ", "XX ", " ", 'X', new ItemStack(decoration, 1, 5))
recipes += shaped(new ItemStack(decoration, 4, 1), "XXX", "XXX", "XX ", 'X', Blocks.stoneSingleSlab)
recipes += shaped(new ItemStack(decoration, 4, 1), "XXX", "XXX", "XX ", 'X', Blocks.stone_slab)
recipes += shaped(new ItemStack(decoration, 8, 2), "XXX", "X X", "XXX", 'X', new ItemStack(decoration, 1, 5))
recipes += shaped(new ItemStack(decoration, 5, 10), "IXI", "XXX", "IXI", 'X', new ItemStack(decoration, 1, 5), 'I', Items.iron_ingot)
}

View file

@ -1,79 +0,0 @@
package resonantinduction.core;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import universalelectricity.core.transform.vector.Vector3;
import universalelectricity.api.vector.VectorWorld;
import codechicken.lib.vec.BlockCoord;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
/**
* General Utilities
*
* @author Calclavia
*
*/
public class MultipartUtility
{
public static TileMultipart getMultipartTile(IBlockAccess access, BlockCoord pos)
{
TileEntity te = access.getBlockTileEntity(pos.x, pos.y, pos.z);
return te instanceof TileMultipart ? (TileMultipart) te : null;
}
public static TMultiPart getMultipart(World world, Vector3 vector, int partMap)
{
return getMultipart(new VectorWorld(world, vector), partMap);
}
public static TMultiPart getMultipart(VectorWorld vector, int partMap)
{
return getMultipart(vector.world, vector.xi(), vector.yi(), vector.zi(), partMap);
}
public static TMultiPart getMultipart(World world, int x, int y, int z, int partMap)
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileMultipart)
{
return ((TileMultipart) tile).partMap(partMap);
}
return null;
}
public static boolean canPlaceWireOnSide(World w, int x, int y, int z, ForgeDirection side, boolean _default)
{
if (!w.blockExists(x, y, z))
return _default;
Block b = Block.blocksList[w.getBlockId(x, y, z)];
if (b == null)
return false;
// Manual list of allowed blocks that wire can sit on.
if (b == Block.glowStone || b == Block.pistonBase || b == Block.pistonStickyBase || b == Block.pistonMoving)
return true;
return b.isBlockSolidOnSide(w, x, y, z, side);
}
public static int isDye(ItemStack is)
{
String[] dyes = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" };
for (int i = 0; i < dyes.length; i++)
{
if (OreDictionary.getOreID(is) != -1 && OreDictionary.getOreName(OreDictionary.getOreID(is)).equals(dyes[i]))
return i;
}
return -1;
}
}

View file

@ -7,19 +7,20 @@ import java.util.logging.Logger
*
* @author Calclavia
*/
object Reference
final object Reference
{
final val idPrefix = "ResonantInduction"
final val coreID = idPrefix + ":Core"
/** The official name of the mod */
final val name: String = "Resonant Induction"
final val name = "Resonant Induction"
final val logger = Logger.getLogger(Reference.name)
final val majorVersion: String = "@MAJOR@"
final val minorVersion: String = "@MINOR@"
final val revisionVersion: String = "@REVIS@"
final val build: String = "@BUILD@"
final val version: String = majorVersion + "." + minorVersion + "." + revisionVersion
final val majorVersion = "@MAJOR@"
final val minorVersion = "@MINOR@"
final val revisionVersion = "@REVIS@"
final val build = "@BUILD@"
final val version = majorVersion + "." + minorVersion + "." + revisionVersion
final val channel: String = "resonindc"
/**
* Directory Information

View file

@ -17,13 +17,10 @@ import resonantinduction.core.resource.ResourceGenerator
/** The core module of Resonant Induction
*
* @author Calclavia */
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = Reference.version, modLanguage = "scala", dependencies = "required-after:ForgeMultipart@[1.0.0.244,);required-after:ResonantEngine;before:ThermalExpansion;before:Mekanism")
@Mod(modid = Reference.coreID, name = Reference.name, version = Reference.version, modLanguage = "scala", dependencies = "required-after:ForgeMultipart@[1.0.0.244,);required-after:ResonantEngine;before:ThermalExpansion;before:Mekanism")
@ModstatInfo(prefix = "resonantin")
object ResonantInduction
{
/** Mod Information */
final val ID: String = Reference.idPrefix + ":Core"
/** Packets */
val packetHandler = new PacketManager(Reference.channel)
val loadables = new LoadableHandler
@ -43,13 +40,13 @@ object ResonantInduction
/**
* Registrations
*/
NetworkRegistry.instance.registerGuiHandler(this, proxy)
NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy)
Modstats.instance.getReporter.registerMod(this)
Settings.config = new Configuration(event.getSuggestedConfigurationFile)
Settings.config = new Configuration(evt.getSuggestedConfigurationFile)
ConfigHandler.sync(Settings, Settings.config)
MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE)
MinecraftForge.EVENT_BUS.register(ResourceGenerator)
MinecraftForge.EVENT_BUS.register(new TextureHookHandler)
loadables.applyModule(proxy)
@ -58,7 +55,7 @@ object ResonantInduction
proxy.preInit()
ResonantTab.itemStack = new ItemStack(blockIndustrialStone)
ResonantTab.itemStack = new ItemStack(CoreContent.decoration)
}
@EventHandler

View file

@ -1,13 +1,13 @@
package resonantinduction.core
import cpw.mods.fml.common.eventhandler.SubscribeEvent
import net.minecraft.item.ItemStack
import net.minecraft.block.Block
import net.minecraftforge.common.config.Configuration
import resonant.api.recipe.QuantumAssemblerRecipes
import resonant.lib.config.Config
import resonant.lib.config.ConfigEvent.PostConfigEvent
import resonant.lib.prefab.poison.PotionRadiation
import scala.collection.convert.wrapAll._
/** @author Calclavia */
object Settings
{
@ -50,27 +50,14 @@ object Settings
@Config var waterPerDeutermium: Int = 4
@Config var deutermiumPerTritium: Int = 4
@Config(comment = "Put a list of block/item IDs to be used by the Quantum Assembler. Separate by commas, no space.")
var quantumAssemblerRecipes: Array[Int] = new Array[Int](0)
var quantumAssemblerRecipes: Array[String] = _
@Config var darkMatterSpawnChance: Double = 0.2
@Config var steamMultiplier: Double = 1
@SubscribeEvent
def configEvent(evt: PostConfigEvent)
{
for (recipeID <- quantumAssemblerRecipes)
{
try
{
QuantumAssemblerRecipes.addRecipe(new ItemStack(recipeID, 1, 0))
}
catch
{
case e: Exception =>
{
e.printStackTrace
}
}
}
QuantumAssemblerRecipes.RECIPES.addAll(quantumAssemblerRecipes.map(Block.blockRegistry.getObject(_).asInstanceOf[Block]).toSet)
PotionRadiation.INSTANCE.getId
}
}

View file

@ -6,7 +6,7 @@ import net.minecraft.block.Block
import net.minecraft.block.material.Material
import net.minecraft.client.renderer.texture.IIconRegister
import net.minecraft.creativetab.CreativeTabs
import net.minecraft.item.ItemStack
import net.minecraft.item.{Item, ItemStack}
import net.minecraft.util.IIcon
import resonant.content.spatial.block.SpatialBlock
import resonant.lib.wrapper.WrapList._
@ -18,16 +18,16 @@ import resonantinduction.core.Reference
* @author Calclavia
*
*/
object BlockIndustrialStone
object BlockDecoration
{
var iconNames = Array("material_stone_brick", "material_stone_brick2", "material_stone_chiseled", "material_stone_cobble", "material_stone_cracked", "material_stone", "material_stone_slab", "material_stone_mossy", "material_steel_dark", "material_steel_tint", "material_steel")
var icons = new Array[IIcon](iconNames.length)
}
class BlockIndustrialStone extends SpatialBlock(Material.rock)
class BlockDecoration extends SpatialBlock(Material.rock)
{
blockHardness = 1
stepSound = Block.soundStoneFootstep
stepSound = Block.soundTypeStone
def damageDropped(par1: Int): Int =
{
@ -36,18 +36,17 @@ class BlockIndustrialStone extends SpatialBlock(Material.rock)
override def getIcon(side: Int, metadata: Int): IIcon =
{
return icons(metadata)
return BlockDecoration.icons(metadata)
}
override def registerIcons(register: IIconRegister)
{
super.registerIcons(register)
(0 until BlockIndustrialStone.icons.size) foreach (i => BlockIndustrialStone.icons(i) = register.registerIcon(Reference.prefix + iconNames(i)))
(0 until BlockDecoration.icons.size) foreach (i => BlockDecoration.icons(i) = register.registerIcon(Reference.prefix + BlockDecoration.iconNames(i)))
}
def getSubBlocks(par1: Int, par2CreativeTabs: CreativeTabs, list: List[_])
override def getSubBlocks(item: Item, par2CreativeTabs: CreativeTabs, list: List[_])
{
(0 until iconNames.length) foreach (i => list.add(new ItemStack(par1, 1, i)))
(0 until BlockDecoration.iconNames.length) foreach (i => list.add(new ItemStack(item, 1, i)))
}
}

View file

@ -2,11 +2,11 @@ package resonantinduction.core.grid
import codechicken.multipart.{PartMap, TileMultipart}
import net.minecraftforge.common.util.ForgeDirection
import universalelectricity.api.core.grid.INodeProvider
import universalelectricity.api.core.grid.{INode, INodeProvider}
trait TraitNodeProvider extends TileMultipart with INodeProvider
{
def getNode[N](nodeType: Class[N], from: ForgeDirection): N =
def getNode[N <: INode](nodeType: Class[N], from: ForgeDirection): N =
{
var part = partMap(from.ordinal)
@ -16,9 +16,9 @@ trait TraitNodeProvider extends TileMultipart with INodeProvider
}
if (part.isInstanceOf[INodeProvider])
{
return (part.asInstanceOf[INodeProvider]).getNode(nodeType, from)
return part.asInstanceOf[INodeProvider].getNode(nodeType, from)
}
return null
return null.asInstanceOf[N]
}
}

View file

@ -66,7 +66,7 @@ abstract class TileFluidNode(material: Material) extends SpatialTile(material) w
{
super.writeToNBT(nbt)
nbt.setInteger("colorID", colorID)
nbt.setCompoundTag("FluidTank", tank.writeToNBT(new NBTTagCompound))
nbt.setTag("FluidTank", tank.writeToNBT(new NBTTagCompound))
}
def write(buf: ByteBuf, id: Int)
@ -98,20 +98,20 @@ abstract class TileFluidNode(material: Material) extends SpatialTile(material) w
{
if (id == TileFluidNode.PACKET_DESCRIPTION)
{
colorID = data.readInt
renderSides = data.readByte
colorID = buf.readInt
renderSides = buf.readByte
tank = buf.readTank()
}
else if (id == TileFluidNode.PACKET_RENDER)
{
colorID = data.readInt
renderSides = data.readByte
colorID = buf.readInt
renderSides = buf.readByte
markRender
}
else if (id == TileFluidNode.PACKET_TANK)
{
tank = buf.readTank()
pressure = data.readInt
pressure = buf.readInt
updateLight()
}
}
@ -135,7 +135,7 @@ abstract class TileFluidNode(material: Material) extends SpatialTile(material) w
{
if (!worldObj.isRemote)
{
if (!FluidUtility.matchExact(prevStack, tank.getFluid) || ticks eq 0)
if (!FluidUtility.matchExact(prevStack, tank.getFluid) || ticks == 0)
{
markTankUpdate = true
prevStack = if (tank.getFluid != null) tank.getFluid.copy else null

View file

@ -0,0 +1,72 @@
package resonantinduction.core.prefab.part
import codechicken.lib.vec.BlockCoord
import codechicken.multipart.{TMultiPart, TileMultipart}
import net.minecraft.block.Block
import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack
import net.minecraft.tileentity.TileEntity
import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.oredict.OreDictionary
import universalelectricity.core.transform.vector.{Vector3, VectorWorld}
/**
* Multipart Utilities
*
* @author Calclavia
*
*/
object MultipartUtility
{
def getMultipartTile(access: IBlockAccess, pos: BlockCoord): TileMultipart =
{
val te: TileEntity = access.getTileEntity(pos.x, pos.y, pos.z)
return if (te.isInstanceOf[TileMultipart]) te.asInstanceOf[TileMultipart] else null
}
def getMultipart(world: World, vector: Vector3, partMap: Int): TMultiPart =
{
return getMultipart(new VectorWorld(world, vector), partMap)
}
def getMultipart(vector: VectorWorld, partMap: Int): TMultiPart =
{
return getMultipart(vector.world, vector.xi, vector.yi, vector.zi, partMap)
}
def getMultipart(world: World, x: Int, y: Int, z: Int, partMap: Int): TMultiPart =
{
val tile: TileEntity = world.getTileEntity(x, y, z)
if (tile.isInstanceOf[TileMultipart])
{
return (tile.asInstanceOf[TileMultipart]).partMap(partMap)
}
return null
}
def canPlaceWireOnSide(w: World, x: Int, y: Int, z: Int, side: ForgeDirection, _default: Boolean): Boolean =
{
if (!w.blockExists(x, y, z)) return _default
val b: Block = w.getBlock(x, y, z)
if (b == null) return false
if (b eq Blocks.glowstone || b eq Blocks.piston || b eq Blocks.sticky_piston || b eq Blocks.piston_extension) return true
return b.isSideSolid(w, x, y, z, side)
}
def isDye(is: ItemStack): Int =
{
val dyes: Array[String] = Array("dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite")
{
var i: Int = 0
while (i < dyes.length)
{
{
if (OreDictionary.getOreID(is) != -1 && (OreDictionary.getOreName(OreDictionary.getOreID(is)) == dyes(i))) return i
}
({i += 1; i - 1 })
}
}
return -1
}
}

View file

@ -1,247 +0,0 @@
package resonantinduction.core.prefab.part;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.BlockColored;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemShears;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import resonantinduction.core.MultipartUtility;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
/**
* @author Calclavia
*
*/
public abstract class PartColorableMaterial<M extends Enum> extends TraitPart
{
public static final int DEFAULT_COLOR = 15;
public int color = DEFAULT_COLOR;
public M material;
public boolean isInsulated = false;
public boolean requiresInsulation = true;
protected final Item insulationType;
public PartColorableMaterial(Item insulationType)
{
this.insulationType = insulationType;
}
/**
* Material Methods
*/
public M getMaterial()
{
return material;
}
public void setMaterial(M material)
{
this.material = material;
}
public abstract void setMaterial(int i);
public int getMaterialID()
{
return material.ordinal();
}
/**
* Insulation Methods
*/
public void setInsulated(boolean insulated)
{
this.isInsulated = insulated;
this.color = DEFAULT_COLOR;
if (!this.world().isRemote)
{
tile().notifyPartChange(this);
this.sendInsulationUpdate();
}
}
public void setInsulated(int dyeColour)
{
this.isInsulated = true;
this.color = dyeColour;
if (!this.world().isRemote)
{
tile().notifyPartChange(this);
this.sendInsulationUpdate();
this.sendColorUpdate();
}
}
public boolean isInsulated()
{
return this.isInsulated;
}
public void sendInsulationUpdate()
{
tile().getWriteStream(this).writeByte(1).writeBoolean(this.isInsulated);
}
/**
* Wire Coloring Methods
*/
public int getColor()
{
return isInsulated || !requiresInsulation ? color : -1;
}
public void setColor(int dye)
{
if (isInsulated || !requiresInsulation)
{
this.color = dye;
if (!world().isRemote)
{
tile().notifyPartChange(this);
onPartChanged(this);
this.sendColorUpdate();
}
}
}
public void sendColorUpdate()
{
tile().getWriteStream(this).writeByte(2).writeInt(this.color);
}
/**
* Changes the wire's color.
*/
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack itemStack)
{
if (itemStack != null)
{
int dyeColor = MultipartUtility.isDye(itemStack);
if (dyeColor != -1 && (isInsulated() || !requiresInsulation))
{
if (!player.capabilities.isCreativeMode && requiresInsulation)
{
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
this.setColor(dyeColor);
return true;
}
else if (requiresInsulation)
{
if (itemStack.getItem() == insulationType)
{
if (this.isInsulated())
{
if (!world().isRemote && player.capabilities.isCreativeMode)
{
tile().dropItems(Collections.singletonList(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color))));
}
this.setInsulated(false);
return true;
}
else
{
if (!player.capabilities.isCreativeMode)
{
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
this.setInsulated(BlockColored.getDyeFromBlock(itemStack.getItemDamage()));
return true;
}
}
else if (itemStack.getItem() instanceof ItemShears && isInsulated())
{
if (!world().isRemote && !player.capabilities.isCreativeMode)
{
tile().dropItems(Collections.singletonList(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color))));
}
this.setInsulated(false);
}
return true;
}
}
return false;
}
@Override
public Iterable<ItemStack> getDrops()
{
List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(getItem());
if (requiresInsulation && isInsulated)
{
drops.add(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color)));
}
return drops;
}
@Override
public void readDesc(MCDataInput packet)
{
this.setMaterial(packet.readByte());
this.color = packet.readByte();
this.isInsulated = packet.readBoolean();
}
@Override
public void writeDesc(MCDataOutput packet)
{
packet.writeByte((byte) this.getMaterialID());
packet.writeByte((byte) this.color);
packet.writeBoolean(this.isInsulated);
}
public void read(MCDataInput packet, int packetID)
{
switch (packetID)
{
case 1:
this.isInsulated = packet.readBoolean();
this.tile().markRender();
break;
case 2:
this.color = packet.readInt();
this.tile().markRender();
break;
}
}
@Override
public void save(NBTTagCompound nbt)
{
super.save(nbt);
nbt.setInteger("typeID", getMaterialID());
nbt.setBoolean("isInsulated", isInsulated);
nbt.setInteger("dyeID", color);
}
@Override
public void load(NBTTagCompound nbt)
{
super.load(nbt);
setMaterial(nbt.getInteger("typeID"));
this.isInsulated = nbt.getBoolean("isInsulated");
this.color = nbt.getInteger("dyeID");
}
}

View file

@ -0,0 +1,226 @@
package resonantinduction.core.prefab.part
import java.util.ArrayList
import java.util.Collections
import java.util.List
import codechicken.multipart.TMultiPart
import net.minecraft.block.BlockColored
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.Item
import net.minecraft.item.ItemShears
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.MovingObjectPosition
import codechicken.lib.data.MCDataInput
import codechicken.lib.data.MCDataOutput
/**
* @author Calclavia
*
*/
object PartColorableMaterial
{
final val DEFAULT_COLOR: Int = 15
}
abstract class PartColorableMaterial[M](insulationType: Item) extends TMultiPart with TraitPart
{
var color: Int = DEFAULT_COLOR
var material: M = null
var isInsulated: Boolean = false
var requiresInsulation: Boolean = true
/**
* Material Methods
*/
def getMaterial: M =
{
return material
}
def setMaterial(material: M)
{
this.material = material
}
def setMaterial(i: Int)
def getMaterialID: Int =
{
return material.ordinal
}
/**
* Insulation Methods
*/
def setInsulated(insulated: Boolean)
{
this.isInsulated = insulated
this.color = DEFAULT_COLOR
if (!this.world.isRemote)
{
tile.notifyPartChange(this)
this.sendInsulationUpdate
}
}
def setInsulated(dyeColour: Int)
{
this.isInsulated = true
this.color = dyeColour
if (!this.world.isRemote)
{
tile.notifyPartChange(this)
this.sendInsulationUpdate
this.sendColorUpdate
}
}
def insulated: Boolean =
{
return this.isInsulated
}
def sendInsulationUpdate
{
tile.getWriteStream(this).writeByte(1).writeBoolean(this.isInsulated)
}
/**
* Wire Coloring Methods
*/
def getColor: Int =
{
return if (isInsulated || !requiresInsulation) color else -1
}
def setColor(dye: Int)
{
if (isInsulated || !requiresInsulation)
{
this.color = dye
if (!world.isRemote)
{
tile.notifyPartChange(this)
onPartChanged(this)
this.sendColorUpdate
}
}
}
def sendColorUpdate
{
tile.getWriteStream(this).writeByte(2).writeInt(this.color)
}
/**
* Changes the wire's color.
*/
override def activate(player: EntityPlayer, part: MovingObjectPosition, itemStack: ItemStack): Boolean =
{
if (itemStack != null)
{
val dyeColor: Int = MultipartUtility.isDye(itemStack)
if (dyeColor != -1 && (isInsulated || !requiresInsulation))
{
if (!player.capabilities.isCreativeMode && requiresInsulation)
{
player.inventory.decrStackSize(player.inventory.currentItem, 1)
}
this.setColor(dyeColor)
return true
}
else if (requiresInsulation)
{
if (itemStack.getItem eq insulationType)
{
if (this.isInsulated)
{
if (!world.isRemote && player.capabilities.isCreativeMode)
{
tile.dropItems(Collections.singletonList(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color))))
}
this.setInsulated(false)
return true
}
else
{
if (!player.capabilities.isCreativeMode)
{
player.inventory.decrStackSize(player.inventory.currentItem, 1)
}
this.setInsulated(BlockColored.getDyeFromBlock(itemStack.getItemDamage))
return true
}
}
else if (itemStack.getItem.isInstanceOf[ItemShears] && isInsulated)
{
if (!world.isRemote && !player.capabilities.isCreativeMode)
{
tile.dropItems(Collections.singletonList(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color))))
}
this.setInsulated(false)
}
return true
}
}
return false
}
override def getDrops: Iterable[ItemStack] =
{
val drops: List[ItemStack] = new ArrayList[ItemStack]
drops.add(getItem)
if (requiresInsulation && isInsulated)
{
drops.add(new ItemStack(insulationType, 1, BlockColored.getBlockFromDye(color)))
}
return drops
}
override def readDesc(packet: MCDataInput)
{
this.setMaterial(packet.readByte)
this.color = packet.readByte
this.isInsulated = packet.readBoolean
}
override def writeDesc(packet: MCDataOutput)
{
packet.writeByte(this.getMaterialID.asInstanceOf[Byte])
packet.writeByte(this.color.asInstanceOf[Byte])
packet.writeBoolean(this.isInsulated)
}
def read(packet: MCDataInput, packetID: Int)
{
packetID match
{
case 1 =>
this.isInsulated = packet.readBoolean
this.tile.markRender
break //todo: break is not supported
case 2 =>
this.color = packet.readInt
this.tile.markRender
break //todo: break is not supported
}
}
override def save(nbt: NBTTagCompound)
{
super.save(nbt)
nbt.setInteger("typeID", getMaterialID)
nbt.setBoolean("isInsulated", isInsulated)
nbt.setInteger("dyeID", color)
}
override def load(nbt: NBTTagCompound)
{
super.load(nbt)
setMaterial(nbt.getInteger("typeID"))
this.isInsulated = nbt.getBoolean("isInsulated")
this.color = nbt.getInteger("dyeID")
}
}

View file

@ -126,7 +126,7 @@ object ResourceGenerator
}
}
def generateOreResources
def generateOreResources()
{
OreDictionary.registerOre("ingotGold", Item.ingotGold)
OreDictionary.registerOre("ingotIron", Item.ingotIron)

View file

@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import resonantinduction.core.MultipartUtility;
import resonantinduction.core.prefab.part.MultipartUtility;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.ControlKeyModifer;

View file

@ -25,7 +25,7 @@ import resonant.lib.render.EnumColor;
import resonant.lib.utility.LinkUtility;
import resonant.lib.utility.WrenchUtility;
import resonant.lib.utility.inventory.InventoryUtility;
import resonantinduction.core.MultipartUtility;
import resonantinduction.core.prefab.part.MultipartUtility;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.part.PartFace;
import resonantinduction.electrical.Electrical;

View file

@ -14,7 +14,7 @@ import resonant.lib.render.block.BlockRenderingHandler;
import resonant.lib.utility.LanguageUtility;
import resonant.lib.utility.LinkUtility;
import resonant.lib.utility.WrenchUtility;
import resonantinduction.core.MultipartUtility;
import resonantinduction.core.prefab.part.MultipartUtility;
import resonantinduction.core.Reference;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.vector.VectorWorld;

View file

@ -14,7 +14,7 @@ import org.lwjgl.input.Keyboard;
import resonant.lib.render.EnumColor;
import resonant.lib.utility.LanguageUtility;
import resonantinduction.core.MultipartUtility;
import resonantinduction.core.prefab.part.MultipartUtility;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantTab;
import resonantinduction.electrical.wire.flat.PartFlatWire;

View file

@ -14,7 +14,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection;
import resonant.lib.prefab.damage.ElectricalDamage;
import resonantinduction.core.MultipartUtility;
import resonantinduction.core.prefab.part.MultipartUtility;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.electricity.IElectricalNetwork;
import universalelectricity.api.energy.IConductor;

View file

@ -16,7 +16,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import resonantinduction.core.MultipartUtility;
import resonantinduction.core.prefab.part.MultipartUtility;
import resonantinduction.electrical.wire.EnumWireMaterial;
import resonantinduction.electrical.wire.PartAdvancedWire;
import codechicken.lib.colour.Colour;